diff --git a/.clang-format b/.clang-format index f0d042c27..7ab3cb079 100644 --- a/.clang-format +++ b/.clang-format @@ -47,13 +47,20 @@ DerivePointerAlignment: true DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeBlocks: Merge IncludeCategories: - - Regex: '^<.*\.h>' + - Regex: '^.*.h"' Priority: 1 - - Regex: '^<.*' + - Regex: '^.*(boost|gflags|glog|gnsssdr|gpstk|gtest|gnuradio|pmt|uhd|volk)/' + Priority: 2 + - Regex: '^.*(armadillo|matio|pugixml)' Priority: 2 - Regex: '.*' Priority: 3 + - Regex: '^<.*\.h>' + Priority: 4 + - Regex: '^<.*' + Priority: 5 IndentCaseLabels: false IndentWidth: 4 IndentWrappedFunctionNames: false @@ -73,7 +80,7 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left ReflowComments: true -SortIncludes: false +SortIncludes: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..bfb1b252c --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,130 @@ +--- +Checks: '-*, + boost-use-to-string, + cert-dcl21-cpp, + cert-dcl58-cpp, + cert-env33-c, + cert-err52-cpp, + cert-err60-cpp, + cert-flp30-c, + clang-analyzer-cplusplus*, + cppcoreguidelines-pro-type-static-cast-downcast, + cppcoreguidelines-slicing, + google-build-namespaces, + google-runtime-int, + misc-misplaced-const, + misc-new-delete-overloads, + misc-non-copyable-objects, + misc-static-assert, + misc-throw-by-value-catch-by-reference, + misc-uniqueptr-reset-release, + misc-unused-using-decls, + modernize-loop-convert, + modernize-pass-by-value, + modernize-raw-string-literal, + modernize-use-auto, + modernize-use-bool-literals, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-noexcept, + modernize-use-nullptr, + performance-faster-string-find, + performance-inefficient-algorithm, + performance-move-const-arg, + performance-type-promotion-in-math-fn, + performance-unnecessary-copy-initialization, + performance-unnecessary-value-param, + readability-container-size-empty, + readability-identifier-naming, + readability-inconsistent-declaration-parameter-name, + readability-named-parameter, + readability-non-const-parameter, + readability-string-compare' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +FormatStyle: 'file' +CheckOptions: + - key: google-build-namespaces.HeaderFileExtensions + value: ',h' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: google-runtime-int.SignedTypePrefix + value: int + - key: google-runtime-int.TypeSuffix + value: _t + - key: google-runtime-int.UnsignedTypePrefix + value: uint + - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries + value: '1' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-pass-by-value.ValuesOnly + value: '0' + - key: modernize-raw-string-literal.ReplaceShorterLiterals + value: '0' + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-use-auto.MinTypeNameLength + value: '5' + - key: modernize-use-auto.RemoveStars + value: '0' + - key: modernize-use-equals-default.IgnoreMacros + value: '1' + - key: modernize-use-noexcept.ReplacementString + value: '' + - key: modernize-use-noexcept.UseNoexceptFalse + value: '1' + - key: modernize-use-nullptr.NullMacros + value: 'NULL' + - key: performance-faster-string-find.StringLikeClasses + value: 'std::basic_string' + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: '1' + - key: performance-type-promotion-in-math-fn.IncludeStyle + value: llvm + - key: performance-unnecessary-value-param.IncludeStyle + value: llvm + - key: readability-identifier-naming.AbstractClassCase + value: CamelCase + - key: readability-identifier-naming.AbstractClassPrefix + value: '' + - key: readability-identifier-naming.AbstractClassSuffix + value: '' + - key: readability-identifier-naming.ClassCase + value: Camel_Snake_Case + - key: readability-identifier-naming.ClassPrefix + value: '' + - key: readability-identifier-naming.ClassSuffix + value: '' + - key: readability-identifier-naming.GlobalConstantCase + value: UPPER_CASE + - key: readability-identifier-naming.GlobalConstantPrefix + value: '' + - key: readability-identifier-naming.GlobalConstantSuffix + value: '' + - key: readability-identifier-naming.IgnoreFailedSplit + value: '0' + - key: readability-identifier-naming.StructCase + value: aNy_CasE + - key: readability-identifier-naming.StructPrefix + value: '' + - key: readability-identifier-naming.StructSuffix + value: '' + - key: readability-inconsistent-declaration-parameter-name.IgnoreMacros + value: '1' + - key: readability-inconsistent-declaration-parameter-name.Strict + value: '0' +... diff --git a/AUTHORS b/AUTHORS index 0416cfe97..6f98d2038 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,56 +1,58 @@ -GNSS-SDR Authorship ------------------------------------------------------------------------------- - -The GNSS-SDR project is hosted and sponsored by the Centre Tecnologic de -Telecomunicacions de Catalunya (CTTC), a non-profit research foundation located -in Castelldefels (40.396764 N, 3.713379 E), 20 km south of Barcelona, Spain. -GNSS-SDR is the by-product of GNSS research conducted at the Communications -Systems Division of CTTC, and it is the combined effort of students, -software engineers and researchers from different institutions around the World. - -Contact Information ------------------------------------------------------------------------------- - GNSS-SDR Homepage - ---------------------------- - https://gnss-sdr.org - - - CTTC Homepage - ---------------------------- - http://www.cttc.cat - - - Mailing Lists - ---------------------------- - gnss-sdr-developers@lists.sourceforge.net - https://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers - - - Email - ---------------------------- - Inquiries beyond the mailing list can be sent to carles.fernandez@cttc.cat - - -List of authors ------------------------------------------------------------------------------- -Carles Fernandez-Prades carles.fernandez@cttc.cat Project manager -Javier Arribas javier.arribas@cttc.es Developer -Luis Esteve Elfau luis@epsilon-formacion.com Developer -Antonio Ramos antonio.ramos@cttc.es Developer -Marc Majoral marc.majoral@cttc.cat Developer -Pau Closas pau.closas@northeastern.edu Consultant -Jordi Vila-Valls jordi.vila@cttc.cat Consultant -Carlos Aviles carlos.avilesr@googlemail.com Contributor -David Pubill david.pubill@cttc.cat Contributor -Mara Branzanti mara.branzanti@gmail.com Contributor -Marc Molina marc.molina.pena@gmail.com Contributor -Daniel Fehr daniel.co@bluewin.ch Contributor -Marc Sales marcsales92@gmail.com Contributor -Damian Miralles dmiralles2009@gmail.com Contributor -Andres Cecilia Luque a.cecilia.luque@gmail.com Contributor -Leonardo Tonetto tonetto.dev@gmail.com Contributor -Anthony Arnold anthony.arnold@uqconnect.edu.au Contributor -Fran Fabra fabra@ice.csic.es Contributor -Cillian O'Driscoll cillian.odriscoll@gmail.com Contributor -Gabriel Araujo gabriel.araujo.5000@gmail.com Contributor -Carlos Paniego carpanie@hotmail.com Artwork +GNSS-SDR Authorship +------------------------------------------------------------------------------ + +The GNSS-SDR project is hosted and sponsored by the Centre Tecnològic de +Telecomunicacions de Catalunya (CTTC), a non-profit research foundation located +in Castelldefels (41.27504 N, 1.987709 E), 20 km south of Barcelona, Spain. +GNSS-SDR is the by-product of GNSS research conducted at the Communications +Systems Division of CTTC, and it is the combined effort of students, +software engineers and researchers from different institutions around the World. + +Contact Information +------------------------------------------------------------------------------ + GNSS-SDR Homepage + ---------------------------- + https://gnss-sdr.org + + + CTTC Homepage + ---------------------------- + http://www.cttc.cat + + + Mailing Lists + ---------------------------- + gnss-sdr-developers@lists.sourceforge.net + https://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers + + + Email + ---------------------------- + Inquiries beyond the mailing list can be sent to carles.fernandez@cttc.cat + + +List of authors +------------------------------------------------------------------------------ +Carles Fernández-Prades carles.fernandez@cttc.cat Project manager +Javier Arribas javier.arribas@cttc.es Developer +Luis Esteve Elfau luis@epsilon-formacion.com Developer +Antonio Ramos antonio.ramosdet@gmail.com Developer +Marc Majoral marc.majoral@cttc.cat Developer +Jordi Vilà-Valls jordi.vila@cttc.cat Consultant +Pau Closas pau.closas@northeastern.edu Consultant +Álvaro Cebrián Juan acebrianjuan@gmail.com Contributor +Andres Cecilia Luque a.cecilia.luque@gmail.com Contributor +Anthony Arnold anthony.arnold@uqconnect.edu.au Contributor +Carlos Avilés carlos.avilesr@googlemail.com Contributor +Cillian O'Driscoll cillian.odriscoll@gmail.com Contributor +Damian Miralles dmiralles2009@gmail.com Contributor +Daniel Fehr daniel.co@bluewin.ch Contributor +David Pubill david.pubill@cttc.cat Contributor +Fran Fabra fabra@ice.csic.es Contributor +Gabriel Araujo gabriel.araujo.5000@gmail.com Contributor +Gerald LaMountain gerald@gece.neu.edu Contributor +Leonardo Tonetto tonetto.dev@gmail.com Contributor +Mara Branzanti mara.branzanti@gmail.com Contributor +Marc Molina marc.molina.pena@gmail.com Contributor +Marc Sales marcsales92@gmail.com Contributor +Carlos Paniego carpanie@hotmail.com Artwork diff --git a/CMakeLists.txt b/CMakeLists.txt index fbdd1fd67..492169801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -21,9 +21,9 @@ ######################################################################## if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(WARNING "In-tree build is bad practice. Try 'cd build && cmake ../' ") -endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) +endif() -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(gnss-sdr CXX C) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) @@ -31,32 +31,36 @@ file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRE if(NOT CMAKE_PREFIX_PATH) if(DEFINED ENV{PYBOMBS_PREFIX}) set(CMAKE_PREFIX_PATH $ENV{PYBOMBS_PREFIX}) - endif(DEFINED ENV{PYBOMBS_PREFIX}) + endif() if(DEFINED ENV{SNAP}) set(CMAKE_PREFIX_PATH $ENV{SNAP}) - endif(DEFINED ENV{SNAP}) -endif(NOT CMAKE_PREFIX_PATH) + endif() +endif() ######################################################################## # Determine optional blocks/libraries to be built (default: not built) -# Enable them at the command line by doing 'cmake -DENABLE_XXX=ON ../' +# Enable them at the command line by doing 'cmake -DENABLE_XXX=ON ..' ######################################################################## # Support of optional RF front-ends option(ENABLE_UHD "Enable the use of UHD (driver for all USRP devices)" ON) -option(ENABLE_OSMOSDR "Enable the use of OsmoSDR and other front-ends (RTL-based dongles, HackRF, bladeRF, etc.) as signal source (experimental)" OFF) +option(ENABLE_OSMOSDR "Enable the use of OsmoSDR and other front-ends (RTL-based dongles, HackRF, bladeRF, etc.) as signal source" OFF) option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Teleorbit Flexiband GNURadio driver" OFF) option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF) option(ENABLE_GN3S "Enable the use of the GN3S dongle as signal source (experimental)" OFF) option(ENABLE_PLUTOSDR "Enable the use of ADALM-PLUTO Evaluation Boards (Analog Devices Inc.), requires gr-iio" OFF) option(ENABLE_FMCOMMS2 "Enable the use of FMCOMMS4-EBZ + ZedBoard hardware, requires gr-iio" OFF) -option(ENABLE_AD9361 "Enable the use of AD9361 directo to FPGA hardware, requires gr-iio" OFF) +option(ENABLE_AD9361 "Enable the use of AD9361 directo to FPGA hardware, requires libiio" OFF) +option(ENABLE_RAW_UDP "Enable the use of high-optimized custom UDP packet sample source, requires libpcap" OFF) # Performance analysis tools option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF) option(ENABLE_GPROF "Enable the use of the GNU profiler tool 'gprof'" OFF) +# Code correctness +option(ENABLE_CLANG_TIDY "Enable the use of clang-tidy when compiling" OFF) + # Acceleration option(ENABLE_PROFILING "Enable execution of volk_gnsssdr_profile at the end of the building" OFF) option(ENABLE_OPENCL "Enable building of processing blocks implemented with OpenCL (experimental)" OFF) @@ -71,21 +75,22 @@ option(ENABLE_OWN_ARMADILLO "Download and build Armadillo locally" OFF) option(ENABLE_LOG "Enable logging" ON) if(ENABLE_PACKAGING) set(ENABLE_GENERIC_ARCH ON) -endif(ENABLE_PACKAGING) +endif() # Testing option(ENABLE_UNIT_TESTING "Build unit tests" ON) +option(ENABLE_UNIT_TESTING_MINIMAL "Build a minimal set of unit tests" OFF) option(ENABLE_UNIT_TESTING_EXTRA "Download external files and build extra unit tests" OFF) option(ENABLE_SYSTEM_TESTING "Build system tests" OFF) option(ENABLE_SYSTEM_TESTING_EXTRA "Download external tools and build extra system tests" OFF) if(ENABLE_SYSTEM_TESTING_EXTRA) set(ENABLE_SYSTEM_TESTING ON) -endif(ENABLE_SYSTEM_TESTING_EXTRA) +endif() option(ENABLE_OWN_GPSTK "Force to download, build and link GPSTk for system tests, even if it is already installed" OFF) option(ENABLE_INSTALL_TESTS "Install QA code system-wide" OFF) if(ENABLE_FPGA) set(ENABLE_INSTALL_TESTS ON) -endif(ENABLE_FPGA) +endif() @@ -96,28 +101,27 @@ set(THIS_IS_A_RELEASE OFF) # only related to version name, no further implicat if(NOT ${THIS_IS_A_RELEASE}) # Get the current working branch execute_process( - COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE ) - # Get the latest abbreviated commit hash of the working branch execute_process( - COMMAND git log -1 --format=%h - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND git log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE ) -endif(NOT ${THIS_IS_A_RELEASE}) +endif() set(VERSION_INFO_MAJOR_VERSION 0) -set(VERSION_INFO_API_COMPAT 0) +set(VERSION_INFO_API_COMPAT 0) if(${THIS_IS_A_RELEASE}) - set(VERSION_INFO_MINOR_VERSION 9) -else(${THIS_IS_A_RELEASE}) - set(VERSION_INFO_MINOR_VERSION 9.git-${GIT_BRANCH}-${GIT_COMMIT_HASH}) -endif(${THIS_IS_A_RELEASE}) + set(VERSION_INFO_MINOR_VERSION 10) +else() + set(VERSION_INFO_MINOR_VERSION 10.git-${GIT_BRANCH}-${GIT_COMMIT_HASH}) +endif() set(VERSION ${VERSION_INFO_MAJOR_VERSION}.${VERSION_INFO_API_COMPAT}.${VERSION_INFO_MINOR_VERSION}) @@ -128,195 +132,209 @@ set(VERSION ${VERSION_INFO_MAJOR_VERSION}.${VERSION_INFO_API_COMPAT}.${VERSION_I ######################################################################## include(ExternalProject) # Detect 64-bits machine -if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) - set(ARCH_64BITS TRUE) -endif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ARCH_64BITS TRUE) +endif() set(OS_IS_MACOSX "") set(OS_IS_LINUX "") # Detect Linux Distribution if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(OperatingSystem "Linux") - set(OS_IS_LINUX TRUE) - if(ARCH_64BITS) - set(ARCH_ "(64 bits)") - else(ARCH_64BITS) - set(ARCH_ "(32 bits)") - endif(ARCH_64BITS) - if(EXISTS "/etc/lsb-release") - execute_process(COMMAND cat /etc/lsb-release - COMMAND grep DISTRIB_ID - COMMAND awk -F= "{ print $2 }" - COMMAND tr "\n" " " - COMMAND sed "s/ //" - OUTPUT_VARIABLE LINUX_DISTRIBUTION - RESULT_VARIABLE LINUX_ID_RESULT - ) - execute_process(COMMAND cat /etc/lsb-release - COMMAND grep DISTRIB_RELEASE - COMMAND awk -F= "{ print $2 }" - COMMAND tr "\n" " " - COMMAND sed "s/ //" - OUTPUT_VARIABLE LINUX_VER - RESULT_VARIABLE LINUX_VER_RESULT - ) - endif(EXISTS "/etc/lsb-release") - if(NOT LINUX_DISTRIBUTION) - if(EXISTS "/etc/linuxmint/info") - set(LINUX_DISTRIBUTION "LinuxMint") - execute_process(COMMAND cat /etc/linuxmint/info - COMMAND grep -m1 RELEASE - COMMAND awk -F= "{ print $2 }" - COMMAND tr "\n" " " - COMMAND sed "s/ //" - OUTPUT_VARIABLE LINUX_VER - RESULT_VARIABLE LINUX_VER_RESULT - ) - endif(EXISTS "/etc/linuxmint/info") - endif(NOT LINUX_DISTRIBUTION) - if(NOT LINUX_DISTRIBUTION) - if(EXISTS "/etc/os-release") - execute_process(COMMAND cat /etc/os-release - COMMAND grep -m1 NAME - COMMAND awk -F= "{ print $2 }" - COMMAND tr "\n" " " - COMMAND sed "s/ //" - OUTPUT_VARIABLE LINUX_DISTRIBUTION - RESULT_VARIABLE LINUX_ID_RESULT - ) - execute_process(COMMAND cat /etc/os-release - COMMAND grep VERSION_ID - COMMAND awk -F= "{ print $2 }" - COMMAND tr "\n" " " - COMMAND sed "s/ //" - OUTPUT_VARIABLE LINUX_VER - RESULT_VARIABLE LINUX_VER_RESULT - ) - if(${LINUX_DISTRIBUTION} MATCHES "Debian") - set(LINUX_DISTRIBUTION "Debian") - file(READ /etc/debian_version LINUX_VER) - endif(${LINUX_DISTRIBUTION} MATCHES "Debian") - endif(EXISTS "/etc/os-release") - endif(NOT LINUX_DISTRIBUTION) - if(NOT LINUX_DISTRIBUTION) - if(EXISTS "/etc/redhat-release") - set(LINUX_DISTRIBUTION "Red Hat") - file (READ /etc/redhat-release LINUX_VER) - endif(EXISTS "/etc/redhat-release") - endif(NOT LINUX_DISTRIBUTION) - if(NOT LINUX_DISTRIBUTION) - if(EXISTS "/etc/debian_version") - set(LINUX_DISTRIBUTION "Debian") - file (READ /etc/debian_version LINUX_VER) - endif(EXISTS "/etc/debian_version") - endif(NOT LINUX_DISTRIBUTION) - if(NOT LINUX_DISTRIBUTION) - set(LINUX_DISTRIBUTION "Generic") - set(LINUX_VER "Unknown") - endif(NOT LINUX_DISTRIBUTION) - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on ${LINUX_DISTRIBUTION} GNU/Linux Release ${LINUX_VER} ${ARCH_}") -endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(OperatingSystem "Linux") + set(OS_IS_LINUX TRUE) + if(ARCH_64BITS) + set(ARCH_ "(64 bits)") + else() + set(ARCH_ "(32 bits)") + endif() + if(EXISTS "/etc/lsb-release") + execute_process(COMMAND cat /etc/lsb-release + COMMAND grep DISTRIB_ID + COMMAND awk -F= "{ print $2 }" + COMMAND tr "\n" " " + COMMAND sed "s/ //" + OUTPUT_VARIABLE LINUX_DISTRIBUTION + RESULT_VARIABLE LINUX_ID_RESULT + ) + execute_process(COMMAND cat /etc/lsb-release + COMMAND grep DISTRIB_RELEASE + COMMAND awk -F= "{ print $2 }" + COMMAND tr "\n" " " + COMMAND sed "s/ //" + OUTPUT_VARIABLE LINUX_VER + RESULT_VARIABLE LINUX_VER_RESULT + ) + endif() + if(NOT LINUX_DISTRIBUTION) + if(EXISTS "/etc/linuxmint/info") + set(LINUX_DISTRIBUTION "LinuxMint") + execute_process(COMMAND cat /etc/linuxmint/info + COMMAND grep -m1 RELEASE + COMMAND awk -F= "{ print $2 }" + COMMAND tr "\n" " " + COMMAND sed "s/ //" + OUTPUT_VARIABLE LINUX_VER + RESULT_VARIABLE LINUX_VER_RESULT + ) + endif() + endif() + if(NOT LINUX_DISTRIBUTION) + if(EXISTS "/etc/os-release") + execute_process(COMMAND cat /etc/os-release + COMMAND grep -m1 NAME + COMMAND awk -F= "{ print $2 }" + COMMAND tr "\n" " " + COMMAND sed "s/ //" + OUTPUT_VARIABLE LINUX_DISTRIBUTION + RESULT_VARIABLE LINUX_ID_RESULT + ) + execute_process(COMMAND cat /etc/os-release + COMMAND grep VERSION_ID + COMMAND awk -F= "{ print $2 }" + COMMAND tr "\n" " " + COMMAND sed "s/ //" + OUTPUT_VARIABLE LINUX_VER + RESULT_VARIABLE LINUX_VER_RESULT + ) + if(${LINUX_DISTRIBUTION} MATCHES "Debian") + set(LINUX_DISTRIBUTION "Debian") + file(READ /etc/debian_version LINUX_VER) + endif() + endif() + endif() + if(NOT LINUX_DISTRIBUTION) + if(EXISTS "/etc/redhat-release") + set(LINUX_DISTRIBUTION "Red Hat") + file(READ /etc/redhat-release LINUX_VER) + endif() + endif() + if(NOT LINUX_DISTRIBUTION) + if(EXISTS "/etc/debian_version") + set(LINUX_DISTRIBUTION "Debian") + file(READ /etc/debian_version LINUX_VER) + endif() + endif() + if(NOT LINUX_DISTRIBUTION) + set(LINUX_DISTRIBUTION "Generic") + set(LINUX_VER "Unknown") + endif() + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on ${LINUX_DISTRIBUTION} GNU/Linux Release ${LINUX_VER} ${ARCH_}") +endif() if(NOT LINUX_DISTRIBUTION) set(LINUX_DISTRIBUTION "Unknown") -endif(NOT LINUX_DISTRIBUTION) +endif() # Detect macOS / Mac OS X Version if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(OperatingSystem "Mac OS X") - set(OS_IS_MACOSX TRUE) - exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION) - string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION}) - if(${DARWIN_VERSION} MATCHES "17") - set(MACOS_HIGH_SIERRA TRUE) - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on macOS High Sierra 10.13") - endif(${DARWIN_VERSION} MATCHES "17") - if(${DARWIN_VERSION} MATCHES "16") - set(MACOS_SIERRA TRUE) - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on macOS Sierra 10.12") - endif(${DARWIN_VERSION} MATCHES "16") - if(${DARWIN_VERSION} MATCHES "15") - set(MACOSX_EL_CAPITAN TRUE) - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.11 El Capitan") - endif(${DARWIN_VERSION} MATCHES "15") - if(${DARWIN_VERSION} MATCHES "14") - set(MACOSX_YOSEMITE TRUE) - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.10 Yosemite") - endif(${DARWIN_VERSION} MATCHES "14") - if(${DARWIN_VERSION} MATCHES "13") - set(MACOSX_MAVERICKS TRUE) - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION="com.apple.compilers.llvm.clang.1_0") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.9 Mavericks") - endif(${DARWIN_VERSION} MATCHES "13") - if(${DARWIN_VERSION} MATCHES "12") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.8 Mountain Lion") - endif(${DARWIN_VERSION} MATCHES "12") - if(${DARWIN_VERSION} MATCHES "11") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.7 Lion") - endif(${DARWIN_VERSION} MATCHES "11") - if(${DARWIN_VERSION} MATCHES "10") - message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.6 Snow Leopard") - endif(${DARWIN_VERSION} MATCHES "10") -endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(OperatingSystem "Mac OS X") + set(OS_IS_MACOSX TRUE) + execute_process(COMMAND uname -v OUTPUT_VARIABLE DARWIN_VERSION) + string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION}) + if(${DARWIN_VERSION} MATCHES "18") + set(MACOS_MOJAVE TRUE) + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on macOS Mojave 10.14") + endif() + if(${DARWIN_VERSION} MATCHES "17") + set(MACOS_HIGH_SIERRA TRUE) + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on macOS High Sierra 10.13") + endif() + if(${DARWIN_VERSION} MATCHES "16") + set(MACOS_SIERRA TRUE) + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on macOS Sierra 10.12") + endif() + if(${DARWIN_VERSION} MATCHES "15") + set(MACOSX_EL_CAPITAN TRUE) + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.11 El Capitan") + endif() + if(${DARWIN_VERSION} MATCHES "14") + set(MACOSX_YOSEMITE TRUE) + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.10 Yosemite") + endif() + if(${DARWIN_VERSION} MATCHES "13") + set(MACOSX_MAVERICKS TRUE) + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION="com.apple.compilers.llvm.clang.1_0") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.9 Mavericks") + endif() + if(${DARWIN_VERSION} MATCHES "12") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.8 Mountain Lion") + endif() + if(${DARWIN_VERSION} MATCHES "11") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.7 Lion") + endif() + if(${DARWIN_VERSION} MATCHES "10") + message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.6 Snow Leopard") + endif() +endif() -#select the release build type by default to get optimization flags +# Define extra build types and select Release by default to get optimization flags +include(GnsssdrBuildTypes) +# Available options: +# - None: nothing set +# - Debug: -O2 -g +# - Release: -O3 +# - RelWithDebInfo: -O3 -g +# - MinSizeRel: -Os +# - Coverage: -Wall -pedantic -pthread -g -O0 -fprofile-arcs -ftest-coverage +# - NoOptWithASM: -O0 -g -save-temps +# - O2WithASM: -O2 -g -save-temps +# - O3WithASM: -O3 -g -save-temps +# - ASAN: -Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer if(NOT CMAKE_BUILD_TYPE) - if(ENABLE_GPERFTOOLS OR ENABLE_GPROF) - set(CMAKE_BUILD_TYPE "RelWithDebInfo") - message(STATUS "Build type not specified: defaulting to RelWithDebInfo.") - else(ENABLE_GPERFTOOLS OR ENABLE_GPROF) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to Release.") - endif(ENABLE_GPERFTOOLS OR ENABLE_GPROF) -else(NOT CMAKE_BUILD_TYPE) - message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") -endif(NOT CMAKE_BUILD_TYPE) + if(ENABLE_GPERFTOOLS OR ENABLE_GPROF) + set(CMAKE_BUILD_TYPE "RelWithDebInfo") + message(STATUS "Build type not specified: defaulting to RelWithDebInfo.") + else() + set(CMAKE_BUILD_TYPE "Release") + message(STATUS "Build type not specified: defaulting to Release.") + endif() +else() + message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") +endif() +gnsssdr_check_build_type(${CMAKE_BUILD_TYPE}) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") -# Append -O2 optimization flag for Debug builds -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2") - # allow 'large' files in 32 bit builds if(UNIX) - add_definitions( -D_LARGEFILE_SOURCE - -D_FILE_OFFSET_BITS=64 - -D_LARGE_FILES - ) -endif(UNIX) + add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES) +endif() # Determine if we are using make or ninja if(CMAKE_MAKE_PROGRAM MATCHES "make") - set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "make") -endif(CMAKE_MAKE_PROGRAM MATCHES "make") + set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "make") +endif() if(CMAKE_MAKE_PROGRAM MATCHES "ninja") - set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "ninja") -endif(CMAKE_MAKE_PROGRAM MATCHES "ninja") + set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "ninja") +endif() if(NOT CMAKE_MAKE_PROGRAM_PRETTY_NAME) - set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "${CMAKE_MAKE_PROGRAM}") -endif(NOT CMAKE_MAKE_PROGRAM_PRETTY_NAME) + set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "${CMAKE_MAKE_PROGRAM}") +endif() ################################################################################ # Minimum required versions ################################################################################ -set(GNSSSDR_CMAKE_MIN_VERSION "2.8.8") +set(GNSSSDR_CMAKE_MIN_VERSION "2.8.12") set(GNSSSDR_GCC_MIN_VERSION "4.7.2") set(GNSSSDR_CLANG_MIN_VERSION "3.4.0") set(GNSSSDR_APPLECLANG_MIN_VERSION "500") set(GNSSSDR_GNURADIO_MIN_VERSION "3.7.3") -set(GNSSSDR_BOOST_MIN_VERSION "1.45") +set(GNSSSDR_BOOST_MIN_VERSION "1.53") set(GNSSSDR_PYTHON_MIN_VERSION "2.7") +set(GNSSSDR_PYTHON3_MIN_VERSION "3.4") set(GNSSSDR_MAKO_MIN_VERSION "0.4.2") set(GNSSSDR_ARMADILLO_MIN_VERSION "5.300.0") set(GNSSSDR_MATIO_MIN_VERSION "1.5.3") @@ -326,23 +344,28 @@ set(GNSSSDR_MATIO_MIN_VERSION "1.5.3") ################################################################################ # Versions to download and build (but not installed) if not found ################################################################################ -set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.1") +set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.3.5") -set(GNSSSDR_ARMADILLO_LOCAL_VERSION "unstable") -set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.0") +set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.200.x") +set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.1") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") -set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10") -set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.12") +set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10.6") +set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.13") +set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.9") + +if(CMAKE_VERSION VERSION_LESS "3.0.2") # Fix for CentOS 7 + set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.1") +endif() ################################################################################ -# Check cmake version +# Check CMake version ################################################################################ if(CMAKE_VERSION VERSION_LESS ${GNSSSDR_CMAKE_MIN_VERSION}) - message(STATUS "Your CMake version is too old and does not support some features required by GNSS-SDR. CMake version must be at least ${GNSSSDR_CMAKE_MIN_VERSION}. For more information check https://github.com/joakimkarlsson/bandit/issues/40") - message(FATAL_ERROR "Fatal error: CMake >= ${GNSSSDR_CMAKE_MIN_VERSION} required.") -endif(CMAKE_VERSION VERSION_LESS ${GNSSSDR_CMAKE_MIN_VERSION}) + message(STATUS "Your CMake version is too old and does not support some features required by GNSS-SDR. CMake version must be at least ${GNSSSDR_CMAKE_MIN_VERSION}.") + message(FATAL_ERROR "Fatal error: CMake >= ${GNSSSDR_CMAKE_MIN_VERSION} required.") +endif() @@ -350,16 +373,11 @@ endif(CMAKE_VERSION VERSION_LESS ${GNSSSDR_CMAKE_MIN_VERSION}) # Check compiler version ################################################################################ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GNSSSDR_GCC_MIN_VERSION}) - message(STATUS "Your GCC version is too old and does not support some C++ features required by GNSS-SDR. GCC version must be at least ${GNSSSDR_GCC_MIN_VERSION}") - if(${LINUX_DISTRIBUTION} MATCHES "Ubuntu") - if(${LINUX_VER} MATCHES "12.04") - message(STATUS "For instructions on how to upgrade GCC, check https://askubuntu.com/a/271561") - endif(${LINUX_VER} MATCHES "12.04") - endif(${LINUX_DISTRIBUTION} MATCHES "Ubuntu") - message(FATAL_ERROR "Fatal error: GCC >= ${GNSSSDR_GCC_MIN_VERSION} required.") - endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GNSSSDR_GCC_MIN_VERSION}) -endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GNSSSDR_GCC_MIN_VERSION}) + message(STATUS "Your GCC version is too old and does not support some C++ features required by GNSS-SDR. GCC version must be at least ${GNSSSDR_GCC_MIN_VERSION}") + message(FATAL_ERROR "Fatal error: GCC >= ${GNSSSDR_GCC_MIN_VERSION} required.") + endif() +endif() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") execute_process(COMMAND @@ -375,42 +393,83 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # retrieve the compiler's version from it string(REGEX MATCH "clang version [0-9.]+" CLANG_OTHER_VERSION ${_err}) string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_OTHER_VERSION}) - else("${IS_APPLE}" STREQUAL "") + else() set(MIN_VERSION ${GNSSSDR_APPLECLANG_MIN_VERSION}) set(APPLE_STR "Apple ") # retrieve the compiler's version from it string(REGEX MATCH "(clang-[0-9.]+)" CLANG_APPLE_VERSION ${_err}) string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_APPLE_VERSION}) - endif("${IS_APPLE}" STREQUAL "") + endif() if(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}") message(WARNING "\nThe compiler selected to build GNSS-SDR (${APPLE_STR}Clang version ${CLANG_VERSION} : ${CMAKE_CXX_COMPILER}) is older than that officially supported (${MIN_VERSION} minimum). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.") - endif(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}") - else(${_res} STREQUAL "0") + endif() + else() message(WARNING "\nCannot determine the version of the compiler selected to build GNSS-SDR (${APPLE_STR}Clang : ${CMAKE_CXX_COMPILER}). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.") - endif(${_res} STREQUAL "0") -endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + endif() +endif() +################################################################################ +# Set C and C++ standard +################################################################################ +if(NOT (CMAKE_VERSION VERSION_LESS "3.1")) + set(CMAKE_C_STANDARD 11) + set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_EXTENSIONS OFF) +else() + add_compile_options("$<$,C>:-std=gnu11>") + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") + add_compile_options("$<$,CXX>:-std=c++11>") + else() + add_compile_options("$<$,CXX>:-std=c++14>") + endif() + endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(OS_IS_MACOSX) + if(CLANG_VERSION VERSION_LESS "600") + add_compile_options("$<$,CXX>:-std=c++11>") + else() + add_compile_options("$<$,CXX>:-std=c++14>") + endif() + else() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") + add_compile_options("$<$,CXX>:-std=c++11>") + else() + add_compile_options("$<$,CXX>:-std=c++14>") + endif() + endif() + endif() +endif() + +# Visibility +# See https://gcc.gnu.org/wiki/Visibility +if(POLICY CMP0053) + cmake_policy(SET CMP0063 NEW) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_C_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +else() + if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + add_definitions(-fvisibility=hidden) + endif() +endif() + + ################################################################################ # Check if the compiler defines the architecture as ARM ################################################################################ if(NOT OS_IS_MACOSX) if(CMAKE_CROSSCOMPILING) set(IS_ARM TRUE) - else(CMAKE_CROSSCOMPILING) + if(NOT CMAKE_NO_SYSTEM_FROM_IMPORTED) + set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE) + endif() + else() include(TestForARM) - endif(CMAKE_CROSSCOMPILING) -endif(NOT OS_IS_MACOSX) - - - -################################################################################ -# Check for availability of SSE -################################################################################ -if(NOT ENABLE_GENERIC_ARCH) - include(TestForSSE) -endif(NOT ENABLE_GENERIC_ARCH) + endif() +endif() @@ -418,18 +477,30 @@ endif(NOT ENABLE_GENERIC_ARCH) # Find the POSIX thread (pthread) libraries ################################################################################ if(CMAKE_VERSION VERSION_LESS 3.1) + # Workaround for CMake < 3.1 find_package(Threads REQUIRED) - link_libraries(${CMAKE_THREAD_LIBS_INIT}) -else(CMAKE_VERSION VERSION_LESS 3.1) + add_library(Threads::Threads SHARED IMPORTED) + set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") + set_property(TARGET Threads::Threads PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") + include(GNUInstallDirs) + # Fix bug in Debian 8.11 + if(${LINUX_DISTRIBUTION} MATCHES "Debian") + if(${LINUX_VER} VERSION_LESS 8.12) + if(ARCH_64BITS) + set(FIX_PTHREADS_LOCATION "x86_64-linux-gnu/") + endif() + endif() + endif() + set_property(TARGET Threads::Threads PROPERTY IMPORTED_LOCATION /usr/${CMAKE_INSTALL_LIBDIR}/${FIX_PTHREADS_LOCATION}${CMAKE_FIND_LIBRARY_PREFIXES}pthread${CMAKE_SHARED_LIBRARY_SUFFIX}) +else() set(CMAKE_THREAD_PREFER_PTHREAD TRUE) if(CMAKE_CROSSCOMPILING) set(THREADS_PREFER_PTHREAD_FLAG FALSE) - else(CMAKE_CROSSCOMPILING) + else() set(THREADS_PREFER_PTHREAD_FLAG TRUE) - endif(CMAKE_CROSSCOMPILING) + endif() find_package(Threads REQUIRED) - link_libraries(Threads::Threads) -endif(CMAKE_VERSION VERSION_LESS 3.1) +endif() @@ -440,28 +511,28 @@ enable_testing() if(ENABLE_UNIT_TESTING OR ENABLE_SYSTEM_TESTING) if(EXISTS $ENV{GTEST_DIR}) set(GTEST_DIR $ENV{GTEST_DIR}) - endif(EXISTS $ENV{GTEST_DIR}) + endif() if(GTEST_DIR) message(STATUS "Googletest root folder set at ${GTEST_DIR}") - find_path(LIBGTEST_DEV_DIR NAMES src/gtest-all.cc PATHS ${GTEST_DIR}) + find_path(LIBGTEST_DEV_DIR NAMES src/gtest-all.cc PATHS ${GTEST_DIR} ${GTEST_DIR}/googletest) if(LIBGTEST_DEV_DIR) - message (STATUS "Googletest has been found.") - else(LIBGTEST_DEV_DIR) - message (FATAL_ERROR " Googletest source code has not been found at ${GTEST_DIR}.") - endif(LIBGTEST_DEV_DIR) - find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h PATHS ${GTEST_DIR}/include) - else(GTEST_DIR) - find_path(LIBGTEST_DEV_DIR NAMES src/gtest-all.cc PATHS /usr/src/googletest/googletest /usr/src/gtest /usr/include/gtest /opt/local/src/gtest-1.7.0 ) + message(STATUS "Googletest has been found.") + else() + message(FATAL_ERROR " Googletest source code has not been found at ${GTEST_DIR}.") + endif() + find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h PATHS ${GTEST_DIR}/googletest/include) + else() + find_path(LIBGTEST_DEV_DIR NAMES src/gtest-all.cc PATHS /usr/src/googletest/googletest /usr/src/gtest /usr/include/gtest /opt/local/src/gtest-1.7.0) find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h PATHS /usr/include /opt/local/src/gtest-1.7.0/include) if(LIBGTEST_DEV_DIR) - message (STATUS "Googletest package has been found.") - else(LIBGTEST_DEV_DIR) - message (STATUS " Googletest has not been found.") - message (STATUS " Googletest v${GNSSSDR_GTEST_LOCAL_VERSION} will be downloaded and built automatically ") - message (STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'. ") - endif(LIBGTEST_DEV_DIR) - endif(GTEST_DIR) -endif(ENABLE_UNIT_TESTING OR ENABLE_SYSTEM_TESTING) + message(STATUS "Googletest package has been found.") + else() + message(STATUS " Googletest has not been found.") + message(STATUS " Googletest v${GNSSSDR_GTEST_LOCAL_VERSION} will be downloaded and built automatically ") + message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'. ") + endif() + endif() +endif() @@ -470,22 +541,95 @@ endif(ENABLE_UNIT_TESTING OR ENABLE_SYSTEM_TESTING) ################################################################################ if(UNIX AND EXISTS "/usr/lib64") list(APPEND BOOST_LIBRARYDIR "/usr/lib64") # Fedora 64-bit fix -endif(UNIX AND EXISTS "/usr/lib64") +endif() set(Boost_ADDITIONAL_VERSIONS - "1.45.0" "1.45" "1.46.0" "1.46" "1.48.0" "1.48" "1.49.0" "1.49" - "1.50.0" "1.50" "1.51.0" "1.51" "1.53.0" "1.53" "1.54.0" "1.54" + "1.53.0" "1.53" "1.54.0" "1.54" "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" "1.70.0" "1.70" "1.71.0" "1.71" "1.72.0" "1.72" "1.73.0" "1.73" "1.74.0" "1.74" "1.75.0" "1.75" "1.76.0" "1.76" "1.77.0" "1.77" "1.78.0" "1.78" "1.79.0" "1.79" + "1.80.0" "1.80" "1.81.0" "1.81" "1.82.0" "1.82" "1.83.0" "1.83" "1.84.0" "1.84" ) set(Boost_USE_MULTITHREAD ON) set(Boost_USE_STATIC_LIBS OFF) -find_package(Boost COMPONENTS date_time system filesystem thread serialization chrono REQUIRED) +find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS atomic chrono date_time filesystem serialization system thread REQUIRED) if(NOT Boost_FOUND) - message(FATAL_ERROR "Fatal error: Boost (version >=${GNSSSDR_BOOST_MIN_VERSION}) required.") -endif(NOT Boost_FOUND) + message(FATAL_ERROR "Fatal error: Boost (version >=${GNSSSDR_BOOST_MIN_VERSION}) required.") +endif() + +if(CMAKE_VERSION VERSION_LESS 3.5) + if(NOT TARGET Boost::boost) + add_library(Boost::boost SHARED IMPORTED) # Trick for CMake 2.8.12 + set_property(TARGET Boost::boost PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::boost PROPERTY + IMPORTED_LOCATION ${Boost_DATE_TIME_LIBRARIES}) + endif() + if(NOT TARGET Boost::date_time) + add_library(Boost::date_time SHARED IMPORTED) + set_property(TARGET Boost::date_time PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::date_time PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_DATE_TIME_LIBRARIES}) + set_property(TARGET Boost::date_time PROPERTY + IMPORTED_LOCATION ${Boost_DATE_TIME_LIBRARIES}) + endif() + if(NOT TARGET Boost::system) + add_library(Boost::system SHARED IMPORTED) + set_property(TARGET Boost::system PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::system PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_SYSTEM_LIBRARIES}) + set_property(TARGET Boost::system PROPERTY + IMPORTED_LOCATION ${Boost_SYSTEM_LIBRARIES}) + endif() + if(NOT TARGET Boost::filesystem) + add_library(Boost::filesystem SHARED IMPORTED) + set_property(TARGET Boost::filesystem PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::filesystem PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_FILESYSTEM_LIBRARIES}) + set_property(TARGET Boost::filesystem PROPERTY + IMPORTED_LOCATION ${Boost_FILESYSTEM_LIBRARIES}) + endif() + if(NOT TARGET Boost::thread) + add_library(Boost::thread SHARED IMPORTED) + set_property(TARGET Boost::thread PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::thread PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_THREAD_LIBRARIES}) + set_property(TARGET Boost::thread PROPERTY + IMPORTED_LOCATION ${Boost_THREAD_LIBRARIES}) + endif() + if(NOT TARGET Boost::serialization) + add_library(Boost::serialization SHARED IMPORTED) + set_property(TARGET Boost::serialization PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::serialization PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_SERIALIZATION_LIBRARIES}) + set_property(TARGET Boost::serialization PROPERTY + IMPORTED_LOCATION ${Boost_SERIALIZATION_LIBRARIES}) + endif() + if(NOT TARGET Boost::chrono) + add_library(Boost::chrono SHARED IMPORTED) + set_property(TARGET Boost::chrono PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::chrono PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_CHRONO_LIBRARIES}) + set_property(TARGET Boost::chrono PROPERTY + IMPORTED_LOCATION ${Boost_CHRONO_LIBRARIES}) + endif() + if(NOT TARGET Boost::atomic) + add_library(Boost::atomic SHARED IMPORTED) + set_property(TARGET Boost::atomic PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::atomic PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_ATOMIC_LIBRARIES}) + set_property(TARGET Boost::atomic PROPERTY + IMPORTED_LOCATION ${Boost_ATOMIC_LIBRARIES}) + endif() +endif() @@ -493,44 +637,119 @@ endif(NOT Boost_FOUND) # GNU Radio - https://gnuradio.org ################################################################################ set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG BLOCKS FFT FILTER PMT) -find_package(Gnuradio) +find_package(GNURADIO) if(PC_GNURADIO_RUNTIME_VERSION) - if(PC_GNURADIO_RUNTIME_VERSION VERSION_LESS ${GNSSSDR_GNURADIO_MIN_VERSION}) - set(GNURADIO_RUNTIME_FOUND) - message(STATUS "The GNU Radio version installed in your system is too old.") - endif(PC_GNURADIO_RUNTIME_VERSION VERSION_LESS ${GNSSSDR_GNURADIO_MIN_VERSION}) -endif(PC_GNURADIO_RUNTIME_VERSION) + if(PC_GNURADIO_RUNTIME_VERSION VERSION_LESS ${GNSSSDR_GNURADIO_MIN_VERSION}) + set(GNURADIO_RUNTIME_FOUND) + message(STATUS "The GNU Radio version installed in your system is too old.") + endif() +endif() if(NOT GNURADIO_RUNTIME_FOUND) - message(STATUS "CMake cannot find GNU Radio >= ${GNSSSDR_GNURADIO_MIN_VERSION}") - if(OS_IS_LINUX) - message("Go to https://github.com/gnuradio/pybombs") - message("and follow the instructions to install GNU Radio in your system.") - message(FATAL_ERROR "GNU Radio ${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") - endif(OS_IS_LINUX) - if(OS_IS_MACOSX) - message("You can install it easily via Macports:") - message(" sudo port install gnuradio ") - message("Alternatively, you can use homebrew:") - message(" brew tap odrisci/gnuradio") - message(" brew install gnuradio" ) - message(FATAL_ERROR "GNU Radio ${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") - endif(OS_IS_MACOSX) -endif(NOT GNURADIO_RUNTIME_FOUND) + message(STATUS "CMake cannot find GNU Radio >= ${GNSSSDR_GNURADIO_MIN_VERSION}") + if(OS_IS_LINUX) + message("Go to https://github.com/gnuradio/pybombs") + message("and follow the instructions to install GNU Radio in your system.") + message(FATAL_ERROR "GNU Radio ${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") + endif() + if(OS_IS_MACOSX) + message("You can install it easily via Macports:") + message(" sudo port install gnuradio ") + message("Alternatively, you can use homebrew:") + message(" brew install gnuradio") + message(FATAL_ERROR "GNU Radio ${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") + endif() +else() + if(NOT TARGET Gnuradio::runtime) + add_library(Gnuradio::runtime SHARED IMPORTED) + list(GET GNURADIO_RUNTIME_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_RUNTIME_DIR ${FIRST_DIR} ABSOLUTE) + set_target_properties(Gnuradio::runtime PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNURADIO_RUNTIME_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${GNURADIO_RUNTIME_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GNURADIO_RUNTIME_LIBRARIES}" + ) + endif() +endif() if(NOT GNURADIO_ANALOG_FOUND) message(FATAL_ERROR "*** The gnuradio-analog library v${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") +else() + if(NOT TARGET Gnuradio::analog) + add_library(Gnuradio::analog SHARED IMPORTED) + list(GET GNURADIO_ANALOG_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_ANALOG_DIR ${FIRST_DIR} ABSOLUTE) + set_target_properties(Gnuradio::analog PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNURADIO_ANALOG_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${GNURADIO_ANALOG_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GNURADIO_ANALOG_LIBRARIES}" + ) + endif() endif() + if(NOT GNURADIO_BLOCKS_FOUND) message(FATAL_ERROR "*** The gnuradio-blocks library v${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") +else() + if(NOT TARGET Gnuradio::blocks) + add_library(Gnuradio::blocks SHARED IMPORTED) + list(GET GNURADIO_BLOCKS_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_BLOCKS_DIR ${FIRST_DIR} ABSOLUTE) + set_target_properties(Gnuradio::blocks PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNURADIO_BLOCKS_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${GNURADIO_BLOCKS_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GNURADIO_BLOCKS_LIBRARIES}" + ) + endif() endif() + if(NOT GNURADIO_FILTER_FOUND) message(FATAL_ERROR "*** The gnuradio-filter library v${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") +else() + if(NOT TARGET Gnuradio::filter) + add_library(Gnuradio::filter SHARED IMPORTED) + list(GET GNURADIO_FILTER_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_FILTER_DIR ${FIRST_DIR} ABSOLUTE) + set_target_properties(Gnuradio::filter PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNURADIO_FILTER_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${GNURADIO_FILTER_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GNURADIO_FILTER_LIBRARIES}" + ) + endif() endif() + if(NOT GNURADIO_FFT_FOUND) message(FATAL_ERROR "*** The gnuradio-fft library v${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") +else() + if(NOT TARGET Gnuradio::fft) + add_library(Gnuradio::fft SHARED IMPORTED) + list(GET GNURADIO_FFT_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_FFT_DIR ${FIRST_DIR} ABSOLUTE) + set_target_properties(Gnuradio::fft PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNURADIO_FFT_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${GNURADIO_FFT_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GNURADIO_FFT_LIBRARIES}" + ) + endif() endif() + if(NOT GNURADIO_PMT_FOUND) message(FATAL_ERROR "*** The gnuradio-pmt library v${GNSSSDR_GNURADIO_MIN_VERSION} or later is required to build gnss-sdr") +else() + if(NOT TARGET Gnuradio::pmt) + add_library(Gnuradio::pmt SHARED IMPORTED) + list(GET GNURADIO_PMT_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_PMT_DIR ${FIRST_DIR} ABSOLUTE) + set_target_properties(Gnuradio::pmt PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNURADIO_PMT_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${GNURADIO_PMT_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GNURADIO_PMT_LIBRARIES}" + ) + endif() endif() @@ -538,7 +757,7 @@ endif() ################################################################################ # VOLK - Vector-Optimized Library of Kernels ################################################################################ -find_package(Volk) +find_package(VOLK) if(NOT VOLK_FOUND) message(FATAL_ERROR "*** VOLK is required to build gnss-sdr") endif() @@ -548,7 +767,7 @@ endif() ################################################################################ # Log4cpp - http://log4cpp.sourceforge.net/ ################################################################################ -find_package(Log4cpp) +find_package(LOG4CPP) if(NOT LOG4CPP_FOUND) message(FATAL_ERROR "*** Log4cpp is required to build gnss-sdr") endif() @@ -558,139 +777,156 @@ endif() ################################################################################ # volk_gnsssdr module - GNSS-SDR's own VOLK library ################################################################################ -find_package(VolkGnssSdr) - -if(NOT VOLK_GNSSSDR_FOUND) +find_package(VOLKGNSSSDR) +if(NOT VOLKGNSSSDR_FOUND) message(STATUS " volk_gnsssdr will be built along with gnss-sdr when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'") ############################### # Find Python required modules ############################### - include(SetupPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B - GNSSSDR_PYTHON_CHECK_MODULE("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) - GNSSSDR_PYTHON_CHECK_MODULE("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) - GNSSSDR_PYTHON_CHECK_MODULE("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + include(SetupPython) # sets PYTHON_EXECUTABLE and search for required modules if(NOT PYTHON_MIN_VER_FOUND) message(FATAL_ERROR "Python ${GNSSSDR_PYTHON_MIN_VERSION} or greater required to build VOLK_GNSSSDR") endif() + if(${PYTHON3}) + set(PYTHON_NAME "python3") + else() + set(PYTHON_NAME "python") + endif() + # Mako if(NOT MAKO_FOUND) - message(STATUS "Mako templates not found. See http://www.makotemplates.org/ ") + message(STATUS "Mako template library not found. See http://www.makotemplates.org/ ") message(STATUS " You can try to install it by typing:") if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo yum install python-mako") + message(STATUS " sudo yum install ${PYTHON_NAME}-mako") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(STATUS " sudo zypper install python-Mako") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo apt-get install python-mako") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(STATUS " sudo zypper install ${PYTHON_NAME}-Mako") + else() + message(STATUS " sudo apt-get install ${PYTHON_NAME}-mako") + endif() message(FATAL_ERROR "Mako templates required to build VOLK_GNSSSDR") - endif(NOT MAKO_FOUND) + endif() # Six if(NOT SIX_FOUND) message(STATUS "python-six not found. See https://pythonhosted.org/six/ ") message(STATUS " You can try to install it by typing:") if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo yum install python-six") + message(STATUS " sudo yum install ${PYTHON_NAME}-six") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(STATUS " sudo zypper install python-six") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo apt-get install python-six") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(STATUS " sudo zypper install ${PYTHON_NAME}-six") + else() + message(STATUS " sudo apt-get install ${PYTHON_NAME}-six") + endif() message(FATAL_ERROR "six - python 2 and 3 compatibility library required to build VOLK_GNSSSDR") - endif(NOT SIX_FOUND) + endif() set(READ_ENVIRO "") if(ENABLE_PACKAGING) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) set(STRIP_VOLK_GNSSSDR_PROFILE "-DENABLE_STRIP=ON -DCMAKE_VERBOSE_MAKEFILE=ON") - endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - set(READ_ENVIRO ${CMAKE_COMMAND} -E environment) - endif(ENABLE_PACKAGING) + endif() + if(NOT DEFINED ENV{PROTECT_PASSWORDS}) + set(READ_ENVIRO ${CMAKE_COMMAND} -E environment) + endif() + endif() set(VOLK_GNSSSDR_BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}") if(PYTHON_EXECUTABLE) set(USE_THIS_PYTHON "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") - endif(PYTHON_EXECUTABLE) + endif() if(OS_IS_MACOSX) if(CMAKE_GENERATOR STREQUAL Xcode) set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild" "-configuration" "Debug" "-target") - endif(CMAKE_GENERATOR STREQUAL Xcode) - endif(OS_IS_MACOSX) + endif() + endif() if(CMAKE_CROSSCOMPILING) set(VOLK_GNSSSDR_COMPILER "") - else(CMAKE_CROSSCOMPILING) + else() set(VOLK_GNSSSDR_COMPILER -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}) - endif(CMAKE_CROSSCOMPILING) + endif() set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_COMPILER} - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install - -DENABLE_STATIC_LIBS=ON - -DENABLE_PROFILING=${ENABLE_PROFILING} - -DCMAKE_INCLUDE_PATH=${Boost_INCLUDE_DIR} - -DENABLE_ORC=OFF - ${STRIP_VOLK_GNSSSDR_PROFILE} - ${USE_THIS_PYTHON} ) + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install + -DENABLE_STATIC_LIBS=ON + -DENABLE_PROFILING=${ENABLE_PROFILING} + -DCMAKE_INCLUDE_PATH=${Boost_INCLUDE_DIR} + -DENABLE_ORC=OFF + ${STRIP_VOLK_GNSSSDR_PROFILE} + ${USE_THIS_PYTHON}) if(EXISTS $ENV{OECORE_TARGET_SYSROOT}) set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake - -DCROSSCOMPILE_MULTILIB=TRUE ) - endif(EXISTS $ENV{OECORE_TARGET_SYSROOT}) + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake + -DCROSSCOMPILE_MULTILIB=TRUE) + endif() if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add(volk_gnsssdr_module - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build - CMAKE_ARGS ${READ_ENVIRO} ${VOLK_GNSSSDR_CMAKE_ARGS} - DOWNLOAD_COMMAND "" - UPDATE_COMMAND "" - PATCH_COMMAND "" - BUILD_COMMAND ${READ_ENVIRO} ${VOLK_GNSSSDR_BUILD_COMMAND} volk_gnsssdr_profile - INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add(volk_gnsssdr_module - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build - CMAKE_ARGS ${READ_ENVIRO} ${VOLK_GNSSSDR_CMAKE_ARGS} - DOWNLOAD_COMMAND "" - UPDATE_COMMAND "" - PATCH_COMMAND "" - BUILD_COMMAND ${READ_ENVIRO} ${VOLK_GNSSSDR_BUILD_COMMAND} volk_gnsssdr_profile - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX} - ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile - INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add(volk_gnsssdr_module + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build + CMAKE_ARGS ${READ_ENVIRO} ${VOLK_GNSSSDR_CMAKE_ARGS} + DOWNLOAD_COMMAND "" + UPDATE_COMMAND "" + PATCH_COMMAND "" + BUILD_COMMAND ${READ_ENVIRO} ${VOLK_GNSSSDR_BUILD_COMMAND} volk_gnsssdr_profile + INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install + ) + else() + ExternalProject_Add(volk_gnsssdr_module + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build + CMAKE_ARGS ${READ_ENVIRO} ${VOLK_GNSSSDR_CMAKE_ARGS} + DOWNLOAD_COMMAND "" + UPDATE_COMMAND "" + PATCH_COMMAND "" + BUILD_COMMAND ${READ_ENVIRO} ${VOLK_GNSSSDR_BUILD_COMMAND} volk_gnsssdr_profile + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX} + ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile + INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install + ) + endif() find_package(ORC) if(NOT ORC_FOUND) - set(ORC_LIBRARIES "") - set(ORC_INCLUDE_DIRS "") - endif(NOT ORC_FOUND) + set(ORC_LIBRARIES "") + set(ORC_INCLUDE_DIRS "") + endif() add_library(volk_gnsssdr UNKNOWN IMPORTED) set_property(TARGET volk_gnsssdr PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/lib/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}) set(VOLK_GNSSSDR_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build/include/;${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include;${ORC_INCLUDE_DIRS}") set(VOLK_GNSSSDR_LIBRARIES volk_gnsssdr ${ORC_LIBRARIES}) + if(NOT TARGET Volkgnsssdr::volkgnsssdr) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build/include) + add_library(Volkgnsssdr::volkgnsssdr STATIC IMPORTED) + add_dependencies(Volkgnsssdr::volkgnsssdr volk_gnsssdr_module) + set_target_properties(Volkgnsssdr::volkgnsssdr PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/lib/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}" + INCLUDE_DIRECTORIES "${VOLK_GNSSSDR_INCLUDE_DIRS}" + INTERFACE_INCLUDE_DIRECTORIES "${VOLK_GNSSSDR_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${VOLK_GNSSSDR_LIBRARIES}" + ) + endif() + if(CMAKE_VERSION VERSION_LESS 3.2) - add_custom_command(TARGET volk_gnsssdr_module POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile + add_custom_command(TARGET volk_gnsssdr_module POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile ${CMAKE_SOURCE_DIR}/install/volk_gnsssdr_profile) - else(CMAKE_VERSION VERSION_LESS 3.2) - add_custom_command(TARGET volk_gnsssdr_module POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile + else() + add_custom_command(TARGET volk_gnsssdr_module POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile ${CMAKE_SOURCE_DIR}/install/volk_gnsssdr_profile - BYPRODUCTS ${CMAKE_SOURCE_DIR}/install/volk_gnsssdr_profile) - endif(CMAKE_VERSION VERSION_LESS 3.2) + BYPRODUCTS ${CMAKE_SOURCE_DIR}/install/volk_gnsssdr_profile) + endif() add_custom_command(TARGET volk_gnsssdr_module POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr-config-info - ${CMAKE_SOURCE_DIR}/install/volk_gnsssdr-config-info) -endif(NOT VOLK_GNSSSDR_FOUND) + ${CMAKE_SOURCE_DIR}/install/volk_gnsssdr-config-info) +endif() @@ -698,59 +934,64 @@ endif(NOT VOLK_GNSSSDR_FOUND) # gflags - https://github.com/gflags/gflags ################################################################################ set(LOCAL_GFLAGS false) -find_package(GFlags) -if (NOT GFlags_FOUND) - message (STATUS " gflags library has not been found.") - message (STATUS " gflags v${GNSSSDR_GFLAGS_LOCAL_VERSION} will be downloaded and built automatically ") - message (STATUS " when doing 'make'. ") +find_package(GFLAGS) +if(NOT GFLAGS_FOUND) + message(STATUS " gflags library has not been found.") + message(STATUS " gflags v${GNSSSDR_GFLAGS_LOCAL_VERSION} will be downloaded and built automatically ") + message(STATUS " when doing 'make'. ") - if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - GIT_REPOSITORY git://github.com/gflags/gflags.git - GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} - UPDATE_COMMAND "" - PATCH_COMMAND "" - INSTALL_COMMAND "" - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - GIT_REPOSITORY git://github.com/gflags/gflags.git - GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} - CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX} - UPDATE_COMMAND "" - PATCH_COMMAND "" - INSTALL_COMMAND "" - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + GIT_REPOSITORY git://github.com/gflags/gflags.git + GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + ) + else() + ExternalProject_Add(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + GIT_REPOSITORY git://github.com/gflags/gflags.git + GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX} + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + ) + endif() - set(GFlags_INCLUDE_DIRS - ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include CACHE PATH "Local Gflags headers" - ) + set(GFlags_INCLUDE_DIRS + ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include CACHE PATH "Local Gflags headers" + ) - add_library(gflags UNKNOWN IMPORTED) - set_property(TARGET gflags PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}) - add_dependencies(gflags gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) - set(GFlags_LIBS gflags) - file(GLOB GFlags_SHARED_LIBS "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*") - set(GFlags_LIBRARY gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) - set(GFlags_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib ) - link_directories(${GFlags_LIBRARY_PATH}) - set(GFlags_lib ${GFlags_LIBS} CACHE FILEPATH "Local Gflags library") - set(GFlags_LIBRARY_PATH ${GFlags_LIBS}) - set(LOCAL_GFLAGS true CACHE STRING "GFlags downloaded and built automatically" FORCE) -endif(NOT GFlags_FOUND) + file(GLOB GFlags_SHARED_LIBS + "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*" + ) + + if(NOT TARGET Gflags::gflags) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include) + add_library(Gflags::gflags STATIC IMPORTED) + add_dependencies(Gflags::gflags gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) + set_target_properties(Gflags::gflags PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}" + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include" + INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() + + set(LOCAL_GFLAGS true CACHE STRING "GFlags downloaded and built automatically" FORCE) +endif() @@ -758,34 +999,34 @@ endif(NOT GFlags_FOUND) # glog - https://github.com/google/glog ################################################################################ if(NOT ${ENABLE_OWN_GLOG}) - find_package(GLOG) - if(GLOG_INCLUDE_DIRS) + find_package(GLOG) + if(GLOG_INCLUDE_DIRS) set(GLOG_FOUND ON) - endif(GLOG_INCLUDE_DIRS) -endif(NOT ${ENABLE_OWN_GLOG}) + endif() +endif() set(glog_RELEASE ${GNSSSDR_GLOG_LOCAL_VERSION}) -if (NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) - message (STATUS " glog library has not been found") - if(NOT GFlags_FOUND) - message(STATUS " or it is likely not linked to gflags.") - endif(NOT GFlags_FOUND) - message (STATUS " glog v${GNSSSDR_GLOG_LOCAL_VERSION} will be downloaded and built automatically ") - message (STATUS " when doing 'make'. ") - if(NOT ${LOCAL_GFLAGS}) - add_library(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} UNKNOWN IMPORTED) - set_property(TARGET gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}") - endif(NOT ${LOCAL_GFLAGS}) - set(TARGET_GFLAGS gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) - if(${LOCAL_GFLAGS}) - set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_SHARED_LIBS}) - set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib) - else(${LOCAL_GFLAGS}) - set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_LIBS}) - set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS}) - endif(${LOCAL_GFLAGS}) +if(NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) + message(STATUS " glog library has not been found") + if(NOT GFLAGS_FOUND) + message(STATUS " or it is likely not linked to gflags.") + endif() + message(STATUS " glog v${GNSSSDR_GLOG_LOCAL_VERSION} will be downloaded and built automatically ") + message(STATUS " when doing 'make'. ") + if(NOT ${LOCAL_GFLAGS}) + add_library(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} UNKNOWN IMPORTED) + set_property(TARGET gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}") + endif() + set(TARGET_GFLAGS gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) + if(${LOCAL_GFLAGS}) + set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_SHARED_LIBS}) + set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib) + else() + set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_LIBS}) + set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS}) + endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags "#!/bin/sh export CPPFLAGS=-I${GFlags_INCLUDE_DIRS} export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK} @@ -800,8 +1041,8 @@ autoreconf -vfi cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure") - else(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags + else() + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags "#!/bin/sh export CPPFLAGS=-I${GFlags_INCLUDE_DIRS} export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK} @@ -812,98 +1053,108 @@ automake --add-missing autoreconf -vfi cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure") + endif() - endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ + GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} - FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ - GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure_with_gflags) - set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure_with_gflags) + # Ensure that aclocal and libtool are present + if(OS_IS_LINUX) + if(EXISTS "/usr/bin/libtoolize") + if(EXISTS "/usr/bin/aclocal" OR EXISTS "/usr/bin/aclocal-1.16" OR EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") + # Everything ok, we can move on + else() + message(" aclocal has not been found.") + message(" You can try to install it by typing:") + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(" sudo yum groupinstall 'Development Tools'") + elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") + message(" sudo zypper install automake") + else() + message(" sudo apt-get install automake") + endif() + message(FATAL_ERROR "aclocal is required to build glog from source") + endif() + else() + message(" libtool has not been found.") + message(" You can try to install it by typing:") + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(" sudo yum groupinstall 'Development Tools'") + elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") + message(" sudo zypper install libtoool") + else() + message(" sudo apt-get install libtool") + endif() + message(FATAL_ERROR "libtool is required to build glog from source") + endif() + endif() - # Ensure that aclocal and libtool are present - if(OS_IS_LINUX) - if(EXISTS "/usr/bin/libtoolize") - if(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") - # Everything ok, we can move on - else(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") - message(" aclocal has not been found.") - message(" You can try to install it by typing:") - if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(" sudo yum groupinstall 'Development Tools'") - elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(" sudo zypper install automake") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(" sudo apt-get install automake") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(FATAL_ERROR "aclocal is required to build glog from source") - endif(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") - else(EXISTS "/usr/bin/libtoolize") - message(" libtool has not been found.") - message(" You can try to install it by typing:") - if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(" sudo yum groupinstall 'Development Tools'") - elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(" sudo zypper install libtoool") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(" sudo apt-get install libtool") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(FATAL_ERROR "libtool is required to build glog from source") - endif(EXISTS "/usr/bin/libtoolize") - endif(OS_IS_LINUX) + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION} + DEPENDS ${TARGET_GFLAGS} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/google/glog/ + GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix= + BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + ) + else() + ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION} + DEPENDS ${TARGET_GFLAGS} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/google/glog/ + GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix= + BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + ) + endif() + add_dependencies(glog-${GNSSSDR_GLOG_LOCAL_VERSION} Gflags::gflags) - if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - glog-${GNSSSDR_GLOG_LOCAL_VERSION} - DEPENDS ${TARGET_GFLAGS} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/google/glog/ - GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} - CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix= - BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" - UPDATE_COMMAND "" - PATCH_COMMAND "" - INSTALL_COMMAND "" - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - glog-${GNSSSDR_GLOG_LOCAL_VERSION} - DEPENDS ${TARGET_GFLAGS} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/google/glog/ - GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} - CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix= - BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} - UPDATE_COMMAND "" - PATCH_COMMAND "" - INSTALL_COMMAND "" - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) + # Set up variables + set(GLOG_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src/ + ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src + ) + set(GLOG_LIBRARIES + ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} + ) - # Set up variables - set(GLOG_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src/ - ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src - ) - set(GLOG_LIBRARIES - ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} - ) - set(LOCAL_GLOG true CACHE STRING "Glog downloaded and built automatically" FORCE) -else(NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) - add_library(glog-${GNSSSDR_GLOG_LOCAL_VERSION} UNKNOWN IMPORTED) - set_property(TARGET glog-${GNSSSDR_GLOG_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GLOG_LIBRARIES}") -endif(NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) + # Create Glog::glog target + if(NOT TARGET Glog::glog) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src) + add_library(Glog::glog STATIC IMPORTED) + add_dependencies(Glog::glog glog-${GNSSSDR_GLOG_LOCAL_VERSION}) + set_target_properties(Glog::glog PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}" + INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}" + INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() + + set(LOCAL_GLOG true CACHE STRING "Glog downloaded and built automatically" FORCE) +endif() if(NOT ENABLE_LOG) - message(STATUS "Logging is not enabled") - add_definitions(-DGOOGLE_STRIP_LOG=1) -endif(NOT ENABLE_LOG) + message(STATUS "Logging is not enabled") +endif() @@ -917,11 +1168,11 @@ if(NOT BLAS) message(" You can try to install it by typing:") if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") message(" sudo yum install blas-devel") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + else() message(" sudo apt-get install libblas-dev") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + endif() message(FATAL_ERROR "BLAS is required to build gnss-sdr") -endif(NOT BLAS) +endif() @@ -937,11 +1188,11 @@ if(NOT LAPACK) message(" sudo yum install lapack-devel") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") message(" sudo zypper install lapack-devel") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + else() message(" sudo apt-get install liblapack-dev") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + endif() message(FATAL_ERROR "LAPACK is required to build gnss-sdr") -endif(NOT LAPACK) +endif() @@ -953,81 +1204,92 @@ if(ARMADILLO_FOUND) if(${ARMADILLO_VERSION_STRING} VERSION_LESS ${GNSSSDR_ARMADILLO_MIN_VERSION}) set(ARMADILLO_FOUND false) set(ENABLE_OWN_ARMADILLO true) - endif(${ARMADILLO_VERSION_STRING} VERSION_LESS ${GNSSSDR_ARMADILLO_MIN_VERSION}) -endif(ARMADILLO_FOUND) + else() + add_library(Armadillo::armadillo SHARED IMPORTED) + set_target_properties(Armadillo::armadillo PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${ARMADILLO_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${ARMADILLO_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${ARMADILLO_LIBRARIES}" + ) + endif() +endif() if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) - message(STATUS " Armadillo has not been found.") - message(STATUS " Armadillo ${GNSSSDR_ARMADILLO_LOCAL_VERSION} will be downloaded and built automatically") - message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'. ") - set(armadillo_BRANCH ${GNSSSDR_ARMADILLO_LOCAL_VERSION}) - set(armadillo_RELEASE ${armadillo_BRANCH}) + message(STATUS " Armadillo has not been found.") + message(STATUS " Armadillo ${GNSSSDR_ARMADILLO_LOCAL_VERSION} will be downloaded and built automatically") + message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'. ") + set(armadillo_BRANCH ${GNSSSDR_ARMADILLO_LOCAL_VERSION}) + set(armadillo_RELEASE ${armadillo_BRANCH}) - ############################################# - # Check if GFORTRAN is found in the system - ############################################# - if(NOT OS_IS_MACOSX) - find_package(GFORTRAN) - if(NOT GFORTRAN) - message(STATUS "The gfortran library has not been found.") - message(STATUS " You can try to install it by typing:") - if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo yum install gcc-fortran") - elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(STATUS " sudo zypper install gcc-fortran") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo apt-get install gfortran") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(FATAL_ERROR "gfortran is required to build gnss-sdr") - endif(NOT GFORTRAN) - endif(NOT OS_IS_MACOSX) + ############################################# + # Check if GFORTRAN is found in the system + ############################################# + if(NOT OS_IS_MACOSX) + find_package(GFORTRAN) + if(NOT GFORTRAN) + message(STATUS "The gfortran library has not been found.") + message(STATUS " You can try to install it by typing:") + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(STATUS " sudo yum install gcc-fortran") + elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") + message(STATUS " sudo zypper install gcc-fortran") + else() + message(STATUS " sudo apt-get install gfortran") + endif() + message(FATAL_ERROR "gfortran is required to build gnss-sdr") + endif() + endif() - ############################################# - # Download and build Armadillo - ############################################# - if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - armadillo-${armadillo_RELEASE} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} - GIT_REPOSITORY https://github.com/conradsnicta/armadillo-code.git - GIT_TAG ${armadillo_BRANCH} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} - CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=-std=c++11 - BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} - UPDATE_COMMAND "" - INSTALL_COMMAND "" - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - armadillo-${armadillo_RELEASE} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} - GIT_REPOSITORY https://github.com/conradsnicta/armadillo-code.git - GIT_TAG ${armadillo_BRANCH} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} - CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=-std=c++11 - BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} - UPDATE_COMMAND "" - INSTALL_COMMAND "" - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) + ############################################# + # Download and build Armadillo + ############################################# + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add(armadillo-${armadillo_RELEASE} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} + GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git + GIT_TAG ${armadillo_BRANCH} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} + CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=-std=c++11 + BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} + UPDATE_COMMAND "" + INSTALL_COMMAND "" + ) + else() + ExternalProject_Add(armadillo-${armadillo_RELEASE} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} + GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git + GIT_TAG ${armadillo_BRANCH} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} + CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=-std=c++11 + BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} + UPDATE_COMMAND "" + INSTALL_COMMAND "" + ) + endif() - # Set up variables - ExternalProject_Get_Property(armadillo-${armadillo_RELEASE} binary_dir) - set(ARMADILLO_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE}/include ) - if(NOT GFORTRAN) - set(GFORTRAN "") - endif(NOT GFORTRAN) - set(ARMADILLO_LIBRARIES ${BLAS} ${LAPACK} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}) - set(LOCAL_ARMADILLO true CACHE STRING "Armadillo downloaded and built automatically" FORCE) - set(ARMADILLO_VERSION_STRING ${armadillo_RELEASE}) -else(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) - set(armadillo_RELEASE ${ARMADILLO_VERSION_STRING}) - add_library(armadillo-${armadillo_RELEASE} UNKNOWN IMPORTED) - set_property(TARGET armadillo-${armadillo_RELEASE} PROPERTY IMPORTED_LOCATION "${ARMADILLO_LIBRARIES}") -endif(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) + # Set up variables + ExternalProject_Get_Property(armadillo-${armadillo_RELEASE} binary_dir) + #set(ARMADILLO_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE}/include) + if(NOT GFORTRAN) + set(GFORTRAN "") + endif() + set(ARMADILLO_LIBRARIES ${BLAS} ${LAPACK} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(LOCAL_ARMADILLO true CACHE STRING "Armadillo downloaded and built automatically" FORCE) + set(ARMADILLO_VERSION_STRING ${armadillo_RELEASE}) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE}/include) + add_library(Armadillo::armadillo STATIC IMPORTED) + add_dependencies(Armadillo::armadillo armadillo-${armadillo_RELEASE}) + set_target_properties(Armadillo::armadillo PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE}/include" + INTERFACE_LINK_LIBRARIES "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) +endif() @@ -1036,60 +1298,60 @@ endif(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) ################################################################################ find_package(GnuTLS) find_library(GNUTLS_OPENSSL_LIBRARY NAMES gnutls-openssl libgnutls-openssl.so.27 - HINTS /usr/lib - /usr/lib64 - /usr/local/lib - /usr/local/lib64 - /opt/local/lib - /usr/lib/x86_64-linux-gnu - /usr/lib/aarch64-linux-gnu - /usr/lib/arm-linux-gnueabihf - /usr/lib/arm-linux-gnueabi - /usr/lib/i386-linux-gnu - /usr/lib/alpha-linux-gnu - /usr/lib/hppa-linux-gnu - /usr/lib/i386-gnu - /usr/lib/i686-gnu - /usr/lib/i686-linux-gnu - /usr/lib/x86_64-kfreebsd-gnu - /usr/lib/i686-kfreebsd-gnu - /usr/lib/m68k-linux-gnu - /usr/lib/mips-linux-gnu - /usr/lib/mips64el-linux-gnuabi64 - /usr/lib/mipsel-linux-gnu - /usr/lib/powerpc-linux-gnu - /usr/lib/powerpc-linux-gnuspe - /usr/lib/powerpc64-linux-gnu - /usr/lib/powerpc64le-linux-gnu - /usr/lib/s390x-linux-gnu - /usr/lib/sparc64-linux-gnu - /usr/lib/x86_64-linux-gnux32 - /usr/lib/sh4-linux-gnu - ) + HINTS /usr/lib + /usr/lib64 + /usr/local/lib + /usr/local/lib64 + /opt/local/lib + /usr/lib/x86_64-linux-gnu + /usr/lib/aarch64-linux-gnu + /usr/lib/arm-linux-gnueabihf + /usr/lib/arm-linux-gnueabi + /usr/lib/i386-linux-gnu + /usr/lib/alpha-linux-gnu + /usr/lib/hppa-linux-gnu + /usr/lib/i386-gnu + /usr/lib/i686-gnu + /usr/lib/i686-linux-gnu + /usr/lib/x86_64-kfreebsd-gnu + /usr/lib/i686-kfreebsd-gnu + /usr/lib/m68k-linux-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/mipsel-linux-gnu + /usr/lib/powerpc-linux-gnu + /usr/lib/powerpc-linux-gnuspe + /usr/lib/powerpc64-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/lib/sparc64-linux-gnu + /usr/lib/x86_64-linux-gnux32 + /usr/lib/sh4-linux-gnu +) if(NOT GNUTLS_OPENSSL_LIBRARY) - message(STATUS "Looking for OpenSSL instead...") - find_package(OpenSSL) - if(OPENSSL_FOUND) + message(STATUS "Looking for OpenSSL instead...") + find_package(OpenSSL) + if(OPENSSL_FOUND) set(GNUTLS_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}) set(GNUTLS_LIBRARIES "") set(GNUTLS_OPENSSL_LIBRARY ${OPENSSL_SSL_LIBRARY}) - else(OPENSSL_FOUND) - message(" The GnuTLS library with openssl compatibility enabled has not been found.") - message(" You can try to install the required libraries by typing:") - if(OS_IS_LINUX) + else() + message(" The GnuTLS library with openssl compatibility enabled has not been found.") + message(" You can try to install the required libraries by typing:") + if(OS_IS_LINUX) if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") message(" sudo yum install openssl-devel") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + else() message(" sudo apt-get install libgnutls-openssl-dev") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - endif(OS_IS_LINUX) - if(OS_IS_MACOSX) + endif() + endif() + if(OS_IS_MACOSX) message(" sudo port install gnutls") - endif(OS_IS_MACOSX) - message(FATAL_ERROR "GnuTLS libraries with openssl compatibility are required to build gnss-sdr") - endif(OPENSSL_FOUND) -endif(NOT GNUTLS_OPENSSL_LIBRARY) + endif() + message(FATAL_ERROR "GnuTLS libraries with openssl compatibility are required to build gnss-sdr") + endif() +endif() @@ -1099,8 +1361,8 @@ endif(NOT GNUTLS_OPENSSL_LIBRARY) find_package(MATIO) if(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERSION}) if(MATIO_FOUND) - message(STATUS " Matio installed version (${MATIO_VERSION_STRING}) is too old (>= ${GNSSSDR_MATIO_MIN_VERSION} is required).") - endif(MATIO_FOUND) + message(STATUS " Matio installed version (${MATIO_VERSION_STRING}) is too old (>= ${GNSSSDR_MATIO_MIN_VERSION} is required).") + endif() message(STATUS " Matio v${GNSSSDR_MATIO_LOCAL_VERSION} will be downloaded and built automatically") message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'. ") find_package(ZLIB) @@ -1114,26 +1376,32 @@ if(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERS message(" sudo yum groupinstall 'Development Tools'") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") message(" sudo zypper install libtoool") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + else() message(" sudo apt-get install libtool") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + endif() message(FATAL_ERROR "libtool is required to build matio from source") - endif(NOT EXISTS "/usr/bin/libtoolize") - if(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") + endif() + if(EXISTS "/usr/bin/aclocal" OR + EXISTS "/usr/bin/aclocal-1.16" OR + EXISTS "/usr/bin/aclocal-1.15" OR + EXISTS "/usr/bin/aclocal-1.14" OR + EXISTS "/usr/bin/aclocal-1.13" OR + EXISTS "/usr/bin/aclocal-1.11" OR + EXISTS "/usr/bin/aclocal-1.10") message(STATUS "Automake found.") - else(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") + else() message(" aclocal has not been found.") message(" You can try to install it by typing:") if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") message(" sudo yum groupinstall 'Development Tools'") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") message(" sudo zypper install automake") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + else() message(" sudo apt-get install automake") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + endif() message(FATAL_ERROR "aclocal is required to build matio from source") - endif(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") - endif(OS_IS_LINUX) + endif() + endif() find_package(HDF5) if(HDF5_FOUND) list(GET HDF5_LIBRARIES 0 HDF5_FIRST_DIR) @@ -1142,73 +1410,121 @@ if(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERS if(OS_IS_MACOSX) if(EXISTS /opt/local/include/hdf5.h) set(HDF5_BASE_DIR /opt/local) - endif(EXISTS /opt/local/include/hdf5.h) + endif() if(EXISTS /usr/local/include/hdf5.h) set(HDF5_BASE_DIR /usr/local) - endif(EXISTS /usr/local/include/hdf5.h) - endif(OS_IS_MACOSX) + endif() + endif() + if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - matio-${GNSSSDR_MATIO_LOCAL_VERSION} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio - GIT_REPOSITORY https://github.com/tbeu/matio - GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION} - UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= - BUILD_COMMAND make - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - matio-${GNSSSDR_MATIO_LOCAL_VERSION} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio - GIT_REPOSITORY https://github.com/tbeu/matio - GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION} - UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= - BUILD_COMMAND make - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) - set(MATIO_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ) - set(MATIO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/matio/include ) + ExternalProject_Add(matio-${GNSSSDR_MATIO_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio + GIT_REPOSITORY https://github.com/tbeu/matio + GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION} + UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= + BUILD_COMMAND $(MAKE) + ) + else() + ExternalProject_Add(matio-${GNSSSDR_MATIO_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio + GIT_REPOSITORY https://github.com/tbeu/matio + GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION} + UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= + BUILD_COMMAND $(MAKE) + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + endif() set(MATIO_LOCAL true) - else(HDF5_FOUND) + if(NOT TARGET Matio::matio) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/matio/include) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/matio/lib) + add_library(Matio::matio SHARED IMPORTED) + add_dependencies(Matio::matio matio-${GNSSSDR_MATIO_LOCAL_VERSION}) + set_target_properties(Matio::matio PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_SHARED_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/matio/include" + INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_SHARED_LIBRARY_SUFFIX}" + ) + endif() + else() message(STATUS " The hdf5 library has not been found in your system.") message(STATUS " Please try to install it by doing:") if(OS_IS_MACOSX) message(STATUS " $ sudo port install hdf5") message(STATUS " or") message(STATUS " $ brew install hdf5") - endif(OS_IS_MACOSX) + endif() if(OS_IS_LINUX) message(STATUS " $ sudo apt-get install libhdf5-dev") - endif(OS_IS_LINUX) + endif() message(FATAL_ERROR "*** The hdf5 library is required to build gnss-sdr") - endif(HDF5_FOUND) - else(ZLIB_FOUND) + endif() + else() message(FATAL_ERROR "*** The zlib library is required to build gnss-sdr") - endif(ZLIB_FOUND) -endif(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERSION}) + endif() +endif() ################################################################################ -# USRP Hardware Driver (UHD) - OPTIONAL +# PugiXML - https://pugixml.org/ ################################################################################ -if(ENABLE_UHD) - find_package(UHD) - if(NOT UHD_FOUND) - set(ENABLE_UHD OFF) - message(STATUS " The USRP Hardware Driver (UHD) signal source will not be built,") - message(STATUS " so all USRP-based front-ends will not be usable.") - message(STATUS " Please check https://files.ettus.com/manual/") - else(NOT UHD_FOUND) - set(GR_REQUIRED_COMPONENTS UHD) - find_package(Gnuradio) - endif(NOT UHD_FOUND) -endif(ENABLE_UHD) +find_package(PUGIXML QUIET) +if(PUGIXML_FOUND) + message(STATUS "PugiXML has been found.") +else() + message(STATUS " PugiXML v${GNSSSDR_PUGIXML_LOCAL_VERSION} will be downloaded and built automatically when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'.") + set(PUGIXML_COMPILER -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}) + set(TOOLCHAIN_ARG "") + if(EXISTS $ENV{OECORE_TARGET_SYSROOT}) + set(PUGIXML_COMPILER "") + set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake") + endif() + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add(pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/zeux/pugixml + GIT_TAG v${GNSSSDR_PUGIXML_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + CMAKE_ARGS ${PUGIXML_COMPILER} ${TOOLCHAIN_ARG} + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + ) + else() + ExternalProject_Add(pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/zeux/pugixml + GIT_TAG v${GNSSSDR_PUGIXML_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} + CMAKE_ARGS ${PUGIXML_COMPILER} ${TOOLCHAIN_ARG} + UPDATE_COMMAND "" + PATCH_COMMAND "" + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX} + INSTALL_COMMAND "" + ) + endif() + + if(NOT TARGET Pugixml::pugixml) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/src) + add_library(Pugixml::pugixml STATIC IMPORTED) + add_dependencies(Pugixml::pugixml pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}) + set_target_properties(Pugixml::pugixml PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/src" + INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() +endif() + ################################################################################ @@ -1216,62 +1532,62 @@ endif(ENABLE_UHD) ################################################################################ find_package(Doxygen) if(DOXYGEN_FOUND) - message(STATUS "Doxygen found.") - message(STATUS "You can build the documentation with '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} doc'." ) - message(STATUS "When done, point your browser to ${CMAKE_BINARY_DIR}/html/index.html") - set(HAVE_DOT ${DOXYGEN_DOT_FOUND}) - file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} top_srcdir) - file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} top_builddir) - find_package(LATEX) - if (PDFLATEX_COMPILER) - set(GENERATE_PDF_DOCUMENTATION "YES") - set(GNSSSDR_USE_MATHJAX "NO") - else(PDFLATEX_COMPILER) - set(GENERATE_PDF_DOCUMENTATION "NO") - set(GNSSSDR_USE_MATHJAX "YES") - endif(PDFLATEX_COMPILER) - configure_file(${CMAKE_SOURCE_DIR}/docs/doxygen/Doxyfile.in - ${CMAKE_BINARY_DIR}/docs/doxygen/Doxyfile - @ONLY - ) - add_custom_target(doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/docs/doxygen/Doxyfile - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen." VERBATIM - ) - if(LATEX_COMPILER) - message(STATUS "'${CMAKE_MAKE_PROGRAM_PRETTY_NAME} pdfmanual' will generate a manual at ${CMAKE_BINARY_DIR}/docs/GNSS-SDR_manual.pdf") - add_custom_target(pdfmanual - COMMAND ${CMAKE_MAKE_PROGRAM} - COMMAND ${CMAKE_COMMAND} -E copy refman.pdf ${CMAKE_BINARY_DIR}/docs/GNSS-SDR_manual.pdf - COMMAND ${CMAKE_MAKE_PROGRAM} clean - DEPENDS doc - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/docs/latex - COMMENT "Generating PDF manual with Doxygen." VERBATIM - ) - endif(LATEX_COMPILER) - message(STATUS "'${CMAKE_MAKE_PROGRAM_PRETTY_NAME} doc-clean' will clean the documentation.") - add_custom_target(doc-clean - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/docs/html - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/docs/latex - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/docs/GNSS-SDR_manual.pdf - COMMENT "Cleaning documentation." VERBATIM - ) -else(DOXYGEN_FOUND) - message(STATUS " Doxygen has not been found in your system.") - message(STATUS " You can get nice code documentation by using it!") - message(STATUS " Get it from http://www.stack.nl/~dimitri/doxygen/index.html") - if(OS_IS_LINUX) - if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " or simply by doing 'sudo yum install doxygen-latex'.") - else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " or simply by doing 'sudo apt-get install doxygen-latex'.") - endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - endif(OS_IS_LINUX) - if(OS_IS_MACOSX) - message(STATUS " or simply by doing 'sudo port install doxygen +latex'.") - endif(OS_IS_MACOSX) -endif(DOXYGEN_FOUND) + message(STATUS "Doxygen found.") + message(STATUS " You can build the documentation with '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} doc'.") + message(STATUS " When done, point your browser to ${CMAKE_BINARY_DIR}/html/index.html") + set(HAVE_DOT ${DOXYGEN_DOT_FOUND}) + file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} top_srcdir) + file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} top_builddir) + find_package(LATEX) + if(PDFLATEX_COMPILER) + set(GENERATE_PDF_DOCUMENTATION "YES") + set(GNSSSDR_USE_MATHJAX "NO") + else() + set(GENERATE_PDF_DOCUMENTATION "NO") + set(GNSSSDR_USE_MATHJAX "YES") + endif() + configure_file(${CMAKE_SOURCE_DIR}/docs/doxygen/Doxyfile.in + ${CMAKE_BINARY_DIR}/docs/doxygen/Doxyfile + @ONLY + ) + add_custom_target(doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/docs/doxygen/Doxyfile + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen." VERBATIM + ) + if(LATEX_COMPILER) + message(STATUS " '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} pdfmanual' will generate a manual at ${CMAKE_BINARY_DIR}/docs/GNSS-SDR_manual.pdf") + add_custom_target(pdfmanual + COMMAND ${CMAKE_MAKE_PROGRAM} + COMMAND ${CMAKE_COMMAND} -E copy refman.pdf ${CMAKE_BINARY_DIR}/docs/GNSS-SDR_manual.pdf + COMMAND ${CMAKE_MAKE_PROGRAM} clean + DEPENDS doc + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/docs/latex + COMMENT "Generating PDF manual with Doxygen." VERBATIM + ) + endif() + message(STATUS " '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} doc-clean' will clean the documentation.") + add_custom_target(doc-clean + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/docs/html + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/docs/latex + COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/docs/GNSS-SDR_manual.pdf + COMMENT "Cleaning documentation." VERBATIM + ) +else() + message(STATUS " Doxygen has not been found in your system.") + message(STATUS " You can get nice code documentation by using it!") + message(STATUS " Get it from http://www.stack.nl/~dimitri/doxygen/index.html") + if(OS_IS_LINUX) + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(STATUS " or simply by doing 'sudo yum install doxygen-latex'.") + else() + message(STATUS " or simply by doing 'sudo apt-get install doxygen-latex'.") + endif() + endif() + if(OS_IS_MACOSX) + message(STATUS " or simply by doing 'sudo port install doxygen +latex'.") + endif() +endif() @@ -1279,28 +1595,28 @@ endif(DOXYGEN_FOUND) # OpenCL (OPTIONAL) ############################################################################### if(ENABLE_OPENCL) - find_package(OpenCL) + find_package(OPENCL) if($ENV{DISABLE_OPENCL}) set(DISABLE_OPENCL TRUE) - endif($ENV{DISABLE_OPENCL}) + endif() if(DISABLE_OPENCL) set(OPENCL_FOUND FALSE) - else(DISABLE_OPENCL) + else() if(OPENCL_FOUND) message(STATUS "OpenCL has been found and will be used by some processing blocks") - message(STATUS "You can disable OpenCL use by doing 'cmake -DENABLE_OPENCL=OFF ../' ") - endif(OPENCL_FOUND) - endif(DISABLE_OPENCL) + message(STATUS " You can disable OpenCL use by doing 'cmake -DENABLE_OPENCL=OFF ..' ") + endif() + endif() if(ENABLE_GENERIC_ARCH) set(OPENCL_FOUND FALSE) message(STATUS "ENABLE_GENERIC_ARCH is set to ON so the use of OpenCL has been disabled.") - endif(ENABLE_GENERIC_ARCH) + endif() if(NOT OPENCL_FOUND) message(STATUS "Processing blocks using OpenCL will not be built.") - endif(NOT OPENCL_FOUND) -else(ENABLE_OPENCL) + endif() +else() set(OPENCL_FOUND FALSE) -endif(ENABLE_OPENCL) +endif() @@ -1308,18 +1624,32 @@ endif(ENABLE_OPENCL) # CUDA (OPTIONAL) ############################################################################### if($ENV{CUDA_GPU_ACCEL}) - message(STATUS "CUDA_GPU_ACCEL environment variable found." ) + message(STATUS "CUDA_GPU_ACCEL environment variable found.") set(ENABLE_CUDA ON) -endif($ENV{CUDA_GPU_ACCEL}) +endif() if(ENABLE_CUDA) - FIND_PACKAGE(CUDA REQUIRED) - message(STATUS "NVIDIA CUDA GPU Acceleration will be enabled." ) - message(STATUS "You can disable it with 'cmake -DENABLE_CUDA=OFF ../'" ) -else(ENABLE_CUDA) - message(STATUS "NVIDIA CUDA GPU Acceleration will be not enabled." ) - message(STATUS "Enable it with 'cmake -DENABLE_CUDA=ON ../' to add support for GPU-based acceleration using CUDA." ) -endif(ENABLE_CUDA) + find_package(CUDA REQUIRED) + message(STATUS "NVIDIA CUDA GPU Acceleration will be enabled.") + message(STATUS " You can disable it with 'cmake -DENABLE_CUDA=OFF ..'") +else() + message(STATUS "NVIDIA CUDA GPU Acceleration will be not enabled.") + message(STATUS " Enable it with 'cmake -DENABLE_CUDA=ON ..' to add support for GPU-based acceleration using CUDA.") +endif() + + + +############################################################################### +# CUSTOM UDP PACKET SOURCE (OPTIONAL) +############################################################################### +if(ENABLE_RAW_UDP) + message(STATUS "High-optimized custom UDP IP packet source is enabled.") + message(STATUS " You can disable it with 'cmake -DENABLE_RAW_UDP=OFF ..'") + find_package(PCAP) + if(NOT PCAP_FOUND) + message(FATAL_ERROR "PCAP required to compile custom UDP packet sample source (with ENABLE_RAW_UDP=ON)") + endif() +endif() @@ -1327,119 +1657,191 @@ endif(ENABLE_CUDA) # FPGA (OPTIONAL) ############################################################################### if(ENABLE_FPGA) - message(STATUS "FPGA Acceleration will be enabled." ) - message(STATUS "You can disable it with 'cmake -DENABLE_FPGA=OFF ../'" ) -else(ENABLE_FPGA) - message(STATUS "Fpga Acceleration will be not enabled." ) - message(STATUS "Enable it with 'cmake -DENABLE_FPGA=ON ../' to add support for GPU-based acceleration using the FPGA." ) -endif(ENABLE_FPGA) + message(STATUS "FPGA Acceleration will be enabled.") + message(STATUS " You can disable it with 'cmake -DENABLE_FPGA=OFF ..'") +else() + message(STATUS "Fpga Acceleration will be not enabled.") + message(STATUS " Enable it with 'cmake -DENABLE_FPGA=ON ..' to add support for GPU-based acceleration using the FPGA.") +endif() ################################################################################ # Setup of optional drivers ################################################################################ -if($ENV{GN3S_DRIVER}) - message(STATUS "GN3S_DRIVER environment variable found." ) - set(ENABLE_GN3S ON) -endif($ENV{GN3S_DRIVER}) -if(GN3S_DRIVER) - set(ENABLE_GN3S ON) -endif(GN3S_DRIVER) -if(ENABLE_GN3S) - message(STATUS "The GN3S driver will be compiled.") - message(STATUS "You can disable it with 'cmake -DENABLE_GN3S=OFF ../'" ) -else(ENABLE_GN3S) - message(STATUS "The (optional and experimental) GN3S driver is not enabled." ) - message(STATUS "Enable it with 'cmake -DENABLE_GN3S=ON ../' to add support for the GN3S dongle." ) -endif(ENABLE_GN3S) -if($ENV{RAW_ARRAY_DRIVER}) - message(STATUS "RAW_ARRAY_DRIVER environment variable found." ) - set(ENABLE_ARRAY ON) -endif($ENV{RAW_ARRAY_DRIVER}) +######################################## +# USRP Hardware Driver (UHD) - OPTIONAL +######################################## +if(ENABLE_UHD) + find_package(UHD) + if(NOT UHD_FOUND) + set(ENABLE_UHD OFF) + message(STATUS " The USRP Hardware Driver (UHD) signal source will not be built,") + message(STATUS " so all USRP-based front-ends will not be usable.") + message(STATUS " Please check https://files.ettus.com/manual/") + else() + set(GR_REQUIRED_COMPONENTS UHD) + find_package(Gnuradio) + if(NOT TARGET Gnuradio::uhd) + add_library(Gnuradio::uhd SHARED IMPORTED) + list(GET GNURADIO_UHD_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_UHD_DIR ${FIRST_DIR} ABSOLUTE) + set_target_properties(Gnuradio::uhd PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNURADIO_UHD_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${GNURADIO_UHD_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GNURADIO_UHD_LIBRARIES}" + ) + endif() + endif() +endif() -if(RAW_ARRAY_DRIVER) - set(ENABLE_ARRAY ON) -endif(RAW_ARRAY_DRIVER) - -if(ENABLE_ARRAY) - message(STATUS "CTTC's Antenna Array front-end driver will be compiled." ) - message(STATUS "You can disable it with 'cmake -DENABLE_ARRAY=OFF ../'" ) - # copy firmware to install folder - # Build project gr-dbfcttc -else(ENABLE_ARRAY) - message(STATUS "The (optional) CTTC's Antenna Array front-end driver is not enabled." ) - message(STATUS "Enable it with 'cmake -DENABLE_ARRAY=ON ../' to add support for the CTTC experimental array front-end." ) -endif(ENABLE_ARRAY) +########################################## +# gr-osmosdr - OPTIONAL +# https://github.com/osmocom/gr-osmosdr +########################################## if($ENV{RTLSDR_DRIVER}) - message(STATUS "RTLSDR_DRIVER environment variable found." ) + message(STATUS "RTLSDR_DRIVER environment variable found.") set(ENABLE_OSMOSDR ON) -endif($ENV{RTLSDR_DRIVER}) +endif() if(ENABLE_OSMOSDR) - find_package(GrOsmoSDR) + find_package(GROSMOSDR) if(GROSMOSDR_FOUND) - message(STATUS "The driver for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based dongles, etc.) will be compiled." ) - message(STATUS "You can disable it with 'cmake -DENABLE_OSMOSDR=OFF ../'" ) - else(GROSMOSDR_FOUND) + message(STATUS "The driver for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based dongles, etc.) will be compiled.") + message(STATUS " You can disable it with 'cmake -DENABLE_OSMOSDR=OFF ..'") + else() if(ENABLE_PACKAGING) - message(WARNING "gr-osmosdr has not been found. Source blocks depending on it will NOT be built.") - else(ENABLE_PACKAGING) - message(FATAL_ERROR "gr-osmosdr required to build gnss-sdr with the optional OSMOSDR driver") - endif(ENABLE_PACKAGING) - endif(GROSMOSDR_FOUND) -else(ENABLE_OSMOSDR) - message(STATUS "The (optional) driver for OsmoSDR and related front-ends is not enabled." ) - message(STATUS "Enable it with 'cmake -DENABLE_OSMOSDR=ON ../' to add support for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based USB dongles, etc.)" ) -endif(ENABLE_OSMOSDR) + message(WARNING "gr-osmosdr has not been found. Source blocks depending on it will NOT be built.") + else() + message(FATAL_ERROR "gr-osmosdr required to build gnss-sdr with the optional OSMOSDR driver") + endif() + endif() +else() + message(STATUS "The (optional) driver for OsmoSDR and related front-ends is not enabled.") + message(STATUS " Enable it with 'cmake -DENABLE_OSMOSDR=ON ..' to add support for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based USB dongles, etc.)") +endif() + +############################################## +# gr-iio - OPTIONAL +# IIO blocks for GNU Radio +# https://github.com/analogdevicesinc/gr-iio +############################################## +if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + find_package(GRIIO) + find_package(LIBIIO) +endif() + + +################################################################################### +# libiio - OPTIONAL +# A cross platform library for interfacing with local and remote Linux IIO devices +# https://github.com/analogdevicesinc/libiio +################################################################################### +if(ENABLE_AD9361) + find_package(LIBIIO) +endif() + + +############################################## +# TELEORBIT FLEXIBAND FRONTEND - OPTIONAL +############################################## if($ENV{FLEXIBAND_DRIVER}) - message(STATUS "FLEXIBAND_DRIVER environment variable found." ) + message(STATUS "FLEXIBAND_DRIVER environment variable found.") set(ENABLE_FLEXIBAND ON) -endif($ENV{FLEXIBAND_DRIVER}) +endif() if(FLEXIBAND_DRIVER) set(ENABLE_FLEXIBAND ON) -endif(FLEXIBAND_DRIVER) +endif() if(ENABLE_FLEXIBAND) - message(STATUS "The Teleorbit Flexiband front-end source will be compiled." ) - message(STATUS "You can disable it with 'cmake -DENABLE_FLEXIBAND=OFF ../'" ) -else(ENABLE_FLEXIBAND) - message(STATUS "The (optional) Teleorbit Flexiband front-end driver adapter is not enabled." ) - message(STATUS "Enable it with 'cmake -DENABLE_FLEXIBAND=ON ../' to add support for the Teleorbit Flexiband front-end." ) -endif(ENABLE_FLEXIBAND) + message(STATUS "The Teleorbit Flexiband front-end source will be compiled.") + message(STATUS " You can disable it with 'cmake -DENABLE_FLEXIBAND=OFF ..'") +else() + message(STATUS "The (optional) Teleorbit Flexiband front-end driver adapter is not enabled.") + message(STATUS " Enable it with 'cmake -DENABLE_FLEXIBAND=ON ..' to add support for the Teleorbit Flexiband front-end.") +endif() +if(ENABLE_FLEXIBAND) + find_package(TELEORBIT) + if(NOT TELEORBIT_FOUND) + message(FATAL_ERROR "Teleorbit Flexiband GNU Radio driver required to build gnss-sdr with the optional FLEXIBAND adapter") + endif() +endif() + + +############################################## +# GN3S - OPTIONAL +############################################## +if($ENV{GN3S_DRIVER}) + message(STATUS "GN3S_DRIVER environment variable found.") + set(ENABLE_GN3S ON) +endif() +if(GN3S_DRIVER) + set(ENABLE_GN3S ON) +endif() +if(ENABLE_GN3S) + message(STATUS "The GN3S driver will be compiled.") + message(STATUS " You can disable it with 'cmake -DENABLE_GN3S=OFF ..'") + find_package(GRGN3S QUIET) +else() + message(STATUS "The (optional and experimental) GN3S driver is not enabled.") + message(STATUS " Enable it with 'cmake -DENABLE_GN3S=ON ..' to add support for the GN3S dongle.") +endif() + + +####################################################### +# CTTC's digital array beamformer prototype - OPTIONAL +####################################################### +if($ENV{RAW_ARRAY_DRIVER}) + message(STATUS "RAW_ARRAY_DRIVER environment variable found.") + set(ENABLE_ARRAY ON) +endif() + +if(RAW_ARRAY_DRIVER) + set(ENABLE_ARRAY ON) +endif() + +if(ENABLE_ARRAY) + message(STATUS "CTTC's Antenna Array front-end driver will be compiled.") + message(STATUS " You can disable it with 'cmake -DENABLE_ARRAY=OFF ..'") + find_package(GRDBFCTTC QUIET) +else() + message(STATUS "The (optional) CTTC's Antenna Array front-end driver is not enabled.") + message(STATUS " Enable it with 'cmake -DENABLE_ARRAY=ON ..' to add support for the CTTC experimental array front-end.") +endif() ################################################################################ -# GPerftools - https://github.com/gperftools/gperftools (OPTIONAL) +# GPerftools - https://github.com/gperftools/gperftools - OPTIONAL) ################################################################################ if(ENABLE_GPERFTOOLS) - find_package(Gperftools) - if ( NOT GPERFTOOLS_FOUND ) + find_package(GPERFTOOLS) + if(NOT GPERFTOOLS_FOUND) message(STATUS "Although ENABLE_GPERFTOOLS has been set to ON, GPerftools has not been found.") - message(STATUS "Binaries will be compiled without 'tcmalloc' and 'profiler' libraries.") - message(STATUS "You can install GPerftools from https://github.com/gperftools/gperftools") - else( NOT GPERFTOOLS_FOUND ) - message(STATUS "GPerftools libraries found." ) - message(STATUS "Binaries will be compiled with 'tcmalloc' and 'profiler' libraries.") - endif( NOT GPERFTOOLS_FOUND ) -endif(ENABLE_GPERFTOOLS) + message(STATUS " Binaries will be compiled without 'tcmalloc' and 'profiler' libraries.") + message(STATUS " You can install GPerftools from https://github.com/gperftools/gperftools") + else() + message(STATUS "GPerftools libraries found.") + message(STATUS " Binaries will be compiled with 'tcmalloc' and 'profiler' libraries.") + endif() +endif() if(ENABLE_GPERFTOOLS) # Set GPerftools related flags if it is available # See https://github.com/gperftools/gperftools/blob/master/README if(GPERFTOOLS_FOUND) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free") - endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + add_compile_options(-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free) + endif() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -fno-builtin") - endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - endif(GPERFTOOLS_FOUND) -endif(ENABLE_GPERFTOOLS) + add_compile_options(-fno-builtin) + endif() + endif() +endif() @@ -1447,106 +1849,83 @@ endif(ENABLE_GPERFTOOLS) # GNU gprof (OPTIONAL) - https://sourceware.org/binutils/docs/gprof/ ######################################################################## if(ENABLE_GPROF) - #if(CMAKE_COMPILER_IS_GNUCXX) - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -pg") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") - #endif(CMAKE_COMPILER_IS_GNUCXX) -endif(ENABLE_GPROF) - + add_compile_options(-pg) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") +endif() ######################################################################## # Set compiler flags ######################################################################## -# Support of C++17 is still not possible due to pm_remez.h (solved in GNU Radio 3.8) -# Enable C++14 support in GCC >= 6.1.1 -# Fallback to C++11 when using GCC < 6.1.1 -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") - else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") - # if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - # else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") - # set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") - # endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") - endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html -endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - -# Support of C++17 is still not possible due to pm_remez.h (solved in GNU Radio 3.8) -# Enable C++14 support in Clang >= 3.5.0 or AppleClang >= 600 -# Fallback to C++11 if older version -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if(OS_IS_MACOSX) - # See https://trac.macports.org/wiki/XcodeVersionInfo for Apple Clang version equivalences - if(CLANG_VERSION VERSION_LESS "600") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") - else(CLANG_VERSION VERSION_LESS "600") - # if(CLANG_VERSION VERSION_LESS "900") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - # else(CLANG_VERSION VERSION_LESS "900") - # set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") - # endif(CLANG_VERSION VERSION_LESS "900") - endif(CLANG_VERSION VERSION_LESS "600") - else(OS_IS_MACOSX) - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") - else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") - # if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - # else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") - # set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") - # endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") - endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") - endif(OS_IS_MACOSX) - - if(OS_IS_MACOSX) - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -stdlib=libc++") - endif(OS_IS_MACOSX) -endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - -if(NOT (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - if(NOT (CMAKE_VERSION VERSION_LESS "3.1")) - set(CMAKE_C_STANDARD 11) - set(CMAKE_CXX_STANDARD 14) - endif(NOT (CMAKE_VERSION VERSION_LESS "3.1")) -endif(NOT (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + # Add warning flags + # For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html + set(cxx_warning_flags -Wall -Wextra) + if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) + add_compile_options("$<$:${cxx_warning_flags}>") + else() + add_compile_options("$<$,CXX>:${cxx_warning_flags}>") + endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") + add_compile_options(-Wno-missing-field-initializers) + endif() + if(CMAKE_CROSSCOMPILING) + add_compile_options(-Wno-psabi) + endif() +endif() # Processor-architecture related flags # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html -if (NOT ARCH_COMPILER_FLAGS) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - if(OS_IS_MACOSX) - set(ARCH_COMPILER_FLAGS "-march=corei7 -mfpmath=sse") - else(OS_IS_MACOSX) - if(NOT ${ENABLE_GENERIC_ARCH}) - if(IS_ARM) # ARM-specific options (https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html) - if(NOT CMAKE_CROSSCOMPILING) - if(ARM_VERSION STREQUAL "arm") - # Unknown arm version - try our best to detect - set(ARCH_COMPILER_FLAGS "-mcpu=native") - else(ARM_VERSION STREQUAL "arm") - set(ARCH_COMPILER_FLAGS "-march=${ARM_VERSION}") - endif(ARM_VERSION STREQUAL "arm") - endif(NOT CMAKE_CROSSCOMPILING) - else(IS_ARM) - set(ARCH_COMPILER_FLAGS "-march=native -mfpmath=sse") - endif(IS_ARM) - endif(NOT ${ENABLE_GENERIC_ARCH}) - endif(OS_IS_MACOSX) - endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) -endif (NOT ARCH_COMPILER_FLAGS) -set(MY_CXX_FLAGS "${MY_CXX_FLAGS} ${ARCH_COMPILER_FLAGS}") +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + if(OS_IS_MACOSX) + add_compile_options(-march=corei7 -mfpmath=sse) + else() + if(NOT ENABLE_GENERIC_ARCH) + if(IS_ARM) + # ARM-specific options + # See https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html + if(NOT CMAKE_CROSSCOMPILING) + if(ARM_VERSION STREQUAL "arm") + # Unknown arm version - try our best to detect + add_compile_options(-mcpu=native) + else() + add_compile_options(-march=${ARM_VERSION}) + endif() + endif() + else() + add_compile_options(-march=native -mfpmath=sse) + endif() + endif() + endif() +endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS}") -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - # https://gcc.gnu.org/wiki/Visibility - add_definitions(-fvisibility=hidden) -endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +######################################################################## +# clang-tidy https://clang.llvm.org/extra/clang-tidy/index.html +######################################################################## +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(NOT (CMAKE_VERSION VERSION_LESS "3.6")) + find_program( + CLANG_TIDY_EXE + NAMES "clang-tidy" + DOC "Path to clang-tidy executable" + ) + if(NOT CLANG_TIDY_EXE) + message(STATUS "clang-tidy not found.") + else() + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + if(ENABLE_CLANG_TIDY) + message(STATUS " clang-tidy will be used in compilation. You can disable it with 'cmake -DENABLE_CLANG_TIDY=OFF ..'") + else() + message(STATUS " You can enable clang-tidy usage in compilation with 'cmake -DENABLE_CLANG_TIDY=ON ..'") + endif() + set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-fix") + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + endif() + endif() +endif() ######################################################################## diff --git a/MANIFEST.md b/MANIFEST.md index ad39cfa7a..ea64ec678 100644 --- a/MANIFEST.md +++ b/MANIFEST.md @@ -5,17 +5,24 @@ tags: - gnss - gps - Galileo + - Glonass author: - Carles Fernandez-Prades - Javier Arribas - et altri (see AUTHORS file for a list of contributors) copyright_owner: - The Authors -dependencies: gnuradio (>= 3.7.3), armadillo, gflags, glog, gnutls +dependencies: + - gnuradio (>= 3.7.3) + - armadillo + - gflags + - glog + - gnutls + - matio license: GPLv3+ repo: https://github.com/gnss-sdr/gnss-sdr website: https://gnss-sdr.org -icon: https://a.fsdn.com/con/app/proj/gnss-sdr/screenshots/logo400x400.jpg +icon: https://gnss-sdr.org/assets/images/logo400x400.jpg --- Global Navigation Satellite Systems receiver defined by software. It performs all the signal processing from raw signal samples up to the computation of the Position-Velocity-Time solution, diff --git a/README.md b/README.md index 55eb8d21b..f8f48bfd2 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,26 @@ [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) + **Welcome to GNSS-SDR!** This program is a software-defined receiver which is able to process (that is, to perform detection, synchronization, demodulation and decoding of the navigation message, computation of observables and, finally, computation of position fixes) the following Global Navigation Satellite System's signals: -In the L1 band (centered at 1575.42 MHz): - - 🛰 GPS L1 C/A :white_check_mark: - - 🛰 Galileo E1b/c :white_check_mark: - - 🛰 GLONASS L1 C/A :white_check_mark: +In the L1 band: + - 🛰 BeiDou B1I (centered at 1561.098 MHz) :white_check_mark: + - 🛰 GPS L1 C/A (centered at 1575.42 MHz) :white_check_mark: + - 🛰 Galileo E1b/c (centered at 1575.42 MHz) :white_check_mark: + - 🛰 GLONASS L1 C/A (centered at 1602.00 MHz) :white_check_mark: -In the L2 band (centered at 1227.60 MHz): - - 🛰 GPS L2C :white_check_mark: - - 🛰 GLONASS L2 C/A :white_check_mark: +In the L2 band: + - 🛰 GPS L2C (centered at 1227.60 MHz) :white_check_mark: + - 🛰 GLONASS L2 C/A (centered at 1246.00 MHz) :white_check_mark: -In the L5 band (centered at 1176.45 MHz): - - 🛰 GPS L5 :white_check_mark: - - 🛰 Galileo E5a :white_check_mark: +In the L5 band: + - 🛰 GPS L5 (centered at 1176.45 MHz) :white_check_mark: + - 🛰 Galileo E5a (centered at 1176.45 MHz) :white_check_mark: -GNSS-SDR provides interfaces for a wide range of radio frequency front-ends, generates processing outputs in standard formats, allows for the full inspection of the whole signal processing chain, and offers a framework for the development of new features. Please visit [https://gnss-sdr.org](https://gnss-sdr.org "GNSS-SDR website") for more information about this open source software-defined GNSS receiver. +GNSS-SDR provides interfaces for a wide range of radio frequency front-ends and raw sample file formats, generates processing outputs in standard formats, allows for the full inspection of the whole signal processing chain, and offers a framework for the development of new features. Please visit [https://gnss-sdr.org](https://gnss-sdr.org "GNSS-SDR website") for more information about this open source software-defined GNSS receiver. @@ -64,10 +66,11 @@ $ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev \ libboost-serialization-dev liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr \ libblas-dev liblapack-dev libarmadillo-dev libgflags-dev libgoogle-glog-dev \ - libgnutls-openssl-dev python-mako python-six libmatio-dev googletest + libgnutls-openssl-dev libpcap-dev python-mako python-six libmatio-dev libpugixml-dev \ + libgtest-dev ~~~~~~ -Please note that `googletest` was named `libgtest-dev` in distributions older than Debian 9 "stretch" and Ubuntu 17.04 "zesty". +Please note that the required files from `libgtest-dev` were moved to `googletest` in Debian 9 "stretch" and Ubuntu 18.04 "bionic", and moved back again to `libgtest-dev` in Debian 10 "buster" and Ubuntu 18.10 "cosmic". **Note for Ubuntu 14.04 LTS "trusty" users:** you will need to build from source and install GNU Radio manually, as explained below, since GNSS-SDR requires `gnuradio-dev` >= 3.7.3, and Ubuntu 14.04 came with 3.7.2. Install all the packages above BUT EXCEPT `libuhd-dev`, `gnuradio-dev` and `gr-osmosdr` (and remove them if they are already installed in your machine), and install those dependencies using PyBOMBS. The same applies to `libmatio-dev`: Ubuntu 14.04 came with 1.5.2 and the minimum required version is 1.5.3. Please do not install the `libmatio-dev` package and install `libtool`, `automake` and `libhdf5-dev` instead. A recent version of the library will be downloaded and built automatically if CMake does not find it installed. @@ -85,7 +88,7 @@ $ sudo yum install make automake gcc gcc-c++ kernel-devel cmake git boost-devel boost-date-time boost-system boost-filesystem boost-thread boost-chrono \ boost-serialization log4cpp-devel gnuradio-devel gr-osmosdr-devel \ blas-devel lapack-devel matio-devel armadillo-devel gflags-devel \ - glog-devel openssl-devel python-mako python-six + glog-devel openssl-devel libpcap-devel python-mako python-six pugixml-devel ~~~~~~ Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux). @@ -102,26 +105,26 @@ $ sudo yum install make automake gcc gcc-c++ kernel-devel libtool \ hdf5-devel cmake git boost-devel boost-date-time boost-system \ boost-filesystem boost-thread boost-chrono boost-serialization \ log4cpp-devel gnuradio-devel gr-osmosdr-devel blas-devel lapack-devel \ - armadillo-devel openssl-devel python-mako python-six + armadillo-devel openssl-devel libpcap-devel python-mako python-six pugixml-devel ~~~~~~ Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux). #### Arch Linux -If you are using Arch Linux (with base-devel group installed): +If you are using Arch Linux: ~~~~~~ -$ pacman -S cmake git boost boost-libs log4cpp libvolk gnuradio gnuradio-osmosdr \ - blas lapack gflags google-glog gnutls openssl python2-mako python2-six \ - libmatio gtest +$ pacman -S gcc make cmake git boost boost-libs log4cpp libvolk gnuradio \ + gnuradio-osmosdr blas lapack gflags google-glog openssl pugixml \ + python-mako python-six libmatio libpcap gtest ~~~~~~ Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux). ### Alternative 2: Install dependencies using PyBOMBS -This option is adequate if you are interested in development, in working with the most recent versions of software dependencies, want more fine tuning on the installed versions, or simply in building everything from the scratch just for the fun of it. In such cases, we recommend to use [PyBOMBS](http://gnuradio.org/pybombs "Python Build Overlay Managed Bundle System wiki") (Python Build Overlay Managed Bundle System), GNU Radio's meta-package manager tool that installs software from source, or whatever the local package manager is, that automatically does all the work for you. Please take a look at the configuration options and general PyBOMBS usage at https://github.com/gnuradio/pybombs. Here we provide a quick step-by-step tutorial. +This option is adequate if you are interested in development, in working with the most recent versions of software dependencies, want more fine tuning on the installed versions, or simply in building everything from the scratch just for the fun of it. In such cases, we recommend to use [PyBOMBS](https://github.com/gnuradio/pybombs "Python Build Overlay Managed Bundle System") (Python Build Overlay Managed Bundle System), GNU Radio's meta-package manager tool that installs software from source, or whatever the local package manager is, that automatically does all the work for you. Please take a look at the configuration options and general PyBOMBS usage at https://github.com/gnuradio/pybombs. Here we provide a quick step-by-step tutorial. First of all, install some basic packages: @@ -182,27 +185,28 @@ or manually as explained below, and then please follow instructions on how to [d #### Install [Armadillo](http://arma.sourceforge.net/ "Armadillo's Homepage"), a C++ linear algebra library: ~~~~~~ -$ sudo apt-get install libopenblas-dev liblapack-dev # For Debian/Ubuntu/LinuxMint +$ sudo apt-get install libblas-dev liblapack-dev # For Debian/Ubuntu/LinuxMint $ sudo yum install lapack-devel blas-devel # For Fedora/CentOS/RHEL $ sudo zypper install lapack-devel blas-devel # For OpenSUSE -$ wget http://sourceforge.net/projects/arma/files/armadillo-8.500.0.tar.xz -$ tar xvfz armadillo-8.500.0.tar.xz -$ cd armadillo-8.500.0 +$ sudo pacman -S blas lapack # For Arch Linux +$ wget https://sourceforge.net/projects/arma/files/armadillo-9.200.7.tar.xz +$ tar xvfz armadillo-9.200.7.tar.xz +$ cd armadillo-9.200.7 $ cmake . $ make $ sudo make install ~~~~~~ -The full stop separated from ```cmake``` by a space is important. [CMake](http://www.cmake.org/ "CMake's Homepage") will figure out what other libraries are currently installed and will modify Armadillo's configuration correspondingly. CMake will also generate a run-time armadillo library, which is a combined alias for all the relevant libraries present on your system (eg. BLAS, LAPACK and ATLAS). +The full stop separated from ```cmake``` by a space is important. [CMake](https://cmake.org/ "CMake's Homepage") will figure out what other libraries are currently installed and will modify Armadillo's configuration correspondingly. CMake will also generate a run-time armadillo library, which is a combined alias for all the relevant libraries present on your system (eg. BLAS, LAPACK and ATLAS). #### Install [Gflags](https://github.com/gflags/gflags "Gflags' Homepage"), a commandline flags processing module for C++: ~~~~~~ -$ wget https://github.com/gflags/gflags/archive/v2.2.1.tar.gz -$ tar xvfz v2.2.1.tar.gz -$ cd gflags-2.2.1 +$ wget https://github.com/gflags/gflags/archive/v2.2.2.tar.gz +$ tar xvfz v2.2.2.tar.gz +$ cd gflags-2.2.2 $ cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DBUILD_gflags_nothreads_LIB=OFF . $ make $ sudo make install @@ -228,28 +232,30 @@ $ sudo ldconfig #### Build the [Google C++ Testing Framework](https://github.com/google/googletest "Googletest Homepage"), also known as Google Test: ~~~~~~ -$ wget https://github.com/google/googletest/archive/release-1.8.0.zip -$ unzip release-1.8.0.zip -$ cd googletest-release-1.8.0 -$ cmake -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF . +$ wget https://github.com/google/googletest/archive/release-1.8.1.zip +$ unzip release-1.8.1.zip +$ cd googletest-release-1.8.1 +$ cmake -DINSTALL_GTEST=OFF -DBUILD_GMOCK=OFF . $ make ~~~~~~ Please **DO NOT install** Google Test (do *not* type ```sudo make install```). Every user needs to compile his tests using the same compiler flags used to compile the installed Google Test libraries; otherwise he may run into undefined behaviors (i.e. the tests can behave strangely and may even crash for no obvious reasons). The reason is that C++ has this thing called the One-Definition Rule: if two C++ source files contain different definitions of the same class/function/variable, and you link them together, you violate the rule. The linker may or may not catch the error (in many cases it is not required by the C++ standard to catch the violation). If it does not, you get strange run-time behaviors that are unexpected and hard to debug. If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of ```#if``` in Google Test). Therefore, for your sanity, we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests. The building system of GNSS-SDR does the compilation and linking of googletest to its own tests; it is only required that you tell the system where the googletest folder that you downloaded resides. Just add to your ```$HOME/.bashrc``` file the following line: ~~~~~~ -export GTEST_DIR=/home/username/googletest-release-1.8.0/googletest +export GTEST_DIR=/home/username/googletest-release-1.8.1/googletest ~~~~~~ -changing `/home/username/googletest-release-1.8.0/googletest` by the actual directory where you built googletest. +changing `/home/username/googletest-release-1.8.1/googletest` by the actual directory where you built googletest. -#### Install the [GnuTLS](http://www.gnutls.org/ "GnuTLS's Homepage") or [OpenSSL](https://www.openssl.org/ "OpenSSL's Homepage") libraries: +#### Install the [GnuTLS](https://www.gnutls.org/ "GnuTLS's Homepage") or [OpenSSL](https://www.openssl.org/ "OpenSSL's Homepage") libraries: ~~~~~~ $ sudo apt-get install libgnutls-openssl-dev # For Debian/Ubuntu/LinuxMint $ sudo yum install openssl-devel # For Fedora/CentOS/RHEL +$ sudo zypper install openssl-devel # For OpenSUSE +$ sudo pacman -S openssl # For Arch Linux ~~~~~~ In case the GnuTLS library with openssl extensions package is not available in your GNU/Linux distribution, GNSS-SDR can also work well with OpenSSL. @@ -513,10 +519,7 @@ More details can be found in our tutorial about [GNSS-SDR configuration options macOS and Mac OS X --------- - -### macOS 10.13 (High Sierra) and 10.12 (Sierra), Mac OS X 10.11 (El Capitan), 10.10 (Yosemite) and 10.9 (Mavericks). - -If you still have not installed [Xcode](http://developer.apple.com/xcode/ "Xcode"), do it now from the App Store (it's free). You will also need the Xcode Command Line Tools. Launch the Terminal, found in /Applications/Utilities/, and type: +GNSS-SDR can be built on MacOS or Mac OS X, starting from 10.9 (Mavericks) and including 10.14 (Mojave). If you still have not installed [Xcode](https://developer.apple.com/xcode/ "Xcode"), do it now from the App Store (it's free). You will also need the Xcode Command Line Tools. Launch the Terminal, found in /Applications/Utilities/, and type: ~~~~~~ $ xcode-select --install @@ -532,7 +535,7 @@ Software pre-requisites can be installed using either [Macports](#macports) or [ #### Macports -First, [install Macports](http://www.macports.org/install.php). If you are upgrading from a previous installation, please follow the [migration rules](http://trac.macports.org/wiki/Migration). +First, [install Macports](https://www.macports.org/install.php). If you are upgrading from a previous installation, please follow the [migration rules](https://trac.macports.org/wiki/Migration). In a terminal, type: @@ -547,6 +550,7 @@ $ sudo port install google-glog +gflags $ sudo port install py27-mako $ sudo port install py27-six $ sudo port install matio +$ sudo port install pugixml ~~~~~~ You also might need to activate a Python installation. The list of installed versions can be retrieved with: @@ -555,7 +559,7 @@ You also might need to activate a Python installation. The list of installed ver $ port select list python ~~~~~~ -and you can activate a certain version (2.7 works well) by typing: +and you can activate a certain version by typing: ~~~~~~ $ sudo port select --set python python27 @@ -569,7 +573,7 @@ First, install [Homebrew](https://brew.sh/). Paste this in a terminal prompt: $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ~~~~~~ -The script explains what it will do and then pauses before it does it. There are more installation options [here](https://docs.brew.sh/Installation.html). +The script explains what it will do, and then it pauses before doing it. There are more installation options [here](https://docs.brew.sh/Installation.html). Install pip: @@ -580,16 +584,26 @@ $ sudo easy_install pip Install the required dependencies: ~~~~~~ -$ brew tap homebrew/science -$ brew install cmake hdf5 arpack superlu -$ brew install armadillo -$ brew install glog gflags gnutls +$ brew install cmake +$ brew install hdf5 arpack superlu armadillo +$ brew install glog gflags $ brew install gnuradio $ brew install libmatio +$ brew install log4cpp +$ brew install pugixml $ pip install mako $ pip install six +$ brew install openssl ~~~~~~ +In the last step, Homebrew installs OpenSSL but it does not link it to `/usr/local`. Thus, you must manually link it instead: + +~~~~~~ +$ ln -s /usr/local/opt/openssl/include/openssl /usr/local/include +$ ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/ +~~~~~~ + + #### Build GNSS-SDR Finally, you are ready to clone the GNSS-SDR repository, configure and build the software: @@ -625,7 +639,7 @@ GNSS-SDR comes with a library which is a module of the Vector-Optimized Library ###### Other package managers -GNU Radio and other dependencies can also be installed using other package managers than Macports, such as [Fink](http://www.finkproject.org/ "Fink") or [Homebrew](http://brew.sh/ "Homebrew"). Since the version of Python that ships with OS X is great for learning but it is not good for development, you could have another Python executable in a non-standard location. If that is the case, you need to inform GNSS-SDR's configuration system by defining the `PYTHON_EXECUTABLE` variable as: +GNU Radio and other dependencies can also be installed using other package managers than Macports, such as [Fink](http://www.finkproject.org/ "Fink") or [Homebrew](https://brew.sh/ "Homebrew"). Since the version of Python that ships with OS X is great for learning but it is not good for development, you could have another Python executable in a non-standard location. If that is the case, you need to inform GNSS-SDR's configuration system by defining the `PYTHON_EXECUTABLE` variable as: ~~~~~~ cmake -DPYTHON_EXECUTABLE=/path/to/bin/python ../ @@ -646,7 +660,7 @@ Other builds --------- * **Docker container**: A technology providing operating-system-level virtualization to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud. Visit [https://github.com/carlesfernandez/docker-gnsssdr](https://github.com/carlesfernandez/docker-gnsssdr) or [https://github.com/carlesfernandez/docker-pybombs-gnsssdr](https://github.com/carlesfernandez/docker-pybombs-gnsssdr) for instructions. -* **Snap packages**: [Snaps](http://snapcraft.io) are universal Linux packages aimed to work on any distribution or device, from IoT devices to servers, desktops to mobile devices. Visit [https://github.com/carlesfernandez/snapcraft-sandbox](https://github.com/carlesfernandez/snapcraft-sandbox) for instructions. +* **Snap packages**: [Snaps](https://snapcraft.io) are universal Linux packages aimed to work on any distribution or device, from IoT devices to servers, desktops to mobile devices. Visit [https://github.com/carlesfernandez/snapcraft-sandbox](https://github.com/carlesfernandez/snapcraft-sandbox) for instructions. * **GNSS-SDR in embedded platforms**: we provide a Software Development Kit (SDK) based on [OpenEmbedded](http://www.openembedded.org/wiki/Main_Page) for cross-compiling GNSS-SDR in your desktop computer and for producing executables that can run in embedded platforms, such as a Zedboard or a Raspberry Pi 3. Visit [Cross-compiling GNSS-SDR](https://gnss-sdr.org/docs/tutorials/cross-compiling/) for instructions. @@ -694,11 +708,11 @@ Getting started 1. After building the code, you will find the ```gnss-sdr``` executable file at gnss-sdr/install. You can make it available everywhere else by ```sudo make install```. Run the profilers ```volk_profile``` and ```volk_gnsssdr_profile``` for testing all available VOLK kernels for each architecture supported by your processor. This only has to be done once. 2. In post-processing mode, you have to provide a captured GNSS signal file. 1. The signal file can be easily recorded using the GNU Radio file sink in ```gr_complex``` mode. - 2. You will need a GPS active antenna, a [USRP](http://www.ettus.com/product) and a suitable USRP daughter board to receive GPS L1 C/A signals. GNSS-SDR require to have at least 2 MHz of bandwidth in 1.57542 GHz. (remember to enable the DC bias with the daughter board jumper). + 2. You will need a GPS active antenna, a [USRP](https://www.ettus.com/product) and a suitable USRP daughter board to receive GPS L1 C/A signals. GNSS-SDR require to have at least 2 MHz of bandwidth in 1.57542 GHz. (remember to enable the DC bias with the daughter board jumper). We use a [DBSRX2](https://www.ettus.com/product/details/DBSRX2) to do the task, but you can try the newer Ettus' daughter boards as well. 3. The easiest way to capture a signal file is to use the GNU Radio Companion GUI. Only two blocks are needed: a USRP signal source connected to complex float file sink. You need to tune the USRP central frequency and decimation factor using USRP signal source properties box. We suggest using a decimation factor of 20 if you use the USRP2. This will give you 100/20 = 5 MSPS which will be enough to receive GPS L1 C/A signals. The front-end gain should also be configured. In our test with the DBSRX2 we obtained good results with ```G=50```. 4. Capture at least 80 seconds of signal in open sky conditions. During the process, be aware of USRP driver buffer underruns messages. If your hard disk is not fast enough to write data at this speed you can capture to a virtual RAM drive. 80 seconds of signal at 5 MSPS occupies less than 3 Gbytes using ```gr_complex```. - 5. If you have no access to an RF front-end, you can download a sample raw data file (that contains GPS and Galileo signals) from [here](http://sourceforge.net/projects/gnss-sdr/files/data/). + 5. If you have no access to an RF front-end, you can download a sample raw data file (that contains GPS and Galileo signals) from [here](https://sourceforge.net/projects/gnss-sdr/files/data/). 3. You are ready to configure the receiver to use your captured file among other parameters: 1. The default configuration file resides at [/usr/local/share/gnss-sdr/conf/default.conf](./conf/gnss-sdr.conf). 2. You need to review/modify at least the following settings: @@ -764,7 +778,7 @@ The name of these parameters can be anything but one reserved word: implementati SignalConditioner.implementation=Pass_Through ~~~~~~ -Since the configuration is just a set of property names and values without any meaning or syntax, the system is very versatile and easily extendable. Adding new properties to the system only implies modifications in the classes that will make use of these properties. In addition, the configuration files are not checked against any strict syntax so it is always in a correct status (as long as it contains pairs of property names and values in the [INI format](http://en.wikipedia.org/wiki/INI_file)). +Since the configuration is just a set of property names and values without any meaning or syntax, the system is very versatile and easily extendable. Adding new properties to the system only implies modifications in the classes that will make use of these properties. In addition, the configuration files are not checked against any strict syntax so it is always in a correct status (as long as it contains pairs of property names and values in the [INI format](https://en.wikipedia.org/wiki/INI_file)). @@ -875,7 +889,7 @@ SignalSource.big_endian_bytes=false ***Example: UHD Signal Source*** -The user may prefer to use a [UHD](http://code.ettus.com/redmine/ettus/projects/uhd/wiki)-compatible RF front-end and try real-time processing. For instance, for a USRP1 + DBSRX daughterboard, use: +The user may prefer to use a [UHD](https://files.ettus.com/manual/)-compatible RF front-end and try real-time processing. For instance, for a USRP1 + DBSRX daughterboard, use: ~~~~~~ ;######### SIGNAL_SOURCE CONFIG ############ @@ -1031,7 +1045,7 @@ More documentation at the [Data Type Adapter Blocks page](https://gnss-sdr.org/d #### Input filter -This block filters the input data. It can be combined with frequency translation for IF signals. The computation of the filter taps is based on parameters of GNU Radio's function [pm_remez](http://gnuradio.org/doc/doxygen/pm__remez_8h.html), that calculates the optimal (in the Chebyshev/minimax sense) FIR filter impulse response given a set of band edges, the desired response on those bands, and the weight given to the error in those bands. +This block filters the input data. It can be combined with frequency translation for IF signals. The computation of the filter taps is based on parameters of GNU Radio's function [pm_remez](https://gnuradio.org/doc/doxygen/pm__remez_8h.html), that calculates the optimal (in the Chebyshev/minimax sense) FIR filter impulse response given a set of band edges, the desired response on those bands, and the weight given to the error in those bands. The block can be configured like this: @@ -1113,6 +1127,7 @@ Each channel must be assigned to a GNSS signal, according to the following ident | GPS L1 C/A | 1C | | Galileo E1b/c | 1B | | Glonass L1 C/A | 1G | +| Beidou B1I | B1 | | GPS L2 L2C(M) | 2S | | Glonass L2 C/A | 2G | | GPS L5 | L5 | @@ -1156,7 +1171,7 @@ More documentation at the [Channels page](https://gnss-sdr.org/docs/sp-blocks/ch #### Acquisition -The first task of a GNSS receiver is to detect the presence or absence of in-view satellites. This is done by the acquisition system process, which also provides a coarse estimation of two signal parameters: the frequency shift with respect to the nominal IF frequency, and a delay term which allows the receiver to create a local code aligned with the incoming code. [AcquisitionInterface](./src/core/interfaces/acquisition_interface.h) is the common interface for all the acquisition algorithms and their corresponding implementations. Algorithms' interface, that may vary depending on the use of information external to the receiver, such as in Assisted GNSS, is defined in classes referred to as *adapters*. These adapters wrap the GNU Radio blocks interface into a compatible interface expected by AcquisitionInterface. This allows the use of existing GNU Radio blocks derived from ```gr::block```, and ensures that newly developed implementations will also be reusable in other GNU Radio-based applications. Moreover, it adds still another layer of abstraction, since each given acquisition algorithm can have different implementations (for instance using different numerical libraries). In such a way, implementations can be continuously improved without having any impact neither on the algorithm interface nor the general acquisition interface. +The first task of a GNSS receiver is to detect the presence or absence of in-view satellites. This is done by the acquisition system process, which also provides a coarse estimation of two signal parameters: the frequency shift with respect to the nominal frequency, and a delay term which allows the receiver to create a local code aligned with the incoming code. [AcquisitionInterface](./src/core/interfaces/acquisition_interface.h) is the common interface for all the acquisition algorithms and their corresponding implementations. Algorithms' interface, that may vary depending on the use of information external to the receiver, such as in Assisted GNSS, is defined in classes referred to as *adapters*. These adapters wrap the GNU Radio blocks interface into a compatible interface expected by AcquisitionInterface. This allows the use of existing GNU Radio blocks derived from ```gr::block```, and ensures that newly developed implementations will also be reusable in other GNU Radio-based applications. Moreover, it adds still another layer of abstraction, since each given acquisition algorithm can have different implementations (for instance using different numerical libraries). In such a way, implementations can be continuously improved without having any impact neither on the algorithm interface nor the general acquisition interface. Check [GpsL1CaPcpsAcquisition](./src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h) and [GalileoE1PcpsAmbiguousAcquisition](./src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h) for examples of adapters from a Parallel Code Phase Search (PCPS) acquisition block, and [pcps_acquisition_cc](./src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h) for an example of a block implementation. The source code of all the available acquisition algorithms is located at: @@ -1169,14 +1184,13 @@ Check [GpsL1CaPcpsAcquisition](./src/algorithms/acquisition/adapters/gps_l1_ca_p |---------gnuradio_blocks <- Signal processing blocks implementation ~~~~~~ -The user can select a given implementation for the algorithm to be used in each receiver channel, as well as their parameters, in the configuration file. For a GPS l1 C/A receiver: +The user can select a given implementation for the algorithm to be used in each receiver channel, as well as their parameters, in the configuration file. For a GPS L1 C/A receiver: ~~~~~~ ;######### ACQUISITION GLOBAL CONFIG ############ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition ; Acquisition algorithm selection for this channel Acquisition_1C.item_type=gr_complex -Acquisition_1C.if=0 ; Signal intermediate frequency in [Hz] -Acquisition_1C.sampled_ms=1 ; Signal block duration for the acquisition signal detection [ms] +Acquisition_1C.coherent_integration_time_ms=1 ; Signal block duration for the acquisition signal detection [ms] Acquisition_1C.threshold=0.005 ; Acquisition threshold Acquisition_1C.pfa=0.0001 ; Acquisition false alarm probability. This option overrides the threshold option. ; Only use with implementations: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition] @@ -1192,8 +1206,7 @@ and, for Galileo E1B channels: ;######### GALILEO ACQUISITION CONFIG ############ Acquisition_1B.implementation=Galileo_E1_PCPS_Ambiguous_Acquisition Acquisition_1B.item_type=gr_complex -Acquisition_1B.if=0 -Acquisition_1B.sampled_ms=4 +Acquisition_1B.coherent_integration_time_ms=4 Acquisition_1B.pfa=0.0000008 Acquisition_1B.doppler_max=15000 Acquisition_1B.doppler_step=125 @@ -1301,7 +1314,7 @@ More documentation at the [Observables Blocks page](https://gnss-sdr.org/docs/sp #### Computation of Position, Velocity and Time -Although data processing for obtaining high-accuracy PVT solutions is out of the scope of GNSS-SDR, we provide a module that can compute simple least square solutions (stored in GIS-friendly formats such as [GeoJSON](http://geojson.org/geojson-spec.html) and [KML](http://www.opengeospatial.org/standards/kml), or transmitted via serial port as [NMEA 0183](https://en.wikipedia.org/wiki/NMEA_0183) messages), and leaves room for more sophisticated positioning methods by storing observables and navigation data in [RINEX](https://en.wikipedia.org/wiki/RINEX) files (v2.11 or v3.02), and generating [RTCM](http://www.rtcm.org "Radio Technical Commission for Maritime Services") 3.2 messages that can be disseminated through the Internet in real time. +Although data processing for obtaining high-accuracy PVT solutions is out of the scope of GNSS-SDR, we provide a module that can compute position fixes (stored in GIS-friendly formats such as [GeoJSON](https://tools.ietf.org/html/rfc7946), [GPX](http://www.topografix.com/gpx.asp) and [KML](http://www.opengeospatial.org/standards/kml), or transmitted via serial port as [NMEA 0183](https://en.wikipedia.org/wiki/NMEA_0183) messages), and leaves room for more sophisticated positioning methods by storing observables and navigation data in [RINEX](https://en.wikipedia.org/wiki/RINEX) files (v2.11 or v3.02), and generating [RTCM](http://www.rtcm.org "Radio Technical Commission for Maritime Services") 3.2 messages that can be disseminated through the Internet in real time. The common interface is [PvtInterface](./src/core/interfaces/pvt_interface.h). @@ -1332,18 +1345,20 @@ PVT.rtcm_MT1077_rate_ms=1000 **Notes on the output formats:** - * **GeoJSON** is a geospatial data interchange format based on JavaScript Object Notation (JSON) supported by numerous mapping and GIS software packages, including [OpenLayers](http://openlayers.org), [Leaflet](http://leafletjs.com), [MapServer](http://www.mapserver.org), [GeoServer](http://geoserver.org), [GeoDjango](https://www.djangoproject.com), [GDAL](http://www.gdal.org), and [CartoDB](https://cartodb.com). It is also possible to use GeoJSON with [PostGIS](http://postgis.net) and [Mapnik](http://mapnik.org), both of which handle the format via the GDAL OGR conversion library. The [Google Maps Javascript API](https://developers.google.com/maps/documentation/javascript/) v3 directly supports the [integration of GeoJSON data layers](https://developers.google.com/maps/documentation/javascript/examples/layer-data-simple), and [GitHub also supports GeoJSON rendering](https://github.com/blog/1528-there-s-a-map-for-that). + * **GeoJSON** is a geospatial data interchange format based on JavaScript Object Notation (JSON) supported by numerous mapping and GIS software packages, including [OpenLayers](https://openlayers.org), [Leaflet](https://leafletjs.com), [MapServer](http://www.mapserver.org), [GeoServer](http://geoserver.org), [GeoDjango](https://www.djangoproject.com), [GDAL](http://www.gdal.org), and [CartoDB](https://cartodb.com). It is also possible to use GeoJSON with [PostGIS](https://postgis.net/) and [Mapnik](http://mapnik.org), both of which handle the format via the GDAL OGR conversion library. The [Google Maps Javascript API](https://developers.google.com/maps/documentation/javascript/) v3 directly supports the [integration of GeoJSON data layers](https://developers.google.com/maps/documentation/javascript/examples/layer-data-simple), and [GitHub also supports GeoJSON rendering](https://github.com/blog/1528-there-s-a-map-for-that). - * **KML** (Keyhole Markup Language) is an XML grammar used to encode and transport representations of geographic data for display in an earth browser. KML is an open standard officially named the OpenGIS KML Encoding Standard (OGC KML), and it is maintained by the Open Geospatial Consortium, Inc. (OGC). KML files can be displayed in geobrowsers such as [Google Earth](https://www.google.com/earth/), [Marble](https://marble.kde.org), [osgEarth](http://osgearth.org), or used with the [NASA World Wind SDK for Java](http://worldwind.arc.nasa.gov/java/). + * **KML** (Keyhole Markup Language) is an XML grammar used to encode and transport representations of geographic data for display in an earth browser. KML is an open standard officially named the OpenGIS KML Encoding Standard (OGC KML), and it is maintained by the Open Geospatial Consortium, Inc. (OGC). KML files can be displayed in geobrowsers such as [Google Earth](https://www.google.com/earth/), [Marble](https://marble.kde.org), [osgEarth](http://osgearth.org), or used with the [NASA World Wind SDK for Java](https://worldwind.arc.nasa.gov/java/). - * **NMEA 0183** is a combined electrical and data specification for communication between marine electronics such as echo sounder, sonars, anemometer, gyrocompass, autopilot, GPS receivers and many other types of instruments. It has been defined by, and is controlled by, the U.S. [National Marine Electronics Association](http://www.nmea.org/). The NMEA 0183 standard uses a simple ASCII, serial communications protocol that defines how data are transmitted in a *sentence* from one *talker* to multiple *listeners* at a time. Through the use of intermediate expanders, a talker can have a unidirectional conversation with a nearly unlimited number of listeners, and using multiplexers, multiple sensors can talk to a single computer port. At the application layer, the standard also defines the contents of each sentence (message) type, so that all listeners can parse messages accurately. Those messages can be sent through the serial port (that could be for instance a Bluetooth link) and be used/displayed by a number of software applications such as [gpsd](http://www.catb.org/gpsd/ "The UNIX GPS daemon"), [JOSM](https://josm.openstreetmap.de/ "The Java OpenStreetMap Editor"), [OpenCPN](http://opencpn.org/ocpn/ "Open Chart Plotter Navigator"), and many others (and maybe running on other devices). + * **GPX** (the GPS Exchange Format) is a light-weight XML data format for the interchange of GPS data (waypoints, routes, and tracks) between applications and Web services on the Internet. The format is open and can be used without the need to pay license fees, and it is supported by a [large list of software tools](http://www.topografix.com/gpx_resources.asp). + + * **NMEA 0183** is a combined electrical and data specification for communication between marine electronics such as echo sounder, sonars, anemometer, gyrocompass, autopilot, GPS receivers and many other types of instruments. It has been defined by, and is controlled by, the U.S. [National Marine Electronics Association](http://www.nmea.org/). The NMEA 0183 standard uses a simple ASCII, serial communications protocol that defines how data are transmitted in a *sentence* from one *talker* to multiple *listeners* at a time. Through the use of intermediate expanders, a talker can have a unidirectional conversation with a nearly unlimited number of listeners, and using multiplexers, multiple sensors can talk to a single computer port. At the application layer, the standard also defines the contents of each sentence (message) type, so that all listeners can parse messages accurately. Those messages can be sent through the serial port (that could be for instance a Bluetooth link) and be used/displayed by a number of software applications such as [gpsd](http://www.catb.org/gpsd/ "The UNIX GPS daemon"), [JOSM](https://josm.openstreetmap.de/ "The Java OpenStreetMap Editor"), [OpenCPN](https://opencpn.org/ "Open Chart Plotter Navigator"), and many others (and maybe running on other devices). * **RINEX** (Receiver Independent Exchange Format) is an interchange format for raw satellite navigation system data, covering observables and the information contained in the navigation message broadcast by GNSS satellites. This allows the user to post-process the received data to produce a more accurate result (usually with other data unknown to the original receiver, such as better models of the atmospheric conditions at time of measurement). RINEX files can be used by software packages such as [GPSTk](http://www.gpstk.org), [RTKLIB](http://www.rtklib.com/) and [gLAB](http://gage14.upc.es/gLAB/). GNSS-SDR by default generates RINEX version [3.02](https://igscb.jpl.nasa.gov/igscb/data/format/rinex302.pdf). If [2.11](https://igscb.jpl.nasa.gov/igscb/data/format/rinex211.txt) is needed, it can be requested through the `rinex_version` parameter in the configuration file: ~~~~~~ PVT.rinex_version=2 ~~~~~~ -* **RTCM SC-104** provides standards that define the data structure for differential GNSS correction information for a variety of differential correction applications. Developed by the Radio Technical Commission for Maritime Services ([RTCM](http://www.rtcm.org/overview.php#Standards "Radio Technical Commission for Maritime Services")), they have become an industry standard for communication of correction information. GNSS-SDR implements RTCM version 3.2, defined in the document *RTCM 10403.2, Differential GNSS (Global Navigation Satellite Systems) Services - Version 3* (February 1, 2013), which can be [purchased online](https://ssl29.pair.com/dmarkle/puborder.php?show=3 "RTCM Online Publication Order Form"). By default, the generated RTCM binary messages are dumped into a text file in hexadecimal format. However, GNSS-SDR is equipped with a TCP/IP server, acting as an NTRIP source that can feed an NTRIP server. NTRIP (Networked Transport of RTCM via Internet Protocol) is an open standard protocol that can be freely downloaded from [BKG](http://igs.bkg.bund.de/root_ftp/NTRIP/documentation/NtripDocumentation.pdf "Networked Transport of RTCM via Internet Protocol (Ntrip) Version 1.0"), and it is designed for disseminating differential correction data (*e.g.* in the RTCM-104 format) or other kinds of GNSS streaming data to stationary or mobile users over the Internet. The TCP/IP server can be enabled by setting ```PVT.flag_rtcm_server=true``` in the configuration file, and will be active during the execution of the software receiver. By default, the server will operate on port 2101 (which is the recommended port for RTCM services according to the Internet Assigned Numbers Authority, [IANA](http://www.iana.org/assignments/service-names-port-numbers "Service Name and Transport Protocol Port Number Registry")), and will identify the Reference Station with ID=1234. This behaviour can be changed in the configuration file: +* **RTCM SC-104** provides standards that define the data structure for differential GNSS correction information for a variety of differential correction applications. Developed by the Radio Technical Commission for Maritime Services ([RTCM](http://www.rtcm.org/differential-global-navigation-satellite--dgnss--standards.html "Radio Technical Commission for Maritime Services")), they have become an industry standard for communication of correction information. GNSS-SDR implements RTCM version 3.2, defined in the document *RTCM 10403.2, Differential GNSS (Global Navigation Satellite Systems) Services - Version 3* (February 1, 2013), which can be [purchased online](https://ssl29.pair.com/dmarkle/puborder.php?show=3 "RTCM Online Publication Order Form"). By default, the generated RTCM binary messages are dumped into a text file in hexadecimal format. However, GNSS-SDR is equipped with a TCP/IP server, acting as an NTRIP source that can feed an NTRIP server. NTRIP (Networked Transport of RTCM via Internet Protocol) is an open standard protocol that can be freely downloaded from [BKG](https://igs.bkg.bund.de/root_ftp/NTRIP/documentation/NtripDocumentation.pdf "Networked Transport of RTCM via Internet Protocol (Ntrip) Version 1.0"), and it is designed for disseminating differential correction data (*e.g.* in the RTCM-104 format) or other kinds of GNSS streaming data to stationary or mobile users over the Internet. The TCP/IP server can be enabled by setting ```PVT.flag_rtcm_server=true``` in the configuration file, and will be active during the execution of the software receiver. By default, the server will operate on port 2101 (which is the recommended port for RTCM services according to the Internet Assigned Numbers Authority, [IANA](https://www.iana.org/assignments/service-names-port-numbers/ "Service Name and Transport Protocol Port Number Registry")), and will identify the Reference Station with ID=1234. This behaviour can be changed in the configuration file: ~~~~~~ PVT.flag_rtcm_server=true PVT.rtcm_tcp_port=2102 @@ -1402,9 +1417,9 @@ Ok, now what? In order to start using GNSS-SDR, you may want to populate ```gnss-sdr/data``` folder (or anywhere else on your system) with raw data files. By "raw data" we mean the output of a Radio Frequency front-end's Analog-to-Digital converter. GNSS-SDR needs signal samples already in baseband or in passband, at a suitable intermediate frequency (on the order of MHz). Prepare your configuration file, and then you are ready for running ```gnss-sdr --config_file=your_configuration.conf```, and seeing how the file is processed. -Another interesting option is working in real-time with an RF front-end. We provide drivers for UHD-compatible hardware such as the [USRP family](http://www.ettus.com/product), for OsmoSDR and other front-ends (HackRF, bladeRF, LimeSDR), for the GN3S v2 USB dongle and for some DVB-T USB dongles. Start with a low number of channels and then increase it in order to test how many channels your processor can handle in real-time. +Another interesting option is working in real-time with an RF front-end. We provide drivers for UHD-compatible hardware such as the [USRP family](https://www.ettus.com/product), for OsmoSDR and other front-ends (HackRF, bladeRF, LimeSDR), for the GN3S v2 USB dongle and for some DVB-T USB dongles. Start with a low number of channels and then increase it in order to test how many channels your processor can handle in real-time. -You can find more information at the [GNSS-SDR Documentation page](https://gnss-sdr.org/docs/) or directly asking to the [GNSS-SDR Developers mailing list](http://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers). +You can find more information at the [GNSS-SDR Documentation page](https://gnss-sdr.org/docs/) or directly asking to the [GNSS-SDR Developers mailing list](https://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers). You are also very welcome to contribute to the project, there are many ways to [participate in GNSS-SDR](https://gnss-sdr.org/contribute/). If you need some special feature not yet implemented, the Developer Team would love to be hired for developing it. Please do not hesitate to [contact them](https://gnss-sdr.org/team/). diff --git a/cmake/Modules/CMakeParseArgumentsCopy.cmake b/cmake/Modules/CMakeParseArgumentsCopy.cmake deleted file mode 100644 index 7ce4c49ae..000000000 --- a/cmake/Modules/CMakeParseArgumentsCopy.cmake +++ /dev/null @@ -1,138 +0,0 @@ -# CMAKE_PARSE_ARGUMENTS( args...) -# -# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for -# parsing the arguments given to that macro or function. -# It processes the arguments and defines a set of variables which hold the -# values of the respective options. -# -# The argument contains all options for the respective macro, -# i.e. keywords which can be used when calling the macro without any value -# following, like e.g. the OPTIONAL keyword of the install() command. -# -# The argument contains all keywords for this macro -# which are followed by one value, like e.g. DESTINATION keyword of the -# install() command. -# -# The argument contains all keywords for this macro -# which can be followed by more than one value, like e.g. the TARGETS or -# FILES keywords of the install() command. -# -# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the -# keywords listed in , and -# a variable composed of the given -# followed by "_" and the name of the respective keyword. -# These variables will then hold the respective value from the argument list. -# For the keywords this will be TRUE or FALSE. -# -# All remaining arguments are collected in a variable -# _UNPARSED_ARGUMENTS, this can be checked afterwards to see whether -# your macro was called with unrecognized parameters. -# -# As an example here a my_install() macro, which takes similar arguments as the -# real install() command: -# -# function(MY_INSTALL) -# set(options OPTIONAL FAST) -# set(oneValueArgs DESTINATION RENAME) -# set(multiValueArgs TARGETS CONFIGURATIONS) -# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) -# ... -# -# Assume my_install() has been called like this: -# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) -# -# After the cmake_parse_arguments() call the macro will have set the following -# variables: -# MY_INSTALL_OPTIONAL = TRUE -# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() -# MY_INSTALL_DESTINATION = "bin" -# MY_INSTALL_RENAME = "" (was not used) -# MY_INSTALL_TARGETS = "foo;bar" -# MY_INSTALL_CONFIGURATIONS = "" (was not used) -# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" -# -# You can the continue and process these variables. -# -# Keywords terminate lists of values, e.g. if directly after a one_value_keyword -# another recognized keyword follows, this is interpreted as the beginning of -# the new option. -# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in -# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would -# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. - -#============================================================================= -# Copyright 2010 Alexander Neundorf -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - - -if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) - return() -endif() -set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) - - -function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) - # first set all result variables to empty/FALSE - foreach(arg_name ${_singleArgNames} ${_multiArgNames}) - set(${prefix}_${arg_name}) - endforeach(arg_name) - - foreach(option ${_optionNames}) - set(${prefix}_${option} FALSE) - endforeach(option) - - set(${prefix}_UNPARSED_ARGUMENTS) - - set(insideValues FALSE) - set(currentArgName) - - # now iterate over all arguments and fill the result variables - foreach(currentArg ${ARGN}) - list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword - - if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) - if(insideValues) - if("${insideValues}" STREQUAL "SINGLE") - set(${prefix}_${currentArgName} ${currentArg}) - set(insideValues FALSE) - elseif("${insideValues}" STREQUAL "MULTI") - list(APPEND ${prefix}_${currentArgName} ${currentArg}) - endif() - else(insideValues) - list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) - endif(insideValues) - else() - if(NOT ${optionIndex} EQUAL -1) - set(${prefix}_${currentArg} TRUE) - set(insideValues FALSE) - elseif(NOT ${singleArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "SINGLE") - elseif(NOT ${multiArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "MULTI") - endif() - endif() - - endforeach(currentArg) - - # propagate the result variables to the caller: - foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) - set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) - endforeach(arg_name) - set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) - -endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/cmake/Modules/FindGFLAGS.cmake b/cmake/Modules/FindGFLAGS.cmake new file mode 100644 index 000000000..db1f9d891 --- /dev/null +++ b/cmake/Modules/FindGFLAGS.cmake @@ -0,0 +1,122 @@ +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . + +# - Try to find GFlags +# +# The following CMake and environment variables are optionally searched +# for defaults: +# GFLAGS_ROOT: Base directory where all GFlags components are found +# +# The following are set after configuration is done: +# GFlags_FOUND +# GFlags_INCLUDE_DIRS +# GFlags_LIBS +# GFlags_LIBRARY_DIRS +# +# Provides the following imported target: +# Gflags::gflags +# + +if(APPLE) + find_path(GFlags_ROOT_DIR + libgflags.dylib + PATHS + /opt/local/lib + /usr/local/lib + ${GFLAGS_ROOT}/lib + $ENV{GFLAGS_ROOT}/lib + ) +else() + find_path(GFlags_ROOT_DIR + libgflags.so + HINTS + /usr/local/lib + /usr/lib/x86_64-linux-gnu + /usr/lib/i386-linux-gnu + /usr/lib/arm-linux-gnueabihf + /usr/lib/arm-linux-gnueabi + /usr/lib/aarch64-linux-gnu + /usr/lib/mipsel-linux-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/powerpc-linux-gnu + /usr/lib/powerpc64-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/powerpc-linux-gnuspe + /usr/lib/hppa-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/lib/i386-gnu + /usr/lib/hppa-linux-gnu + /usr/lib/x86_64-kfreebsd-gnu + /usr/lib/i386-kfreebsd-gnu + /usr/lib/m68k-linux-gnu + /usr/lib/sh4-linux-gnu + /usr/lib/sparc64-linux-gnu + /usr/lib/x86_64-linux-gnux32 + /usr/lib/alpha-linux-gnu + /usr/lib64 + /usr/lib + ${GFLAGS_ROOT}/lib + $ENV{GFLAGS_ROOT}/lib + ${GFLAGS_ROOT}/lib64 + $ENV{GFLAGS_ROOT}/lib64 + ) +endif() + +if(GFlags_ROOT_DIR) + # We are testing only a couple of files in the include directories + find_path(GFlags_INCLUDE_DIRS + gflags/gflags.h + HINTS + /opt/local/include + /usr/local/include + /usr/include + ${GFlags_ROOT_DIR}/src + ${GFLAGS_ROOT}/include + $ENV{GFLAGS_ROOT}/include + ) + + # Find the libraries + set(GFlags_LIBRARY_DIRS ${GFlags_ROOT_DIR}) + + find_library(GFlags_lib gflags ${GFlags_LIBRARY_DIRS}) + if(EXISTS ${GFlags_INCLUDE_DIRS}/gflags/gflags_gflags.h) + set(GFLAGS_GREATER_20 TRUE) + else() + set(GFLAGS_GREATER_20 FALSE) + endif() + message(STATUS "gflags library found at ${GFlags_lib}") + set(GFlags_LIBS ${GFlags_lib}) + set(GFlags_FOUND true) + mark_as_advanced(GFlags_INCLUDE_DIRS) +else() + message(STATUS "Cannot find gflags") + set(GFlags_FOUND false) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GFLAGS DEFAULT_MSG GFlags_LIBS GFlags_INCLUDE_DIRS) + +if(GFLAGS_FOUND AND NOT TARGET Gflags::gflags) + add_library(Gflags::gflags SHARED IMPORTED) + set_target_properties(Gflags::gflags PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GFlags_LIBS}" + INTERFACE_INCLUDE_DIRECTORIES "${GFlags_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GFlags_LIBS}" + ) +endif() diff --git a/cmake/Modules/FindGFORTRAN.cmake b/cmake/Modules/FindGFORTRAN.cmake index eec7a4265..f19ccd77a 100644 --- a/cmake/Modules/FindGFORTRAN.cmake +++ b/cmake/Modules/FindGFORTRAN.cmake @@ -15,126 +15,136 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . - find_library(GFORTRAN NAMES gfortran - PATHS /usr/lib - /usr/lib64 - /usr/local/lib - /usr/local/lib/i386 - /usr/lib/gcc/x86_64-linux-gnu - /usr/lib/gcc/i686-linux-gnu - /usr/lib/gcc/i386-linux-gnu - /usr/lib/gcc/x86_64-linux-gnu/4.6 # Ubuntu 12.04 - /usr/lib/gcc/i686-linux-gnu/4.6 - /usr/lib/gcc/x86_64-linux-gnu/4.7 - /usr/lib/gcc/i686-linux-gnu/4.7 - /usr/lib/gcc/x86_64-linux-gnu/4.8 - /usr/lib/gcc/i686-linux-gnu/4.8 - /usr/lib/gcc/x86_64-linux-gnu/4.9 - /usr/lib/gcc/i686-linux-gnu/4.9 - /usr/lib/gcc/x86_64-redhat-linux/4.7.2 # Fedora 18 - /usr/lib/gcc/i686-redhat-linux/4.7.2 - /usr/lib/gcc/x86_64-redhat-linux/4.8.1 # Fedora 19 - /usr/lib/gcc/x86_64-redhat-linux/4.8.3 # Fedora 20 - /usr/lib/gcc/x86_64-redhat-linux/4.9.1 # Fedora 21 - /usr/lib/gcc/i686-redhat-linux/4.8.1 - /usr/lib/gcc/i686-redhat-linux/4.8.3 - /usr/lib/gcc/i686-redhat-linux/4.9.1 - /usr/lib/gcc/x86_64-redhat-linux/4.4.4 # CentOS 6 - /usr/lib/gcc/i686-redhat-linux/4.4.4 - /usr/lib/gcc/x86_64-redhat-linux/4.8.2 - /usr/lib/gcc/i686-redhat-linux/4.8.2 - /usr/lib/gcc/x86_64-redhat-linux/7 - /usr/lib/gcc/i686-redhat-linux/7 - /usr/lib/gcc/armv7hl-redhat-linux-gnueabi/7 - /usr/lib/gcc/aarch64-redhat-linux/7 - /usr/lib/gcc/i586-suse-linux/4.8 # OpenSUSE 13.1 - /usr/lib/gcc/i586-suse-linux/4.9 - /usr/lib/gcc/x86_64-suse-linux/4.8 - /usr/lib/gcc/x86_64-suse-linux/4.9 - /usr/lib/gcc/i486-linux-gnu # Debian 7 - /usr/lib/gcc/i486-linux-gnu/4.4 - /usr/lib/gcc/i486-linux-gnu/4.6 - /usr/lib/gcc/i486-linux-gnu/4.7 - /usr/lib/gcc/i486-linux-gnu/4.8 - /usr/lib/gcc/i486-linux-gnu/4.9 - /usr/lib/gcc/i586-linux-gnu/4.9 - /usr/lib/gcc/arm-linux-gnueabihf/4.4 # Debian armhf - /usr/lib/gcc/arm-linux-gnueabihf/4.5 - /usr/lib/gcc/arm-linux-gnueabihf/4.6 - /usr/lib/gcc/arm-linux-gnueabihf/4.7 - /usr/lib/gcc/arm-linux-gnueabihf/4.8 - /usr/lib/gcc/arm-linux-gnueabihf/4.9 - /usr/lib/gcc/aarch64-linux-gnu/4.9 # Debian arm64 - /usr/lib/gcc/arm-linux-gnueabi/4.7 # Debian armel - /usr/lib/gcc/arm-linux-gnueabi/4.9 - /usr/lib/gcc/x86_64-linux-gnu/5 - /usr/lib/gcc/i686-linux-gnu/5 - /usr/lib/gcc/arm-linux-gnueabi/5 - /usr/lib/gcc/arm-linux-gnueabihf/5 - /usr/lib/gcc/aarch64-linux-gnu/5 - /usr/lib/gcc/x86_64-linux-gnu/6 # Ubuntu 16.10 - /usr/lib/gcc/alpha-linux-gnu/6 - /usr/lib/gcc/aarch64-linux-gnu/6 - /usr/lib/gcc/arm-linux-gnueabi/6 - /usr/lib/gcc/arm-linux-gnueabihf/6 - /usr/lib/gcc/hppa-linux-gnu/6 - /usr/lib/gcc/i686-gnu/6 - /usr/lib/gcc/i686-linux-gnu/6 - /usr/lib/gcc/x86_64-kfreebsd-gnu/6 - /usr/lib/gcc/i686-kfreebsd-gnu/6 - /usr/lib/gcc/m68k-linux-gnu/6 - /usr/lib/gcc/mips-linux-gnu/6 - /usr/lib/gcc/mips64el-linux-gnuabi64/6 - /usr/lib/gcc/mipsel-linux-gnu/6 - /usr/lib/gcc/powerpc-linux-gnu/6 - /usr/lib/gcc/powerpc-linux-gnuspe/6 - /usr/lib/gcc/powerpc64-linux-gnu/6 - /usr/lib/gcc/powerpc64le-linux-gnu/6 - /usr/lib/gcc/s390x-linux-gnu/6 - /usr/lib/gcc/sparc64-linux-gnu/6 - /usr/lib/gcc/x86_64-linux-gnux32/6 - /usr/lib/gcc/sh4-linux-gnu/6 - /usr/lib/gcc/x86_64-linux-gnu/7 # Debian 9 Buster - /usr/lib/gcc/alpha-linux-gnu/7 - /usr/lib/gcc/aarch64-linux-gnu/7 - /usr/lib/gcc/arm-linux-gnueabi/7 - /usr/lib/gcc/arm-linux-gnueabihf/7 - /usr/lib/gcc/hppa-linux-gnu/7 - /usr/lib/gcc/i686-gnu/7 - /usr/lib/gcc/i686-linux-gnu/7 - /usr/lib/gcc/x86_64-kfreebsd-gnu/7 - /usr/lib/gcc/i686-kfreebsd-gnu/7 - /usr/lib/gcc/m68k-linux-gnu/7 - /usr/lib/gcc/mips-linux-gnu/7 - /usr/lib/gcc/mips64el-linux-gnuabi64/7 - /usr/lib/gcc/mipsel-linux-gnu/7 - /usr/lib/gcc/powerpc-linux-gnu/7 - /usr/lib/gcc/powerpc-linux-gnuspe/7 - /usr/lib/gcc/powerpc64-linux-gnu/7 - /usr/lib/gcc/powerpc64le-linux-gnu/7 - /usr/lib/gcc/s390x-linux-gnu/7 - /usr/lib/gcc/sparc64-linux-gnu/7 - /usr/lib/gcc/x86_64-linux-gnux32/7 - /usr/lib/gcc/sh4-linux-gnu/7 - /usr/lib/x86_64-linux-gnu # libgfortran4 - /usr/lib/i386-linux-gnu - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu - /usr/lib/i386-gnu - /usr/lib/x86_64-kfreebsd-gnu - /usr/lib/i386-kfreebsd-gnu - /usr/lib/mips-linux-gnu - /usr/lib/mips64el-linux-gnuabi64 - /usr/lib/mipsel-linux-gnu - /usr/lib/powerpc-linux-gnu - /usr/lib/powerpc64-linux-gnu - /usr/lib/powerpc64le-linux-gnu - /usr/lib/s390x-linux-gnu - /usr/lib/sh4-linux-gnu - /usr/lib/sparc64-linux-gnu - /usr/lib/x86_64-linux-gnux32 - /usr/lib/alpha-linux-gnu - ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GFORTRAN DEFAULT_MSG GFORTRAN) \ No newline at end of file +find_library(GFORTRAN NAMES gfortran + PATHS /usr/lib + /usr/lib64 + /usr/local/lib + /usr/local/lib/i386 + /usr/lib/gcc/x86_64-linux-gnu + /usr/lib/gcc/i686-linux-gnu + /usr/lib/gcc/i386-linux-gnu + /usr/lib/gcc/x86_64-linux-gnu/4.6 # Ubuntu 12.04 + /usr/lib/gcc/i686-linux-gnu/4.6 + /usr/lib/gcc/x86_64-linux-gnu/4.7 + /usr/lib/gcc/i686-linux-gnu/4.7 + /usr/lib/gcc/x86_64-linux-gnu/4.8 + /usr/lib/gcc/i686-linux-gnu/4.8 + /usr/lib/gcc/x86_64-linux-gnu/4.9 + /usr/lib/gcc/i686-linux-gnu/4.9 + /usr/lib/gcc/x86_64-redhat-linux/4.7.2 # Fedora 18 + /usr/lib/gcc/i686-redhat-linux/4.7.2 + /usr/lib/gcc/x86_64-redhat-linux/4.8.1 # Fedora 19 + /usr/lib/gcc/x86_64-redhat-linux/4.8.3 # Fedora 20 + /usr/lib/gcc/x86_64-redhat-linux/4.9.1 # Fedora 21 + /usr/lib/gcc/i686-redhat-linux/4.8.1 + /usr/lib/gcc/i686-redhat-linux/4.8.3 + /usr/lib/gcc/i686-redhat-linux/4.9.1 + /usr/lib/gcc/x86_64-redhat-linux/4.4.4 # CentOS 6 + /usr/lib/gcc/i686-redhat-linux/4.4.4 + /usr/lib/gcc/x86_64-redhat-linux/4.8.2 + /usr/lib/gcc/i686-redhat-linux/4.8.2 + /usr/lib/gcc/x86_64-redhat-linux/7 + /usr/lib/gcc/i686-redhat-linux/7 + /usr/lib/gcc/armv7hl-redhat-linux-gnueabi/7 + /usr/lib/gcc/aarch64-redhat-linux/7 + /usr/lib/gcc/i586-suse-linux/4.8 # OpenSUSE 13.1 + /usr/lib/gcc/i586-suse-linux/4.9 + /usr/lib/gcc/x86_64-suse-linux/4.8 + /usr/lib/gcc/x86_64-suse-linux/4.9 + /usr/lib/gcc/i486-linux-gnu # Debian 7 + /usr/lib/gcc/i486-linux-gnu/4.4 + /usr/lib/gcc/i486-linux-gnu/4.6 + /usr/lib/gcc/i486-linux-gnu/4.7 + /usr/lib/gcc/i486-linux-gnu/4.8 + /usr/lib/gcc/i486-linux-gnu/4.9 + /usr/lib/gcc/i586-linux-gnu/4.9 + /usr/lib/gcc/arm-linux-gnueabihf/4.4 # Debian armhf + /usr/lib/gcc/arm-linux-gnueabihf/4.5 + /usr/lib/gcc/arm-linux-gnueabihf/4.6 + /usr/lib/gcc/arm-linux-gnueabihf/4.7 + /usr/lib/gcc/arm-linux-gnueabihf/4.8 + /usr/lib/gcc/arm-linux-gnueabihf/4.9 + /usr/lib/gcc/aarch64-linux-gnu/4.9 # Debian arm64 + /usr/lib/gcc/arm-linux-gnueabi/4.7 # Debian armel + /usr/lib/gcc/arm-linux-gnueabi/4.9 + /usr/lib/gcc/x86_64-linux-gnu/5 + /usr/lib/gcc/i686-linux-gnu/5 + /usr/lib/gcc/arm-linux-gnueabi/5 + /usr/lib/gcc/arm-linux-gnueabihf/5 + /usr/lib/gcc/aarch64-linux-gnu/5 + /usr/lib/gcc/x86_64-linux-gnu/6 # Ubuntu 16.10 + /usr/lib/gcc/alpha-linux-gnu/6 + /usr/lib/gcc/aarch64-linux-gnu/6 + /usr/lib/gcc/arm-linux-gnueabi/6 + /usr/lib/gcc/arm-linux-gnueabihf/6 + /usr/lib/gcc/hppa-linux-gnu/6 + /usr/lib/gcc/i686-gnu/6 + /usr/lib/gcc/i686-linux-gnu/6 + /usr/lib/gcc/x86_64-kfreebsd-gnu/6 + /usr/lib/gcc/i686-kfreebsd-gnu/6 + /usr/lib/gcc/m68k-linux-gnu/6 + /usr/lib/gcc/mips-linux-gnu/6 + /usr/lib/gcc/mips64el-linux-gnuabi64/6 + /usr/lib/gcc/mipsel-linux-gnu/6 + /usr/lib/gcc/powerpc-linux-gnu/6 + /usr/lib/gcc/powerpc-linux-gnuspe/6 + /usr/lib/gcc/powerpc64-linux-gnu/6 + /usr/lib/gcc/powerpc64le-linux-gnu/6 + /usr/lib/gcc/s390x-linux-gnu/6 + /usr/lib/gcc/sparc64-linux-gnu/6 + /usr/lib/gcc/x86_64-linux-gnux32/6 + /usr/lib/gcc/sh4-linux-gnu/6 + /usr/lib/gcc/x86_64-linux-gnu/7 # Debian 9 Buster + /usr/lib/gcc/alpha-linux-gnu/7 + /usr/lib/gcc/aarch64-linux-gnu/7 + /usr/lib/gcc/arm-linux-gnueabi/7 + /usr/lib/gcc/arm-linux-gnueabihf/7 + /usr/lib/gcc/hppa-linux-gnu/7 + /usr/lib/gcc/i686-gnu/7 + /usr/lib/gcc/i686-linux-gnu/7 + /usr/lib/gcc/x86_64-kfreebsd-gnu/7 + /usr/lib/gcc/i686-kfreebsd-gnu/7 + /usr/lib/gcc/m68k-linux-gnu/7 + /usr/lib/gcc/mips-linux-gnu/7 + /usr/lib/gcc/mips64el-linux-gnuabi64/7 + /usr/lib/gcc/mipsel-linux-gnu/7 + /usr/lib/gcc/powerpc-linux-gnu/7 + /usr/lib/gcc/powerpc-linux-gnuspe/7 + /usr/lib/gcc/powerpc64-linux-gnu/7 + /usr/lib/gcc/powerpc64le-linux-gnu/7 + /usr/lib/gcc/s390x-linux-gnu/7 + /usr/lib/gcc/sparc64-linux-gnu/7 + /usr/lib/gcc/x86_64-linux-gnux32/7 + /usr/lib/gcc/sh4-linux-gnu/7 + /usr/lib/x86_64-linux-gnu # libgfortran4 + /usr/lib/i386-linux-gnu + /usr/lib/arm-linux-gnueabi + /usr/lib/arm-linux-gnueabihf + /usr/lib/aarch64-linux-gnu + /usr/lib/i386-gnu + /usr/lib/x86_64-kfreebsd-gnu + /usr/lib/i386-kfreebsd-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/mipsel-linux-gnu + /usr/lib/powerpc-linux-gnu + /usr/lib/powerpc64-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/lib/sh4-linux-gnu + /usr/lib/sparc64-linux-gnu + /usr/lib/x86_64-linux-gnux32 + /usr/lib/alpha-linux-gnu + /usr/lib/gcc/x86_64-linux-gnu/8 # libgfortran8 + /usr/lib/gcc/aarch64-linux-gnu/8 + /usr/lib/gcc/arm-linux-gnueabihf/8 + /usr/lib/gcc/i686-linux-gnu/8 + /usr/lib/gcc/powerpc64le-linux-gnu/8 + /usr/lib/gcc/s390x-linux-gnu/8 + /usr/lib/gcc/alpha-linux-gnu/8 + ${GFORTRAN_ROOT}/lib + $ENV{GFORTRAN_ROOT}/lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GFORTRAN DEFAULT_MSG GFORTRAN) diff --git a/cmake/Modules/FindGFlags.cmake b/cmake/Modules/FindGFlags.cmake deleted file mode 100644 index a0ca5ac79..000000000 --- a/cmake/Modules/FindGFlags.cmake +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) -# -# This file is part of GNSS-SDR. -# -# GNSS-SDR is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# GNSS-SDR 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNSS-SDR. If not, see . - -# - Try to find GFlags -# -# The following variables are optionally searched for defaults -# GFlags_ROOT_DIR: Base directory where all GFlags components are found -# -# The following are set after configuration is done: -# GFlags_FOUND -# GFlags_INCLUDE_DIRS -# GFlags_LIBS -# GFlags_LIBRARY_DIRS - -cmake_minimum_required(VERSION 2.6) - -if(APPLE) - FIND_PATH(GFlags_ROOT_DIR - libgflags.dylib - PATHS - /opt/local/lib - /usr/local/lib - ) -else(APPLE) - FIND_PATH(GFlags_ROOT_DIR - libgflags.so - HINTS - /usr/local/lib - /usr/lib/x86_64-linux-gnu - /usr/lib/i386-linux-gnu - /usr/lib/arm-linux-gnueabihf - /usr/lib/arm-linux-gnueabi - /usr/lib/aarch64-linux-gnu - /usr/lib/mipsel-linux-gnu - /usr/lib/mips-linux-gnu - /usr/lib/mips64el-linux-gnuabi64 - /usr/lib/powerpc-linux-gnu - /usr/lib/powerpc64-linux-gnu - /usr/lib/powerpc64le-linux-gnu - /usr/lib/powerpc-linux-gnuspe - /usr/lib/hppa-linux-gnu - /usr/lib/s390x-linux-gnu - /usr/lib/i386-gnu - /usr/lib/hppa-linux-gnu - /usr/lib/x86_64-kfreebsd-gnu - /usr/lib/i386-kfreebsd-gnu - /usr/lib/m68k-linux-gnu - /usr/lib/sh4-linux-gnu - /usr/lib/sparc64-linux-gnu - /usr/lib/x86_64-linux-gnux32 - /usr/lib/alpha-linux-gnu - /usr/lib64 - /usr/lib - ) -endif(APPLE) - -IF(GFlags_ROOT_DIR) - # We are testing only a couple of files in the include directories - FIND_PATH(GFlags_INCLUDE_DIRS - gflags/gflags.h - HINTS - /opt/local/include - /usr/local/include - /usr/include - ${GFlags_ROOT_DIR}/src - ) - - # Find the libraries - SET(GFlags_LIBRARY_DIRS ${GFlags_ROOT_DIR}) - - FIND_LIBRARY(GFlags_lib gflags ${GFlags_LIBRARY_DIRS}) - if(EXISTS ${GFlags_INCLUDE_DIRS}/gflags/gflags_gflags.h) - set(GFLAGS_GREATER_20 TRUE) - else(EXISTS ${GFlags_INCLUDE_DIRS}/gflags/gflags_gflags.h) - set(GFLAGS_GREATER_20 FALSE) - endif(EXISTS ${GFlags_INCLUDE_DIRS}/gflags/gflags_gflags.h) - # set up include and link directory - include_directories(${GFlags_INCLUDE_DIRS}) - link_directories(${GFlags_LIBRARY_DIRS}) - message(STATUS "gflags library found at ${GFlags_lib}") - SET(GFlags_LIBS ${GFlags_lib}) - SET(GFlags_FOUND true) - MARK_AS_ADVANCED(GFlags_INCLUDE_DIRS) -ELSE(GFlags_ROOT_DIR) - MESSAGE(STATUS "Cannot find gflags") - SET(GFlags_FOUND false) -ENDIF(GFlags_ROOT_DIR) - diff --git a/cmake/Modules/FindGLOG.cmake b/cmake/Modules/FindGLOG.cmake index 7c50d8805..b85339195 100644 --- a/cmake/Modules/FindGLOG.cmake +++ b/cmake/Modules/FindGLOG.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -27,21 +27,24 @@ # # GLOG_ROOT - Can be set to Glog install path or Windows build path # +# Provides the following imported target: +# Glog::glog +# -if (NOT DEFINED GLOG_ROOT) - set (GLOG_ROOT /usr /usr/local) -endif (NOT DEFINED GLOG_ROOT) +if(NOT DEFINED GLOG_ROOT) + set(GLOG_ROOT /usr /usr/local) +endif() if(MSVC) - set(LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/Release) -else(MSVC) - set (LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/lib) -endif(MSVC) + set(LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/Release) +else() + set(LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/lib) +endif() macro(_FIND_GLOG_LIBRARIES _var) - find_library(${_var} - NAMES ${ARGN} - PATHS ${LIB_PATHS} + find_library(${_var} + NAMES ${ARGN} + PATHS ${LIB_PATHS} /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu @@ -68,48 +71,52 @@ macro(_FIND_GLOG_LIBRARIES _var) /usr/lib/alpha-linux-gnu /usr/lib64 /usr/lib + ${GLOG_ROOT}/lib + $ENV{GLOG_ROOT}/lib + ${GLOG_ROOT}/lib64 + $ENV{GLOG_ROOT}/lib64 PATH_SUFFIXES lib ) - mark_as_advanced(${_var}) + mark_as_advanced(${_var}) endmacro() macro(_GLOG_APPEND_LIBRARIES _list _release) set(_debug ${_release}_DEBUG) if(${_debug}) - set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}}) + set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}}) else() - set(${_list} ${${_list}} ${${_release}}) + set(${_list} ${${_list}} ${${_release}}) endif() endmacro() if(MSVC) - find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h - PATHS - ${GLOG_ROOT}/src/windows - ${GLOG_ROOT}/src/windows/glog - ) -else(MSVC) - # Linux/OS X builds - find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h - PATHS - ${GLOG_ROOT}/include/glog - /usr/include/glog - /opt/local/include/glog # default location in Macports - ) -endif(MSVC) + find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h + PATHS + ${GLOG_ROOT}/src/windows + ${GLOG_ROOT}/src/windows/glog + ) +else() + # Linux/OS X builds + find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h + PATHS + ${GLOG_ROOT}/include/glog + /usr/include/glog + /opt/local/include/glog # default location in Macports + ) +endif() # Find the libraries if(MSVC) - _FIND_GLOG_LIBRARIES(GLOG_LIBRARIES libglog.lib) -else(MSVC) - # Linux/OS X builds - if(UNIX) - _FIND_GLOG_LIBRARIES(GLOG_LIBRARIES libglog.so) - endif(UNIX) - if(APPLE) - _FIND_GLOG_LIBRARIES(GLOG_LIBRARIES libglog.dylib) - endif(APPLE) -endif(MSVC) + _find_glog_libraries(GLOG_LIBRARIES libglog.lib) +else() + # Linux/OS X builds + if(UNIX) + _find_glog_libraries(GLOG_LIBRARIES libglog.so) + endif() + if(APPLE) + _find_glog_libraries(GLOG_LIBRARIES libglog.dylib) + endif() +endif() if(GLOG_FOUND) message(STATUS "glog library found at ${GLOG_LIBRARIES}") @@ -117,21 +124,26 @@ endif() # handle the QUIETLY and REQUIRED arguments and set GLOG_FOUND to TRUE if # all listed variables are TRUE -include("${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake") -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Glog DEFAULT_MSG - GLOG_LIBRARIES) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLOG DEFAULT_MSG GLOG_LIBRARIES) if(MSVC) - string(REGEX REPLACE "/glog$" "" VAR_WITHOUT ${GLOG_INCLUDE_DIR}) - string(REGEX REPLACE "/windows$" "" VAR_WITHOUT ${VAR_WITHOUT}) - set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS} "${VAR_WITHOUT}") - string(REGEX REPLACE "/libglog.lib" "" GLOG_LIBRARIES_DIR ${GLOG_LIBRARIES}) -else(MSVC) - # Linux/OS X builds - set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) - string(REGEX REPLACE "/libglog.so" "" GLOG_LIBRARIES_DIR ${GLOG_LIBRARIES}) -endif(MSVC) - -if(GLOG_FOUND) - # _GLOG_APPEND_LIBRARIES(GLOG GLOG_LIBRARIES) + string(REGEX REPLACE "/glog$" "" VAR_WITHOUT ${GLOG_INCLUDE_DIR}) + string(REGEX REPLACE "/windows$" "" VAR_WITHOUT ${VAR_WITHOUT}) + set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS} "${VAR_WITHOUT}") + string(REGEX REPLACE "/libglog.lib" "" GLOG_LIBRARIES_DIR ${GLOG_LIBRARIES}) +else() + # Linux/OS X builds + set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) + string(REGEX REPLACE "/libglog.so" "" GLOG_LIBRARIES_DIR ${GLOG_LIBRARIES}) +endif() + +if(GLOG_FOUND AND NOT TARGET Glog::glog) + add_library(Glog::glog SHARED IMPORTED) + set_target_properties(Glog::glog PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GLOG_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GLOG_LIBRARIES}" + ) endif() diff --git a/cmake/Modules/FindGNSSSIMULATOR.cmake b/cmake/Modules/FindGNSSSIMULATOR.cmake new file mode 100644 index 000000000..66aa9176a --- /dev/null +++ b/cmake/Modules/FindGNSSSIMULATOR.cmake @@ -0,0 +1,30 @@ +# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . + +find_program(SW_GENERATOR_BIN gnss_sim + PATHS /usr/bin + /usr/local/bin + /opt/local/bin + ${CMAKE_INSTALL_PREFIX}/bin + ${GNSSSIMULATOR_ROOT}/bin + $ENV{GNSSSIMULATOR_ROOT}/bin + PATH_SUFFIXES bin +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GNSSSIMULATOR DEFAULT_MSG SW_GENERATOR_BIN) +mark_as_advanced(SW_GENERATOR_BIN) diff --git a/cmake/Modules/FindGnuradio.cmake b/cmake/Modules/FindGNURADIO.cmake similarity index 59% rename from cmake/Modules/FindGnuradio.cmake rename to cmake/Modules/FindGNURADIO.cmake index 0205d5d82..7f5deb3ab 100644 --- a/cmake/Modules/FindGnuradio.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -19,15 +19,14 @@ # Find GNU Radio ######################################################################## -INCLUDE(FindPkgConfig) -INCLUDE(FindPackageHandleStandardArgs) +include(FindPkgConfig) +include(FindPackageHandleStandardArgs) # if GR_REQUIRED_COMPONENTS is not defined, it will be set to the following list if(NOT GR_REQUIRED_COMPONENTS) set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG BLOCKS DIGITAL FFT FILTER PMT FEC TRELLIS UHD) endif() - # Allows us to use all .cmake files in this directory list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR}) @@ -35,18 +34,17 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR}) set(GNURADIO_ALL_LIBRARIES "") set(GNURADIO_ALL_INCLUDE_DIRS "") -MACRO(LIST_CONTAINS var value) - SET(${var}) - FOREACH(value2 ${ARGN}) - IF (${value} STREQUAL ${value2}) - SET(${var} TRUE) - ENDIF(${value} STREQUAL ${value2}) - ENDFOREACH(value2) -ENDMACRO(LIST_CONTAINS) +macro(LIST_CONTAINS var value) + set(${var}) + foreach(value2 ${ARGN}) + if(${value} STREQUAL ${value2}) + set(${var} TRUE) + endif() + endforeach() +endmacro() function(GR_MODULE EXTVAR PCNAME INCFILE LIBFILE) - - LIST_CONTAINS(REQUIRED_MODULE ${EXTVAR} ${GR_REQUIRED_COMPONENTS}) + list_contains(REQUIRED_MODULE ${EXTVAR} ${GR_REQUIRED_COMPONENTS}) if(NOT REQUIRED_MODULE) #message("Ignoring GNU Radio Module ${EXTVAR}") return() @@ -55,7 +53,7 @@ function(GR_MODULE EXTVAR PCNAME INCFILE LIBFILE) message(STATUS "Checking for GNU Radio Module: ${EXTVAR}") # check for .pc hints - PKG_CHECK_MODULES(PC_GNURADIO_${EXTVAR} ${PCNAME}) + pkg_check_modules(PC_GNURADIO_${EXTVAR} ${PCNAME}) if(NOT PC_GNURADIO_${EXTVAR}_FOUND) set(PC_GNURADIO_${EXTVAR}_LIBRARIES ${LIBFILE}) @@ -67,29 +65,29 @@ function(GR_MODULE EXTVAR PCNAME INCFILE LIBFILE) set(PC_LIBDIR ${PC_GNURADIO_${EXTVAR}_LIBDIR}) # look for include files - FIND_PATH( - ${INCVAR_NAME} + find_path(${INCVAR_NAME} NAMES ${INCFILE} HINTS $ENV{GNURADIO_RUNTIME_DIR}/include - ${PC_INCDIR} - ${CMAKE_INSTALL_PREFIX}/include - ${GNURADIO_INSTALL_PREFIX}/include + ${PC_INCDIR} + ${CMAKE_INSTALL_PREFIX}/include + ${GNURADIO_INSTALL_PREFIX}/include PATHS /usr/local/include /usr/include ${GNURADIO_INSTALL_PREFIX}/include + ${GNURADIO_ROOT}/include + $ENV{GNURADIO_ROOT}/include ) # look for libs foreach(libname ${PC_GNURADIO_${EXTVAR}_LIBRARIES}) - FIND_LIBRARY( - ${LIBVAR_NAME}_${libname} + find_library(${LIBVAR_NAME}_${libname} NAMES ${libname} ${libname}-${PC_GNURADIO_RUNTIME_VERSION} HINTS $ENV{GNURADIO_RUNTIME_DIR}/lib - ${PC_LIBDIR} - ${CMAKE_INSTALL_PREFIX}/lib/ - ${CMAKE_INSTALL_PREFIX}/lib64/ - ${GNURADIO_INSTALL_PREFIX}/lib/ - ${GNURADIO_INSTALL_PREFIX}/lib64 + ${PC_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_INSTALL_PREFIX}/lib64 + ${GNURADIO_INSTALL_PREFIX}/lib + ${GNURADIO_INSTALL_PREFIX}/lib64 PATHS /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu @@ -117,9 +115,13 @@ function(GR_MODULE EXTVAR PCNAME INCFILE LIBFILE) /usr/lib64 /usr/lib ${GNURADIO_INSTALL_PREFIX}/lib + ${GNURADIO_ROOT}/lib + $ENV{GNURADIO_ROOT}/lib + ${GNURADIO_ROOT}/lib64 + $ENV{GNURADIO_ROOT}/lib64 ) - list(APPEND ${LIBVAR_NAME} ${${LIBVAR_NAME}_${libname}}) - endforeach(libname) + list(APPEND ${LIBVAR_NAME} ${${LIBVAR_NAME}_${libname}}) + endforeach() set(${LIBVAR_NAME} ${${LIBVAR_NAME}} PARENT_SCOPE) @@ -131,43 +133,42 @@ function(GR_MODULE EXTVAR PCNAME INCFILE LIBFILE) set(GNURADIO_ALL_INCLUDE_DIRS ${GNURADIO_ALL_INCLUDE_DIRS} ${GNURADIO_${EXTVAR}_INCLUDE_DIRS} PARENT_SCOPE) set(GNURADIO_ALL_LIBRARIES ${GNURADIO_ALL_LIBRARIES} ${GNURADIO_${EXTVAR}_LIBRARIES} PARENT_SCOPE) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_${EXTVAR} DEFAULT_MSG GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS) + find_package_handle_standard_args(GNURADIO_${EXTVAR} DEFAULT_MSG GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS) message(STATUS "GNURADIO_${EXTVAR}_FOUND = ${GNURADIO_${EXTVAR}_FOUND}") set(GNURADIO_${EXTVAR}_FOUND ${GNURADIO_${EXTVAR}_FOUND} PARENT_SCOPE) # generate an error if the module is missing if(NOT GNURADIO_${EXTVAR}_FOUND) - message(STATUS "Required GNU Radio Component: ${EXTVAR} missing!") + message(STATUS "Required GNU Radio Component: ${EXTVAR} missing!") endif() - MARK_AS_ADVANCED(GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS) - + mark_as_advanced(GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS) endfunction() -GR_MODULE(RUNTIME gnuradio-runtime gnuradio/top_block.h gnuradio-runtime) -GR_MODULE(ANALOG gnuradio-analog gnuradio/analog/api.h gnuradio-analog) -GR_MODULE(AUDIO gnuradio-audio gnuradio/audio/api.h gnuradio-audio) -GR_MODULE(BLOCKS gnuradio-blocks gnuradio/blocks/api.h gnuradio-blocks) -GR_MODULE(CHANNELS gnuradio-channels gnuradio/channels/api.h gnuradio-channels) -GR_MODULE(DIGITAL gnuradio-digital gnuradio/digital/api.h gnuradio-digital) -GR_MODULE(FCD gnuradio-fcd gnuradio/fcd_api.h gnuradio-fcd) -GR_MODULE(FEC gnuradio-fec gnuradio/fec/api.h gnuradio-fec) -GR_MODULE(FFT gnuradio-fft gnuradio/fft/api.h gnuradio-fft) -GR_MODULE(FILTER gnuradio-filter gnuradio/filter/api.h gnuradio-filter) -GR_MODULE(NOAA gnuradio-noaa gnuradio/noaa/api.h gnuradio-noaa) -GR_MODULE(PAGER gnuradio-pager gnuradio/pager/api.h gnuradio-pager) -GR_MODULE(QTGUI gnuradio-qtgui gnuradio/qtgui/api.h gnuradio-qtgui) -GR_MODULE(TRELLIS gnuradio-trellis gnuradio/trellis/api.h gnuradio-trellis) -GR_MODULE(UHD gnuradio-uhd gnuradio/uhd/api.h gnuradio-uhd) -GR_MODULE(VOCODER gnuradio-vocoder gnuradio/vocoder/api.h gnuradio-vocoder) -GR_MODULE(WAVELET gnuradio-wavelet gnuradio/wavelet/api.h gnuradio-wavelet) -GR_MODULE(WXGUI gnuradio-wxgui gnuradio/wxgui/api.h gnuradio-wxgui) -GR_MODULE(PMT gnuradio-runtime pmt/pmt.h gnuradio-pmt) +gr_module(RUNTIME gnuradio-runtime gnuradio/top_block.h gnuradio-runtime) +gr_module(ANALOG gnuradio-analog gnuradio/analog/api.h gnuradio-analog) +gr_module(AUDIO gnuradio-audio gnuradio/audio/api.h gnuradio-audio) +gr_module(BLOCKS gnuradio-blocks gnuradio/blocks/api.h gnuradio-blocks) +gr_module(CHANNELS gnuradio-channels gnuradio/channels/api.h gnuradio-channels) +gr_module(DIGITAL gnuradio-digital gnuradio/digital/api.h gnuradio-digital) +gr_module(FCD gnuradio-fcd gnuradio/fcd_api.h gnuradio-fcd) +gr_module(FEC gnuradio-fec gnuradio/fec/api.h gnuradio-fec) +gr_module(FFT gnuradio-fft gnuradio/fft/api.h gnuradio-fft) +gr_module(FILTER gnuradio-filter gnuradio/filter/api.h gnuradio-filter) +gr_module(NOAA gnuradio-noaa gnuradio/noaa/api.h gnuradio-noaa) +gr_module(PAGER gnuradio-pager gnuradio/pager/api.h gnuradio-pager) +gr_module(QTGUI gnuradio-qtgui gnuradio/qtgui/api.h gnuradio-qtgui) +gr_module(TRELLIS gnuradio-trellis gnuradio/trellis/api.h gnuradio-trellis) +gr_module(UHD gnuradio-uhd gnuradio/uhd/api.h gnuradio-uhd) +gr_module(VOCODER gnuradio-vocoder gnuradio/vocoder/api.h gnuradio-vocoder) +gr_module(WAVELET gnuradio-wavelet gnuradio/wavelet/api.h gnuradio-wavelet) +gr_module(WXGUI gnuradio-wxgui gnuradio/wxgui/api.h gnuradio-wxgui) +gr_module(PMT gnuradio-runtime pmt/pmt.h gnuradio-pmt) list(REMOVE_DUPLICATES GNURADIO_ALL_INCLUDE_DIRS) list(REMOVE_DUPLICATES GNURADIO_ALL_LIBRARIES) - # Trick to find out that GNU Radio is >= 3.7.4 if pkgconfig is not present +# Trick to find out that GNU Radio is >= 3.7.4 if pkgconfig is not present if(NOT PC_GNURADIO_RUNTIME_VERSION) find_file(GNURADIO_VERSION_GREATER_THAN_373 NAMES gnuradio/blocks/tsb_vector_sink_f.h @@ -177,21 +178,25 @@ if(NOT PC_GNURADIO_RUNTIME_VERSION) PATHS /usr/local/include /usr/include ${GNURADIO_INSTALL_PREFIX}/include + ${GNURADIO_ROOT}/include + $ENV{GNURADIO_ROOT}/include ) - if(GNURADIO_VERSION_GREATER_THAN_373) - set(PC_GNURADIO_RUNTIME_VERSION "3.7.4+") - endif(GNURADIO_VERSION_GREATER_THAN_373) + if(GNURADIO_VERSION_GREATER_THAN_373) + set(PC_GNURADIO_RUNTIME_VERSION "3.7.4+") + endif() - find_file(GNURADIO_VERSION_GREATER_THAN_38 - NAMES gnuradio/filter/mmse_resampler_cc.h - HINTS $ENV{GNURADIO_RUNTIME_DIR}/include - ${CMAKE_INSTALL_PREFIX}/include - ${GNURADIO_INSTALL_PREFIX}/include - PATHS /usr/local/include - /usr/include - ${GNURADIO_INSTALL_PREFIX}/include - ) - if(GNURADIO_VERSION_GREATER_THAN_38) - set(PC_GNURADIO_RUNTIME_VERSION "3.8.0+") - endif(GNURADIO_VERSION_GREATER_THAN_38) -endif(NOT PC_GNURADIO_RUNTIME_VERSION) + find_file(GNURADIO_VERSION_GREATER_THAN_38 + NAMES gnuradio/filter/mmse_resampler_cc.h + HINTS $ENV{GNURADIO_RUNTIME_DIR}/include + ${CMAKE_INSTALL_PREFIX}/include + ${GNURADIO_INSTALL_PREFIX}/include + PATHS /usr/local/include + /usr/include + ${GNURADIO_INSTALL_PREFIX}/include + ${GNURADIO_ROOT}/include + $ENV{GNURADIO_ROOT}/include + ) + if(GNURADIO_VERSION_GREATER_THAN_38) + set(PC_GNURADIO_RUNTIME_VERSION "3.8.0+") + endif() +endif() diff --git a/cmake/Modules/FindGPERFTOOLS.cmake b/cmake/Modules/FindGPERFTOOLS.cmake new file mode 100644 index 000000000..1c778574f --- /dev/null +++ b/cmake/Modules/FindGPERFTOOLS.cmake @@ -0,0 +1,132 @@ +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . + +# Tries to find Gperftools. +# +# Usage of this module as follows: +# +# find_package(GPERFTOOLS) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# GPERFTOOLS_ROOT Set this variable to the root installation of +# Gperftools if the module has problems finding +# the proper installation path. +# +# Variables defined by this module: +# +# GPERFTOOLS_FOUND System has Gperftools libs/headers +# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler) +# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers +# +# Provides the following imported targets: +# Gperftools::tcmalloc +# Gperftools::profiler +# Gperftools::gperftools +# + +find_library(GPERFTOOLS_TCMALLOC + NAMES tcmalloc + HINTS ${Gperftools_ROOT_DIR}/lib + ${GPERFTOOLS_ROOT}/lib + $ENV{GPERFTOOLS_ROOT}/lib + ${GPERFTOOLS_ROOT}/lib64 + $ENV{GPERFTOOLS_ROOT}/lib64 + /usr/lib + /usr/lib64 +) + +find_library(GPERFTOOLS_PROFILER + NAMES profiler + HINTS ${Gperftools_ROOT_DIR}/lib + ${GPERFTOOLS_ROOT}/lib + $ENV{GPERFTOOLS_ROOT}/lib + ${GPERFTOOLS_ROOT}/lib64 + $ENV{GPERFTOOLS_ROOT}/lib64 + /usr/lib + /usr/lib64 +) + +find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER + NAMES tcmalloc_and_profiler + HINTS ${Gperftools_ROOT_DIR}/lib + ${GPERFTOOLS_ROOT}/lib + $ENV{GPERFTOOLS_ROOT}/lib + ${GPERFTOOLS_ROOT}/lib64 + $ENV{GPERFTOOLS_ROOT}/lib64 + /usr/lib + /usr/lib64 +) + +find_path(GPERFTOOLS_INCLUDE_DIR + NAMES gperftools/heap-profiler.h + HINTS ${Gperftools_ROOT_DIR}/include + ${GPERFTOOLS_ROOT}/include + $ENV{GPERFTOOLS_ROOT}/include + /usr/include +) + +set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + GPERFTOOLS + DEFAULT_MSG + GPERFTOOLS_LIBRARIES + GPERFTOOLS_INCLUDE_DIR + GPERFTOOLS_TCMALLOC + GPERFTOOLS_PROFILER + +) + +if(GPERFTOOLS_FOUND AND NOT TARGET Gperftools::tcmalloc) + add_library(Gperftools::tcmalloc SHARED IMPORTED) + set_target_properties(Gperftools::tcmalloc PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPERFTOOLS_TCMALLOC}" + INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${GPERFTOOLS_TCMALLOC}" + ) +endif() + +if(GPERFTOOLS_FOUND AND NOT TARGET Gperftools::profiler) + add_library(Gperftools::profiler SHARED IMPORTED) + set_target_properties(Gperftools::profiler PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPERFTOOLS_PROFILER}" + INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${GPERFTOOLS_PROFILER}" + ) +endif() + +if(GPERFTOOLS_FOUND AND NOT TARGET Gperftools::gperftools) + add_library(Gperftools::gperftools SHARED IMPORTED) + set_target_properties(Gperftools::gperftools PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPERFTOOLS_TCMALLOC_AND_PROFILER}" + INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${GPERFTOOLS_TCMALLOC_AND_PROFILER}" + ) +endif() + +mark_as_advanced( + GPERFTOOLS_TCMALLOC + GPERFTOOLS_PROFILER + GPERFTOOLS_TCMALLOC_AND_PROFILER + GPERFTOOLS_LIBRARIES + GPERFTOOLS_INCLUDE_DIR) diff --git a/cmake/Modules/FindGPSTK.cmake b/cmake/Modules/FindGPSTK.cmake index 515878d5a..1959c3ff6 100644 --- a/cmake/Modules/FindGPSTK.cmake +++ b/cmake/Modules/FindGPSTK.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -19,29 +19,43 @@ # Find the native gpstk includes and library # This module defines # GPSTK_INCLUDE_DIR, where to find Rinex3ObsBase.hpp, etc. -# GPSTK_LIBRARIES, libraries to link against to use GPSTK. # GPSTK_FOUND, If false, do not try to use GPSTK. -# also defined, but not for general use are # GPSTK_LIBRARY, where to find the GPSTK library. -FIND_PATH(GPSTK_INCLUDE_DIR Rinex3ObsBase.hpp - HINTS /usr/include/gpstk - /usr/local/include/gpstk - /opt/local/include/gpstk ) +find_path(GPSTK_INCLUDE_DIR gpstk/Rinex3ObsBase.hpp + HINTS /usr/include + /usr/local/include + /opt/local/include + ${GPSTK_ROOT}/include + $ENV{GPSTK_ROOT}/include +) -SET(GPSTK_NAMES ${GPSTK_NAMES} gpstk libgpstk) -FIND_LIBRARY(GPSTK_LIBRARY NAMES ${GPSTK_NAMES} - HINTS /usr/lib - /usr/local/lib - /opt/local/lib ) +set(GPSTK_NAMES ${GPSTK_NAMES} gpstk libgpstk) -# handle the QUIETLY and REQUIRED arguments and set GPSTK_FOUND to TRUE if +include(GNUInstallDirs) + +find_library(GPSTK_LIBRARY NAMES ${GPSTK_NAMES} + HINTS /usr/lib + /usr/local/lib + /usr/${CMAKE_INSTALL_LIBDIR} + /usr/local/${CMAKE_INSTALL_LIBDIR} + /opt/local/lib + ${GPSTK_ROOT}/${CMAKE_INSTALL_LIBDIR} + $ENV{GPSTK_ROOT}/${CMAKE_INSTALL_LIBDIR} +) + +# handle the QUIETLY and REQUIRED arguments and set GPSTK_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GPSTK DEFAULT_MSG GPSTK_LIBRARY GPSTK_INCLUDE_DIR) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GPSTK DEFAULT_MSG GPSTK_LIBRARY GPSTK_INCLUDE_DIR) +mark_as_advanced(GPSTK_LIBRARY GPSTK_INCLUDE_DIR) -IF(GPSTK_FOUND) - SET( GPSTK_LIBRARIES ${GPSTK_LIBRARY} ) -ENDIF(GPSTK_FOUND) - -MARK_AS_ADVANCED(GPSTK_INCLUDE_DIR GPSTK_LIBRARY) +if(GPSTK_FOUND AND NOT TARGET Gpstk::gpstk) + add_library(Gpstk::gpstk SHARED IMPORTED) + set_target_properties(Gpstk::gpstk PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPSTK_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${GPSTK_INCLUDE_DIR};${GPSTK_INCLUDE_DIR}/gpstk" + INTERFACE_LINK_LIBRARIES "${GPSTK_LIBRARY}" + ) +endif() diff --git a/cmake/Modules/FindGrDbfcttc.cmake b/cmake/Modules/FindGRDBFCTTC.cmake similarity index 57% rename from cmake/Modules/FindGrDbfcttc.cmake rename to cmake/Modules/FindGRDBFCTTC.cmake index 0245514d8..64c838af1 100644 --- a/cmake/Modules/FindGrDbfcttc.cmake +++ b/cmake/Modules/FindGRDBFCTTC.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -19,20 +19,22 @@ # Find GR-DBFCTTC Module ######################################################################## -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GR_DBFCTTC gr-dbfcttc) +include(FindPkgConfig) +pkg_check_modules(PC_GR_DBFCTTC gr-dbfcttc) -FIND_PATH( +find_path( GR_DBFCTTC_INCLUDE_DIRS NAMES dbfcttc/api.h HINTS $ENV{GR_DBFCTTC_DIR}/include ${PC_GR_DBFCTTC_INCLUDEDIR} PATHS ${CMAKE_INSTALL_PREFIX}/include - /usr/include + /usr/include /usr/local/include + ${GRDBFCTTC_ROOT}/include + $ENV{GRDBFCTTC_ROOT}/include ) -FIND_LIBRARY( +find_library( GR_DBFCTTC_LIBRARIES NAMES gnuradio-dbfcttc HINTS $ENV{GR_DBFCTTC_DIR}/lib @@ -43,8 +45,23 @@ FIND_LIBRARY( /usr/lib64 /usr/local/lib /usr/local/lib64 + ${GRDBFCTTC_ROOT}/lib + $ENV{GRDBFCTTC_ROOT}/lib + ${GRDBFCTTC_ROOT}/lib64 + $ENV{GRDBFCTTC_ROOT}/lib64 ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GR_DBFCTTC DEFAULT_MSG GR_DBFCTTC_LIBRARIES GR_DBFCTTC_INCLUDE_DIRS) -MARK_AS_ADVANCED(GR_DBFCTTC_LIBRARIES GR_DBFCTTC_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GRDBFCTTC DEFAULT_MSG GR_DBFCTTC_LIBRARIES GR_DBFCTTC_INCLUDE_DIRS) + +if(GRDBFCTTC_FOUND AND NOT TARGET Gnuradio::dbfcttc) + add_library(Gnuradio::dbfcttc SHARED IMPORTED) + set_target_properties(Gnuradio::dbfcttc PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GR_DBFCTTC_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${GR_DBFCTTC_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GR_DBFCTTC_LIBRARIES}" + ) +endif() + +mark_as_advanced(GR_DBFCTTC_LIBRARIES GR_DBFCTTC_INCLUDE_DIRS) diff --git a/cmake/Modules/FindGrGN3S.cmake b/cmake/Modules/FindGRGN3S.cmake similarity index 59% rename from cmake/Modules/FindGrGN3S.cmake rename to cmake/Modules/FindGRGN3S.cmake index a1340d4a7..4664a6edb 100644 --- a/cmake/Modules/FindGrGN3S.cmake +++ b/cmake/Modules/FindGRGN3S.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -19,10 +19,10 @@ # Find GR-GN3S Module ######################################################################## -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GR_GN3S gr-gn3s) +include(FindPkgConfig) +pkg_check_modules(PC_GR_GN3S gr-gn3s) -FIND_PATH( +find_path( GR_GN3S_INCLUDE_DIRS NAMES gn3s/gn3s_api.h HINTS $ENV{GR_GN3S_DIR}/include @@ -30,9 +30,11 @@ FIND_PATH( PATHS ${CMAKE_INSTALL_PREFIX}/include /usr/local/include /usr/include + ${GRGN3S_ROOT}/include + $ENV{GRGN3S_ROOT}/include ) -FIND_LIBRARY( +find_library( GR_GN3S_LIBRARIES NAMES gr-gn3s HINTS $ENV{GR_GN3S_DIR}/lib @@ -43,8 +45,23 @@ FIND_LIBRARY( /usr/local/lib64 /usr/lib /usr/lib64 + ${GRGN3S_ROOT}/lib + $ENV{GRGN3S_ROOT}/lib + ${GRGN3S_ROOT}/lib64 + $ENV{GRGN3S_ROOT}/lib64 ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GR_GN3S DEFAULT_MSG GR_GN3S_LIBRARIES GR_GN3S_INCLUDE_DIRS) -MARK_AS_ADVANCED(GR_GN3S_LIBRARIES GR_GN3S_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GRGN3S DEFAULT_MSG GR_GN3S_LIBRARIES GR_GN3S_INCLUDE_DIRS) + +if(GRGN3S_FOUND AND NOT TARGET Gnuradio::gn3s) + add_library(Gnuradio::gn3s SHARED IMPORTED) + set_target_properties(Gnuradio::gn3s PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GR_GN3S_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${GR_GN3S_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${GR_GN3S_LIBRARIES}" + ) +endif() + +mark_as_advanced(GR_GN3S_LIBRARIES GR_GN3S_INCLUDE_DIRS) diff --git a/cmake/Modules/Findiio.cmake b/cmake/Modules/FindGRIIO.cmake similarity index 64% rename from cmake/Modules/Findiio.cmake rename to cmake/Modules/FindGRIIO.cmake index 69ee780ec..8cb8e9efc 100644 --- a/cmake/Modules/Findiio.cmake +++ b/cmake/Modules/FindGRIIO.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -15,24 +15,30 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_IIO gnuradio-iio) +# +# Provides the following imported target: +# Gnuradio::iio +# -FIND_PATH( - IIO_INCLUDE_DIRS + +include(FindPkgConfig) +pkg_check_modules(PC_IIO gnuradio-iio) + +find_path(IIO_INCLUDE_DIRS NAMES gnuradio/iio/api.h HINTS $ENV{IIO_DIR}/include - ${PC_IIO_INCLUDEDIR} + ${PC_IIO_INCLUDEDIR} PATHS ${CMAKE_INSTALL_PREFIX}/include /usr/local/include /usr/include + ${GRIIO_ROOT}/include + $ENV{GRIIO_ROOT}/include ) -FIND_LIBRARY( - IIO_LIBRARIES +find_library(IIO_LIBRARIES NAMES gnuradio-iio HINTS $ENV{IIO_DIR}/lib - ${PC_IIO_LIBDIR} + ${PC_IIO_LIBDIR} PATHS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64 /usr/local/lib @@ -61,8 +67,23 @@ FIND_LIBRARY( /usr/lib/sparc64-linux-gnu /usr/lib/x86_64-linux-gnux32 /usr/lib/sh4-linux-gnu + ${GRIIO_ROOT}/lib + $ENV{GRIIO_ROOT}/lib + ${GRIIO_ROOT}/lib64 + $ENV{GRIIO_ROOT}/lib64 ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(IIO DEFAULT_MSG IIO_LIBRARIES IIO_INCLUDE_DIRS) -MARK_AS_ADVANCED(IIO_LIBRARIES IIO_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GRIIO DEFAULT_MSG IIO_LIBRARIES IIO_INCLUDE_DIRS) + +if(GRIIO_FOUND AND NOT TARGET Gnuradio::iio) + add_library(Gnuradio::iio SHARED IMPORTED) + set_target_properties(Gnuradio::iio PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${IIO_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${IIO_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${IIO_LIBRARIES}" + ) +endif() + +mark_as_advanced(IIO_LIBRARIES IIO_INCLUDE_DIRS) diff --git a/cmake/Modules/FindGrOsmoSDR.cmake b/cmake/Modules/FindGROSMOSDR.cmake similarity index 62% rename from cmake/Modules/FindGrOsmoSDR.cmake rename to cmake/Modules/FindGROSMOSDR.cmake index 254fecef1..0054db97d 100644 --- a/cmake/Modules/FindGrOsmoSDR.cmake +++ b/cmake/Modules/FindGROSMOSDR.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -19,7 +19,7 @@ # # Usage of this module as follows: # -# find_package(GrOsmoSDR) +# find_package(GROSMOSDR) # # Variables used by this module, they can change the default behaviour and need # to be set before calling find_package: @@ -33,24 +33,35 @@ # GROSMOSDR_FOUND System has gr-osmosdr libs/headers # GROSMOSDR_LIBRARIES The gr-osmosdr libraries (gnuradio-osmosdr) # GROSMOSDR_INCLUDE_DIR The location of gr-osmosdr headers +# +# Provides the following imported target: +# Gnuradio::osmosdr +# -if(NOT GROSMOSDR_FOUND) - pkg_check_modules (GROSMOSDR_PKG gnuradio-osmosdr) - find_path(GROSMOSDR_INCLUDE_DIR - NAMES osmosdr/source.h - osmosdr/api.h - PATHS + +include(FindPkgConfig) +pkg_check_modules(GROSMOSDR_PKG gnuradio-osmosdr) + +find_path(GROSMOSDR_INCLUDE_DIR + NAMES + osmosdr/source.h + osmosdr/api.h + PATHS ${GROSMOSDR_PKG_INCLUDE_DIRS} /usr/include /usr/local/include - ) + /opt/local/include + ${GROSMOSDR_ROOT}/include + $ENV{GROSMOSDR_ROOT}/include +) - find_library(GROSMOSDR_LIBRARIES - NAMES gnuradio-osmosdr - PATHS +find_library(GROSMOSDR_LIBRARIES + NAMES gnuradio-osmosdr + PATHS ${GROSMOSDR_PKG_LIBRARY_DIRS} /usr/lib /usr/local/lib + /opt/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/lib/arm-linux-gnueabihf @@ -75,16 +86,23 @@ if(NOT GROSMOSDR_FOUND) /usr/lib/x86_64-linux-gnux32 /usr/lib/alpha-linux-gnu /usr/lib64 - ) + ${GROSMOSDR_ROOT}/lib + $ENV{GROSMOSDR_ROOT}/lib + ${GROSMOSDR_ROOT}/lib64 + $ENV{GROSMOSDR_ROOT}/lib64 +) - if(GROSMOSDR_INCLUDE_DIR AND GROSMOSDR_LIBRARIES) - set(GROSMOSDR_FOUND TRUE CACHE INTERNAL "gnuradio-osmosdr found") - message(STATUS "Found gnuradio-osmosdr: ${GROSMOSDR_INCLUDE_DIR}, ${GROSMOSDR_LIBRARIES}") - else(GROSMOSDR_INCLUDE_DIR AND GROSMOSDR_LIBRARIES) - set(GROSMOSDR_FOUND FALSE CACHE INTERNAL "gnuradio-osmosdr found") - message(STATUS "gnuradio-osmosdr not found.") - endif(GROSMOSDR_INCLUDE_DIR AND GROSMOSDR_LIBRARIES) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GROSMOSDR DEFAULT_MSG GROSMOSDR_LIBRARIES GROSMOSDR_INCLUDE_DIR) -mark_as_advanced(GROSMOSDR_INCLUDE_DIR GROSMOSDR_LIBRARIES) +if(GROSMOSDR_FOUND AND NOT TARGET Gnuradio::osmosdr) + add_library(Gnuradio::osmosdr SHARED IMPORTED) + set_target_properties(Gnuradio::osmosdr PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GROSMOSDR_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${GROSMOSDR_INCLUDE_DIR};${GROSMOSDR_INCLUDE_DIR}/osmosdr" + INTERFACE_LINK_LIBRARIES "${GROSMOSDR_LIBRARIES}" + ) +endif() -endif(NOT GROSMOSDR_FOUND) +mark_as_advanced(GROSMOSDR_LIBRARIES GROSMOSDR_INCLUDE_DIR) diff --git a/cmake/Modules/FindGperftools.cmake b/cmake/Modules/FindGperftools.cmake deleted file mode 100644 index 6e4d955b7..000000000 --- a/cmake/Modules/FindGperftools.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) -# -# This file is part of GNSS-SDR. -# -# GNSS-SDR is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# GNSS-SDR 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNSS-SDR. If not, see . - -# Tries to find Gperftools. -# -# Usage of this module as follows: -# -# find_package(Gperftools) -# -# Variables used by this module, they can change the default behaviour and need -# to be set before calling find_package: -# -# Gperftools_ROOT_DIR Set this variable to the root installation of -# Gperftools if the module has problems finding -# the proper installation path. -# -# Variables defined by this module: -# -# GPERFTOOLS_FOUND System has Gperftools libs/headers -# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler) -# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers - -find_library(GPERFTOOLS_TCMALLOC - NAMES tcmalloc - HINTS ${Gperftools_ROOT_DIR}/lib) - -find_library(GPERFTOOLS_PROFILER - NAMES profiler - HINTS ${Gperftools_ROOT_DIR}/lib) - -find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER - NAMES tcmalloc_and_profiler - HINTS ${Gperftools_ROOT_DIR}/lib) - -find_path(GPERFTOOLS_INCLUDE_DIR - NAMES gperftools/heap-profiler.h - HINTS ${Gperftools_ROOT_DIR}/include) - -set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - Gperftools - DEFAULT_MSG - GPERFTOOLS_LIBRARIES - GPERFTOOLS_INCLUDE_DIR -) - -mark_as_advanced( - Gperftools_ROOT_DIR - GPERFTOOLS_TCMALLOC - GPERFTOOLS_PROFILER - GPERFTOOLS_TCMALLOC_AND_PROFILER - GPERFTOOLS_LIBRARIES - GPERFTOOLS_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/Modules/Findlibiio.cmake b/cmake/Modules/FindLIBIIO.cmake similarity index 69% rename from cmake/Modules/Findlibiio.cmake rename to cmake/Modules/FindLIBIIO.cmake index e96d420ce..5a9a3806f 100644 --- a/cmake/Modules/Findlibiio.cmake +++ b/cmake/Modules/FindLIBIIO.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -15,10 +15,15 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_LIBIIO libiio) +# +# Provides the following imported target: +# Iio::iio +# -FIND_PATH( +include(FindPkgConfig) +pkg_check_modules(PC_LIBIIO libiio) + +find_path( LIBIIO_INCLUDE_DIRS NAMES iio.h HINTS $ENV{LIBIIO_DIR}/include @@ -27,9 +32,11 @@ FIND_PATH( /usr/local/include /usr/include /opt/local/include + ${LIBIIO_ROOT}/include + $ENV{LIBIIO_ROOT}/include ) -FIND_LIBRARY( +find_library( LIBIIO_LIBRARIES NAMES iio libiio.so.0 HINTS $ENV{LIBIIO_DIR}/lib @@ -63,8 +70,23 @@ FIND_LIBRARY( /usr/lib/x86_64-linux-gnux32 /usr/lib/sh4-linux-gnu /Library/Frameworks/iio.framework/ + ${LIBIIO_ROOT}/lib + $ENV{LIBIIO_ROOT}/lib + ${LIBIIO_ROOT}/lib64 + $ENV{LIBIIO_ROOT}/lib64 ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBIIO DEFAULT_MSG LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS) -MARK_AS_ADVANCED(LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LIBIIO DEFAULT_MSG LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS) + +if(LIBIIO_FOUND AND NOT TARGET Iio::iio) + add_library(Iio::iio SHARED IMPORTED) + set_target_properties(Iio::iio PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${LIBIIO_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBIIO_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${LIBIIO_LIBRARIES}" + ) +endif() + +mark_as_advanced(LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS) diff --git a/cmake/Modules/FindLibOsmoSDR.cmake b/cmake/Modules/FindLIBOSMOSDR.cmake similarity index 64% rename from cmake/Modules/FindLibOsmoSDR.cmake rename to cmake/Modules/FindLIBOSMOSDR.cmake index fc7a28b06..7534f4a00 100644 --- a/cmake/Modules/FindLibOsmoSDR.cmake +++ b/cmake/Modules/FindLIBOSMOSDR.cmake @@ -19,27 +19,33 @@ # # Usage of this module as follows: # -# find_package(LibOsmoSDR) +# find_package(LIBOSMOSDR) # # # Variables defined by this module: # # LIBOSMOSDR_FOUND System has libosmosdr libs/headers -# LIBOSMOSDR_LIBRARIES The libosmosdr libraries +# LIBOSMOSDR_LIBRARIES The libosmosdr libraries # LIBOSMOSDR_INCLUDE_DIR The location of libosmosdr headers +# +# Provides the following imported target: +# Osmosdr::osmosdr +# +include(FindPkgConfig) +pkg_check_modules(LIBOSMOSDR_PKG libosmosdr) -if(NOT LIBOSMOSDR_FOUND) - pkg_check_modules (LIBOSMOSDR_PKG libosmosdr) - find_path(LIBOSMOSDR_INCLUDE_DIR NAMES osmosdr.h - PATHS +find_path(LIBOSMOSDR_INCLUDE_DIR NAMES osmosdr.h + PATHS ${LIBOSMOSDR_PKG_INCLUDE_DIRS} /usr/include /usr/local/include - ) + ${LIBOSMOSDR_ROOT}/include + $ENV{LIBOSMOSDR_ROOT}/include +) - find_library(LIBOSMOSDR_LIBRARIES NAMES osmosdr - PATHS +find_library(LIBOSMOSDR_LIBRARIES NAMES osmosdr + PATHS ${LIBOSMOSDR_PKG_LIBRARY_DIRS} /usr/lib /usr/local/lib @@ -67,16 +73,23 @@ if(NOT LIBOSMOSDR_FOUND) /usr/lib/x86_64-linux-gnux32 /usr/lib/alpha-linux-gnu /usr/lib64 - ) + ${LIBOSMOSDR_ROOT}/lib + $ENV{LIBOSMOSDR_ROOT}/lib + ${LIBOSMOSDR_ROOT}/lib64 + $ENV{LIBOSMOSDR_ROOT}/lib64 +) - if(LIBOSMOSDR_INCLUDE_DIR AND LIBOSMOSDR_LIBRARIES) - set(LIBOSMOSDR_FOUND TRUE CACHE INTERNAL "libosmosdr found") - message(STATUS "Found libosmosdr: ${LIBOSMOSDR_INCLUDE_DIR}, ${LIBOSMOSDR_LIBRARIES}") - else(LIBOSMOSDR_INCLUDE_DIR AND LIBOSMOSDR_LIBRARIES) - set(LIBOSMOSDR_FOUND FALSE CACHE INTERNAL "libosmosdr found") - message(STATUS "libosmosdr not found.") - endif(LIBOSMOSDR_INCLUDE_DIR AND LIBOSMOSDR_LIBRARIES) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LIBOSMOSDR DEFAULT_MSG LIBOSMOSDR_INCLUDE_DIR LIBOSMOSDR_LIBRARIES) + +if(LIBOSMOSDR_FOUND AND NOT TARGET Osmosdr::osmosdr) + add_library(Osmosdr::osmosdr SHARED IMPORTED) + set_target_properties(Osmosdr::osmosdr PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${LIBOSMOSDR_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBOSMOSDR_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${LIBOSMOSDR_LIBRARIES}" + ) +endif() mark_as_advanced(LIBOSMOSDR_INCLUDE_DIR LIBOSMOSDR_LIBRARIES) - -endif(NOT LIBOSMOSDR_FOUND) diff --git a/cmake/Modules/FindLog4cpp.cmake b/cmake/Modules/FindLOG4CPP.cmake similarity index 72% rename from cmake/Modules/FindLog4cpp.cmake rename to cmake/Modules/FindLOG4CPP.cmake index 3b1e7560e..29c7308fa 100644 --- a/cmake/Modules/FindLog4cpp.cmake +++ b/cmake/Modules/FindLOG4CPP.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -21,17 +21,22 @@ # LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc. # LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP. # LOG4CPP_FOUND - True if LOG4CPP found. +# +# Provides the following imported target: +# Log4cpp::log4cpp +# - -if (LOG4CPP_INCLUDE_DIR) +if(LOG4CPP_INCLUDE_DIR) # Already in cache, be silent set(LOG4CPP_FIND_QUIETLY TRUE) -endif () +endif() find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh /opt/local/include /usr/local/include /usr/include + ${LOG4CPP_ROOT}/include + $ENV{LOG4CPP_ROOT}/include ) set(LOG4CPP_NAMES log4cpp) @@ -68,28 +73,38 @@ find_library(LOG4CPP_LIBRARY /usr/lib /usr/local/lib /opt/local/lib + ${LOG4CPP_ROOT}/lib + $ENV{LOG4CPP_ROOT}/lib + ${LOG4CPP_ROOT}/lib64 + $ENV{LOG4CPP_ROOT}/lib64 ) - -if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY) +if(LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY) set(LOG4CPP_FOUND TRUE) set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} CACHE INTERNAL "" FORCE) set(LOG4CPP_INCLUDE_DIRS ${LOG4CPP_INCLUDE_DIR} CACHE INTERNAL "" FORCE) -else () +else() set(LOG4CPP_FOUND FALSE CACHE INTERNAL "" FORCE) set(LOG4CPP_LIBRARY "" CACHE INTERNAL "" FORCE) set(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) set(LOG4CPP_INCLUDE_DIR "" CACHE INTERNAL "" FORCE) set(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) -endif () +endif() -if (LOG4CPP_FOUND) - if (NOT LOG4CPP_FIND_QUIETLY) - message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}") - endif () -else () - if (LOG4CPP_FIND_REQUIRED) - message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.") - message(FATAL_ERROR "Could NOT find LOG4CPP library") - endif () -endif () \ No newline at end of file +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LOG4CPP DEFAULT_MSG LOG4CPP_INCLUDE_DIRS LOG4CPP_LIBRARIES) + +if (LOG4CPP_FOUND AND NOT TARGET Log4cpp::log4cpp) + add_library(Log4cpp::log4cpp SHARED IMPORTED) + set_target_properties(Log4cpp::log4cpp PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${LOG4CPP_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LOG4CPP_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${LOG4CPP_LIBRARIES}" + ) +endif() + +mark_as_advanced( + LOG4CPP_LIBRARIES + LOG4CPP_INCLUDE_DIRS +) diff --git a/cmake/Modules/FindMATIO.cmake b/cmake/Modules/FindMATIO.cmake index 2bac55ede..623939690 100644 --- a/cmake/Modules/FindMATIO.cmake +++ b/cmake/Modules/FindMATIO.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -21,30 +21,33 @@ # # Once done this will define: # -# MATIO_FOUND - True if MATIO found. -# MATIO_LIBRARIES - MATIO libraries. +# MATIO_FOUND - True if MATIO found. +# MATIO_LIBRARIES - MATIO libraries. # MATIO_INCLUDE_DIRS - where to find matio.h, etc.. # MATIO_VERSION_STRING - version number as a string (e.g.: "1.3.4") -# +# +# Provides the following imported target: +# Matio::matio +# #============================================================================= # Copyright 2015 Avtech Scientific -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# +# # * Neither the names of Kitware, Inc., the Insight Software Consortium, # nor the names of their contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -60,58 +63,80 @@ # # Look for the header file. -find_path(MATIO_INCLUDE_DIR NAMES matio.h DOC "The MATIO include directory") +find_path(MATIO_INCLUDE_DIR + NAMES matio.h + HINTS + ${MATIO_ROOT}/include + $ENV{MATIO_ROOT}/include + DOC "The MATIO include directory" +) # Look for the library. -find_library(MATIO_LIBRARY NAMES matio DOC "The MATIO library") +find_library(MATIO_LIBRARY + NAMES matio + HINTS + ${MATIO_ROOT}/lib + $ENV{MATIO_ROOT}/lib + ${MATIO_ROOT}/lib64 + $ENV{MATIO_ROOT}/lib64 + DOC "The MATIO library" +) if(MATIO_INCLUDE_DIR) - # --------------------------------------------------- - # Extract version information from MATIO - # --------------------------------------------------- + # --------------------------------------------------- + # Extract version information from MATIO + # --------------------------------------------------- - # If the file is missing, set all values to 0 - set(MATIO_MAJOR_VERSION 0) - set(MATIO_MINOR_VERSION 0) - set(MATIO_RELEASE_LEVEL 0) + # If the file is missing, set all values to 0 + set(MATIO_MAJOR_VERSION 0) + set(MATIO_MINOR_VERSION 0) + set(MATIO_RELEASE_LEVEL 0) - # new versions of MATIO have `matio_pubconf.h` - if(EXISTS ${MATIO_INCLUDE_DIR}/matio_pubconf.h) - set(MATIO_CONFIG_FILE "matio_pubconf.h") - else() - set(MATIO_CONFIG_FILE "matioConfig.h") - endif() + # new versions of MATIO have `matio_pubconf.h` + if(EXISTS ${MATIO_INCLUDE_DIR}/matio_pubconf.h) + set(MATIO_CONFIG_FILE "matio_pubconf.h") + else() + set(MATIO_CONFIG_FILE "matioConfig.h") + endif() - if(MATIO_CONFIG_FILE) + if(MATIO_CONFIG_FILE) - # Read and parse MATIO config header file for version number - file(STRINGS "${MATIO_INCLUDE_DIR}/${MATIO_CONFIG_FILE}" _matio_HEADER_CONTENTS REGEX "#define MATIO_((MAJOR|MINOR)_VERSION)|(RELEASE_LEVEL) ") + # Read and parse MATIO config header file for version number + file(STRINGS "${MATIO_INCLUDE_DIR}/${MATIO_CONFIG_FILE}" _matio_HEADER_CONTENTS REGEX "#define MATIO_((MAJOR|MINOR)_VERSION)|(RELEASE_LEVEL) ") - foreach(line ${_matio_HEADER_CONTENTS}) - if(line MATCHES "#define ([A-Z_]+) ([0-9]+)") - set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") - endif() - endforeach() + foreach(line ${_matio_HEADER_CONTENTS}) + if(line MATCHES "#define ([A-Z_]+) ([0-9]+)") + set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") + endif() + endforeach() - unset(_matio_HEADER_CONTENTS) - endif() + unset(_matio_HEADER_CONTENTS) + endif() - set(MATIO_VERSION_STRING "${MATIO_MAJOR_VERSION}.${MATIO_MINOR_VERSION}.${MATIO_RELEASE_LEVEL}") -endif () - -#================== + set(MATIO_VERSION_STRING "${MATIO_MAJOR_VERSION}.${MATIO_MINOR_VERSION}.${MATIO_RELEASE_LEVEL}") +endif() mark_as_advanced(MATIO_INCLUDE_DIR MATIO_LIBRARY) -# handle the QUIETLY and REQUIRED arguments and set MATIO_FOUND to TRUE if +# handle the QUIETLY and REQUIRED arguments and set MATIO_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(MATIO REQUIRED_VARS MATIO_LIBRARY MATIO_INCLUDE_DIR VERSION_VAR MATIO_VERSION_STRING) +find_package_handle_standard_args(MATIO REQUIRED_VARS MATIO_LIBRARY MATIO_INCLUDE_DIR VERSION_VAR MATIO_VERSION_STRING) if(MATIO_FOUND) set(MATIO_LIBRARIES ${MATIO_LIBRARY}) set(MATIO_INCLUDE_DIRS ${MATIO_INCLUDE_DIR}) -else(MATIO_FOUND) +else() set(MATIO_LIBRARIES) set(MATIO_INCLUDE_DIRS) -endif(MATIO_FOUND) \ No newline at end of file +endif() + +if(MATIO_FOUND AND NOT TARGET Matio::matio) + add_library(Matio::matio SHARED IMPORTED) + set_target_properties(Matio::matio PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${MATIO_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${MATIO_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${MATIO_LIBRARY}" + ) +endif() diff --git a/cmake/Modules/FindOpenBLAS.cmake b/cmake/Modules/FindOPENBLAS.cmake similarity index 53% rename from cmake/Modules/FindOpenBLAS.cmake rename to cmake/Modules/FindOPENBLAS.cmake index 133de9b63..8ff70d65f 100644 --- a/cmake/Modules/FindOpenBLAS.cmake +++ b/cmake/Modules/FindOPENBLAS.cmake @@ -17,26 +17,33 @@ # - Try to find OpenBLAS library (not headers!) # -# The following environment variable is optionally searched +# The following environment variable is optionally searched # OPENBLAS_HOME: Base directory where all OpenBlas components are found -SET(OPEN_BLAS_SEARCH_PATHS /lib/ - /lib64/ - /usr/lib - /usr/lib64 - /usr/local/lib - /usr/local/lib64 - /opt/OpenBLAS/lib - /opt/local/lib - /usr/lib/openblas-base - $ENV{OPENBLAS_HOME}/lib - ) - -FIND_LIBRARY(OPENBLAS NAMES openblas PATHS ${OPEN_BLAS_SEARCH_PATHS}) +set(OPEN_BLAS_SEARCH_PATHS + /lib + /lib64/ + /usr/lib + /usr/lib64 + /usr/local/lib + /usr/local/lib64 + /opt/OpenBLAS/lib + /opt/local/lib + /usr/lib/openblas-base + $ENV{OPENBLAS_HOME}/lib + ${OPENBLAS_ROOT}/lib + $ENV{OPENBLAS_ROOT}/lib + ${OPENBLAS_ROOT}/lib64 + $ENV{OPENBLAS_ROOT}/lib64 +) -IF (OPENBLAS) - SET(OPENBLAS_FOUND ON) - MESSAGE(STATUS "Found OpenBLAS") -ENDIF (OPENBLAS) +find_library(OPENBLAS NAMES openblas PATHS ${OPEN_BLAS_SEARCH_PATHS}) -MARK_AS_ADVANCED(OPENBLAS) +if(OPENBLAS) + set(OPENBLAS_FOUND ON) + message(STATUS "Found OpenBLAS") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OPENBLAS DEFAULT_MSG OPENBLAS) +mark_as_advanced(OPENBLAS) diff --git a/cmake/Modules/FindOPENCL.cmake b/cmake/Modules/FindOPENCL.cmake new file mode 100644 index 000000000..988360c29 --- /dev/null +++ b/cmake/Modules/FindOPENCL.cmake @@ -0,0 +1,110 @@ +# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . + +# +# This file taken from FindOpenCL project @ http://gitorious.com/findopencl +# +# - Try to find OpenCL +# This module tries to find an OpenCL implementation on your system. It supports +# AMD / ATI, Apple and NVIDIA implementations, but shoudl work, too. +# +# Once done this will define +# OPENCL_FOUND - system has OpenCL +# OPENCL_INCLUDE_DIRS - the OpenCL include directory +# OPENCL_LIBRARIES - link these to use OpenCL +# +# WIN32 should work, but is untested + +include(FindPackageHandleStandardArgs) + +set(OPENCL_VERSION_STRING "0.1.0") +set(OPENCL_VERSION_MAJOR 0) +set(OPENCL_VERSION_MINOR 1) +set(OPENCL_VERSION_PATCH 0) + +if(APPLE) + find_library(OPENCL_LIBRARIES OpenCL DOC "OpenCL lib for OSX") + find_path(OPENCL_INCLUDE_DIRS OpenCL/cl.h DOC "Include for OpenCL on OSX") + find_path(_OPENCL_CPP_INCLUDE_DIRS OpenCL/cl.hpp DOC "Include for OpenCL CPP bindings on OSX") + +else() + if(WIN32) + find_path(OPENCL_INCLUDE_DIRS CL/cl.h) + find_path(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp) + + # The AMD SDK currently installs both x86 and x86_64 libraries + # This is only a hack to find out architecture + if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") + set(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86_64") + set(OPENCL_LIB_DIR "$ENV{ATIINTERNALSTREAMSDKROOT}/lib/x86_64") + else() + set(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86") + set(OPENCL_LIB_DIR "$ENV{ATIINTERNALSTREAMSDKROOT}/lib/x86") + endif() + + # find out if the user asked for a 64-bit build, and use the corresponding + # 64 or 32 bit NVIDIA library paths to the search: + string(REGEX MATCH "Win64" ISWIN64 ${CMAKE_GENERATOR}) + if("${ISWIN64}" STREQUAL "Win64") + find_library(OPENCL_LIBRARIES OpenCL.lib ${OPENCL_LIB_DIR} $ENV{CUDA_LIB_PATH} $ENV{CUDA_PATH}/lib/x64) + else() + find_library(OPENCL_LIBRARIES OpenCL.lib ${OPENCL_LIB_DIR} $ENV{CUDA_LIB_PATH} $ENV{CUDA_PATH}/lib/Win32) + endif() + + get_filename_component(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE) + + # On Win32 search relative to the library + find_path(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}" $ENV{CUDA_INC_PATH} $ENV{CUDA_PATH}/include) + find_path(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}" $ENV{CUDA_INC_PATH} $ENV{CUDA_PATH}/include) + + else() + # Unix style platforms + find_library(OPENCL_LIBRARIES OpenCL + ENV LD_LIBRARY_PATH + ) + + get_filename_component(OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH) + get_filename_component(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE) + + # The AMD SDK currently does not place its headers + # in /usr/include, therefore also search relative + # to the library + find_path(OPENCL_INCLUDE_DIRS CL/cl.h PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include") + find_path(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include") + endif() +endif() + +find_package_handle_standard_args(OPENCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS) + +if(_OPENCL_CPP_INCLUDE_DIRS) + set(OPENCL_HAS_CPP_BINDINGS TRUE) + list(APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS}) + # This is often the same, so clean up + list(REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS) +endif() + +mark_as_advanced( + OPENCL_INCLUDE_DIRS +) + +if(OPENCL_INCLUDE_DIRS AND OPENCL_LIBRARIES) + set( OPENCL_FOUND TRUE ) + add_definitions( -DOPENCL=1 ) +else() + set( OPENCL_FOUND FALSE ) + add_definitions( -DOPENCL=0 ) +endif() diff --git a/cmake/Modules/FindORC.cmake b/cmake/Modules/FindORC.cmake index 2751494ba..fea12b98f 100644 --- a/cmake/Modules/FindORC.cmake +++ b/cmake/Modules/FindORC.cmake @@ -15,52 +15,61 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_ORC "orc-0.4 > 0.4.22") +find_package(PkgConfig) +pkg_check_modules(PC_ORC "orc-0.4 > 0.4.22") -FIND_PROGRAM(ORCC_EXECUTABLE orcc - HINTS ${PC_ORC_TOOLSDIR} - PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin) - -FIND_PATH(ORC_INCLUDE_DIR NAMES orc/orc.h - HINTS ${PC_ORC_INCLUDEDIR} - PATHS ${ORC_ROOT}/include/orc-0.4 ${CMAKE_INSTALL_PREFIX}/include/orc-0.4) - - -FIND_PATH(ORC_LIBRARY_DIR NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX} - HINTS ${PC_ORC_LIBDIR} - /usr/local/lib - /usr/lib/x86_64-linux-gnu - /usr/lib/i386-linux-gnu - /usr/lib/arm-linux-gnueabihf - /usr/lib/arm-linux-gnueabi - /usr/lib/aarch64-linux-gnu - /usr/lib/mipsel-linux-gnu - /usr/lib/mips-linux-gnu - /usr/lib/mips64el-linux-gnuabi64 - /usr/lib/powerpc-linux-gnu - /usr/lib/powerpc64-linux-gnu - /usr/lib/powerpc64le-linux-gnu - /usr/lib/hppa-linux-gnu - /usr/lib/s390x-linux-gnu - /usr/lib64 - /usr/lib - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - -FIND_LIBRARY(ORC_LIB orc-0.4 - HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - -LIST(APPEND ORC_LIBRARY - ${ORC_LIB} +find_program(ORCC_EXECUTABLE orcc + HINTS ${PC_ORC_TOOLSDIR} + PATHS ${ORC_ROOT}/bin + ${CMAKE_INSTALL_PREFIX}/bin ) +find_path(ORC_INCLUDE_DIR + NAMES orc/orc.h + HINTS ${PC_ORC_INCLUDEDIR} + PATHS ${ORC_ROOT}/include/orc-0.4 + ${CMAKE_INSTALL_PREFIX}/include/orc-0.4 +) -SET(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR}) -SET(ORC_LIBRARIES ${ORC_LIBRARY}) -SET(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR}) +find_path(ORC_LIBRARY_DIR + NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX} + HINTS ${PC_ORC_LIBDIR} + /usr/local/lib + /usr/lib/x86_64-linux-gnu + /usr/lib/i386-linux-gnu + /usr/lib/arm-linux-gnueabihf + /usr/lib/arm-linux-gnueabi + /usr/lib/aarch64-linux-gnu + /usr/lib/mipsel-linux-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/powerpc-linux-gnu + /usr/lib/powerpc64-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/hppa-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/lib64 + /usr/lib + ${ORC_ROOT}/lib + $ENV{ORC_ROOT}/lib + PATHS + ${ORC_ROOT}/lib${LIB_SUFFIX} + ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} +) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR ORCC_EXECUTABLE) +find_library(ORC_LIB orc-0.4 + HINTS ${PC_ORC_LIBRARY_DIRS} + PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} + ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} +) -mark_as_advanced(ORC_INCLUDE_DIR ORC_LIBRARY ORCC_EXECUTABLE) \ No newline at end of file +list(APPEND ORC_LIBRARY ${ORC_LIB}) + +set(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR}) +set(ORC_LIBRARIES ${ORC_LIBRARY}) +set(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR ORCC_EXECUTABLE) + +mark_as_advanced(ORC_INCLUDE_DIR ORC_LIBRARY ORCC_EXECUTABLE) diff --git a/cmake/Modules/FindOpenCL.cmake b/cmake/Modules/FindOpenCL.cmake deleted file mode 100644 index 7b2d3f1dd..000000000 --- a/cmake/Modules/FindOpenCL.cmake +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) -# -# This file is part of GNSS-SDR. -# -# GNSS-SDR is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# GNSS-SDR 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNSS-SDR. If not, see . - -# -# This file taken from FindOpenCL project @ http://gitorious.com/findopencl -# -# - Try to find OpenCL -# This module tries to find an OpenCL implementation on your system. It supports -# AMD / ATI, Apple and NVIDIA implementations, but shoudl work, too. -# -# Once done this will define -# OPENCL_FOUND - system has OpenCL -# OPENCL_INCLUDE_DIRS - the OpenCL include directory -# OPENCL_LIBRARIES - link these to use OpenCL -# -# WIN32 should work, but is untested - -FIND_PACKAGE( PackageHandleStandardArgs ) - -SET (OPENCL_VERSION_STRING "0.1.0") -SET (OPENCL_VERSION_MAJOR 0) -SET (OPENCL_VERSION_MINOR 1) -SET (OPENCL_VERSION_PATCH 0) - -IF (APPLE) - - FIND_LIBRARY(OPENCL_LIBRARIES OpenCL DOC "OpenCL lib for OSX") - FIND_PATH(OPENCL_INCLUDE_DIRS OpenCL/cl.h DOC "Include for OpenCL on OSX") - FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS OpenCL/cl.hpp DOC "Include for OpenCL CPP bindings on OSX") - -ELSE (APPLE) - - IF (WIN32) - - FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h) - FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp) - - # The AMD SDK currently installs both x86 and x86_64 libraries - # This is only a hack to find out architecture - IF( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64" ) - SET(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86_64") - SET(OPENCL_LIB_DIR "$ENV{ATIINTERNALSTREAMSDKROOT}/lib/x86_64") - ELSE (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") - SET(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86") - SET(OPENCL_LIB_DIR "$ENV{ATIINTERNALSTREAMSDKROOT}/lib/x86") - ENDIF( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64" ) - - # find out if the user asked for a 64-bit build, and use the corresponding - # 64 or 32 bit NVIDIA library paths to the search: - STRING(REGEX MATCH "Win64" ISWIN64 ${CMAKE_GENERATOR}) - IF("${ISWIN64}" STREQUAL "Win64") - FIND_LIBRARY(OPENCL_LIBRARIES OpenCL.lib ${OPENCL_LIB_DIR} $ENV{CUDA_LIB_PATH} $ENV{CUDA_PATH}/lib/x64) - ELSE("${ISWIN64}" STREQUAL "Win64") - FIND_LIBRARY(OPENCL_LIBRARIES OpenCL.lib ${OPENCL_LIB_DIR} $ENV{CUDA_LIB_PATH} $ENV{CUDA_PATH}/lib/Win32) - ENDIF("${ISWIN64}" STREQUAL "Win64") - - GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE) - - # On Win32 search relative to the library - FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}" $ENV{CUDA_INC_PATH} $ENV{CUDA_PATH}/include) - FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}" $ENV{CUDA_INC_PATH} $ENV{CUDA_PATH}/include) - - ELSE (WIN32) - - # Unix style platforms - FIND_LIBRARY(OPENCL_LIBRARIES OpenCL - ENV LD_LIBRARY_PATH - ) - - GET_FILENAME_COMPONENT(OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH) - GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE) - - # The AMD SDK currently does not place its headers - # in /usr/include, therefore also search relative - # to the library - FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include") - FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include") - - ENDIF (WIN32) - -ENDIF (APPLE) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS( OpenCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS ) - -IF( _OPENCL_CPP_INCLUDE_DIRS ) - SET( OPENCL_HAS_CPP_BINDINGS TRUE ) - LIST( APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS} ) - # This is often the same, so clean up - LIST( REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS ) -ENDIF( _OPENCL_CPP_INCLUDE_DIRS ) - -MARK_AS_ADVANCED( - OPENCL_INCLUDE_DIRS -) - -IF( OPENCL_INCLUDE_DIRS AND OPENCL_LIBRARIES ) - SET( OPENCL_FOUND TRUE ) - add_definitions( -DOPENCL=1 ) -ELSE( OPENCL_INCLUDE_DIRS AND OPENCL_LIBRARIES ) - SET( OPENCL_FOUND FALSE ) - add_definitions( -DOPENCL=0 ) -ENDIF( OPENCL_INCLUDE_DIRS AND OPENCL_LIBRARIES ) diff --git a/cmake/Modules/FindPCAP.cmake b/cmake/Modules/FindPCAP.cmake new file mode 100644 index 000000000..6c8e52f8f --- /dev/null +++ b/cmake/Modules/FindPCAP.cmake @@ -0,0 +1,135 @@ +################################################################### +# +# Copyright (c) 2006 Frederic Heem, +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the Telsey nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +################################################################### +# - Find pcap +# Find the PCAP includes and library +# http://www.tcpdump.org/ +# +# The environment variable PCAPDIR allows to specficy where to find +# libpcap in non standard location. +# +# PCAP_INCLUDE_DIRS - where to find pcap.h, etc. +# PCAP_LIBRARIES - List of libraries when using pcap. +# PCAP_FOUND - True if pcap found. +# +# Provides the following imported target: +# Pcap::pcap +# + +if(EXISTS $ENV{PCAPDIR}) + find_path(PCAP_INCLUDE_DIR + NAMES + pcap/pcap.h + pcap.h + PATHS + $ENV{PCAPDIR} + ${PCAP_ROOT}/include + $ENV{PCAP_ROOT}/include + NO_DEFAULT_PATH + ) + find_library(PCAP_LIBRARY + NAMES + pcap + PATHS + $ENV{PCAPDIR} + ${PCAP_ROOT}/lib + $ENV{PCAP_ROOT}/lib + NO_DEFAULT_PATH + ) +else() + find_path(PCAP_INCLUDE_DIR + NAMES + pcap/pcap.h + pcap.h + HINTS + ${PCAP_ROOT}/include + $ENV{PCAP_ROOT}/include + ) + find_library(PCAP_LIBRARY + NAMES + pcap + HINTS + ${PCAP_ROOT}/lib + $ENV{PCAP_ROOT}/lib + ) +endif() + +set(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR}) +set(PCAP_LIBRARIES ${PCAP_LIBRARY}) + +if(PCAP_INCLUDE_DIRS) + message(STATUS "Pcap include dirs set to ${PCAP_INCLUDE_DIRS}") +else() + message(FATAL " Pcap include dirs cannot be found") +endif() + +if(PCAP_LIBRARIES) + message(STATUS "Pcap library set to ${PCAP_LIBRARIES}") +else() + message(FATAL "Pcap library cannot be found") +endif() + +#Functions +include(CheckFunctionExists) +set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS}) +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES}) +check_function_exists("pcap_breakloop" HAVE_PCAP_BREAKLOOP) +check_function_exists("pcap_datalink_name_to_val" HAVE_PCAP_DATALINK_NAME_TO_VAL) +check_function_exists("pcap_datalink_val_to_name" HAVE_PCAP_DATALINK_VAL_TO_NAME) +check_function_exists("pcap_findalldevs" HAVE_PCAP_FINDALLDEVS) +check_function_exists("pcap_freecode" HAVE_PCAP_FREECODE) +check_function_exists("pcap_get_selectable_fd" HAVE_PCAP_GET_SELECTABLE_FD) +check_function_exists("pcap_lib_version" HAVE_PCAP_LIB_VERSION) +check_function_exists("pcap_list_datalinks" HAVE_PCAP_LIST_DATALINKS) +check_function_exists("pcap_open_dead" HAVE_PCAP_OPEN_DEAD) +check_function_exists("pcap_set_datalink" HAVE_PCAP_SET_DATALINK) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PCAP DEFAULT_MSG PCAP_INCLUDE_DIRS PCAP_LIBRARIES) + +if(PCAP_FOUND AND NOT TARGET Pcap::pcap) + add_library(Pcap::pcap SHARED IMPORTED) + set_target_properties(Pcap::pcap PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${PCAP_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${PCAP_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${PCAP_LIBRARIES}" + ) +endif() + +mark_as_advanced( + PCAP_LIBRARIES + PCAP_INCLUDE_DIRS +) diff --git a/cmake/Modules/FindPUGIXML.cmake b/cmake/Modules/FindPUGIXML.cmake new file mode 100644 index 000000000..3d8ce2bdc --- /dev/null +++ b/cmake/Modules/FindPUGIXML.cmake @@ -0,0 +1,97 @@ +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . + +# Find the pugixml XML parsing library. +# +# Sets the usual variables expected for find_package scripts: +# +# PUGIXML_INCLUDE_DIR - header location +# PUGIXML_LIBRARIES - library to link against +# PUGIXML_FOUND - true if pugixml was found. +# +# Provides the following imported target: +# Pugixml::pugixml +# + +find_path(PUGIXML_INCLUDE_DIR + NAMES pugixml.hpp + PATHS ${PUGIXML_HOME}/include + /usr/include + /usr/local/include + /usr/local/include/pugixml-1.9 + /opt/local/include + ${PUGIXML_ROOT}/include + $ENV{PUGIXML_ROOT}/include + ${PUGIXML_ROOT}/include/pugixml-1.9 + $ENV{PUGIXML_ROOT}/include/pugixml-1.9 +) + +find_library(PUGIXML_LIBRARY + NAMES pugixml + PATHS ${PUGIXML_HOME}/lib + /usr/lib/x86_64-linux-gnu + /usr/lib/aarch64-linux-gnu + /usr/lib/arm-linux-gnueabi + /usr/lib/arm-linux-gnueabihf + /usr/lib/i386-linux-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/mipsel-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/local/lib + /usr/local/lib/pugixml-1.9 + /opt/local/lib + /usr/lib + /usr/lib64 + /usr/local/lib64 + ${PUGIXML_ROOT}/lib + $ENV{PUGIXML_ROOT}/lib + ${PUGIXML_ROOT}/lib64 + $ENV{PUGIXML_ROOT}/lib64 + ${PUGIXML_ROOT}/lib/pugixml-1.9 + $ENV{PUGIXML_ROOT}/lib/pugixml-1.9 + ${PUGIXML_ROOT}/lib64/pugixml-1.9 + $ENV{PUGIXML_ROOT}/lib64/pugixml-1.9 +) + +# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PUGIXML DEFAULT_MSG PUGIXML_LIBRARY + PUGIXML_INCLUDE_DIR) + +if(PUGIXML_FOUND) + set(PUGIXML_LIBRARIES ${PUGIXML_LIBRARY}) + if(NOT PUGIXML_FIND_QUIETLY) + message(STATUS "PugiXML include = ${PUGIXML_INCLUDE_DIR}") + message(STATUS "PugiXML library = ${PUGIXML_LIBRARY}") + endif() +else() + message(STATUS "PugiXML not found.") +endif() + +mark_as_advanced(PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR) + +if(PUGIXML_FOUND AND NOT TARGET Pugixml::pugixml) + add_library(Pugixml::pugixml SHARED IMPORTED) + set_target_properties(Pugixml::pugixml PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${PUGIXML_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PUGIXML_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${PUGIXML_LIBRARY}" + ) +endif() diff --git a/cmake/Modules/FindTeleorbit.cmake b/cmake/Modules/FindTELEORBIT.cmake similarity index 53% rename from cmake/Modules/FindTeleorbit.cmake rename to cmake/Modules/FindTELEORBIT.cmake index e7fdbf5fc..bdb3d861c 100644 --- a/cmake/Modules/FindTeleorbit.cmake +++ b/cmake/Modules/FindTELEORBIT.cmake @@ -15,32 +15,47 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_TELEORBIT teleorbit) +include(FindPkgConfig) +pkg_check_modules(PC_TELEORBIT teleorbit) -FIND_PATH( - TELEORBIT_INCLUDE_DIRS +find_path(TELEORBIT_INCLUDE_DIRS NAMES teleorbit/api.h HINTS $ENV{TELEORBIT_DIR}/include - ${PC_TELEORBIT_INCLUDEDIR} + ${PC_TELEORBIT_INCLUDEDIR} PATHS ${CMAKE_INSTALL_PREFIX}/include /usr/local/include /usr/include + ${TELEORBIT_ROOT}/include + $ENV{TELEORBIT_ROOT}/include ) -FIND_LIBRARY( - TELEORBIT_LIBRARIES +find_library(TELEORBIT_LIBRARIES NAMES gnuradio-teleorbit HINTS $ENV{TELEORBIT_DIR}/lib - ${PC_TELEORBIT_LIBDIR} + ${PC_TELEORBIT_LIBDIR} PATHS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64 /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64 + ${TELEORBIT_ROOT}/lib + $ENV{TELEORBIT_ROOT}/lib + ${TELEORBIT_ROOT}/lib64 + $ENV{TELEORBIT_ROOT}/lib64 ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(TELEORBIT DEFAULT_MSG TELEORBIT_LIBRARIES TELEORBIT_INCLUDE_DIRS) -MARK_AS_ADVANCED(TELEORBIT_LIBRARIES TELEORBIT_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(TELEORBIT DEFAULT_MSG TELEORBIT_LIBRARIES TELEORBIT_INCLUDE_DIRS) + +if(TELEORBIT_FOUND AND NOT TARGET Gnuradio::teleorbit) + add_library(Gnuradio::teleorbit SHARED IMPORTED) + set_target_properties(Gnuradio::teleorbit PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${TELEORBIT_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${TELEORBIT_INCLUDE_DIRS};${TELEORBIT_INCLUDE_DIRS}/teleorbit" + INTERFACE_LINK_LIBRARIES "${TELEORBIT_LIBRARIES}" + ) +endif() + +mark_as_advanced(TELEORBIT_LIBRARIES TELEORBIT_INCLUDE_DIRS) diff --git a/cmake/Modules/FindUHD.cmake b/cmake/Modules/FindUHD.cmake index 3a245f8a2..e0d6d77e0 100644 --- a/cmake/Modules/FindUHD.cmake +++ b/cmake/Modules/FindUHD.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -15,28 +15,32 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . +# +# Provides the following imported target: +# Iio::iio +# + ######################################################################## # Find the library for the USRP Hardware Driver ######################################################################## +include(FindPkgConfig) +pkg_check_modules(PC_UHD uhd) -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_UHD uhd) - -FIND_PATH( - UHD_INCLUDE_DIRS +find_path(UHD_INCLUDE_DIRS NAMES uhd/config.hpp HINTS $ENV{UHD_DIR}/include - ${PC_UHD_INCLUDEDIR} + ${PC_UHD_INCLUDEDIR} PATHS /usr/local/include /usr/include ${GNURADIO_INSTALL_PREFIX}/include + ${UHD_ROOT}/include + $ENV{UHD_ROOT}/include ) -FIND_LIBRARY( - UHD_LIBRARIES +find_library(UHD_LIBRARIES NAMES uhd HINTS $ENV{UHD_DIR}/lib - ${PC_UHD_LIBDIR} + ${PC_UHD_LIBDIR} PATHS /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu @@ -64,8 +68,23 @@ FIND_LIBRARY( /usr/lib64 /usr/lib ${GNURADIO_INSTALL_PREFIX}/lib + ${UHD_ROOT}/lib + $ENV{UHD_ROOT}/lib + ${UHD_ROOT}/lib64 + $ENV{UHD_ROOT}/lib64 ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(UHD DEFAULT_MSG UHD_LIBRARIES UHD_INCLUDE_DIRS) -MARK_AS_ADVANCED(UHD_LIBRARIES UHD_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(UHD DEFAULT_MSG UHD_LIBRARIES UHD_INCLUDE_DIRS) + +if(UHD_FOUND AND NOT TARGET Uhd::uhd) + add_library(Uhd::uhd SHARED IMPORTED) + set_target_properties(Uhd::uhd PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${UHD_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${UHD_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${UHD_LIBRARIES}" + ) +endif() + +mark_as_advanced(UHD_LIBRARIES UHD_INCLUDE_DIRS) diff --git a/cmake/Modules/FindVolk.cmake b/cmake/Modules/FindVOLK.cmake similarity index 69% rename from cmake/Modules/FindVolk.cmake rename to cmake/Modules/FindVOLK.cmake index 994ce6e7d..26d236625 100644 --- a/cmake/Modules/FindVolk.cmake +++ b/cmake/Modules/FindVOLK.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -15,25 +15,30 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . +# +# Provides the following imported target: +# Volk::volk +# + ######################################################################## # Find VOLK (Vector-Optimized Library of Kernels) ######################################################################## -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_VOLK volk) +include(FindPkgConfig) +pkg_check_modules(PC_VOLK volk) -FIND_PATH( - VOLK_INCLUDE_DIRS +find_path(VOLK_INCLUDE_DIRS NAMES volk/volk.h HINTS $ENV{VOLK_DIR}/include ${PC_VOLK_INCLUDEDIR} PATHS /usr/local/include /usr/include ${CMAKE_INSTALL_PREFIX}/include + ${VOLK_ROOT}/include + $ENV{VOLK_ROOT}/include ) -FIND_LIBRARY( - VOLK_LIBRARIES +find_library(VOLK_LIBRARIES NAMES volk HINTS $ENV{VOLK_DIR}/lib ${PC_VOLK_LIBDIR} @@ -65,9 +70,22 @@ FIND_LIBRARY( /usr/lib/alpha-linux-gnu /usr/lib64 ${CMAKE_INSTALL_PREFIX}/lib + ${VOLK_ROOT}/lib + $ENV{VOLK_ROOT}/lib + ${VOLK_ROOT}/lib64 + $ENV{VOLK_ROOT}/lib64 ) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VOLK DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS) +mark_as_advanced(VOLK_LIBRARIES VOLK_INCLUDE_DIRS VOLK_VERSION) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(VOLK DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS) -MARK_AS_ADVANCED(VOLK_LIBRARIES VOLK_INCLUDE_DIRS VOLK_VERSION) +if(VOLK_FOUND AND NOT TARGET Volk::volk) + add_library(Volk::volk SHARED IMPORTED) + set_target_properties(Volk::volk PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${VOLK_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${VOLK_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${VOLK_LIBRARIES}" + ) +endif() diff --git a/cmake/Modules/FindVolkGnssSdr.cmake b/cmake/Modules/FindVOLKGNSSSDR.cmake similarity index 50% rename from cmake/Modules/FindVolkGnssSdr.cmake rename to cmake/Modules/FindVOLKGNSSSDR.cmake index 6225f38a0..57abd1d99 100644 --- a/cmake/Modules/FindVolkGnssSdr.cmake +++ b/cmake/Modules/FindVOLKGNSSSDR.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -15,35 +15,56 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . +# +# Provides the following imported target: +# Volkgnsssdr::volkgnsssdr +# + + ######################################################################## # Find VOLK (Vector-Optimized Library of Kernels) GNSS-SDR library ######################################################################## -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_VOLK_GNSSSDR volk_gnsssdr) +include(FindPkgConfig) +pkg_check_modules(PC_VOLK_GNSSSDR volk_gnsssdr) -FIND_PATH( - VOLK_GNSSSDR_INCLUDE_DIRS +find_path(VOLK_GNSSSDR_INCLUDE_DIRS NAMES volk_gnsssdr/volk_gnsssdr.h HINTS $ENV{VOLK_GNSSSDR_DIR}/include - ${PC_VOLK_GNSSSDR_INCLUDEDIR} + ${PC_VOLK_GNSSSDR_INCLUDEDIR} PATHS /usr/local/include /usr/include ${GNURADIO_INSTALL_PREFIX}/include + ${VOLKGNSSSDR_ROOT}/include + $ENV{VOLKGNSSSDR_ROOT}/include ) -FIND_LIBRARY( - VOLK_GNSSSDR_LIBRARIES +find_library(VOLK_GNSSSDR_LIBRARIES NAMES volk_gnsssdr HINTS $ENV{VOLK_GNSSSDR_DIR}/lib - ${PC_VOLK_GNSSSDR_LIBDIR} + ${PC_VOLK_GNSSSDR_LIBDIR} PATHS /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64 ${GNURADIO_INSTALL_PREFIX}/lib + ${VOLKGNSSSDR_ROOT}/lib + $ENV{VOLKGNSSSDR_ROOT}/lib + ${VOLKGNSSSDR_ROOT}/lib64 + $ENV{VOLKGNSSSDR_ROOT}/lib64 ) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(VOLK_GNSSSDR DEFAULT_MSG VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS) -MARK_AS_ADVANCED(VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS) \ No newline at end of file +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VOLKGNSSSDR DEFAULT_MSG VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS) +mark_as_advanced(VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS) + + +if(VOLKGNSSSDR_FOUND AND NOT TARGET Volkgnsssdr::volkgnsssdr) + add_library(Volkgnsssdr::volkgnsssdr SHARED IMPORTED) + set_target_properties(Volkgnsssdr::volkgnsssdr PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${VOLK_GNSSSDR_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${VOLK_GNSSSDR_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${VOLK_GNSSSDR_LIBRARIES}" + ) +endif() diff --git a/cmake/Modules/GnsssdrBuildTypes.cmake b/cmake/Modules/GnsssdrBuildTypes.cmake new file mode 100644 index 000000000..a80cd0c6b --- /dev/null +++ b/cmake/Modules/GnsssdrBuildTypes.cmake @@ -0,0 +1,219 @@ +# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . + +if(DEFINED __INCLUDED_GNSSSDR_BUILD_TYPES_CMAKE) + return() +endif() +set(__INCLUDED_GNSSSDR_BUILD_TYPES_CMAKE TRUE) + +# Standard CMake Build Types and their basic CFLAGS: +# - None: nothing set +# - Debug: -O2 -g +# - Release: -O3 +# - RelWithDebInfo: -O3 -g +# - MinSizeRel: -Os + +# Additional Build Types, defined below: +# - NoOptWithASM: -O0 -g -save-temps +# - O2WithASM: -O2 -g -save-temps +# - O3WithASM: -O3 -g -save-temps + +# Defines the list of acceptable cmake build types. When adding a new +# build type below, make sure to add it to this list. +list(APPEND AVAIL_BUILDTYPES + None Debug Release RelWithDebInfo MinSizeRel + Coverage NoOptWithASM O2WithASM O3WithASM ASAN +) + +######################################################################## +# GNSSSDR_CHECK_BUILD_TYPE(build type) +# +# Use this to check that the build type set in CMAKE_BUILD_TYPE on the +# commandline is one of the valid build types used by this project. It +# checks the value set in the cmake interface against the list of +# known build types in AVAIL_BUILDTYPES. If the build type is found, +# the function exits immediately. If nothing is found by the end of +# checking all available build types, we exit with an error and list +# the avialable build types. +######################################################################## +function(GNSSSDR_CHECK_BUILD_TYPE settype) + string(TOUPPER ${settype} _settype) + foreach(btype ${AVAIL_BUILDTYPES}) + string(TOUPPER ${btype} _btype) + if(${_settype} STREQUAL ${_btype}) + return() # found it; exit cleanly + endif() + endforeach() + # Build type not found; error out + message(FATAL_ERROR "Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}") +endfunction() + + +######################################################################## +# For GCC and Clang, we can set a build type: +# +# -DCMAKE_BUILD_TYPE=Coverage +# +# This type uses no optimization (-O0), outputs debug symbols (-g) and +# outputs all intermediary files the build system produces, including +# all assembly (.s) files. Look in the build directory for these +# files. +# NOTE: This is not defined on Windows systems. +######################################################################## +if(NOT WIN32) + set(CMAKE_CXX_FLAGS_COVERAGE "-Wall -pedantic -pthread -g -O0 -fprofile-arcs -ftest-coverage" CACHE STRING + "Flags used by the C++ compiler during Coverage builds." FORCE) + set(CMAKE_C_FLAGS_COVERAGE "-Wall -pedantic -pthread -g -O0 -fprofile-arcs -ftest-coverage" CACHE STRING + "Flags used by the C compiler during Coverage builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_COVERAGE + "-W" CACHE STRING + "Flags used for linking binaries during Coverage builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE + "-W" CACHE STRING + "Flags used by the shared lib linker during Coverage builds." FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_COVERAGE + CMAKE_C_FLAGS_COVERAGE + CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE) +endif() + + +######################################################################## +# For GCC and Clang, we can set a build type: +# +# -DCMAKE_BUILD_TYPE=NoOptWithASM +# +# This type uses no optimization (-O0), outputs debug symbols (-g) and +# outputs all intermediary files the build system produces, including +# all assembly (.s) files. Look in the build directory for these +# files. +# NOTE: This is not defined on Windows systems. +######################################################################## +if(NOT WIN32) + set(CMAKE_CXX_FLAGS_NOOPTWITHASM "-Wall -save-temps -g -O0" CACHE STRING + "Flags used by the C++ compiler during NoOptWithASM builds." FORCE) + set(CMAKE_C_FLAGS_NOOPTWITHASM "-Wall -save-temps -g -O0" CACHE STRING + "Flags used by the C compiler during NoOptWithASM builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM + "-W" CACHE STRING + "Flags used for linking binaries during NoOptWithASM builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM + "-W" CACHE STRING + "Flags used by the shared lib linker during NoOptWithASM builds." FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_NOOPTWITHASM + CMAKE_C_FLAGS_NOOPTWITHASM + CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM + CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM) +endif() + + + +######################################################################## +# For GCC and Clang, we can set a build type: +# +# -DCMAKE_BUILD_TYPE=O2WithASM +# +# This type uses level 2 optimization (-O2), outputs debug symbols +# (-g) and outputs all intermediary files the build system produces, +# including all assembly (.s) files. Look in the build directory for +# these files. +# NOTE: This is not defined on Windows systems. +######################################################################## + +if(NOT WIN32) + set(CMAKE_CXX_FLAGS_O2WITHASM "-Wall -save-temps -g -O2" CACHE STRING + "Flags used by the C++ compiler during O2WithASM builds." FORCE) + set(CMAKE_C_FLAGS_O2WITHASM "-Wall -save-temps -g -O2" CACHE STRING + "Flags used by the C compiler during O2WithASM builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_O2WITHASM + "-W" CACHE STRING + "Flags used for linking binaries during O2WithASM builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_O2WITHASM + "-W" CACHE STRING + "Flags used by the shared lib linker during O2WithASM builds." FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_O2WITHASM + CMAKE_C_FLAGS_O2WITHASM + CMAKE_EXE_LINKER_FLAGS_O2WITHASM + CMAKE_SHARED_LINKER_FLAGS_O2WITHASM) +endif() + + +######################################################################## +# For GCC and Clang, we can set a build type: +# +# -DCMAKE_BUILD_TYPE=O3WithASM +# +# This type uses level 3 optimization (-O3), outputs debug symbols +# (-g) and outputs all intermediary files the build system produces, +# including all assembly (.s) files. Look in the build directory for +# these files. +# NOTE: This is not defined on Windows systems. +######################################################################## + +if(NOT WIN32) + set(CMAKE_CXX_FLAGS_O3WITHASM "-Wall -save-temps -g -O3" CACHE STRING + "Flags used by the C++ compiler during O3WithASM builds." FORCE) + set(CMAKE_C_FLAGS_O3WITHASM "-Wall -save-temps -g -O3" CACHE STRING + "Flags used by the C compiler during O3WithASM builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_O3WITHASM + "-W" CACHE STRING + "Flags used for linking binaries during O3WithASM builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_O3WITHASM + "-W" CACHE STRING + "Flags used by the shared lib linker during O3WithASM builds." FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_O3WITHASM + CMAKE_C_FLAGS_O3WITHASM + CMAKE_EXE_LINKER_FLAGS_O3WITHASM + CMAKE_SHARED_LINKER_FLAGS_O3WITHASM) +endif() + + +######################################################################## +# For GCC and Clang, we can set a build type: +# +# -DCMAKE_BUILD_TYPE=ASAN +# +# This type creates an address sanitized build (-fsanitize=address) +# and defaults to the DebugParanoid linker flags. +# NOTE: This is not defined on Windows systems. +######################################################################## +if(NOT WIN32) + set(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + "Flags used by the C++ compiler during Address Sanitized builds." FORCE) + set(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + "Flags used by the C compiler during Address Sanitized builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_ASAN + "-W" CACHE STRING + "Flags used for linking binaries during Address Sanitized builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_ASAN + "-W" CACHE STRING + "Flags used by the shared lib linker during Address Sanitized builds." FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_ASAN + CMAKE_C_FLAGS_ASAN + CMAKE_EXE_LINKER_FLAGS_ASAN + CMAKE_SHARED_LINKER_ASAN) +endif() diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index eb4e7a55d..f3d59c900 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -15,54 +15,6 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -######################################################################## -# Setup the python interpreter: -# This allows the user to specify a specific interpreter, -# or finds the interpreter via the built-in cmake module. -######################################################################## -#this allows the user to override PYTHON_EXECUTABLE -if(PYTHON_EXECUTABLE) - - set(PYTHONINTERP_FOUND TRUE) - -#otherwise if not set, try to automatically find it -else(PYTHON_EXECUTABLE) - - #use the built-in find script - set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6) - find_package(PythonInterp 2) - - #and if that fails use the find program routine - if(NOT PYTHONINTERP_FOUND) - find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7 python3) - if(PYTHON_EXECUTABLE) - set(PYTHONINTERP_FOUND TRUE) - endif(PYTHON_EXECUTABLE) - endif(NOT PYTHONINTERP_FOUND) - -endif(PYTHON_EXECUTABLE) - -if (CMAKE_CROSSCOMPILING) - set(QA_PYTHON_EXECUTABLE "/usr/bin/python") -else (CMAKE_CROSSCOMPILING) - set(QA_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) -endif(CMAKE_CROSSCOMPILING) - -#make the path to the executable appear in the cmake gui -set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") -set(QA_PYTHON_EXECUTABLE ${QA_PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter for QA tests") - -#make sure we can use -B with python (introduced in 2.6) -if(PYTHON_EXECUTABLE) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -B -c "" - OUTPUT_QUIET ERROR_QUIET - RESULT_VARIABLE PYTHON_HAS_DASH_B_RESULT - ) - if(PYTHON_HAS_DASH_B_RESULT EQUAL 0) - set(PYTHON_DASH_B "-B") - endif() -endif(PYTHON_EXECUTABLE) ######################################################################## # Check for the existence of a python module: @@ -71,25 +23,97 @@ endif(PYTHON_EXECUTABLE) # - cmd an additional command to run # - have the result variable to set ######################################################################## -macro(GNSSSDR_PYTHON_CHECK_MODULE desc mod cmd have) - message(STATUS "Python checking for ${desc}") +macro(GNSSSDR_PYTHON_CHECK_MODULE_RAW desc python_code have) execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c " -######################################### -try: import ${mod} -except: - try: ${mod} - except: exit(-1) -try: assert ${cmd} -except: exit(-1) -#########################################" - RESULT_VARIABLE ${have} + COMMAND ${PYTHON_EXECUTABLE} -c "${python_code}" + OUTPUT_QUIET ERROR_QUIET + RESULT_VARIABLE return_code ) - if(${have} EQUAL 0) + if(return_code EQUAL 0) message(STATUS "Python checking for ${desc} - found") set(${have} TRUE) - else(${have} EQUAL 0) + else() message(STATUS "Python checking for ${desc} - not found") set(${have} FALSE) - endif(${have} EQUAL 0) -endmacro(GNSSSDR_PYTHON_CHECK_MODULE) + endif() +endmacro() + +macro(GNSSSDR_PYTHON_CHECK_MODULE desc mod cmd have) + gnsssdr_python_check_module_raw( + "${desc}" " +######################################### +try: + import ${mod} + assert ${cmd} +except (ImportError, AssertionError): exit(-1) +except: pass +#########################################" + "${have}") +endmacro() + + +######################################################################## +# Setup the python interpreter: +# This allows the user to specify a specific interpreter, +# or finds the interpreter via the built-in cmake module. +######################################################################## + +if(CMAKE_VERSION VERSION_LESS 3.12) + if(PYTHON_EXECUTABLE) + message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") + string(FIND "${PYTHON_EXECUTABLE}" "python3" IS_PYTHON3) + if(IS_PYTHON3 EQUAL -1) + find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED) + else() + find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED) + endif() + gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) + gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) + gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + else() + message(STATUS "PYTHON_EXECUTABLE not set - trying by default python2") + message(STATUS "Use -DPYTHON_EXECUTABLE=/path/to/python3 to build for python3.") + find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION}) + if(NOT PYTHONINTERP_FOUND) + message(STATUS "python2 not found - trying with python3") + find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED) + endif() + gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) + gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) + gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + endif() + find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT) +else() + find_package(Python3 COMPONENTS Interpreter) + if(Python3_FOUND) + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR}) + gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) + gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) + gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + endif() + if(NOT Python3_FOUND OR NOT MAKO_FOUND OR NOT SIX_FOUND) + find_package(Python2 COMPONENTS Interpreter) + if(Python2_FOUND) + set(PYTHON_EXECUTABLE ${Python2_EXECUTABLE}) + set(PYTHON_VERSION_MAJOR ${Python2_VERSION_MAJOR}) + gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) + gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) + gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + endif() + endif() +endif() + +if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) + set(PYTHON3 TRUE) +endif() + +if(CMAKE_CROSSCOMPILING) + set(QA_PYTHON_EXECUTABLE "/usr/bin/python") +else() + set(QA_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) +endif() + +# make the path to the executable appear in the cmake gui +set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") +set(QA_PYTHON_EXECUTABLE ${QA_PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter for QA tests") diff --git a/cmake/Modules/TestForARM.cmake b/cmake/Modules/TestForARM.cmake index 26c0a1874..05a5c172e 100644 --- a/cmake/Modules/TestForARM.cmake +++ b/cmake/Modules/TestForARM.cmake @@ -16,14 +16,14 @@ # along with GNSS-SDR. If not, see . ############################################################################## -# check if the compiler defines the architecture as ARM and set the +# check if the compiler defines the architecture as ARM and set the # version, if found. # # - Anthony Arnold ############################################################################## -if (__TEST_FOR_ARM_INCLUDED) - return () +if(__TEST_FOR_ARM_INCLUDED) + return() endif() set(__TEST_FOR_ARM_INCLUDED TRUE) @@ -31,27 +31,27 @@ set(__TEST_FOR_ARM_INCLUDED TRUE) # output variable if found. function(check_arm_version ppdef input_string version output_var) string(REGEX MATCH "${ppdef}" _VERSION_MATCH "${input_string}") - if (NOT _VERSION_MATCH STREQUAL "") + if(NOT _VERSION_MATCH STREQUAL "") set(${output_var} "${version}" PARENT_SCOPE) - endif(NOT _VERSION_MATCH STREQUAL "") + endif() endfunction() message(STATUS "Checking for ARM") -set (IS_ARM NO) -set (ARM_VERSION "") +set(IS_ARM NO) +set(ARM_VERSION "") -if (CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") execute_process(COMMAND echo "int main(){}" COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dM -E - OUTPUT_VARIABLE TEST_FOR_ARM_RESULTS) string(REGEX MATCH "__arm" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") if(ARM_FOUND STREQUAL "") - string(REGEX MATCH "__aarch64" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") - endif(ARM_FOUND STREQUAL "") + string(REGEX MATCH "__aarch64" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") + endif() - if (NOT ARM_FOUND STREQUAL "") + if(NOT ARM_FOUND STREQUAL "") set(IS_ARM YES) message(STATUS "ARM system detected") @@ -83,22 +83,21 @@ if (CMAKE_COMPILER_IS_GNUCXX) check_arm_version("__ARM_ARCH_8A" ${TEST_FOR_ARM_RESULTS} "armv8-a" ARM_VERSION) # anything else just define as arm - if (ARM_VERSION STREQUAL "") + if(ARM_VERSION STREQUAL "") message(STATUS "Couldn't detect ARM version. Setting to 'arm'") set(ARM_VERSION "arm") - else (ARM_VERSION STREQUAL "") + else() message(STATUS "ARM version ${ARM_VERSION} detected") - endif (ARM_VERSION STREQUAL "") - - else (NOT ARM_FOUND STREQUAL "") - message(STATUS "System is not ARM") - endif(NOT ARM_FOUND STREQUAL "") + endif() + else() + message(STATUS "System is not ARM") + endif() -else (CMAKE_COMPILE_IS_GNUCXX) +else() # TODO: Other compilers message(STATUS "Not detecting ARM on non-GNUCXX compiler. Defaulting to false") message(STATUS "If you are compiling for ARM, set IS_ARM=ON manually") -endif(CMAKE_COMPILER_IS_GNUCXX) +endif() set(IS_ARM ${IS_ARM} CACHE BOOL "Compiling for ARM") set(ARM_VERSION ${ARM_VERSION} CACHE STRING "ARM version") diff --git a/cmake/Modules/TestForSSE.cmake b/cmake/Modules/TestForSSE.cmake index 135a434ef..23b2d16a8 100644 --- a/cmake/Modules/TestForSSE.cmake +++ b/cmake/Modules/TestForSSE.cmake @@ -22,21 +22,20 @@ # - Anthony Arnold ############################################################################### - -function (test_for_sse h_file result_var name) - if (NOT DEFINED ${result_var}) +function(test_for_sse h_file result_var name) + if(NOT DEFINED ${result_var}) execute_process(COMMAND echo "#include <${h_file}>" - COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -c -x c++ - - RESULT_VARIABLE COMPILE_RESULT - OUTPUT_QUIET ERROR_QUIET) + COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -c -x c++ - + RESULT_VARIABLE COMPILE_RESULT + OUTPUT_QUIET ERROR_QUIET) set(detected 0) - if (COMPILE_RESULT EQUAL 0) + if(COMPILE_RESULT EQUAL 0) message(STATUS "Detected ${name}") set(detected 1) - endif(COMPILE_RESULT EQUAL 0) + endif() set(${result_var} ${detected} CACHE INTERNAL "${name} Available") - endif (NOT DEFINED ${result_var}) -endfunction(test_for_sse) + endif() +endfunction() message(STATUS "Testing for SIMD extensions") diff --git a/cmake/Toolchains/oe-sdk_cross.cmake b/cmake/Toolchains/oe-sdk_cross.cmake index aac39094e..dd7aedf5f 100644 --- a/cmake/Toolchains/oe-sdk_cross.cmake +++ b/cmake/Toolchains/oe-sdk_cross.cmake @@ -18,20 +18,20 @@ ########################################################## # Toolchain file for Open Embedded ########################################################## -set( CMAKE_SYSTEM_NAME Linux ) +set(CMAKE_SYSTEM_NAME Linux) string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT}) string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) -set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE ) -set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources -set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources -set( CMAKE_LIBRARY_PATH $ENV{OECORE_TARGET_SYSROOT}/usr/lib ) +set(CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_LIBRARY_PATH $ENV{OECORE_TARGET_SYSROOT}/usr/lib) -set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} ) -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +set(CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT}) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set ( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 ) -set ( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib ) +set(ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4) +set(ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index 5d4ab76f7..a0004acc5 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -17,22 +17,22 @@ if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") -endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif() file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove \"$ENV{DESTDIR}${file}\" OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) + RESULT_VARIABLE rm_retval + ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") - endif(NOT "${rm_retval}" STREQUAL 0) - else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + endif() + else() message(STATUS "File $ENV{DESTDIR}${file} does not exist.") - endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") -endforeach(file) + endif() +endforeach() diff --git a/conf/front-end-cal.conf b/conf/front-end-cal.conf index 106b8d736..8a2b55cb5 100644 --- a/conf/front-end-cal.conf +++ b/conf/front-end-cal.conf @@ -39,7 +39,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=217 -GNSS-SDR.SUPL_MNS=7 +GNSS-SDR.SUPL_MNC=7 GNSS-SDR.SUPL_LAC=861 GNSS-SDR.SUPL_CI=40184 @@ -182,8 +182,6 @@ Resampler.implementation=Pass_Through Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition_Fine_Doppler ;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version. Acquisition.item_type=gr_complex -;#if: Signal intermediate frequency in [Hz] -Acquisition.if=0 ;#sampled_ms: Signal block duration for the acquisition signal detection [ms] Acquisition.sampled_ms=1 ;#threshold: Acquisition threshold diff --git a/conf/gnss-sdr-kalman-bayes.conf b/conf/gnss-sdr-kalman-bayes.conf new file mode 100644 index 000000000..051d080de --- /dev/null +++ b/conf/gnss-sdr-kalman-bayes.conf @@ -0,0 +1,63 @@ +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. +GNSS-SDR.internal_fs_sps=2000000 +GNSS-SDR.internal_fs_hz=2000000 + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource.implementation=File_Signal_Source +SignalSource.filename=/home/glamountain/gnss-sdr/data/2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN/2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN.dat +SignalSource.item_type=ishort +SignalSource.sampling_frequency=4000000 +SignalSource.freq=1575420000 +SignalSource.samples=0 + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner.implementation=Signal_Conditioner +DataTypeAdapter.implementation=Ishort_To_Complex +InputFilter.implementation=Pass_Through +InputFilter.item_type=gr_complex +Resampler.implementation=Direct_Resampler +Resampler.sample_freq_in=4000000 +Resampler.sample_freq_out=2000000 +Resampler.item_type=gr_complex + +;######### CHANNELS GLOBAL CONFIG ############ +Channels_1C.count=8 +Channels.in_acquisition=1 +Channel.signal=1C + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition +Acquisition_1C.item_type=gr_complex +Acquisition_1C.threshold=0.008 +Acquisition_1C.doppler_max=10000 +Acquisition_1C.doppler_step=250 +Acquisition_1C.dump=false +Acquisition_1C.dump_filename=../data/kalman/acq_dump + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_1C.implementation=GPS_L1_CA_KF_Tracking +Tracking_1C.item_type=gr_complex +Tracking_1C.pll_bw_hz=40.0; +Tracking_1C.dll_bw_hz=4.0; +Tracking_1C.order=3; +Tracking_1C.dump=true +Tracking_1C.dump_filename=../data/kalman/epl_tracking_ch_ +Tracking_1C.bce_run = true; +Tracking_1C.p_transient = 0; +Tracking_1C.s_transient = 100; + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=GPS_L1_CA_Observables + +;######### PVT CONFIG ############ +PVT.implementation=GPS_L1_CA_PVT +PVT.averaging_depth=100 +PVT.flag_averaging=true +PVT.output_rate_ms=10 +PVT.display_rate_ms=500 diff --git a/conf/gnss-sdr.conf b/conf/gnss-sdr.conf index 4c9ae11a4..353bdb2fd 100644 --- a/conf/gnss-sdr.conf +++ b/conf/gnss-sdr.conf @@ -23,7 +23,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_BDS_B1I_byte.conf b/conf/gnss-sdr_BDS_B1I_byte.conf new file mode 100644 index 000000000..0c55931a1 --- /dev/null +++ b/conf/gnss-sdr_BDS_B1I_byte.conf @@ -0,0 +1,121 @@ +; This is a GNSS-SDR configuration file +; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ + +; You can define your own receiver and invoke it by doing +; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf +; + +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. +GNSS-SDR.internal_fs_sps=25000000 + +;######### CONTROL_THREAD CONFIG ############ +ControlThread.wait_for_flowgraph=false + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource.implementation=File_Signal_Source +SignalSource.filename=/home/dmiralles/Documents/GNSS-Metadata-Standard/install/BdsB1IStr01.dat +SignalSource.item_type=byte +SignalSource.sampling_frequency=25000000 +SignalSource.samples=0 +SignalSource.repeat=false +SignalSource.dump=false +SignalSource.enable_throttle_control=false + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner.implementation=Signal_Conditioner +DataTypeAdapter.implementation=Byte_To_Short +InputFilter.implementation=Freq_Xlating_Fir_Filter +InputFilter.input_item_type=short +InputFilter.output_item_type=gr_complex +InputFilter.taps_item_type=float +InputFilter.number_of_taps=5 +InputFilter.number_of_bands=2 +InputFilter.band1_begin=0.0 +InputFilter.band1_end=0.70 +InputFilter.band2_begin=0.80 +InputFilter.band2_end=1.0 +InputFilter.ampl1_begin=1.0 +InputFilter.ampl1_end=1.0 +InputFilter.ampl2_begin=0.0 +InputFilter.ampl2_end=0.0 +InputFilter.band1_error=1.0 +InputFilter.band2_error=1.0 +InputFilter.filter_type=bandpass +InputFilter.grid_density=16 +InputFilter.sampling_frequency=25000000 +InputFilter.IF=6250000 +Resampler.implementation=Pass_Through +Resampler.sample_freq_in=25000000 +Resampler.sample_freq_out=25000000 +Resampler.item_type=gr_complex + + +;######### CHANNELS GLOBAL CONFIG ############ +Channels_B1.count=10 +Channels.in_acquisition=1 +Channel.signal=B1 + +Channel0.satellite = 6; +Channel1.satellite = 8; +Channel2.satellite = 9; +Channel3.satellite = 13; +Channel4.satellite = 17; +Channel5.satellite = 1; +Channel6.satellite = 2; +Channel7.satellite = 3; +Channel8.satellite = 4; +Channel9.satellite = 5; + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_B1.implementation=BEIDOU_B1I_PCPS_Acquisition +Acquisition_B1.item_type=gr_complex +Acquisition_B1.coherent_integration_time_ms=1 +Acquisition_B1.threshold=0.0038 +;Acquisition_B1.pfa=0.0000001; +Acquisition_B1.doppler_max=15000 +Acquisition_B1.doppler_step=100 +Acquisition_B1.dump=true +Acquisition_B1.dump_filename=./bds_acq +Acquisition_B1.blocking=false; +Acquisition_B1.use_CFAR_algorithm=true; +Acquisition_B1.bit_transition_flag = false; + + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_B1.implementation=BEIDOU_B1I_DLL_PLL_Tracking +Tracking_B1.item_type=gr_complex +Tracking_B1.pll_bw_hz=25.0; +Tracking_B1.dll_bw_hz=2.50; +Tracking_B1.dump=true; +Tracking_B1.dump_filename=./epl_tracking_ch_ + + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_B1.implementation=BEIDOU_B1I_Telemetry_Decoder +TelemetryDecoder_B1.dump=false + + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=true +Observables.dump_filename=./observables.dat + + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.positioning_mode=Single ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic +PVT.iono_model=OFF ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX +PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.dump_filename=./PVT +PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea; +PVT.flag_nmea_tty_port=false; +PVT.nmea_dump_devname=/dev/pts/4 +PVT.flag_rtcm_server=false +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.dump=true diff --git a/conf/gnss-sdr_GLONASS_L1_ibyte.conf b/conf/gnss-sdr_GLONASS_L1_ibyte.conf new file mode 100644 index 000000000..9c5183c98 --- /dev/null +++ b/conf/gnss-sdr_GLONASS_L1_ibyte.conf @@ -0,0 +1,100 @@ +; You can define your own receiver and invoke it by doing +; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf +; + +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [Hz]. +GNSS-SDR.internal_fs_sps=6625000 + +;######### CONTROL_THREAD CONFIG ############ +ControlThread.wait_for_flowgraph=false + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource.implementation=File_Signal_Source +SignalSource.filename=/home/dmiralles/Documents/GSOC/GSOC2017/gnss-sdr/data/dmirallesNT1065_L2_20160831_fs6625e6_60e3_schar_1H.bin +SignalSource.item_type=ibyte +SignalSource.sampling_frequency=6625000 +SignalSource.freq=1602000000 +SignalSource.samples=0 +SignalSource.repeat=false +SignalSource.sample_type=iq +SignalSource.seconds_to_skip=0 +SignalSource.dump=false +SignalSource.dump_filename=../data/signal_source.dat +SignalSource.enable_throttle_control=false + + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner.implementation=Signal_Conditioner + +;DataTypeAdapter.implementation=Ishort_To_Complex +DataTypeAdapter.implementation=Ibyte_To_Complex +InputFilter.implementation=Pass_Through +;InputFilter.input_item_type=gr_complex +;InputFilter.output_item_type=gr_complex +InputFilter.item_type=gr_complex +;Resampler.implementation=Pass_Through +;Resampler.item_type=gr_complex +Resampler.implementation=Pass_Through +;Resampler.sample_freq_in=4000000 +;Resampler.sample_freq_out=2000000 +;Resampler.item_type=gr_complex +Resampler.item_type=gr_complex + +;######### CHANNELS GLOBAL CONFIG ############ +Channels_1R.count=8 ;Assuming here that identifier `1r=R` defines GLONASS SP signals +Channels.in_acquisition=1 +Channel.signal=1R +;Channel.item_type=cshort + + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_1R.dump=false +Acquisition_1R.dump_filename=./acq_dump.dat +Acquisition_1R.item_type=cshort +Acquisition_1R.sampled_ms=1 +Acquisition_1R.implementation=GLONASS_L1_CA_PCPS_Acquisition +Acquisition_1R.threshold=0.008 +;Acquisition_1C.pfa=0.000001 +Acquisition_1R.doppler_max=10000 +Acquisition_1R.doppler_step=250 +Acquisition_1R.tong_init_val=2 +Acquisition_1R.tong_max_val=10 +Acquisition_1R.tong_max_dwells=20 + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_1R.implementation=GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking +Tracking_1R.item_type=cshort +Tracking_1R.dump=false +Tracking_1R.dump_filename=../data/epl_tracking_ch_ +Tracking_1R.pll_bw_hz=40.0; +Tracking_1R.dll_bw_hz=4.0; +Tracking_1R.order=3; + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_1R.implementation=GLONASS_L1_CA_Telemetry_Decoder +TelemetryDecoder_1R.dump=false + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=false +Observables.dump_filename=./observables.dat + + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.positioning_mode=PPP_Static ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic +PVT.iono_model=Broadcast ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX +PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.dump_filename=./PVT +PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea; +PVT.flag_nmea_tty_port=false; +PVT.nmea_dump_devname=/dev/pts/4 +PVT.flag_rtcm_server=false +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.dump=false diff --git a/conf/gnss-sdr_GPS_L1_2ch_udp.conf b/conf/gnss-sdr_GPS_L1_2ch_udp.conf new file mode 100644 index 000000000..6dd703fa6 --- /dev/null +++ b/conf/gnss-sdr_GPS_L1_2ch_udp.conf @@ -0,0 +1,103 @@ +; You can define your own receiver and invoke it by doing +; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf +; + +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [Sps]. +GNSS-SDR.internal_fs_sps=13250000 ;//66.25/5 +;GNSS-SDR.internal_fs_sps=6625000 ;//66.25/10 +;GNSS-SDR.internal_fs_sps=3312500 ;//66.25/20 +;GNSS-SDR.internal_fs_sps=2650000 ;//66.25/25 + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource.implementation=Custom_UDP_Signal_Source +SignalSource.item_type=gr_complex +SignalSource.origin_address=0.0.0.0 +SignalSource.capture_device=eth0 +SignalSource.port=1234 +SignalSource.payload_bytes=1472 +;SignalSource.sample_type=cbyte +SignalSource.sample_type=c4bits +SignalSource.IQ_swap=false +SignalSource.RF_channels=1 +SignalSource.channels_in_udp=2 +SignalSource.dump=false +SignalSource.dump_filename=./signal_source.dat + + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner.implementation=Pass_Through +;SignalConditioner0.implementation=Pass_Through +;SignalConditioner1.implementation=Pass_Through + +;######### CHANNELS GLOBAL CONFIG ############ +Channels_1C.count=8 +Channels.in_acquisition=1 + +;# CHANNEL CONNECTION +Channel.signal=1C +Channel0.RF_channel_ID=0 +Channel1.RF_channel_ID=0 +Channel2.RF_channel_ID=0 +Channel3.RF_channel_ID=0 +Channel4.RF_channel_ID=0 +Channel5.RF_channel_ID=0 +Channel6.RF_channel_ID=0 +Channel7.RF_channel_ID=0 +Channel8.RF_channel_ID=1 +Channel9.RF_channel_ID=1 + +;Channel0.signal=1C +;Channel1.RF_channel_ID=1 +;Channel1.signal=1C + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition +Acquisition_1C.item_type=gr_complex +Acquisition_1C.threshold=17 +Acquisition_1C.use_CFAR_algorithm=false +Acquisition_1C.blocking=false +Acquisition_1C.doppler_max=5000 +Acquisition_1C.doppler_step=250 +Acquisition_1C.dump=false +Acquisition_1C.dump_filename=./acq_dump.dat + + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking +Tracking_1C.item_type=gr_complex +Tracking_1C.dump=false +Tracking_1C.dump_filename=./tracking_ch_ +Tracking_1C.pll_bw_hz=35.0; +Tracking_1C.dll_bw_hz=2.0; +Tracking_1C.early_late_space_chips=0.5; + + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder +TelemetryDecoder_1C.dump=false + + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=false +Observables.dump_filename=./observables.dat + + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.positioning_mode=PPP_Static ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic +PVT.iono_model=Broadcast ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX +PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.dump_filename=./PVT +PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea; +PVT.flag_nmea_tty_port=false; +PVT.nmea_dump_devname=/dev/pts/4 +PVT.flag_rtcm_server=false +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.dump=false diff --git a/conf/gnss-sdr_GPS_L1_CA_ibyte.conf b/conf/gnss-sdr_GPS_L1_CA_ibyte.conf index da4b273c2..c4a38223d 100644 --- a/conf/gnss-sdr_GPS_L1_CA_ibyte.conf +++ b/conf/gnss-sdr_GPS_L1_CA_ibyte.conf @@ -52,7 +52,6 @@ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition Acquisition_1C.item_type=gr_complex Acquisition_1C.threshold=0.01 ;Acquisition_1C.pfa=0.00001 -Acquisition_1C.if=0 Acquisition_1C.doppler_max=10000 Acquisition_1C.doppler_step=250 Acquisition_1C.dump=false; @@ -62,7 +61,6 @@ Acquisition_1C.dump_filename=/archive/gps_acquisition.dat ;######### TRACKING GLOBAL CONFIG ############ Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking Tracking_1C.item_type=gr_complex -Tracking_1C.if=60000 Tracking_1C.early_late_space_chips=0.5 Tracking_1C.pll_bw_hz=25.0; Tracking_1C.dll_bw_hz=3.0; diff --git a/conf/gnss-sdr_GPS_L1_LimeSDR.conf b/conf/gnss-sdr_GPS_L1_LimeSDR.conf index c50572aef..c465a41ca 100644 --- a/conf/gnss-sdr_GPS_L1_LimeSDR.conf +++ b/conf/gnss-sdr_GPS_L1_LimeSDR.conf @@ -65,7 +65,6 @@ Channel.signal=1C ;######### ACQUISITION GLOBAL CONFIG ############ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition_Fine_Doppler Acquisition_1C.item_type=gr_complex -Acquisition_1C.if=0 Acquisition_1C.sampled_ms=1 Acquisition_1C.threshold=0.015 Acquisition_1C.doppler_max=10000 @@ -78,7 +77,6 @@ Acquisition_1C.dump_filename=./acq_dump.dat ;######### TRACKING GLOBAL CONFIG ############ Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking Tracking_1C.item_type=gr_complex -Tracking_1C.if=0 Tracking_1C.pll_bw_hz=40.0; Tracking_1C.dll_bw_hz=2.0; Tracking_1C.order=3; diff --git a/conf/gnss-sdr_GPS_L1_USRP_X300_realtime.conf b/conf/gnss-sdr_GPS_L1_USRP_X300_realtime.conf index ba96a533e..f437366bf 100644 --- a/conf/gnss-sdr_GPS_L1_USRP_X300_realtime.conf +++ b/conf/gnss-sdr_GPS_L1_USRP_X300_realtime.conf @@ -24,7 +24,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_USRP_realtime.conf b/conf/gnss-sdr_GPS_L1_USRP_realtime.conf index b432eb6b2..323feec08 100644 --- a/conf/gnss-sdr_GPS_L1_USRP_realtime.conf +++ b/conf/gnss-sdr_GPS_L1_USRP_realtime.conf @@ -23,7 +23,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_fmcomms2_realtime.conf b/conf/gnss-sdr_GPS_L1_fmcomms2_realtime.conf index 3de8486d8..b2d0604bb 100644 --- a/conf/gnss-sdr_GPS_L1_fmcomms2_realtime.conf +++ b/conf/gnss-sdr_GPS_L1_fmcomms2_realtime.conf @@ -21,7 +21,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_nsr.conf b/conf/gnss-sdr_GPS_L1_nsr.conf index 2b3d3f5f4..4b0b05ae2 100644 --- a/conf/gnss-sdr_GPS_L1_nsr.conf +++ b/conf/gnss-sdr_GPS_L1_nsr.conf @@ -2,7 +2,7 @@ ; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ ; Sample configuration file for IFEN SX-NSR software receiver front-end -; http://www.ifen.com/products/sx-scientific-gnss-solutions/nsr-software-receiver.html +; https://www.ifen.com/products/sx3-gnss-software-receiver/ ; This sample configuration is able to process directly .sream binary files ; You can define your own receiver and invoke it by doing ; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf @@ -25,7 +25,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_nsr_kf.conf b/conf/gnss-sdr_GPS_L1_nsr_kf.conf new file mode 100644 index 000000000..d2a84cd9f --- /dev/null +++ b/conf/gnss-sdr_GPS_L1_nsr_kf.conf @@ -0,0 +1,211 @@ +; Default configuration file +; You can define your own receiver and invoke it by doing +; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf +; + +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. +;GNSS-SDR.internal_fs_sps=6826700 +GNSS-SDR.internal_fs_sps=2560000 +;GNSS-SDR.internal_fs_sps=4096000 +;GNSS-SDR.internal_fs_sps=5120000 + +;######### SIGNAL_SOURCE CONFIG ############ +;#implementation: Use [File_Signal_Source] [Nsr_File_Signal_Source] or [UHD_Signal_Source] or [GN3S_Signal_Source] (experimental) +SignalSource.implementation=Nsr_File_Signal_Source + +;#filename: path to file with the captured GNSS signal samples to be processed +SignalSource.filename=/home/javier/signals/ifen/E1L1_FE0_Band0.stream ; <- PUT YOUR FILE HERE + +;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version. +SignalSource.item_type=byte + +;#sampling_frequency: Original Signal sampling frequency in [Hz] +SignalSource.sampling_frequency=20480000 + +;#freq: RF front-end center frequency in [Hz] +SignalSource.freq=1575420000 + +;#samples: Number of samples to be processed. Notice that 0 indicates the entire file. +SignalSource.samples=0 + +;#repeat: Repeat the processing file. Disable this option in this version +SignalSource.repeat=false + +;#dump: Dump the Signal source data to a file. Disable this option in this version +SignalSource.dump=false + +SignalSource.dump_filename=../data/signal_source.dat + + +;#enable_throttle_control: Enabling this option tells the signal source to keep the delay between samples in post processing. +; it helps to not overload the CPU, but the processing time will be longer. +SignalSource.enable_throttle_control=false + + +;######### SIGNAL_CONDITIONER CONFIG ############ +;## It holds blocks to change data type, filter and resample input data. + +;#implementation: Use [Pass_Through] or [Signal_Conditioner] +;#[Pass_Through] disables this block and the [DataTypeAdapter], [InputFilter] and [Resampler] blocks +;#[Signal_Conditioner] enables this block. Then you have to configure [DataTypeAdapter], [InputFilter] and [Resampler] blocks +SignalConditioner.implementation=Signal_Conditioner + +;######### DATA_TYPE_ADAPTER CONFIG ############ +;## Changes the type of input data. +;#implementation: [Pass_Through] disables this block +DataTypeAdapter.implementation=Pass_Through +DataTypeAdapter.item_type=float + +;######### INPUT_FILTER CONFIG ############ +;## Filter the input data. Can be combined with frequency translation for IF signals + +;#implementation: Use [Pass_Through] or [Fir_Filter] or [Freq_Xlating_Fir_Filter] +;#[Freq_Xlating_Fir_Filter] enables FIR filter and a composite frequency translation +;# that shifts IF down to zero Hz. + +InputFilter.implementation=Freq_Xlating_Fir_Filter + +;#dump: Dump the filtered data to a file. +InputFilter.dump=false + +;#dump_filename: Log path and filename. +InputFilter.dump_filename=../data/input_filter.dat + +;#The following options are used in the filter design of Fir_Filter and Freq_Xlating_Fir_Filter implementation. +;#These options are based on parameters of gnuradio's function: gr_remez. +;#These function calculates the optimal (in the Chebyshev/minimax sense) FIR filter inpulse +;#reponse given a set of band edges, the desired reponse on those bands, +;#and the weight given to the error in those bands. + +;#input_item_type: Type and resolution for input signal samples. Use only gr_complex in this version. +InputFilter.input_item_type=float + +;#outut_item_type: Type and resolution for output filtered signal samples. Use only gr_complex in this version. +InputFilter.output_item_type=gr_complex + +;#taps_item_type: Type and resolution for the taps of the filter. Use only float in this version. +InputFilter.taps_item_type=float + +;#number_of_taps: Number of taps in the filter. Increasing this parameter increases the processing time +InputFilter.number_of_taps=5 + +;#number_of _bands: Number of frequency bands in the filter. +InputFilter.number_of_bands=2 + +;#bands: frequency at the band edges [ b1 e1 b2 e2 b3 e3 ...]. +;#Frequency is in the range [0, 1], with 1 being the Nyquist frequency (Fs/2) +;#The number of band_begin and band_end elements must match the number of bands + +InputFilter.band1_begin=0.0 +InputFilter.band1_end=0.45 +InputFilter.band2_begin=0.55 +InputFilter.band2_end=1.0 + +;#ampl: desired amplitude at the band edges [ a(b1) a(e1) a(b2) a(e2) ...]. +;#The number of ampl_begin and ampl_end elements must match the number of bands + +InputFilter.ampl1_begin=1.0 +InputFilter.ampl1_end=1.0 +InputFilter.ampl2_begin=0.0 +InputFilter.ampl2_end=0.0 + +;#band_error: weighting applied to each band (usually 1). +;#The number of band_error elements must match the number of bands +InputFilter.band1_error=1.0 +InputFilter.band2_error=1.0 + +;#filter_type: one of "bandpass", "hilbert" or "differentiator" +InputFilter.filter_type=bandpass + +;#grid_density: determines how accurately the filter will be constructed. +;The minimum value is 16; higher values are slower to compute the filter. +InputFilter.grid_density=16 + +;# Original sampling frequency stored in the signal file +InputFilter.sampling_frequency=20480000 + +;#The following options are used only in Freq_Xlating_Fir_Filter implementation. +;#InputFilter.IF is the intermediate frequency (in Hz) shifted down to zero Hz + +InputFilter.IF=5499998.47412109 + +;# Decimation factor after the frequency tranaslating block +InputFilter.decimation_factor=8 + + +;######### RESAMPLER CONFIG ############ +;## Resamples the input data. + +;#implementation: Use [Pass_Through] or [Direct_Resampler] +;#[Pass_Through] disables this block +;#[Direct_Resampler] enables a resampler that implements a nearest neigbourhood interpolation +Resampler.implementation=Pass_Through + +;######### CHANNELS GLOBAL CONFIG ############ +;#count: Number of available GPS satellite channels. +Channels_1C.count=8 +Channels.in_acquisition=1 +#Channel.signal=1C + + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_1C.dump=false +Acquisition_1C.dump_filename=./acq_dump.dat +Acquisition_1C.item_type=gr_complex +Acquisition_1C.if=0 +Acquisition_1C.sampled_ms=1 +Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition +;#use_CFAR_algorithm: If enabled, acquisition estimates the input signal power to implement CFAR detection algorithms +;#notice that this affects the Acquisition threshold range! +Acquisition_1C.use_CFAR_algorithm=false; +;#threshold: Acquisition threshold +Acquisition_1C.threshold=10 +;Acquisition_1C.pfa=0.01 +Acquisition_1C.doppler_max=5000 +Acquisition_1C.doppler_step=100 + + +;######### TRACKING GPS CONFIG ############ +Tracking_1C.implementation=GPS_L1_CA_KF_Tracking +Tracking_1C.item_type=gr_complex +Tracking_1C.if=0 +Tracking_1C.dump=true +Tracking_1C.dump_filename=../data/epl_tracking_ch_ +Tracking_1C.pll_bw_hz=15.0; +Tracking_1C.dll_bw_hz=2.0; +Tracking_1C.order=3; + + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder +TelemetryDecoder_1C.dump=false +TelemetryDecoder_1C.decimation_factor=1; + +;######### OBSERVABLES CONFIG ############ +;#implementation: +Observables.implementation=Hybrid_Observables + +;#dump: Enable or disable the Observables internal binary data file logging [true] or [false] +Observables.dump=false + +;#dump_filename: Log path and filename. +Observables.dump_filename=./observables.dat + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.positioning_mode=PPP_Static ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic +PVT.iono_model=Broadcast ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX +PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.dump_filename=./PVT +PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea; +PVT.flag_nmea_tty_port=false; +PVT.nmea_dump_devname=/dev/pts/4 +PVT.flag_rtcm_server=false +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.dump=true diff --git a/conf/gnss-sdr_GPS_L1_nsr_twobit_packed.conf b/conf/gnss-sdr_GPS_L1_nsr_twobit_packed.conf index d31885566..dfe6e331a 100644 --- a/conf/gnss-sdr_GPS_L1_nsr_twobit_packed.conf +++ b/conf/gnss-sdr_GPS_L1_nsr_twobit_packed.conf @@ -2,7 +2,7 @@ ; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ ; Sample configuration file for IFEN SX-NSR software receiver front-end -; http://www.ifen.com/products/sx-scientific-gnss-solutions/nsr-software-receiver.html +; https://www.ifen.com/products/sx3-gnss-software-receiver/ ; This sample configuration is able to process directly .sream binary files ; You can define your own receiver and invoke it by doing ; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf @@ -25,7 +25,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 @@ -105,7 +105,6 @@ Channel.signal=1C ;######### GPS ACQUISITION CONFIG ############ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition Acquisition_1C.item_type=gr_complex -Acquisition_1C.if=0 Acquisition_1C.sampled_ms=1 Acquisition_1C.threshold=0.0075 ;Acquisition_1C.pfa=0.01 @@ -118,7 +117,6 @@ Acquisition_1C.dump_filename=./acq_dump.dat ;######### TRACKING GPS CONFIG ############ Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking Tracking_1C.item_type=gr_complex -Tracking_1C.if=0 Tracking_1C.pll_bw_hz=45.0; Tracking_1C.dll_bw_hz=2.0; Tracking_1C.order=3; diff --git a/conf/gnss-sdr_GPS_L1_plutosdr_realtime.conf b/conf/gnss-sdr_GPS_L1_plutosdr_realtime.conf index fa8996dc7..872f56bf4 100644 --- a/conf/gnss-sdr_GPS_L1_plutosdr_realtime.conf +++ b/conf/gnss-sdr_GPS_L1_plutosdr_realtime.conf @@ -24,7 +24,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_pulse_blanking_gr_complex.conf b/conf/gnss-sdr_GPS_L1_pulse_blanking_gr_complex.conf index e186f1da7..618341f48 100644 --- a/conf/gnss-sdr_GPS_L1_pulse_blanking_gr_complex.conf +++ b/conf/gnss-sdr_GPS_L1_pulse_blanking_gr_complex.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_rtl_tcp_realtime.conf b/conf/gnss-sdr_GPS_L1_rtl_tcp_realtime.conf index 91b952ad0..4b91a9344 100644 --- a/conf/gnss-sdr_GPS_L1_rtl_tcp_realtime.conf +++ b/conf/gnss-sdr_GPS_L1_rtl_tcp_realtime.conf @@ -24,7 +24,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5_1C +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf b/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf index f3252578b..2cec70e8c 100644 --- a/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf +++ b/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf @@ -24,7 +24,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L1_two_bits_cpx.conf b/conf/gnss-sdr_GPS_L1_two_bits_cpx.conf index 84753bee7..b58fc57ba 100644 --- a/conf/gnss-sdr_GPS_L1_two_bits_cpx.conf +++ b/conf/gnss-sdr_GPS_L1_two_bits_cpx.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L2C_USRP1_realtime.conf b/conf/gnss-sdr_GPS_L2C_USRP1_realtime.conf index 6d61e063b..cce644be9 100644 --- a/conf/gnss-sdr_GPS_L2C_USRP1_realtime.conf +++ b/conf/gnss-sdr_GPS_L2C_USRP1_realtime.conf @@ -23,7 +23,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_GPS_L2C_USRP_X300_realtime.conf b/conf/gnss-sdr_GPS_L2C_USRP_X300_realtime.conf index 55a84a13e..49868f37a 100644 --- a/conf/gnss-sdr_GPS_L2C_USRP_X300_realtime.conf +++ b/conf/gnss-sdr_GPS_L2C_USRP_X300_realtime.conf @@ -23,7 +23,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_Galileo_E5a.conf b/conf/gnss-sdr_Galileo_E5a.conf index c4df4139f..81dddd613 100644 --- a/conf/gnss-sdr_Galileo_E5a.conf +++ b/conf/gnss-sdr_Galileo_E5a.conf @@ -22,7 +22,7 @@ GNSS-SDR.internal_fs_sps=32000000 ;GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com ;GNSS-SDR.SUPL_gps_acquisition_port=7275 ;GNSS-SDR.SUPL_MCC=244 -;GNSS-SDR.SUPL_MNS=5 +;GNSS-SDR.SUPL_MNC=5 ;GNSS-SDR.SUPL_LAC=0x59e2 ;GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_Galileo_E5a_IFEN_CTTC.conf b/conf/gnss-sdr_Galileo_E5a_IFEN_CTTC.conf index f66079cb4..26d01617d 100644 --- a/conf/gnss-sdr_Galileo_E5a_IFEN_CTTC.conf +++ b/conf/gnss-sdr_Galileo_E5a_IFEN_CTTC.conf @@ -21,7 +21,7 @@ GNSS-SDR.internal_fs_sps=50000000 ;GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com ;GNSS-SDR.SUPL_gps_acquisition_port=7275 ;GNSS-SDR.SUPL_MCC=244 -;GNSS-SDR.SUPL_MNS=5 +;GNSS-SDR.SUPL_MNC=5 ;GNSS-SDR.SUPL_LAC=0x59e2 ;GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_Hybrid_byte.conf b/conf/gnss-sdr_Hybrid_byte.conf index a70b62820..b7f4e58ff 100644 --- a/conf/gnss-sdr_Hybrid_byte.conf +++ b/conf/gnss-sdr_Hybrid_byte.conf @@ -14,7 +14,7 @@ GNSS-SDR.internal_fs_sps=20000000 ;######### SIGNAL_SOURCE CONFIG ############ SignalSource.implementation=File_Signal_Source -SignalSource.filename=/datalogger/signals/Fraunhofer/L125_III1b_210s_L1.bin ; <- PUT YOUR FILE HERE +SignalSource.filename=/media/javier/Extreme 500/fraunhofer/L125_III1b_210s_L1.bin ; <- PUT YOUR FILE HERE SignalSource.item_type=byte SignalSource.sampling_frequency=20000000 SignalSource.samples=0 @@ -46,12 +46,20 @@ Resampler.dump_filename=../data/resampler.dat ;######### CHANNELS GLOBAL CONFIG ############ -Channels_1C.count=8 -Channels_1B.count=8 +Channels_1C.count=10 +Channels_1B.count=10 Channels.in_acquisition=1 ;#signal: +;# "1C" GPS L1 C/A +;# "1B" GALILEO E1 B (I/NAV OS/CS/SoL) +;# "1G" GLONASS L1 C/A +;# "2S" GPS L2 L2C (M) +;# "5X" GALILEO E5a I+Q +;# "L5" GPS L5 + ;#if the option is disabled by default is assigned "1C" GPS L1 C/A +Channel0.signal=1C Channel1.signal=1C Channel2.signal=1C Channel3.signal=1C @@ -67,16 +75,19 @@ Channel12.signal=1B Channel13.signal=1B Channel14.signal=1B Channel15.signal=1B - +Channel16.signal=1B +Channel17.signal=1B +Channel18.signal=1B +Channel19.signal=1B ;######### GPS ACQUISITION CONFIG ############ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition Acquisition_1C.item_type=gr_complex -Acquisition_1C.coherent_integration_time_ms=1 -Acquisition_1C.threshold=0.0060 -;Acquisition_1C.pfa=0.01 -Acquisition_1C.doppler_max=10000 -Acquisition_1C.doppler_step=500 +Acquisition_1C.threshold=18 +Acquisition_1C.use_CFAR_algorithm=false +Acquisition_1C.blocking=true +Acquisition_1C.doppler_max=5000 +Acquisition_1C.doppler_step=250 Acquisition_1C.dump=false Acquisition_1C.dump_filename=./acq_dump.dat @@ -84,21 +95,23 @@ Acquisition_1C.dump_filename=./acq_dump.dat ;######### GALILEO ACQUISITION CONFIG ############ Acquisition_1B.implementation=Galileo_E1_PCPS_Ambiguous_Acquisition Acquisition_1B.item_type=gr_complex -Acquisition_1B.coherent_integration_time_ms=4 -;Acquisition_1B.threshold=0 -Acquisition_1B.pfa=0.0000008 -Acquisition_1B.doppler_max=15000 +Acquisition_1B.threshold=25 +Acquisition_1B.use_CFAR_algorithm=false +Acquisition_1B.blocking=true +Acquisition_1B.doppler_max=5000 Acquisition_1B.doppler_step=125 Acquisition_1B.dump=false Acquisition_1B.dump_filename=./acq_dump.dat - ;######### TRACKING GPS CONFIG ############ -Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking +Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_C_Aid_Tracking Tracking_1C.item_type=gr_complex -Tracking_1C.pll_bw_hz=45.0; -Tracking_1C.dll_bw_hz=4.0; -Tracking_1C.order=3; +Tracking_1C.extend_correlation_ms=1 +Tracking_1C.pll_bw_hz=40; +Tracking_1C.pll_bw_narrow_hz=30; +Tracking_1C.dll_bw_hz=2.0; +Tracking_1C.dll_bw_narrow_hz=1.5; +Tracking_1C.order=2; Tracking_1C.dump=false Tracking_1C.dump_filename=../data/epl_tracking_ch_ @@ -107,7 +120,7 @@ Tracking_1C.dump_filename=../data/epl_tracking_ch_ Tracking_1B.implementation=Galileo_E1_DLL_PLL_VEML_Tracking Tracking_1B.item_type=gr_complex Tracking_1B.pll_bw_hz=15.0; -Tracking_1B.dll_bw_hz=2.0; +Tracking_1B.dll_bw_hz=3.0; Tracking_1B.order=3; Tracking_1B.early_late_space_chips=0.15; Tracking_1B.very_early_late_space_chips=0.6; @@ -126,6 +139,7 @@ TelemetryDecoder_1B.dump=false ;######### OBSERVABLES CONFIG ############ +;#implementation: Observables.implementation=Hybrid_Observables Observables.dump=false Observables.dump_filename=./observables.dat @@ -133,13 +147,14 @@ Observables.dump_filename=./observables.dat ;######### PVT CONFIG ############ PVT.implementation=RTKLIB_PVT -PVT.positioning_mode=PPP_Static ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic +PVT.positioning_mode=Single ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic PVT.iono_model=Broadcast ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad -PVT.output_rate_ms=100; +PVT.output_rate_ms=10; PVT.display_rate_ms=500; -PVT.dump=false +PVT.elevation_mask=15; PVT.flag_rtcm_server=false PVT.flag_rtcm_tty_port=false PVT.rtcm_dump_devname=/dev/pts/1 +PVT.dump=false PVT.dump_filename=./PVT diff --git a/conf/gnss-sdr_Hybrid_ishort.conf b/conf/gnss-sdr_Hybrid_ishort.conf index 55a70b7a2..c634009f3 100644 --- a/conf/gnss-sdr_Hybrid_ishort.conf +++ b/conf/gnss-sdr_Hybrid_ishort.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_Hybrid_nsr.conf b/conf/gnss-sdr_Hybrid_nsr.conf index 934ca2ffd..9f65ead4b 100644 --- a/conf/gnss-sdr_Hybrid_nsr.conf +++ b/conf/gnss-sdr_Hybrid_nsr.conf @@ -14,7 +14,7 @@ GNSS-SDR.internal_fs_sps=2560000 ;######### SIGNAL_SOURCE CONFIG ############ SignalSource.implementation=Nsr_File_Signal_Source -SignalSource.filename=/media/javier/SISTEMA/signals/ifen/E1L1_FE0_Band0.stream ; <- PUT YOUR FILE HERE +SignalSource.filename=/home/javier/signals/ifen/E1L1_FE0_Band0.stream ; <- PUT YOUR FILE HERE SignalSource.item_type=byte SignalSource.sampling_frequency=20480000 SignalSource.samples=0 @@ -61,8 +61,8 @@ InputFilter.dump_filename=../data/input_filter.dat Resampler.implementation=Pass_Through ;######### CHANNELS GLOBAL CONFIG ############ -Channels_1C.count=8 -Channels_1B.count=0 +Channels_1C.count=10 +Channels_1B.count=10 Channels.in_acquisition=1 ;#signal: @@ -82,22 +82,26 @@ Channel4.signal=1C Channel5.signal=1C Channel6.signal=1C Channel7.signal=1C -Channel8.signal=1B -Channel9.signal=1B +Channel8.signal=1C +Channel9.signal=1C Channel10.signal=1B Channel11.signal=1B Channel12.signal=1B Channel13.signal=1B Channel14.signal=1B Channel15.signal=1B +Channel16.signal=1B +Channel17signal=1B +Channel18.signal=1B +Channel19.signal=1B ;######### GPS ACQUISITION CONFIG ############ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition Acquisition_1C.item_type=gr_complex -Acquisition_1C.coherent_integration_time_ms=1 -Acquisition_1C.threshold=0.0075 -;Acquisition_1C.pfa=0.01 +Acquisition_1C.threshold=25 +Acquisition_1C.use_CFAR_algorithm=false +Acquisition_1C.blocking=true Acquisition_1C.doppler_max=5000 Acquisition_1C.doppler_step=250 Acquisition_1C.dump=false @@ -107,32 +111,31 @@ Acquisition_1C.dump_filename=./acq_dump.dat ;######### GALILEO ACQUISITION CONFIG ############ Acquisition_1B.implementation=Galileo_E1_PCPS_Ambiguous_Acquisition Acquisition_1B.item_type=gr_complex -Acquisition_1B.coherent_integration_time_ms=4 -;Acquisition_1B.threshold=0 -Acquisition_1B.pfa=0.0000002 -Acquisition_1B.doppler_max=15000 -Acquisition_1B.doppler_step=125 +Acquisition_1B.threshold=25 +Acquisition_1B.use_CFAR_algorithm=false +Acquisition_1B.blocking=true +Acquisition_1B.doppler_max=5000 +Acquisition_1B.doppler_step=250 Acquisition_1B.dump=false Acquisition_1B.dump_filename=./acq_dump.dat - ;######### TRACKING GPS CONFIG ############ Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_C_Aid_Tracking Tracking_1C.item_type=gr_complex Tracking_1C.extend_correlation_ms=1 Tracking_1C.pll_bw_hz=40; -Tracking_1C.pll_bw_narrow_hz=20; +Tracking_1C.pll_bw_narrow_hz=30; Tracking_1C.dll_bw_hz=2.0; -Tracking_1C.dll_bw_narrow_hz=1.0; -Tracking_1C.order=3; -Tracking_1C.dump=true +Tracking_1C.dll_bw_narrow_hz=1.5; +Tracking_1C.order=2; +Tracking_1C.dump=false Tracking_1C.dump_filename=../data/epl_tracking_ch_ ;######### TRACKING GALILEO CONFIG ############ Tracking_1B.implementation=Galileo_E1_DLL_PLL_VEML_Tracking Tracking_1B.item_type=gr_complex -Tracking_1B.pll_bw_hz=15.0; +Tracking_1B.pll_bw_hz=20.0; Tracking_1B.dll_bw_hz=2.0; Tracking_1B.order=3; Tracking_1B.early_late_space_chips=0.15; @@ -165,6 +168,7 @@ PVT.iono_model=Broadcast ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad PVT.output_rate_ms=10; PVT.display_rate_ms=500; +PVT.elevation_mask=20; PVT.flag_rtcm_server=false PVT.flag_rtcm_tty_port=false PVT.rtcm_dump_devname=/dev/pts/1 diff --git a/conf/gnss-sdr_galileo_E1_extended_correlator_byte.conf b/conf/gnss-sdr_galileo_E1_extended_correlator_byte.conf index aea77c99c..366299f74 100644 --- a/conf/gnss-sdr_galileo_E1_extended_correlator_byte.conf +++ b/conf/gnss-sdr_galileo_E1_extended_correlator_byte.conf @@ -97,7 +97,6 @@ Tracking_1C.dump_filename=../data/epl_tracking_ch_ ;######### TRACKING GALILEO CONFIG ############ Tracking_1B.implementation=Galileo_E1_DLL_PLL_VEML_Tracking Tracking_1B.item_type=gr_complex -Tracking_1B.if=0 Tracking_1B.track_pilot=true Tracking_1B.pll_bw_hz=4.0; Tracking_1B.dll_bw_hz=0.5; diff --git a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf index 7b978be5b..c395a5f3c 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf @@ -21,7 +21,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1a.conf b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1a.conf index bb5d4327e..134bfa457 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1a.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1a.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1b.conf b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1b.conf index 2ef22b956..9552ebabe 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1b.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_III_1b.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_II_3b.conf b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_II_3b.conf index 1d7fa6097..f1e5d264b 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_II_3b.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_II_3b.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_I_1b.conf b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_I_1b.conf index 2072f8c7d..201fff1ab 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_I_1b.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_realtime_I_1b.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L1_L2_Flexiband_realtime_III_1b.conf b/conf/gnss-sdr_multichannel_GPS_L1_L2_Flexiband_realtime_III_1b.conf index 3094d8c97..48eabee34 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_L2_Flexiband_realtime_III_1b.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_L2_Flexiband_realtime_III_1b.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_bin_file_III_1b.conf b/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_bin_file_III_1b.conf index 720c68fa9..7c19ebc2c 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_bin_file_III_1b.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_bin_file_III_1b.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 @@ -188,7 +188,6 @@ Acquisition_1C.dump_filename=./acq_dump.dat ;######### TRACKING GLOBAL CONFIG ############ Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking Tracking_1C.item_type=gr_complex -Tracking_1C.if=0 Tracking_1C.dump=false Tracking_1C.dump_filename=../data/epl_tracking_ch_ Tracking_1C.pll_bw_hz=40.0; @@ -199,7 +198,6 @@ Tracking_1C.early_late_space_chips=0.5; ;# GPS L2C M Acquisition_2S.implementation=GPS_L2_M_PCPS_Acquisition Acquisition_2S.item_type=gr_complex -Acquisition_2S.if=0 Acquisition_2S.threshold=0.0005 ;Acquisition_2S.pfa=0.001 Acquisition_2S.doppler_max=5000 @@ -211,7 +209,6 @@ Acquisition_2S.dump_filename=./acq_dump.dat Tracking_2S.implementation=GPS_L2_M_DLL_PLL_Tracking Tracking_2S.item_type=gr_complex -Tracking_2S.if=0 Tracking_2S.pll_bw_hz=1.5; Tracking_2S.dll_bw_hz=0.3; Tracking_2S.order=3; diff --git a/conf/gnss-sdr_multichannel_GPS_L1_USRP_X300_realtime.conf b/conf/gnss-sdr_multichannel_GPS_L1_USRP_X300_realtime.conf index 411a712ab..63746aea4 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_USRP_X300_realtime.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_USRP_X300_realtime.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_1C_ephemeris_port=7275 GNSS-SDR.SUPL_1C_acquisition_server=supl.google.com GNSS-SDR.SUPL_1C_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b.conf b/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b.conf index fb6fae1c2..9c2a86def 100644 --- a/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b.conf +++ b/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b_real.conf b/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b_real.conf index 6d62e65b3..a52349af1 100644 --- a/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b_real.conf +++ b/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1b_real.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/conf/gnss-sdr_multichannel_all_in_one_Flexiband_bin_file_III_1b.conf b/conf/gnss-sdr_multichannel_all_in_one_Flexiband_bin_file_III_1b.conf index 50e49f2e9..a3e23b001 100644 --- a/conf/gnss-sdr_multichannel_all_in_one_Flexiband_bin_file_III_1b.conf +++ b/conf/gnss-sdr_multichannel_all_in_one_Flexiband_bin_file_III_1b.conf @@ -22,7 +22,7 @@ GNSS-SDR.SUPL_gps_ephemeris_port=7275 GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com GNSS-SDR.SUPL_gps_acquisition_port=7275 GNSS-SDR.SUPL_MCC=244 -GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_MNC=5 GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 diff --git a/docs/PULL_REQUEST_TEMPLATE.md b/docs/PULL_REQUEST_TEMPLATE.md index 0ab14dff6..a6cc9eef2 100644 --- a/docs/PULL_REQUEST_TEMPLATE.md +++ b/docs/PULL_REQUEST_TEMPLATE.md @@ -9,4 +9,4 @@ Before submitting your pull request, please make sure the following is done: 6. You have forked the [gnss-sdr upstream repository](https://github.com/gnss-sdr/gnss-sdr) and have created your branch from `next` (or any other currently living branch in the upstream repository). 7. Please include a description of your changes here. -**Please feel free to delete this line and the above text once you have read it and in case you want to go on with your pull request.** +**Please feel free to delete this line and the above text once you have read it and in case you want to go on with your pull request, and explain your intend below.** diff --git a/docs/changelog b/docs/changelog index 6931753ab..312543bc6 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,33 +1,69 @@ ## [Unreleased](https://github.com/gnss-sdr/gnss-sdr/tree/next) -Next release will have several improvements, addition of new features and bug fixes in many dimensions: +### Improvements in Efficiency + +- Applied clang-tidy checks and fixes related to performance. + +### Improvements in Interoperability: + +- Added the BeiDou B1I receiver chain. +- Fix bug in GLONASS dual frequency receiver. + +### Improvements in Maintainability: + +- Usage of clang-tidy integrated into CMake scripts. New option -DENABLE_CLANG_TIDY=ON executes clang-tidy along with compilation. Requires clang compiler. +- Applied clang-tidy checks and fixes related to readability. + +### Improvements in Portability: + +- CMake scripts now follow a modern approach (targets and properties) but still work in 2.8.12 + + +## Improvements in Reliability + +- Applied clang-tidy checks and fixes related to High Integrity C++. + + +## [0.0.10](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.10) + +This release has several improvements in different dimensions, addition of new features and bug fixes: ### Improvements in Accuracy: -- Part of the RTKLIB core libraries has been integrated into GNSS-SDR. There is now a single PVT block implementation which makes use of RTKLIB to deliver PVT solutions, including Single and PPP navigation modes. +- Part of the RTKLIB core library has been integrated into GNSS-SDR. There is now a single PVT block implementation which makes use of RTKLIB to deliver PVT solutions, including Single and PPP navigation modes. - Fixed CN0 estimation for other correlation times than 1 ms. +- Improved computation of tracking parameters and GNSS observables. +- Other minor bug fixes. ### Improvements in Availability: - Internal Finite State Machines rewritten for improved continuity in delivering position fixes. This fixes a bug that was stalling the receiver after about six hours of continuous operation. - Redesign of the time counter for enhanced continuity. +- Improved flow graph in multi-system configurations: the receiver does not get stalled anymore if no signal is found from the first system. +- Improved acquisition and tracking sensitivity. +- Added mechanisms for Assisted GNSS, thus shortening the Time-To-First-Fix. Provision of data via XML files or via SUPL v1.0. Documented at https://gnss-sdr.org/docs/sp-blocks/global-parameters/ +- Other minor bug fixes. ### Improvements in Efficiency: -- Added the possibility of non-blocking acquisition, which works well when using real-time data from a RF front-end. -- Complex codes have been replaced by real codes, alleviating the computational burden. -- New kernels: volk_gnsssdr_16i_xn_resampler_16i_xn.h, volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn.h, volk_gnsssdr_32f_xn_resampler_32f_xn.h, volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h -- Some AVX2 kernels added to the volk_gnsssdr library. -- Several performance improvements. +- Added the possibility of non-blocking acquisition, which works well when using real-time data from an RF front-end. +- Improved flow graph in multi-band configurations: satellites acquired in one band are immediately searched in others. +- Complex local codes have been replaced by real codes, alleviating the computational burden. +- New volk_gnsssdr kernels: volk_gnsssdr_16i_xn_resampler_16i_xn.h, volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn.h, volk_gnsssdr_32f_xn_resampler_32f_xn.h, volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h +- Some AVX2 implementations added to the volk_gnsssdr library. +- Improvement in C++ usage: Use of const container calls when result is immediately converted to a const iterator. Using these members removes an implicit conversion from iterator to const_iterator. +- Output printers can be shut down, with some savings in memory and storage requirements. +- A number of code optimizations here and there. ### Improvements in Flexibility: -- A number of new parameters have been exposed in the configuration. -- Possibility to choose Pilot or Data tracking where available. -- Enabled extended coherent integration times. +- A number of new parameters have been exposed to the configuration system. +- Possibility to choose Pilot or Data component for tracking of GPS L5 and Galileo E5a signals. +- Enabled extended coherent integration times for signal tracking. +- Configurable coherent and/or non-coherent signal acquisition. - Some configuration parameters can now be overridden by commandline flags for easier use in scripts. @@ -37,78 +73,108 @@ Next release will have several improvements, addition of new features and bug fi - Added the GLONASS L1 SP receiver chain. - Added the GLONASS L2 SP receiver chain. - Improvements in the Galileo E5a and GPS L2C receiver chains. -- Added four more signal sources: "Fmcomms2_Signal_Source", "Plutosdr_Signal Source", "Spir_GSS6450_File_Signal_Source" and "Labsat_Signal_Source". +- Updated list of available GNSS satellites. +- Added five more signal sources: "Fmcomms2_Signal_Source" (requires gr-iio), "Plutosdr_Signal Source" (requires gr-iio), "Spir_GSS6450_File_Signal_Source", "Labsat_Signal_Source" and "Custom_UDP_Signal_Source" (requires libpcap). Documented in https://gnss-sdr.org/docs/sp-blocks/signal-source/ - Improved support for BladeRF, HackRF and RTL-SDR front-ends. - Added tools for the interaction with front-ends based on the AD9361 chipset. -- Intermediate results are now saved in .mat binary format, readable from Matlab/Octave and from Python via h5py. +- Intermediate results are now saved in MAT-file format (.mat), readable from Matlab/Octave and from Python via h5py. - Added the GPX output format. -- Fixed a bug in the format of NMEA sentences when latitude or longitude minutes were >10 -- Improvements in the RTCM server. -- Improvements in the generation of RINEX files. +- Improvements in the generation of KML files. +- Improvements in the NMEA output. The receiver can produce GPGGA, GPRMC, GPGSA, GPGSV, GAGSA and GAGSV sentences. +- Improvements in the RTCM server stability. +- Improvements in the correctness of generated RINEX files. +- The receiver can read and make use of Galileo almanac XML files published by the European GNSS Service Centre at https://www.gsc-europa.eu/system-status/almanac-data +- Own-defined XML schemas for navigation data published at https://github.com/gnss-sdr/gnss-sdr/tree/next/docs/xml-schemas +- Added program rinex2assist to convert RINEX navigation files into XML files usable for Assisted GNSS. Only available building from source. See https://github.com/gnss-sdr/gnss-sdr/tree/next/src/utils/rinex2assist ### Improvements in Maintainability: -- C-style casts have been replaced by C++ casts. C-style casts are difficult to search for. C++ casts provide compile time checking ability and express programmers' intent better, so they are safer and clearer. -- The override special identifier is now used when overriding a virtual function. This helps the compiler to check for type changes in the base class. -- Use of const container calls when result is immediately converted to a const iterator. Using these members removes an implicit conversion from iterator to const_iterator. -- Improved control over minimum required versions for core dependencies. -- Automated code formating with clang-format. -- Application of the coding style guide in several source files, improving readability. -- The software builds with C++11, C++14 and C++17 standards. -- Setup of a Continuous Integration system that checks building in a wide range of Linux distributions. +- Setup of a Continuous Integration system that checks building and runs QA code in a wide range of GNU/Linux distributions (Arch Linux, CentOS, Debian, Fedora, OpenSUSE, Ubuntu) and releases. See https://gitlab.com/gnss-sdr/gnss-sdr +- Creation of multi-system processing blocks, drastically reducing code duplication and maintainability time. +- Automated code formatting with clang-format. This tool is widely available and easy to integrate into many code editors, and it also can be used from the command line. It cuts time spent on adhering to the project's code formatting style. +- Improvement in C++ usage: C-style casts have been replaced by C++ casts. C-style casts are difficult to search for. C++ casts provide compile time checking ability and express programmers' intent better, so they are safer and clearer. +- Improvement in C++ usage: The override special identifier is now used when overriding a virtual function. This helps the compiler to check for type changes in the base class, making the detection of errors easier. +- Improvement in C++ usage: A number of unused includes have been removed. Order of includes set to: local (in-source) headers, then library headers, then system headers. This helps to detect missing includes. +- Improvement in C++ usage: Enhanced const correctness. Misuses of those variables are detected by the compiler. +- Improved code with clang-tidy and generation of a compile_commands.json file containing the exact compiler calls for all translation units of the project in machine-readable form if clang-tidy is detected. +- Applied some style rules to CMake scripts. +- Minimal versions of dependencies identified and detected. ### Improvements in Portability: -- The library has been replaced by the more modern and portable . -- The library has been replaced by the more modern and portable for file handling. -- C++ libraries preferred over C libraries (e.g., instead of ). -- A number of unused includes have been removed. -- The software can now be built using GCC or LLVM/Clang compilers on GNU/Linux. +- Several CMake scripts improvements, more verbose outputs in case of errors. Building configuration has been documented in https://gnss-sdr.org/docs/tutorials/configuration-options-building-time/ +- Improved SDK for cross-compilation in embedded devices. Documented in https://gnss-sdr.org/docs/tutorials/cross-compiling/ +- Improved control over minimum required versions for core dependencies. +- The software builds with C++11, C++14 and C++17 standards. +- The software can now be built using GCC >= 4.7.2 or LLVM/Clang >= 3.4.0 compilers on GNU/Linux, and with Clang/AppleClang on MacOS. - The Ninja build system can be used in replacement of make. -- The volk_gnsssdr library can be built using Python 2.7 or Python 3.6. -- Several CMake scripts improvements. -- BLAS and LAPACK libraries are mandatory on ARM devices. +- The volk_gnsssdr library can be built using Python 2.7+ or Python 3.6+. +- The volk_gnsssdr library is now ready for AArch64 NEON instructions. +- Improved detection of required and optional dependencies in many GNU/Linux distributions and processor architectures. +- Improvement in C++ usage: The library has been replaced by the more modern and portable (except for the interaction with RTKLIB). +- Improvement in C++ usage: The library has been replaced by the more modern and portable for file handling. +- Improvement in C++ usage: C++ libraries preferred over C libraries (e.g., instead of , instead of ). +- Fix compatibility with Boost 1.67 (closes Debian bug #911882 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911882) +- Fixes required by Debian packaging. +- Fixes required by Macports packaging. +- A downside in portability: BLAS and LAPACK libraries are now required even in ARM devices. +- A downside in portability: the matio library >= 1.5.3 is a new required dependency. If not found, it is downloaded and built automatically at building time, but this requires libtool, automake and hdf5 already installed in the system. +- A downside in portability: the PugiXML library is a new required dependency. If not found, it is downloaded and built automatically at building time. ### Improvements in Reliability: -- Introduced 3 new Input Filter implementations for pulsed and narrowband interference mitigation: `Pulse_Blanking_Filter`, `Notch_Filter` and `Notch_Filter_Lite`. -- Enhanced const correctness. -- rand() function replaced by library. -- strlen and strncpy have been replaced by safer C++ counterparts. +- Introduced 3 new Input Filter implementations for pulsed and narrowband interference mitigation: `Pulse_Blanking_Filter`, `Notch_Filter` and `Notch_Filter_Lite`. Documented in https://gnss-sdr.org/docs/sp-blocks/input-filter/ +- Improved flow graph stability. +- Introduction of high-integrity C++ practices into the source code and included in the coding style guide. See https://gnss-sdr.org/coding-style/ - Fixed a number of defects detected by Coverity Scan. -- Some destructors have been fixed, avoiding a segmentation fault when exiting the program. -- Introduction of high-integrity C++ practices into the coding style guide. -- Website switched from http to https. Links in source code switched when available. +- Improvement of QA code and addition of a number of new tests. Documented at https://gnss-sdr.org/docs/tutorials/testing-software-receiver-2/ +- Improvement in C++ usage: rand() function replaced by library. +- Improvement in C++ usage: strlen and strncpy have been replaced by safer C++ counterparts. +- Improvement in C++ usage: Some destructors have been fixed, avoiding segmentation faults when exiting the program. +- Website switched from http to https. Links in the source tree switched when available. ### Improvements in Reproducibility: -- Setup of a Continuous Reproducibility system at GitLab for the automatic reproduction of experiments. The concept was introduced in https://ieeexplore.ieee.org/document/8331069/ +- Setup of a Continuous Reproducibility system at GitLab for the automatic reproduction of experiments. The concept was introduced in https://ieeexplore.ieee.org/document/8331069/ Example added in the src/utils/reproducibility/ieee-access18/ folder. - Fixes of Lintian warnings related to build reproducibility. ### Improvements in Scalability: -- Improvements in multi-system, multi-band receiver configurations. The receiver now accepts any number of channels in the three available bands. +- Improvements in multi-system, multi-band receiver configurations. The receiver now accepts any number of channels and systems in the three available bands. +- All possible combinations of signals and integration times are now accepted by the Observables block. ### Improvements in Testability: -- Several Unit Tests added. +- Several Unit Tests added. Documentation of testing concepts and available tests at https://gnss-sdr.org/docs/tutorials/testing-software-receiver/ +- New extra unit test AcquisitionPerformanceTest checks the performance of Acquisition blocks. +- New extra unit test TrackingPullInTest checks acquisition to tracking transition. +- New extra unit test HybridObservablesTest checks the generation of observables. +- Improved system testing: position_test accepts a wide list of parameters and can be used with external files. - Receiver channels can now be fixed to a given satellite. +- Testing integrated in a Continuous Reproducibility system (see above). - Improved CTest support in volk_gnsssdr. ### Improvements in Usability: -- All Observables block implementations have been collapsed in a universal implementation for all kinds of GNSS signals, making it easier to configure. -- All PVT block implementations have been collapsed in a universal implementation for all kinds of GNSS signals, making it easier to configure. -- Misleading parameter name GNSS-SDR.internal_fs_hz has been replaced by GNSS-SDR.internal_fs_sps. The old parameter name is still read. If found, a warning is provided to the user. -- Updated and improved documentation. +- All Observables block implementations have been merged into a single implementation for all kinds of GNSS signals, making it easier to configure. +- All PVT block implementations have been merged into a single implementation for all kinds of GNSS signals, making it easier to configure. +- Misleading parameter name GNSS-SDR.internal_fs_hz has been replaced by GNSS-SDR.internal_fs_sps. The old parameter name is still read. If found, a warning is provided to the user. The old name will be removed in future releases. +- Updated and improved online documentation of processing blocks at https://gnss-sdr.org/docs/sp-blocks/ +- Improved documentation of required dependency packages in several GNU/Linux distributions. +- Dump and output files can now be stored anywhere. +- Parameter names with the same role have been harmonized within different block implementations. +- Added a changelog, a code of conduct, a contributing guide and a pull-request template in the source tree. - Added colors to the commandline user interface. +- Updated manfiles. +- Updated examples of configuration files under the conf/ folder. + See the definitions of concepts and metrics at https://gnss-sdr.org/design-forces/ @@ -116,7 +182,6 @@ See the definitions of concepts and metrics at https://gnss-sdr.org/design-force - ## [0.0.9](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.9) DOI: https://doi.org/10.5281/zenodo.291371 diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index 9d0978e3f..28b3c9d2a 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -21,7 +21,7 @@ # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. +# https://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 @@ -551,7 +551,7 @@ LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -623,7 +623,7 @@ INPUT = @top_srcdir@/src @top_srcdir@/docs/doxygen/other # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# into libc) for the transcoding. See https://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 @@ -796,7 +796,7 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# tagging system (see https://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO @@ -875,7 +875,7 @@ HTML_STYLESHEET = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images # according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. +# see https://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. @@ -925,8 +925,6 @@ HTML_DYNAMIC_SECTIONS = NO # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. GENERATE_DOCSET = NO @@ -1123,7 +1121,7 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the +# (see https://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you also need to install MathJax separately and @@ -1133,7 +1131,7 @@ USE_MATHJAX = @GNSSSDR_USE_MATHJAX@ # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# https://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1149,7 +1147,7 @@ MATHJAX_FORMAT = HTML-CSS # MathJax, but it is strongly recommended to install a local copy of MathJax # before deployment. -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = https://cdnjs.com/libraries/mathjax/ # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example @@ -1160,7 +1158,7 @@ MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: https://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1194,7 +1192,7 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1207,7 +1205,7 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and +# Xapian (see: https://xapian.org/). See the section "External Indexing and # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. @@ -1358,7 +1356,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. diff --git a/docs/doxygen/images/GeneralBlockDiagram.png b/docs/doxygen/images/GeneralBlockDiagram.png index fb5b95d76..51e433ec0 100644 Binary files a/docs/doxygen/images/GeneralBlockDiagram.png and b/docs/doxygen/images/GeneralBlockDiagram.png differ diff --git a/docs/manpage/gnss-sdr-manpage b/docs/manpage/gnss-sdr-manpage index 5ca98ccb7..90f7d1a8e 100644 --- a/docs/manpage/gnss-sdr-manpage +++ b/docs/manpage/gnss-sdr-manpage @@ -1,6 +1,6 @@ .\" Manpage for gnss\-sdr. .\" Contact carles.fernandez@cttc.es to correct errors or typos. -.TH gnss\-sdr 1 "24 Feb 2018" "0.0.9" "gnss\-sdr man page" +.TH gnss\-sdr 1 "12 Dec 2018" "0.0.10" "gnss\-sdr man page" .SH NAME \fBgnss\-sdr\fR \- GNSS Software Defined Receiver. .SH SYNOPSIS diff --git a/docs/xml-schemas/README.md b/docs/xml-schemas/README.md new file mode 100644 index 000000000..007d520c0 --- /dev/null +++ b/docs/xml-schemas/README.md @@ -0,0 +1,35 @@ +# XML Schemas for Assisted GNSS-SDR + +GNSS-SDR can read assistance data from [Extensible Markup Language (XML)](https://www.w3.org/XML/) files for faster [Time-To-First-Fix](https://gnss-sdr.org/design-forces/availability/#time-to-first-fix-ttff), and can store navigation data decoded from GNSS signals in the same format. This folder provides XML Schemas which describe those XML files structure. + +[XSD (XML Schema Definition)](https://www.w3.org/XML/Schema) is a World Wide Web Consortium (W3C) recommendation that specifies how to formally describe the elements in an XML document. + + +GPS L1 C/A +---------- + + - [ephemeris_map.xsd](./ephemeris_map.xsd) - GPS NAV message ephemeris parameters. + - [iono_model.xsd](./iono_model.xsd) - GPS NAV message ionospheric model parameters. + - [utc_model.xsd](./utc_model.xsd) - GPS NAV message UTC model parameters. + - [gps_almanac_map.xsd](./gps_almanac_map.xsd) - GPS NAV message almanac. + + +GPS L2C and L5 +-------------- + + - [cnav_ephemeris_map.xsd](./cnav_ephemeris_map.xsd) - GPS CNAV message ephemeris parameters. + + +Galileo +------- + + - [gal_ephemeris_map.xsd](./gal_ephemeris_map.xsd) - Galileo ephemeris parameters. + - [gal_iono_model.xsd](./gal_iono_model.xsd) - Galileo ionospheric model parameters. + - [gal_utc_model.xsd](./gal_utc_model.xsd) - Galileo UTC model parameters. + - [gal_almanac_map.xsd](./gal_almanac_map.xsd) - Galileo almanac. + +------- + +Please check https://gnss-sdr.org/docs/sp-blocks/global-parameters/ for more information about the usage of XML files in GNSS-SDR. + +You could find useful the utility program [rinex2assist](https://github.com/gnss-sdr/gnss-sdr/tree/next/src/utils/rinex2assist) for the generation of compatible XML files from recent, publicly available RINEX navigation data files. diff --git a/docs/xml-schemas/cnav_ephemeris_map.xsd b/docs/xml-schemas/cnav_ephemeris_map.xsd new file mode 100644 index 000000000..2ada62f13 --- /dev/null +++ b/docs/xml-schemas/cnav_ephemeris_map.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/ephemeris_map.xsd b/docs/xml-schemas/ephemeris_map.xsd new file mode 100644 index 000000000..4290bbed5 --- /dev/null +++ b/docs/xml-schemas/ephemeris_map.xsd @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/gal_almanac_map.xsd b/docs/xml-schemas/gal_almanac_map.xsd new file mode 100644 index 000000000..8512bfc64 --- /dev/null +++ b/docs/xml-schemas/gal_almanac_map.xsd @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/gal_ephemeris_map.xsd b/docs/xml-schemas/gal_ephemeris_map.xsd new file mode 100644 index 000000000..fe307412e --- /dev/null +++ b/docs/xml-schemas/gal_ephemeris_map.xsd @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/gal_iono_model.xsd b/docs/xml-schemas/gal_iono_model.xsd new file mode 100644 index 000000000..69b22aad4 --- /dev/null +++ b/docs/xml-schemas/gal_iono_model.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/gal_utc_model.xsd b/docs/xml-schemas/gal_utc_model.xsd new file mode 100644 index 000000000..3cc38107c --- /dev/null +++ b/docs/xml-schemas/gal_utc_model.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/gps_almanac_map.xsd b/docs/xml-schemas/gps_almanac_map.xsd new file mode 100644 index 000000000..86b9d2a2d --- /dev/null +++ b/docs/xml-schemas/gps_almanac_map.xsd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/iono_model.xsd b/docs/xml-schemas/iono_model.xsd new file mode 100644 index 000000000..26cda74bd --- /dev/null +++ b/docs/xml-schemas/iono_model.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xml-schemas/utc_model.xsd b/docs/xml-schemas/utc_model.xsd new file mode 100644 index 000000000..c02015ead --- /dev/null +++ b/docs/xml-schemas/utc_model.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84e918b73..83c519fd5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,5 +21,5 @@ add_subdirectory(core) add_subdirectory(main) if(ENABLE_UNIT_TESTING OR ENABLE_SYSTEM_TESTING) add_subdirectory(tests) -endif(ENABLE_UNIT_TESTING OR ENABLE_SYSTEM_TESTING) +endif() add_subdirectory(utils) diff --git a/src/algorithms/PVT/adapters/CMakeLists.txt b/src/algorithms/PVT/adapters/CMakeLists.txt index 73c996521..538a7ddcf 100644 --- a/src/algorithms/PVT/adapters/CMakeLists.txt +++ b/src/algorithms/PVT/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,28 +16,47 @@ # along with GNSS-SDR. If not, see . # + set(PVT_ADAPTER_SOURCES - rtklib_pvt.cc + rtklib_pvt.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${ARMADILLO_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} +set(PVT_ADAPTER_HEADERS + rtklib_pvt.h ) -file(GLOB PVT_ADAPTER_HEADERS "*.h") -list(SORT PVT_ADAPTER_HEADERS) -add_library(pvt_adapters ${PVT_ADAPTER_SOURCES} ${PVT_ADAPTER_HEADERS}) source_group(Headers FILES ${PVT_ADAPTER_HEADERS}) -target_link_libraries(pvt_adapters pvt_gr_blocks ${ARMADILLO_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}) + +add_library(pvt_adapters ${PVT_ADAPTER_SOURCES} ${PVT_ADAPTER_HEADERS}) + +target_link_libraries(pvt_adapters + PUBLIC + pvt_gr_blocks + core_system_parameters + PRIVATE + gnss_sdr_flags + pvt_libs +) + +target_include_directories(pvt_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(Boost_VERSION LESS 105800) + target_compile_definitions(pvt_adapters PRIVATE -DOLD_BOOST=1) +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(pvt_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET pvt_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 39a8ebd3f..7491968a1 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -32,111 +32,108 @@ #include "rtklib_pvt.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include -#include -#include -#include +#include "pvt_conf.h" #include +#if OLD_BOOST +#include +namespace bc = boost::math; +#else +#include +namespace bc = boost::integer; +#endif using google::LogMessage; -RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, - std::string role, + +Rtklib_Pvt::Rtklib_Pvt(ConfigurationInterface* configuration, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { + Pvt_Conf pvt_output_parameters = Pvt_Conf(); // dump parameters std::string default_dump_filename = "./pvt.dat"; std::string default_nmea_dump_filename = "./nmea_pvt.nmea"; std::string default_nmea_dump_devname = "/dev/tty1"; std::string default_rtcm_dump_devname = "/dev/pts/1"; DLOG(INFO) << "role " << role; - dump_ = configuration->property(role + ".dump", false); - dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); + pvt_output_parameters.dump = configuration->property(role + ".dump", false); + pvt_output_parameters.dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + pvt_output_parameters.dump_mat = configuration->property(role + ".dump_mat", true); // output rate - int output_rate_ms = configuration->property(role + ".output_rate_ms", 500); + pvt_output_parameters.output_rate_ms = configuration->property(role + ".output_rate_ms", 500); // display rate - int display_rate_ms = configuration->property(role + ".display_rate_ms", 500); + pvt_output_parameters.display_rate_ms = configuration->property(role + ".display_rate_ms", 500); // NMEA Printer settings - bool flag_nmea_tty_port = configuration->property(role + ".flag_nmea_tty_port", false); - std::string nmea_dump_filename = configuration->property(role + ".nmea_dump_filename", default_nmea_dump_filename); + pvt_output_parameters.flag_nmea_tty_port = configuration->property(role + ".flag_nmea_tty_port", false); + pvt_output_parameters.nmea_dump_filename = configuration->property(role + ".nmea_dump_filename", default_nmea_dump_filename); std::string nmea_dump_devname = configuration->property(role + ".nmea_dump_devname", default_nmea_dump_devname); // RINEX version - int rinex_version = configuration->property(role + ".rinex_version", 3); - if (FLAGS_RINEX_version.compare("3.01") == 0) + pvt_output_parameters.rinex_version = configuration->property(role + ".rinex_version", 3); + if (FLAGS_RINEX_version == "3.01") { - rinex_version = 3; + pvt_output_parameters.rinex_version = 3; } - else if (FLAGS_RINEX_version.compare("3.02") == 0) + else if (FLAGS_RINEX_version == "3.02") { - rinex_version = 3; + pvt_output_parameters.rinex_version = 3; } - else if (FLAGS_RINEX_version.compare("3") == 0) + else if (FLAGS_RINEX_version == "3") { - rinex_version = 3; + pvt_output_parameters.rinex_version = 3; } - else if (FLAGS_RINEX_version.compare("2.11") == 0) + else if (FLAGS_RINEX_version == "2.11") { - rinex_version = 2; + pvt_output_parameters.rinex_version = 2; } - else if (FLAGS_RINEX_version.compare("2.10") == 0) + else if (FLAGS_RINEX_version == "2.10") { - rinex_version = 2; + pvt_output_parameters.rinex_version = 2; } - else if (FLAGS_RINEX_version.compare("2") == 0) + else if (FLAGS_RINEX_version == "2") { - rinex_version = 2; + pvt_output_parameters.rinex_version = 2; } + pvt_output_parameters.rinexobs_rate_ms = bc::lcm(configuration->property(role + ".rinexobs_rate_ms", 1000), pvt_output_parameters.output_rate_ms); + pvt_output_parameters.rinexnav_rate_ms = bc::lcm(configuration->property(role + ".rinexnav_rate_ms", 6000), pvt_output_parameters.output_rate_ms); // RTCM Printer settings - bool flag_rtcm_tty_port = configuration->property(role + ".flag_rtcm_tty_port", false); - std::string rtcm_dump_devname = configuration->property(role + ".rtcm_dump_devname", default_rtcm_dump_devname); - bool flag_rtcm_server = configuration->property(role + ".flag_rtcm_server", false); - unsigned short rtcm_tcp_port = configuration->property(role + ".rtcm_tcp_port", 2101); - unsigned short rtcm_station_id = configuration->property(role + ".rtcm_station_id", 1234); + pvt_output_parameters.flag_rtcm_tty_port = configuration->property(role + ".flag_rtcm_tty_port", false); + pvt_output_parameters.rtcm_dump_devname = configuration->property(role + ".rtcm_dump_devname", default_rtcm_dump_devname); + pvt_output_parameters.flag_rtcm_server = configuration->property(role + ".flag_rtcm_server", false); + pvt_output_parameters.rtcm_tcp_port = configuration->property(role + ".rtcm_tcp_port", 2101); + pvt_output_parameters.rtcm_station_id = configuration->property(role + ".rtcm_station_id", 1234); // RTCM message rates: least common multiple with output_rate_ms - int rtcm_MT1019_rate_ms = boost::math::lcm(configuration->property(role + ".rtcm_MT1019_rate_ms", 5000), output_rate_ms); - int rtcm_MT1020_rate_ms = boost::math::lcm(configuration->property(role + ".rtcm_MT1020_rate_ms", 5000), output_rate_ms); - int rtcm_MT1045_rate_ms = boost::math::lcm(configuration->property(role + ".rtcm_MT1045_rate_ms", 5000), output_rate_ms); - int rtcm_MSM_rate_ms = boost::math::lcm(configuration->property(role + ".rtcm_MSM_rate_ms", 1000), output_rate_ms); - int rtcm_MT1077_rate_ms = boost::math::lcm(configuration->property(role + ".rtcm_MT1077_rate_ms", rtcm_MSM_rate_ms), output_rate_ms); - int rtcm_MT1087_rate_ms = boost::math::lcm(configuration->property(role + ".rtcm_MT1087_rate_ms", rtcm_MSM_rate_ms), output_rate_ms); - int rtcm_MT1097_rate_ms = boost::math::lcm(configuration->property(role + ".rtcm_MT1097_rate_ms", rtcm_MSM_rate_ms), output_rate_ms); - std::map rtcm_msg_rate_ms; - rtcm_msg_rate_ms[1019] = rtcm_MT1019_rate_ms; - rtcm_msg_rate_ms[1020] = rtcm_MT1020_rate_ms; - rtcm_msg_rate_ms[1045] = rtcm_MT1045_rate_ms; + int rtcm_MT1019_rate_ms = bc::lcm(configuration->property(role + ".rtcm_MT1019_rate_ms", 5000), pvt_output_parameters.output_rate_ms); + int rtcm_MT1020_rate_ms = bc::lcm(configuration->property(role + ".rtcm_MT1020_rate_ms", 5000), pvt_output_parameters.output_rate_ms); + int rtcm_MT1045_rate_ms = bc::lcm(configuration->property(role + ".rtcm_MT1045_rate_ms", 5000), pvt_output_parameters.output_rate_ms); + int rtcm_MSM_rate_ms = bc::lcm(configuration->property(role + ".rtcm_MSM_rate_ms", 1000), pvt_output_parameters.output_rate_ms); + int rtcm_MT1077_rate_ms = bc::lcm(configuration->property(role + ".rtcm_MT1077_rate_ms", rtcm_MSM_rate_ms), pvt_output_parameters.output_rate_ms); + int rtcm_MT1087_rate_ms = bc::lcm(configuration->property(role + ".rtcm_MT1087_rate_ms", rtcm_MSM_rate_ms), pvt_output_parameters.output_rate_ms); + int rtcm_MT1097_rate_ms = bc::lcm(configuration->property(role + ".rtcm_MT1097_rate_ms", rtcm_MSM_rate_ms), pvt_output_parameters.output_rate_ms); + //std::map rtcm_msg_rate_ms; + pvt_output_parameters.rtcm_msg_rate_ms[1019] = rtcm_MT1019_rate_ms; + pvt_output_parameters.rtcm_msg_rate_ms[1020] = rtcm_MT1020_rate_ms; + pvt_output_parameters.rtcm_msg_rate_ms[1045] = rtcm_MT1045_rate_ms; for (int k = 1071; k < 1078; k++) // All GPS MSM { - rtcm_msg_rate_ms[k] = rtcm_MT1077_rate_ms; + pvt_output_parameters.rtcm_msg_rate_ms[k] = rtcm_MT1077_rate_ms; } for (int k = 1081; k < 1088; k++) // All GLONASS MSM { - rtcm_msg_rate_ms[k] = rtcm_MT1087_rate_ms; + pvt_output_parameters.rtcm_msg_rate_ms[k] = rtcm_MT1087_rate_ms; } for (int k = 1091; k < 1098; k++) // All Galileo MSM { - rtcm_msg_rate_ms[k] = rtcm_MT1097_rate_ms; + pvt_output_parameters.rtcm_msg_rate_ms[k] = rtcm_MT1097_rate_ms; } - // getting names from the config file, if available - // default filename for assistance data - const std::string eph_default_xml_filename = "./gps_ephemeris.xml"; - const std::string utc_default_xml_filename = "./gps_utc_model.xml"; - const std::string iono_default_xml_filename = "./gps_iono.xml"; - const std::string ref_time_default_xml_filename = "./gps_ref_time.xml"; - const std::string ref_location_default_xml_filename = "./gps_ref_location.xml"; - eph_xml_filename_ = configuration->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename); - //std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model.xml", utc_default_xml_filename); - //std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename); - //std::string ref_time_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_time_xml", ref_time_default_xml_filename); - //std::string ref_location_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_location_xml", ref_location_default_xml_filename); // Infer the type of receiver /* @@ -170,6 +167,15 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, * 26 | GPS L1 C/A + GLONASS L1 C/A * 27 | Galileo E1B + GLONASS L1 C/A * 28 | GPS L2C + GLONASS L1 C/A + * + * + * Skipped previous values to avoid overlapping + * 50 | Beidou B1I + * 51 | Beidou B1I + GPS L1 C/A + * 52 | Beidou B1I + Galileo E1B + * 53 | Beidou B1I + GLONASS L1 C/A + * 54 | Beidou B1I + GPS L1 C/A + Galileo E1B + * 55 | Beidou B1I + GPS L1 C/A + GLONASS L1 C/A + Galileo E1B */ int gps_1C_count = configuration->property("Channels_1C.count", 0); int gps_2S_count = configuration->property("Channels_2S.count", 0); @@ -179,53 +185,176 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int gal_E5b_count = configuration->property("Channels_7X.count", 0); int glo_1G_count = configuration->property("Channels_1G.count", 0); int glo_2G_count = configuration->property("Channels_2G.count", 0); + int bds_B1_count = configuration->property("Channels_B1.count", 0); - unsigned int type_of_receiver = 0; + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 1; // L1 + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 2; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 3; // L5 + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 4; // E1 + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 5; // E5a + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 6; + } + if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 7; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 8; // L1+L5 + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 9; // L1+E1 + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 10; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 11; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 12; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 13; // L5+E5a + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 14; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 15; + } + //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) pvt_output_parameters.type_of_receiver = 16; + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 17; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 18; + } + //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) pvt_output_parameters.type_of_receiver = 19; + //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) pvt_output_parameters.type_of_receiver = 20; + if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 21; + } + //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count = 0)) pvt_output_parameters.type_of_receiver = 22; + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 23; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 24; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 25; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 26; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 27; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 28; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 29; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 30; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 31; + } - // *******************WARNING!!!!!!!*********** - // GPS L5 only configurable for single frequency, single system at the moment!!!!!! - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 1; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 2; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 3; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 4; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 5; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 6; + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 32; // L1+E1+L5+E5a + } + // BeiDou B1I Receiver + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 50; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 51; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 52; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 53; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 54; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 55; + } - if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 7; - //if( (gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) type_of_receiver = 8; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 9; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 10; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 11; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 12; - //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) type_of_receiver = 13; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 14; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 15; - //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) type_of_receiver = 16; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 17; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 18; - //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) type_of_receiver = 19; - //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) type_of_receiver = 20; - if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0)) type_of_receiver = 21; - //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count = 0)) type_of_receiver = 22; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0)) type_of_receiver = 23; - if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0)) type_of_receiver = 24; - if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count != 0)) type_of_receiver = 25; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0)) type_of_receiver = 26; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0)) type_of_receiver = 27; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0)) type_of_receiver = 28; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0)) type_of_receiver = 29; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0)) type_of_receiver = 30; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0)) type_of_receiver = 31; - //RTKLIB PVT solver options + // RTKLIB PVT solver options // Settings 1 int positioning_mode = -1; std::string default_pos_mode("Single"); - std::string positioning_mode_str = configuration->property(role + ".positioning_mode", default_pos_mode); /* (PMODE_XXX) see src/algorithms/libs/rtklib/rtklib.h */ - if (positioning_mode_str.compare("Single") == 0) positioning_mode = PMODE_SINGLE; - if (positioning_mode_str.compare("Static") == 0) positioning_mode = PMODE_STATIC; - if (positioning_mode_str.compare("Kinematic") == 0) positioning_mode = PMODE_KINEMA; - if (positioning_mode_str.compare("PPP_Static") == 0) positioning_mode = PMODE_PPP_STATIC; - if (positioning_mode_str.compare("PPP_Kinematic") == 0) positioning_mode = PMODE_PPP_KINEMA; + std::string positioning_mode_str = configuration->property(role + ".positioning_mode", default_pos_mode); // (PMODE_XXX) see src/algorithms/libs/rtklib/rtklib.h + if (positioning_mode_str == "Single") + { + positioning_mode = PMODE_SINGLE; + } + if (positioning_mode_str == "Static") + { + positioning_mode = PMODE_STATIC; + } + if (positioning_mode_str == "Kinematic") + { + positioning_mode = PMODE_KINEMA; + } + if (positioning_mode_str == "PPP_Static") + { + positioning_mode = PMODE_PPP_STATIC; + } + if (positioning_mode_str == "PPP_Kinematic") + { + positioning_mode = PMODE_PPP_KINEMA; + } if (positioning_mode == -1) { @@ -239,10 +368,22 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int num_bands = 0; - if ((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) num_bands = 1; - if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0))) num_bands = 2; - if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 2; - if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 3; + if ((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) + { + num_bands = 1; + } + if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0))) + { + num_bands = 2; + } + if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) + { + num_bands = 2; + } + if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) + { + num_bands = 3; + } int number_of_frequencies = configuration->property(role + ".num_bands", num_bands); /* (1:L1, 2:L1+L2, 3:L1+L2+L5) */ if ((number_of_frequencies < 1) || (number_of_frequencies > 3)) @@ -270,12 +411,30 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, std::string default_iono_model("OFF"); std::string iono_model_str = configuration->property(role + ".iono_model", default_iono_model); /* (IONOOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ int iono_model = -1; - if (iono_model_str.compare("OFF") == 0) iono_model = IONOOPT_OFF; - if (iono_model_str.compare("Broadcast") == 0) iono_model = IONOOPT_BRDC; - if (iono_model_str.compare("SBAS") == 0) iono_model = IONOOPT_SBAS; - if (iono_model_str.compare("Iono-Free-LC") == 0) iono_model = IONOOPT_IFLC; - if (iono_model_str.compare("Estimate_STEC") == 0) iono_model = IONOOPT_EST; - if (iono_model_str.compare("IONEX") == 0) iono_model = IONOOPT_TEC; + if (iono_model_str == "OFF") + { + iono_model = IONOOPT_OFF; + } + if (iono_model_str == "Broadcast") + { + iono_model = IONOOPT_BRDC; + } + if (iono_model_str == "SBAS") + { + iono_model = IONOOPT_SBAS; + } + if (iono_model_str == "Iono-Free-LC") + { + iono_model = IONOOPT_IFLC; + } + if (iono_model_str == "Estimate_STEC") + { + iono_model = IONOOPT_EST; + } + if (iono_model_str == "IONEX") + { + iono_model = IONOOPT_TEC; + } if (iono_model == -1) { //warn user and set the default @@ -289,11 +448,26 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, std::string default_trop_model("OFF"); int trop_model = -1; std::string trop_model_str = configuration->property(role + ".trop_model", default_trop_model); /* (TROPOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ - if (trop_model_str.compare("OFF") == 0) trop_model = TROPOPT_OFF; - if (trop_model_str.compare("Saastamoinen") == 0) trop_model = TROPOPT_SAAS; - if (trop_model_str.compare("SBAS") == 0) trop_model = TROPOPT_SBAS; - if (trop_model_str.compare("Estimate_ZTD") == 0) trop_model = TROPOPT_EST; - if (trop_model_str.compare("Estimate_ZTD_Grad") == 0) trop_model = TROPOPT_ESTG; + if (trop_model_str == "OFF") + { + trop_model = TROPOPT_OFF; + } + if (trop_model_str == "Saastamoinen") + { + trop_model = TROPOPT_SAAS; + } + if (trop_model_str == "SBAS") + { + trop_model = TROPOPT_SBAS; + } + if (trop_model_str == "Estimate_ZTD") + { + trop_model = TROPOPT_EST; + } + if (trop_model_str == "Estimate_ZTD_Grad") + { + trop_model = TROPOPT_ESTG; + } if (trop_model == -1) { //warn user and set the default @@ -323,9 +497,23 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int earth_tide = configuration->property(role + ".earth_tide", 0); int nsys = 0; - if ((gps_1C_count > 0) || (gps_2S_count > 0) || (gps_L5_count > 0)) nsys += SYS_GPS; - if ((gal_1B_count > 0) || (gal_E5a_count > 0) || (gal_E5b_count > 0)) nsys += SYS_GAL; - if ((glo_1G_count > 0) || (glo_2G_count > 0)) nsys += SYS_GLO; + if ((gps_1C_count > 0) || (gps_2S_count > 0) || (gps_L5_count > 0)) + { + nsys += SYS_GPS; + } + if ((gal_1B_count > 0) || (gal_E5a_count > 0) || (gal_E5b_count > 0)) + { + nsys += SYS_GAL; + } + if ((glo_1G_count > 0) || (glo_2G_count > 0)) + { + nsys += SYS_GLO; + } + if ((bds_B1_count > 0)) + { + nsys += SYS_BDS; + } + int navigation_system = configuration->property(role + ".navigation_system", nsys); /* (SYS_XXX) see src/algorithms/libs/rtklib/rtklib.h */ if ((navigation_system < 1) || (navigation_system > 255)) /* GPS: 1 SBAS: 2 GPS+SBAS: 3 Galileo: 8 Galileo+GPS: 9 GPS+SBAS+Galileo: 11 All: 255 */ { @@ -338,11 +526,26 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, std::string default_gps_ar("Continuous"); std::string integer_ambiguity_resolution_gps_str = configuration->property(role + ".AR_GPS", default_gps_ar); /* Integer Ambiguity Resolution mode for GPS (0:off,1:continuous,2:instantaneous,3:fix and hold,4:ppp-ar) */ int integer_ambiguity_resolution_gps = -1; - if (integer_ambiguity_resolution_gps_str.compare("OFF") == 0) integer_ambiguity_resolution_gps = ARMODE_OFF; - if (integer_ambiguity_resolution_gps_str.compare("Continuous") == 0) integer_ambiguity_resolution_gps = ARMODE_CONT; - if (integer_ambiguity_resolution_gps_str.compare("Instantaneous") == 0) integer_ambiguity_resolution_gps = ARMODE_INST; - if (integer_ambiguity_resolution_gps_str.compare("Fix-and-Hold") == 0) integer_ambiguity_resolution_gps = ARMODE_FIXHOLD; - if (integer_ambiguity_resolution_gps_str.compare("PPP-AR") == 0) integer_ambiguity_resolution_gps = ARMODE_PPPAR; + if (integer_ambiguity_resolution_gps_str == "OFF") + { + integer_ambiguity_resolution_gps = ARMODE_OFF; + } + if (integer_ambiguity_resolution_gps_str == "Continuous") + { + integer_ambiguity_resolution_gps = ARMODE_CONT; + } + if (integer_ambiguity_resolution_gps_str == "Instantaneous") + { + integer_ambiguity_resolution_gps = ARMODE_INST; + } + if (integer_ambiguity_resolution_gps_str == "Fix-and-Hold") + { + integer_ambiguity_resolution_gps = ARMODE_FIXHOLD; + } + if (integer_ambiguity_resolution_gps_str == "PPP-AR") + { + integer_ambiguity_resolution_gps = ARMODE_PPPAR; + } if (integer_ambiguity_resolution_gps == -1) { //warn user and set the default @@ -372,7 +575,7 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, double min_ratio_to_fix_ambiguity = configuration->property(role + ".min_ratio_to_fix_ambiguity", 3.0); /* Set the integer ambiguity validation threshold for ratio‐test, which uses the ratio of squared residuals of the best integer vector to the second‐best vector. */ - int min_lock_to_fix_ambiguity = configuration->property(role + ".min_lock_to_fix_ambiguity", 0); /* Set the minimum lock count to fix integer ambiguity. + int min_lock_to_fix_ambiguity = configuration->property(role + ".min_lock_to_fix_ambiguity", 0); /* Set the minimum lock count to fix integer ambiguity.FLAGS_RINEX_version. If the lock count is less than the value, the ambiguity is excluded from the fixed integer vector. */ double min_elevation_to_fix_ambiguity = configuration->property(role + ".min_elevation_to_fix_ambiguity", 0.0); /* Set the minimum elevation (deg) to fix integer ambiguity. @@ -471,60 +674,105 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, 0, /* initialize by restart */ 1, /* output single by dgps/float/fix/ppp outage */ {"", ""}, /* char rnxopt[2][256] rinex options {rover,base} */ - {sat_PCV, rec_PCV, phwindup, reject_GPS_IIA, raim_fde}, /* posopt[6] positioning options [0]: satellite and receiver antenna PCV model; [1]: interpolate antenna parameters; [2]: apply phase wind-up correction for PPP modes; [3]: exclude measurements of GPS Block IIA satellites satellite [4]: RAIM FDE (fault detection and exclusion) [5]: handle day-boundary clock jump */ + {sat_PCV, rec_PCV, phwindup, reject_GPS_IIA, raim_fde}, /* posopt[6] positioning options [0]: satellite and receiver antenna PCV model; [1]: interpolate antenna parameters; [2]: apply phase wind-up correction for PPP modes; [3]: exclude measurements of GPS Block IIA satellites satellite [4]: RAIM FDE (fault detection and exclusion) [5]: handle day-boundary clock jump */ 0, /* solution sync mode (0:off,1:on) */ - {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ - {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ + {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ + {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ 0, /* disable L2-AR */ {} /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ }; rtkinit(&rtk, &rtklib_configuration_options); + // Outputs + bool default_output_enabled = configuration->property(role + ".output_enabled", true); + pvt_output_parameters.output_enabled = default_output_enabled; + pvt_output_parameters.rinex_output_enabled = configuration->property(role + ".rinex_output_enabled", default_output_enabled); + pvt_output_parameters.gpx_output_enabled = configuration->property(role + ".gpx_output_enabled", default_output_enabled); + pvt_output_parameters.geojson_output_enabled = configuration->property(role + ".geojson_output_enabled", default_output_enabled); + pvt_output_parameters.kml_output_enabled = configuration->property(role + ".kml_output_enabled", default_output_enabled); + pvt_output_parameters.xml_output_enabled = configuration->property(role + ".xml_output_enabled", default_output_enabled); + pvt_output_parameters.nmea_output_file_enabled = configuration->property(role + ".nmea_output_file_enabled", default_output_enabled); + pvt_output_parameters.rtcm_output_file_enabled = configuration->property(role + ".rtcm_output_file_enabled", default_output_enabled); + + std::string default_output_path = configuration->property(role + ".output_path", std::string(".")); + pvt_output_parameters.output_path = default_output_path; + pvt_output_parameters.rinex_output_path = configuration->property(role + ".rinex_output_path", default_output_path); + pvt_output_parameters.gpx_output_path = configuration->property(role + ".gpx_output_path", default_output_path); + pvt_output_parameters.geojson_output_path = configuration->property(role + ".geojson_output_path", default_output_path); + pvt_output_parameters.kml_output_path = configuration->property(role + ".kml_output_path", default_output_path); + pvt_output_parameters.xml_output_path = configuration->property(role + ".xml_output_path", default_output_path); + pvt_output_parameters.nmea_output_file_path = configuration->property(role + ".nmea_output_file_path", default_output_path); + pvt_output_parameters.rtcm_output_file_path = configuration->property(role + ".rtcm_output_file_path", default_output_path); + + // Read PVT MONITOR Configuration + pvt_output_parameters.monitor_enabled = configuration->property(role + ".enable_monitor", false); + pvt_output_parameters.udp_addresses = configuration->property(role + ".monitor_client_addresses", std::string("127.0.0.1")); + pvt_output_parameters.udp_port = configuration->property(role + ".monitor_udp_port", 1234); + // make PVT object - pvt_ = rtklib_make_pvt_cc(in_streams_, dump_, dump_filename_, output_rate_ms, display_rate_ms, flag_nmea_tty_port, nmea_dump_filename, nmea_dump_devname, rinex_version, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_msg_rate_ms, rtcm_dump_devname, type_of_receiver, rtk); + pvt_ = rtklib_make_pvt_cc(in_streams_, pvt_output_parameters, rtk); DLOG(INFO) << "pvt(" << pvt_->unique_id() << ")"; -} - - -bool RtklibPvt::save_assistance_to_XML() -{ - LOG(INFO) << "SUPL: Try to save GPS ephemeris to XML file " << eph_xml_filename_; - std::map eph_map = pvt_->get_GPS_L1_ephemeris_map(); - - if (eph_map.size() > 0) + if (out_streams_ > 0) { - try - { - std::ofstream ofs(eph_xml_filename_.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map); - ofs.close(); - LOG(INFO) << "Saved GPS L1 Ephemeris map data"; - } - catch (const std::exception& e) - { - LOG(WARNING) << e.what(); - return false; - } - return true; // return variable (true == succeeded) - } - else - { - LOG(WARNING) << "Failed to save Ephemeris, map is empty"; - return false; + LOG(ERROR) << "The PVT block does not have an output stream"; } } -RtklibPvt::~RtklibPvt() +Rtklib_Pvt::~Rtklib_Pvt() { rtkfree(&rtk); - save_assistance_to_XML(); } -void RtklibPvt::connect(gr::top_block_sptr top_block) +bool Rtklib_Pvt::get_latest_PVT(double* longitude_deg, + double* latitude_deg, + double* height_m, + double* ground_speed_kmh, + double* course_over_ground_deg, + time_t* UTC_time) +{ + return pvt_->get_latest_PVT(longitude_deg, + latitude_deg, + height_m, + ground_speed_kmh, + course_over_ground_deg, + UTC_time); +} + + +void Rtklib_Pvt::clear_ephemeris() +{ + pvt_->clear_ephemeris(); +} + + +std::map Rtklib_Pvt::get_gps_ephemeris() const +{ + return pvt_->get_gps_ephemeris_map(); +} + + +std::map Rtklib_Pvt::get_galileo_ephemeris() const +{ + return pvt_->get_galileo_ephemeris_map(); +} + + +std::map Rtklib_Pvt::get_gps_almanac() const +{ + return pvt_->get_gps_almanac_map(); +} + + +std::map Rtklib_Pvt::get_galileo_almanac() const +{ + return pvt_->get_galileo_almanac_map(); +} + + +void Rtklib_Pvt::connect(gr::top_block_sptr top_block) { if (top_block) { /* top_block is not null */ @@ -534,7 +782,7 @@ void RtklibPvt::connect(gr::top_block_sptr top_block) } -void RtklibPvt::disconnect(gr::top_block_sptr top_block) +void Rtklib_Pvt::disconnect(gr::top_block_sptr top_block) { if (top_block) { /* top_block is not null */ @@ -543,13 +791,13 @@ void RtklibPvt::disconnect(gr::top_block_sptr top_block) } -gr::basic_block_sptr RtklibPvt::get_left_block() +gr::basic_block_sptr Rtklib_Pvt::get_left_block() { return pvt_; } -gr::basic_block_sptr RtklibPvt::get_right_block() +gr::basic_block_sptr Rtklib_Pvt::get_right_block() { - return pvt_; // this is a sink, nothing downstream + return nullptr; // this is a sink, nothing downstream } diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.h b/src/algorithms/PVT/adapters/rtklib_pvt.h index 936fd1632..ace356712 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.h +++ b/src/algorithms/PVT/adapters/rtklib_pvt.h @@ -32,37 +32,49 @@ #ifndef GNSS_SDR_RTKLIB_PVT_H_ #define GNSS_SDR_RTKLIB_PVT_H_ +#include "galileo_almanac.h" +#include "galileo_ephemeris.h" +#include "gps_almanac.h" +#include "gps_ephemeris.h" #include "pvt_interface.h" +#include "rtklib.h" #include "rtklib_pvt_cc.h" +#include #include class ConfigurationInterface; /*! - * \brief This class implements a PvtInterface for Galileo E1 + * \brief This class implements a PvtInterface for the RTKLIB PVT block */ -class RtklibPvt : public PvtInterface +class Rtklib_Pvt : public PvtInterface { public: - RtklibPvt(ConfigurationInterface* configuration, - std::string role, + Rtklib_Pvt(ConfigurationInterface* configuration, + const std::string& role, unsigned int in_streams, unsigned int out_streams); - virtual ~RtklibPvt(); + virtual ~Rtklib_Pvt(); inline std::string role() override { return role_; } - //! Returns "RTKLIB_Pvt" + //! Returns "RTKLIB_PVT" inline std::string implementation() override { return "RTKLIB_PVT"; } + void clear_ephemeris() override; + std::map get_gps_ephemeris() const override; + std::map get_galileo_ephemeris() const override; + std::map get_gps_almanac() const override; + std::map get_galileo_almanac() const override; + void connect(gr::top_block_sptr top_block) override; void disconnect(gr::top_block_sptr top_block) override; gr::basic_block_sptr get_left_block() override; @@ -79,16 +91,19 @@ public: return sizeof(gr_complex); } + bool get_latest_PVT(double* longitude_deg, + double* latitude_deg, + double* height_m, + double* ground_speed_kmh, + double* course_over_ground_deg, + time_t* UTC_time) override; + private: rtklib_pvt_cc_sptr pvt_; - rtk_t rtk; - bool dump_; - std::string dump_filename_; + rtk_t rtk{}; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - std::string eph_xml_filename_; - bool save_assistance_to_XML(); }; #endif diff --git a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt index 34013b2ad..d59bac863 100644 --- a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,25 +17,47 @@ # set(PVT_GR_BLOCKS_SOURCES - rtklib_pvt_cc.cc + rtklib_pvt_cc.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib - ${ARMADILLO_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} +set(PVT_GR_BLOCKS_HEADERS + rtklib_pvt_cc.h ) -file(GLOB PVT_GR_BLOCKS_HEADERS "*.h") -list(SORT PVT_GR_BLOCKS_HEADERS) -add_library(pvt_gr_blocks ${PVT_GR_BLOCKS_SOURCES} ${PVT_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${PVT_GR_BLOCKS_HEADERS}) -target_link_libraries(pvt_gr_blocks pvt_lib ${ARMADILLO_LIBRARIES}) + +add_library(pvt_gr_blocks ${PVT_GR_BLOCKS_SOURCES} ${PVT_GR_BLOCKS_HEADERS}) + +target_link_libraries(pvt_gr_blocks + PUBLIC + pvt_libs + core_system_parameters + Boost::date_time + Gnuradio::pmt + Gnuradio::runtime + PRIVATE + algorithms_libs + Gflags::gflags + Glog::glog + Boost::filesystem + Boost::system + Boost::serialization +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(pvt_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +if(Boost_VERSION LESS 105800) + target_compile_definitions(pvt_gr_blocks PRIVATE -DOLD_BOOST=1) +endif() + +set_property(TARGET pvt_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index 8bcc49a88..c41a1989d 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -29,68 +29,865 @@ */ #include "rtklib_pvt_cc.h" -#include -#include -#include +#include "display.h" +#include "galileo_almanac_helper.h" +#include "gnss_sdr_create_directory.h" +#include "pvt_conf.h" #include -#include +#include #include +#include +#include #include #include #include -#include "display.h" #include -#include -#include #include - +#include +#include +#include +#if OLD_BOOST +#include +namespace bc = boost::math; +#else +#include +namespace bc = boost::integer; +#endif using google::LogMessage; -rtklib_pvt_cc_sptr rtklib_make_pvt_cc(unsigned int nchannels, - bool dump, - std::string dump_filename, - int output_rate_ms, - int display_rate_ms, - bool flag_nmea_tty_port, - std::string nmea_dump_filename, - std::string nmea_dump_devname, - int rinex_version, - bool flag_rtcm_server, - bool flag_rtcm_tty_port, - unsigned short rtcm_tcp_port, - unsigned short rtcm_station_id, - std::map rtcm_msg_rate_ms, - std::string rtcm_dump_devname, - const unsigned int type_of_receiver, - rtk_t& rtk) +rtklib_pvt_cc_sptr rtklib_make_pvt_cc(uint32_t nchannels, + const Pvt_Conf& conf_, + const rtk_t& rtk) { return rtklib_pvt_cc_sptr(new rtklib_pvt_cc(nchannels, - dump, - dump_filename, - output_rate_ms, - display_rate_ms, - flag_nmea_tty_port, - nmea_dump_filename, - nmea_dump_devname, - rinex_version, - flag_rtcm_server, - flag_rtcm_tty_port, - rtcm_tcp_port, - rtcm_station_id, - rtcm_msg_rate_ms, - rtcm_dump_devname, - type_of_receiver, + conf_, rtk)); } -void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) +rtklib_pvt_cc::rtklib_pvt_cc(uint32_t nchannels, + const Pvt_Conf& conf_, + const rtk_t& rtk) : gr::sync_block("rtklib_pvt_cc", + gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)), + gr::io_signature::make(0, 0, 0)) +{ + d_output_rate_ms = conf_.output_rate_ms; + d_display_rate_ms = conf_.display_rate_ms; + d_dump = conf_.dump; + d_dump_mat = conf_.dump_mat and d_dump; + d_dump_filename = conf_.dump_filename; + std::string dump_ls_pvt_filename = conf_.dump_filename; + if (d_dump) + { + std::string dump_path; + // Get path + if (d_dump_filename.find_last_of('/') != std::string::npos) + { + std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); + dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); + d_dump_filename = dump_filename_; + } + else + { + dump_path = std::string("."); + } + if (d_dump_filename.empty()) + { + d_dump_filename = "pvt"; + } + // remove extension if any + if (d_dump_filename.substr(1).find_last_of('.') != std::string::npos) + { + d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); + } + dump_ls_pvt_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + dump_ls_pvt_filename.append(".dat"); + // create directory + if (!gnss_sdr_create_directory(dump_path)) + { + std::cerr << "GNSS-SDR cannot create dump file for the PVT block. Wrong permissions?" << std::endl; + d_dump = false; + } + } + + d_nchannels = nchannels; + + type_of_rx = conf_.type_of_receiver; + + // GPS Ephemeris data message port in + this->message_port_register_in(pmt::mp("telemetry")); + this->set_msg_handler(pmt::mp("telemetry"), boost::bind(&rtklib_pvt_cc::msg_handler_telemetry, this, _1)); + + // initialize kml_printer + std::string kml_dump_filename; + kml_dump_filename = d_dump_filename; + d_kml_output_enabled = conf_.kml_output_enabled; + if (d_kml_output_enabled) + { + d_kml_dump = std::make_shared(conf_.kml_output_path); + d_kml_dump->set_headers(kml_dump_filename); + } + else + { + d_kml_dump = nullptr; + } + + // initialize gpx_printer + std::string gpx_dump_filename; + gpx_dump_filename = d_dump_filename; + d_gpx_output_enabled = conf_.gpx_output_enabled; + if (d_gpx_output_enabled) + { + d_gpx_dump = std::make_shared(conf_.gpx_output_path); + d_gpx_dump->set_headers(gpx_dump_filename); + } + else + { + d_gpx_dump = nullptr; + } + + // initialize geojson_printer + std::string geojson_dump_filename; + geojson_dump_filename = d_dump_filename; + + d_geojson_output_enabled = conf_.geojson_output_enabled; + if (d_geojson_output_enabled) + { + d_geojson_printer = std::make_shared(conf_.geojson_output_path); + d_geojson_printer->set_headers(geojson_dump_filename); + } + else + { + d_geojson_printer = nullptr; + } + + // initialize nmea_printer + d_nmea_output_file_enabled = (conf_.nmea_output_file_enabled or conf_.flag_nmea_tty_port); + if (d_nmea_output_file_enabled) + { + d_nmea_printer = std::make_shared(conf_.nmea_dump_filename, conf_.nmea_output_file_enabled, conf_.flag_nmea_tty_port, conf_.nmea_dump_devname, conf_.nmea_output_file_path); + } + else + { + d_nmea_printer = nullptr; + } + + // initialize rtcm_printer + std::string rtcm_dump_filename; + rtcm_dump_filename = d_dump_filename; + if (conf_.flag_rtcm_server or conf_.flag_rtcm_tty_port or conf_.rtcm_output_file_enabled) + { + d_rtcm_printer = std::make_shared(rtcm_dump_filename, conf_.rtcm_output_file_enabled, conf_.flag_rtcm_server, conf_.flag_rtcm_tty_port, conf_.rtcm_tcp_port, conf_.rtcm_station_id, conf_.rtcm_dump_devname, true, conf_.rtcm_output_file_path); + std::map rtcm_msg_rate_ms = conf_.rtcm_msg_rate_ms; + if (rtcm_msg_rate_ms.find(1019) != rtcm_msg_rate_ms.end()) + { + d_rtcm_MT1019_rate_ms = rtcm_msg_rate_ms[1019]; + } + else + { + d_rtcm_MT1019_rate_ms = bc::lcm(5000, d_output_rate_ms); // default value if not set + } + if (rtcm_msg_rate_ms.find(1020) != rtcm_msg_rate_ms.end()) + { + d_rtcm_MT1020_rate_ms = rtcm_msg_rate_ms[1020]; + } + else + { + d_rtcm_MT1020_rate_ms = bc::lcm(5000, d_output_rate_ms); // default value if not set + } + if (rtcm_msg_rate_ms.find(1045) != rtcm_msg_rate_ms.end()) + { + d_rtcm_MT1045_rate_ms = rtcm_msg_rate_ms[1045]; + } + else + { + d_rtcm_MT1045_rate_ms = bc::lcm(5000, d_output_rate_ms); // default value if not set + } + if (rtcm_msg_rate_ms.find(1077) != rtcm_msg_rate_ms.end()) // whatever between 1071 and 1077 + { + d_rtcm_MT1077_rate_ms = rtcm_msg_rate_ms[1077]; + } + else + { + d_rtcm_MT1077_rate_ms = bc::lcm(1000, d_output_rate_ms); // default value if not set + } + if (rtcm_msg_rate_ms.find(1087) != rtcm_msg_rate_ms.end()) // whatever between 1081 and 1087 + { + d_rtcm_MT1087_rate_ms = rtcm_msg_rate_ms[1087]; + } + else + { + d_rtcm_MT1087_rate_ms = bc::lcm(1000, d_output_rate_ms); // default value if not set + } + if (rtcm_msg_rate_ms.find(1097) != rtcm_msg_rate_ms.end()) // whatever between 1091 and 1097 + { + d_rtcm_MT1097_rate_ms = rtcm_msg_rate_ms[1097]; + d_rtcm_MSM_rate_ms = rtcm_msg_rate_ms[1097]; + } + else + { + d_rtcm_MT1097_rate_ms = bc::lcm(1000, d_output_rate_ms); // default value if not set + d_rtcm_MSM_rate_ms = bc::lcm(1000, d_output_rate_ms); // default value if not set + } + b_rtcm_writing_started = false; + b_rtcm_enabled = true; + } + else + { + d_rtcm_MT1019_rate_ms = 0; + d_rtcm_MT1045_rate_ms = 0; + d_rtcm_MT1020_rate_ms = 0; + d_rtcm_MT1077_rate_ms = 0; + d_rtcm_MT1087_rate_ms = 0; + d_rtcm_MT1097_rate_ms = 0; + d_rtcm_MSM_rate_ms = 0; + b_rtcm_enabled = false; + b_rtcm_writing_started = false; + d_rtcm_printer = nullptr; + } + + // initialize RINEX printer + b_rinex_header_written = false; + b_rinex_header_updated = false; + b_rinex_output_enabled = conf_.rinex_output_enabled; + d_rinex_version = conf_.rinex_version; + if (b_rinex_output_enabled) + { + rp = std::make_shared(d_rinex_version, conf_.rinex_output_path); + } + else + { + rp = nullptr; + } + d_rinexobs_rate_ms = conf_.rinexobs_rate_ms; + d_rinexnav_rate_ms = conf_.rinexnav_rate_ms; + + // XML printer + d_xml_storage = conf_.xml_output_enabled; + if (d_xml_storage) + { + xml_base_path = conf_.xml_output_path; + boost::filesystem::path full_path(boost::filesystem::current_path()); + const boost::filesystem::path p(xml_base_path); + if (!boost::filesystem::exists(p)) + { + std::string new_folder; + for (auto& folder : boost::filesystem::path(xml_base_path)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + std::cout << "Could not create the " << new_folder << " folder." << std::endl; + xml_base_path = full_path.string(); + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + } + else + { + xml_base_path = p.string(); + } + if (xml_base_path != ".") + { + std::cout << "XML files will be stored at " << xml_base_path << std::endl; + } + + xml_base_path = xml_base_path + boost::filesystem::path::preferred_separator; + } + + d_rx_time = 0.0; + d_last_status_print_seg = 0; + + // PVT MONITOR + flag_monitor_pvt_enabled = conf_.monitor_enabled; + if (flag_monitor_pvt_enabled) + { + std::string address_string = conf_.udp_addresses; + std::vector udp_addr_vec = split_string(address_string, '_'); + std::sort(udp_addr_vec.begin(), udp_addr_vec.end()); + udp_addr_vec.erase(std::unique(udp_addr_vec.begin(), udp_addr_vec.end()), udp_addr_vec.end()); + + udp_sink_ptr = std::unique_ptr(new Monitor_Pvt_Udp_Sink(udp_addr_vec, conf_.udp_port)); + } + else + { + udp_sink_ptr = nullptr; + } + + // Create Sys V message queue + first_fix = true; + sysv_msg_key = 1101; + int msgflg = IPC_CREAT | 0666; + if ((sysv_msqid = msgget(sysv_msg_key, msgflg)) == -1) + { + std::cout << "GNSS-SDR can not create message queues!" << std::endl; + throw std::exception(); + } + + d_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat, rtk); + d_pvt_solver->set_averaging_depth(1); + start = std::chrono::system_clock::now(); +} + + +rtklib_pvt_cc::~rtklib_pvt_cc() +{ + msgctl(sysv_msqid, IPC_RMID, nullptr); + try + { + if (d_xml_storage) + { + // save GPS L2CM ephemeris to XML file + std::string file_name = xml_base_path + "gps_cnav_ephemeris.xml"; + if (d_pvt_solver->gps_cnav_ephemeris_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", d_pvt_solver->gps_cnav_ephemeris_map); + LOG(INFO) << "Saved GPS L2CM or L5 Ephemeris map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS L2CM or L5 Ephemeris, map is empty"; + } + + // save GPS L1 CA ephemeris to XML file + file_name = xml_base_path + "gps_ephemeris.xml"; + if (d_pvt_solver->gps_ephemeris_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_pvt_solver->gps_ephemeris_map); + LOG(INFO) << "Saved GPS L1 CA Ephemeris map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS L1 CA Ephemeris, map is empty"; + } + + // save Galileo E1 ephemeris to XML file + file_name = xml_base_path + "gal_ephemeris.xml"; + if (d_pvt_solver->galileo_ephemeris_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", d_pvt_solver->galileo_ephemeris_map); + LOG(INFO) << "Saved Galileo E1 Ephemeris map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save Galileo E1 Ephemeris, map is empty"; + } + + // save GLONASS GNAV ephemeris to XML file + file_name = xml_base_path + "eph_GLONASS_GNAV.xml"; + if (d_pvt_solver->glonass_gnav_ephemeris_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); + LOG(INFO) << "Saved GLONASS GNAV Ephemeris map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GLONASS GNAV Ephemeris, map is empty"; + } + + // Save GPS UTC model parameters + file_name = xml_base_path + "gps_utc_model.xml"; + if (d_pvt_solver->gps_utc_model.valid) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", d_pvt_solver->gps_utc_model); + LOG(INFO) << "Saved GPS UTC model parameters"; + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS UTC model parameters, not valid data"; + } + + // Save Galileo UTC model parameters + file_name = xml_base_path + "gal_utc_model.xml"; + if (d_pvt_solver->galileo_utc_model.Delta_tLS_6 != 0.0) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", d_pvt_solver->galileo_utc_model); + LOG(INFO) << "Saved Galileo UTC model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save Galileo UTC model parameters, not valid data"; + } + + // Save GPS iono parameters + file_name = xml_base_path + "gps_iono.xml"; + if (d_pvt_solver->gps_iono.valid == true) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", d_pvt_solver->gps_iono); + LOG(INFO) << "Saved GPS ionospheric model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS ionospheric model parameters, not valid data"; + } + + // Save GPS CNAV iono parameters + file_name = xml_base_path + "gps_cnav_iono.xml"; + if (d_pvt_solver->gps_cnav_iono.valid == true) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_iono_model", d_pvt_solver->gps_cnav_iono); + LOG(INFO) << "Saved GPS CNAV ionospheric model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS CNAV ionospheric model parameters, not valid data"; + } + + // Save Galileo iono parameters + file_name = xml_base_path + "gal_iono.xml"; + if (d_pvt_solver->galileo_iono.ai0_5 != 0.0) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", d_pvt_solver->galileo_iono); + LOG(INFO) << "Saved Galileo ionospheric model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save Galileo ionospheric model parameters, not valid data"; + } + + // save GPS almanac to XML file + file_name = xml_base_path + "gps_almanac.xml"; + if (d_pvt_solver->gps_almanac_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", d_pvt_solver->gps_almanac_map); + LOG(INFO) << "Saved GPS almanac map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS almanac, map is empty"; + } + + // Save Galileo almanac + file_name = xml_base_path + "gal_almanac.xml"; + if (d_pvt_solver->galileo_almanac_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", d_pvt_solver->galileo_almanac_map); + LOG(INFO) << "Saved Galileo almanac data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save Galileo almanac, not valid data"; + } + + // Save GPS CNAV UTC model parameters + file_name = xml_base_path + "gps_cnav_utc_model.xml"; + if (d_pvt_solver->gps_cnav_utc_model.valid) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_utc_model", d_pvt_solver->gps_cnav_utc_model); + LOG(INFO) << "Saved GPS CNAV UTC model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS CNAV UTC model parameters, not valid data"; + } + + // save GLONASS GNAV ephemeris to XML file + file_name = xml_base_path + "glo_gnav_ephemeris.xml"; + if (d_pvt_solver->glonass_gnav_ephemeris_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); + LOG(INFO) << "Saved GLONASS GNAV ephemeris map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GLONASS GNAV ephemeris, map is empty"; + } + + // save GLONASS UTC model parameters to XML file + file_name = xml_base_path + "glo_utc_model.xml"; + if (d_pvt_solver->glonass_gnav_utc_model.valid) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gnav_utc_model", d_pvt_solver->glonass_gnav_utc_model); + LOG(INFO) << "Saved GLONASS UTC model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GLONASS GNAV ephemeris, not valid data"; + } + + // save BeiDou DNAV ephemeris to XML file + file_name = xml_base_path + "bds_dnav_ephemeris.xml"; + if (d_pvt_solver->beidou_dnav_ephemeris_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_ephemeris_map", d_pvt_solver->beidou_dnav_ephemeris_map); + LOG(INFO) << "Saved BeiDou DNAV Ephemeris map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save BeiDou DNAV Ephemeris, map is empty"; + } + + // Save BeiDou DNAV iono parameters + file_name = xml_base_path + "bds_dnav_iono.xml"; + if (d_pvt_solver->beidou_dnav_iono.valid) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_iono_model", d_pvt_solver->beidou_dnav_iono); + LOG(INFO) << "Saved BeiDou DNAV ionospheric model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save BeiDou DNAV ionospheric model parameters, not valid data"; + } + + // save BeiDou DNAV almanac to XML file + file_name = xml_base_path + "bds_dnav_almanac.xml"; + if (d_pvt_solver->beidou_dnav_almanac_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_almanac_map", d_pvt_solver->beidou_dnav_almanac_map); + LOG(INFO) << "Saved BeiDou DNAV almanac map data"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save BeiDou DNAV almanac, map is empty"; + } + + // Save BeiDou UTC model parameters + file_name = xml_base_path + "bds_dnav_utc_model.xml"; + if (d_pvt_solver->beidou_dnav_utc_model.valid) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_utc_model", d_pvt_solver->beidou_dnav_utc_model); + LOG(INFO) << "Saved BeiDou DNAV UTC model parameters"; + } + catch (const boost::archive::archive_exception& e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save BeiDou DNAV UTC model parameters, not valid data"; + } + } + } + catch (std::length_error& e) + { + LOG(WARNING) << e.what(); + } +} + + +void rtklib_pvt_cc::msg_handler_telemetry(const pmt::pmt_t& msg) { try { - //************* GPS telemetry ***************** + // ************* GPS telemetry ***************** if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { // ### GPS EPHEMERIS ### @@ -102,14 +899,14 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) << "inserted with Toe=" << gps_eph->d_Toe << " and GPS Week=" << gps_eph->i_GPS_week; // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->gps_ephemeris_map[gps_eph->i_satellite_PRN] = *gps_eph; + d_pvt_solver->gps_ephemeris_map[gps_eph->i_satellite_PRN] = *gps_eph; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { // ### GPS IONO ### std::shared_ptr gps_iono; gps_iono = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->gps_iono = *gps_iono; + d_pvt_solver->gps_iono = *gps_iono; DLOG(INFO) << "New IONO record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) @@ -117,7 +914,7 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) // ### GPS UTC MODEL ### std::shared_ptr gps_utc_model; gps_utc_model = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->gps_utc_model = *gps_utc_model; + d_pvt_solver->gps_utc_model = *gps_utc_model; DLOG(INFO) << "New UTC record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) @@ -126,7 +923,7 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) std::shared_ptr gps_cnav_ephemeris; gps_cnav_ephemeris = boost::any_cast>(pmt::any_ref(msg)); // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->gps_cnav_ephemeris_map[gps_cnav_ephemeris->i_satellite_PRN] = *gps_cnav_ephemeris; + d_pvt_solver->gps_cnav_ephemeris_map[gps_cnav_ephemeris->i_satellite_PRN] = *gps_cnav_ephemeris; DLOG(INFO) << "New GPS CNAV ephemeris record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) @@ -134,7 +931,7 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) // ### GPS CNAV IONO ### std::shared_ptr gps_cnav_iono; gps_cnav_iono = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->gps_cnav_iono = *gps_cnav_iono; + d_pvt_solver->gps_cnav_iono = *gps_cnav_iono; DLOG(INFO) << "New CNAV IONO record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) @@ -142,11 +939,20 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) // ### GPS CNAV UTC MODEL ### std::shared_ptr gps_cnav_utc_model; gps_cnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->gps_cnav_utc_model = *gps_cnav_utc_model; + d_pvt_solver->gps_cnav_utc_model = *gps_cnav_utc_model; DLOG(INFO) << "New CNAV UTC record has arrived "; } - //**************** Galileo telemetry ******************** + else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + { + // ### GPS ALMANAC ### + std::shared_ptr gps_almanac; + gps_almanac = boost::any_cast>(pmt::any_ref(msg)); + d_pvt_solver->gps_almanac_map[gps_almanac->i_satellite_PRN] = *gps_almanac; + DLOG(INFO) << "New GPS almanac record has arrived "; + } + + // **************** Galileo telemetry ******************** else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { // ### Galileo EPHEMERIS ### @@ -157,14 +963,14 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) << ", GALILEO Week Number =" << galileo_eph->WN_5 << " and Ephemeris IOD = " << galileo_eph->IOD_ephemeris; // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->galileo_ephemeris_map[galileo_eph->i_satellite_PRN] = *galileo_eph; + d_pvt_solver->galileo_ephemeris_map[galileo_eph->i_satellite_PRN] = *galileo_eph; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { // ### Galileo IONO ### std::shared_ptr galileo_iono; galileo_iono = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->galileo_iono = *galileo_iono; + d_pvt_solver->galileo_iono = *galileo_iono; DLOG(INFO) << "New IONO record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) @@ -172,20 +978,43 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) // ### Galileo UTC MODEL ### std::shared_ptr galileo_utc_model; galileo_utc_model = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->galileo_utc_model = *galileo_utc_model; + d_pvt_solver->galileo_utc_model = *galileo_utc_model; DLOG(INFO) << "New UTC record has arrived "; } + else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + { + // ### Galileo Almanac ### + std::shared_ptr galileo_almanac_helper; + galileo_almanac_helper = boost::any_cast>(pmt::any_ref(msg)); + + Galileo_Almanac sv1 = galileo_almanac_helper->get_almanac(1); + Galileo_Almanac sv2 = galileo_almanac_helper->get_almanac(2); + Galileo_Almanac sv3 = galileo_almanac_helper->get_almanac(3); + + if (sv1.i_satellite_PRN != 0) + { + d_pvt_solver->galileo_almanac_map[sv1.i_satellite_PRN] = sv1; + } + if (sv2.i_satellite_PRN != 0) + { + d_pvt_solver->galileo_almanac_map[sv2.i_satellite_PRN] = sv2; + } + if (sv3.i_satellite_PRN != 0) + { + d_pvt_solver->galileo_almanac_map[sv3.i_satellite_PRN] = sv3; + } + DLOG(INFO) << "New Galileo Almanac data have arrived "; + } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { // ### Galileo Almanac ### - std::shared_ptr galileo_almanac; - galileo_almanac = boost::any_cast>(pmt::any_ref(msg)); - // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->galileo_almanac = *galileo_almanac; - DLOG(INFO) << "New Galileo Almanac has arrived "; + std::shared_ptr galileo_alm; + galileo_alm = boost::any_cast>(pmt::any_ref(msg)); + // update/insert new almanac record to the global almanac map + d_pvt_solver->galileo_almanac_map[galileo_alm->i_satellite_PRN] = *galileo_alm; } - //**************** GLONASS GNAV Telemetry ************************** + // **************** GLONASS GNAV Telemetry ************************** else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { // ### GLONASS GNAV EPHEMERIS ### @@ -198,14 +1027,14 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) << " and Ephemeris IOD in UTC = " << glonass_gnav_eph->compute_GLONASS_time(glonass_gnav_eph->d_t_b) << " from SV = " << glonass_gnav_eph->i_satellite_slot_number; // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->glonass_gnav_ephemeris_map[glonass_gnav_eph->i_satellite_PRN] = *glonass_gnav_eph; + d_pvt_solver->glonass_gnav_ephemeris_map[glonass_gnav_eph->i_satellite_PRN] = *glonass_gnav_eph; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { // ### GLONASS GNAV UTC MODEL ### std::shared_ptr glonass_gnav_utc_model; glonass_gnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->glonass_gnav_utc_model = *glonass_gnav_utc_model; + d_pvt_solver->glonass_gnav_utc_model = *glonass_gnav_utc_model; DLOG(INFO) << "New GLONASS GNAV UTC record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) @@ -213,10 +1042,49 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) // ### GLONASS GNAV Almanac ### std::shared_ptr glonass_gnav_almanac; glonass_gnav_almanac = boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->glonass_gnav_almanac = *glonass_gnav_almanac; + d_pvt_solver->glonass_gnav_almanac = *glonass_gnav_almanac; DLOG(INFO) << "New GLONASS GNAV Almanac has arrived " << ", GLONASS GNAV Slot Number =" << glonass_gnav_almanac->d_n_A; } + + // ************* BeiDou telemetry ***************** + else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + { + // ### Beidou EPHEMERIS ### + std::shared_ptr bds_dnav_eph; + bds_dnav_eph = boost::any_cast>(pmt::any_ref(msg)); + DLOG(INFO) << "Ephemeris record has arrived from SAT ID " + << bds_dnav_eph->i_satellite_PRN << " (Block " + << bds_dnav_eph->satelliteBlock[bds_dnav_eph->i_satellite_PRN] << ")" + << "inserted with Toe=" << bds_dnav_eph->d_Toe << " and BDS Week=" + << bds_dnav_eph->i_BEIDOU_week; + // update/insert new ephemeris record to the global ephemeris map + d_pvt_solver->beidou_dnav_ephemeris_map[bds_dnav_eph->i_satellite_PRN] = *bds_dnav_eph; + } + else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + { + // ### BeiDou IONO ### + std::shared_ptr bds_dnav_iono; + bds_dnav_iono = boost::any_cast>(pmt::any_ref(msg)); + d_pvt_solver->beidou_dnav_iono = *bds_dnav_iono; + DLOG(INFO) << "New BeiDou DNAV IONO record has arrived "; + } + else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + { + // ### BeiDou UTC MODEL ### + std::shared_ptr bds_dnav_utc_model; + bds_dnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); + d_pvt_solver->beidou_dnav_utc_model = *bds_dnav_utc_model; + DLOG(INFO) << "New BeiDou DNAV UTC record has arrived "; + } + else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + { + // ### BeiDou ALMANAC ### + std::shared_ptr bds_dnav_almanac; + bds_dnav_almanac = boost::any_cast>(pmt::any_ref(msg)); + d_pvt_solver->beidou_dnav_almanac_map[bds_dnav_almanac->i_satellite_PRN] = *bds_dnav_almanac; + DLOG(INFO) << "New BeiDou DNAV almanac record has arrived "; + } else { LOG(WARNING) << "msg_handler_telemetry unknown object type!"; @@ -229,271 +1097,50 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) } -std::map rtklib_pvt_cc::get_GPS_L1_ephemeris_map() +std::map rtklib_pvt_cc::get_gps_ephemeris_map() const { - return d_ls_pvt->gps_ephemeris_map; + return d_pvt_solver->gps_ephemeris_map; } -rtklib_pvt_cc::rtklib_pvt_cc(unsigned int nchannels, bool dump, std::string dump_filename, - int output_rate_ms, int display_rate_ms, bool flag_nmea_tty_port, - std::string nmea_dump_filename, std::string nmea_dump_devname, int rinex_version, - bool flag_rtcm_server, bool flag_rtcm_tty_port, unsigned short rtcm_tcp_port, - unsigned short rtcm_station_id, std::map rtcm_msg_rate_ms, std::string rtcm_dump_devname, const unsigned int type_of_receiver, rtk_t& rtk) : gr::sync_block("rtklib_pvt_cc", - gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)), - gr::io_signature::make(0, 0, 0)) +std::map rtklib_pvt_cc::get_gps_almanac_map() const { - d_output_rate_ms = output_rate_ms; - d_display_rate_ms = display_rate_ms; - d_dump = dump; - d_nchannels = nchannels; - d_dump_filename = dump_filename; - std::string dump_ls_pvt_filename = dump_filename; - type_of_rx = type_of_receiver; - - // GPS Ephemeris data message port in - this->message_port_register_in(pmt::mp("telemetry")); - this->set_msg_handler(pmt::mp("telemetry"), boost::bind(&rtklib_pvt_cc::msg_handler_telemetry, this, _1)); - - //initialize kml_printer - std::string kml_dump_filename; - kml_dump_filename = d_dump_filename; - d_kml_dump = std::make_shared(); - d_kml_dump->set_headers(kml_dump_filename); - - //initialize gpx_printer - std::string gpx_dump_filename; - gpx_dump_filename = d_dump_filename; - d_gpx_dump = std::make_shared(); - d_gpx_dump->set_headers(gpx_dump_filename); - - //initialize geojson_printer - std::string geojson_dump_filename; - geojson_dump_filename = d_dump_filename; - d_geojson_printer = std::make_shared(); - d_geojson_printer->set_headers(geojson_dump_filename); - - //initialize nmea_printer - d_nmea_printer = std::make_shared(nmea_dump_filename, flag_nmea_tty_port, nmea_dump_devname); - - //initialize rtcm_printer - std::string rtcm_dump_filename; - rtcm_dump_filename = d_dump_filename; - d_rtcm_printer = std::make_shared(rtcm_dump_filename, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_dump_devname); - if (rtcm_msg_rate_ms.find(1019) != rtcm_msg_rate_ms.end()) - { - d_rtcm_MT1019_rate_ms = rtcm_msg_rate_ms[1019]; - } - else - { - d_rtcm_MT1019_rate_ms = boost::math::lcm(5000, d_output_rate_ms); // default value if not set - } - if (rtcm_msg_rate_ms.find(1020) != rtcm_msg_rate_ms.end()) - { - d_rtcm_MT1020_rate_ms = rtcm_msg_rate_ms[1020]; - } - else - { - d_rtcm_MT1020_rate_ms = boost::math::lcm(5000, d_output_rate_ms); // default value if not set - } - if (rtcm_msg_rate_ms.find(1045) != rtcm_msg_rate_ms.end()) - { - d_rtcm_MT1045_rate_ms = rtcm_msg_rate_ms[1045]; - } - else - { - d_rtcm_MT1045_rate_ms = boost::math::lcm(5000, d_output_rate_ms); // default value if not set - } - if (rtcm_msg_rate_ms.find(1077) != rtcm_msg_rate_ms.end()) // whatever between 1071 and 1077 - { - d_rtcm_MT1077_rate_ms = rtcm_msg_rate_ms[1077]; - } - else - { - d_rtcm_MT1077_rate_ms = boost::math::lcm(1000, d_output_rate_ms); // default value if not set - } - if (rtcm_msg_rate_ms.find(1087) != rtcm_msg_rate_ms.end()) // whatever between 1081 and 1087 - { - d_rtcm_MT1087_rate_ms = rtcm_msg_rate_ms[1087]; - } - else - { - d_rtcm_MT1087_rate_ms = boost::math::lcm(1000, d_output_rate_ms); // default value if not set - } - if (rtcm_msg_rate_ms.find(1097) != rtcm_msg_rate_ms.end()) // whatever between 1091 and 1097 - { - d_rtcm_MT1097_rate_ms = rtcm_msg_rate_ms[1097]; - d_rtcm_MSM_rate_ms = rtcm_msg_rate_ms[1097]; - } - else - { - d_rtcm_MT1097_rate_ms = boost::math::lcm(1000, d_output_rate_ms); // default value if not set - d_rtcm_MSM_rate_ms = boost::math::lcm(1000, d_output_rate_ms); // default value if not set - } - b_rtcm_writing_started = false; - - d_dump_filename.append("_raw.dat"); - dump_ls_pvt_filename.append("_ls_pvt.dat"); - - d_ls_pvt = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, d_dump, rtk); - d_ls_pvt->set_averaging_depth(1); - - d_rx_time = 0.0; - last_pvt_display_T_rx_s = 0.0; - last_RTCM_1019_output_time = 0.0; - last_RTCM_1020_output_time = 0.0; - last_RTCM_1045_output_time = 0.0; - last_RTCM_1077_output_time = 0.0; - last_RTCM_1087_output_time = 0.0; - last_RTCM_1097_output_time = 0.0; - last_RTCM_MSM_output_time = 0.0; - last_RINEX_obs_output_time = 0.0; - last_RINEX_nav_output_time = 0.0; - - b_rinex_header_written = false; - b_rinex_header_updated = false; - d_rinex_version = rinex_version; - rp = std::make_shared(d_rinex_version); - - d_last_status_print_seg = 0; - - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "PVT dump enabled Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure& e) - { - LOG(WARNING) << "Exception opening PVT dump file " << e.what(); - } - } - } - - // Create Sys V message queue - first_fix = true; - sysv_msg_key = 1101; - int msgflg = IPC_CREAT | 0666; - if ((sysv_msqid = msgget(sysv_msg_key, msgflg)) == -1) - { - std::cout << "GNSS-SDR can not create message queues!" << std::endl; - throw new std::exception(); - } - start = std::chrono::system_clock::now(); + return d_pvt_solver->gps_almanac_map; } -rtklib_pvt_cc::~rtklib_pvt_cc() +std::map rtklib_pvt_cc::get_galileo_ephemeris_map() const { - msgctl(sysv_msqid, IPC_RMID, NULL); + return d_pvt_solver->galileo_ephemeris_map; +} - //save GPS L2CM ephemeris to XML file - std::string file_name = "eph_GPS_CNAV.xml"; - if (d_ls_pvt->gps_cnav_ephemeris_map.size() > 0) - { - try - { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->gps_cnav_ephemeris_map); - ofs.close(); - LOG(INFO) << "Saved GPS L2CM or L5 Ephemeris map data"; - } - catch (std::exception& e) - { - LOG(WARNING) << e.what(); - } - } - else - { - LOG(WARNING) << "Failed to save GPS L2CM or L5 Ephemeris, map is empty"; - } +std::map rtklib_pvt_cc::get_galileo_almanac_map() const +{ + return d_pvt_solver->galileo_almanac_map; +} - //save GPS L1 CA ephemeris to XML file - file_name = "eph_GPS_L1CA.xml"; - if (d_ls_pvt->gps_ephemeris_map.size() > 0) - { - try - { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->gps_ephemeris_map); - ofs.close(); - LOG(INFO) << "Saved GPS L1 CA Ephemeris map data"; - } - catch (const std::exception& e) - { - LOG(WARNING) << e.what(); - } - } - else - { - LOG(WARNING) << "Failed to save GPS L1 CA Ephemeris, map is empty"; - } +std::map rtklib_pvt_cc::get_beidou_dnav_ephemeris_map() const +{ + return d_pvt_solver->beidou_dnav_ephemeris_map; +} - //save Galileo E1 ephemeris to XML file - file_name = "eph_Galileo_E1.xml"; - if (d_ls_pvt->galileo_ephemeris_map.size() > 0) - { - try - { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->galileo_ephemeris_map); - ofs.close(); - LOG(INFO) << "Saved Galileo E1 Ephemeris map data"; - } - catch (const std::exception& e) - { - LOG(WARNING) << e.what(); - } - } - else - { - LOG(WARNING) << "Failed to save Galileo E1 Ephemeris, map is empty"; - } +std::map rtklib_pvt_cc::get_beidou_dnav_almanac_map() const +{ + return d_pvt_solver->beidou_dnav_almanac_map; +} - //save GLONASS GNAV ephemeris to XML file - file_name = "eph_GLONASS_GNAV.xml"; - if (d_ls_pvt->glonass_gnav_ephemeris_map.size() > 0) - { - try - { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->glonass_gnav_ephemeris_map); - ofs.close(); - LOG(INFO) << "Saved GLONASS GNAV Ephemeris map data"; - } - catch (std::exception& e) - { - LOG(WARNING) << e.what(); - } - } - else - { - LOG(WARNING) << "Failed to save GLONASS GNAV Ephemeris, map is empty"; - } - if (d_dump_file.is_open() == true) - { - try - { - d_dump_file.close(); - } - catch (const std::exception& ex) - { - LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); - } - } +void rtklib_pvt_cc::clear_ephemeris() +{ + d_pvt_solver->gps_ephemeris_map.clear(); + d_pvt_solver->gps_almanac_map.clear(); + d_pvt_solver->galileo_ephemeris_map.clear(); + d_pvt_solver->galileo_almanac_map.clear(); + d_pvt_solver->beidou_dnav_ephemeris_map.clear(); + d_pvt_solver->beidou_dnav_almanac_map.clear(); } @@ -505,24 +1152,108 @@ bool rtklib_pvt_cc::observables_pairCompare_min(const std::pair> boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_observables_map); + //std::cout << "Loaded gnss_synchro map data with " << gnss_synchro_map.size() << " pseudoranges" << std::endl; + } + catch (const std::exception& e) + { + std::cout << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +std::vector rtklib_pvt_cc::split_string(const std::string& s, char delim) const +{ + std::vector v; + std::stringstream ss(s); + std::string item; + + while (std::getline(ss, item, delim)) + { + *(std::back_inserter(v)++) = item; + } + + return v; +} + + +bool rtklib_pvt_cc::get_latest_PVT(double* longitude_deg, + double* latitude_deg, + double* height_m, + double* ground_speed_kmh, + double* course_over_ground_deg, + time_t* UTC_time) const +{ + if (d_pvt_solver->is_valid_position()) + { + *latitude_deg = d_pvt_solver->get_latitude(); + *longitude_deg = d_pvt_solver->get_longitude(); + *height_m = d_pvt_solver->get_height(); + *ground_speed_kmh = d_pvt_solver->get_speed_over_ground() * 3600.0 / 1000.0; + *course_over_ground_deg = d_pvt_solver->get_course_over_ground(); + *UTC_time = convert_to_time_t(d_pvt_solver->get_position_UTC_time()); + + return true; + } + + return false; +} + + int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items __attribute__((unused))) { - for (int epoch = 0; epoch < noutput_items; epoch++) + for (int32_t epoch = 0; epoch < noutput_items; epoch++) { bool flag_display_pvt = false; bool flag_compute_pvt_output = false; @@ -532,149 +1263,179 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item bool flag_write_RTCM_MSM_output = false; bool flag_write_RINEX_obs_output = false; bool flag_write_RINEX_nav_output = false; - unsigned int gps_channel = 0; - unsigned int gal_channel = 0; - unsigned int glo_channel = 0; gnss_observables_map.clear(); - const Gnss_Synchro** in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - + const auto** in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer // ############ 1. READ PSEUDORANGES #### - for (unsigned int i = 0; i < d_nchannels; i++) + for (uint32_t i = 0; i < d_nchannels; i++) { if (in[i][epoch].Flag_valid_pseudorange) { - std::map::const_iterator tmp_eph_iter_gps = d_ls_pvt->gps_ephemeris_map.find(in[i][epoch].PRN); - std::map::const_iterator tmp_eph_iter_gal = d_ls_pvt->galileo_ephemeris_map.find(in[i][epoch].PRN); - std::map::const_iterator tmp_eph_iter_cnav = d_ls_pvt->gps_cnav_ephemeris_map.find(in[i][epoch].PRN); - std::map::const_iterator tmp_eph_iter_glo_gnav = d_ls_pvt->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN); - if (((tmp_eph_iter_gps->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal).compare("1C") == 0)) or ((tmp_eph_iter_cnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal).compare("2S") == 0)) or ((tmp_eph_iter_gal->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal).compare("1B") == 0)) or ((tmp_eph_iter_gal->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal).compare("5X") == 0)) or ((tmp_eph_iter_glo_gnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal).compare("1G") == 0)) or ((tmp_eph_iter_glo_gnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal).compare("2G") == 0)) or ((tmp_eph_iter_cnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal).compare("L5") == 0))) + std::map::const_iterator tmp_eph_iter_gps = d_pvt_solver->gps_ephemeris_map.find(in[i][epoch].PRN); + std::map::const_iterator tmp_eph_iter_gal = d_pvt_solver->galileo_ephemeris_map.find(in[i][epoch].PRN); + std::map::const_iterator tmp_eph_iter_cnav = d_pvt_solver->gps_cnav_ephemeris_map.find(in[i][epoch].PRN); + std::map::const_iterator tmp_eph_iter_glo_gnav = d_pvt_solver->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN); + std::map::const_iterator tmp_eph_iter_bds_dnav = d_pvt_solver->beidou_dnav_ephemeris_map.find(in[i][epoch].PRN); + + if (((tmp_eph_iter_gps->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "1C")) or + ((tmp_eph_iter_cnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "2S")) or + ((tmp_eph_iter_gal->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "1B")) or + ((tmp_eph_iter_gal->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "5X")) or + ((tmp_eph_iter_glo_gnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "1G")) or + ((tmp_eph_iter_glo_gnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "2G")) or + ((tmp_eph_iter_cnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "L5")) or + ((tmp_eph_iter_bds_dnav->second.i_satellite_PRN == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "B1"))) { // store valid observables in a map. gnss_observables_map.insert(std::pair(i, in[i][epoch])); } - try + if (b_rtcm_enabled) { - if (d_ls_pvt->gps_ephemeris_map.size() > 0) + try { - if (tmp_eph_iter_gps != d_ls_pvt->gps_ephemeris_map.end()) + if (d_pvt_solver->gps_ephemeris_map.empty() == false) { - d_rtcm_printer->lock_time(d_ls_pvt->gps_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + if (tmp_eph_iter_gps != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->lock_time(d_pvt_solver->gps_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } + } + if (d_pvt_solver->galileo_ephemeris_map.empty() == false) + { + if (tmp_eph_iter_gal != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->lock_time(d_pvt_solver->galileo_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } + } + if (d_pvt_solver->gps_cnav_ephemeris_map.empty() == false) + { + if (tmp_eph_iter_cnav != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + d_rtcm_printer->lock_time(d_pvt_solver->gps_cnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } + } + if (d_pvt_solver->glonass_gnav_ephemeris_map.empty() == false) + { + if (tmp_eph_iter_glo_gnav != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->lock_time(d_pvt_solver->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } } } - if (d_ls_pvt->galileo_ephemeris_map.size() > 0) + catch (const boost::exception& ex) { - if (tmp_eph_iter_gal != d_ls_pvt->galileo_ephemeris_map.end()) - { - d_rtcm_printer->lock_time(d_ls_pvt->galileo_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time - } + std::cout << "RTCM boost exception: " << boost::diagnostic_information(ex) << std::endl; + LOG(ERROR) << "RTCM boost exception: " << boost::diagnostic_information(ex); } - if (d_ls_pvt->gps_cnav_ephemeris_map.size() > 0) + catch (const std::exception& ex) { - if (tmp_eph_iter_cnav != d_ls_pvt->gps_cnav_ephemeris_map.end()) - { - d_rtcm_printer->lock_time(d_ls_pvt->gps_cnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time - } + std::cout << "RTCM std exception: " << ex.what() << std::endl; + LOG(ERROR) << "RTCM std exception: " << ex.what(); } - if (d_ls_pvt->glonass_gnav_ephemeris_map.size() > 0) - { - if (tmp_eph_iter_glo_gnav != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - d_rtcm_printer->lock_time(d_ls_pvt->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time - } - } - } - catch (const boost::exception& ex) - { - std::cout << "RTCM boost exception: " << boost::diagnostic_information(ex) << std::endl; - LOG(ERROR) << "RTCM boost exception: " << boost::diagnostic_information(ex); - } - catch (const std::exception& ex) - { - std::cout << "RTCM std exception: " << ex.what() << std::endl; - LOG(ERROR) << "RTCM std exception: " << ex.what(); } } } // ############ 2 COMPUTE THE PVT ################################ - if (gnss_observables_map.size() > 0) + if (gnss_observables_map.empty() == false) { double current_RX_time = gnss_observables_map.begin()->second.RX_time; - - if (std::fabs(current_RX_time - d_rx_time) * 1000.0 >= static_cast(d_output_rate_ms)) + auto current_RX_time_ms = static_cast(current_RX_time * 1000.0); + if (current_RX_time_ms % d_output_rate_ms == 0) { flag_compute_pvt_output = true; d_rx_time = current_RX_time; + // std::cout.precision(17); + // std::cout << "current_RX_time: " << current_RX_time << " map time: " << gnss_observables_map.begin()->second.RX_time << std::endl; } // compute on the fly PVT solution if (flag_compute_pvt_output == true) { - if (d_ls_pvt->get_PVT(gnss_observables_map, d_rx_time, false)) + // receiver clock correction is disabled to be coherent with the RINEX and RTCM standard + // std::cout << TEXT_RED << "(internal) accumulated RX clock offset: " << d_pvt_solver->get_time_offset_s() << "[s]" << TEXT_RESET << std::endl; + // for (std::map::iterator it = gnss_observables_map.begin(); it != gnss_observables_map.cend(); ++it) + // { + // todo: check if it has effect to correct the receiver time for the internal pvt solution + // take into account that the RINEX obs with the RX time (integer ms) CAN NOT be corrected to keep the coherence in obs time + // it->second.Pseudorange_m = it->second.Pseudorange_m - d_pvt_solver->get_time_offset_s() * GPS_C_m_s; + // } + + if (d_pvt_solver->get_PVT(gnss_observables_map, false)) { - if (std::fabs(current_RX_time - last_pvt_display_T_rx_s) * 1000.0 >= static_cast(d_display_rate_ms)) + //Optional debug code: export observables snapshot for rtklib unit testing + //std::cout << "step 1: save gnss_synchro map" << std::endl; + //save_gnss_synchro_map_xml("./gnss_synchro_map.xml"); + //getchar(); //stop the execution + //end debug + if (d_display_rate_ms != 0) { - flag_display_pvt = true; - last_pvt_display_T_rx_s = current_RX_time; + if (current_RX_time_ms % d_display_rate_ms == 0) + { + flag_display_pvt = true; + } } - if ((std::fabs(current_RX_time - last_RTCM_1019_output_time) * 1000.0 >= static_cast(d_rtcm_MT1019_rate_ms)) and (d_rtcm_MT1019_rate_ms != 0)) // allows deactivating messages by setting rate = 0 + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - flag_write_RTCM_1019_output = true; - last_RTCM_1019_output_time = current_RX_time; + if (current_RX_time_ms % d_rtcm_MT1019_rate_ms == 0) + { + flag_write_RTCM_1019_output = true; + } } - if ((std::fabs(current_RX_time - last_RTCM_1020_output_time) * 1000.0 >= static_cast(d_rtcm_MT1020_rate_ms)) and (d_rtcm_MT1020_rate_ms != 0)) // allows deactivating messages by setting rate = 0 + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - flag_write_RTCM_1020_output = true; - last_RTCM_1020_output_time = current_RX_time; + if (current_RX_time_ms % d_rtcm_MT1020_rate_ms == 0) + { + flag_write_RTCM_1020_output = true; + } } - if ((std::fabs(current_RX_time - last_RTCM_1045_output_time) * 1000.0 >= static_cast(d_rtcm_MT1045_rate_ms)) and (d_rtcm_MT1045_rate_ms != 0)) + if (d_rtcm_MT1045_rate_ms != 0) { - flag_write_RTCM_1045_output = true; - last_RTCM_1045_output_time = current_RX_time; + if (current_RX_time_ms % d_rtcm_MT1045_rate_ms == 0) + { + flag_write_RTCM_1045_output = true; + } + } + // TODO: RTCM 1077, 1087 and 1097 are not used, so, disable the output rates + // if (current_RX_time_ms % d_rtcm_MT1077_rate_ms==0 and d_rtcm_MT1077_rate_ms != 0) + // { + // last_RTCM_1077_output_time = current_RX_time; + // } + // if (current_RX_time_ms % d_rtcm_MT1087_rate_ms==0 and d_rtcm_MT1087_rate_ms != 0) + // { + // last_RTCM_1087_output_time = current_RX_time; + // } + // if (current_RX_time_ms % d_rtcm_MT1097_rate_ms==0 and d_rtcm_MT1097_rate_ms != 0) + // { + // last_RTCM_1097_output_time = current_RX_time; + // } + if (d_rtcm_MSM_rate_ms != 0) + { + if (current_RX_time_ms % d_rtcm_MSM_rate_ms == 0) + { + flag_write_RTCM_MSM_output = true; + } + } + if (d_rinexobs_rate_ms != 0) + { + if (current_RX_time_ms % static_cast(d_rinexobs_rate_ms) == 0) + { + flag_write_RINEX_obs_output = true; + } + } + if (d_rinexnav_rate_ms != 0) + { + if (current_RX_time_ms % static_cast(d_rinexnav_rate_ms) == 0) + { + flag_write_RINEX_nav_output = true; + } } - if ((std::fabs(current_RX_time - last_RTCM_1077_output_time) * 1000.0 >= static_cast(d_rtcm_MT1077_rate_ms)) and (d_rtcm_MT1077_rate_ms != 0)) - { - last_RTCM_1077_output_time = current_RX_time; - } - if ((std::fabs(current_RX_time - last_RTCM_1087_output_time) * 1000.0 >= static_cast(d_rtcm_MT1087_rate_ms)) and (d_rtcm_MT1087_rate_ms != 0)) - { - last_RTCM_1087_output_time = current_RX_time; - } - if ((std::fabs(current_RX_time - last_RTCM_1097_output_time) * 1000.0 >= static_cast(d_rtcm_MT1097_rate_ms)) and (d_rtcm_MT1097_rate_ms != 0)) - { - last_RTCM_1097_output_time = current_RX_time; - } - - if ((std::fabs(current_RX_time - last_RTCM_MSM_output_time) * 1000.0 >= static_cast(d_rtcm_MSM_rate_ms)) and (d_rtcm_MSM_rate_ms != 0)) - { - flag_write_RTCM_MSM_output = true; - last_RTCM_MSM_output_time = current_RX_time; - } - if ((std::fabs(current_RX_time - last_RINEX_obs_output_time) >= 1.0)) // TODO: Make it configurable - { - flag_write_RINEX_obs_output = true; - last_RINEX_obs_output_time = current_RX_time; - } - - if ((std::fabs(current_RX_time - last_RINEX_nav_output_time) >= 6.0)) // TODO: Make it configurable - { - flag_write_RINEX_nav_output = true; - last_RINEX_nav_output_time = current_RX_time; - } - - // correct the observable to account for the receiver clock offset - - for (std::map::iterator it = gnss_observables_map.begin(); it != gnss_observables_map.end(); ++it) - { - it->second.Pseudorange_m = it->second.Pseudorange_m - d_ls_pvt->get_time_offset_s() * GPS_C_m_s; - } if (first_fix == true) { - std::cout << "First position fix at " << boost::posix_time::to_simple_string(d_ls_pvt->get_position_UTC_time()) - << " UTC is Lat = " << d_ls_pvt->get_latitude() << " [deg], Long = " << d_ls_pvt->get_longitude() - << " [deg], Height= " << d_ls_pvt->get_height() << " [m]" << std::endl; + std::cout << "First position fix at " << boost::posix_time::to_simple_string(d_pvt_solver->get_position_UTC_time()) + << " UTC is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() + << " [deg], Height= " << d_pvt_solver->get_height() << " [m]" << std::endl; ttff_msgbuf ttff; ttff.mtype = 1; end = std::chrono::system_clock::now(); @@ -683,10 +1444,22 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item send_sys_v_ttff_msg(ttff); first_fix = false; } - d_kml_dump->print_position(d_ls_pvt, false); - d_gpx_dump->print_position(d_ls_pvt, false); - d_geojson_printer->print_position(d_ls_pvt, false); - d_nmea_printer->Print_Nmea_Line(d_ls_pvt, false); + if (d_kml_output_enabled) + { + d_kml_dump->print_position(d_pvt_solver, false); + } + if (d_gpx_output_enabled) + { + d_gpx_dump->print_position(d_pvt_solver, false); + } + if (d_geojson_output_enabled) + { + d_geojson_printer->print_position(d_pvt_solver, false); + } + if (d_nmea_output_file_enabled) + { + d_nmea_printer->Print_Nmea_Line(d_pvt_solver, false); + } /* * TYPE | RECEIVER @@ -722,571 +1495,692 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item * 29 | GPS L1 C/A + GLONASS L2 C/A * 30 | Galileo E1B + GLONASS L2 C/A * 31 | GPS L2C + GLONASS L2 C/A + * 32 | GPS L1 C/A + Galileo E1B + GPS L5 + Galileo E5a */ // ####################### RINEX FILES ################# - - std::map::const_iterator galileo_ephemeris_iter; - std::map::const_iterator gps_ephemeris_iter; - std::map::const_iterator gps_cnav_ephemeris_iter; - std::map::const_iterator glonass_gnav_ephemeris_iter; - std::map::const_iterator gnss_observables_iter; - - if (!b_rinex_header_written) // & we have utc data in nav message! + if (b_rinex_output_enabled) { - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); + std::map::const_iterator galileo_ephemeris_iter; + std::map::const_iterator gps_ephemeris_iter; + std::map::const_iterator gps_cnav_ephemeris_iter; + std::map::const_iterator glonass_gnav_ephemeris_iter; + std::map::const_iterator beidou_dnav_ephemeris_iter; + if (!b_rinex_header_written) // & we have utc data in nav message! + { + galileo_ephemeris_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + gps_ephemeris_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + gps_cnav_ephemeris_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + beidou_dnav_ephemeris_iter = d_pvt_solver->beidou_dnav_ephemeris_map.cbegin(); + switch (type_of_rx) + { + case 1: // GPS L1 C/A only + if (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, d_rx_time); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 2: // GPS L2C only + if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + std::string signal("2S"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 3: // GPS L5 only + if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + std::string signal("L5"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 4: // Galileo E1B only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 5: // Galileo E5a only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + std::string signal("5X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 6: // Galileo E5b only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + std::string signal("7X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 7: // GPS L1 C/A + GPS L2C + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + std::string signal("1C 2S"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 8: // GPS L1 + GPS L5 + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + std::string signal("1C L5"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 9: // GPS L1 C/A + Galileo E1B + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + std::string gal_signal("1B"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 10: // GPS L1 C/A + Galileo E5a + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + std::string gal_signal("5X"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 11: // GPS L1 C/A + Galileo E5b + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + std::string gal_signal("7X"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 13: // L5+E5a + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + std::string gal_signal("5X"); + std::string gps_signal("L5"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gps_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 14: // Galileo E1B + Galileo E5a + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + std::string gal_signal("1B 5X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 15: // Galileo E1B + Galileo E5b + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + std::string gal_signal("1B 7X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 23: // GLONASS L1 C/A only + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + std::string signal("1G"); + rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 24: // GLONASS L2 C/A only + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + std::string signal("2G"); + rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 25: // GLONASS L1 C/A + GLONASS L2 C/A + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + std::string signal("1G 2G"); + rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + std::string glo_signal("1G"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + if (d_rinex_version == 3) + { + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + } + if (d_rinex_version == 2) + { + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + } + b_rinex_header_written = true; // do not write header anymore + } + break; + case 27: // Galileo E1B + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + std::string glo_signal("1G"); + std::string gal_signal("1B"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 28: // GPS L2C + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + std::string glo_signal("1G"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + std::string glo_signal("2G"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + if (d_rinex_version == 3) + { + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + } + if (d_rinex_version == 2) + { + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + } + b_rinex_header_written = true; // do not write header anymore + } + break; + case 30: // Galileo E1B + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + std::string glo_signal("2G"); + std::string gal_signal("1B"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 31: // GPS L2C + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + std::string glo_signal("2G"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 32: // L1+E1+L5+E5a + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and + (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and + (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + std::string gal_signal("1B 5X"); + std::string gps_signal("1C L5"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gps_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 33: // L1+E1+E5a + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and + (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + std::string gal_signal("1B 5X"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 50: // BDS B1I only + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } - if (type_of_rx == 1) // GPS L1 C/A only - { - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, d_rx_time); - rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model); - b_rinex_header_written = true; // do not write header anymore + break; + default: + break; } } - if (type_of_rx == 2) // GPS L2C only + if (b_rinex_header_written) // The header is already written, we can now log the navigation message data { - if (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend()) + if (flag_write_RINEX_nav_output) { - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time); - rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model); - b_rinex_header_written = true; // do not write header anymore + switch (type_of_rx) + { + case 1: // GPS L1 C/A only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + break; + case 2: // GPS L2C only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); + break; + case 3: // GPS L5 only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); + break; + case 4: + case 5: + case 6: + rp->log_rinex_nav(rp->navGalFile, d_pvt_solver->galileo_ephemeris_map); + break; + case 7: // GPS L1 C/A + GPS L2C + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); + break; + case 8: // L1+L5 + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + break; + case 9: + case 10: + case 11: + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 13: // L5+E5a + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 14: + case 15: + rp->log_rinex_nav(rp->navGalFile, d_pvt_solver->galileo_ephemeris_map); + break; + case 23: + case 24: + case 25: + rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A + if (d_rinex_version == 3) + { + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + } + if (d_rinex_version == 2) + { + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); + } + break; + case 27: // Galileo E1B + GLONASS L1 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->galileo_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 28: // GPS L2C + GLONASS L1 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A + if (d_rinex_version == 3) + { + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + } + if (d_rinex_version == 2) + { + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); + } + break; + case 30: // Galileo E1B + GLONASS L2 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->galileo_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 31: // GPS L2C + GLONASS L2 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 32: // L1+E1+L5+E5a + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 33: // L1+E1+E5a + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 50: // BDS B1I only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->beidou_dnav_ephemeris_map); + break; + default: + break; + } } - } - if (type_of_rx == 3) // GPS L5 only - { - if (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time); - rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 4) // Galileo E1B only - { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time); - rp->rinex_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 5) // Galileo E5a only - { - std::string signal("5X"); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 6) // Galileo E5b only - { - std::string signal("7X"); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 7) // GPS L1 C/A + GPS L2C - { - if ((gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) - { - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time); - rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - } + galileo_ephemeris_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + gps_ephemeris_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + gps_cnav_ephemeris_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + beidou_dnav_ephemeris_iter = d_pvt_solver->beidou_dnav_ephemeris_map.cbegin(); - if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B - { - if ((galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend())) + // Log observables into the RINEX file + if (flag_write_RINEX_obs_output) { - std::string gal_signal("1B"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 10) // GPS L1 C/A + Galileo E5a - { - if ((galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend())) - { - std::string gal_signal("5X"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 11) // GPS L1 C/A + Galileo E5b - { - if ((galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend())) - { - std::string gal_signal("7X"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 14) // Galileo E1B + Galileo E5a - { - if ((galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend())) - { - std::string gal_signal("1B 5X"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 15) // Galileo E1B + Galileo E5b - { - if ((galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend())) - { - std::string gal_signal("1B 7X"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 23) // GLONASS L1 C/A only - { - std::string signal("1G"); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 24) // GLONASS L2 C/A only - { - std::string signal("2G"); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 25) // GLONASS L1 C/A + GLONASS L2 C/A - { - std::string signal("1G 2G"); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - b_rinex_header_written = true; // do not write header anymore - } - } - - if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend())) - { - std::string glo_signal("1G"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - if (d_rinex_version == 3) - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - if (d_rinex_version == 2) + switch (type_of_rx) { - rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model); - rp->rinex_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - } - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 27) // Galileo E1B + GLONASS L1 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend())) - { - std::string glo_signal("1G"); - std::string gal_signal("1B"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 28) // GPS L2C + GLONASS L1 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) - { - std::string glo_signal("1G"); - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) && (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend())) - { - std::string glo_signal("2G"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - if (d_rinex_version == 3) - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - if (d_rinex_version == 2) - { - rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model); - rp->rinex_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - } - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 30) // Galileo E1B + GLONASS L2 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend())) - { - std::string glo_signal("2G"); - std::string gal_signal("1B"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - if (type_of_rx == 31) // GPS L2C + GLONASS L2 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) - { - std::string glo_signal("2G"); - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - } - } - if (b_rinex_header_written) // The header is already written, we can now log the navigation message data - { - if (flag_write_RINEX_nav_output) - { - if (type_of_rx == 1) // GPS L1 C/A only - { - rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_ephemeris_map); - } - if (type_of_rx == 2) // GPS L2C only - { - rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_cnav_ephemeris_map); - } - if (type_of_rx == 3) // GPS L5 only - { - rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_cnav_ephemeris_map); - } - if ((type_of_rx == 4) or (type_of_rx == 5) or (type_of_rx == 6)) // Galileo - { - rp->log_rinex_nav(rp->navGalFile, d_ls_pvt->galileo_ephemeris_map); - } - if (type_of_rx == 7) // GPS L1 C/A + GPS L2C - { - rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_cnav_ephemeris_map); - } - if ((type_of_rx == 9) or (type_of_rx == 10) or (type_of_rx == 11)) // GPS L1 C/A + Galileo - { - rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_ephemeris_map, d_ls_pvt->galileo_ephemeris_map); - } - if ((type_of_rx == 14) or (type_of_rx == 15)) // Galileo E1B + Galileo E5a - { - rp->log_rinex_nav(rp->navGalFile, d_ls_pvt->galileo_ephemeris_map); - } - if ((type_of_rx == 23) or (type_of_rx == 24) or (type_of_rx == 25)) // GLONASS L1 C/A, GLONASS L2 C/A - { - rp->log_rinex_nav(rp->navGloFile, d_ls_pvt->glonass_gnav_ephemeris_map); - } - if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A - { - if (d_rinex_version == 3) - rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); - if (d_rinex_version == 2) - { - rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_ephemeris_map); - rp->log_rinex_nav(rp->navGloFile, d_ls_pvt->glonass_gnav_ephemeris_map); - } - } - if (type_of_rx == 27) // Galileo E1B + GLONASS L1 C/A - { - rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->galileo_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); - } - if (type_of_rx == 28) // GPS L2C + GLONASS L1 C/A - { - rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_cnav_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); - } - if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A - { - if (d_rinex_version == 3) - rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); - if (d_rinex_version == 2) - { - rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_ephemeris_map); - rp->log_rinex_nav(rp->navGloFile, d_ls_pvt->glonass_gnav_ephemeris_map); - } - } - if (type_of_rx == 30) // Galileo E1B + GLONASS L2 C/A - { - rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->galileo_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); - } - if (type_of_rx == 31) // GPS L2C + GLONASS L2 C/A - { - rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_cnav_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); - } - } - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); - - // Log observables into the RINEX file - if (flag_write_RINEX_obs_output) - { - if (type_of_rx == 1) // GPS L1 C/A only - { - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); - rp->update_nav_header(rp->navFile, d_ls_pvt->gps_utc_model, d_ls_pvt->gps_iono); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 2) // GPS L2C only - { - if (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_cnav_utc_model); - rp->update_nav_header(rp->navFile, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->gps_cnav_iono); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 3) // GPS L5 - { - if (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_cnav_utc_model); - rp->update_nav_header(rp->navFile, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->gps_cnav_iono); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 4) // Galileo E1B only - { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B"); - } - if (!b_rinex_header_updated and (d_ls_pvt->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 5) // Galileo E5a only - { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "5X"); - } - if (!b_rinex_header_updated and (d_ls_pvt->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 6) // Galileo E5b only - { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "7X"); - } - if (!b_rinex_header_updated and (d_ls_pvt->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 7) // GPS L1 C/A + GPS L2C - { - if ((gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end()) and (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); - rp->update_nav_header(rp->navFile, d_ls_pvt->gps_utc_model, d_ls_pvt->gps_iono); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B - { - if ((galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) and (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 14) // Galileo E1B + Galileo E5a - { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 5X"); - } - if (!b_rinex_header_updated and (d_ls_pvt->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 15) // Galileo E1B + Galileo E5b - { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 7X"); - } - if (!b_rinex_header_updated and (d_ls_pvt->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 23) // GLONASS L1 C/A only - { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C"); - } - if (!b_rinex_header_updated and (d_ls_pvt->glonass_gnav_utc_model.d_tau_c != 0)) - { - rp->update_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->glonass_gnav_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 24) // GLONASS L2 C/A only - { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "2C"); - } - if (!b_rinex_header_updated and (d_ls_pvt->glonass_gnav_utc_model.d_tau_c != 0)) - { - rp->update_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->glonass_gnav_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 25) // GLONASS L1 C/A + GLONASS L2 C/A - { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C 2C"); - } - if (!b_rinex_header_updated and (d_ls_pvt->glonass_gnav_utc_model.d_tau_c != 0)) - { - rp->update_nav_header(rp->navMixFile, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - rp->update_obs_header(rp->obsFile, d_ls_pvt->glonass_gnav_utc_model); - b_rinex_header_updated = true; - } - } - if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) and (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore - } - } - if (type_of_rx == 27) // Galileo E1B + GLONASS L1 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) and (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->galileo_utc_model.A0_6 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); - rp->update_nav_header(rp->navMixFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore - } - } - if (type_of_rx == 28) // GPS L2C + GLONASS L1 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) and (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_ls_pvt->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_cnav_utc_model); - rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore - } - } - if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) && (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated && (d_ls_pvt->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore - } - } - if (type_of_rx == 30) // Galileo E1B + GLONASS L2 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) && (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated && (d_ls_pvt->galileo_utc_model.A0_6 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); - rp->update_nav_header(rp->navMixFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore - } - } - if (type_of_rx == 31) // GPS L2C + GLONASS L2 C/A - { - if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.end())) - { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated && (d_ls_pvt->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_cnav_utc_model); - rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore + case 1: // GPS L1 C/A only + if (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); + b_rinex_header_updated = true; + } + break; + case 2: // GPS L2C only + if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); + b_rinex_header_updated = true; + } + break; + case 3: // GPS L5 + if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); + b_rinex_header_updated = true; + } + break; + case 4: // Galileo E1B only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 5: // Galileo E5a only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "5X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 6: // Galileo E5b only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "7X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 7: // GPS L1 C/A + GPS L2C + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); + b_rinex_header_updated = true; + } + break; + case 8: // L1+L5 + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and ((d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) or (d_pvt_solver->gps_utc_model.d_A0 != 0))) + { + if (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); + } + else + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); + } + b_rinex_header_updated = true; + } + break; + case 9: // GPS L1 C/A + Galileo E1B + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 13: // L5+E5a + if ((gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 14: // Galileo E1B + Galileo E5a + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 5X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 15: // Galileo E1B + Galileo E5b + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 7X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 23: // GLONASS L1 C/A only + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C"); + } + if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + { + rp->update_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); + b_rinex_header_updated = true; + } + break; + case 24: // GLONASS L2 C/A only + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "2C"); + } + if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + { + rp->update_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); + b_rinex_header_updated = true; + } + break; + case 25: // GLONASS L1 C/A + GLONASS L2 C/A + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C 2C"); + } + if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + { + rp->update_nav_header(rp->navMixFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); + b_rinex_header_updated = true; + } + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 27: // Galileo E1B + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 28: // GPS L2C + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 30: // Galileo E1B + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 31: // GPS L2C + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 32: // L1+E1+L5+E5a + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and ((d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) or (d_pvt_solver->gps_utc_model.d_A0 != 0)) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + if (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + } + else + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + } + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 33: // L1+E1+E5a + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 50: // BDS B1I only + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "B1"); + } + if (!b_rinex_header_updated and (d_pvt_solver->beidou_dnav_utc_model.d_A0_UTC != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->beidou_dnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_utc_model, d_pvt_solver->beidou_dnav_iono); + b_rinex_header_updated = true; + } + break; + default: + break; } } } @@ -1295,767 +2189,1057 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item // ####################### RTCM MESSAGES ################# try { - if (b_rtcm_writing_started) + if (b_rtcm_writing_started and b_rtcm_enabled) { - if (type_of_rx == 1) // GPS L1 C/A + switch (type_of_rx) { + case 1: // GPS L1 C/A if (flag_write_RTCM_1019_output == true) { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (flag_write_RTCM_MSM_output == true) { - std::map::const_iterator gps_ephemeris_iter; - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - } - if ((type_of_rx == 4) || (type_of_rx == 5) || (type_of_rx == 6) || (type_of_rx == 14) || (type_of_rx == 15)) // Galileo - { + break; + case 4: + case 5: + case 6: if (flag_write_RTCM_1045_output == true) { - for (std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); gal_ephemeris_iter++) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1045(gal_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); } } if (flag_write_RTCM_MSM_output == true) { - std::map::const_iterator gal_ephemeris_iter; - gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); - if (gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - } - if (type_of_rx == 7) // GPS L1 C/A + GPS L2C - { + break; + case 7: // GPS L1 C/A + GPS L2C if (flag_write_RTCM_1019_output == true) { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (flag_write_RTCM_MSM_output == true) { - std::map::const_iterator gps_ephemeris_iter; - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - std::map::const_iterator gps_cnav_ephemeris_iter; - gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); - if ((gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - } - if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B - { + break; + case 8: // L1+L5 if (flag_write_RTCM_1019_output == true) { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.begin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 9: // GPS L1 C/A + Galileo E1B + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (flag_write_RTCM_1045_output == true) { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end(); galileo_ephemeris_iter++) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); } } if (flag_write_RTCM_MSM_output == true) { - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; + std::map::const_iterator gnss_observables_iter; + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + int gps_channel = 0; + int gal_channel = 0; for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { - if (system.compare("G") == 0) + if (system == "G") { // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - gps_channel = i; + gps_channel = 1; } } } if (gal_channel == 0) { - if (system.compare("E") == 0) + if (system == "E") { - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - gal_channel = i; + gal_channel = 1; } } } - i++; } - if (flag_write_RTCM_MSM_output == true) + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - if (flag_write_RTCM_MSM_output == true) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - } - if ((type_of_rx == 23) || (type_of_rx == 24) || (type_of_rx == 25)) // GLONASS - { + break; + case 13: // L5+E5a + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + + if (flag_write_RTCM_MSM_output and d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + int gal_channel = 0; + int gps_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system == "G") + { + // This is a channel with valid GPS signal + gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (gal_channel == 0) + { + if (system == "E") + { + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + } + + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend() and (d_rtcm_MT1097_rate_ms != 0)) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend() and (d_rtcm_MT1077_rate_ms != 0)) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 14: + case 15: + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 23: + case 24: + case 25: if (flag_write_RTCM_1020_output == true) { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } - - std::map::const_iterator glo_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); - - if (glo_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + if (flag_write_RTCM_MSM_output == true) { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + auto glo_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + if (glo_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } } b_rtcm_writing_started = true; - } - if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A - { + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A if (flag_write_RTCM_1019_output == true) { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (flag_write_RTCM_1020_output == true) { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } if (flag_write_RTCM_MSM_output == true) { - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.begin(); gnss_observables_iter != gnss_observables_map.end(); gnss_observables_iter++) + std::map::const_iterator gnss_observables_iter; + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { - if (system.compare("G") == 0) + if (system == "G") { // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - gps_channel = i; + gps_channel = 1; } } } if (glo_channel == 0) { - if (system.compare("R") == 0) + if (system == "R") { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - glo_channel = i; + glo_channel = 1; } } } - i++; } - if (flag_write_RTCM_MSM_output == true) + + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - if (flag_write_RTCM_MSM_output == true) + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - } - if (type_of_rx == 27) // GLONASS L1 C/A + Galileo E1B - { + break; + case 27: // GLONASS L1 C/A + Galileo E1B if (flag_write_RTCM_1020_output == true) { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } if (flag_write_RTCM_1045_output == true) { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); } } if (flag_write_RTCM_MSM_output == true) { - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gal_channel = 0; + int glo_channel = 0; for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { - if (system.compare("E") == 0) + if (system == "E") { // This is a channel with valid GPS signal - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - gal_channel = i; + gal_channel = 1; } } } if (glo_channel == 0) { - if (system.compare("R") == 0) + if (system == "R") { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - glo_channel = i; + glo_channel = 1; } } } - i++; } - if (flag_write_RTCM_MSM_output == true) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - if (flag_write_RTCM_MSM_output == true) + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - } - if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A - { + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A if (flag_write_RTCM_1019_output == true) { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (flag_write_RTCM_1020_output == true) { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } if (flag_write_RTCM_MSM_output == true) { - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.begin(); gnss_observables_iter != gnss_observables_map.end(); gnss_observables_iter++) + std::map::const_iterator gnss_observables_iter; + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { - if (system.compare("G") == 0) + if (system == "G") { // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - gps_channel = i; + gps_channel = 1; } } } if (glo_channel == 0) { - if (system.compare("R") == 0) + if (system == "R") { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - glo_channel = i; + glo_channel = 1; } } } - i++; } - if (flag_write_RTCM_MSM_output == true) + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - if (flag_write_RTCM_MSM_output == true) + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - } - if (type_of_rx == 30) // GLONASS L2 C/A + Galileo E1B - { + break; + case 30: // GLONASS L2 C/A + Galileo E1B if (flag_write_RTCM_1020_output == true) { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } if (flag_write_RTCM_1045_output == true) { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); } } if (flag_write_RTCM_MSM_output == true) { - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gal_channel = 0; + int glo_channel = 0; for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { - if (system.compare("E") == 0) + if (system == "E") { // This is a channel with valid GPS signal - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - gal_channel = i; + gal_channel = 1; } } } if (glo_channel == 0) { - if (system.compare("R") == 0) + if (system == "R") { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - glo_channel = i; + glo_channel = 1; } } } - i++; } - if (flag_write_RTCM_MSM_output == true) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - if (flag_write_RTCM_MSM_output == true) + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } + break; + case 32: // L1+E1+L5+E5a + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gal_channel = 0; + int gps_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) + { + if (system == "E") + { + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (gps_channel == 0) + { + if (system == "G") + { + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + default: + break; } } - if (!b_rtcm_writing_started) // the first time + if (!b_rtcm_writing_started and b_rtcm_enabled) // the first time { - if (type_of_rx == 1) // GPS L1 C/A - { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); - } - - std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if ((type_of_rx == 4) || (type_of_rx == 5) || (type_of_rx == 6) || (type_of_rx == 14) || (type_of_rx == 15)) // Galileo - { - for (std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); gal_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_ephemeris_iter->second); - } - - std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); - - if (gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if (type_of_rx == 7) // GPS L1 C/A + GPS L2C - { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); - } - - std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - std::map::const_iterator gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); - - if ((gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B + switch (type_of_rx) { + case 1: // GPS L1 C/A if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 4: + case 5: + case 6: + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 7: // GPS L1 C/A + GPS L2C + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 8: // L1+L5 + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 9: // GPS L1 C/A + Galileo E1B + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (d_rtcm_MT1045_rate_ms != 0) { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end(); galileo_ephemeris_iter++) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); } } - - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + if (d_rtcm_MSM_rate_ms != 0) { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gps_channel = 0; + int gal_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { - if (system.compare("G") == 0) + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) { - // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end()) + if (system == "G") { - gps_channel = i; + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (gal_channel == 0) + { + if (system == "E") + { + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } } } } - if (gal_channel == 0) + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - if (system.compare("E") == 0) + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + + case 13: // L5+E5a + if (d_rtcm_MT1045_rate_ms != 0) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + int gal_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) { - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) + if (system == "E") { - gal_channel = i; + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } } } } - i++; - } - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end() && (d_rtcm_MT1077_rate_ms != 0)) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end() && (d_rtcm_MT1097_rate_ms != 0)) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend() and (d_rtcm_MT1097_rate_ms != 0)) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } } b_rtcm_writing_started = true; - } - if ((type_of_rx == 23) || (type_of_rx == 24) || (type_of_rx == 25)) // GLONASS - { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + break; + case 14: + case 15: + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } } - - std::map::const_iterator glo_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); - - if (glo_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + if (d_rtcm_MSM_rate_ms != 0) { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } } b_rtcm_writing_started = true; - } - if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A - { + break; + case 23: + case 24: + case 25: + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto glo_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + if (glo_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } - - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + if (d_rtcm_MSM_rate_ms != 0) { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) + std::map::const_iterator gnss_observables_iter; + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { - if (system.compare("G") == 0) + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) { - // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + if (system == "G") { - gps_channel = i; + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - if (glo_channel == 0) + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (system.compare("R") == 0) - { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = i; - } - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - i++; } - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if (type_of_rx == 27) // GLONASS L1 C/A + Galileo E1B - { + break; + case 27: // GLONASS L1 C/A + Galileo E1B if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); } } - - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + if (d_rtcm_MSM_rate_ms != 0) { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) + int gal_channel = 0; + int glo_channel = 0; + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { - if (system.compare("E") == 0) + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) { - // This is a channel with valid GPS signal - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + if (system == "E") { - gal_channel = i; + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - if (glo_channel == 0) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - if (system.compare("R") == 0) - { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - glo_channel = i; - } - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - i++; } - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - } - if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A - { + b_rtcm_writing_started = true; + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } - - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + if (d_rtcm_MSM_rate_ms != 0) { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + std::map::const_iterator gnss_observables_iter; + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { - if (system.compare("G") == 0) + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) { - // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + if (system == "G") { - gps_channel = i; + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - if (glo_channel == 0) + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (system.compare("R") == 0) - { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = i; - } - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } - i++; - } - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } } - b_rtcm_writing_started = true; - } - if (type_of_rx == 30) // GLONASS L2 C/A + Galileo E1B - { + break; + case 30: // GLONASS L2 C/A + Galileo E1B if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); } } if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); } } - - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + if (d_rtcm_MSM_rate_ms != 0) { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) + int gal_channel = 0; + int glo_channel = 0; + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { - if (system.compare("E") == 0) + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) { - // This is a channel with valid GPS signal - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + if (system == "E") { - gal_channel = i; + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - if (glo_channel == 0) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - if (system.compare("R") == 0) + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 32: // L1+E1+L5+E5a + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gps_channel = 0; + int gal_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + if (system == "G") { - glo_channel = i; + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (gal_channel == 0) + { + if (system == "E") + { + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } } } } - i++; - } - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } } + b_rtcm_writing_started = true; + break; + default: + break; } } } - catch (const boost::exception& ex) { std::cout << "RTCM boost exception: " << boost::diagnostic_information(ex) << std::endl; @@ -2070,41 +3254,44 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item } // DEBUG MESSAGE: Display position in console output - if (d_ls_pvt->is_valid_position() and flag_display_pvt) + if (d_pvt_solver->is_valid_position() and flag_display_pvt) { - std::cout << TEXT_BOLD_GREEN << "Position at " << boost::posix_time::to_simple_string(d_ls_pvt->get_position_UTC_time()) - << " UTC using " << d_ls_pvt->get_num_valid_observations() << " observations is Lat = " << d_ls_pvt->get_latitude() << " [deg], Long = " << d_ls_pvt->get_longitude() - << " [deg], Height= " << d_ls_pvt->get_height() << " [m]" << TEXT_RESET << std::endl; + std::streamsize ss = std::cout.precision(); // save current precision + std::cout.setf(std::ios::fixed, std::ios::floatfield); + auto facet = new boost::posix_time::time_facet("%Y-%b-%d %H:%M:%S.%f %z"); + std::cout.imbue(std::locale(std::cout.getloc(), facet)); - LOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_ls_pvt->get_position_UTC_time()) - << " UTC using " << d_ls_pvt->get_num_valid_observations() << " observations is Lat = " << d_ls_pvt->get_latitude() << " [deg], Long = " << d_ls_pvt->get_longitude() - << " [deg], Height= " << d_ls_pvt->get_height() << " [m]"; + std::cout << TEXT_BOLD_GREEN + << "Position at " << d_pvt_solver->get_position_UTC_time() + << " UTC using " << d_pvt_solver->get_num_valid_observations() + << std::fixed << std::setprecision(9) + << " observations is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() + << std::fixed << std::setprecision(3) + << " [deg], Height = " << d_pvt_solver->get_height() << " [m]" << TEXT_RESET << std::endl; + std::cout << std::setprecision(ss); + DLOG(INFO) << "RX clock offset: " << d_pvt_solver->get_time_offset_s() << "[s]"; - /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_ls_pvt->get_position_UTC_time()) - << " UTC using "<< d_ls_pvt->get_num_valid_observations()<<" observations is HDOP = " << d_ls_pvt->get_HDOP() << " VDOP = " - << d_ls_pvt->get_VDOP() <<" TDOP = " << d_ls_pvt->get_TDOP() - << " GDOP = " << d_ls_pvt->get_GDOP() << std::endl; */ + // boost::posix_time::ptime p_time; + // gtime_t rtklib_utc_time = gpst2time(adjgpsweek(d_pvt_solver->gps_ephemeris_map.cbegin()->second.i_GPS_week), d_rx_time); + // p_time = boost::posix_time::from_time_t(rtklib_utc_time.time); + // p_time += boost::posix_time::microseconds(round(rtklib_utc_time.sec * 1e6)); + // std::cout << TEXT_MAGENTA << "Observable RX time (GPST) " << boost::posix_time::to_simple_string(p_time) << TEXT_RESET << std::endl; + + DLOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_pvt_solver->get_position_UTC_time()) + << " UTC using " << d_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() + << " [deg], Height = " << d_pvt_solver->get_height() << " [m]"; + + /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_pvt_solver->get_position_UTC_time()) + << " UTC using "<< d_pvt_solver->get_num_valid_observations() <<" observations is HDOP = " << d_pvt_solver->get_hdop() << " VDOP = " + << d_pvt_solver->get_vdop() + << " GDOP = " << d_pvt_solver->get_gdop() << std::endl; */ } - // MULTIPLEXED FILE RECORDING - Record results to file - if (d_dump == true) + // PVT MONITOR + if (d_pvt_solver->is_valid_position() and flag_monitor_pvt_enabled) { - try - { - double tmp_double; - for (unsigned int i = 0; i < d_nchannels; i++) - { - tmp_double = in[i][epoch].Pseudorange_m; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = 0; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_rx_time), sizeof(double)); - } - } - catch (const std::ifstream::failure& e) - { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); - } + Monitor_Pvt monitor_pvt = d_pvt_solver->get_monitor_pvt(); + udp_sink_ptr->write_monitor_pvt(monitor_pvt); } } } diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h index b208f4c0c..dbe2fe3eb 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h @@ -31,93 +31,84 @@ #ifndef GNSS_SDR_RTKLIB_PVT_CC_H #define GNSS_SDR_RTKLIB_PVT_CC_H - -#include "nmea_printer.h" -#include "kml_printer.h" -#include "gpx_printer.h" +#include "beidou_dnav_almanac.h" +#include "beidou_dnav_ephemeris.h" +#include "galileo_almanac.h" +#include "galileo_ephemeris.h" #include "geojson_printer.h" +#include "gnss_synchro.h" +#include "gps_almanac.h" +#include "gps_ephemeris.h" +#include "gpx_printer.h" +#include "kml_printer.h" +#include "monitor_pvt_udp_sink.h" +#include "nmea_printer.h" +#include "pvt_conf.h" #include "rinex_printer.h" #include "rtcm_printer.h" #include "rtklib_solver.h" +#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include +#include #include -#include +#include class rtklib_pvt_cc; -typedef boost::shared_ptr rtklib_pvt_cc_sptr; +using rtklib_pvt_cc_sptr = boost::shared_ptr; -rtklib_pvt_cc_sptr rtklib_make_pvt_cc(unsigned int n_channels, - bool dump, - std::string dump_filename, - int output_rate_ms, - int display_rate_ms, - bool flag_nmea_tty_port, - std::string nmea_dump_filename, - std::string nmea_dump_devname, - int rinex_version, - bool flag_rtcm_server, - bool flag_rtcm_tty_port, - unsigned short rtcm_tcp_port, - unsigned short rtcm_station_id, - std::map rtcm_msg_rate_ms, - std::string rtcm_dump_devname, - const unsigned int type_of_receiver, - rtk_t& rtk); +rtklib_pvt_cc_sptr rtklib_make_pvt_cc(uint32_t nchannels, + const Pvt_Conf& conf_, + const rtk_t& rtk); /*! - * \brief This class implements a block that computes the PVT solution with Galileo E1 signals + * \brief This class implements a block that computes the PVT solution using the RTKLIB integrated library */ class rtklib_pvt_cc : public gr::sync_block { private: - friend rtklib_pvt_cc_sptr rtklib_make_pvt_cc(unsigned int nchannels, - bool dump, - std::string dump_filename, - int output_rate_ms, - int display_rate_ms, - bool flag_nmea_tty_port, - std::string nmea_dump_filename, - std::string nmea_dump_devname, - int rinex_version, - bool flag_rtcm_server, - bool flag_rtcm_tty_port, - unsigned short rtcm_tcp_port, - unsigned short rtcm_station_id, - std::map rtcm_msg_rate_ms, - std::string rtcm_dump_devname, - const unsigned int type_of_receiver, - rtk_t& rtk); + friend rtklib_pvt_cc_sptr rtklib_make_pvt_cc(uint32_t nchannels, + const Pvt_Conf& conf_, + const rtk_t& rtk); - void msg_handler_telemetry(pmt::pmt_t msg); + void msg_handler_telemetry(const pmt::pmt_t& msg); bool d_dump; + bool d_dump_mat; + bool b_rinex_output_enabled; bool b_rinex_header_written; bool b_rinex_header_updated; double d_rinex_version; + int32_t d_rinexobs_rate_ms; + int32_t d_rinexnav_rate_ms; + bool b_rtcm_writing_started; - int d_rtcm_MT1045_rate_ms; //!< Galileo Broadcast Ephemeris - int d_rtcm_MT1019_rate_ms; //!< GPS Broadcast Ephemeris (orbits) - int d_rtcm_MT1020_rate_ms; //!< GLONASS Broadcast Ephemeris (orbits) - int d_rtcm_MT1077_rate_ms; //!< The type 7 Multiple Signal Message format for the USA’s GPS system, popular - int d_rtcm_MT1087_rate_ms; //!< GLONASS MSM7. The type 7 Multiple Signal Message format for the Russian GLONASS system - int d_rtcm_MT1097_rate_ms; //!< Galileo MSM7. The type 7 Multiple Signal Message format for Europe’s Galileo system - int d_rtcm_MSM_rate_ms; + bool b_rtcm_enabled; + int32_t d_rtcm_MT1045_rate_ms; // Galileo Broadcast Ephemeris + int32_t d_rtcm_MT1019_rate_ms; // GPS Broadcast Ephemeris (orbits) + int32_t d_rtcm_MT1020_rate_ms; // GLONASS Broadcast Ephemeris (orbits) + int32_t d_rtcm_MT1077_rate_ms; // The type 7 Multiple Signal Message format for the USA’s GPS system, popular + int32_t d_rtcm_MT1087_rate_ms; // GLONASS MSM7. The type 7 Multiple Signal Message format for the Russian GLONASS system + int32_t d_rtcm_MT1097_rate_ms; // Galileo MSM7. The type 7 Multiple Signal Message format for Europe’s Galileo system + int32_t d_rtcm_MSM_rate_ms; - int d_last_status_print_seg; //for status printer + int32_t d_last_status_print_seg; // for status printer - unsigned int d_nchannels; + uint32_t d_nchannels; std::string d_dump_filename; - std::ofstream d_dump_file; - int d_output_rate_ms; - int d_display_rate_ms; + int32_t d_output_rate_ms; + int32_t d_display_rate_ms; std::shared_ptr rp; std::shared_ptr d_kml_dump; @@ -126,22 +117,18 @@ private: std::shared_ptr d_geojson_printer; std::shared_ptr d_rtcm_printer; double d_rx_time; - double last_pvt_display_T_rx_s; - double last_RTCM_1019_output_time; - double last_RTCM_1020_output_time; - double last_RTCM_1045_output_time; - double last_RTCM_1077_output_time; - double last_RTCM_1087_output_time; - double last_RTCM_1097_output_time; - double last_RTCM_MSM_output_time; - double last_RINEX_obs_output_time; - double last_RINEX_nav_output_time; - std::shared_ptr d_ls_pvt; + + bool d_geojson_output_enabled; + bool d_gpx_output_enabled; + bool d_kml_output_enabled; + bool d_nmea_output_file_enabled; + + std::shared_ptr d_pvt_solver; std::map gnss_observables_map; bool observables_pairCompare_min(const std::pair& a, const std::pair& b); - unsigned int type_of_rx; + uint32_t type_of_rx; bool first_fix; key_t sysv_msg_key; @@ -154,33 +141,61 @@ private: bool send_sys_v_ttff_msg(ttff_msgbuf ttff); std::chrono::time_point start, end; -public: - rtklib_pvt_cc(unsigned int nchannels, - bool dump, std::string dump_filename, - int output_rate_ms, - int display_rate_ms, - bool flag_nmea_tty_port, - std::string nmea_dump_filename, - std::string nmea_dump_devname, - int rinex_version, - bool flag_rtcm_server, - bool flag_rtcm_tty_port, - unsigned short rtcm_tcp_port, - unsigned short rtcm_station_id, - std::map rtcm_msg_rate_ms, - std::string rtcm_dump_devname, - const unsigned int type_of_receiver, - rtk_t& rtk); + bool save_gnss_synchro_map_xml(const std::string& file_name); // debug helper function - /*! - * \brief Get latest set of GPS L1 ephemeris from PVT block - * - * It is used to save the assistance data at the receiver shutdown - */ - std::map get_GPS_L1_ephemeris_map(); + bool load_gnss_synchro_map_xml(const std::string& file_name); // debug helper function + + bool d_xml_storage; + std::string xml_base_path; + + inline std::time_t convert_to_time_t(const boost::posix_time::ptime pt) const + { + return (pt - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds(); + } + + bool flag_monitor_pvt_enabled; + std::unique_ptr udp_sink_ptr; + std::vector split_string(const std::string& s, char delim) const; + +public: + rtklib_pvt_cc(uint32_t nchannels, + const Pvt_Conf& conf_, + const rtk_t& rtk); ~rtklib_pvt_cc(); //!< Default destructor + /*! + * \brief Get latest set of GPS ephemeris from PVT block + * + */ + std::map get_gps_ephemeris_map() const; + + std::map get_gps_almanac_map() const; + + std::map get_galileo_ephemeris_map() const; + + std::map get_galileo_almanac_map() const; + + std::map get_beidou_dnav_ephemeris_map() const; + + std::map get_beidou_dnav_almanac_map() const; + + /*! + * \brief Clear all ephemeris information and the almanacs for GPS and Galileo + * + */ + void clear_ephemeris(); + + /*! + * \brief Get the latest Position WGS84 [deg], Ground Velocity, Course over Ground, and UTC Time, if available + */ + bool get_latest_PVT(double* longitude_deg, + double* latitude_deg, + double* height_m, + double* ground_speed_kmh, + double* course_over_ground_deg, + time_t* UTC_time) const; + int work(int noutput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); //!< PVT Signal Processing }; diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index 82d733a19..d04fa0cb5 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,49 +16,81 @@ # along with GNSS-SDR. If not, see . # -add_definitions( -DGNSS_SDR_VERSION="${VERSION}" ) -set(PVT_LIB_SOURCES - pvt_solution.cc - ls_pvt.cc - hybrid_ls_pvt.cc - kml_printer.cc - gpx_printer.cc - rinex_printer.cc - nmea_printer.cc - rtcm_printer.cc - geojson_printer.cc - rtklib_solver.cc +set(PVT_LIB_SOURCES + pvt_solution.cc + ls_pvt.cc + hybrid_ls_pvt.cc + kml_printer.cc + gpx_printer.cc + rinex_printer.cc + nmea_printer.cc + rtcm_printer.cc + geojson_printer.cc + rtklib_solver.cc + pvt_conf.cc + monitor_pvt_udp_sink.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib - ${Boost_INCLUDE_DIRS} - ${ARMADILLO_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} +set(PVT_LIB_HEADERS + pvt_solution.h + ls_pvt.h + hybrid_ls_pvt.h + kml_printer.h + gpx_printer.h + rinex_printer.h + nmea_printer.h + rtcm_printer.h + geojson_printer.h + rtklib_solver.h + pvt_conf.h + monitor_pvt_udp_sink.h + monitor_pvt.h ) -file(GLOB PVT_LIB_HEADERS "*.h") list(SORT PVT_LIB_HEADERS) -add_library(pvt_lib ${PVT_LIB_SOURCES} ${PVT_LIB_HEADERS}) -source_group(Headers FILES ${PVT_LIB_HEADERS}) -add_dependencies(pvt_lib rtklib_lib armadillo-${armadillo_RELEASE} glog-${glog_RELEASE}) +list(SORT PVT_LIB_SOURCES) -target_link_libraries( - pvt_lib - rtklib_lib - gnss_sdr_flags - ${Boost_LIBRARIES} - ${GLOG_LIBRARIES} - ${ARMADILLO_LIBRARIES} - ${BLAS} - ${LAPACK} - ) - +source_group(Headers FILES ${PVT_LIB_HEADERS}) + +add_library(pvt_libs ${PVT_LIB_SOURCES} ${PVT_LIB_HEADERS}) + +target_link_libraries(pvt_libs + PUBLIC + Armadillo::armadillo + Boost::date_time + algorithms_libs + algorithms_libs_rtklib + core_system_parameters + PRIVATE + Boost::filesystem + Boost::system + Gflags::gflags + Glog::glog + Matio::matio +) + +target_include_directories(pvt_libs + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs + ${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib + ${CMAKE_SOURCE_DIR}/src/core/receiver +) + +target_compile_definitions(pvt_libs PRIVATE -DGNSS_SDR_VERSION="${VERSION}") + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(pvt_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET pvt_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ + $ + $ + $ +) diff --git a/src/algorithms/PVT/libs/geojson_printer.cc b/src/algorithms/PVT/libs/geojson_printer.cc index 5dd3ecdba..504393422 100644 --- a/src/algorithms/PVT/libs/geojson_printer.cc +++ b/src/algorithms/PVT/libs/geojson_printer.cc @@ -32,24 +32,66 @@ #include "geojson_printer.h" #include +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem #include +#include #include #include -GeoJSON_Printer::GeoJSON_Printer() +GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path) { first_pos = true; + geojson_base_path = base_path; + boost::filesystem::path full_path(boost::filesystem::current_path()); + const boost::filesystem::path p(geojson_base_path); + if (!boost::filesystem::exists(p)) + { + std::string new_folder; + for (auto& folder : boost::filesystem::path(geojson_base_path)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + std::cout << "Could not create the " << new_folder << " folder." << std::endl; + geojson_base_path = full_path.string(); + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + } + else + { + geojson_base_path = p.string(); + } + if (geojson_base_path != ".") + { + std::cout << "GeoJSON files will be stored at " << geojson_base_path << std::endl; + } + + geojson_base_path = geojson_base_path + boost::filesystem::path::preferred_separator; } GeoJSON_Printer::~GeoJSON_Printer() { - GeoJSON_Printer::close_file(); + try + { + GeoJSON_Printer::close_file(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } } -bool GeoJSON_Printer::set_headers(std::string filename, bool time_tag_name) +bool GeoJSON_Printer::set_headers(const std::string& filename, bool time_tag_name) { boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); tm timeinfo = boost::posix_time::to_tm(pt); @@ -96,6 +138,7 @@ bool GeoJSON_Printer::set_headers(std::string filename, bool time_tag_name) { filename_ = filename + ".geojson"; } + filename_ = geojson_base_path + filename_; geojson_file.open(filename_.c_str()); @@ -105,27 +148,24 @@ bool GeoJSON_Printer::set_headers(std::string filename, bool time_tag_name) DLOG(INFO) << "GeoJSON printer writing on " << filename.c_str(); // Set iostream numeric format and precision - geojson_file.setf(geojson_file.fixed, geojson_file.floatfield); + geojson_file.setf(geojson_file.std::ofstream::fixed, geojson_file.std::ofstream::floatfield); geojson_file << std::setprecision(14); // Writing the header geojson_file << "{" << std::endl; - geojson_file << " \"type\": \"Feature\"," << std::endl; + geojson_file << R"( "type": "Feature",)" << std::endl; geojson_file << " \"properties\": {" << std::endl; - geojson_file << " \"name\": \"Locations generated by GNSS-SDR\" " << std::endl; + geojson_file << R"( "name": "Locations generated by GNSS-SDR" )" << std::endl; geojson_file << " }," << std::endl; - - geojson_file << " \"geometry\": {" << std::endl; - geojson_file << " \"type\": \"MultiPoint\"," << std::endl; + geojson_file << R"( "type": "MultiPoint",)" << std::endl; geojson_file << " \"coordinates\": [" << std::endl; return true; } - else - { - return false; - } + + std::cout << "File " << filename_ << " cannot be saved. Wrong permissions?" << std::endl; + return false; } @@ -135,7 +175,7 @@ bool GeoJSON_Printer::print_position(const std::shared_ptr& positi double longitude; double height; - std::shared_ptr position_ = position; + const std::shared_ptr& position_ = position; if (print_average_values == false) { @@ -164,10 +204,7 @@ bool GeoJSON_Printer::print_position(const std::shared_ptr& positi } return true; } - else - { - return false; - } + return false; } @@ -184,13 +221,12 @@ bool GeoJSON_Printer::close_file() // if nothing is written, erase the file if (first_pos == true) { - if (remove(filename_.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(filename_.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } - return true; } - else - { - return false; - } + return false; } diff --git a/src/algorithms/PVT/libs/geojson_printer.h b/src/algorithms/PVT/libs/geojson_printer.h index 9963e64d2..b9bdcdb28 100644 --- a/src/algorithms/PVT/libs/geojson_printer.h +++ b/src/algorithms/PVT/libs/geojson_printer.h @@ -50,11 +50,12 @@ private: std::ofstream geojson_file; bool first_pos; std::string filename_; + std::string geojson_base_path; public: - GeoJSON_Printer(); + GeoJSON_Printer(const std::string& base_path = "."); ~GeoJSON_Printer(); - bool set_headers(std::string filename, bool time_tag_name = true); + bool set_headers(const std::string& filename, bool time_tag_name = true); bool print_position(const std::shared_ptr& position, bool print_average_values); bool close_file(); }; diff --git a/src/algorithms/PVT/libs/gpx_printer.cc b/src/algorithms/PVT/libs/gpx_printer.cc index 3a8661e6d..d37b77908 100644 --- a/src/algorithms/PVT/libs/gpx_printer.cc +++ b/src/algorithms/PVT/libs/gpx_printer.cc @@ -1,6 +1,6 @@ /*! * \file gpx_printer.cc - * \brief Interface of a class that prints PVT information to a gpx file + * \brief Implementation of a class that prints PVT information to a gpx file * \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com * * @@ -32,12 +32,55 @@ #include "gpx_printer.h" #include +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem #include +#include #include using google::LogMessage; -bool Gpx_Printer::set_headers(std::string filename, bool time_tag_name) + +Gpx_Printer::Gpx_Printer(const std::string& base_path) +{ + positions_printed = false; + indent = " "; + gpx_base_path = base_path; + boost::filesystem::path full_path(boost::filesystem::current_path()); + const boost::filesystem::path p(gpx_base_path); + if (!boost::filesystem::exists(p)) + { + std::string new_folder; + for (auto& folder : boost::filesystem::path(gpx_base_path)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + std::cout << "Could not create the " << new_folder << " folder." << std::endl; + gpx_base_path = full_path.string(); + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + } + else + { + gpx_base_path = p.string(); + } + if (gpx_base_path != ".") + { + std::cout << "GPX files will be stored at " << gpx_base_path << std::endl; + } + + gpx_base_path = gpx_base_path + boost::filesystem::path::preferred_separator; +} + + +bool Gpx_Printer::set_headers(const std::string& filename, bool time_tag_name) { boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); tm timeinfo = boost::posix_time::to_tm(pt); @@ -84,47 +127,56 @@ bool Gpx_Printer::set_headers(std::string filename, bool time_tag_name) { gpx_filename = filename + ".gpx"; } + + gpx_filename = gpx_base_path + gpx_filename; gpx_file.open(gpx_filename.c_str()); if (gpx_file.is_open()) { DLOG(INFO) << "GPX printer writing on " << filename.c_str(); // Set iostream numeric format and precision - gpx_file.setf(gpx_file.fixed, gpx_file.floatfield); + gpx_file.setf(gpx_file.std::ofstream::fixed, gpx_file.std::ofstream::floatfield); gpx_file << std::setprecision(14); - gpx_file << "" << std::endl - << "" << std::endl - << "" << std::endl - << indent << "Position fixes computed by GNSS-SDR v" << GNSS_SDR_VERSION << "" << std::endl - << indent << "GNSS-SDR position log generated at " << pt << " (local time)" << std::endl - << indent << "" << std::endl; + gpx_file << R"()" << std::endl + << R"(" << std::endl + << indent << "" << std::endl + << indent << indent << "Position fixes computed by GNSS-SDR v" << GNSS_SDR_VERSION << "" << std::endl + << indent << indent << "GNSS-SDR position log generated at " << pt << " (local time)" << std::endl + << indent << indent << "" << std::endl; return true; } - else - { - return false; - } + std::cout << "File " << gpx_filename << " cannot be saved. Wrong permissions?" << std::endl; + return false; } -bool Gpx_Printer::print_position(const std::shared_ptr& position, bool print_average_values) +bool Gpx_Printer::print_position(const std::shared_ptr& position, bool print_average_values) { double latitude; double longitude; double height; positions_printed = true; - std::shared_ptr position_ = position; + const std::shared_ptr& position_ = position; + + double speed_over_ground = position_->get_speed_over_ground(); // expressed in m/s + double course_over_ground = position_->get_course_over_ground(); // expressed in deg double hdop = position_->get_hdop(); double vdop = position_->get_vdop(); double pdop = position_->get_pdop(); std::string utc_time = to_iso_extended_string(position_->get_position_UTC_time()); - utc_time.resize(23); // time up to ms - utc_time.append("Z"); // UTC time zone + if (utc_time.length() < 23) + { + utc_time += "."; + } + utc_time.resize(23, '0'); // time up to ms + utc_time.append("Z"); // UTC time zone if (print_average_values == false) { @@ -141,15 +193,16 @@ bool Gpx_Printer::print_position(const std::shared_ptr& position, if (gpx_file.is_open()) { - gpx_file << indent << indent << "" << height << "" + gpx_file << indent << indent << indent << "" << height << "" << "" - << "" << hdop << "" << vdop << "" << pdop << "" << std::endl; + << "" << hdop << "" << vdop << "" << pdop << "" + << "" + << "" << speed_over_ground << "" + << "" << course_over_ground << "" + << "" << std::endl; return true; } - else - { - return false; - } + return false; } @@ -157,31 +210,31 @@ bool Gpx_Printer::close_file() { if (gpx_file.is_open()) { - gpx_file << indent << "" << std::endl - << "" << std::endl + gpx_file << indent << indent << "" << std::endl + << indent << "" << std::endl << ""; gpx_file.close(); return true; } - else - { - return false; - } -} - - -Gpx_Printer::Gpx_Printer() -{ - positions_printed = false; - indent = " "; + return false; } Gpx_Printer::~Gpx_Printer() { - close_file(); + try + { + close_file(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } if (!positions_printed) { - if (remove(gpx_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary GPX file"; + if (remove(gpx_filename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary GPX file"; + } } } diff --git a/src/algorithms/PVT/libs/gpx_printer.h b/src/algorithms/PVT/libs/gpx_printer.h index f158b6fb9..c584eba4c 100644 --- a/src/algorithms/PVT/libs/gpx_printer.h +++ b/src/algorithms/PVT/libs/gpx_printer.h @@ -52,12 +52,13 @@ private: bool positions_printed; std::string gpx_filename; std::string indent; + std::string gpx_base_path; public: - Gpx_Printer(); + Gpx_Printer(const std::string& base_path = "."); ~Gpx_Printer(); - bool set_headers(std::string filename, bool time_tag_name = true); - bool print_position(const std::shared_ptr& position, bool print_average_values); + bool set_headers(const std::string& filename, bool time_tag_name = true); + bool print_position(const std::shared_ptr& position, bool print_average_values); bool close_file(); }; diff --git a/src/algorithms/PVT/libs/hybrid_ls_pvt.cc b/src/algorithms/PVT/libs/hybrid_ls_pvt.cc index 25898e195..2b1adf739 100644 --- a/src/algorithms/PVT/libs/hybrid_ls_pvt.cc +++ b/src/algorithms/PVT/libs/hybrid_ls_pvt.cc @@ -30,19 +30,21 @@ */ #include "hybrid_ls_pvt.h" -#include "Galileo_E1.h" #include "GPS_L1_CA.h" #include "GPS_L2C.h" +#include "Galileo_E1.h" +#include #include +#include using google::LogMessage; -hybrid_ls_pvt::hybrid_ls_pvt(int nchannels, std::string dump_filename, bool flag_dump_to_file) : Ls_Pvt() +Hybrid_Ls_Pvt::Hybrid_Ls_Pvt(int nchannels, std::string dump_filename, bool flag_dump_to_file) : Ls_Pvt() { // init empty ephemeris for all the available GNSS channels d_nchannels = nchannels; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); d_flag_dump_enabled = flag_dump_to_file; d_galileo_current_time = 0; count_valid_position = 0; @@ -67,7 +69,7 @@ hybrid_ls_pvt::hybrid_ls_pvt(int nchannels, std::string dump_filename, bool flag } -hybrid_ls_pvt::~hybrid_ls_pvt() +Hybrid_Ls_Pvt::~Hybrid_Ls_Pvt() { if (d_dump_file.is_open() == true) { @@ -83,7 +85,7 @@ hybrid_ls_pvt::~hybrid_ls_pvt() } -bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, double hybrid_current_time, bool flag_averaging) +bool Hybrid_Ls_Pvt::get_PVT(std::map gnss_observables_map, double hybrid_current_time, bool flag_averaging) { std::map::iterator gnss_observables_iter; std::map::iterator galileo_ephemeris_iter; @@ -131,7 +133,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do // COMMON RX TIME PVT ALGORITHM double Rx_time = hybrid_current_time; - double Tx_time = Rx_time - gnss_observables_iter->second.Pseudorange_m / GALILEO_C_m_s; + double Tx_time = Rx_time - gnss_observables_iter->second.Pseudorange_m / GALILEO_C_M_S; // 2- compute the clock drift using the clock model (broadcast) for this SV SV_clock_bias_s = galileo_ephemeris_iter->second.sv_clock_drift(Tx_time); @@ -148,9 +150,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do // 4- fill the observations vector with the corrected observables obs.resize(valid_obs + 1, 1); - obs(valid_obs) = gnss_observables_iter->second.Pseudorange_m + SV_clock_bias_s * GALILEO_C_m_s - this->get_time_offset_s() * GALILEO_C_m_s; - this->set_visible_satellites_ID(valid_obs, galileo_ephemeris_iter->second.i_satellite_PRN); - this->set_visible_satellites_CN0_dB(valid_obs, gnss_observables_iter->second.CN0_dB_hz); + obs(valid_obs) = gnss_observables_iter->second.Pseudorange_m + SV_clock_bias_s * GALILEO_C_M_S - this->get_time_offset_s() * GALILEO_C_M_S; Galileo_week_number = galileo_ephemeris_iter->second.WN_5; //for GST GST = galileo_ephemeris_iter->second.Galileo_System_Time(Galileo_week_number, hybrid_current_time); @@ -174,7 +174,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do { // 1 GPS - find the ephemeris for the current GPS SV observation. The SV PRN ID is the map key std::string sig_(gnss_observables_iter->second.Signal); - if (sig_.compare("1C") == 0) + if (sig_ == "1C") { gps_ephemeris_iter = gps_ephemeris_map.find(gnss_observables_iter->second.PRN); if (gps_ephemeris_iter != gps_ephemeris_map.end()) @@ -188,7 +188,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do // COMMON RX TIME PVT ALGORITHM MODIFICATION (Like RINEX files) // first estimate of transmit time double Rx_time = hybrid_current_time; - double Tx_time = Rx_time - gnss_observables_iter->second.Pseudorange_m / GPS_C_m_s; + double Tx_time = Rx_time - gnss_observables_iter->second.Pseudorange_m / GPS_C_M_S; // 2- compute the clock drift using the clock model (broadcast) for this SV, not including relativistic effect SV_clock_bias_s = gps_ephemeris_iter->second.sv_clock_drift(Tx_time); //- gps_ephemeris_iter->second.d_TGD; @@ -208,12 +208,10 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do // See IS-GPS-200E section 20.3.3.3.3.2 double sqrt_Gamma = GPS_L1_FREQ_HZ / GPS_L2_FREQ_HZ; double Gamma = sqrt_Gamma * sqrt_Gamma; - double P1_P2 = (1.0 - Gamma) * (gps_ephemeris_iter->second.d_TGD * GPS_C_m_s); + double P1_P2 = (1.0 - Gamma) * (gps_ephemeris_iter->second.d_TGD * GPS_C_M_S); double Code_bias_m = P1_P2 / (1.0 - Gamma); obs.resize(valid_obs + 1, 1); - obs(valid_obs) = gnss_observables_iter->second.Pseudorange_m + dtr * GPS_C_m_s - Code_bias_m - this->get_time_offset_s() * GPS_C_m_s; - this->set_visible_satellites_ID(valid_obs, gps_ephemeris_iter->second.i_satellite_PRN); - this->set_visible_satellites_CN0_dB(valid_obs, gnss_observables_iter->second.CN0_dB_hz); + obs(valid_obs) = gnss_observables_iter->second.Pseudorange_m + dtr * GPS_C_M_S - Code_bias_m - this->get_time_offset_s() * GPS_C_M_S; // SV ECEF DEBUG OUTPUT LOG(INFO) << "(new)ECEF GPS L1 CA satellite SV ID=" << gps_ephemeris_iter->second.i_satellite_PRN @@ -231,7 +229,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->first; } } - if (sig_.compare("2S") == 0) + if (sig_ == "2S") { gps_cnav_ephemeris_iter = gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN); if (gps_cnav_ephemeris_iter != gps_cnav_ephemeris_map.end()) @@ -245,7 +243,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do // COMMON RX TIME PVT ALGORITHM MODIFICATION (Like RINEX files) // first estimate of transmit time double Rx_time = hybrid_current_time; - double Tx_time = Rx_time - gnss_observables_iter->second.Pseudorange_m / GPS_C_m_s; + double Tx_time = Rx_time - gnss_observables_iter->second.Pseudorange_m / GPS_C_M_S; // 2- compute the clock drift using the clock model (broadcast) for this SV SV_clock_bias_s = gps_cnav_ephemeris_iter->second.sv_clock_drift(Tx_time); @@ -263,9 +261,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do // 4- fill the observations vector with the corrected observables obs.resize(valid_obs + 1, 1); - obs(valid_obs) = gnss_observables_iter->second.Pseudorange_m + dtr * GPS_C_m_s + SV_clock_bias_s * GPS_C_m_s; - this->set_visible_satellites_ID(valid_obs, gps_cnav_ephemeris_iter->second.i_satellite_PRN); - this->set_visible_satellites_CN0_dB(valid_obs, gnss_observables_iter->second.CN0_dB_hz); + obs(valid_obs) = gnss_observables_iter->second.Pseudorange_m + dtr * GPS_C_M_S + SV_clock_bias_s * GPS_C_M_S; GPS_week = gps_cnav_ephemeris_iter->second.i_GPS_week; GPS_week = GPS_week % 1024; //Necessary due to the increase of WN bits in CNAV message (10 in GPS NAV and 13 in CNAV) @@ -315,17 +311,17 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do DLOG(INFO) << " Executing Bancroft algorithm..."; rx_position_and_time = bancroftPos(satpos.t(), obs); this->set_rx_pos(rx_position_and_time.rows(0, 2)); // save ECEF position for the next iteration - this->set_time_offset_s(rx_position_and_time(3) / GPS_C_m_s); // save time for the next iteration [meters]->[seconds] + this->set_time_offset_s(rx_position_and_time(3) / GPS_C_M_S); // save time for the next iteration [meters]->[seconds] } // Execute WLS using previous position as the initialization point rx_position_and_time = leastSquarePos(satpos, obs, W); this->set_rx_pos(rx_position_and_time.rows(0, 2)); // save ECEF position for the next iteration - this->set_time_offset_s(this->get_time_offset_s() + rx_position_and_time(3) / GPS_C_m_s); // accumulate the rx time error for the next iteration [meters]->[seconds] + this->set_time_offset_s(this->get_time_offset_s() + rx_position_and_time(3) / GPS_C_M_S); // accumulate the rx time error for the next iteration [meters]->[seconds] DLOG(INFO) << "Hybrid Position at TOW=" << hybrid_current_time << " in ECEF (X,Y,Z,t[meters]) = " << rx_position_and_time; - DLOG(INFO) << "Accumulated rx clock error=" << this->get_time_offset_s() << " clock error for this iteration=" << rx_position_and_time(3) / GPS_C_m_s << " [s]"; + DLOG(INFO) << "Accumulated rx clock error=" << this->get_time_offset_s() << " clock error for this iteration=" << rx_position_and_time(3) / GPS_C_M_S << " [s]"; // Compute GST and Gregorian time if (GST != 0.0) @@ -338,7 +334,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_observables_map, do } // get time string Gregorian calendar - boost::posix_time::time_duration t = boost::posix_time::seconds(utc); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast(utc * 1000.0)); // NOLINT(google-runtime-int) // 22 August 1999 00:00 last Galileo start GST epoch (ICD sec 5.1.2) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); this->set_position_UTC_time(p_time); diff --git a/src/algorithms/PVT/libs/hybrid_ls_pvt.h b/src/algorithms/PVT/libs/hybrid_ls_pvt.h index f8a6fc32c..79313c92b 100644 --- a/src/algorithms/PVT/libs/hybrid_ls_pvt.h +++ b/src/algorithms/PVT/libs/hybrid_ls_pvt.h @@ -32,11 +32,12 @@ #ifndef GNSS_SDR_HYBRID_LS_PVT_H_ #define GNSS_SDR_HYBRID_LS_PVT_H_ -#include "ls_pvt.h" +#include "galileo_almanac.h" #include "galileo_navigation_message.h" -#include "gps_navigation_message.h" -#include "gps_cnav_navigation_message.h" #include "gnss_synchro.h" +#include "gps_cnav_navigation_message.h" +#include "gps_navigation_message.h" +#include "ls_pvt.h" #include "rtklib_rtkcmn.h" #include #include @@ -45,7 +46,7 @@ /*! * \brief This class implements a simple PVT Least Squares solution */ -class hybrid_ls_pvt : public Ls_Pvt +class Hybrid_Ls_Pvt : public Ls_Pvt { private: int count_valid_position; @@ -56,10 +57,10 @@ private: double d_galileo_current_time; public: - hybrid_ls_pvt(int nchannels, std::string dump_filename, bool flag_dump_to_file); - ~hybrid_ls_pvt(); + Hybrid_Ls_Pvt(int nchannels, std::string dump_filename, bool flag_dump_to_file); + ~Hybrid_Ls_Pvt(); - bool get_PVT(std::map gnss_observables_map, double Rx_time, bool flag_averaging); + bool get_PVT(std::map gnss_observables_map, double hybrid_current_time, bool flag_averaging); std::map galileo_ephemeris_map; //!< Map storing new Galileo_Ephemeris std::map gps_ephemeris_map; //!< Map storing new GPS_Ephemeris diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index 1233df036..790090544 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -2,6 +2,7 @@ * \file kml_printer.cc * \brief Implementation of a class that prints PVT information to a kml file * \author Javier Arribas, 2011. jarribas(at)cttc.es + * Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com * * * ------------------------------------------------------------------------- @@ -31,12 +32,63 @@ #include "kml_printer.h" #include +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem #include +#include #include using google::LogMessage; -bool Kml_Printer::set_headers(std::string filename, bool time_tag_name) + +Kml_Printer::Kml_Printer(const std::string& base_path) +{ + positions_printed = false; + indent = " "; + kml_base_path = base_path; + boost::filesystem::path full_path(boost::filesystem::current_path()); + const boost::filesystem::path p(kml_base_path); + if (!boost::filesystem::exists(p)) + { + std::string new_folder; + for (auto& folder : boost::filesystem::path(kml_base_path)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + std::cout << "Could not create the " << new_folder << " folder." << std::endl; + kml_base_path = full_path.string(); + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + } + else + { + kml_base_path = p.string(); + } + if (kml_base_path != ".") + { + std::cout << "KML files will be stored at " << kml_base_path << std::endl; + } + + kml_base_path = kml_base_path + boost::filesystem::path::preferred_separator; + + boost::filesystem::path tmp_base_path = boost::filesystem::temp_directory_path(); + boost::filesystem::path tmp_filename = boost::filesystem::unique_path(); + boost::filesystem::path tmp_file = tmp_base_path / tmp_filename; + + tmp_file_str = tmp_file.string(); + + point_id = 0; +} + + +bool Kml_Printer::set_headers(const std::string& filename, bool time_tag_name) { boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); tm timeinfo = boost::posix_time::to_tm(pt); @@ -83,48 +135,84 @@ bool Kml_Printer::set_headers(std::string filename, bool time_tag_name) { kml_filename = filename + ".kml"; } + kml_filename = kml_base_path + kml_filename; kml_file.open(kml_filename.c_str()); - if (kml_file.is_open()) + tmp_file.open(tmp_file_str.c_str()); + + if (kml_file.is_open() && tmp_file.is_open()) { DLOG(INFO) << "KML printer writing on " << filename.c_str(); // Set iostream numeric format and precision - kml_file.setf(kml_file.fixed, kml_file.floatfield); + kml_file.setf(kml_file.std::ofstream::fixed, kml_file.std::ofstream::floatfield); kml_file << std::setprecision(14); - kml_file << "" << std::endl - << "" << std::endl - << " " << std::endl - << " GNSS Track" << std::endl - << " GNSS-SDR Receiver position log file created at " << pt - << " " << std::endl - << "" << std::endl - << "" << std::endl - << "GNSS-SDR PVT" << std::endl - << "GNSS-SDR position log" << std::endl - << "#yellowLineGreenPoly" << std::endl - << "" << std::endl - << "0" << std::endl - << "1" << std::endl - << "absolute" << std::endl - << "" << std::endl; + + tmp_file.setf(tmp_file.std::ofstream::fixed, tmp_file.std::ofstream::floatfield); + tmp_file << std::setprecision(14); + + kml_file << R"()" << std::endl + << R"()" << std::endl + << indent << "" << std::endl + << indent << indent << "GNSS Track" << std::endl + << indent << indent << "" << std::endl + << indent << indent << indent << indent << "GNSS-SDR Receiver position log file created at " << pt << "" << std::endl + << indent << indent << indent << indent << "https://gnss-sdr.org/" << std::endl + << indent << indent << indent << "" << std::endl + << indent << indent << "]]>" << std::endl + << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << "normal" << std::endl + << indent << indent << indent << indent << "#track_n" << std::endl + << indent << indent << indent << "" << std::endl + << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << "highlight" << std::endl + << indent << indent << indent << indent << "#track_h" << std::endl + << indent << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << indent << indent << "Points" << std::endl; + return true; } - else - { - return false; - } + std::cout << "File " << kml_filename << " cannot be saved. Wrong permissions?" << std::endl; + return false; } -bool Kml_Printer::print_position(const std::shared_ptr& position, bool print_average_values) +bool Kml_Printer::print_position(const std::shared_ptr& position, bool print_average_values) { double latitude; double longitude; @@ -132,7 +220,21 @@ bool Kml_Printer::print_position(const std::shared_ptr& position, positions_printed = true; - std::shared_ptr position_ = position; + const std::shared_ptr& position_ = position; + + double speed_over_ground = position_->get_speed_over_ground(); // expressed in m/s + double course_over_ground = position_->get_course_over_ground(); // expressed in deg + + double hdop = position_->get_hdop(); + double vdop = position_->get_vdop(); + double pdop = position_->get_pdop(); + std::string utc_time = to_iso_extended_string(position_->get_position_UTC_time()); + if (utc_time.length() < 23) + { + utc_time += "."; + } + utc_time.resize(23, '0'); // time up to ms + utc_time.append("Z"); // UTC time zone if (print_average_values == false) { @@ -147,48 +249,93 @@ bool Kml_Printer::print_position(const std::shared_ptr& position, height = position_->get_avg_height(); } - if (kml_file.is_open()) + if (kml_file.is_open() && tmp_file.is_open()) { - kml_file << longitude << "," << latitude << "," << height << std::endl; + point_id++; + kml_file << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << "" << point_id << "" << std::endl + << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << indent << indent << "Time:" << utc_time << "" << std::endl + << indent << indent << indent << indent << indent << indent << "Longitude:" << longitude << "deg" << std::endl + << indent << indent << indent << indent << indent << indent << "Latitude:" << latitude << "deg" << std::endl + << indent << indent << indent << indent << indent << indent << "Altitude:" << height << "m" << std::endl + << indent << indent << indent << indent << indent << indent << "Speed:" << speed_over_ground << "m/s" << std::endl + << indent << indent << indent << indent << indent << indent << "Course:" << course_over_ground << "deg" << std::endl + << indent << indent << indent << indent << indent << indent << "HDOP:" << hdop << "" << std::endl + << indent << indent << indent << indent << indent << indent << "VDOP:" << vdop << "" << std::endl + << indent << indent << indent << indent << indent << indent << "PDOP:" << pdop << "" << std::endl + << indent << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << "]]>" << std::endl + << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << indent << "" << utc_time << "" << std::endl + << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << "#track" << std::endl + << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << indent << "absolute" << std::endl + << indent << indent << indent << indent << indent << "" << longitude << "," << latitude << "," << height << "" << std::endl + << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << "" << std::endl; + + tmp_file << indent << indent << indent << indent << indent + << longitude << "," << latitude << "," << height << std::endl; + return true; } - else - { - return false; - } + return false; } bool Kml_Printer::close_file() { - if (kml_file.is_open()) + if (kml_file.is_open() && tmp_file.is_open()) { - kml_file << "" << std::endl - << "" << std::endl - << "" << std::endl - << "" << std::endl + tmp_file.close(); + + kml_file << indent << indent << "" + << indent << indent << "" << std::endl + << indent << indent << indent << "Path" << std::endl + << indent << indent << indent << "#yellowLineGreenPoly" << std::endl + << indent << indent << indent << "" << std::endl + << indent << indent << indent << indent << "0" << std::endl + << indent << indent << indent << indent << "1" << std::endl + << indent << indent << indent << indent << "absolute" << std::endl + << indent << indent << indent << indent << "" << std::endl; + + // Copy the contents of tmp_file into kml_file + std::ifstream src(tmp_file_str, std::ios::binary); + kml_file << src.rdbuf(); + + kml_file << indent << indent << indent << indent << "" << std::endl + << indent << indent << indent << "" << std::endl + << indent << indent << "" << std::endl + << indent << "" << std::endl << ""; + kml_file.close(); + return true; } - else - { - return false; - } -} - - -Kml_Printer::Kml_Printer() -{ - positions_printed = false; + return false; } Kml_Printer::~Kml_Printer() { - close_file(); + try + { + close_file(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } if (!positions_printed) { - if (remove(kml_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary KML file"; + if (remove(kml_filename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary KML file"; + } } } diff --git a/src/algorithms/PVT/libs/kml_printer.h b/src/algorithms/PVT/libs/kml_printer.h index 435943a6c..1608158b4 100644 --- a/src/algorithms/PVT/libs/kml_printer.h +++ b/src/algorithms/PVT/libs/kml_printer.h @@ -2,7 +2,7 @@ * \file kml_printer.h * \brief Interface of a class that prints PVT information to a kml file * \author Javier Arribas, 2011. jarribas(at)cttc.es - * + * Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com * * ------------------------------------------------------------------------- * @@ -34,6 +34,7 @@ #define GNSS_SDR_KML_PRINTER_H_ #include "pvt_solution.h" +#include "rtklib_solver.h" #include #include #include @@ -48,14 +49,19 @@ class Kml_Printer { private: std::ofstream kml_file; + std::ofstream tmp_file; bool positions_printed; std::string kml_filename; + std::string kml_base_path; + std::string tmp_file_str; + unsigned int point_id; + std::string indent; public: - Kml_Printer(); + Kml_Printer(const std::string& base_path = std::string(".")); ~Kml_Printer(); - bool set_headers(std::string filename, bool time_tag_name = true); - bool print_position(const std::shared_ptr& position, bool print_average_values); + bool set_headers(const std::string& filename, bool time_tag_name = true); + bool print_position(const std::shared_ptr& position, bool print_average_values); bool close_file(); }; diff --git a/src/algorithms/PVT/libs/ls_pvt.cc b/src/algorithms/PVT/libs/ls_pvt.cc index 8525d952f..5f9b9ad48 100644 --- a/src/algorithms/PVT/libs/ls_pvt.cc +++ b/src/algorithms/PVT/libs/ls_pvt.cc @@ -31,6 +31,7 @@ #include "ls_pvt.h" #include "GPS_L1_CA.h" +#include "geofunctions.h" #include #include #include @@ -43,6 +44,7 @@ Ls_Pvt::Ls_Pvt() : Pvt_Solution() { } + arma::vec Ls_Pvt::bancroftPos(const arma::mat& satpos, const arma::vec& obs) { // BANCROFT Calculation of preliminary coordinates for a GPS receiver based on pseudoranges @@ -93,7 +95,7 @@ arma::vec Ls_Pvt::bancroftPos(const arma::mat& satpos, const arma::vec& obs) { int z = B(i, 2); double rho = (x - pos(0)) * (x - pos(0)) + (y - pos(1)) * (y - pos(1)) + (z - pos(2)) * (z - pos(2)); - traveltime = sqrt(rho) / GPS_C_m_s; + traveltime = sqrt(rho) / GPS_C_M_S; } double angle = traveltime * 7.292115147e-5; double cosa = cos(angle); @@ -226,24 +228,21 @@ arma::vec Ls_Pvt::leastSquarePos(const arma::mat& satpos, const arma::vec& obs, (X(1, i) - pos(1)) + (X(2, i) - pos(2)) * (X(2, i) - pos(2)); - traveltime = sqrt(rho2) / GPS_C_m_s; + traveltime = sqrt(rho2) / GPS_C_M_S; //--- Correct satellite position (do to earth rotation) -------- Rot_X = Ls_Pvt::rotateSatellite(traveltime, X.col(i)); //armadillo //--- Find DOA and range of satellites - double* azim = 0; - double* elev = 0; - double* dist = 0; - Ls_Pvt::topocent(azim, elev, dist, pos.subvec(0, 2), Rot_X - pos.subvec(0, 2)); - this->set_visible_satellites_Az(i, *azim); - this->set_visible_satellites_El(i, *elev); - this->set_visible_satellites_Distance(i, *dist); + double* azim = nullptr; + double* elev = nullptr; + double* dist = nullptr; + topocent(azim, elev, dist, pos.subvec(0, 2), Rot_X - pos.subvec(0, 2)); if (traveltime < 0.1 && nmbOfSatellites > 3) { //--- Find receiver's height - Ls_Pvt::togeod(&dphi, &dlambda, &h, 6378137.0, 298.257223563, pos(0), pos(1), pos(2)); + togeod(&dphi, &dlambda, &h, 6378137.0, 298.257223563, pos(0), pos(1), pos(2)); // Add troposphere correction if the receiver is below the troposphere if (h > 15000) { @@ -253,8 +252,11 @@ arma::vec Ls_Pvt::leastSquarePos(const arma::mat& satpos, const arma::vec& obs, else { //--- Find delay due to troposphere (in meters) - Ls_Pvt::tropo(&trop, sin(this->get_visible_satellites_El(i) * GPS_PI / 180.0), h / 1000.0, 1013.0, 293.0, 50.0, 0.0, 0.0, 0.0); - if (trop > 5.0) trop = 0.0; //check for erratic values + Ls_Pvt::tropo(&trop, sin(*elev * GPS_PI / 180.0), h / 1000.0, 1013.0, 293.0, 50.0, 0.0, 0.0, 0.0); + if (trop > 5.0) + { + trop = 0.0; //check for erratic values + } } } } @@ -280,13 +282,10 @@ arma::vec Ls_Pvt::leastSquarePos(const arma::mat& satpos, const arma::vec& obs, } } - //-- compute the Dilution Of Precision values - //this->set_Q(arma::inv(arma::htrans(A) * A)); - // check the consistency of the PVT solution - if (((fabs(pos(3)) * 1000.0) / GPS_C_m_s) > GPS_STARTOFFSET_ms * 2) + if (((fabs(pos(3)) * 1000.0) / GPS_C_M_S) > GPS_STARTOFFSET_MS * 2) { - LOG(WARNING) << "Receiver time offset out of range! Estimated RX Time error [s]:" << pos(3) / GPS_C_m_s; + LOG(WARNING) << "Receiver time offset out of range! Estimated RX Time error [s]:" << pos(3) / GPS_C_M_S; throw std::runtime_error("Receiver time offset out of range!"); } return pos; diff --git a/src/algorithms/PVT/libs/monitor_pvt.h b/src/algorithms/PVT/libs/monitor_pvt.h new file mode 100644 index 000000000..41f22a1de --- /dev/null +++ b/src/algorithms/PVT/libs/monitor_pvt.h @@ -0,0 +1,140 @@ +/*! + * \file monitor_pvt.h + * \brief Interface of the Monitor_Pvt class + * \author + * Álvaro Cebrián Juan, 2019. acebrianjuan(at)gmail.com + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_MONITOR_PVT_H_ +#define GNSS_SDR_MONITOR_PVT_H_ + +#include +#include + +/*! + * \brief This class contains parameters and outputs of the PVT block + */ +class Monitor_Pvt +{ +public: + // TOW + uint32_t TOW_at_current_symbol_ms; + // WEEK + uint32_t week; + // PVT GPS time + double RX_time; + // User clock offset [s] + double user_clk_offset; + + // ECEF POS X,Y,X [m] + ECEF VEL X,Y,X [m/s] (6 x double) + double pos_x; + double pos_y; + double pos_z; + double vel_x; + double vel_y; + double vel_z; + + // position variance/covariance (m^2) {c_xx,c_yy,c_zz,c_xy,c_yz,c_zx} (6 x double) + double cov_xx; + double cov_yy; + double cov_zz; + double cov_xy; + double cov_yz; + double cov_zx; + + // GEO user position Latitude [deg] + double latitude; + // GEO user position Longitude [deg] + double longitude; + // GEO user position Height [m] + double height; + + // NUMBER OF VALID SATS + uint8_t valid_sats; + // RTKLIB solution status + uint8_t solution_status; + // RTKLIB solution type (0:xyz-ecef,1:enu-baseline) + uint8_t solution_type; + // AR ratio factor for validation + float AR_ratio_factor; + // AR ratio threshold for validation + float AR_ratio_threshold; + + // GDOP / PDOP/ HDOP/ VDOP + double gdop; + double pdop; + double hdop; + double vdop; + + /*! + * \brief This member function serializes and restores + * Monitor_Pvt objects from a byte stream. + */ + template + + void serialize(Archive& ar, const unsigned int version) + { + if (version) + { + }; + + ar& BOOST_SERIALIZATION_NVP(TOW_at_current_symbol_ms); + ar& BOOST_SERIALIZATION_NVP(week); + ar& BOOST_SERIALIZATION_NVP(RX_time); + ar& BOOST_SERIALIZATION_NVP(user_clk_offset); + + ar& BOOST_SERIALIZATION_NVP(pos_x); + ar& BOOST_SERIALIZATION_NVP(pos_y); + ar& BOOST_SERIALIZATION_NVP(pos_z); + ar& BOOST_SERIALIZATION_NVP(vel_x); + ar& BOOST_SERIALIZATION_NVP(vel_y); + ar& BOOST_SERIALIZATION_NVP(vel_z); + + ar& BOOST_SERIALIZATION_NVP(cov_xx); + ar& BOOST_SERIALIZATION_NVP(cov_yy); + ar& BOOST_SERIALIZATION_NVP(cov_zz); + ar& BOOST_SERIALIZATION_NVP(cov_xy); + ar& BOOST_SERIALIZATION_NVP(cov_yz); + ar& BOOST_SERIALIZATION_NVP(cov_zx); + + ar& BOOST_SERIALIZATION_NVP(latitude); + ar& BOOST_SERIALIZATION_NVP(longitude); + ar& BOOST_SERIALIZATION_NVP(height); + + ar& BOOST_SERIALIZATION_NVP(valid_sats); + ar& BOOST_SERIALIZATION_NVP(solution_status); + ar& BOOST_SERIALIZATION_NVP(solution_type); + ar& BOOST_SERIALIZATION_NVP(AR_ratio_factor); + ar& BOOST_SERIALIZATION_NVP(AR_ratio_threshold); + + ar& BOOST_SERIALIZATION_NVP(gdop); + ar& BOOST_SERIALIZATION_NVP(pdop); + ar& BOOST_SERIALIZATION_NVP(hdop); + ar& BOOST_SERIALIZATION_NVP(vdop); + } +}; + +#endif /* GNSS_SDR_MONITOR_PVT_H_ */ diff --git a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc new file mode 100644 index 000000000..2982ec401 --- /dev/null +++ b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc @@ -0,0 +1,98 @@ +/*! + * \file monitor_pvt_udp_sink.cc + * \brief Implementation of a class that sends serialized Monitor_Pvt + * objects over udp to one or multiple endpoints + * \author Álvaro Cebrián Juan, 2019. acebrianjuan(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "monitor_pvt_udp_sink.h" +#include +#include +#include + + +Monitor_Pvt_Udp_Sink::Monitor_Pvt_Udp_Sink(std::vector addresses, const uint16_t& port) : socket{io_service} +{ + for (const auto& address : addresses) + { + boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port); + endpoints.push_back(endpoint); + } + monitor_pvt.TOW_at_current_symbol_ms = 0U; + monitor_pvt.week = 0U; + monitor_pvt.RX_time = 0.0; + monitor_pvt.user_clk_offset = 0.0; + monitor_pvt.pos_x = 0.0; + monitor_pvt.pos_y = 0.0; + monitor_pvt.pos_z = 0.0; + monitor_pvt.vel_x = 0.0; + monitor_pvt.vel_y = 0.0; + monitor_pvt.vel_z = 0.0; + monitor_pvt.cov_xx = 0.0; + monitor_pvt.cov_yy = 0.0; + monitor_pvt.cov_zz = 0.0; + monitor_pvt.cov_xy = 0.0; + monitor_pvt.cov_yz = 0.0; + monitor_pvt.cov_zx = 0.0; + monitor_pvt.latitude = 0.0; + monitor_pvt.longitude = 0.0; + monitor_pvt.height = 0.0; + monitor_pvt.valid_sats = 0; + monitor_pvt.solution_status = 0; + monitor_pvt.solution_type = 0; + monitor_pvt.AR_ratio_factor = 0.0; + monitor_pvt.AR_ratio_threshold = 0.0; + monitor_pvt.gdop = 0.0; + monitor_pvt.pdop = 0.0; + monitor_pvt.hdop = 0.0; + monitor_pvt.vdop = 0.0; +} + + +bool Monitor_Pvt_Udp_Sink::write_monitor_pvt(const Monitor_Pvt& monitor_pvt) +{ + std::ostringstream archive_stream; + boost::archive::binary_oarchive oa{archive_stream}; + oa << monitor_pvt; + std::string outbound_data = archive_stream.str(); + + for (const auto& endpoint : endpoints) + { + socket.open(endpoint.protocol(), error); + socket.connect(endpoint, error); + + try + { + socket.send(boost::asio::buffer(outbound_data)); + } + catch (boost::system::system_error const& e) + { + return false; + } + } + return true; +} diff --git a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.h b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.h new file mode 100644 index 000000000..bf132bad4 --- /dev/null +++ b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.h @@ -0,0 +1,53 @@ +/*! + * \file monitor_pvt_udp_sink.h + * \brief Interface of a class that sends serialized Monitor_Pvt objects + * over udp to one or multiple endpoints + * \author Álvaro Cebrián Juan, 2019. acebrianjuan(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_MONITOR_PVT_UDP_SINK_H_ +#define GNSS_SDR_MONITOR_PVT_UDP_SINK_H_ + +#include "monitor_pvt.h" +#include + +class Monitor_Pvt_Udp_Sink +{ +public: + Monitor_Pvt_Udp_Sink(std::vector addresses, const uint16_t &port); + bool write_monitor_pvt(const Monitor_Pvt &monitor_pvt); + +private: + boost::asio::io_service io_service; + boost::asio::ip::udp::socket socket; + boost::system::error_code error; + std::vector endpoints; + Monitor_Pvt monitor_pvt; +}; + + +#endif /* GNSS_SDR_MONITOR_PVT_UDP_SINK_H_ */ diff --git a/src/algorithms/PVT/libs/nmea_printer.cc b/src/algorithms/PVT/libs/nmea_printer.cc index 56aad23af..bbef7b0c7 100644 --- a/src/algorithms/PVT/libs/nmea_printer.cc +++ b/src/algorithms/PVT/libs/nmea_printer.cc @@ -1,5 +1,5 @@ /*! - * \file kml_printer.cc + * \file nmea_printer.cc * \brief Implementation of a NMEA 2.1 printer for GNSS-SDR * This class provides a implementation of a subset of the NMEA-0183 standard for interfacing * marine electronic devices as defined by the National Marine Electronics Association (NMEA). @@ -34,8 +34,14 @@ */ #include "nmea_printer.h" +#include "rtklib_solution.h" #include +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem #include +#include +#include #include #include @@ -43,19 +49,61 @@ using google::LogMessage; -Nmea_Printer::Nmea_Printer(std::string filename, bool flag_nmea_tty_port, std::string nmea_dump_devname) +Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path) { - nmea_filename = filename; - nmea_file_descriptor.open(nmea_filename.c_str(), std::ios::out); - if (nmea_file_descriptor.is_open()) + nmea_base_path = base_path; + d_flag_nmea_output_file = flag_nmea_output_file; + if (d_flag_nmea_output_file == true) { - DLOG(INFO) << "NMEA printer writing on " << nmea_filename.c_str(); + boost::filesystem::path full_path(boost::filesystem::current_path()); + const boost::filesystem::path p(nmea_base_path); + if (!boost::filesystem::exists(p)) + { + std::string new_folder; + for (auto& folder : boost::filesystem::path(nmea_base_path)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + std::cout << "Could not create the " << new_folder << " folder." << std::endl; + nmea_base_path = full_path.string(); + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + } + else + { + nmea_base_path = p.string(); + } + + if ((nmea_base_path != ".") and (d_flag_nmea_output_file == true)) + { + std::cout << "NMEA files will be stored at " << nmea_base_path << std::endl; + } + + nmea_base_path = nmea_base_path + boost::filesystem::path::preferred_separator; + + nmea_filename = nmea_base_path + filename; + + nmea_file_descriptor.open(nmea_filename.c_str(), std::ios::out); + if (nmea_file_descriptor.is_open()) + { + DLOG(INFO) << "NMEA printer writing on " << nmea_filename.c_str(); + } + else + { + std::cout << "File " << nmea_filename << " cannot be saved. Wrong permissions?" << std::endl; + } } - nmea_devname = nmea_dump_devname; + nmea_devname = std::move(nmea_dump_devname); if (flag_nmea_tty_port == true) { - nmea_dev_descriptor = init_serial(nmea_devname.c_str()); + nmea_dev_descriptor = init_serial(nmea_devname); if (nmea_dev_descriptor != -1) { DLOG(INFO) << "NMEA printer writing on " << nmea_devname.c_str(); @@ -71,35 +119,61 @@ Nmea_Printer::Nmea_Printer(std::string filename, bool flag_nmea_tty_port, std::s Nmea_Printer::~Nmea_Printer() { - if (nmea_file_descriptor.is_open()) + try { - nmea_file_descriptor.close(); + if (nmea_file_descriptor.is_open()) + { + nmea_file_descriptor.close(); + } + } + catch (const std::ofstream::failure& e) + { + std::cerr << "Problem closing NMEA dump file: " << nmea_filename << '\n'; + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } + try + { + close_serial(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; } - close_serial(); } -int Nmea_Printer::init_serial(std::string serial_device) +int Nmea_Printer::init_serial(const std::string& serial_device) { /*! * Opens the serial device and sets the default baud rate for a NMEA transmission (9600,8,N,1) */ int fd = 0; - struct termios options; - long BAUD; - long DATABITS; - long STOPBITS; - long PARITYON; - long PARITY; + struct termios options + { + }; + int64_t BAUD; + int64_t DATABITS; + int64_t STOPBITS; + int64_t PARITYON; + int64_t PARITY; - fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY); - if (fd == -1) return fd; //failed to open TTY port + fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC); + if (fd == -1) + { + return fd; // failed to open TTY port + } - if (fcntl(fd, F_SETFL, 0) == -1) LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O - tcgetattr(fd, &options); // read serial port options + if (fcntl(fd, F_SETFL, 0) == -1) + { + LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O + } + tcgetattr(fd, &options); // read serial port options BAUD = B9600; - //BAUD = B38400; + // BAUD = B38400; DATABITS = CS8; STOPBITS = 0; PARITYON = 0; @@ -107,7 +181,7 @@ int Nmea_Printer::init_serial(std::string serial_device) options.c_cflag = BAUD | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD; // enable receiver, set 8 bit data, ignore control lines - //options.c_cflag |= (CLOCAL | CREAD | CS8); + // options.c_cflag |= (CLOCAL | CREAD | CS8); options.c_iflag = IGNPAR; // set the new port options @@ -125,7 +199,7 @@ void Nmea_Printer::close_serial() } -bool Nmea_Printer::Print_Nmea_Line(const std::shared_ptr& pvt_data, bool print_average_values) +bool Nmea_Printer::Print_Nmea_Line(const std::shared_ptr& pvt_data, bool print_average_values) { std::string GPRMC; std::string GPGGA; @@ -138,34 +212,36 @@ bool Nmea_Printer::Print_Nmea_Line(const std::shared_ptr& pvt_dat // generate the NMEA sentences - //GPRMC + // GPRMC GPRMC = get_GPRMC(); - //GPGGA (Global Positioning System Fixed Data) + // GPGGA (Global Positioning System Fixed Data) GPGGA = get_GPGGA(); - //GPGSA + // GPGSA GPGSA = get_GPGSA(); - //GPGSV + // GPGSV GPGSV = get_GPGSV(); // write to log file - try + if (d_flag_nmea_output_file) { - //GPRMC - nmea_file_descriptor << GPRMC; - //GPGGA (Global Positioning System Fixed Data) - nmea_file_descriptor << GPGGA; - //GPGSA - nmea_file_descriptor << GPGSA; - //GPGSV - nmea_file_descriptor << GPGSV; - } - catch (const std::exception& ex) - { - DLOG(INFO) << "NMEA printer can not write on output file" << nmea_filename.c_str(); - ; + try + { + // GPRMC + nmea_file_descriptor << GPRMC; + // GPGGA (Global Positioning System Fixed Data) + nmea_file_descriptor << GPGGA; + // GPGSA + nmea_file_descriptor << GPGSA; + // GPGSV + nmea_file_descriptor << GPGSV; + } + catch (const std::exception& ex) + { + DLOG(INFO) << "NMEA printer can not write on output file" << nmea_filename.c_str(); + } } - //write to serial device + // write to serial device if (nmea_dev_descriptor != -1) { if (write(nmea_dev_descriptor, GPRMC.c_str(), GPRMC.length()) == -1) @@ -197,9 +273,9 @@ char Nmea_Printer::checkSum(std::string sentence) { char check = 0; // iterate over the string, XOR each byte with the total sum: - for (unsigned int c = 0; c < sentence.length(); c++) + for (char c : sentence) { - check = char(check ^ sentence.at(c)); + check = char(check ^ c); } // return the result return check; @@ -283,7 +359,7 @@ std::string Nmea_Printer::longitude_to_hm(double longitude) std::string Nmea_Printer::get_UTC_NMEA_time(boost::posix_time::ptime d_position_UTC_time) { - //UTC Time: hhmmss.sss + // UTC Time: hhmmss.sss std::stringstream sentence_str; boost::posix_time::time_duration td = d_position_UTC_time.time_of_day(); @@ -297,13 +373,22 @@ std::string Nmea_Printer::get_UTC_NMEA_time(boost::posix_time::ptime d_position_ utc_seconds = td.seconds(); utc_milliseconds = td.total_milliseconds() - td.total_seconds() * 1000; - if (utc_hours < 10) sentence_str << "0"; // two digits for hours + if (utc_hours < 10) + { + sentence_str << "0"; // two digits for hours + } sentence_str << utc_hours; - if (utc_mins < 10) sentence_str << "0"; // two digits for minutes + if (utc_mins < 10) + { + sentence_str << "0"; // two digits for minutes + } sentence_str << utc_mins; - if (utc_seconds < 10) sentence_str << "0"; // two digits for seconds + if (utc_seconds < 10) + { + sentence_str << "0"; // two digits for seconds + } sentence_str << utc_seconds; if (utc_milliseconds < 10) @@ -328,184 +413,22 @@ std::string Nmea_Printer::get_UTC_NMEA_time(boost::posix_time::ptime d_position_ std::string Nmea_Printer::get_GPRMC() { // Sample -> $GPRMC,161229.487,A,3723.2475,N,12158.3416,W,0.13,309.62,120598,*10 - bool valid_fix = d_PVT_data->is_valid_position(); - - // ToDo: Compute speed and course over ground - double speed_over_ground_knots = 0; - double course_over_ground_deg = 0; - - //boost::posix_time::ptime d_position_UTC_time=boost::posix_time::microsec_clock::universal_time(); - std::stringstream sentence_str; - - //GPRMC (RMC-Recommended,Minimum Specific GNSS Data) - std::string sentence_header; - sentence_header = "$GPRMC,"; - sentence_str << sentence_header; - - //UTC Time: hhmmss.sss - sentence_str << get_UTC_NMEA_time(d_PVT_data->get_position_UTC_time()); - - //Status: A: data valid, V: data NOT valid - - if (valid_fix == true) - { - sentence_str << ",A"; - } - else - { - sentence_str << ",V"; - }; - - if (print_avg_pos == true) - { - // Latitude ddmm.mmmm,(N or S) - sentence_str << "," << latitude_to_hm(d_PVT_data->get_avg_latitude()); - // longitude dddmm.mmmm,(E or W) - sentence_str << "," << longitude_to_hm(d_PVT_data->get_avg_longitude()); - } - else - { - // Latitude ddmm.mmmm,(N or S) - sentence_str << "," << latitude_to_hm(d_PVT_data->get_latitude()); - // longitude dddmm.mmmm,(E or W) - sentence_str << "," << longitude_to_hm(d_PVT_data->get_longitude()); - } - - //Speed over ground (knots) - sentence_str << ","; - sentence_str.setf(std::ios::fixed, std::ios::floatfield); - sentence_str.precision(2); - sentence_str << speed_over_ground_knots; - - //course over ground (degrees) - sentence_str << ","; - sentence_str.setf(std::ios::fixed, std::ios::floatfield); - sentence_str.precision(2); - sentence_str << course_over_ground_deg; - - // Date ddmmyy - boost::gregorian::date sentence_date = d_PVT_data->get_position_UTC_time().date(); - unsigned int year = sentence_date.year(); - unsigned int day = sentence_date.day(); - unsigned int month = sentence_date.month(); - - sentence_str << ","; - sentence_str.width(2); - sentence_str.fill('0'); - sentence_str << day; - sentence_str.width(2); - sentence_str.fill('0'); - sentence_str << month; - - std::stringstream year_strs; - year_strs << std::dec << year; - sentence_str << std::dec << year_strs.str().substr(2); - - //Magnetic Variation (degrees) - // ToDo: Implement magnetic compass - sentence_str << ","; - - //Magnetic Variation (E or W) - // ToDo: Implement magnetic compass - sentence_str << ","; - - // Checksum - char checksum; - std::string tmpstr; - tmpstr = sentence_str.str(); - checksum = checkSum(tmpstr.substr(1)); - sentence_str << "*"; - sentence_str.width(2); - sentence_str.fill('0'); - sentence_str << std::hex << static_cast(checksum); - - // end NMEA sentence - sentence_str << "\r\n"; + unsigned char buff[1024] = {0}; + outnmea_rmc(buff, &d_PVT_data->pvt_sol); + sentence_str << buff; return sentence_str.str(); } std::string Nmea_Printer::get_GPGSA() { - //$GPGSA,A,3,07,02,26,27,09,04,15, , , , , ,1.8,1.0,1.5*33 + // $GPGSA,A,3,07,02,26,27,09,04,15, , , , , ,1.8,1.0,1.5*33 // GSA-GNSS DOP and Active Satellites - bool valid_fix = d_PVT_data->is_valid_position(); - int n_sats_used = d_PVT_data->get_num_valid_observations(); - double pdop = d_PVT_data->get_pdop(); - double hdop = d_PVT_data->get_hdop(); - double vdop = d_PVT_data->get_vdop(); - std::stringstream sentence_str; - std::string sentence_header; - sentence_header = "$GPGSA,"; - sentence_str << sentence_header; - - // mode1: - // (M) Manual-forced to operate in 2D or 3D mode - // (A) Automatic-allowed to automatically switch 2D/3D - std::string mode1 = "M"; - sentence_str << mode1; - - // mode2: - // 1 fix not available - // 2 fix 2D - // 3 fix 3D - if (valid_fix == true) - { - sentence_str << ",3"; - } - else - { - sentence_str << ",1"; - }; - - // Used satellites - for (int i = 0; i < 12; i++) - { - sentence_str << ","; - if (i < n_sats_used) - { - sentence_str.width(2); - sentence_str.fill('0'); - sentence_str << d_PVT_data->get_visible_satellites_ID(i); - } - } - - // PDOP - sentence_str << ","; - sentence_str.setf(std::ios::fixed, std::ios::floatfield); - sentence_str.width(2); - sentence_str.precision(1); - sentence_str.fill('0'); - sentence_str << pdop; - //HDOP - sentence_str << ","; - sentence_str.setf(std::ios::fixed, std::ios::floatfield); - sentence_str.width(2); - sentence_str.precision(1); - sentence_str.fill('0'); - sentence_str << hdop; - //VDOP - sentence_str << ","; - sentence_str.setf(std::ios::fixed, std::ios::floatfield); - sentence_str.width(2); - sentence_str.precision(1); - sentence_str.fill('0'); - sentence_str << vdop; - - // Checksum - char checksum; - std::string tmpstr; - tmpstr = sentence_str.str(); - checksum = checkSum(tmpstr.substr(1)); - sentence_str << "*"; - sentence_str.width(2); - sentence_str.fill('0'); - sentence_str << std::hex << static_cast(checksum); - - // end NMEA sentence - sentence_str << "\r\n"; + unsigned char buff[1024] = {0}; + outnmea_gsa(buff, &d_PVT_data->pvt_sol, d_PVT_data->pvt_ssat); + sentence_str << buff; return sentence_str.str(); } @@ -513,199 +436,22 @@ std::string Nmea_Printer::get_GPGSA() std::string Nmea_Printer::get_GPGSV() { // GSV-GNSS Satellites in View + // $GPGSV,2,1,07,07,79,048,42,02,51,062,43,26,36,256,42,27,27,138,42*71 // Notice that NMEA 2.1 only supports 12 channels - int n_sats_used = d_PVT_data->get_num_valid_observations(); std::stringstream sentence_str; - std::stringstream frame_str; - std::string sentence_header; - sentence_header = "$GPGSV,"; - char checksum; - std::string tmpstr; - - // 1st step: How many GPGSV frames we need? (up to 3) - // Each frame contains up to 4 satellites - int n_frames; - n_frames = std::ceil((static_cast(n_sats_used)) / 4.0); - - // generate the frames - int current_satellite = 0; - for (int i = 1; i < (n_frames + 1); i++) - { - frame_str.str(""); - frame_str << sentence_header; - - // number of messages - frame_str << n_frames; - - // message number - frame_str << ","; - frame_str << i; - - // total number of satellites in view - frame_str << ","; - frame_str.width(2); - frame_str.fill('0'); - frame_str << std::dec << n_sats_used; - - //satellites info - for (int j = 0; j < 4; j++) - { - // write satellite info - frame_str << ","; - frame_str.width(2); - frame_str.fill('0'); - frame_str << std::dec << d_PVT_data->get_visible_satellites_ID(current_satellite); - - frame_str << ","; - frame_str.width(2); - frame_str.fill('0'); - frame_str << std::dec << static_cast(d_PVT_data->get_visible_satellites_El(current_satellite)); - - frame_str << ","; - frame_str.width(3); - frame_str.fill('0'); - frame_str << std::dec << static_cast(d_PVT_data->get_visible_satellites_Az(current_satellite)); - - frame_str << ","; - frame_str.width(2); - frame_str.fill('0'); - frame_str << std::dec << static_cast(d_PVT_data->get_visible_satellites_CN0_dB(current_satellite)); - - current_satellite++; - - if (current_satellite == n_sats_used) - { - break; - } - } - - // frame checksum - tmpstr = frame_str.str(); - checksum = checkSum(tmpstr.substr(1)); - frame_str << "*"; - frame_str.width(2); - frame_str.fill('0'); - frame_str << std::hex << static_cast(checksum); - - // end NMEA sentence - frame_str << "\r\n"; - - //add frame to sentence - sentence_str << frame_str.str(); - } + unsigned char buff[1024] = {0}; + outnmea_gsv(buff, &d_PVT_data->pvt_sol, d_PVT_data->pvt_ssat); + sentence_str << buff; return sentence_str.str(); - //$GPGSV,2,1,07,07,79,048,42,02,51,062,43,26,36,256,42,27,27,138,42*71 } std::string Nmea_Printer::get_GPGGA() { - //boost::posix_time::ptime d_position_UTC_time=boost::posix_time::microsec_clock::universal_time(); - bool valid_fix = d_PVT_data->is_valid_position(); - int n_channels = d_PVT_data->get_num_valid_observations(); //d_nchannels - double hdop = d_PVT_data->get_hdop(); - double MSL_altitude; - - if (d_PVT_data->is_averaging() == true) - { - MSL_altitude = d_PVT_data->get_avg_height(); - } - else - { - MSL_altitude = d_PVT_data->get_height(); - } - std::stringstream sentence_str; - - //GPGGA (Global Positioning System Fixed Data) - std::string sentence_header; - sentence_header = "$GPGGA,"; - sentence_str << sentence_header; - - //UTC Time: hhmmss.sss - sentence_str << get_UTC_NMEA_time(d_PVT_data->get_position_UTC_time()); - - if (d_PVT_data->is_averaging() == true) - { - // Latitude ddmm.mmmm,(N or S) - sentence_str << "," << latitude_to_hm(d_PVT_data->get_avg_latitude()); - // longitude dddmm.mmmm,(E or W) - sentence_str << "," << longitude_to_hm(d_PVT_data->get_avg_longitude()); - } - else - { - // Latitude ddmm.mmmm,(N or S) - sentence_str << "," << latitude_to_hm(d_PVT_data->get_latitude()); - // longitude dddmm.mmmm,(E or W) - sentence_str << "," << longitude_to_hm(d_PVT_data->get_longitude()); - } - - // Position fix indicator - // 0 - Fix not available or invalid - // 1 - GPS SPS Mode, fix valid - // 2 - Differential GPS, SPS Mode, fix valid - // 3-5 - Not supported - // 6 - Dead Reckoning Mode, fix valid - // ToDo: Update PVT module to identify the fix mode - - if (valid_fix == true) - { - sentence_str << ",1"; - } - else - { - sentence_str << ",0"; - } - - // Number of satellites used in PVT - sentence_str << ","; - if (n_channels < 10) - { - sentence_str << '0' << n_channels; - } - else - { - sentence_str << n_channels; - } - - // HDOP - sentence_str << ","; - sentence_str.setf(std::ios::fixed, std::ios::floatfield); - sentence_str.width(2); - sentence_str.precision(1); - sentence_str.fill('0'); - sentence_str << hdop; - - // MSL Altitude - sentence_str << ","; - sentence_str.precision(1); - sentence_str << MSL_altitude; - sentence_str << ",M"; - - // Geoid-to-ellipsoid separation. Ellipsoid altitude = MSL Altitude + Geoid Separation. - // ToDo: Compute this value - sentence_str << ","; - sentence_str << "0.0"; - sentence_str << ",M"; - - // Age of Diff. Corr. (Seconds) Null fields when DGPS is not used - // Diff. Ref. Station ID (0000) - // ToDo: Implement this fields for Differential GPS - sentence_str << ","; - sentence_str << "0.0,0000"; - - // Checksum - char checksum; - std::string tmpstr; - tmpstr = sentence_str.str(); - checksum = checkSum(tmpstr.substr(1)); - sentence_str << "*"; - sentence_str.width(2); - sentence_str.fill('0'); - sentence_str << std::hex << static_cast(checksum); - - // end NMEA sentence - sentence_str << "\r\n"; + unsigned char buff[1024] = {0}; + outnmea_gga(buff, &d_PVT_data->pvt_sol); + sentence_str << buff; return sentence_str.str(); - //$GPGGA,104427.591,5920.7009,N,01803.2938,E,1,05,3.3,78.2,M,23.2,M,0.0,0000*4A + // $GPGGA,104427.591,5920.7009,N,01803.2938,E,1,05,3.3,78.2,M,23.2,M,0.0,0000*4A } diff --git a/src/algorithms/PVT/libs/nmea_printer.h b/src/algorithms/PVT/libs/nmea_printer.h index 318745e1c..6ceab023c 100644 --- a/src/algorithms/PVT/libs/nmea_printer.h +++ b/src/algorithms/PVT/libs/nmea_printer.h @@ -38,6 +38,7 @@ #include "rtklib_solver.h" #include +#include #include @@ -53,12 +54,12 @@ public: /*! * \brief Default constructor. */ - Nmea_Printer(std::string filename, bool flag_nmea_tty_port, std::string nmea_dump_filename); + Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path = "."); /*! * \brief Print NMEA PVT and satellite info to the initialized device */ - bool Print_Nmea_Line(const std::shared_ptr& position, bool print_average_values); + bool Print_Nmea_Line(const std::shared_ptr& pvt_data, bool print_average_values); /*! * \brief Default destructor. @@ -66,12 +67,13 @@ public: ~Nmea_Printer(); private: - std::string nmea_filename; // String with the NMEA log filename + std::string nmea_filename; // String with the NMEA log filename + std::string nmea_base_path; std::ofstream nmea_file_descriptor; // Output file stream for NMEA log file std::string nmea_devname; int nmea_dev_descriptor; // NMEA serial device descriptor (i.e. COM port) - std::shared_ptr d_PVT_data; - int init_serial(std::string serial_device); //serial port control + std::shared_ptr d_PVT_data; + int init_serial(const std::string& serial_device); //serial port control void close_serial(); std::string get_GPGGA(); // fix data std::string get_GPGSV(); // satellite data @@ -82,6 +84,7 @@ private: std::string latitude_to_hm(double lat); char checkSum(std::string sentence); bool print_avg_pos; + bool d_flag_nmea_output_file; }; #endif diff --git a/src/algorithms/PVT/libs/pvt_conf.cc b/src/algorithms/PVT/libs/pvt_conf.cc new file mode 100644 index 000000000..6a1e1023c --- /dev/null +++ b/src/algorithms/PVT/libs/pvt_conf.cc @@ -0,0 +1,73 @@ +/*! + * \file pvt_conf.cc + * \brief Class that contains all the configuration parameters for a PVT block + * \author Carles Fernandez, 2018. cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "pvt_conf.h" + +Pvt_Conf::Pvt_Conf() +{ + type_of_receiver = 0U; + output_rate_ms = 0; + display_rate_ms = 0; + + rinex_version = 0; + rinexobs_rate_ms = 0; + rinexnav_rate_ms = 0; + + dump = false; + dump_mat = true; + + flag_nmea_tty_port = false; + + flag_rtcm_server = false; + flag_rtcm_tty_port = false; + rtcm_tcp_port = 0U; + rtcm_station_id = 0U; + + output_enabled = true; + rinex_output_enabled = true; + gpx_output_enabled = true; + geojson_output_enabled = true; + nmea_output_file_enabled = true; + kml_output_enabled = true; + xml_output_enabled = true; + rtcm_output_file_enabled = true; + + output_path = std::string("."); + rinex_output_path = std::string("."); + gpx_output_path = std::string("."); + geojson_output_path = std::string("."); + nmea_output_file_path = std::string("."); + kml_output_path = std::string("."); + xml_output_path = std::string("."); + rtcm_output_file_path = std::string("."); + + monitor_enabled = false; + udp_port = 0; +} diff --git a/src/algorithms/PVT/libs/pvt_conf.h b/src/algorithms/PVT/libs/pvt_conf.h new file mode 100644 index 000000000..45c960c2f --- /dev/null +++ b/src/algorithms/PVT/libs/pvt_conf.h @@ -0,0 +1,90 @@ +/*! + * \file pvt_conf.h + * \brief Class that contains all the configuration parameters for the PVT block + * \author Carles Fernandez, 2018. cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_PVT_CONF_H_ +#define GNSS_SDR_PVT_CONF_H_ + +#include +#include +#include +#include + +class Pvt_Conf +{ +public: + uint32_t type_of_receiver; + int32_t output_rate_ms; + int32_t display_rate_ms; + + int32_t rinex_version; + int32_t rinexobs_rate_ms; + int32_t rinexnav_rate_ms; + std::map rtcm_msg_rate_ms; + + bool dump; + bool dump_mat; + std::string dump_filename; + + bool flag_nmea_tty_port; + std::string nmea_dump_filename; + std::string nmea_dump_devname; + + bool flag_rtcm_server; + bool flag_rtcm_tty_port; + uint16_t rtcm_tcp_port; + uint16_t rtcm_station_id; + std::string rtcm_dump_devname; + + bool output_enabled; + bool rinex_output_enabled; + bool gpx_output_enabled; + bool geojson_output_enabled; + bool nmea_output_file_enabled; + bool kml_output_enabled; + bool xml_output_enabled; + bool rtcm_output_file_enabled; + + std::string output_path; + std::string rinex_output_path; + std::string gpx_output_path; + std::string geojson_output_path; + std::string nmea_output_file_path; + std::string kml_output_path; + std::string xml_output_path; + std::string rtcm_output_file_path; + + bool monitor_enabled; + std::string udp_addresses; + int udp_port; + + Pvt_Conf(); +}; + +#endif diff --git a/src/algorithms/PVT/libs/pvt_solution.cc b/src/algorithms/PVT/libs/pvt_solution.cc index d0f31cc39..b1366a751 100644 --- a/src/algorithms/PVT/libs/pvt_solution.cc +++ b/src/algorithms/PVT/libs/pvt_solution.cc @@ -31,6 +31,7 @@ #include "pvt_solution.h" #include "GPS_L1_CA.h" +#include "geofunctions.h" #include #include @@ -43,6 +44,8 @@ Pvt_Solution::Pvt_Solution() d_latitude_d = 0.0; d_longitude_d = 0.0; d_height_m = 0.0; + d_speed_over_ground_m_s = 0.0; + d_course_over_ground_d = 0.0; d_avg_latitude_d = 0.0; d_avg_longitude_d = 0.0; d_avg_height_m = 0.0; @@ -73,16 +76,9 @@ arma::vec Pvt_Solution::rotateSatellite(double const traveltime, const arma::vec omegatau = OMEGA_EARTH_DOT * traveltime; //--- Build a rotation matrix ---------------------------------------------- - arma::mat R3 = arma::zeros(3, 3); - R3(0, 0) = cos(omegatau); - R3(0, 1) = sin(omegatau); - R3(0, 2) = 0.0; - R3(1, 0) = -sin(omegatau); - R3(1, 1) = cos(omegatau); - R3(1, 2) = 0.0; - R3(2, 0) = 0.0; - R3(2, 1) = 0.0; - R3(2, 2) = 1; + arma::mat R3 = {{cos(omegatau), sin(omegatau), 0.0}, + {-sin(omegatau), cos(omegatau), 0.0}, + {0.0, 0.0, 1.0}}; //--- Do the rotation ------------------------------------------------------ arma::vec X_sat_rot; @@ -133,125 +129,7 @@ int Pvt_Solution::cart2geo(double X, double Y, double Z, int elipsoid_selection) d_latitude_d = phi * 180.0 / GPS_PI; d_longitude_d = lambda * 180.0 / GPS_PI; d_height_m = h; - return 0; -} - - -int Pvt_Solution::togeod(double *dphi, double *dlambda, double *h, double a, double finv, double X, double Y, double Z) -{ - /* Subroutine to calculate geodetic coordinates latitude, longitude, - height given Cartesian coordinates X,Y,Z, and reference ellipsoid - values semi-major axis (a) and the inverse of flattening (finv). - - The output units of angular quantities will be in decimal degrees - (15.5 degrees not 15 deg 30 min). The output units of h will be the - same as the units of X,Y,Z,a. - - Inputs: - a - semi-major axis of the reference ellipsoid - finv - inverse of flattening of the reference ellipsoid - X,Y,Z - Cartesian coordinates - - Outputs: - dphi - latitude - dlambda - longitude - h - height above reference ellipsoid - - Based in a Matlab function by Kai Borre - */ - - *h = 0; - double tolsq = 1.e-10; // tolerance to accept convergence - int maxit = 10; // max number of iterations - double rtd = 180.0 / GPS_PI; - - // compute square of eccentricity - double esq; - if (finv < 1.0E-20) - { - esq = 0.0; - } - else - { - esq = (2.0 - 1.0 / finv) / finv; - } - - // first guess - double P = sqrt(X * X + Y * Y); // P is distance from spin axis - - //direct calculation of longitude - if (P > 1.0E-20) - { - *dlambda = atan2(Y, X) * rtd; - } - else - { - *dlambda = 0.0; - } - - // correct longitude bound - if (*dlambda < 0) - { - *dlambda = *dlambda + 360.0; - } - - double r = sqrt(P * P + Z * Z); // r is distance from origin (0,0,0) - - double sinphi; - if (r > 1.0E-20) - { - sinphi = Z / r; - } - else - { - sinphi = 0.0; - } - *dphi = asin(sinphi); - - // initial value of height = distance from origin minus - // approximate distance from origin to surface of ellipsoid - if (r < 1.0E-20) - { - *h = 0; - return 1; - } - - *h = r - a * (1 - sinphi * sinphi / finv); - - // iterate - double cosphi; - double N_phi; - double dP; - double dZ; - double oneesq = 1.0 - esq; - - for (int i = 0; i < maxit; i++) - { - sinphi = sin(*dphi); - cosphi = cos(*dphi); - - // compute radius of curvature in prime vertical direction - N_phi = a / sqrt(1 - esq * sinphi * sinphi); - - // compute residuals in P and Z - dP = P - (N_phi + (*h)) * cosphi; - dZ = Z - (N_phi * oneesq + (*h)) * sinphi; - - // update height and latitude - *h = *h + (sinphi * dZ + cosphi * dP); - *dphi = *dphi + (cosphi * dZ - sinphi * dP) / (N_phi + (*h)); - - // test for convergence - if ((dP * dP + dZ * dZ) < tolsq) - { - break; - } - if (i == (maxit - 1)) - { - LOG(WARNING) << "The computation of geodetic coordinates did not converge"; - } - } - *dphi = (*dphi) * rtd; + //todo: refactor this class. Mix of duplicated functions, use either RTKLIB geodetic functions or geofunctions.h return 0; } @@ -310,7 +188,7 @@ int Pvt_Solution::tropo(double *ddr_m, double sinel, double hsta_km, double p_mb double b; double rtop; - while (1) + while (true) { rtop = pow((a_e + htop), 2) - pow((a_e + hsta_km), 2) * (1 - pow(sinel, 2)); @@ -363,83 +241,6 @@ int Pvt_Solution::tropo(double *ddr_m, double sinel, double hsta_km, double p_mb } -int Pvt_Solution::topocent(double *Az, double *El, double *D, const arma::vec &x, const arma::vec &dx) -{ - /* Transformation of vector dx into topocentric coordinate - system with origin at x - Inputs: - x - vector origin coordinates (in ECEF system [X; Y; Z;]) - dx - vector ([dX; dY; dZ;]). - - Outputs: - D - vector length. Units like the input - Az - azimuth from north positive clockwise, degrees - El - elevation angle, degrees - - Based on a Matlab function by Kai Borre - */ - - double lambda; - double phi; - double h; - double dtr = GPS_PI / 180.0; - double a = 6378137.0; // semi-major axis of the reference ellipsoid WGS-84 - double finv = 298.257223563; // inverse of flattening of the reference ellipsoid WGS-84 - - // Transform x into geodetic coordinates - Pvt_Solution::togeod(&phi, &lambda, &h, a, finv, x(0), x(1), x(2)); - - double cl = cos(lambda * dtr); - double sl = sin(lambda * dtr); - double cb = cos(phi * dtr); - double sb = sin(phi * dtr); - - arma::mat F = arma::zeros(3, 3); - - F(0, 0) = -sl; - F(0, 1) = -sb * cl; - F(0, 2) = cb * cl; - - F(1, 0) = cl; - F(1, 1) = -sb * sl; - F(1, 2) = cb * sl; - - F(2, 0) = 0; - F(2, 1) = cb; - F(2, 2) = sb; - - arma::vec local_vector; - - local_vector = arma::htrans(F) * dx; - - double E = local_vector(0); - double N = local_vector(1); - double U = local_vector(2); - - double hor_dis; - hor_dis = sqrt(E * E + N * N); - - if (hor_dis < 1.0E-20) - { - *Az = 0; - *El = 90; - } - else - { - *Az = atan2(E, N) / dtr; - *El = atan2(U, hor_dis) / dtr; - } - - if (*Az < 0) - { - *Az = *Az + 360.0; - } - - *D = sqrt(dx(0) * dx(0) + dx(1) * dx(1) + dx(2) * dx(2)); - return 0; -} - - void Pvt_Solution::set_averaging_depth(int depth) { d_averaging_depth = depth; @@ -534,6 +335,30 @@ double Pvt_Solution::get_height() const } +double Pvt_Solution::get_speed_over_ground() const +{ + return d_speed_over_ground_m_s; +} + + +void Pvt_Solution::set_speed_over_ground(double speed_m_s) +{ + d_speed_over_ground_m_s = speed_m_s; +} + + +void Pvt_Solution::set_course_over_ground(double cog_deg) +{ + d_course_over_ground_d = cog_deg; +} + + +double Pvt_Solution::get_course_over_ground() const +{ + return d_course_over_ground_d; +} + + double Pvt_Solution::get_avg_latitude() const { return d_avg_latitude_d; @@ -557,6 +382,7 @@ bool Pvt_Solution::is_averaging() const return d_flag_averaging; } + bool Pvt_Solution::is_valid_position() const { return b_valid_position; @@ -606,172 +432,3 @@ void Pvt_Solution::set_num_valid_observations(int num) { d_valid_observations = num; } - - -bool Pvt_Solution::set_visible_satellites_ID(size_t index, unsigned int prn) -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Setting sat ID to channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return false; - } - else - { - if (prn >= PVT_MAX_PRN) - { - LOG(WARNING) << "Setting to channel " << index << " a PRN of " << prn << " (the maximum is " << PVT_MAX_PRN << ")"; - return false; - } - else - { - d_visible_satellites_IDs[index] = prn; - return true; - } - } -} - - -unsigned int Pvt_Solution::get_visible_satellites_ID(size_t index) const -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Getting sat ID for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return 0; - } - else - { - return d_visible_satellites_IDs[index]; - } -} - - -bool Pvt_Solution::set_visible_satellites_El(size_t index, double el) -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Setting sat elevation for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return false; - } - else - { - if (el > 90.0) - { - LOG(WARNING) << "Setting a sat elevation > 90 [degrees]. Saturating to 90"; - d_visible_satellites_El[index] = 90.0; - } - else - { - if (el < -90.0) - { - LOG(WARNING) << "Setting a sat elevation < -90 [degrees]. Saturating to -90"; - d_visible_satellites_El[index] = -90.0; - } - else - { - d_visible_satellites_El[index] = el; - } - } - return true; - } -} - - -double Pvt_Solution::get_visible_satellites_El(size_t index) const -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Getting sat elevation for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return 0.0; - } - else - { - return d_visible_satellites_El[index]; - } -} - - -bool Pvt_Solution::set_visible_satellites_Az(size_t index, double az) -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Getting sat azimuth for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return false; - } - else - { - d_visible_satellites_Az[index] = az; - return true; - } -} - - -double Pvt_Solution::get_visible_satellites_Az(size_t index) const -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Getting sat azimuth for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return 0.0; - } - else - { - return d_visible_satellites_Az[index]; - } -} - - -bool Pvt_Solution::set_visible_satellites_Distance(size_t index, double dist) -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Setting sat distance for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return false; - } - else - { - d_visible_satellites_Distance[index] = dist; - return true; - } -} - - -double Pvt_Solution::get_visible_satellites_Distance(size_t index) const -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Getting sat distance for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return 0.0; - } - else - { - return d_visible_satellites_Distance[index]; - } -} - - -bool Pvt_Solution::set_visible_satellites_CN0_dB(size_t index, double cn0) -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Setting sat Cn0 for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return false; - } - else - { - d_visible_satellites_CN0_dB[index] = cn0; - return true; - } -} - - -double Pvt_Solution::get_visible_satellites_CN0_dB(size_t index) const -{ - if (index >= PVT_MAX_CHANNELS) - { - LOG(WARNING) << "Getting received CN0 for channel " << index << " (the maximum is " << PVT_MAX_CHANNELS << ")"; - return 0.0; - } - else - { - return d_visible_satellites_CN0_dB[index]; - } -} diff --git a/src/algorithms/PVT/libs/pvt_solution.h b/src/algorithms/PVT/libs/pvt_solution.h index 958bf4668..7afd074d2 100644 --- a/src/algorithms/PVT/libs/pvt_solution.h +++ b/src/algorithms/PVT/libs/pvt_solution.h @@ -33,12 +33,10 @@ #define GNSS_SDR_PVT_SOLUTION_H_ +#include #include #include -#include -const unsigned int PVT_MAX_CHANNELS = 90; -const unsigned int PVT_MAX_PRN = 127; // 126 is SBAS /*! * \brief Base class for a PVT solution @@ -49,9 +47,11 @@ class Pvt_Solution private: double d_rx_dt_s; // RX time offset [s] - double d_latitude_d; // RX position Latitude WGS84 [deg] - double d_longitude_d; // RX position Longitude WGS84 [deg] - double d_height_m; // RX position height WGS84 [m] + double d_latitude_d; // RX position Latitude WGS84 [deg] + double d_longitude_d; // RX position Longitude WGS84 [deg] + double d_height_m; // RX position height WGS84 [m] + double d_speed_over_ground_m_s; // RX speed over ground [m/s] + double d_course_over_ground_d; // RX course over ground [deg] double d_avg_latitude_d; // Averaged latitude in degrees double d_avg_longitude_d; // Averaged longitude in degrees @@ -70,12 +70,6 @@ private: boost::posix_time::ptime d_position_UTC_time; int d_valid_observations; - int d_visible_satellites_IDs[PVT_MAX_CHANNELS] = {}; // Array with the IDs of the valid satellites - double d_visible_satellites_El[PVT_MAX_CHANNELS] = {}; // Array with the LOS Elevation of the valid satellites - double d_visible_satellites_Az[PVT_MAX_CHANNELS] = {}; // Array with the LOS Azimuth of the valid satellites - double d_visible_satellites_Distance[PVT_MAX_CHANNELS] = {}; // Array with the LOS Distance of the valid satellites - double d_visible_satellites_CN0_dB[PVT_MAX_CHANNELS] = {}; // Array with the IDs of the valid satellites - public: Pvt_Solution(); @@ -86,6 +80,12 @@ public: double get_longitude() const; //!< Get RX position Longitude WGS84 [deg] double get_height() const; //!< Get RX position height WGS84 [m] + double get_speed_over_ground() const; //!< Get RX speed over ground [m/s] + void set_speed_over_ground(double speed_m_s); //!< Set RX speed over ground [m/s] + + double get_course_over_ground() const; //!< Get RX course over ground [deg] + void set_course_over_ground(double cog_deg); //!< Set RX course over ground [deg] + double get_avg_latitude() const; //!< Get RX position averaged Latitude WGS84 [deg] double get_avg_longitude() const; //!< Get RX position averaged Longitude WGS84 [deg] double get_avg_height() const; //!< Get RX position averaged height WGS84 [m] @@ -102,21 +102,6 @@ public: int get_num_valid_observations() const; //!< Get the number of valid pseudorange observations (valid satellites) void set_num_valid_observations(int num); //!< Set the number of valid pseudorange observations (valid satellites) - bool set_visible_satellites_ID(size_t index, unsigned int prn); //!< Set the ID of the visible satellite index channel - unsigned int get_visible_satellites_ID(size_t index) const; //!< Get the ID of the visible satellite index channel - - bool set_visible_satellites_El(size_t index, double el); //!< Set the LOS Elevation, in degrees, of the visible satellite index channel - double get_visible_satellites_El(size_t index) const; //!< Get the LOS Elevation, in degrees, of the visible satellite index channel - - bool set_visible_satellites_Az(size_t index, double az); //!< Set the LOS Azimuth, in degrees, of the visible satellite index channel - double get_visible_satellites_Az(size_t index) const; //!< Get the LOS Azimuth, in degrees, of the visible satellite index channel - - bool set_visible_satellites_Distance(size_t index, double dist); //!< Set the LOS Distance of the visible satellite index channel - double get_visible_satellites_Distance(size_t index) const; //!< Get the LOS Distance of the visible satellite index channel - - bool set_visible_satellites_CN0_dB(size_t index, double cn0); //!< Set the CN0 in dB of the visible satellite index channel - double get_visible_satellites_CN0_dB(size_t index) const; //!< Get the CN0 in dB of the visible satellite index channel - //averaging void perform_pos_averaging(); void set_averaging_depth(int depth); //!< Set length of averaging window @@ -142,41 +127,6 @@ public: */ int cart2geo(double X, double Y, double Z, int elipsoid_selection); - /*! - * \brief Transformation of vector dx into topocentric coordinate system with origin at x - * - * \param[in] x Vector origin coordinates (in ECEF system [X; Y; Z;]) - * \param[in] dx Vector ([dX; dY; dZ;]). - * - * \param[out] D Vector length. Units like the input - * \param[out] Az Azimuth from north positive clockwise, degrees - * \param[out] El Elevation angle, degrees - * - * Based on a Matlab function by Kai Borre - */ - int topocent(double *Az, double *El, double *D, const arma::vec &x, const arma::vec &dx); - - /*! - * \brief Subroutine to calculate geodetic coordinates latitude, longitude, - * height given Cartesian coordinates X,Y,Z, and reference ellipsoid - * values semi-major axis (a) and the inverse of flattening (finv). - * - * The output units of angular quantities will be in decimal degrees - * (15.5 degrees not 15 deg 30 min). The output units of h will be the - * same as the units of X,Y,Z,a. - * - * \param[in] a - semi-major axis of the reference ellipsoid - * \param[in] finv - inverse of flattening of the reference ellipsoid - * \param[in] X,Y,Z - Cartesian coordinates - * - * \param[out] dphi - latitude - * \param[out] dlambda - longitude - * \param[out] h - height above reference ellipsoid - * - * Based in a Matlab function by Kai Borre - */ - int togeod(double *dphi, double *dlambda, double *h, double a, double finv, double X, double Y, double Z); - /*! * \brief Tropospheric correction * diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 859239096..10f552559 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -29,18 +29,21 @@ */ #include "rinex_printer.h" -#include #include #include -#include +#include +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem #include -#include // for getlogin_r() #include // for min and max #include // for floor #include // for getenv() +#include #include #include #include +#include // for getlogin_r() #include #include @@ -48,14 +51,45 @@ using google::LogMessage; -Rinex_Printer::Rinex_Printer(int conf_version) +Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path) { - navfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_GPS_NAV"); - obsfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_OBS"); - sbsfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_SBAS"); - navGalfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV"); - navMixfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV"); - navGlofilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_GLO_NAV"); + std::string base_rinex_path = base_path; + boost::filesystem::path full_path(boost::filesystem::current_path()); + const boost::filesystem::path p(base_rinex_path); + if (!boost::filesystem::exists(p)) + { + std::string new_folder; + for (auto& folder : boost::filesystem::path(base_rinex_path)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + std::cout << "Could not create the " << new_folder << " folder." << std::endl; + base_rinex_path = full_path.string(); + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + } + else + { + base_rinex_path = p.string(); + } + if (base_rinex_path != ".") + { + std::cout << "RINEX files will be stored at " << base_rinex_path << std::endl; + } + + navfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GPS_NAV"); + obsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_OBS"); + sbsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_SBAS"); + navGalfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV"); + navMixfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV"); + navGlofilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GLO_NAV"); + navBdsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_BDS_NAV"); Rinex_Printer::navFile.open(navfilename, std::ios::out | std::ios::in | std::ios::app); Rinex_Printer::obsFile.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); @@ -63,6 +97,15 @@ Rinex_Printer::Rinex_Printer(int conf_version) Rinex_Printer::navGalFile.open(navGalfilename, std::ios::out | std::ios::in | std::ios::app); Rinex_Printer::navMixFile.open(navMixfilename, std::ios::out | std::ios::in | std::ios::app); Rinex_Printer::navGloFile.open(navGlofilename, std::ios::out | std::ios::in | std::ios::app); + Rinex_Printer::navBdsFile.open(navBdsfilename, std::ios::out | std::ios::in | std::ios::app); + + + if (!Rinex_Printer::navFile.is_open() or !Rinex_Printer::obsFile.is_open() or + !Rinex_Printer::sbsFile.is_open() or !Rinex_Printer::navGalFile.is_open() or + !Rinex_Printer::navMixFile.is_open() or !Rinex_Printer::navGloFile.is_open()) + { + std::cout << "RINEX files cannot be saved. Wrong permissions?" << std::endl; + } // RINEX v3.02 codes satelliteSystem["GPS"] = "G"; @@ -127,6 +170,8 @@ Rinex_Printer::Rinex_Printer(int conf_version) observationCode["COMPASS_E6_I"] = "6I"; observationCode["COMPASS_E6_Q"] = "6Q"; observationCode["COMPASS_E6_IQ"] = "6X"; + observationCode["BEIDOU_B1_I"] = "1I"; + observationCode["BEIDOU_B1_Q"] = "1Q"; observationType["PSEUDORANGE"] = "C"; observationType["CARRIER_PHASE"] = "L"; @@ -161,43 +206,76 @@ Rinex_Printer::Rinex_Printer(int conf_version) Rinex_Printer::~Rinex_Printer() { // close RINEX files - long posn, poso, poss, posng, posmn, posnr; + int64_t posn, poso, poss, posng, posmn, posnr, posnc; posn = navFile.tellp(); poso = obsFile.tellp(); poss = sbsFile.tellp(); posng = navGalFile.tellp(); posmn = navMixFile.tellp(); posnr = navGloFile.tellp(); - - Rinex_Printer::navFile.close(); - Rinex_Printer::obsFile.close(); - Rinex_Printer::sbsFile.close(); - Rinex_Printer::navGalFile.close(); - Rinex_Printer::navGloFile.close(); + posnc = navBdsFile.tellp(); + try + { + Rinex_Printer::navFile.close(); + Rinex_Printer::obsFile.close(); + Rinex_Printer::sbsFile.close(); + Rinex_Printer::navGalFile.close(); + Rinex_Printer::navGloFile.close(); + Rinex_Printer::navBdsFile.close(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } // If nothing written, erase the files. if (posn == 0) { - if (remove(navfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (poso == 0) { - if (remove(obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (poss == 0) { - if (remove(sbsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(sbsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (posng == 0) { - if (remove(navGalfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navGalfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (posmn == 0) { - if (remove(navMixfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navMixfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (posnr == 0) { - if (remove(navGlofilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navGlofilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } + } + if (posnc == 0) + { + if (remove(navBdsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } } @@ -214,14 +292,20 @@ void Rinex_Printer::lengthCheck(const std::string& line) } -std::string Rinex_Printer::createFilename(std::string type) +std::string Rinex_Printer::createFilename(const std::string& type) { const std::string stationName = "GSDR"; // 4-character station name designator boost::gregorian::date today = boost::gregorian::day_clock::local_day(); - const int dayOfTheYear = today.day_of_year(); + const int32_t dayOfTheYear = today.day_of_year(); std::stringstream strm0; - if (dayOfTheYear < 100) strm0 << "0"; // three digits for day of the year - if (dayOfTheYear < 10) strm0 << "0"; // three digits for day of the year + if (dayOfTheYear < 100) + { + strm0 << "0"; // three digits for day of the year + } + if (dayOfTheYear < 10) + { + strm0 << "0"; // three digits for day of the year + } strm0 << dayOfTheYear; std::string dayOfTheYearTag = strm0.str(); @@ -236,10 +320,12 @@ std::string Rinex_Printer::createFilename(std::string type) fileType.insert(std::pair("RINEX_FILE_TYPE_SBAS", "B")); // B - SBAS broadcast data file. fileType.insert(std::pair("RINEX_FILE_TYPE_CLK", "C")); // C - Clock file. fileType.insert(std::pair("RINEX_FILE_TYPE_SUMMARY", "S")); // S - Summary file (used e.g., by IGS, not a standard!). + fileType.insert(std::pair("RINEX_FILE_TYPE_BDS_NAV", "F")); // G - GLONASS navigation file. + boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); tm pt_tm = boost::posix_time::to_tm(pt); - int local_hour = pt_tm.tm_hour; + int32_t local_hour = pt_tm.tm_hour; std::stringstream strm; strm << local_hour; @@ -271,14 +357,17 @@ std::string Rinex_Printer::createFilename(std::string type) std::string hourTag = Hmap[strm.str()]; - int local_minute = pt_tm.tm_min; + int32_t local_minute = pt_tm.tm_min; std::stringstream strm2; - if (local_minute < 10) strm2 << "0"; // at least two digits for minutes + if (local_minute < 10) + { + strm2 << "0"; // at least two digits for minutes + } strm2 << local_minute; std::string minTag = strm2.str(); - int local_year = pt_tm.tm_year - 100; // 2012 is 112 + int32_t local_year = pt_tm.tm_year - 100; // 2012 is 112 std::stringstream strm3; strm3 << local_year; std::string yearTag = strm3.str(); @@ -297,7 +386,7 @@ std::string Rinex_Printer::getLocalTime() line += std::string(12, ' '); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -314,22 +403,28 @@ std::string Rinex_Printer::getLocalTime() tm pt_tm = boost::local_time::to_tm(pt); std::stringstream strmHour; - int utc_hour = pt_tm.tm_hour; - if (utc_hour < 10) strmHour << "0"; // two digits for hours + int32_t utc_hour = pt_tm.tm_hour; + if (utc_hour < 10) + { + strmHour << "0"; // two digits for hours + } strmHour << utc_hour; std::stringstream strmMin; - int utc_minute = pt_tm.tm_min; - if (utc_minute < 10) strmMin << "0"; // two digits for minutes + int32_t utc_minute = pt_tm.tm_min; + if (utc_minute < 10) + { + strmMin << "0"; // two digits for minutes + } strmMin << utc_minute; if (version == 2) { - int day = pt_tm.tm_mday; - line += Rinex_Printer::rightJustify(boost::lexical_cast(day), 2); + int32_t day = pt_tm.tm_mday; + line += Rinex_Printer::rightJustify(std::to_string(day), 2); line += std::string("-"); - std::map months; + std::map months; months[0] = "JAN"; months[1] = "FEB"; months[2] = "MAR"; @@ -345,7 +440,7 @@ std::string Rinex_Printer::getLocalTime() line += months[pt_tm.tm_mon]; line += std::string("-"); - line += boost::lexical_cast(pt_tm.tm_year - 100); + line += std::to_string(pt_tm.tm_year - 100); line += std::string(1, ' '); line += strmHour.str(); line += std::string(":"); @@ -361,8 +456,11 @@ std::string Rinex_Printer::getLocalTime() line += strmMin.str(); std::stringstream strm2; - int utc_seconds = pt_tm.tm_sec; - if (utc_seconds < 10) strm2 << "0"; // two digits for seconds + int32_t utc_seconds = pt_tm.tm_sec; + if (utc_seconds < 10) + { + strm2 << "0"; // two digits for seconds + } strm2 << utc_seconds; line += strm2.str(); line += std::string(1, ' '); @@ -428,8 +526,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_M line += std::string(1, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -441,8 +539,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_M line += std::string(1, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 17); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -477,6 +575,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_M out << line << std::endl; } + void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac) { if (glonass_gnav_almanac.i_satellite_freq_channel) @@ -548,8 +647,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += std::string(1, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -561,8 +660,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += std::string(1, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 17); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -573,8 +672,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += std::string("GPUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_t_OT), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -583,10 +682,10 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono // -------- Line 6 leap seconds // For leap second information, see http://www.endruntechnologies.com/leap.htm line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_DN), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_DN), 6); line += std::string(36, ' '); line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); Rinex_Printer::lengthCheck(line); @@ -672,8 +771,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps line += std::string(1, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -685,8 +784,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps line += std::string(1, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 17); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -697,8 +796,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps line += std::string("GPUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_t_OT), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -707,10 +806,10 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps // -------- Line 6 leap seconds // For leap second information, see http://www.endruntechnologies.com/leap.htm line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_DN), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_DN), 6); line += std::string(36, ' '); line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); Rinex_Printer::lengthCheck(line); @@ -725,13 +824,13 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps } -void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac) +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac) { if (glonass_gnav_almanac.i_satellite_freq_channel) { } //Avoid compiler warning //Avoid compiler warning, there is not time system correction between Galileo and GLONASS - if (galileo_almanac.A_0G_10) + if (galileo_utc_model.A_0G_10) { } std::string line; @@ -798,8 +897,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali line += std::string("GAUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.t0t_6), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WNot_6), 5); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t0t_6), 7); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot_6), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -811,8 +910,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali line += std::string(1, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -821,10 +920,10 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali // -------- Line 6 leap seconds // For leap second information, see http://www.endruntechnologies.com/leap.htm line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLS_6), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLSF_6), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WN_LSF_6), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.DN_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN_6), 6); line += std::string(36, ' '); line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); Rinex_Printer::lengthCheck(line); @@ -839,7 +938,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali } -void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac) +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono, const Galileo_Utc_Model& utc_model) { std::string line; @@ -905,8 +1004,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono line += std::string("GAUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0_6, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1_6, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.t0t_6), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.WNot_6), 5); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.t0t_6), 7); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.WNot_6), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -915,10 +1014,10 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono // -------- Line system time correction 2 line.clear(); line += std::string("GPGA"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_0G_10, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_1G_10, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.t_0G_10), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.WN_0G_10), 5); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_0G_10, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_1G_10, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.t_0G_10), 7); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_0G_10), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -927,10 +1026,10 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono // -------- Line 6 leap seconds // For leap second information, see http://www.endruntechnologies.com/leap.htm line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.Delta_tLS_6), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.Delta_tLSF_6), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.WN_LSF_6), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.DN_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLS_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLSF_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.DN_6), 6); line += std::string(36, ' '); line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); Rinex_Printer::lengthCheck(line); @@ -1023,8 +1122,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& ion line += std::string("GPUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 5); // valid until 2019 + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 5); // valid until 2019 /* if ( SBAS ) { line += string(1, ' '); @@ -1043,10 +1142,142 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& ion // -------- Line 6 leap seconds // For leap second information, see http://www.endruntechnologies.com/leap.htm line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); + line += std::string(36, ' '); + line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- End of Header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& iono, const Gps_CNAV_Utc_Model& utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model) +{ + std::string line; + + // -------- Line 1 + line = std::string(5, ' '); + line += stringVersion; + line += std::string(11, ' '); + line += std::string("N: GNSS NAV DATA"); + line += std::string(4, ' '); + line += std::string("M: MIXED"); + line += std::string(12, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1 + line.clear(); + line += std::string("GAL "); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); + double zero = 0.0; + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 2 + line.clear(); + line += std::string("GPSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 3 + line.clear(); + line += std::string("GPSB"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line system time correction + line.clear(); + line += std::string("GAUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t0t_6), 7); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot_6), 5); + line += std::string(10, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line system time correction 2 + line.clear(); + line += std::string("GPUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 5); // valid until 2019 + line += std::string(10, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 6 leap seconds + // For leap second information, see http://www.endruntechnologies.com/leap.htm + line.clear(); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); line += std::string(36, ' '); line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); Rinex_Printer::lengthCheck(line); @@ -1181,8 +1412,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co line += std::string(3, ' '); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 18, 2), 19); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 18, 2), 19); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 9); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 9); // valid until 2019 + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 9); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 9); // valid until 2019 line += std::string(1, ' '); line += Rinex_Printer::leftJustify("DELTA-UTC: A0,A1,T,W", 20); } @@ -1192,8 +1423,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co line += std::string("GPUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 5); // valid until 2019 + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 5); // valid until 2019 /* if ( SBAS ) { line += string(1, ' '); @@ -1213,16 +1444,16 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co // -------- Line 6 leap seconds // For leap second information, see http://www.endruntechnologies.com/leap.htm line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); if (version == 2) { line += std::string(54, ' '); } if (version == 3) { - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); line += std::string(36, ' '); } line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); @@ -1238,7 +1469,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co } -void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model) { std::string line; @@ -1317,8 +1548,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += std::string("GAUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.t0t_6), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WNot_6), 5); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t0t_6), 7); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot_6), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -1327,10 +1558,10 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono // -------- Line system time correction 2 line.clear(); line += std::string("GPGA"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_0G_10, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_1G_10, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.t_0G_10), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.WN_0G_10), 5); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_0G_10, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_1G_10, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t_0G_10), 7); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_0G_10), 5); line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -1341,8 +1572,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += std::string("GPUT"); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_t_OT), 7); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 line += std::string(10, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); Rinex_Printer::lengthCheck(line); @@ -1351,10 +1582,124 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono // -------- Line 6 leap seconds // For leap second information, see http://www.endruntechnologies.com/leap.htm line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_LSF), 6); - line += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_DN), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_DN), 6); + line += std::string(36, ' '); + line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- End of Header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& iono, const Beidou_Dnav_Utc_Model& utc_model) +{ + std::string line; + + // -------- Line 1 + line = std::string(5, ' '); + line += stringVersion; + line += std::string(11, ' '); + + if (version == 3) + { + line += std::string("N: GNSS NAV DATA"); + line += std::string(4, ' '); + //! \todo Add here other systems... + line += std::string("F: BDS"); + line += std::string(14, ' '); + // ... + } + + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 3 + line.clear(); + line += Rinex_Printer::leftJustify("BDS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1, only version 3 supported + line.clear(); + line += std::string("BDSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 2 + line.clear(); + line += std::string("BDSB"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 5 system time correction + line.clear(); + line += std::string("BDUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0_UTC, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1_UTC, 15, 2), 16); + line += std::string(22, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 6 leap seconds + // For leap second information, see http://www.endruntechnologies.com/leap.htm + line.clear(); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); line += std::string(36, ' '); line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); Rinex_Printer::lengthCheck(line); @@ -1390,7 +1735,7 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) line += Rinex_Printer::leftJustify("GNSS-SDR", 20); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -1405,24 +1750,36 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) boost::local_time::local_date_time pt = boost::local_time::local_sec_clock::local_time(zone); tm pt_tm = boost::local_time::to_tm(pt); std::stringstream strYear; - int utc_year = pt.date().year(); + int32_t utc_year = pt.date().year(); utc_year -= 2000; // two digits for year strYear << utc_year; std::stringstream strMonth; - int utc_month = pt.date().month().as_number(); - if (utc_month < 10) strMonth << "0"; // two digits for months + int32_t utc_month = pt.date().month().as_number(); + if (utc_month < 10) + { + strMonth << "0"; // two digits for months + } strMonth << utc_month; std::stringstream strmDay; - int utc_day = pt.date().day().as_number(); - if (utc_day < 10) strmDay << "0"; // two digits for days + int32_t utc_day = pt.date().day().as_number(); + if (utc_day < 10) + { + strmDay << "0"; // two digits for days + } strmDay << utc_day; std::stringstream strmHour; - int utc_hour = pt_tm.tm_hour; - if (utc_hour < 10) strmHour << "0"; // two digits for hours + int32_t utc_hour = pt_tm.tm_hour; + if (utc_hour < 10) + { + strmHour << "0"; // two digits for hours + } strmHour << utc_hour; std::stringstream strmMin; - int utc_minute = pt_tm.tm_min; - if (utc_minute < 10) strmMin << "0"; // two digits for minutes + int32_t utc_minute = pt_tm.tm_min; + if (utc_minute < 10) + { + strmMin << "0"; // two digits for minutes + } strmMin << utc_minute; std::string time_str; time_str += strmDay.str(); @@ -1485,7 +1842,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -1505,8 +1862,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ line_aux += std::string("GLUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -1516,8 +1873,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ line_aux += std::string("GLGP"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -1541,7 +1898,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ out.close(); out.open(navGlofilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < static_cast(data.size()) - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -1552,12 +1909,12 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ } -void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac) +void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model) { std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -1590,8 +1947,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal line_aux += std::string("GAUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0_6, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1_6, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.t0t_6), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.WNot_6), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.t0t_6), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WNot_6), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -1599,20 +1956,20 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { line_aux += std::string("GPGA"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_0G_10, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_1G_10, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.t_0G_10), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.WN_0G_10), 5); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_0G_10, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_1G_10, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.t_0G_10), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_0G_10), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.Delta_tLS_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.Delta_tLSF_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.WN_LSF_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.DN_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLS_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLSF_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN_6), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -1636,7 +1993,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal out.close(); out.open(navGalfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < (int)data.size() - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -1652,7 +2009,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -1696,15 +2053,15 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut line_aux += std::string(3, ' '); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 18, 2), 19); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 18, 2), 19); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 9); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 9); // valid until 2019 + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 9); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 9); // valid until 2019 line_aux += std::string(1, ' '); line_aux += Rinex_Printer::leftJustify("DELTA-UTC: A0,A1,T,W", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); line_aux += std::string(54, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -1751,18 +2108,18 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut line_aux += std::string("GPUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 5); // valid until 2019 line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -1787,7 +2144,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut out.close(); out.open(navfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < static_cast(data.size()) - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -1803,7 +2160,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -1847,18 +2204,18 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode line_aux += std::string("GPUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 5); // valid until 2019 line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -1882,7 +2239,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode out.close(); out.open(navfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < static_cast(data.size()) - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -1893,12 +2250,141 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode } -void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) +void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Model& utc_model, const Gps_CNAV_Iono& iono, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model) { std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); + out.seekp(0); + data.clear(); + + bool no_more_finds = false; + std::string line_str; + + while (!out.eof()) + { + std::getline(out, line_str); + + if (!no_more_finds) + { + line_aux.clear(); + if ((line_str.find("GAL", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) + { + line_aux += std::string("GAL "); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); + double zero = 0.0; + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GPSA", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) + { + line_aux += std::string("GPSA"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GPSB", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) + { + line_aux += std::string("GPSB"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + + else if ((line_str.find("GAUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) + { + line_aux += std::string("GAUT"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t0t_6), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot_6), 5); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) + { + line_aux += std::string("GPGA"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_0G_10, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_1G_10, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t_0G_10), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_0G_10), 5); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("GPUT", 0) != std::string::npos) + { + line_aux += std::string("GPUT"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) + { + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + } + else + { + data.push_back(line_str); + } + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); + out.seekp(pos); + std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; +} + + +void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model) +{ + std::vector data; + std::string line_aux; + + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -1955,8 +2441,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += std::string("GPUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_t_OT), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -1966,8 +2452,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += std::string("GAUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.t0t_6), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WNot_6), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t0t_6), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot_6), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -1975,20 +2461,20 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { line_aux += std::string("GPGA"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_0G_10, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_1G_10, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.t_0G_10), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.WN_0G_10), 5); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_0G_10, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_1G_10, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t_0G_10), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_0G_10), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_DN), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_DN), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -2012,7 +2498,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion out.close(); out.open(navMixfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < static_cast(data.size()) - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -2031,7 +2517,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -2063,8 +2549,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += std::string("GPUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_t_OT), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -2074,8 +2560,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += std::string("GLUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -2085,18 +2571,18 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += std::string("GLGP"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_DN), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_DN), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -2120,7 +2606,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion out.close(); out.open(navMixfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < (int)data.size() - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -2139,7 +2625,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -2171,8 +2657,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp line_aux += std::string("GPUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_t_OT), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -2182,8 +2668,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp line_aux += std::string("GLUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -2193,18 +2679,18 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp line_aux += std::string("GLGP"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_DN), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_DN), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -2228,7 +2714,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp out.close(); out.open(navMixfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < (int)data.size() - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -2239,19 +2725,19 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp } -void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac) +void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac) { if (glonass_gnav_almanac.i_satellite_freq_channel) { } //Avoid compiler warning //Avoid compiler warning, there is not time system correction between Galileo and GLONASS - if (galileo_almanac.A_0G_10) + if (galileo_utc_model.A_0G_10) { } std::vector data; std::string line_aux; - long pos = out.tellp(); + int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -2284,8 +2770,8 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal line_aux += std::string("GAUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.t0t_6), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WNot_6), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t0t_6), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot_6), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); @@ -2295,18 +2781,18 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal line_aux += std::string("GLUT"); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 7); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(0.0), 5); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); line_aux += std::string(10, ' '); line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLS_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLSF_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WN_LSF_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.DN_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN_6), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -2330,7 +2816,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal out.close(); out.open(navMixfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < (int)data.size() - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -2341,10 +2827,102 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal } -void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) +void Rinex_Printer::update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_Model& utc_model, const Beidou_Dnav_Iono& iono) +{ + std::vector data; + std::string line_aux; + + int64_t pos = out.tellp(); + out.seekp(0); + data.clear(); + + bool no_more_finds = false; + std::string line_str; + + while (!out.eof()) + { + std::getline(out, line_str); + + if (!no_more_finds) + { + line_aux.clear(); + + if (line_str.find("BDSA", 0) != std::string::npos) + { + line_aux += std::string("GPSA"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("BDSB", 0) != std::string::npos) + { + line_aux += std::string("GPSB"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("BDUT", 0) != std::string::npos) + { + line_aux += std::string("GPUT"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0_UTC, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1_UTC, 15, 2), 16); + line_aux += std::string(22, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) + { + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + } + else + { + data.push_back(line_str); + } + } + + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); + out.seekp(pos); + std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; +} + +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { std::string line; - std::map::const_iterator gps_ephemeris_iter; + std::map::const_iterator gps_ephemeris_iter; for (gps_ephemeris_iter = eph_map.cbegin(); gps_ephemeris_iter != eph_map.cend(); @@ -2360,12 +2938,12 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(gps_ephemeris_iter->second.i_satellite_PRN), 2); + line += Rinex_Printer::rightJustify(std::to_string(gps_ephemeris_iter->second.i_satellite_PRN), 2); line += std::string(1, ' '); std::string year(timestring, 2, 2); line += year; line += std::string(1, ' '); - if (boost::lexical_cast(month) < 10) + if (boost::lexical_cast(month) < 10) { line += std::string(1, ' '); line += std::string(month, 1, 1); @@ -2375,7 +2953,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(day) < 10) + if (boost::lexical_cast(day) < 10) { line += std::string(1, ' '); line += std::string(day, 1, 1); @@ -2385,7 +2963,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(hour) < 10) + if (boost::lexical_cast(hour) < 10) { line += std::string(1, ' '); line += std::string(hour, 1, 1); @@ -2395,7 +2973,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(minutes) < 10) + if (boost::lexical_cast(minutes) < 10) { line += std::string(1, ' '); line += std::string(minutes, 1, 1); @@ -2405,7 +2983,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(seconds) < 10) + if (boost::lexical_cast(seconds) < 10) { line += std::string(1, ' '); line += std::string(seconds, 1, 1); @@ -2432,8 +3010,11 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); - line += boost::lexical_cast(gps_ephemeris_iter->second.i_satellite_PRN); + if (gps_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } + line += std::to_string(gps_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; @@ -2576,7 +3157,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(gps_ephemeris_iter->second.i_code_on_L2), 18, 2); line += std::string(1, ' '); - double GPS_week_continuous_number = static_cast(gps_ephemeris_iter->second.i_GPS_week + 1024); // valid until April 7, 2019 (check http://www.colorado.edu/geography/gcraft/notes/gps/gpseow.htm) + auto GPS_week_continuous_number = static_cast(gps_ephemeris_iter->second.i_GPS_week + 1024); // valid until April 7, 2019 (check http://www.colorado.edu/geography/gcraft/notes/gps/gpseow.htm) line += Rinex_Printer::doub2for(GPS_week_continuous_number, 18, 2); line += std::string(1, ' '); line += Rinex_Printer::doub2for(static_cast(gps_ephemeris_iter->second.i_code_on_L2), 18, 2); @@ -2626,26 +3207,53 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN).compare("IIA")) + if (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIA") { // Block II/IIA (Table 20-XI IS-GPS-200E ) - if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) curve_fit_interval = 8; - if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) curve_fit_interval = 14; - if ((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) curve_fit_interval = 26; - if ((gps_ephemeris_iter->second.d_IODC > 503) && (gps_ephemeris_iter->second.d_IODC < 511)) curve_fit_interval = 50; - if (((gps_ephemeris_iter->second.d_IODC > 751) && (gps_ephemeris_iter->second.d_IODC < 757)) || (gps_ephemeris_iter->second.d_IODC == 511)) curve_fit_interval = 74; - if (gps_ephemeris_iter->second.d_IODC == 757) curve_fit_interval = 98; + if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) + { + curve_fit_interval = 8; + } + if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) + { + curve_fit_interval = 14; + } + if ((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) + { + curve_fit_interval = 26; + } + if ((gps_ephemeris_iter->second.d_IODC > 503) && (gps_ephemeris_iter->second.d_IODC < 511)) + { + curve_fit_interval = 50; + } + if (((gps_ephemeris_iter->second.d_IODC > 751) && (gps_ephemeris_iter->second.d_IODC < 757)) || (gps_ephemeris_iter->second.d_IODC == 511)) + { + curve_fit_interval = 74; + } + if (gps_ephemeris_iter->second.d_IODC == 757) + { + curve_fit_interval = 98; + } } - if ((gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN).compare("IIR") == 0) || - (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN).compare("IIR-M") == 0) || - (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN).compare("IIF") == 0) || - (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN).compare("IIIA") == 0)) + if ((gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIR") || + (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIR-M") || + (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIF") || + (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIIA")) { // Block IIR/IIR-M/IIF/IIIA (Table 20-XII IS-GPS-200E ) - if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) curve_fit_interval = 8; - if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) curve_fit_interval = 14; - if (((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) || ((gps_ephemeris_iter->second.d_IODC > 1020) && (gps_ephemeris_iter->second.d_IODC < 1024))) curve_fit_interval = 26; + if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) + { + curve_fit_interval = 8; + } + if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) + { + curve_fit_interval = 14; + } + if (((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) || ((gps_ephemeris_iter->second.d_IODC > 1020) && (gps_ephemeris_iter->second.d_IODC < 1024))) + { + curve_fit_interval = 26; + } } line += Rinex_Printer::doub2for(curve_fit_interval, 18, 2); line += std::string(1, ' '); @@ -2663,10 +3271,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { std::string line; - std::map::const_iterator gps_ephemeris_iter; + std::map::const_iterator gps_ephemeris_iter; for (gps_ephemeris_iter = eph_map.cbegin(); gps_ephemeris_iter != eph_map.cend(); @@ -2681,8 +3289,11 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); - line += boost::lexical_cast(gps_ephemeris_iter->second.i_satellite_PRN); + if (gps_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } + line += std::to_string(gps_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; @@ -2715,7 +3326,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(gps_ephemeris_iter->second.i_GPS_week + 1024); // valid until April 7, 2019 (check http://www.colorado.edu/geography/gcraft/notes/gps/gpseow.htm) + auto GPS_week_continuous_number = static_cast(gps_ephemeris_iter->second.i_GPS_week + 1024); // valid until April 7, 2019 (check http://www.colorado.edu/geography/gcraft/notes/gps/gpseow.htm) line += Rinex_Printer::doub2for(GPS_week_continuous_number, 18, 2); line += std::string(1, ' '); line += Rinex_Printer::doub2for(my_zero, 18, 2); @@ -2819,10 +3433,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { std::string line; - std::map::const_iterator galileo_ephemeris_iter; + std::map::const_iterator galileo_ephemeris_iter; line.clear(); for (galileo_ephemeris_iter = eph_map.cbegin(); galileo_ephemeris_iter != eph_map.cend(); @@ -2838,8 +3452,11 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); - line += boost::lexical_cast(galileo_ephemeris_iter->second.i_satellite_PRN); + if (galileo_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } + line += std::to_string(galileo_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; @@ -2922,10 +3539,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(data_source_INAV), 18, 2); line += std::string(1, ' '); - double GST_week = static_cast(galileo_ephemeris_iter->second.WN_5); + auto GST_week = static_cast(galileo_ephemeris_iter->second.WN_5); double num_GST_rollovers = floor((GST_week + 1024.0) / 4096.0); double Galileo_week_continuous_number = GST_week + 1024.0 + num_GST_rollovers * 4096.0; line += Rinex_Printer::doub2for(Galileo_week_continuous_number, 18, 2); @@ -2943,27 +3560,63 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.E1B_HS_5 == 0) E1B_HS = "00"; - if (galileo_ephemeris_iter->second.E1B_HS_5 == 1) E1B_HS = "01"; - if (galileo_ephemeris_iter->second.E1B_HS_5 == 2) E1B_HS = "10"; - if (galileo_ephemeris_iter->second.E1B_HS_5 == 3) E1B_HS = "11"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 0) E5B_HS = "00"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 1) E5B_HS = "01"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 2) E5B_HS = "10"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 3) E5B_HS = "11"; + if (galileo_ephemeris_iter->second.E1B_HS_5 == 0) + { + E1B_HS = "00"; + } + if (galileo_ephemeris_iter->second.E1B_HS_5 == 1) + { + E1B_HS = "01"; + } + if (galileo_ephemeris_iter->second.E1B_HS_5 == 2) + { + E1B_HS = "10"; + } + if (galileo_ephemeris_iter->second.E1B_HS_5 == 3) + { + E1B_HS = "11"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 0) + { + E5B_HS = "00"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 1) + { + E5B_HS = "01"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 2) + { + E5B_HS = "10"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 3) + { + E5B_HS = "11"; + } - if (E1B_HS == "11") LOG(WARNING) << "Signal Component currently in Test"; - if (E1B_HS == "10") LOG(WARNING) << "Signal will be out of service"; - if (E1B_HS == "01") LOG(WARNING) << "Signal out of service"; + if (E1B_HS == "11") + { + LOG(WARNING) << "Signal Component currently in Test"; + } + if (E1B_HS == "10") + { + LOG(WARNING) << "Signal will be out of service"; + } + if (E1B_HS == "01") + { + LOG(WARNING) << "Signal out of service"; + } E1B_HS = "00"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID - std::string E1B_DVS = boost::lexical_cast(galileo_ephemeris_iter->second.E1B_DVS_5); - if (E1B_DVS == "1") LOG(WARNING) << "Navigation data without guarantee"; + std::string E1B_DVS = std::to_string(galileo_ephemeris_iter->second.E1B_DVS_5); + if (E1B_DVS == "1") + { + LOG(WARNING) << "Navigation data without guarantee"; + } E1B_DVS = "0"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID - std::string SVhealth_str = E5B_HS + boost::lexical_cast(galileo_ephemeris_iter->second.E5b_DVS_5) + "11" + "1" + E1B_DVS + E1B_HS + boost::lexical_cast(galileo_ephemeris_iter->second.E1B_DVS_5); + std::string SVhealth_str = E5B_HS + std::to_string(galileo_ephemeris_iter->second.E5b_DVS_5) + "11" + "1" + E1B_DVS + E1B_HS + std::to_string(galileo_ephemeris_iter->second.E1B_DVS_5); SVhealth_str = "000000000"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID - int SVhealth = Rinex_Printer::toInt(SVhealth_str, 9); + int32_t SVhealth = Rinex_Printer::toInt(SVhealth_str, 9); line += Rinex_Printer::doub2for(static_cast(SVhealth), 18, 2); line += std::string(1, ' '); line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.BGD_E1E5a_5, 18, 2); @@ -2989,13 +3642,13 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { std::string line; - std::map::const_iterator glonass_gnav_ephemeris_iter; + std::map::const_iterator glonass_gnav_ephemeris_iter; - for (glonass_gnav_ephemeris_iter = eph_map.begin(); - glonass_gnav_ephemeris_iter != eph_map.end(); + for (glonass_gnav_ephemeris_iter = eph_map.cbegin(); + glonass_gnav_ephemeris_iter != eph_map.cend(); glonass_gnav_ephemeris_iter++) { // -------- SV / EPOCH / SV CLK @@ -3008,12 +3661,12 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(glonass_gnav_ephemeris_iter->second.i_satellite_PRN), 2); + line += Rinex_Printer::rightJustify(std::to_string(glonass_gnav_ephemeris_iter->second.i_satellite_PRN), 2); line += std::string(1, ' '); std::string year(timestring, 2, 2); line += year; line += std::string(1, ' '); - if (boost::lexical_cast(month) < 10) + if (boost::lexical_cast(month) < 10) { line += std::string(1, ' '); line += std::string(month, 1, 1); @@ -3023,7 +3676,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(day) < 10) + if (boost::lexical_cast(day) < 10) { line += std::string(1, ' '); line += std::string(day, 1, 1); @@ -3033,7 +3686,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(hour) < 10) + if (boost::lexical_cast(hour) < 10) { line += std::string(1, ' '); line += std::string(hour, 1, 1); @@ -3043,7 +3696,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(minutes) < 10) + if (boost::lexical_cast(minutes) < 10) { line += std::string(1, ' '); line += std::string(minutes, 1, 1); @@ -3053,7 +3706,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(seconds) < 10) + if (boost::lexical_cast(seconds) < 10) { line += std::string(1, ' '); line += std::string(seconds, 1, 1); @@ -3080,8 +3733,11 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); - line += boost::lexical_cast(glonass_gnav_ephemeris_iter->second.i_satellite_PRN); + if (glonass_gnav_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } + line += std::to_string(glonass_gnav_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; @@ -3186,7 +3842,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map) { version = 3; stringVersion = "3.02"; @@ -3195,21 +3851,30 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& glonass_gnav_eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_cnav_eph_map, const std::map& galileo_eph_map) +{ + version = 3; + stringVersion = "3.02"; + Rinex_Printer::log_rinex_nav(out, gps_cnav_eph_map); + Rinex_Printer::log_rinex_nav(out, galileo_eph_map); +} + + +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& glonass_gnav_eph_map) { Rinex_Printer::log_rinex_nav(out, gps_eph_map); Rinex_Printer::log_rinex_nav(out, glonass_gnav_eph_map); } -void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& glonass_gnav_eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_cnav_eph_map, const std::map& glonass_gnav_eph_map) { - Rinex_Printer::log_rinex_nav(out, gps_eph_map); + Rinex_Printer::log_rinex_nav(out, gps_cnav_eph_map); Rinex_Printer::log_rinex_nav(out, glonass_gnav_eph_map); } -void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& galileo_eph_map, const std::map& glonass_gnav_eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& galileo_eph_map, const std::map& glonass_gnav_eph_map) { version = 3; stringVersion = "3.02"; @@ -3218,13 +3883,156 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) +{ + std::string line; + std::map::const_iterator bds_ephemeris_iter; + + for (bds_ephemeris_iter = eph_map.cbegin(); + bds_ephemeris_iter != eph_map.cend(); + bds_ephemeris_iter++) + { + // -------- SV / EPOCH / SV CLK + boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_BDS_time(bds_ephemeris_iter->second, bds_ephemeris_iter->second.d_Toc); + std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + std::string month(timestring, 4, 2); + std::string day(timestring, 6, 2); + std::string hour(timestring, 9, 2); + std::string minutes(timestring, 11, 2); + std::string seconds(timestring, 13, 2); + + line += satelliteSystem["Beidou"]; + if (bds_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } + line += std::to_string(bds_ephemeris_iter->second.i_satellite_PRN); + std::string year(timestring, 0, 4); + line += std::string(1, ' '); + line += year; + line += std::string(1, ' '); + line += month; + line += std::string(1, ' '); + line += day; + line += std::string(1, ' '); + line += hour; + line += std::string(1, ' '); + line += minutes; + line += std::string(1, ' '); + line += seconds; + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_A_f0, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_A_f1, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_A_f2, 18, 2); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- BROADCAST ORBIT - 1 + line.clear(); + line += std::string(5, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_AODE, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Crs, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Delta_n, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_M_0, 18, 2); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- BROADCAST ORBIT - 2 + line.clear(); + line += std::string(5, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Cuc, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_eccentricity, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Cus, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_sqrt_A, 18, 2); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- BROADCAST ORBIT - 3 + line.clear(); + line += std::string(5, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Toe, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Cic, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_OMEGA0, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Cis, 18, 2); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- BROADCAST ORBIT - 4 + line.clear(); + line += std::string(5, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_i_0, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_Crc, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_OMEGA, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_OMEGA_DOT, 18, 2); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- BROADCAST ORBIT - 5 + line.clear(); + line += std::string(5, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_IDOT, 18, 2); + line += std::string(1, ' '); + line += std::string(18, ' '); // spare + line += std::string(1, ' '); + auto BDS_week_continuous_number = static_cast(bds_ephemeris_iter->second.i_BEIDOU_week); + line += Rinex_Printer::doub2for(BDS_week_continuous_number, 18, 2); + line += std::string(1, ' '); + line += std::string(18, ' '); // spare + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + + // -------- BROADCAST ORBIT - 6 + line.clear(); + line += std::string(5, ' '); + line += Rinex_Printer::doub2for(static_cast(bds_ephemeris_iter->second.i_SV_accuracy), 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(static_cast(bds_ephemeris_iter->second.i_SV_health), 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_TGD1, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_TGD2, 18, 2); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- BROADCAST ORBIT - 7 + line.clear(); + line += std::string(5, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_TOW, 18, 2); + line += std::string(1, ' '); + line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.d_AODC, 18, 2); + line += std::string(1, ' '); + line += std::string(18, ' '); // spare + line += std::string(1, ' '); + line += std::string(18, ' '); // spare + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + line.clear(); + } +} + + +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephemeris& eph, const double d_TOW_first_observation, const std::string& glonass_bands) { if (eph.d_m) { } //Avoid compiler warning std::string line; - std::map::const_iterator glonass_gnav_ephemeris_iter; + std::map::const_iterator glonass_gnav_ephemeris_iter; // -------- Line 1 line = std::string(5, ' '); @@ -3313,7 +4121,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -3333,7 +4141,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -3498,12 +4309,12 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem // -------- GLONASS SLOT / FRQ # // TODO Need to provide system with list of all satellites and update this accordingly line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 3); // Number of satellites in list + line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); line += satelliteSystem["GLONASS"]; - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 2); // Slot Number + line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 2); // Frequency Number + line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number line += std::string(1, ' '); line += std::string(60 - line.size(), ' '); line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20); @@ -3548,7 +4359,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double d_TOW_first_observation, const std::string glonass_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double d_TOW_first_observation, const std::string& glonass_bands) { if (glonass_gnav_eph.d_m) { @@ -3636,7 +4447,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -3656,7 +4467,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -3733,7 +4547,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps out << line << std::endl; // Find GLONASS Signal in Mixed file - unsigned int number_of_observations_glo = 0; + uint32_t number_of_observations_glo = 0; std::string signal_("1G"); std::size_t found_1G = glonass_bands.find(signal_); if (found_1G != std::string::npos) @@ -3851,12 +4665,12 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- GLONASS SLOT / FRQ # // TODO Need to provide system with list of all satellites and update this accordingly line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 3); // Number of satellites in list + line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); line += satelliteSystem["GLONASS"]; - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 2); // Slot Number + line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 2); // Frequency Number + line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number line += std::string(1, ' '); line += std::string(60 - line.size(), ' '); line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20); @@ -3901,7 +4715,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double d_TOW_first_observation, const std::string glonass_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& gps_cnav_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double d_TOW_first_observation, const std::string& glonass_bands) { if (glonass_gnav_eph.d_m) { @@ -3988,7 +4802,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -4008,7 +4822,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -4083,7 +4900,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris out << line << std::endl; // Find GLONASS Signal in Mixed file - unsigned int number_of_observations_glo = 0; + uint32_t number_of_observations_glo = 0; std::string signal_("1G"); std::size_t found_1G = glonass_bands.find(signal_); if (found_1G != std::string::npos) @@ -4145,7 +4962,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); + boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_cnav_eph, d_TOW_first_observation); std::string timestring = boost::posix_time::to_iso_string(p_gps_time); std::string year(timestring, 0, 4); std::string month(timestring, 4, 2); @@ -4169,12 +4986,12 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- GLONASS SLOT / FRQ # // TODO Need to provide system with list of all satellites and update this accordingly line.clear(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 3); // Number of satellites in list + line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); line += satelliteSystem["GLONASS"]; - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 2); // Slot Number + line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(boost::lexical_cast(0), 2); // Frequency Number + line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number line += std::string(1, ' '); line += std::string(60 - line.size(), ' '); line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20); @@ -4218,7 +5035,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double d_TOW_first_observation, const std::string galileo_bands, const std::string glonass_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double d_TOW_first_observation, const std::string& galileo_bands, const std::string& glonass_bands) { if (glonass_gnav_eph.d_m) { @@ -4294,7 +5111,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -4314,7 +5131,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -4359,7 +5179,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- SYS / OBS TYPES line.clear(); - unsigned int number_of_observations_gal = 0; + uint32_t number_of_observations_gal = 0; std::string signal_("1B"); std::size_t found_1B = galileo_bands.find(signal_); if (found_1B != std::string::npos) @@ -4440,7 +5260,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& out << line << std::endl; line.clear(); - unsigned int number_of_observations_glo = 0; + uint32_t number_of_observations_glo = 0; signal_ = "1G"; std::size_t found_1G = glonass_bands.find(signal_); if (found_1G != std::string::npos) @@ -4614,7 +5434,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -4634,7 +5454,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -4796,7 +5619,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& eph, const double d_TOW_first_observation) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& eph, const double d_TOW_first_observation, const std::string& gps_bands) { std::string line; @@ -4868,7 +5691,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -4888,7 +5711,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -4934,30 +5760,66 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- SYS / OBS TYPES // one line per available system line.clear(); + uint32_t number_of_observations_gps = 0; + std::string signal_("2S"); + std::size_t found_2S = gps_bands.find(signal_); + if (found_2S != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + signal_ = "L5"; + std::size_t found_L5 = gps_bands.find(signal_); + if (found_L5 != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } line += satelliteSystem["GPS"]; line += std::string(2, ' '); std::stringstream strm; - numberTypesObservations = 4; + numberTypesObservations = number_of_observations_gps; strm << numberTypesObservations; line += Rinex_Printer::rightJustify(strm.str(), 3); // per type of observation - // GPS L2 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS DOPPLER L2 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L2_L2CM"]; + if (found_2S != std::string::npos) + { + // GPS L2 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS DOPPLER L2 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L2_L2CM"]; + } + + if (found_L5 != std::string::npos) + { + // GPS L5 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L5_Q"]; + // GPS DOPPLER L5 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L5_Q"]; + } line += std::string(60 - line.size(), ' '); line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); Rinex_Printer::lengthCheck(line); @@ -5005,7 +5867,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& eph_cnav, const double d_TOW_first_observation) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& eph_cnav, const double d_TOW_first_observation, const std::string& gps_bands) { if (eph_cnav.d_i_0) { @@ -5080,7 +5942,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -5100,7 +5962,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -5146,46 +6011,90 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- SYS / OBS TYPES // one line per available system line.clear(); + uint32_t number_of_observations_gps = 0; + std::string signal_("1C"); + std::size_t found_1C = gps_bands.find(signal_); + if (found_1C != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + signal_ = "2S"; + std::size_t found_2S = gps_bands.find(signal_); + if (found_2S != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + signal_ = "L5"; + std::size_t found_L5 = gps_bands.find(signal_); + if (found_L5 != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } line += satelliteSystem["GPS"]; line += std::string(2, ' '); std::stringstream strm; - numberTypesObservations = 8; + numberTypesObservations = number_of_observations_gps; strm << numberTypesObservations; line += Rinex_Printer::rightJustify(strm.str(), 3); // per type of observation - // GPS L1 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L1_CA"]; - // GPS DOPPLER L1 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 CA SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L1_CA"]; - // GPS L2 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS DOPPLER L2 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L2_L2CM"]; + if (found_1C != std::string::npos) + { + // GPS L1 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L1_CA"]; + // GPS L1 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L1_CA"]; + // GPS DOPPLER L1 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L1_CA"]; + // GPS L1 CA SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L1_CA"]; + } + if (found_2S != std::string::npos) + { + // GPS L2 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS DOPPLER L2 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L2_L2CM"]; + } + if (found_L5 != std::string::npos) + { + // GPS L5 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L5_Q"]; + // GPS DOPPLER L5 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L5_Q"]; + } line += std::string(60 - line.size(), ' '); line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); Rinex_Printer::lengthCheck(line); @@ -5233,7 +6142,679 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, const double d_TOW_first_observation, const std::string bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& eph_cnav, const Galileo_Ephemeris& galileo_eph, const double d_TOW_first_observation, const std::string& gps_bands, const std::string& galileo_bands) +{ + std::string line; + version = 3; + if (eph_cnav.d_e_eccentricity == 0) + { + // avoid warning + } + if (galileo_eph.e_1 == 0) + { + // avoid warning + } + + // -------- Line 1 + line = std::string(5, ' '); + line += "3.02"; + line += std::string(11, ' '); + line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += satelliteSystem["Mixed"]; + line += std::string(19, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 3 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line MARKER NAME + line.clear(); + line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, + line += Rinex_Printer::leftJustify("MARKER NAME", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line MARKER TYPE + //line.clear(); + //line += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + //line += std::string(40, ' '); + //line += Rinex_Printer::leftJustify("MARKER TYPE", 20); + //Rinex_Printer::lengthCheck(line); + //out << line << std::endl; + + // -------- Line OBSERVER / AGENCY + line.clear(); + std::string username; + char c_username[20] = {0}; + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); + if (nGet == 0) + { + username = c_username; + } + else + { + username = "UNKNOWN USER"; + } + line += leftJustify(username, 20); + line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property + line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line REC / TYPE VERS + line.clear(); + line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property + line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property + //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } + line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); + line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); + lengthCheck(line); + out << line << std::endl; + + // -------- ANTENNA TYPE + line.clear(); + line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property + line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property + line += std::string(20, ' '); + line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- APPROX POSITION (optional for moving platforms) + // put here real data! + double antena_x = 0.0; + double antena_y = 0.0; + double antena_z = 0.0; + line.clear(); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); + line += std::string(18, ' '); + line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- ANTENNA: DELTA H/E/N + // put here real data! + double antena_h = 0.0; + double antena_e = 0.0; + double antena_n = 0.0; + line.clear(); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); + line += std::string(18, ' '); + line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- SYS / OBS TYPES + // one line per available system + line.clear(); + uint32_t number_of_observations_gps = 0; + std::string signal_("1C"); + std::size_t found_1C = gps_bands.find(signal_); + if (found_1C != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + signal_ = "2S"; + std::size_t found_2S = gps_bands.find(signal_); + if (found_2S != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + signal_ = "L5"; + std::size_t found_L5 = gps_bands.find(signal_); + if (found_L5 != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + line += satelliteSystem["GPS"]; + line += std::string(2, ' '); + std::stringstream strm; + numberTypesObservations = number_of_observations_gps; + strm << numberTypesObservations; + line += Rinex_Printer::rightJustify(strm.str(), 3); + // per type of observation + if (found_1C != std::string::npos) + { + // GPS L1 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L1_CA"]; + // GPS L1 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L1_CA"]; + // GPS DOPPLER L1 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L1_CA"]; + // GPS L1 CA SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L1_CA"]; + } + if (found_2S != std::string::npos) + { + // GPS L2 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS DOPPLER L2 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L2_L2CM"]; + } + if (found_L5 != std::string::npos) + { + // GPS L5 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L5_Q"]; + // GPS DOPPLER L5 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L5_Q"]; + } + line += std::string(60 - line.size(), ' '); + line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + line.clear(); + uint32_t number_of_observations_gal = 0; + signal_ = "1B"; + std::size_t found_1B = galileo_bands.find(signal_); + if (found_1B != std::string::npos) + { + number_of_observations_gal = number_of_observations_gal + 4; + } + signal_ = "5X"; + std::size_t found_5X = galileo_bands.find(signal_); + if (found_5X != std::string::npos) + { + number_of_observations_gal = number_of_observations_gal + 4; + } + signal_ = "7X"; + std::size_t found_7X = galileo_bands.find(signal_); + if (found_7X != std::string::npos) + { + number_of_observations_gal = number_of_observations_gal + 4; + } + line += satelliteSystem["Galileo"]; + line += std::string(2, ' '); + line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); + if (found_1B != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GALILEO_E1_B"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GALILEO_E1_B"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GALILEO_E1_B"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GALILEO_E1_B"]; + } + if (found_5X != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GALILEO_E5a_IQ"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GALILEO_E5a_IQ"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GALILEO_E5a_IQ"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GALILEO_E5a_IQ"]; + } + if (found_7X != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GALILEO_E5b_IQ"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GALILEO_E5b_IQ"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GALILEO_E5b_IQ"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GALILEO_E5b_IQ"]; + } + line += std::string(60 - line.size(), ' '); + line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Signal Strength units + line.clear(); + line += Rinex_Printer::leftJustify("DBHZ", 20); + line += std::string(40, ' '); + line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- TIME OF FIRST OBS + line.clear(); + boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); + std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + std::string year(timestring, 0, 4); + std::string month(timestring, 4, 2); + std::string day(timestring, 6, 2); + std::string hour(timestring, 9, 2); + std::string minutes(timestring, 11, 2); + double gps_t = d_TOW_first_observation; + double seconds = fmod(gps_t, 60); + line += Rinex_Printer::rightJustify(year, 6); + line += Rinex_Printer::rightJustify(month, 6); + line += Rinex_Printer::rightJustify(day, 6); + line += Rinex_Printer::rightJustify(hour, 6); + line += Rinex_Printer::rightJustify(minutes, 6); + line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); + line += Rinex_Printer::rightJustify(std::string("GPS"), 8); + line += std::string(9, ' '); + line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- end of header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& eph_cnav, const Galileo_Ephemeris& galileo_eph, const double d_TOW_first_observation, const std::string& gps_bands, const std::string& galileo_bands) +{ + std::string line; + version = 3; + if (galileo_eph.e_1 == 0) + { + // avoid warning + } + // -------- Line 1 + line = std::string(5, ' '); + line += "3.02"; + line += std::string(11, ' '); + line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += satelliteSystem["Mixed"]; + line += std::string(19, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 3 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line MARKER NAME + line.clear(); + line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, + line += Rinex_Printer::leftJustify("MARKER NAME", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line MARKER TYPE + //line.clear(); + //line += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + //line += std::string(40, ' '); + //line += Rinex_Printer::leftJustify("MARKER TYPE", 20); + //Rinex_Printer::lengthCheck(line); + //out << line << std::endl; + + // -------- Line OBSERVER / AGENCY + line.clear(); + std::string username; + char c_username[20] = {0}; + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); + if (nGet == 0) + { + username = c_username; + } + else + { + username = "UNKNOWN USER"; + } + line += leftJustify(username, 20); + line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property + line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line REC / TYPE VERS + line.clear(); + line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property + line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property + //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } + line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); + line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); + lengthCheck(line); + out << line << std::endl; + + // -------- ANTENNA TYPE + line.clear(); + line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property + line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property + line += std::string(20, ' '); + line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- APPROX POSITION (optional for moving platforms) + // put here real data! + double antena_x = 0.0; + double antena_y = 0.0; + double antena_z = 0.0; + line.clear(); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); + line += std::string(18, ' '); + line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- ANTENNA: DELTA H/E/N + // put here real data! + double antena_h = 0.0; + double antena_e = 0.0; + double antena_n = 0.0; + line.clear(); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); + line += std::string(18, ' '); + line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- SYS / OBS TYPES + // one line per available system + line.clear(); + uint32_t number_of_observations_gps = 0; + std::string signal_("2S"); + std::size_t found_2S = gps_bands.find(signal_); + if (found_2S != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + signal_ = "L5"; + std::size_t found_L5 = gps_bands.find(signal_); + if (found_L5 != std::string::npos) + { + number_of_observations_gps = number_of_observations_gps + 4; + } + line += satelliteSystem["GPS"]; + line += std::string(2, ' '); + std::stringstream strm; + numberTypesObservations = number_of_observations_gps; + strm << numberTypesObservations; + line += Rinex_Printer::rightJustify(strm.str(), 3); + // per type of observation + if (found_2S != std::string::npos) + { + // GPS L2 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS DOPPLER L2 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L2_L2CM"]; + // GPS L2 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L2_L2CM"]; + } + if (found_L5 != std::string::npos) + { + // GPS L5 PSEUDORANGE + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 PHASE + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GPS_L5_Q"]; + // GPS DOPPLER L5 + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GPS_L5_Q"]; + // GPS L5 SIGNAL STRENGTH + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GPS_L5_Q"]; + } + line += std::string(60 - line.size(), ' '); + line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + line.clear(); + uint32_t number_of_observations_gal = 0; + signal_ = "1B"; + std::size_t found_1B = galileo_bands.find(signal_); + if (found_1B != std::string::npos) + { + number_of_observations_gal = number_of_observations_gal + 4; + } + signal_ = "5X"; + std::size_t found_5X = galileo_bands.find(signal_); + if (found_5X != std::string::npos) + { + number_of_observations_gal = number_of_observations_gal + 4; + } + signal_ = "7X"; + std::size_t found_7X = galileo_bands.find(signal_); + if (found_7X != std::string::npos) + { + number_of_observations_gal = number_of_observations_gal + 4; + } + line += satelliteSystem["Galileo"]; + line += std::string(2, ' '); + line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); + if (found_1B != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GALILEO_E1_B"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GALILEO_E1_B"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GALILEO_E1_B"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GALILEO_E1_B"]; + } + if (found_5X != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GALILEO_E5a_IQ"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GALILEO_E5a_IQ"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GALILEO_E5a_IQ"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GALILEO_E5a_IQ"]; + } + if (found_7X != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["GALILEO_E5b_IQ"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["GALILEO_E5b_IQ"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["GALILEO_E5b_IQ"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["GALILEO_E5b_IQ"]; + } + line += std::string(60 - line.size(), ' '); + line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Signal Strength units + line.clear(); + line += Rinex_Printer::leftJustify("DBHZ", 20); + line += std::string(40, ' '); + line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- TIME OF FIRST OBS + line.clear(); + boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph_cnav, d_TOW_first_observation); + std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + std::string year(timestring, 0, 4); + std::string month(timestring, 4, 2); + std::string day(timestring, 6, 2); + std::string hour(timestring, 9, 2); + std::string minutes(timestring, 11, 2); + double gps_t = d_TOW_first_observation; + double seconds = fmod(gps_t, 60); + line += Rinex_Printer::rightJustify(year, 6); + line += Rinex_Printer::rightJustify(month, 6); + line += Rinex_Printer::rightJustify(day, 6); + line += Rinex_Printer::rightJustify(hour, 6); + line += Rinex_Printer::rightJustify(minutes, 6); + line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); + line += Rinex_Printer::rightJustify(std::string("GPS"), 8); + line += std::string(9, ' '); + line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- end of header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, const double d_TOW_first_observation, const std::string& bands) { std::string line; version = 3; @@ -5306,7 +6887,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -5326,7 +6907,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -5371,7 +6955,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- SYS / OBS TYPES // one line per available system - unsigned int number_of_observations = 0; + uint32_t number_of_observations = 0; std::string signal_("1B"); std::size_t found_1B = bands.find(signal_); if (found_1B != std::string::npos) @@ -5494,7 +7078,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, const double d_TOW_first_observation, const std::string galileo_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, const double d_TOW_first_observation, const std::string& galileo_bands) { if (galileo_eph.e_1) { @@ -5570,7 +7154,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line.clear(); std::string username; char c_username[20] = {0}; - int nGet = getlogin_r(c_username, sizeof(c_username) - 1); + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); if (nGet == 0) { username = c_username; @@ -5590,7 +7174,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -5665,7 +7252,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps out << line << std::endl; line.clear(); - unsigned int number_of_observations_gal = 0; + uint32_t number_of_observations_gal = 0; std::string signal_("1B"); std::size_t found_1B = galileo_bands.find(signal_); if (found_1B != std::string::npos) @@ -5784,6 +7371,238 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Ephemeris& eph, const double d_TOW_first_observation, const std::string& bands) +{ + std::string line; + version = 3; + + // -------- Line 1 + line = std::string(5, ' '); + line += "3.02"; + line += std::string(11, ' '); + line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += satelliteSystem["Beidou"]; + line += std::string(19, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO C = BEIDOU S = GEO M = MIXED", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 3 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("BEIDOU OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line MARKER NAME + line.clear(); + line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, + line += Rinex_Printer::leftJustify("MARKER NAME", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line OBSERVER / AGENCY + line.clear(); + std::string username; + char c_username[20] = {0}; + int32_t nGet = getlogin_r(c_username, sizeof(c_username) - 1); + if (nGet == 0) + { + username = c_username; + } + else + { + username = "UNKNOWN USER"; + } + line += leftJustify(username, 20); + line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property + line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line REC / TYPE VERS + line.clear(); + line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property + line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property + //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } + line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); + line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); + lengthCheck(line); + out << line << std::endl; + + // -------- ANTENNA TYPE + line.clear(); + line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property + line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property + line += std::string(20, ' '); + line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- APPROX POSITION (optional for moving platforms) + // put here real data! + double antena_x = 0.0; + double antena_y = 0.0; + double antena_z = 0.0; + line.clear(); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); + line += std::string(18, ' '); + line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- ANTENNA: DELTA H/E/N + // put here real data! + double antena_h = 0.0; + double antena_e = 0.0; + double antena_n = 0.0; + line.clear(); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); + line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); + line += std::string(18, ' '); + line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- SYS / OBS TYPES + // one line per available system + uint32_t number_of_observations = 0; + std::string signal_("B1"); + std::size_t found_B1 = bands.find(signal_); + if (found_B1 != std::string::npos) + { + number_of_observations = number_of_observations + 4; + } + signal_ = "B3"; + std::size_t found_B3 = bands.find(signal_); + if (found_B3 != std::string::npos) + { + number_of_observations = number_of_observations + 4; + } + + line.clear(); + + line += satelliteSystem["Beidou"]; + line += std::string(2, ' '); + line += Rinex_Printer::rightJustify(std::to_string(number_of_observations), 3); + + if (found_B1 != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["BEIDOU_B1_I"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["BEIDOU_B1_I"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["BEIDOU_B1_I"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["BEIDOU_B1_I"]; + } + + if (found_B3 != std::string::npos) + { + line += std::string(1, ' '); + line += observationType["PSEUDORANGE"]; + line += observationCode["BEIDOU_B3_I"]; + line += std::string(1, ' '); + line += observationType["CARRIER_PHASE"]; + line += observationCode["BEIDOU_B3_I"]; + line += std::string(1, ' '); + line += observationType["DOPPLER"]; + line += observationCode["BEIDOU_B3_I"]; + line += std::string(1, ' '); + line += observationType["SIGNAL_STRENGTH"]; + line += observationCode["BEIDOU_B3_I"]; + } + + line += std::string(60 - line.size(), ' '); + line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Signal Strength units + line.clear(); + line += Rinex_Printer::leftJustify("DBHZ", 20); + line += std::string(40, ' '); + line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- TIME OF FIRST OBS + line.clear(); + boost::posix_time::ptime p_bds_time = Rinex_Printer::compute_BDS_time(eph, d_TOW_first_observation); + std::string timestring = boost::posix_time::to_iso_string(p_bds_time); + std::string year(timestring, 0, 4); + std::string month(timestring, 4, 2); + std::string day(timestring, 6, 2); + std::string hour(timestring, 9, 2); + std::string minutes(timestring, 11, 2); + double beidou_t = d_TOW_first_observation; + double seconds = fmod(beidou_t, 60); + line += Rinex_Printer::rightJustify(year, 6); + line += Rinex_Printer::rightJustify(month, 6); + line += Rinex_Printer::rightJustify(day, 6); + line += Rinex_Printer::rightJustify(hour, 6); + line += Rinex_Printer::rightJustify(minutes, 6); + line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); + line += Rinex_Printer::rightJustify(std::string("BDT"), 8); + line += std::string(9, ' '); + line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- SYS /PHASE SHIFTS + + // -------- end of header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + void Rinex_Printer::update_obs_header(std::fstream& out __attribute__((unused)), const Glonass_Gnav_Utc_Model& utc_model) { if (utc_model.d_N_4) @@ -5817,7 +7636,7 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) // TIME OF FIRST OBS last header annotation might change in the future { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); line_aux += std::string(54, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -5838,10 +7657,10 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -5866,7 +7685,7 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut out.close(); out.open(obsfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < static_cast(data.size()) - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -5897,10 +7716,10 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_CNAV_Utc_Mode if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -5924,7 +7743,7 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_CNAV_Utc_Mode out.close(); out.open(obsfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < static_cast(data.size()) - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -5956,10 +7775,10 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLS_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLSF_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WN_LSF_6), 6); - line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.DN_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF_6), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN_6), 6); line_aux += std::string(36, ' '); line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); @@ -5983,7 +7802,7 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model out.close(); out.open(obsfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < static_cast(data.size()) - 1; i++) + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) { out << data[i] << std::endl; } @@ -5993,14 +7812,73 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeris& eph, const double obs_time, const std::map& observables, const std::string glonass_band) +void Rinex_Printer::update_obs_header(std::fstream& out, const Beidou_Dnav_Utc_Model& utc_model) +{ + std::vector data; + std::string line_aux; + + out.seekp(0); + data.clear(); + + bool no_more_finds = false; + std::string line_str; + + while (!out.eof()) + { + std::getline(out, line_str); + + if (!no_more_finds) + { + line_aux.clear(); + + if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) + { + data.push_back(line_str); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.i_DN), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + } + else + { + data.push_back(line_str); + } + } + + out.close(); + out.open(obsfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); + out.seekp(0, std::ios_base::end); +} + + +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeris& eph, const double obs_time, const std::map& observables, const std::string& glonass_band) { // RINEX observations timestamps are GPS timestamps. std::string line; double int_sec = 0; // Avoid compiler warning - if (glonass_band.size()) + if (!glonass_band.empty()) { } @@ -6055,22 +7933,25 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); //Number of satellites observed in current epoch - int numSatellitesObserved = 0; - std::map::const_iterator observables_iter; - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + int32_t numSatellitesObserved = 0; + std::map::const_iterator observables_iter; + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { line += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); - line += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } + line += std::to_string(static_cast(observables_iter->second.PRN)); } // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); @@ -6078,8 +7959,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri Rinex_Printer::lengthCheck(line); out << line << std::endl; - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { std::string lineObs; @@ -6090,7 +7971,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6101,8 +7982,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS L1 CA PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GLONASS_TWO_PI, 3), 14); if (lli == 0) @@ -6113,7 +7994,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS L1 CA DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) @@ -6124,10 +8005,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); //GLONASS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -6159,15 +8043,15 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri line += std::string(1, '0'); //Number of satellites observed in current epoch - int numSatellitesObserved = 0; - std::map::const_iterator observables_iter; - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + int32_t numSatellitesObserved = 0; + std::map::const_iterator observables_iter; + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); @@ -6176,20 +8060,23 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri Rinex_Printer::lengthCheck(line); out << line << std::endl; - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { std::string lineObs; lineObs.clear(); lineObs += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(observables_iter->second.PRN)); //lineObs += std::string(2, ' '); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6200,8 +8087,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS L1 CA PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GLONASS_TWO_PI, 3), 14); @@ -6213,7 +8100,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS L1 CA DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); @@ -6226,19 +8113,22 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); //GLONASS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double gps_obs_time, const std::map& observables) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double gps_obs_time, const std::map& observables) { if (glonass_gnav_eph.d_m) { @@ -6328,40 +8218,40 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep //Number of satellites observed in current epoch //Get maps with observations - std::map observablesG1C; - std::map observablesR1C; - std::map observablesR2C; - std::map::const_iterator observables_iter; + std::map observablesG1C; + std::map observablesR1C; + std::map observablesR2C; + std::map::const_iterator observables_iter; - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("R") == 0) && (sig_.compare("1G") == 0)) + if ((system_ == "R") && (sig_ == "1G")) { - observablesR1C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesR1C.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("R") == 0) && (sig_.compare("2G") == 0)) + if ((system_ == "R") && (sig_ == "2G")) { - observablesR2C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesR2C.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("G") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "G") && (sig_ == "1C")) { - observablesG1C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesG1C.insert(std::pair(observables_iter->first, observables_iter->second)); } } - std::multimap total_glo_map; - std::set available_glo_prns; - std::set::iterator it; - for (observables_iter = observablesR1C.begin(); - observables_iter != observablesR1C.end(); + std::multimap total_glo_map; + std::set available_glo_prns; + std::set::iterator it; + for (observables_iter = observablesR1C.cbegin(); + observables_iter != observablesR1C.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_glo_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) { @@ -6369,12 +8259,12 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } } - for (observables_iter = observablesR2C.begin(); - observables_iter != observablesR2C.end(); + for (observables_iter = observablesR2C.cbegin(); + observables_iter != observablesR2C.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_glo_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) { @@ -6382,38 +8272,47 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } } - int numGloSatellitesObserved = available_glo_prns.size(); - int numGpsSatellitesObserved = observablesG1C.size(); - int numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + int32_t numGloSatellitesObserved = available_glo_prns.size(); + int32_t numGpsSatellitesObserved = observablesG1C.size(); + int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); if (version == 2) { // Add list of GPS satellites - for (observables_iter = observablesG1C.begin(); - observables_iter != observablesG1C.end(); + for (observables_iter = observablesG1C.cbegin(); + observables_iter != observablesG1C.cend(); observables_iter++) { line += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); - line += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } + line += std::to_string(static_cast(observables_iter->second.PRN)); } // Add list of GLONASS L1 satellites - for (observables_iter = observablesR1C.begin(); - observables_iter != observablesR1C.end(); + for (observables_iter = observablesR1C.cbegin(); + observables_iter != observablesR1C.cend(); observables_iter++) { line += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); - line += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } + line += std::to_string(static_cast(observables_iter->second.PRN)); } // Add list of GLONASS L2 satellites - for (observables_iter = observablesR2C.begin(); - observables_iter != observablesR2C.end(); + for (observables_iter = observablesR2C.cbegin(); + observables_iter != observablesR2C.cend(); observables_iter++) { line += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); - line += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } + line += std::to_string(static_cast(observables_iter->second.PRN)); } } line += std::string(80 - line.size(), ' '); @@ -6423,8 +8322,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // -------- OBSERVATION record std::string s; std::string lineObs; - for (observables_iter = observablesG1C.begin(); - observables_iter != observablesG1C.end(); + for (observables_iter = observablesG1C.cbegin(); + observables_iter != observablesG1C.cend(); observables_iter++) { lineObs.clear(); @@ -6433,17 +8332,26 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep if (version == 3) { // Specify system only if in version 3 - if (s.compare("G") == 0) lineObs += satelliteSystem["GPS"]; - if (s.compare("R") == 0) lineObs += satelliteSystem["GLONASS"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (s == "G") + { + lineObs += satelliteSystem["GPS"]; + } + if (s == "R") + { + lineObs += satelliteSystem["GLONASS"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(observables_iter->second.PRN)); } // Pseudorange Measurements lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6454,8 +8362,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GPS_TWO_PI, 3), 14); @@ -6467,7 +8375,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); @@ -6479,16 +8387,19 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } - std::pair::iterator, std::multimap::iterator> ret; + std::pair::iterator, std::multimap::iterator> ret; for (it = available_glo_prns.begin(); it != available_glo_prns.end(); it++) @@ -6497,18 +8408,21 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep if (version == 3) { lineObs += satelliteSystem["GLONASS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(*it)); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); } ret = total_glo_map.equal_range(*it); - for (std::multimap::iterator iter = ret.first; iter != ret.second; ++iter) + for (auto iter = ret.first; iter != ret.second; ++iter) { /// \todo Need to account for pseudorange correction for glonass //double leap_seconds = Rinex_Printer::get_leap_second(glonass_gnav_eph, gps_obs_time); lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6519,8 +8433,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS CARRIER PHASE lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GLONASS_TWO_PI), 3), 14); @@ -6532,7 +8446,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS DOPPLER lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); @@ -6544,19 +8458,22 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double gps_obs_time, const std::map& observables) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double gps_obs_time, const std::map& observables) { if (glonass_gnav_eph.d_m) { @@ -6602,40 +8519,40 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g //Number of satellites observed in current epoch //Get maps with observations - std::map observablesG2S; - std::map observablesR1C; - std::map observablesR2C; - std::map::const_iterator observables_iter; + std::map observablesG2S; + std::map observablesR1C; + std::map observablesR2C; + std::map::const_iterator observables_iter; - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("R") == 0) && (sig_.compare("1G") == 0)) + if ((system_ == "R") && (sig_ == "1G")) { - observablesR1C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesR1C.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("R") == 0) && (sig_.compare("2G") == 0)) + if ((system_ == "R") && (sig_ == "2G")) { - observablesR2C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesR2C.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("G") == 0) && (sig_.compare("2S") == 0)) + if ((system_ == "G") && (sig_ == "2S")) { - observablesG2S.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesG2S.insert(std::pair(observables_iter->first, observables_iter->second)); } } - std::multimap total_glo_map; - std::set available_glo_prns; - std::set::iterator it; - for (observables_iter = observablesR1C.begin(); - observables_iter != observablesR1C.end(); + std::multimap total_glo_map; + std::set available_glo_prns; + std::set::iterator it; + for (observables_iter = observablesR1C.cbegin(); + observables_iter != observablesR1C.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_glo_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) { @@ -6643,12 +8560,12 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g } } - for (observables_iter = observablesR2C.begin(); - observables_iter != observablesR2C.end(); + for (observables_iter = observablesR2C.cbegin(); + observables_iter != observablesR2C.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_glo_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) { @@ -6656,10 +8573,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g } } - int numGloSatellitesObserved = available_glo_prns.size(); - int numGpsSatellitesObserved = observablesG2S.size(); - int numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + int32_t numGloSatellitesObserved = available_glo_prns.size(); + int32_t numGpsSatellitesObserved = observablesG2S.size(); + int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); line += std::string(80 - line.size(), ' '); Rinex_Printer::lengthCheck(line); @@ -6668,24 +8585,33 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // -------- OBSERVATION record std::string s; std::string lineObs; - for (observables_iter = observablesG2S.begin(); - observables_iter != observablesG2S.end(); + for (observables_iter = observablesG2S.cbegin(); + observables_iter != observablesG2S.cend(); observables_iter++) { lineObs.clear(); s.assign(1, observables_iter->second.System); // Specify system only if in version 3 - if (s.compare("G") == 0) lineObs += satelliteSystem["GPS"]; - if (s.compare("R") == 0) lineObs += satelliteSystem["GLONASS"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (s == "G") + { + lineObs += satelliteSystem["GPS"]; + } + if (s == "R") + { + lineObs += satelliteSystem["GLONASS"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(observables_iter->second.PRN)); // Pseudorange Measurements lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6696,8 +8622,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GPS_TWO_PI, 3), 14); @@ -6709,7 +8635,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); @@ -6721,34 +8647,40 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } - std::pair::iterator, std::multimap::iterator> ret; + std::pair::iterator, std::multimap::iterator> ret; for (it = available_glo_prns.begin(); it != available_glo_prns.end(); it++) { lineObs.clear(); lineObs += satelliteSystem["GLONASS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(*it)); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); ret = total_glo_map.equal_range(*it); - for (std::multimap::iterator iter = ret.first; iter != ret.second; ++iter) + for (auto iter = ret.first; iter != ret.second; ++iter) { /// \todo Need to account for pseudorange correction for glonass //double leap_seconds = Rinex_Printer::get_leap_second(glonass_gnav_eph, gps_obs_time); lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6759,8 +8691,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS CARRIER PHASE lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GLONASS_TWO_PI), 3), 14); @@ -6772,7 +8704,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS DOPPLER lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); @@ -6784,19 +8716,22 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double galileo_obs_time, const std::map& observables) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double galileo_obs_time, const std::map& observables) { if (glonass_gnav_eph.d_m) { @@ -6842,52 +8777,52 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga //Number of satellites observed in current epoch //Get maps with observations - std::map observablesE1B; - std::map observablesR1C; - std::map observablesR2C; - std::map::const_iterator observables_iter; + std::map observablesE1B; + std::map observablesR1C; + std::map observablesR2C; + std::map::const_iterator observables_iter; - for (observables_iter = observables.begin(); - observables_iter != observables.end(); + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); observables_iter++) { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("R") == 0) && (sig_.compare("1G") == 0)) + if ((system_ == "R") && (sig_ == "1G")) { - observablesR1C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesR1C.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("R") == 0) && (sig_.compare("2G") == 0)) + if ((system_ == "R") && (sig_ == "2G")) { - observablesR2C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesR2C.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("E") == 0) && (sig_.compare("1B") == 0)) + if ((system_ == "E") && (sig_ == "1B")) { - observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); } } - std::multimap total_glo_map; - std::set available_glo_prns; - std::set::iterator it; - for (observables_iter = observablesR1C.begin(); - observables_iter != observablesR1C.end(); + std::multimap total_glo_map; + std::set available_glo_prns; + std::set::iterator it; + for (observables_iter = observablesR1C.cbegin(); + observables_iter != observablesR1C.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_glo_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) { available_glo_prns.insert(prn_); } } - for (observables_iter = observablesR2C.begin(); - observables_iter != observablesR2C.end(); + for (observables_iter = observablesR2C.cbegin(); + observables_iter != observablesR2C.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_glo_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) { @@ -6895,10 +8830,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga } } - int numGloSatellitesObserved = available_glo_prns.size(); - int numGalSatellitesObserved = observablesE1B.size(); - int numSatellitesObserved = numGalSatellitesObserved + numGloSatellitesObserved; - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + int32_t numGloSatellitesObserved = available_glo_prns.size(); + int32_t numGalSatellitesObserved = observablesE1B.size(); + int32_t numSatellitesObserved = numGalSatellitesObserved + numGloSatellitesObserved; + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); @@ -6909,21 +8844,30 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga std::string s; std::string lineObs; - for (observables_iter = observablesE1B.begin(); - observables_iter != observablesE1B.end(); + for (observables_iter = observablesE1B.cbegin(); + observables_iter != observablesE1B.cend(); observables_iter++) { lineObs.clear(); s.assign(1, observables_iter->second.System); - if (s.compare("E") == 0) lineObs += satelliteSystem["Galileo"]; - if (s.compare("R") == 0) lineObs += satelliteSystem["GLONASS"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (s == "E") + { + lineObs += satelliteSystem["Galileo"]; + } + if (s == "R") + { + lineObs += satelliteSystem["GLONASS"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(observables_iter->second.PRN)); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6934,8 +8878,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GPS_TWO_PI, 3), 14); @@ -6947,7 +8891,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); @@ -6959,31 +8903,37 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } - std::pair::iterator, std::multimap::iterator> ret; + std::pair::iterator, std::multimap::iterator> ret; for (it = available_glo_prns.begin(); it != available_glo_prns.end(); it++) { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(*it)); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); ret = total_glo_map.equal_range(*it); - for (std::multimap::iterator iter = ret.first; iter != ret.second; ++iter) + for (auto iter = ret.first; iter != ret.second; ++iter) { lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -6994,8 +8944,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS CARRIER PHASE lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GLONASS_TWO_PI), 3), 14); @@ -7007,7 +8957,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS DOPPLER lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); @@ -7019,19 +8969,22 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const double obs_time, const std::map& observables) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const double obs_time, const std::map& observables) { // RINEX observations timestamps are GPS timestamps. std::string line; @@ -7088,22 +9041,25 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); //Number of satellites observed in current epoch - int numSatellitesObserved = 0; - std::map::const_iterator observables_iter; + int32_t numSatellitesObserved = 0; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { line += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); - line += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } + line += std::to_string(static_cast(observables_iter->second.PRN)); } // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); @@ -7123,7 +9079,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -7134,8 +9090,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L1 CA PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GPS_TWO_PI, 3), 14); if (lli == 0) @@ -7146,7 +9102,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L1 CA DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) @@ -7157,10 +9113,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); //GPS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -7193,15 +9152,15 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c line += std::string(1, '0'); //Number of satellites observed in current epoch - int numSatellitesObserved = 0; - std::map::const_iterator observables_iter; + int32_t numSatellitesObserved = 0; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); @@ -7217,13 +9176,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c std::string lineObs; lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(observables_iter->second.PRN)); //lineObs += std::string(2, ' '); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -7234,8 +9196,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L1 CA PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GPS_TWO_PI, 3), 14); @@ -7247,7 +9209,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L1 CA DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); @@ -7260,19 +9222,22 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); //GPS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& eph, double obs_time, const std::map& observables) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& eph, double obs_time, const std::map& observables) { // RINEX observations timestamps are GPS timestamps. std::string line; @@ -7314,15 +9279,15 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e line += std::string(1, '0'); //Number of satellites observed in current epoch - int numSatellitesObserved = 0; - std::map::const_iterator observables_iter; + int32_t numSatellitesObserved = 0; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); @@ -7338,14 +9303,17 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e std::string lineObs; lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(observables_iter->second.PRN)); //lineObs += std::string(2, ' '); //GPS L2 PSEUDORANGE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -7356,8 +9324,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L2 PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GPS_TWO_PI, 3), 14); @@ -7369,7 +9337,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L2 DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); @@ -7382,18 +9350,21 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); //GPS L2 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& eph_cnav, double obs_time, const std::map& observables) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& eph_cnav, double obs_time, const std::map& observables) { if (eph_cnav.d_i_0) { @@ -7440,38 +9411,51 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c //Number of satellites observed in current epoch //Get maps with GPS L1 and L2 observations - std::map observablesL1; - std::map observablesL2; - std::map::const_iterator observables_iter; + std::map observablesL1; + std::map observablesL2; + std::map observablesL5; + std::map::const_iterator observables_iter; - std::multimap total_mmap; - std::multimap::iterator mmap_iter; + std::multimap total_mmap; + std::multimap::iterator mmap_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("G") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "G") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); - total_mmap.insert(std::pair(observables_iter->second.PRN, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + total_mmap.insert(std::pair(observables_iter->second.PRN, observables_iter->second)); } - if ((system_.compare("G") == 0) && (sig_.compare("2S") == 0)) + if ((system_ == "G") && (sig_ == "2S")) { - observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); mmap_iter = total_mmap.find(observables_iter->second.PRN); if (mmap_iter == total_mmap.end()) { Gnss_Synchro gs = Gnss_Synchro(); - total_mmap.insert(std::pair(observables_iter->second.PRN, gs)); + total_mmap.insert(std::pair(observables_iter->second.PRN, gs)); } - total_mmap.insert(std::pair(observables_iter->second.PRN, observables_iter->second)); + total_mmap.insert(std::pair(observables_iter->second.PRN, observables_iter->second)); + } + + if ((system_ == "G") && (sig_ == "L5")) + { + observablesL5.insert(std::pair(observables_iter->first, observables_iter->second)); + mmap_iter = total_mmap.find(observables_iter->second.PRN); + if (mmap_iter == total_mmap.end()) + { + Gnss_Synchro gs = Gnss_Synchro(); + total_mmap.insert(std::pair(observables_iter->second.PRN, gs)); + } + total_mmap.insert(std::pair(observables_iter->second.PRN, observables_iter->second)); } } // Fill with zeros satellites with L1 obs but not L2 - std::multimap mmap_aux; + std::multimap mmap_aux; mmap_aux = total_mmap; for (mmap_iter = mmap_aux.begin(); mmap_iter != mmap_aux.end(); @@ -7485,17 +9469,17 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c std::string sig = "2S"; std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = mmap_iter->second.PRN; - total_mmap.insert(std::pair(mmap_iter->second.PRN, gs)); + total_mmap.insert(std::pair(mmap_iter->second.PRN, gs)); } } - std::set available_prns; - std::set::iterator it; + std::set available_prns; + std::set::iterator it; for (observables_iter = observablesL1.cbegin(); observables_iter != observablesL1.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -7507,7 +9491,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c observables_iter != observablesL2.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -7515,8 +9499,20 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c } } - int numSatellitesObserved = available_prns.size(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + for (observables_iter = observablesL5.cbegin(); + observables_iter != observablesL5.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + it = available_prns.find(prn_); + if (it == available_prns.end()) + { + available_prns.insert(prn_); + } + } + + int32_t numSatellitesObserved = available_prns.size(); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); @@ -7524,22 +9520,25 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c out << line << std::endl; std::string lineObs; - std::pair::iterator, std::multimap::iterator> ret; + std::pair::iterator, std::multimap::iterator> ret; for (it = available_prns.begin(); it != available_prns.end(); it++) { lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(*it)); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); ret = total_mmap.equal_range(*it); - for (std::multimap::iterator iter = ret.first; iter != ret.second; ++iter) + for (auto iter = ret.first; iter != ret.second; ++iter) { lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -7550,8 +9549,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS CARRIER PHASE lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14); @@ -7563,7 +9562,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS DOPPLER lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); @@ -7575,19 +9574,22 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& observables, const std::string galileo_bands) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& observables, const std::string& galileo_bands) { // RINEX observations timestamps are Galileo timestamps. // See http://gage14.upc.es/gLAB/HTML/Observation_Rinex_v3.01.html @@ -7632,10 +9634,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep //Number of satellites observed in current epoch //Get maps with Galileo observations - std::map observablesE1B; - std::map observablesE5A; - std::map observablesE5B; - std::map::const_iterator observables_iter; + std::map observablesE1B; + std::map observablesE5A; + std::map observablesE5B; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); @@ -7643,34 +9645,34 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("E") == 0) && (sig_.compare("1B") == 0)) + if ((system_ == "E") && (sig_ == "1B")) { - observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("E") == 0) && (sig_.compare("5X") == 0)) + if ((system_ == "E") && (sig_ == "5X")) { - observablesE5A.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesE5A.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("E") == 0) && (sig_.compare("7X") == 0)) + if ((system_ == "E") && (sig_ == "7X")) { - observablesE5B.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesE5B.insert(std::pair(observables_iter->first, observables_iter->second)); } } std::size_t found_1B = galileo_bands.find("1B"); std::size_t found_E5a = galileo_bands.find("5X"); std::size_t found_E5b = galileo_bands.find("7X"); - std::multimap total_map; - std::set available_prns; - std::set::iterator it; + std::multimap total_map; + std::set available_prns; + std::set::iterator it; if (found_1B != std::string::npos) { - for (observables_iter = observablesE1B.begin(); - observables_iter != observablesE1B.end(); + for (observables_iter = observablesE1B.cbegin(); + observables_iter != observablesE1B.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_map.insert(std::pair(prn_, observables_iter->second)); it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -7684,7 +9686,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep observables_iter != observablesE5A.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -7697,10 +9699,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sig = "1B"; std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; - total_map.insert(std::pair(prn_, gs)); + total_map.insert(std::pair(prn_, gs)); } } - total_map.insert(std::pair(prn_, observables_iter->second)); + total_map.insert(std::pair(prn_, observables_iter->second)); } } if (found_E5b != std::string::npos) @@ -7709,7 +9711,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep observables_iter != observablesE5B.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -7722,7 +9724,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sig = "1B"; std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; - total_map.insert(std::pair(prn_, gs)); + total_map.insert(std::pair(prn_, gs)); } if (found_E5a != std::string::npos) { @@ -7732,7 +9734,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sig = "5X"; std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; - total_map.insert(std::pair(prn_, gs)); + total_map.insert(std::pair(prn_, gs)); } } else @@ -7748,15 +9750,15 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sig = "5X"; std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; - total_map.insert(std::pair(prn_, gs)); + total_map.insert(std::pair(prn_, gs)); } } } - total_map.insert(std::pair(prn_, observables_iter->second)); + total_map.insert(std::pair(prn_, observables_iter->second)); } } - int numSatellitesObserved = available_prns.size(); - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + int32_t numSatellitesObserved = available_prns.size(); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); @@ -7764,22 +9766,25 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep out << line << std::endl; std::string lineObs; - std::pair::iterator, std::multimap::iterator> ret; + std::pair::iterator, std::multimap::iterator> ret; for (it = available_prns.begin(); it != available_prns.end(); it++) { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(*it)); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); ret = total_map.equal_range(*it); - for (std::multimap::iterator iter = ret.first; iter != ret.second; ++iter) + for (auto iter = ret.first; iter != ret.second; ++iter) { lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -7790,8 +9795,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo CARRIER PHASE lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14); @@ -7803,7 +9808,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo DOPPLER lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); @@ -7815,19 +9820,22 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } -void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& observables) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& observables) { if (galileo_eph.e_1) { @@ -7873,11 +9881,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep //Number of satellites observed in current epoch //Get maps with observations - std::map observablesG1C; - std::map observablesE1B; - std::map observablesE5A; - std::map observablesE5B; - std::map::const_iterator observables_iter; + std::map observablesG1C; + std::map observablesE1B; + std::map observablesE5A; + std::map observablesE5B; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); @@ -7885,33 +9893,33 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("E") == 0) && (sig_.compare("1B") == 0)) + if ((system_ == "E") && (sig_ == "1B")) { - observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("E") == 0) && (sig_.compare("5X") == 0)) + if ((system_ == "E") && (sig_ == "5X")) { - observablesE5A.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesE5A.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("E") == 0) && (sig_.compare("7X") == 0)) + if ((system_ == "E") && (sig_ == "7X")) { - observablesE5B.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesE5B.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("G") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "G") && (sig_ == "1C")) { - observablesG1C.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesG1C.insert(std::pair(observables_iter->first, observables_iter->second)); } } - std::multimap total_gal_map; - std::set available_gal_prns; - std::set::iterator it; + std::multimap total_gal_map; + std::set available_gal_prns; + std::set::iterator it; for (observables_iter = observablesE1B.cbegin(); observables_iter != observablesE1B.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_gal_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) { @@ -7923,8 +9931,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE5A.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_gal_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) { @@ -7936,8 +9944,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE5B.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; - total_gal_map.insert(std::pair(prn_, observables_iter->second)); + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) { @@ -7945,10 +9953,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } } - int numGalSatellitesObserved = available_gal_prns.size(); - int numGpsSatellitesObserved = observablesG1C.size(); - int numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + int32_t numGalSatellitesObserved = available_gal_prns.size(); + int32_t numGpsSatellitesObserved = observablesG1C.size(); + int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) //line += rightJustify(asString(clockOffset, 12), 15); @@ -7966,14 +9974,23 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs.clear(); s.assign(1, observables_iter->second.System); - if (s.compare("G") == 0) lineObs += satelliteSystem["GPS"]; - if (s.compare("E") == 0) lineObs += satelliteSystem["Galileo"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(observables_iter->second.PRN)); + if (s == "G") + { + lineObs += satelliteSystem["GPS"]; + } + if (s == "E") + { + lineObs += satelliteSystem["Galileo"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(observables_iter->second.PRN)); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -7984,8 +10001,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / GPS_TWO_PI, 3), 14); @@ -7997,7 +10014,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // DOPPLER lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); @@ -8009,31 +10026,37 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } - std::pair::iterator, std::multimap::iterator> ret; + std::pair::iterator, std::multimap::iterator> ret; for (it = available_gal_prns.begin(); it != available_gal_prns.end(); it++) { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); - lineObs += boost::lexical_cast(static_cast(*it)); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); ret = total_gal_map.equal_range(*it); - for (std::multimap::iterator iter = ret.first; iter != ret.second; ++iter) + for (auto iter = ret.first; iter != ret.second; ++iter) { lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); //Loss of lock indicator (LLI) - int lli = 0; // Include in the observation!! + int32_t lli = 0; // Include in the observation!! if (lli == 0) { lineObs += std::string(1, ' '); @@ -8044,8 +10067,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo CARRIER PHASE lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14); @@ -8057,7 +10080,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo DOPPLER lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); @@ -8069,41 +10092,829 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // { // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } -void Rinex_Printer::to_date_time(int gps_week, int gps_tow, int& year, int& month, int& day, int& hour, int& minute, int& second) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& observables) +{ + if (galileo_eph.e_1) + { + } // avoid warning, not needed + std::string line; + + boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, gps_obs_time); + std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + //double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); + //double gps_t = eph.sv_clock_correction(obs_time); + double gps_t = gps_obs_time; + + std::string month(timestring, 4, 2); + std::string day(timestring, 6, 2); + std::string hour(timestring, 9, 2); + std::string minutes(timestring, 11, 2); + + std::string year(timestring, 0, 4); + line += std::string(1, '>'); + line += std::string(1, ' '); + line += year; + line += std::string(1, ' '); + line += month; + line += std::string(1, ' '); + line += day; + line += std::string(1, ' '); + line += hour; + line += std::string(1, ' '); + line += minutes; + + line += std::string(1, ' '); + double seconds = fmod(gps_t, 60); + // Add extra 0 if seconds are < 10 + if (seconds < 10) + { + line += std::string(1, '0'); + } + line += Rinex_Printer::asString(seconds, 7); + line += std::string(2, ' '); + // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event + line += std::string(1, '0'); + + //Number of satellites observed in current epoch + + //Get maps with observations + std::map observablesG2S; + std::map observablesGL5; + std::map observablesE1B; + std::map observablesE5A; + std::map observablesE5B; + std::map::const_iterator observables_iter; + + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); + observables_iter++) + { + std::string system_(&observables_iter->second.System, 1); + std::string sig_(observables_iter->second.Signal); + if ((system_ == "E") && (sig_ == "1B")) + { + observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "E") && (sig_ == "5X")) + { + observablesE5A.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "E") && (sig_ == "7X")) + { + observablesE5B.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "G") && (sig_ == "2S")) + { + observablesG2S.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "G") && (sig_ == "L5")) + { + observablesGL5.insert(std::pair(observables_iter->first, observables_iter->second)); + } + } + + std::multimap total_gps_map; + std::multimap total_gal_map; + std::set available_gal_prns; + std::set available_gps_prns; + std::set::iterator it; + for (observables_iter = observablesE1B.cbegin(); + observables_iter != observablesE1B.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gal_prns.find(prn_); + if (it == available_gal_prns.end()) + { + available_gal_prns.insert(prn_); + } + } + + for (observables_iter = observablesE5A.cbegin(); + observables_iter != observablesE5A.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gal_prns.find(prn_); + if (it == available_gal_prns.end()) + { + available_gal_prns.insert(prn_); + } + } + + for (observables_iter = observablesE5B.cbegin(); + observables_iter != observablesE5B.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gal_prns.find(prn_); + if (it == available_gal_prns.end()) + { + available_gal_prns.insert(prn_); + } + } + + for (observables_iter = observablesG2S.cbegin(); + observables_iter != observablesG2S.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gps_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gps_prns.find(prn_); + if (it == available_gps_prns.end()) + { + available_gps_prns.insert(prn_); + } + } + + for (observables_iter = observablesGL5.cbegin(); + observables_iter != observablesGL5.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gps_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gps_prns.find(prn_); + if (it == available_gps_prns.end()) + { + available_gps_prns.insert(prn_); + } + } + + int32_t numGalSatellitesObserved = available_gal_prns.size(); + int32_t numGpsSatellitesObserved = available_gps_prns.size(); + int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + + // Receiver clock offset (optional) + //line += rightJustify(asString(clockOffset, 12), 15); + + line += std::string(80 - line.size(), ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + std::string s; + std::string lineObs; + + std::pair::iterator, std::multimap::iterator> ret; + for (it = available_gps_prns.begin(); + it != available_gps_prns.end(); + it++) + { + lineObs.clear(); + lineObs += satelliteSystem["GPS"]; + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); + ret = total_gps_map.equal_range(*it); + for (auto iter = ret.first; iter != ret.second; ++iter) + { + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + + //Loss of lock indicator (LLI) + int32_t lli = 0; // Include in the observation!! + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + + // Signal Strength Indicator (SSI) + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // CARRIER PHASE + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // DOPPLER + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // SIGNAL STRENGTH + lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + } + + out << lineObs << std::endl; + } + + for (it = available_gal_prns.begin(); + it != available_gal_prns.end(); + it++) + { + lineObs.clear(); + lineObs += satelliteSystem["Galileo"]; + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); + ret = total_gal_map.equal_range(*it); + for (auto iter = ret.first; iter != ret.second; ++iter) + { + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + + //Loss of lock indicator (LLI) + int32_t lli = 0; // Include in the observation!! + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + + // Signal Strength Indicator (SSI) + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // Galileo CARRIER PHASE + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // Galileo DOPPLER + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // Galileo SIGNAL STRENGTH + lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + } + + //if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + out << lineObs << std::endl; + } +} + + +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& gps_cnav_eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& observables) +{ + if (galileo_eph.e_1) + { + } // avoid warning, not needed + if (gps_cnav_eph.d_e_eccentricity) + { + } // avoid warning, not needed + std::string line; + + boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); + std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + //double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); + //double gps_t = eph.sv_clock_correction(obs_time); + double gps_t = gps_obs_time; + + std::string month(timestring, 4, 2); + std::string day(timestring, 6, 2); + std::string hour(timestring, 9, 2); + std::string minutes(timestring, 11, 2); + + std::string year(timestring, 0, 4); + line += std::string(1, '>'); + line += std::string(1, ' '); + line += year; + line += std::string(1, ' '); + line += month; + line += std::string(1, ' '); + line += day; + line += std::string(1, ' '); + line += hour; + line += std::string(1, ' '); + line += minutes; + + line += std::string(1, ' '); + double seconds = fmod(gps_t, 60); + // Add extra 0 if seconds are < 10 + if (seconds < 10) + { + line += std::string(1, '0'); + } + line += Rinex_Printer::asString(seconds, 7); + line += std::string(2, ' '); + // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event + line += std::string(1, '0'); + + //Number of satellites observed in current epoch + + //Get maps with observations + std::map observablesG2S; + std::map observablesGL5; + std::map observablesG1C; + std::map observablesE1B; + std::map observablesE5A; + std::map observablesE5B; + std::map::const_iterator observables_iter; + + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); + observables_iter++) + { + std::string system_(&observables_iter->second.System, 1); + std::string sig_(observables_iter->second.Signal); + if ((system_ == "E") && (sig_ == "1B")) + { + observablesE1B.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "E") && (sig_ == "5X")) + { + observablesE5A.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "E") && (sig_ == "7X")) + { + observablesE5B.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "G") && (sig_ == "2S")) + { + observablesG2S.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "G") && (sig_ == "L5")) + { + observablesGL5.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "G") && (sig_ == "1C")) + { + observablesG1C.insert(std::pair(observables_iter->first, observables_iter->second)); + } + } + + std::multimap total_gps_map; + std::multimap total_gal_map; + std::set available_gal_prns; + std::set available_gps_prns; + std::set::iterator it; + for (observables_iter = observablesE1B.cbegin(); + observables_iter != observablesE1B.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gal_prns.find(prn_); + if (it == available_gal_prns.end()) + { + available_gal_prns.insert(prn_); + } + } + + for (observables_iter = observablesE5A.cbegin(); + observables_iter != observablesE5A.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gal_prns.find(prn_); + if (it == available_gal_prns.end()) + { + available_gal_prns.insert(prn_); + } + } + + for (observables_iter = observablesE5B.cbegin(); + observables_iter != observablesE5B.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gal_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gal_prns.find(prn_); + if (it == available_gal_prns.end()) + { + available_gal_prns.insert(prn_); + } + } + + for (observables_iter = observablesG1C.cbegin(); + observables_iter != observablesG1C.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gps_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gps_prns.find(prn_); + if (it == available_gps_prns.end()) + { + available_gps_prns.insert(prn_); + } + } + + for (observables_iter = observablesG2S.cbegin(); + observables_iter != observablesG2S.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gps_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gps_prns.find(prn_); + if (it == available_gps_prns.end()) + { + available_gps_prns.insert(prn_); + } + } + + for (observables_iter = observablesGL5.cbegin(); + observables_iter != observablesGL5.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_gps_map.insert(std::pair(prn_, observables_iter->second)); + it = available_gps_prns.find(prn_); + if (it == available_gps_prns.end()) + { + available_gps_prns.insert(prn_); + } + } + + int32_t numGalSatellitesObserved = available_gal_prns.size(); + int32_t numGpsSatellitesObserved = available_gps_prns.size(); + int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + + // Receiver clock offset (optional) + //line += rightJustify(asString(clockOffset, 12), 15); + + line += std::string(80 - line.size(), ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + std::string s; + std::string lineObs; + + std::pair::iterator, std::multimap::iterator> ret; + for (it = available_gps_prns.begin(); + it != available_gps_prns.end(); + it++) + { + lineObs.clear(); + lineObs += satelliteSystem["GPS"]; + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); + ret = total_gps_map.equal_range(*it); + for (auto iter = ret.first; iter != ret.second; ++iter) + { + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + + //Loss of lock indicator (LLI) + int32_t lli = 0; // Include in the observation!! + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + + // Signal Strength Indicator (SSI) + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // CARRIER PHASE + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // DOPPLER + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // SIGNAL STRENGTH + lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + } + + out << lineObs << std::endl; + } + + for (it = available_gal_prns.begin(); + it != available_gal_prns.end(); + it++) + { + lineObs.clear(); + lineObs += satelliteSystem["Galileo"]; + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); + ret = total_gal_map.equal_range(*it); + for (auto iter = ret.first; iter != ret.second; ++iter) + { + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + + //Loss of lock indicator (LLI) + int32_t lli = 0; // Include in the observation!! + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + + // Signal Strength Indicator (SSI) + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // Galileo CARRIER PHASE + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // Galileo DOPPLER + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + //else + // { + // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // Galileo SIGNAL STRENGTH + lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + } + + //if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + out << lineObs << std::endl; + } +} + + +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris& eph, double obs_time, const std::map& observables, const std::string& bds_bands) +{ + std::string line; + + boost::posix_time::ptime p_bds_time = Rinex_Printer::compute_BDS_time(eph, obs_time); + std::string timestring = boost::posix_time::to_iso_string(p_bds_time); + //double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); + //double gps_t = eph.sv_clock_correction(obs_time); + double bds_t = obs_time; + + std::string month(timestring, 4, 2); + std::string day(timestring, 6, 2); + std::string hour(timestring, 9, 2); + std::string minutes(timestring, 11, 2); + + std::string year(timestring, 0, 4); + line += std::string(1, '>'); + line += std::string(1, ' '); + line += year; + line += std::string(1, ' '); + line += month; + line += std::string(1, ' '); + line += day; + line += std::string(1, ' '); + line += hour; + line += std::string(1, ' '); + line += minutes; + + line += std::string(1, ' '); + double seconds = fmod(bds_t, 60); + // Add extra 0 if seconds are < 10 + if (seconds < 10) + { + line += std::string(1, '0'); + } + line += Rinex_Printer::asString(seconds, 7); + line += std::string(2, ' '); + // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event + line += std::string(1, '0'); + + //Number of satellites observed in current epoch + + //Get maps with BeiDou observations + std::map observablesB1I; + std::map observablesB3I; + + std::map::const_iterator observables_iter; + + for (observables_iter = observables.cbegin(); + observables_iter != observables.cend(); + observables_iter++) + { + std::string system_(&observables_iter->second.System, 1); + std::string sig_(observables_iter->second.Signal); + if ((system_ == "C") && (sig_ == "B1")) + { + observablesB1I.insert(std::pair(observables_iter->first, observables_iter->second)); + } + if ((system_ == "C") && (sig_ == "B3")) + { + observablesB3I.insert(std::pair(observables_iter->first, observables_iter->second)); + } + } + std::size_t found_B1 = bds_bands.find("B1"); + std::size_t found_B3 = bds_bands.find("B3"); + + std::multimap total_map; + std::set available_prns; + std::set::iterator it; + if (found_B1 != std::string::npos) + { + for (observables_iter = observablesB1I.cbegin(); + observables_iter != observablesB1I.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + total_map.insert(std::pair(prn_, observables_iter->second)); + it = available_prns.find(prn_); + if (it == available_prns.end()) + { + available_prns.insert(prn_); + } + } + } + if (found_B3 != std::string::npos) + { + for (observables_iter = observablesB3I.cbegin(); + observables_iter != observablesB3I.cend(); + observables_iter++) + { + uint32_t prn_ = observables_iter->second.PRN; + it = available_prns.find(prn_); + if (it == available_prns.end()) + { + available_prns.insert(prn_); + if (found_B1 != std::string::npos) + { + Gnss_Synchro gs = Gnss_Synchro(); + std::string sys = "C"; + gs.System = *sys.c_str(); + std::string sig = "B1"; + std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); + gs.PRN = prn_; + total_map.insert(std::pair(prn_, gs)); + } + } + total_map.insert(std::pair(prn_, observables_iter->second)); + } + } + + int32_t numSatellitesObserved = available_prns.size(); + line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + // Receiver clock offset (optional) + //line += rightJustify(asString(clockOffset, 12), 15); + line += std::string(80 - line.size(), ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + std::string lineObs; + std::pair::iterator, std::multimap::iterator> ret; + for (it = available_prns.begin(); + it != available_prns.end(); + it++) + { + lineObs.clear(); + lineObs += satelliteSystem["Beidou"]; + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } + lineObs += std::to_string(static_cast(*it)); + ret = total_map.equal_range(*it); + for (auto iter = ret.first; iter != ret.second; ++iter) + { + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + + //Loss of lock indicator (LLI) + int32_t lli = 0; // Include in the observation!! + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + + // Signal Strength Indicator (SSI) + int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // CARRIER PHASE + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (BEIDOU_TWO_PI), 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // DOPPLER + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + + // SIGNAL STRENGTH + lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + } + + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } + out << lineObs << std::endl; + } +} + + +void Rinex_Printer::to_date_time(int32_t gps_week, int32_t gps_tow, int& year, int& month, int& day, int& hour, int& minute, int& second) { // represents GPS time (week, TOW) in the date time format of the Gregorian calendar. // -> Leap years are considered, but leap seconds are not. - int days_per_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + int32_t days_per_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // seconds in a not leap year - const int secs_per_day = 24 * 60 * 60; - const int secs_per_week = 7 * secs_per_day; - const int secs_per_normal_year = 365 * secs_per_day; - const int secs_per_leap_year = secs_per_normal_year + secs_per_day; + const int32_t secs_per_day = 24 * 60 * 60; + const int32_t secs_per_week = 7 * secs_per_day; + const int32_t secs_per_normal_year = 365 * secs_per_day; + const int32_t secs_per_leap_year = secs_per_normal_year + secs_per_day; // the GPS epoch is 06.01.1980 00:00, i.e. midnight 5. / 6. January 1980 // -> seconds since then - int secs_since_gps_epoch = gps_week * secs_per_week + gps_tow; + int32_t secs_since_gps_epoch = gps_week * secs_per_week + gps_tow; // find year, consider leap years bool is_leap_year; - int remaining_secs = secs_since_gps_epoch + 5 * secs_per_day; - for (int y = 1980; true; y++) + int32_t remaining_secs = secs_since_gps_epoch + 5 * secs_per_day; + for (int32_t y = 1980; true; y++) { is_leap_year = y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); - int secs_in_year_y = is_leap_year ? secs_per_leap_year : secs_per_normal_year; + int32_t secs_in_year_y = is_leap_year ? secs_per_leap_year : secs_per_normal_year; if (secs_in_year_y <= remaining_secs) { @@ -8119,9 +10930,9 @@ void Rinex_Printer::to_date_time(int gps_week, int gps_tow, int& year, int& mont } // find month - for (int m = 1; true; m++) + for (int32_t m = 1; true; m++) { - int secs_in_month_m = days_per_month[m - 1] * secs_per_day; + int32_t secs_in_month_m = days_per_month[m - 1] * secs_per_day; if (is_leap_year && m == 2) // consider February of leap year { secs_in_month_m += secs_per_day; @@ -8161,19 +10972,19 @@ void Rinex_Printer::to_date_time(int gps_week, int gps_tow, int& year, int& mont // line1 << " "; // // // gps time of reception -// int gps_week; +// int32_t gps_week; // double gps_sec; // if(sbs_message.get_rx_time_obj().get_gps_time(gps_week, gps_sec)) // { -// int year; -// int month; -// int day; -// int hour; -// int minute; -// int second; +// int32_t year; +// int32_t month; +// int32_t day; +// int32_t hour; +// int32_t minute; +// int32_t second; // // double gps_sec_one_digit_precicion = round(gps_sec *10)/10; // to prevent rounding towards 60.0sec in the stream output -// int gps_tow = trunc(gps_sec_one_digit_precicion); +// int32_t gps_tow = trunc(gps_sec_one_digit_precicion); // double sub_sec = gps_sec_one_digit_precicion - double(gps_tow); // // to_date_time(gps_week, gps_tow, year, month, day, hour, minute, second); @@ -8234,9 +11045,9 @@ void Rinex_Printer::to_date_time(int gps_week, int gps_tow, int& year, int& mont //} -int Rinex_Printer::signalStrength(const double snr) +int32_t Rinex_Printer::signalStrength(const double snr) { - int ss; + int32_t ss; ss = int(std::min(std::max(int(floor(snr / 6)), 1), 9)); return ss; } @@ -8247,12 +11058,25 @@ boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Gps_Navigation_Me // if we are processing a file -> wait to leap second to resolve the ambiguity else take the week from the local system time //: idea resolve the ambiguity with the leap second http://www.colorado.edu/geography/gcraft/notes/gps/gpseow.htm const double utc_t = nav_msg.utc_time(nav_msg.d_TOW); - boost::posix_time::time_duration t = boost::posix_time::millisec((utc_t + 604800 * static_cast(nav_msg.i_GPS_week)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((utc_t + 604800 * static_cast(nav_msg.i_GPS_week)) * 1000)); boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } +boost::posix_time::ptime Rinex_Printer::compute_BDS_time(const Beidou_Dnav_Ephemeris& eph, const double obs_time) +{ + // The RINEX v2.11 v3.00 format uses GPS time for the observations epoch, not UTC time, thus, no leap seconds needed here. + // (see Section 3 in http://igscb.jpl.nasa.gov/igscb/data/format/rinex211.txt) + // (see Pag. 17 in http://igscb.jpl.nasa.gov/igscb/data/format/rinex300.pdf) + // --??? No time correction here, since it will be done in the RINEX processor + const double bds_t = obs_time; + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((bds_t + 604800 * static_cast(eph.i_BEIDOU_week % 8192)) * 1000)); + boost::posix_time::ptime p_time(boost::gregorian::date(2006, 1, 1), t); + return p_time; +} + + boost::posix_time::ptime Rinex_Printer::compute_GPS_time(const Gps_Ephemeris& eph, const double obs_time) { // The RINEX v2.11 v3.00 format uses GPS time for the observations epoch, not UTC time, thus, no leap seconds needed here. @@ -8260,7 +11084,7 @@ boost::posix_time::ptime Rinex_Printer::compute_GPS_time(const Gps_Ephemeris& ep // (see Pag. 17 in http://igscb.jpl.nasa.gov/igscb/data/format/rinex300.pdf) // --??? No time correction here, since it will be done in the RINEX processor const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -8273,7 +11097,7 @@ boost::posix_time::ptime Rinex_Printer::compute_GPS_time(const Gps_CNAV_Ephemeri // (see Pag. 17 in http://igscb.jpl.nasa.gov/igscb/data/format/rinex300.pdf) // --??? No time correction here, since it will be done in the RINEX processor const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -8285,7 +11109,7 @@ boost::posix_time::ptime Rinex_Printer::compute_Galileo_time(const Galileo_Ephem // (see Pag. 17 in http://igscb.jpl.nasa.gov/igscb/data/format/rinex301.pdf) // --??? No time correction here, since it will be done in the RINEX processor double galileo_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000); // + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -8296,7 +11120,7 @@ boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Glonass_Gnav_Ephe double tod = 0.0; double glot2utc = 3 * 3600; double obs_time_glot = 0.0; - int i = 0; + int32_t i = 0; // Get observation time in nearly GLONASS time. Correction for leap seconds done at the end obs_time_glot = obs_time + glot2utc; @@ -8336,7 +11160,7 @@ double Rinex_Printer::get_leap_second(const Glonass_Gnav_Ephemeris& eph, const d double tod = 0.0; double glot2utc = 3 * 3600; double obs_time_glot = 0.0; - int i = 0; + int32_t i = 0; double leap_second = 0; // Get observation time in nearly GLONASS time. Correction for leap seconds done at the end diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 2cd961956..0e189dc80 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -51,20 +51,23 @@ #ifndef GNSS_SDR_RINEX_PRINTER_H_ #define GNSS_SDR_RINEX_PRINTER_H_ -#include "gps_navigation_message.h" -#include "gps_cnav_navigation_message.h" -#include "galileo_navigation_message.h" -#include "glonass_gnav_navigation_message.h" +#include "Beidou_B1I.h" +#include "GLONASS_L1_L2_CA.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" -#include "GLONASS_L1_L2_CA.h" +#include "beidou_dnav_navigation_message.h" +#include "galileo_navigation_message.h" +#include "glonass_gnav_navigation_message.h" #include "gnss_synchro.h" +#include "gps_cnav_navigation_message.h" +#include "gps_navigation_message.h" #include -#include +#include #include -#include // for stringstream #include // for setprecision #include +#include // for stringstream +#include class Sbas_Raw_Msg; @@ -76,12 +79,12 @@ class Rinex_Printer { public: /*! - * \brief Default constructor. Creates GPS Navigation and Observables RINEX files and their headers + * \brief Default constructor. Creates GNSS Navigation and Observables RINEX files and their headers */ - Rinex_Printer(int version = 0); + Rinex_Printer(int version = 0, const std::string& base_path = "."); /*! - * \brief Default destructor. Closes GPS Navigation and Observables RINEX files + * \brief Default destructor. Closes GNSS Navigation and Observables RINEX files */ ~Rinex_Printer(); @@ -90,6 +93,7 @@ public: std::fstream sbsFile; //& eph_map); + void log_rinex_nav(std::fstream& out, const std::map& eph_map); /*! * \brief Writes data from the GPS L2 navigation message into the RINEX file */ - void log_rinex_nav(std::fstream& out, const std::map& eph_map); + void log_rinex_nav(std::fstream& out, const std::map& eph_map); /*! * \brief Writes data from the Galileo navigation message into the RINEX file */ - void log_rinex_nav(std::fstream& out, const std::map& eph_map); + void log_rinex_nav(std::fstream& out, const std::map& eph_map); /*! * \brief Writes data from the Mixed (GPS/Galileo) navigation message into the RINEX file */ - void log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map); + void log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map); + + /*! + * \brief Writes data from the Mixed (GPS/Galileo) navigation message into the RINEX file + */ + void log_rinex_nav(std::fstream& out, const std::map& gps_cnav_eph_map, const std::map& galileo_eph_map); /*! * \brief Writes data from the GLONASS GNAV navigation message into the RINEX file */ - void log_rinex_nav(std::fstream& out, const std::map& eph_map); + void log_rinex_nav(std::fstream& out, const std::map& eph_map); /*! * \brief Writes data from the Mixed (GPS/GLONASS GNAV) navigation message into the RINEX file */ - void log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& glonass_gnav_eph_map); + void log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& glonass_gnav_eph_map); /*! * \brief Writes data from the Mixed (GPS/GLONASS GNAV) navigation message into the RINEX file */ - void log_rinex_nav(std::fstream& out, const std::map& gps_cnav_eph_map, const std::map& glonass_gnav_eph_map); + void log_rinex_nav(std::fstream& out, const std::map& gps_cnav_eph_map, const std::map& glonass_gnav_eph_map); /*! * \brief Writes data from the Mixed (Galileo/ GLONASS GNAV) navigation message into the RINEX file */ - void log_rinex_nav(std::fstream& out, const std::map& galileo_eph_map, const std::map& glonass_gnav_eph_map); + void log_rinex_nav(std::fstream& out, const std::map& galileo_eph_map, const std::map& glonass_gnav_eph_map); + + /*! + * \brief Writes data from the Beidou B1I navigation message into the RINEX file + */ + void log_rinex_nav(std::fstream& out, const std::map& eph_map); /*! * \brief Writes GPS L1 observables into the RINEX file */ - void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, double obs_time, const std::map& observables); + void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, double obs_time, const std::map& observables); /*! * \brief Writes GPS L2 observables into the RINEX file */ - void log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& eph, double obs_time, const std::map& observables); + void log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& eph, double obs_time, const std::map& observables); /*! * \brief Writes dual frequency GPS L1 and L2 observables into the RINEX file */ - void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& eph_cnav, double obs_time, const std::map& observables); + void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& eph_cnav, double obs_time, const std::map& observables); /*! * \brief Writes Galileo observables into the RINEX file. Example: galileo_bands("1B"), galileo_bands("1B 5X"), galileo_bands("5X"), ... Default: "1B". */ - void log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& observables, const std::string galileo_bands = "1B"); + void log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& observables, const std::string& galileo_bands = "1B"); /*! * \brief Writes Mixed GPS / Galileo observables into the RINEX file */ - void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, const double gps_obs_time, const std::map& observables); + void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, const double gps_obs_time, const std::map& observables); + + /*! + * \brief Writes Mixed GPS / Galileo observables into the RINEX file + */ + void log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& observables); + + /*! + * \brief Writes Mixed GPS / Galileo observables into the RINEX file + */ + void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& gps_cnav_eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& observables); /*! * \brief Writes GLONASS GNAV observables into the RINEX file. Example: glonass_bands("1C"), galileo_bands("1B 5X"), galileo_bands("5X"), ... Default: "1B". */ - void log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeris& eph, double obs_time, const std::map& observables, const std::string glonass_bands = "1C"); + void log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeris& eph, double obs_time, const std::map& observables, const std::string& glonass_bands = "1C"); /*! * \brief Writes Mixed GPS L1 C/A - GLONASS observables into the RINEX file */ - void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double gps_obs_time, const std::map& observables); + void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double gps_obs_time, const std::map& observables); /*! * \brief Writes Mixed GPS L2C - GLONASS observables into the RINEX file */ - void log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& gps_cnav_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double gps_obs_time, const std::map& observables); + void log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double gps_obs_time, const std::map& observables); /*! * \brief Writes Mixed Galileo/GLONASS observables into the RINEX file */ - void log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double gps_obs_time, const std::map& observables); + void log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const double galileo_obs_time, const std::map& observables); + + /*! + * \brief Writes BDS B1I observables into the RINEX file + */ + void log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris& eph, double obs_time, const std::map& observables, const std::string& bds_bands); + /*! * \brief Represents GPS time in the date time format. Leap years are considered, but leap seconds are not. @@ -313,21 +374,25 @@ public: */ //void log_rinex_sbs(std::fstream & out, const Sbas_Raw_Msg & sbs_message); - void update_nav_header(std::fstream& out, const Gps_Utc_Model& gps_utc, const Gps_Iono& gps_iono); + void update_nav_header(std::fstream& out, const Gps_Utc_Model& utc_model, const Gps_Iono& gps_iono); void update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Model& utc_model, const Gps_CNAV_Iono& iono); - void update_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac); + void update_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model); - void update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac); + void update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Model& utc_model, const Gps_CNAV_Iono& iono, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model); + + void update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model); void update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac); void update_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac); - void update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps_cnav_iono, const Gps_CNAV_Utc_Model& gps_cnav_utc, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac); + void update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps_iono, const Gps_CNAV_Utc_Model& gps_utc_model, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac); - void update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac); + void update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac); + + void update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_Model& utc_model, const Beidou_Dnav_Iono& beidou_dnav_iono); void update_obs_header(std::fstream& out, const Gps_Utc_Model& utc_model); @@ -337,7 +402,9 @@ public: void update_obs_header(std::fstream& out, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); - std::map satelliteSystem; // satelliteSystem; // observationType; // observationCode; // 3 && checkSwitch) exponentLength = 3; + if (exponentLength < 0) + { + exponentLength = 1; + } + + if (exponentLength > 3 && checkSwitch) + { + exponentLength = 3; + } std::string toReturn = doub2sci(d, length, exponentLength, true, checkSwitch); sci2for(toReturn, 0, length, exponentLength, checkSwitch); @@ -628,8 +703,15 @@ inline std::string Rinex_Printer::doub2sci(const double& d, short exponentLength = expLen; /* Validate the assumptions regarding the input arguments */ - if (exponentLength < 0) exponentLength = 1; - if (exponentLength > 3 && checkSwitch) exponentLength = 3; + if (exponentLength < 0) + { + exponentLength = 1; + } + + if (exponentLength > 3 && checkSwitch) + { + exponentLength = 3; + } std::stringstream c; c.setf(std::ios::scientific, std::ios::floatfield); @@ -641,7 +723,10 @@ inline std::string Rinex_Printer::doub2sci(const double& d, // an extra -1 for '-' or ' ' if it's positive or negative int expSize = 0; if (showSign) - expSize = 1; + { + expSize = 1; + } + c.precision(length - 3 - exponentLength - 1 - expSize); c << d; c >> toReturn; @@ -658,7 +743,7 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr, std::string::size_type idx = aStr.find('.', startPos); int expAdd = 0; std::string exp; - long iexp; + int64_t iexp; //If checkSwitch is false, always redo the exponential. Otherwise, //set it to false. bool redoexp = !checkSwitch; @@ -683,7 +768,9 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr, aStr[idx - 1] = '.'; // Only add one to the exponent if the number is non-zero if (asDouble(aStr.substr(startPos, length)) != 0.0) - expAdd = 1; + { + expAdd = 1; + } } idx = aStr.find('e', startPos); @@ -698,9 +785,13 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr, // Change the exponent character to D normally, or E of checkSwitch is false. if (checkSwitch) - aStr[idx] = 'D'; + { + aStr[idx] = 'D'; + } else - aStr[idx] = 'E'; + { + aStr[idx] = 'E'; + } // Change the exponent itself if (redoexp) @@ -716,7 +807,10 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr, iexp -= iexp * 2; } else - aStr += "+"; + { + aStr += "+"; + } + aStr += Rinex_Printer::rightJustify(asString(iexp), expLen, '0'); } @@ -761,9 +855,9 @@ inline std::string Rinex_Printer::asFixWidthString(const int x, const int width, } -inline long asInt(const std::string& s) +inline int64_t asInt(const std::string& s) { - return strtol(s.c_str(), 0, 10); + return strtol(s.c_str(), nullptr, 10); } diff --git a/src/algorithms/PVT/libs/rtcm_printer.cc b/src/algorithms/PVT/libs/rtcm_printer.cc index cd400ed4b..d3416be6e 100644 --- a/src/algorithms/PVT/libs/rtcm_printer.cc +++ b/src/algorithms/PVT/libs/rtcm_printer.cc @@ -33,50 +33,91 @@ #include "rtcm_printer.h" #include +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem #include +#include +#include +#include // for O_RDWR #include -#include // for O_RDWR #include // for tcgetattr +#include using google::LogMessage; -Rtcm_Printer::Rtcm_Printer(std::string filename, bool flag_rtcm_server, bool flag_rtcm_tty_port, unsigned short rtcm_tcp_port, unsigned short rtcm_station_id, std::string rtcm_dump_devname, bool time_tag_name) +Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump, bool flag_rtcm_server, bool flag_rtcm_tty_port, uint16_t rtcm_tcp_port, uint16_t rtcm_station_id, const std::string& rtcm_dump_devname, bool time_tag_name, const std::string& base_path) { boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); tm timeinfo = boost::posix_time::to_tm(pt); + d_rtcm_file_dump = flag_rtcm_file_dump; + rtcm_base_path = base_path; + if (d_rtcm_file_dump) + { + boost::filesystem::path full_path(boost::filesystem::current_path()); + const boost::filesystem::path p(rtcm_base_path); + if (!boost::filesystem::exists(p)) + { + std::string new_folder; + for (auto& folder : boost::filesystem::path(rtcm_base_path)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + std::cout << "Could not create the " << new_folder << " folder." << std::endl; + rtcm_base_path = full_path.string(); + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + } + else + { + rtcm_base_path = p.string(); + } + if (rtcm_base_path != ".") + { + std::cout << "RTCM binary file will be stored at " << rtcm_base_path << std::endl; + } + + rtcm_base_path = rtcm_base_path + boost::filesystem::path::preferred_separator; + } if (time_tag_name) { std::stringstream strm0; - const int year = timeinfo.tm_year - 100; + const int32_t year = timeinfo.tm_year - 100; strm0 << year; - const int month = timeinfo.tm_mon + 1; + const int32_t month = timeinfo.tm_mon + 1; if (month < 10) { strm0 << "0"; } strm0 << month; - const int day = timeinfo.tm_mday; + const int32_t day = timeinfo.tm_mday; if (day < 10) { strm0 << "0"; } strm0 << day << "_"; - const int hour = timeinfo.tm_hour; + const int32_t hour = timeinfo.tm_hour; if (hour < 10) { strm0 << "0"; } strm0 << hour; - const int min = timeinfo.tm_min; + const int32_t min = timeinfo.tm_min; if (min < 10) { strm0 << "0"; } strm0 << min; - const int sec = timeinfo.tm_sec; + const int32_t sec = timeinfo.tm_sec; if (sec < 10) { strm0 << "0"; @@ -89,11 +130,18 @@ Rtcm_Printer::Rtcm_Printer(std::string filename, bool flag_rtcm_server, bool fla { rtcm_filename = filename + ".rtcm"; } - - rtcm_file_descriptor.open(rtcm_filename.c_str(), std::ios::out); - if (rtcm_file_descriptor.is_open()) + rtcm_filename = rtcm_base_path + rtcm_filename; + if (d_rtcm_file_dump) { - DLOG(INFO) << "RTCM printer writing on " << rtcm_filename.c_str(); + rtcm_file_descriptor.open(rtcm_filename.c_str(), std::ios::out); + if (rtcm_file_descriptor.is_open()) + { + DLOG(INFO) << "RTCM printer writing on " << rtcm_filename.c_str(); + } + else + { + std::cout << "File " << rtcm_filename << "cannot be saved. Wrong permissions?" << std::endl; + } } rtcm_devname = rtcm_dump_devname; @@ -141,19 +189,36 @@ Rtcm_Printer::~Rtcm_Printer() } if (rtcm_file_descriptor.is_open()) { - long pos; + int64_t pos; pos = rtcm_file_descriptor.tellp(); - rtcm_file_descriptor.close(); + try + { + rtcm_file_descriptor.close(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } if (pos == 0) { - if (remove(rtcm_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary RTCM file"; + if (remove(rtcm_filename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary RTCM file"; + } } } - close_serial(); + try + { + close_serial(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } } -bool Rtcm_Printer::Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables) { std::string m1001 = rtcm->print_MT1001(gps_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1001); @@ -161,7 +226,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_ti } -bool Rtcm_Printer::Print_Rtcm_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables) { std::string m1002 = rtcm->print_MT1002(gps_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1002); @@ -169,7 +234,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1002(const Gps_Ephemeris& gps_eph, double obs_ti } -bool Rtcm_Printer::Print_Rtcm_MT1003(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1003(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables) { std::string m1003 = rtcm->print_MT1003(gps_eph, cnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1003); @@ -177,7 +242,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1003(const Gps_Ephemeris& gps_eph, const Gps_CNA } -bool Rtcm_Printer::Print_Rtcm_MT1004(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1004(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables) { std::string m1003 = rtcm->print_MT1004(gps_eph, cnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1003); @@ -185,7 +250,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1004(const Gps_Ephemeris& gps_eph, const Gps_CNA } -bool Rtcm_Printer::Print_Rtcm_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables) { std::string m1009 = rtcm->print_MT1009(glonass_gnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1009); @@ -193,7 +258,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_ } -bool Rtcm_Printer::Print_Rtcm_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables) { std::string m1010 = rtcm->print_MT1010(glonass_gnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1010); @@ -201,7 +266,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_ } -bool Rtcm_Printer::Print_Rtcm_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables) { std::string m1011 = rtcm->print_MT1011(glonass_gnav_ephL1, glonass_gnav_ephL2, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1011); @@ -209,7 +274,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ } -bool Rtcm_Printer::Print_Rtcm_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables) +bool Rtcm_Printer::Print_Rtcm_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables) { std::string m1012 = rtcm->print_MT1012(glonass_gnav_ephL1, glonass_gnav_ephL2, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1012); @@ -241,15 +306,15 @@ bool Rtcm_Printer::Print_Rtcm_MT1045(const Galileo_Ephemeris& gal_eph) } -bool Rtcm_Printer::Print_Rtcm_MSM(unsigned int msm_number, const Gps_Ephemeris& gps_eph, +bool Rtcm_Printer::Print_Rtcm_MSM(uint32_t msm_number, const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& gps_cnav_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { @@ -292,24 +357,30 @@ bool Rtcm_Printer::Print_Rtcm_MSM(unsigned int msm_number, const Gps_Ephemeris& } -int Rtcm_Printer::init_serial(std::string serial_device) +int Rtcm_Printer::init_serial(const std::string& serial_device) { /* * Opens the serial device and sets the default baud rate for a RTCM transmission (9600,8,N,1) */ - int fd = 0; + int32_t fd = 0; struct termios options; - long BAUD; - long DATABITS; - long STOPBITS; - long PARITYON; - long PARITY; + int64_t BAUD; + int64_t DATABITS; + int64_t STOPBITS; + int64_t PARITYON; + int64_t PARITY; - fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY); - if (fd == -1) return fd; // failed to open TTY port + fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC); + if (fd == -1) + { + return fd; // failed to open TTY port + } - if (fcntl(fd, F_SETFL, 0) == -1) LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O - tcgetattr(fd, &options); // read serial port options + if (fcntl(fd, F_SETFL, 0) == -1) + { + LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O + } + tcgetattr(fd, &options); // read serial port options BAUD = B9600; //BAUD = B38400; @@ -341,14 +412,17 @@ void Rtcm_Printer::close_serial() bool Rtcm_Printer::Print_Message(const std::string& message) { //write to file - try + if (d_rtcm_file_dump) { - rtcm_file_descriptor << message << std::endl; - } - catch (const std::exception& ex) - { - DLOG(INFO) << "RTCM printer cannot write on the output file " << rtcm_filename.c_str(); - return false; + try + { + rtcm_file_descriptor << message << std::endl; + } + catch (const std::exception& ex) + { + DLOG(INFO) << "RTCM printer cannot write on the output file " << rtcm_filename.c_str(); + return false; + } } //write to serial device @@ -372,25 +446,25 @@ std::string Rtcm_Printer::print_MT1005_test() } -unsigned int Rtcm_Printer::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm_Printer::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { return rtcm->lock_time(eph, obs_time, gnss_synchro); } -unsigned int Rtcm_Printer::lock_time(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm_Printer::lock_time(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { return rtcm->lock_time(eph, obs_time, gnss_synchro); } -unsigned int Rtcm_Printer::lock_time(const Galileo_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm_Printer::lock_time(const Galileo_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { return rtcm->lock_time(eph, obs_time, gnss_synchro); } -unsigned int Rtcm_Printer::lock_time(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm_Printer::lock_time(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { return rtcm->lock_time(eph, obs_time, gnss_synchro); } diff --git a/src/algorithms/PVT/libs/rtcm_printer.h b/src/algorithms/PVT/libs/rtcm_printer.h index c0a926895..9db248eb9 100644 --- a/src/algorithms/PVT/libs/rtcm_printer.h +++ b/src/algorithms/PVT/libs/rtcm_printer.h @@ -36,8 +36,8 @@ #include "rtcm.h" #include // std::ofstream -#include // std::shared_ptr - +#include +#include // std::shared_ptr /*! * \brief This class provides a implementation of a subset of the RTCM Standard 10403.2 messages @@ -48,17 +48,17 @@ public: /*! * \brief Default constructor. */ - Rtcm_Printer(std::string filename, bool flag_rtcm_server, bool flag_rtcm_tty_port, unsigned short rtcm_tcp_port, unsigned short rtcm_station_id, std::string rtcm_dump_filename, bool time_tag_name = true); + Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump, bool flag_rtcm_server, bool flag_rtcm_tty_port, uint16_t rtcm_tcp_port, uint16_t rtcm_station_id, const std::string& rtcm_dump_devname, bool time_tag_name = true, const std::string& base_path = "."); /*! * \brief Default destructor. */ ~Rtcm_Printer(); - bool Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables); - bool Print_Rtcm_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables); - bool Print_Rtcm_MT1003(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables); - bool Print_Rtcm_MT1004(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1003(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1004(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables); /*! * \brief Prints L1-Only GLONASS RTK Observables * \details This GLONASS message type is not generally used or supported; type 1012 is to be preferred. @@ -68,7 +68,7 @@ public: * \param observables Set of observables as defined by the platform * \return true or false upon operation success */ - bool Print_Rtcm_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables); /*! * \brief Prints Extended L1-Only GLONASS RTK Observables * \details This GLONASS message type is used when only L1 data is present and bandwidth is very tight, often 1012 is used in such cases. @@ -78,7 +78,7 @@ public: * \param observables Set of observables as defined by the platform * \return true or false upon operation success */ - bool Print_Rtcm_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables); /*! * \brief Prints L1&L2 GLONASS RTK Observables * \details This GLONASS message type is not generally used or supported; type 1012 is to be preferred @@ -89,7 +89,7 @@ public: * \param observables Set of observables as defined by the platform * \return true or false upon operation success */ - bool Print_Rtcm_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables); /*! * \brief Prints Extended L1&L2 GLONASS RTK Observables * \details This GLONASS message type is the most common observational message type, with L1/L2/SNR content. This is one of the most common messages found. @@ -100,7 +100,7 @@ public: * \param observables Set of observables as defined by the platform * \return true or false upon operation success */ - bool Print_Rtcm_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables); + bool Print_Rtcm_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables); bool Print_Rtcm_MT1019(const Gps_Ephemeris& gps_eph); //& observables, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); std::string print_MT1005_test(); // rtcm; bool Print_Message(const std::string& message); + bool d_rtcm_file_dump; }; #endif diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 8d74aea20..72e40d2fe 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -52,27 +52,40 @@ * -----------------------------------------------------------------------*/ #include "rtklib_solver.h" -#include "rtklib_conversions.h" +#include "Beidou_B1I.h" +#include "GLONASS_L1_L2_CA.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" -#include "GLONASS_L1_L2_CA.h" +#include "rtklib_conversions.h" +#include "rtklib_solution.h" #include +#include +#include +#include using google::LogMessage; -rtklib_solver::rtklib_solver(int nchannels, std::string dump_filename, bool flag_dump_to_file, rtk_t& rtk) +Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat, const rtk_t &rtk) { // init empty ephemeris for all the available GNSS channels d_nchannels = nchannels; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); d_flag_dump_enabled = flag_dump_to_file; + d_flag_dump_mat_enabled = flag_dump_to_mat; count_valid_position = 0; this->set_averaging_flag(false); rtk_ = rtk; - for (unsigned int i = 0; i > 4; i++) dop_[i] = 0.0; + for (double &i : dop_) + { + i = 0.0; + } pvt_sol = {{0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, '0', '0', '0', 0, 0, 0}; - + ssat_t ssat0 = {0, 0, {0.0}, {0.0}, {0.0}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {}, {}, {}, {}, 0.0, 0.0, 0.0, 0.0, {{{0, 0}}, {{0, 0}}}, {{}, {}}}; + for (auto &i : pvt_ssat) + { + i = ssat0; + } // ############# ENABLE DATA FILE LOG ################# if (d_flag_dump_enabled == true) { @@ -80,20 +93,345 @@ rtklib_solver::rtklib_solver(int nchannels, std::string dump_filename, bool flag { try { - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.exceptions(std::ofstream::failbit | std::ofstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "PVT lib dump enabled Log file: " << d_dump_filename.c_str(); } - catch (const std::ifstream::failure& e) + catch (const std::ofstream::failure &e) { - LOG(WARNING) << "Exception opening PVT lib dump file " << e.what(); + LOG(WARNING) << "Exception opening RTKLIB dump file " << e.what(); } } } + // PVT MONITOR + monitor_pvt.TOW_at_current_symbol_ms = 0U; + monitor_pvt.week = 0U; + monitor_pvt.RX_time = 0.0; + monitor_pvt.user_clk_offset = 0.0; + monitor_pvt.pos_x = 0.0; + monitor_pvt.pos_y = 0.0; + monitor_pvt.pos_z = 0.0; + monitor_pvt.vel_x = 0.0; + monitor_pvt.vel_y = 0.0; + monitor_pvt.vel_z = 0.0; + monitor_pvt.cov_xx = 0.0; + monitor_pvt.cov_yy = 0.0; + monitor_pvt.cov_zz = 0.0; + monitor_pvt.cov_xy = 0.0; + monitor_pvt.cov_yz = 0.0; + monitor_pvt.cov_zx = 0.0; + monitor_pvt.latitude = 0.0; + monitor_pvt.longitude = 0.0; + monitor_pvt.height = 0.0; + monitor_pvt.valid_sats = 0; + monitor_pvt.solution_status = 0; + monitor_pvt.solution_type = 0; + monitor_pvt.AR_ratio_factor = 0.0; + monitor_pvt.AR_ratio_threshold = 0.0; + monitor_pvt.gdop = 0.0; + monitor_pvt.pdop = 0.0; + monitor_pvt.hdop = 0.0; + monitor_pvt.vdop = 0.0; +} + +bool Rtklib_Solver::save_matfile() +{ + // READ DUMP FILE + std::string dump_filename = d_dump_filename; + std::ifstream::pos_type size; + int32_t number_of_double_vars = 21; + int32_t number_of_uint32_vars = 2; + int32_t number_of_uint8_vars = 3; + int32_t number_of_float_vars = 2; + int32_t epoch_size_bytes = sizeof(double) * number_of_double_vars + + sizeof(uint32_t) * number_of_uint32_vars + + sizeof(uint8_t) * number_of_uint8_vars + + sizeof(float) * number_of_float_vars; + std::ifstream dump_file; + std::cout << "Generating .mat file for " << dump_filename << std::endl; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return false; + } + // count number of epochs and rewind + int64_t num_epoch = 0LL; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return false; + } + + auto *TOW_at_current_symbol_ms = new uint32_t[num_epoch]; + auto *week = new uint32_t[num_epoch]; + auto *RX_time = new double[num_epoch]; + auto *user_clk_offset = new double[num_epoch]; + auto *pos_x = new double[num_epoch]; + auto *pos_y = new double[num_epoch]; + auto *pos_z = new double[num_epoch]; + auto *vel_x = new double[num_epoch]; + auto *vel_y = new double[num_epoch]; + auto *vel_z = new double[num_epoch]; + auto *cov_xx = new double[num_epoch]; + auto *cov_yy = new double[num_epoch]; + auto *cov_zz = new double[num_epoch]; + auto *cov_xy = new double[num_epoch]; + auto *cov_yz = new double[num_epoch]; + auto *cov_zx = new double[num_epoch]; + auto *latitude = new double[num_epoch]; + auto *longitude = new double[num_epoch]; + auto *height = new double[num_epoch]; + auto *valid_sats = new uint8_t[num_epoch]; + auto *solution_status = new uint8_t[num_epoch]; + auto *solution_type = new uint8_t[num_epoch]; + auto *AR_ratio_factor = new float[num_epoch]; + auto *AR_ratio_threshold = new float[num_epoch]; + auto *gdop = new double[num_epoch]; + auto *pdop = new double[num_epoch]; + auto *hdop = new double[num_epoch]; + auto *vdop = new double[num_epoch]; + + try + { + if (dump_file.is_open()) + { + for (int64_t i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&TOW_at_current_symbol_ms[i]), sizeof(uint32_t)); + dump_file.read(reinterpret_cast(&week[i]), sizeof(uint32_t)); + dump_file.read(reinterpret_cast(&RX_time[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&user_clk_offset[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&pos_x[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&pos_y[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&pos_z[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&vel_x[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&vel_y[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&vel_z[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&cov_xx[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&cov_yy[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&cov_zz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&cov_xy[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&cov_yz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&cov_zx[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&latitude[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&longitude[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&height[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&valid_sats[i]), sizeof(uint8_t)); + dump_file.read(reinterpret_cast(&solution_status[i]), sizeof(uint8_t)); + dump_file.read(reinterpret_cast(&solution_type[i]), sizeof(uint8_t)); + dump_file.read(reinterpret_cast(&AR_ratio_factor[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&AR_ratio_threshold[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&gdop[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&pdop[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&hdop[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&vdop[i]), sizeof(double)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] TOW_at_current_symbol_ms; + delete[] week; + delete[] RX_time; + delete[] user_clk_offset; + delete[] pos_x; + delete[] pos_y; + delete[] pos_z; + delete[] vel_x; + delete[] vel_y; + delete[] vel_z; + delete[] cov_xx; + delete[] cov_yy; + delete[] cov_zz; + delete[] cov_xy; + delete[] cov_yz; + delete[] cov_zx; + delete[] latitude; + delete[] longitude; + delete[] height; + delete[] valid_sats; + delete[] solution_status; + delete[] solution_type; + delete[] AR_ratio_factor; + delete[] AR_ratio_threshold; + delete[] gdop; + delete[] pdop; + delete[] hdop; + delete[] vdop; + + return false; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_UINT32, MAT_T_UINT32, 2, dims, TOW_at_current_symbol_ms, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("week", MAT_C_UINT32, MAT_T_UINT32, 2, dims, week, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("RX_time", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, RX_time, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("user_clk_offset", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, user_clk_offset, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("pos_x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_x, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("pos_y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_y, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("pos_z", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_z, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("vel_x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_x, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("vel_y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_y, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("vel_z", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_z, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("cov_xx", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_xx, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("cov_yy", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_yy, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("cov_zz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_zz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("cov_xy", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_xy, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("cov_yz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_yz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("cov_zx", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_zx, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("latitude", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, latitude, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("longitude", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, longitude, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("height", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, height, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("valid_sats", MAT_C_UINT8, MAT_T_UINT8, 2, dims, valid_sats, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("solution_status", MAT_C_UINT8, MAT_T_UINT8, 2, dims, solution_status, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("solution_type", MAT_C_UINT8, MAT_T_UINT8, 2, dims, solution_type, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("AR_ratio_factor", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, AR_ratio_factor, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("AR_ratio_threshold", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, AR_ratio_threshold, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("gdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, gdop, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("pdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pdop, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("hdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, hdop, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("vdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vdop, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + + Mat_Close(matfp); + delete[] TOW_at_current_symbol_ms; + delete[] week; + delete[] RX_time; + delete[] user_clk_offset; + delete[] pos_x; + delete[] pos_y; + delete[] pos_z; + delete[] vel_x; + delete[] vel_y; + delete[] vel_z; + delete[] cov_xx; + delete[] cov_yy; + delete[] cov_zz; + delete[] cov_xy; + delete[] cov_yz; + delete[] cov_zx; + delete[] latitude; + delete[] longitude; + delete[] height; + delete[] valid_sats; + delete[] solution_status; + delete[] solution_type; + delete[] AR_ratio_factor; + delete[] AR_ratio_threshold; + delete[] gdop; + delete[] pdop; + delete[] hdop; + delete[] vdop; + + return true; } -rtklib_solver::~rtklib_solver() +Rtklib_Solver::~Rtklib_Solver() { if (d_dump_file.is_open() == true) { @@ -101,45 +439,62 @@ rtklib_solver::~rtklib_solver() { d_dump_file.close(); } - catch (const std::exception& ex) + catch (const std::exception &ex) { - LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); + LOG(WARNING) << "Exception in destructor closing the RTKLIB dump file " << ex.what(); + } + } + if (d_flag_dump_mat_enabled) + { + try + { + save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor saving the PVT .mat dump file " << ex.what(); } } } -double rtklib_solver::get_gdop() const +double Rtklib_Solver::get_gdop() const { return dop_[0]; } -double rtklib_solver::get_pdop() const +double Rtklib_Solver::get_pdop() const { return dop_[1]; } -double rtklib_solver::get_hdop() const +double Rtklib_Solver::get_hdop() const { return dop_[2]; } -double rtklib_solver::get_vdop() const +double Rtklib_Solver::get_vdop() const { return dop_[3]; } +Monitor_Pvt Rtklib_Solver::get_monitor_pvt() const +{ + return monitor_pvt; +} -bool rtklib_solver::get_PVT(const std::map& gnss_observables_map, double Rx_time, bool flag_averaging) +bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_map, bool flag_averaging) { std::map::const_iterator gnss_observables_iter; std::map::const_iterator galileo_ephemeris_iter; std::map::const_iterator gps_ephemeris_iter; std::map::const_iterator gps_cnav_ephemeris_iter; std::map::const_iterator glonass_gnav_ephemeris_iter; + std::map::const_iterator beidou_ephemeris_iter; + const Glonass_Gnav_Utc_Model gnav_utc = this->glonass_gnav_utc_model; this->set_averaging_flag(flag_averaging); @@ -147,16 +502,49 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ // ******************************************************************************** // ****** PREPARE THE DATA (SV EPHEMERIS AND OBSERVATIONS) ************************ // ******************************************************************************** - int valid_obs = 0; //valid observations counter - int glo_valid_obs = 0; //GLONASS L1/L2 valid observations counter + int valid_obs = 0; // valid observations counter + int glo_valid_obs = 0; // GLONASS L1/L2 valid observations counter obsd_t obs_data[MAXOBS]; eph_t eph_data[MAXOBS]; geph_t geph_data[MAXOBS]; + // Workaround for NAV/CNAV clash problem + bool gps_dual_band = false; + bool band1 = false; + bool band2 = false; for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); - gnss_observables_iter++) //CHECK INCONSISTENCY when combining GLONASS + other system + ++gnss_observables_iter) + { + switch (gnss_observables_iter->second.System) + { + case 'G': + { + std::string sig_(gnss_observables_iter->second.Signal); + if (sig_ == "1C") + { + band1 = true; + } + if (sig_ == "2S") + { + band2 = true; + } + } + break; + default: + { + } + } + } + if (band1 == true and band2 == true) + { + gps_dual_band = true; + } + + for (gnss_observables_iter = gnss_observables_map.cbegin(); + gnss_observables_iter != gnss_observables_map.cend(); + ++gnss_observables_iter) // CHECK INCONSISTENCY when combining GLONASS + other system { switch (gnss_observables_iter->second.System) { @@ -164,15 +552,15 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ { std::string sig_(gnss_observables_iter->second.Signal); // Galileo E1 - if (sig_.compare("1B") == 0) + if (sig_ == "1B") { // 1 Gal - find the ephemeris for the current GALILEO SV observation. The SV PRN ID is the map key galileo_ephemeris_iter = galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); if (galileo_ephemeris_iter != galileo_ephemeris_map.cend()) { - //convert ephemeris from GNSS-SDR class to RTKLIB structure + // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second); - //convert observation from GNSS-SDR class to RTKLIB structure + // convert observation from GNSS-SDR class to RTKLIB structure obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, @@ -187,7 +575,7 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ } // Galileo E5 - if (sig_.compare("5X") == 0) + if (sig_ == "5X") { // 1 Gal - find the ephemeris for the current GALILEO SV observation. The SV PRN ID is the map key galileo_ephemeris_iter = galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); @@ -201,25 +589,25 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ obs_data[i + glo_valid_obs] = insert_obs_to_rtklib(obs_data[i + glo_valid_obs], gnss_observables_iter->second, galileo_ephemeris_iter->second.WN_5, - 2); //Band 3 (L5/E5) + 2); // Band 3 (L5/E5) found_E1_obs = true; break; } } if (!found_E1_obs) { - //insert Galileo E5 obs as new obs and also insert its ephemeris - //convert ephemeris from GNSS-SDR class to RTKLIB structure + // insert Galileo E5 obs as new obs and also insert its ephemeris + // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second); - //convert observation from GNSS-SDR class to RTKLIB structure - unsigned char default_code_ = static_cast(CODE_NONE); + // convert observation from GNSS-SDR class to RTKLIB structure + auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {default_code_, default_code_, default_code_}, {}, {0.0, 0.0, 0.0}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, galileo_ephemeris_iter->second.WN_5, - 2); //Band 3 (L5/E5) + 2); // Band 3 (L5/E5) valid_obs++; } } @@ -235,14 +623,14 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ // GPS L1 // 1 GPS - find the ephemeris for the current GPS SV observation. The SV PRN ID is the map key std::string sig_(gnss_observables_iter->second.Signal); - if (sig_.compare("1C") == 0) + if (sig_ == "1C") { gps_ephemeris_iter = gps_ephemeris_map.find(gnss_observables_iter->second.PRN); if (gps_ephemeris_iter != gps_ephemeris_map.cend()) { - //convert ephemeris from GNSS-SDR class to RTKLIB structure + // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(gps_ephemeris_iter->second); - //convert observation from GNSS-SDR class to RTKLIB structure + // convert observation from GNSS-SDR class to RTKLIB structure obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, @@ -255,8 +643,8 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->first; } } - //GPS L2 - if (sig_.compare("2S") == 0) + // GPS L2 (todo: solve NAV/CNAV clash) + if ((sig_ == "2S") and (gps_dual_band == false)) { gps_cnav_ephemeris_iter = gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN); if (gps_cnav_ephemeris_iter != gps_cnav_ephemeris_map.cend()) @@ -276,7 +664,7 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ obs_data[i + glo_valid_obs] = insert_obs_to_rtklib(obs_data[i + glo_valid_obs], gnss_observables_iter->second, eph_data[i].week, - 1); //Band 2 (L2) + 1); // Band 2 (L2) break; } } @@ -285,17 +673,17 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ else { // 3. If not found, insert the GPS L2 ephemeris and the observation - //convert ephemeris from GNSS-SDR class to RTKLIB structure + // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second); - //convert observation from GNSS-SDR class to RTKLIB structure - unsigned char default_code_ = static_cast(CODE_NONE); + // convert observation from GNSS-SDR class to RTKLIB structure + auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {default_code_, default_code_, default_code_}, {}, {0.0, 0.0, 0.0}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, gps_cnav_ephemeris_iter->second.i_GPS_week, - 1); //Band 2 (L2) + 1); // Band 2 (L2) valid_obs++; } } @@ -304,8 +692,8 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->second.PRN; } } - //GPS L5 - if (sig_.compare("L5") == 0) + // GPS L5 + if (sig_ == "L5") { gps_cnav_ephemeris_iter = gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN); if (gps_cnav_ephemeris_iter != gps_cnav_ephemeris_map.cend()) @@ -324,7 +712,7 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ obs_data[i + glo_valid_obs] = insert_obs_to_rtklib(obs_data[i], gnss_observables_iter->second, gps_cnav_ephemeris_iter->second.i_GPS_week, - 2); //Band 3 (L5) + 2); // Band 3 (L5) break; } } @@ -332,17 +720,17 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ else { // 3. If not found, insert the GPS L5 ephemeris and the observation - //convert ephemeris from GNSS-SDR class to RTKLIB structure + // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second); - //convert observation from GNSS-SDR class to RTKLIB structure - unsigned char default_code_ = static_cast(CODE_NONE); + // convert observation from GNSS-SDR class to RTKLIB structure + auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {default_code_, default_code_, default_code_}, {}, {0.0, 0.0, 0.0}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, gps_cnav_ephemeris_iter->second.i_GPS_week, - 2); //Band 3 (L5) + 2); // Band 3 (L5) valid_obs++; } } @@ -357,20 +745,20 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ { std::string sig_(gnss_observables_iter->second.Signal); // GLONASS GNAV L1 - if (sig_.compare("1G") == 0) + if (sig_ == "1G") { // 1 Glo - find the ephemeris for the current GLONASS SV observation. The SV Slot Number (PRN ID) is the map key glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); if (glonass_gnav_ephemeris_iter != glonass_gnav_ephemeris_map.cend()) { - //convert ephemeris from GNSS-SDR class to RTKLIB structure + // convert ephemeris from GNSS-SDR class to RTKLIB structure geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second, gnav_utc); - //convert observation from GNSS-SDR class to RTKLIB structure + // convert observation from GNSS-SDR class to RTKLIB structure obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, glonass_gnav_ephemeris_iter->second.d_WN, - 0); //Band 0 (L1) + 0); // Band 0 (L1) glo_valid_obs++; } else // the ephemeris are not available for this SV @@ -379,7 +767,7 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ } } // GLONASS GNAV L2 - if (sig_.compare("2G") == 0) + if (sig_ == "2G") { // 1 GLONASS - find the ephemeris for the current GLONASS SV observation. The SV PRN ID is the map key glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); @@ -400,15 +788,15 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ } if (!found_L1_obs) { - //insert GLONASS GNAV L2 obs as new obs and also insert its ephemeris - //convert ephemeris from GNSS-SDR class to RTKLIB structure + // insert GLONASS GNAV L2 obs as new obs and also insert its ephemeris + // convert ephemeris from GNSS-SDR class to RTKLIB structure geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second, gnav_utc); - //convert observation from GNSS-SDR class to RTKLIB structure + // convert observation from GNSS-SDR class to RTKLIB structure obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, glonass_gnav_ephemeris_iter->second.d_WN, - 1); //Band 1 (L2) + 1); // Band 1 (L2) glo_valid_obs++; } } @@ -419,6 +807,34 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ } break; } + case 'C': + { + // BEIDOU B1I + // - find the ephemeris for the current BEIDOU SV observation. The SV PRN ID is the map key + std::string sig_(gnss_observables_iter->second.Signal); + if (sig_ == "B1") + { + beidou_ephemeris_iter = beidou_dnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (beidou_ephemeris_iter != beidou_dnav_ephemeris_map.cend()) + { + // convert ephemeris from GNSS-SDR class to RTKLIB structure + eph_data[valid_obs] = eph_to_rtklib(beidou_ephemeris_iter->second); + // convert observation from GNSS-SDR class to RTKLIB structure + obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; + obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, + gnss_observables_iter->second, + beidou_ephemeris_iter->second.i_BEIDOU_week + 1356, + 0); + valid_obs++; + } + else // the ephemeris are not available for this SV + { + DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->first; + } + } + break; + } + default: DLOG(INFO) << "Hybrid observables: Unknown GNSS"; break; @@ -439,11 +855,11 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ nav_data.n = valid_obs; nav_data.ng = glo_valid_obs; - for (int i = 0; i < MAXSAT; i++) + for (auto &i : nav_data.lam) { - nav_data.lam[i][0] = SPEED_OF_LIGHT / FREQ1; /* L1/E1 */ - nav_data.lam[i][1] = SPEED_OF_LIGHT / FREQ2; /* L2 */ - nav_data.lam[i][2] = SPEED_OF_LIGHT / FREQ5; /* L5/E5 */ + i[0] = SPEED_OF_LIGHT / FREQ1; // L1/E1 + i[1] = SPEED_OF_LIGHT / FREQ2; // L2 + i[2] = SPEED_OF_LIGHT / FREQ5; // L5/E5 } result = rtkpos(&rtk_, obs_data, valid_obs + glo_valid_obs, &nav_data); @@ -452,48 +868,91 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ { LOG(INFO) << "RTKLIB rtkpos error"; DLOG(INFO) << "RTKLIB rtkpos error message: " << rtk_.errbuf; - this->set_time_offset_s(0.0); //reset rx time estimation + this->set_time_offset_s(0.0); // reset rx time estimation this->set_num_valid_observations(0); } else { - this->set_num_valid_observations(rtk_.sol.ns); //record the number of valid satellites used by the PVT solver + this->set_num_valid_observations(rtk_.sol.ns); // record the number of valid satellites used by the PVT solver pvt_sol = rtk_.sol; // DOP computation unsigned int used_sats = 0; for (unsigned int i = 0; i < MAXSAT; i++) { - if (int vsat = rtk_.ssat[i].vsat[0] == 1) used_sats++; + pvt_ssat[i] = rtk_.ssat[i]; + if (rtk_.ssat[i].vs == 1) + { + used_sats++; + } } - double azel[used_sats * 2]; + std::vector azel; + azel.reserve(used_sats * 2); unsigned int index_aux = 0; - for (unsigned int i = 0; i < MAXSAT; i++) + for (auto &i : rtk_.ssat) { - if (int vsat = rtk_.ssat[i].vsat[0] == 1) + if (i.vs == 1) { - azel[2 * index_aux] = rtk_.ssat[i].azel[0]; - azel[2 * index_aux + 1] = rtk_.ssat[i].azel[1]; + azel[2 * index_aux] = i.azel[0]; + azel[2 * index_aux + 1] = i.azel[1]; index_aux++; } } - if (index_aux > 0) dops(index_aux, azel, 0.0, dop_); + if (index_aux > 0) + { + dops(index_aux, azel.data(), 0.0, dop_.data()); + } this->set_valid_position(true); arma::vec rx_position_and_time(4); - rx_position_and_time(0) = pvt_sol.rr[0]; - rx_position_and_time(1) = pvt_sol.rr[1]; - rx_position_and_time(2) = pvt_sol.rr[2]; - rx_position_and_time(3) = pvt_sol.dtr[0]; + rx_position_and_time(0) = pvt_sol.rr[0]; // [m] + rx_position_and_time(1) = pvt_sol.rr[1]; // [m] + rx_position_and_time(2) = pvt_sol.rr[2]; // [m] + + //todo: fix this ambiguity in the RTKLIB units in receiver clock offset! + if (rtk_.opt.mode == PMODE_SINGLE) + { + rx_position_and_time(3) = pvt_sol.dtr[0]; // if the RTKLIB solver is set to SINGLE, the dtr is already expressed in [s] + } + else + { + rx_position_and_time(3) = pvt_sol.dtr[0] / GPS_C_M_S; // the receiver clock offset is expressed in [meters], so we convert it into [s] + } this->set_rx_pos(rx_position_and_time.rows(0, 2)); // save ECEF position for the next iteration - double offset_s = this->get_time_offset_s(); - this->set_time_offset_s(offset_s + (rx_position_and_time(3) / GPS_C_m_s)); // accumulate the rx time error for the next iteration [meters]->[seconds] - DLOG(INFO) << "RTKLIB Position at TOW=" << Rx_time << " in ECEF (X,Y,Z,t[meters]) = " << rx_position_and_time; + + //compute Ground speed and COG + double ground_speed_ms = 0.0; + double pos[3]; + double enuv[3]; + ecef2pos(pvt_sol.rr, pos); + ecef2enu(pos, &pvt_sol.rr[3], enuv); + this->set_speed_over_ground(norm_rtk(enuv, 2)); + double new_cog; + if (ground_speed_ms >= 1.0) + { + new_cog = atan2(enuv[0], enuv[1]) * R2D; + if (new_cog < 0.0) + { + new_cog += 360.0; + } + this->set_course_over_ground(new_cog); + } + + //observable fix: + //double offset_s = this->get_time_offset_s(); + //this->set_time_offset_s(offset_s + (rx_position_and_time(3) / GPS_C_m_s)); // accumulate the rx time error for the next iteration [meters]->[seconds] + this->set_time_offset_s(rx_position_and_time(3)); + + DLOG(INFO) << "RTKLIB Position at RX TOW = " << gnss_observables_map.begin()->second.RX_time + << " in ECEF (X,Y,Z,t[meters]) = " << rx_position_and_time; boost::posix_time::ptime p_time; - gtime_t rtklib_utc_time = gpst2utc(pvt_sol.time); + // gtime_t rtklib_utc_time = gpst2utc(pvt_sol.time); //Corrected RX Time (Non integer multiply of 1 ms of granularity) + // Uncorrected RX Time (integer multiply of 1 ms and the same observables time reported in RTCM and RINEX) + gtime_t rtklib_time = gpst2time(adjgpsweek(nav_data.eph[0].week), gnss_observables_map.begin()->second.RX_time); + gtime_t rtklib_utc_time = gpst2utc(rtklib_time); p_time = boost::posix_time::from_time_t(rtklib_utc_time.time); - p_time += boost::posix_time::microseconds(round(rtklib_utc_time.sec * 1e6)); + p_time += boost::posix_time::microseconds(static_cast(round(rtklib_utc_time.sec * 1e6))); // NOLINT(google-runtime-int) this->set_position_UTC_time(p_time); cart2geo(static_cast(rx_position_and_time(0)), static_cast(rx_position_and_time(1)), static_cast(rx_position_and_time(2)), 4); @@ -502,6 +961,58 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ << " [deg], Height= " << this->get_height() << " [m]" << " RX time offset= " << this->get_time_offset_s() << " [s]"; + // PVT MONITOR + + // TOW + monitor_pvt.TOW_at_current_symbol_ms = gnss_observables_map.begin()->second.TOW_at_current_symbol_ms; + // WEEK + monitor_pvt.week = adjgpsweek(nav_data.eph[0].week); + // PVT GPS time + monitor_pvt.RX_time = gnss_observables_map.begin()->second.RX_time; + // User clock offset [s] + monitor_pvt.user_clk_offset = rx_position_and_time(3); + + // ECEF POS X,Y,X [m] + ECEF VEL X,Y,X [m/s] (6 x double) + monitor_pvt.pos_x = pvt_sol.rr[0]; + monitor_pvt.pos_y = pvt_sol.rr[1]; + monitor_pvt.pos_z = pvt_sol.rr[2]; + monitor_pvt.vel_x = pvt_sol.rr[3]; + monitor_pvt.vel_y = pvt_sol.rr[4]; + monitor_pvt.vel_z = pvt_sol.rr[5]; + + // position variance/covariance (m^2) {c_xx,c_yy,c_zz,c_xy,c_yz,c_zx} (6 x double) + monitor_pvt.cov_xx = pvt_sol.qr[0]; + monitor_pvt.cov_yy = pvt_sol.qr[1]; + monitor_pvt.cov_zz = pvt_sol.qr[2]; + monitor_pvt.cov_xy = pvt_sol.qr[3]; + monitor_pvt.cov_yz = pvt_sol.qr[4]; + monitor_pvt.cov_zx = pvt_sol.qr[5]; + + // GEO user position Latitude [deg] + monitor_pvt.latitude = get_latitude(); + // GEO user position Longitude [deg] + monitor_pvt.longitude = get_longitude(); + // GEO user position Height [m] + monitor_pvt.height = get_height(); + + // NUMBER OF VALID SATS + monitor_pvt.valid_sats = pvt_sol.ns; + // RTKLIB solution status + monitor_pvt.solution_status = pvt_sol.stat; + // RTKLIB solution type (0:xyz-ecef,1:enu-baseline) + monitor_pvt.solution_type = pvt_sol.type; + // AR ratio factor for validation + monitor_pvt.AR_ratio_factor = pvt_sol.ratio; + // AR ratio threshold for validation + monitor_pvt.AR_ratio_threshold = pvt_sol.thres; + + // GDOP / PDOP/ HDOP/ VDOP + monitor_pvt.gdop = dop_[0]; + monitor_pvt.pdop = dop_[1]; + monitor_pvt.hdop = dop_[2]; + monitor_pvt.vdop = dop_[3]; + + // ######## LOG FILE ######### if (d_flag_dump_enabled == true) { @@ -509,34 +1020,78 @@ bool rtklib_solver::get_PVT(const std::map& gnss_observables_ try { double tmp_double; - // PVT GPS time - tmp_double = Rx_time; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // ECEF User Position East [m] - tmp_double = rx_position_and_time(0); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // ECEF User Position North [m] - tmp_double = rx_position_and_time(1); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // ECEF User Position Up [m] - tmp_double = rx_position_and_time(2); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + uint32_t tmp_uint32; + // TOW + tmp_uint32 = gnss_observables_map.begin()->second.TOW_at_current_symbol_ms; + d_dump_file.write(reinterpret_cast(&tmp_uint32), sizeof(uint32_t)); + // WEEK + tmp_uint32 = adjgpsweek(nav_data.eph[0].week); + d_dump_file.write(reinterpret_cast(&tmp_uint32), sizeof(uint32_t)); + // PVT GPS time + tmp_double = gnss_observables_map.begin()->second.RX_time; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // User clock offset [s] tmp_double = rx_position_and_time(3); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + + // ECEF POS X,Y,X [m] + ECEF VEL X,Y,X [m/s] (6 x double) + tmp_double = pvt_sol.rr[0]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.rr[1]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.rr[2]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.rr[3]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.rr[4]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.rr[5]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + + // position variance/covariance (m^2) {c_xx,c_yy,c_zz,c_xy,c_yz,c_zx} (6 x double) + tmp_double = pvt_sol.qr[0]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.qr[1]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.qr[2]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.qr[3]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.qr[4]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = pvt_sol.qr[5]; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + // GEO user position Latitude [deg] - tmp_double = this->get_latitude(); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = get_latitude(); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // GEO user position Longitude [deg] - tmp_double = this->get_longitude(); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = get_longitude(); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // GEO user position Height [m] - tmp_double = this->get_height(); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = get_height(); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + + // NUMBER OF VALID SATS + d_dump_file.write(reinterpret_cast(&pvt_sol.ns), sizeof(uint8_t)); + // RTKLIB solution status + d_dump_file.write(reinterpret_cast(&pvt_sol.stat), sizeof(uint8_t)); + // RTKLIB solution type (0:xyz-ecef,1:enu-baseline) + d_dump_file.write(reinterpret_cast(&pvt_sol.type), sizeof(uint8_t)); + // AR ratio factor for validation + d_dump_file.write(reinterpret_cast(&pvt_sol.ratio), sizeof(float)); + // AR ratio threshold for validation + d_dump_file.write(reinterpret_cast(&pvt_sol.thres), sizeof(float)); + + // GDOP / PDOP/ HDOP/ VDOP + d_dump_file.write(reinterpret_cast(&dop_[0]), sizeof(double)); + d_dump_file.write(reinterpret_cast(&dop_[1]), sizeof(double)); + d_dump_file.write(reinterpret_cast(&dop_[2]), sizeof(double)); + d_dump_file.write(reinterpret_cast(&dop_[3]), sizeof(double)); } - catch (const std::ifstream::failure& e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing PVT LS dump file " << e.what(); + LOG(WARNING) << "Exception writing RTKLIB dump file " << e.what(); } } } diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index ac180f617..9f8bd86f9 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -55,13 +55,17 @@ #define GNSS_SDR_RTKLIB_SOLVER_H_ -#include "rtklib_rtkpos.h" +#include "beidou_dnav_navigation_message.h" +#include "galileo_almanac.h" #include "galileo_navigation_message.h" -#include "gps_navigation_message.h" -#include "gps_cnav_navigation_message.h" #include "glonass_gnav_navigation_message.h" #include "gnss_synchro.h" +#include "gps_cnav_navigation_message.h" +#include "gps_navigation_message.h" +#include "monitor_pvt.h" #include "pvt_solution.h" +#include "rtklib_rtkpos.h" +#include #include #include #include @@ -70,38 +74,46 @@ /*! * \brief This class implements a simple PVT Least Squares solution */ -class rtklib_solver : public Pvt_Solution +class Rtklib_Solver : public Pvt_Solution { private: rtk_t rtk_; std::string d_dump_filename; std::ofstream d_dump_file; - sol_t pvt_sol; + bool save_matfile(); + bool d_flag_dump_enabled; + bool d_flag_dump_mat_enabled; int d_nchannels; // Number of available channels for positioning - double dop_[4]; + std::array dop_; + Monitor_Pvt monitor_pvt; public: - rtklib_solver(int nchannels, std::string dump_filename, bool flag_dump_to_file, rtk_t& rtk); - ~rtklib_solver(); + sol_t pvt_sol; + ssat_t pvt_ssat[MAXSAT]; + Rtklib_Solver(int nchannels, std::string dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat, const rtk_t& rtk); + ~Rtklib_Solver(); - bool get_PVT(const std::map& gnss_observables_map, double Rx_time, bool flag_averaging); + bool get_PVT(const std::map& gnss_observables_map, bool flag_averaging); double get_hdop() const; double get_vdop() const; double get_pdop() const; double get_gdop() const; - + Monitor_Pvt get_monitor_pvt() const; + std::map galileo_ephemeris_map; //!< Map storing new Galileo_Ephemeris std::map gps_ephemeris_map; //!< Map storing new GPS_Ephemeris std::map gps_cnav_ephemeris_map; //!< Map storing new GPS_CNAV_Ephemeris - std::map glonass_gnav_ephemeris_map; //!< Map storing new GLONASS GNAV Ephmeris + std::map glonass_gnav_ephemeris_map; //!< Map storing new GLONASS GNAV Ephemeris + std::map beidou_dnav_ephemeris_map; //!< Map storing new GLONASS GNAV Ephmeris Galileo_Utc_Model galileo_utc_model; Galileo_Iono galileo_iono; - Galileo_Almanac galileo_almanac; + std::map galileo_almanac_map; Gps_Utc_Model gps_utc_model; Gps_Iono gps_iono; + std::map gps_almanac_map; Gps_CNAV_Iono gps_cnav_iono; Gps_CNAV_Utc_Model gps_cnav_utc_model; @@ -109,6 +121,10 @@ public: Glonass_Gnav_Utc_Model glonass_gnav_utc_model; //!< Map storing GLONASS GNAV UTC Model Glonass_Gnav_Almanac glonass_gnav_almanac; //!< Map storing GLONASS GNAV Almanac Model + Beidou_Dnav_Utc_Model beidou_dnav_utc_model; + Beidou_Dnav_Iono beidou_dnav_iono; + std::map beidou_dnav_almanac_map; + int count_valid_position; }; diff --git a/src/algorithms/acquisition/CMakeLists.txt b/src/algorithms/acquisition/CMakeLists.txt index 0dc31ec9b..96259341c 100644 --- a/src/algorithms/acquisition/CMakeLists.txt +++ b/src/algorithms/acquisition/CMakeLists.txt @@ -18,7 +18,4 @@ add_subdirectory(adapters) add_subdirectory(gnuradio_blocks) -if(ENABLE_FPGA) - add_subdirectory(libs) -endif(ENABLE_FPGA) - +add_subdirectory(libs) diff --git a/src/algorithms/acquisition/adapters/CMakeLists.txt b/src/algorithms/acquisition/adapters/CMakeLists.txt index 831601796..bfe54fa8e 100644 --- a/src/algorithms/acquisition/adapters/CMakeLists.txt +++ b/src/algorithms/acquisition/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -34,35 +34,92 @@ set(ACQ_ADAPTER_SOURCES galileo_e5a_pcps_acquisition.cc glonass_l1_ca_pcps_acquisition.cc glonass_l2_ca_pcps_acquisition.cc + beidou_b1i_pcps_acquisition.cc +) + +set(ACQ_ADAPTER_HEADERS + gps_l1_ca_pcps_acquisition.h + gps_l1_ca_pcps_assisted_acquisition.h + gps_l1_ca_pcps_acquisition_fine_doppler.h + gps_l1_ca_pcps_tong_acquisition.h + gps_l1_ca_pcps_quicksync_acquisition.h + gps_l2_m_pcps_acquisition.h + gps_l5i_pcps_acquisition.h + galileo_e1_pcps_ambiguous_acquisition.h + galileo_e1_pcps_cccwsr_ambiguous_acquisition.h + galileo_e1_pcps_quicksync_ambiguous_acquisition.h + galileo_e1_pcps_tong_ambiguous_acquisition.h + galileo_e1_pcps_8ms_ambiguous_acquisition.h + galileo_e5a_noncoherent_iq_acquisition_caf.h + galileo_e5a_pcps_acquisition.h + glonass_l1_ca_pcps_acquisition.h + glonass_l2_ca_pcps_acquisition.h ) if(ENABLE_FPGA) - set(ACQ_ADAPTER_SOURCES ${ACQ_ADAPTER_SOURCES} gps_l1_ca_pcps_acquisition_fpga.cc) -endif(ENABLE_FPGA) + set(ACQ_ADAPTER_SOURCES ${ACQ_ADAPTER_SOURCES} + gps_l1_ca_pcps_acquisition_fpga.cc + gps_l2_m_pcps_acquisition_fpga.cc + galileo_e1_pcps_ambiguous_acquisition_fpga.cc + galileo_e5a_pcps_acquisition_fpga.cc + gps_l5i_pcps_acquisition_fpga.cc + ) + set(ACQ_ADAPTER_HEADERS ${ACQ_ADAPTER_HEADERS} + gps_l1_ca_pcps_acquisition_fpga.h + gps_l2_m_pcps_acquisition_fpga.h + galileo_e1_pcps_ambiguous_acquisition_fpga.h + galileo_e5a_pcps_acquisition_fpga.h + gps_l5i_pcps_acquisition_fpga.h + ) +endif() if(OPENCL_FOUND) - set(ACQ_ADAPTER_SOURCES ${ACQ_ADAPTER_SOURCES} gps_l1_ca_pcps_opencl_acquisition.cc) -endif(OPENCL_FOUND) + set(ACQ_ADAPTER_SOURCES + ${ACQ_ADAPTER_SOURCES} + gps_l1_ca_pcps_opencl_acquisition.cc + ) + set(ACQ_ADAPTER_HEADERS ${ACQ_ADAPTER_HEADERS} + gps_l1_ca_pcps_opencl_acquisition.h + ) +endif() -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${ARMADILLO_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${GNURADIO_BLOCKS_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} +list(SORT ACQ_ADAPTER_HEADERS) +list(SORT ACQ_ADAPTER_SOURCES) + +source_group(Headers FILES ${ACQ_ADAPTER_HEADERS}) + +add_library(acquisition_adapters ${ACQ_ADAPTER_SOURCES} ${ACQ_ADAPTER_HEADERS}) + +target_link_libraries(acquisition_adapters + PUBLIC + Gnuradio::blocks + algorithms_libs + gnss_sdr_flags + acquisition_gr_blocks + core_system_parameters + PRIVATE + Boost::boost + Gflags::gflags + Glog::glog + Volkgnsssdr::volkgnsssdr + acquisition_libs ) -file(GLOB ACQ_ADAPTER_HEADERS "*.h") -list(SORT ACQ_ADAPTER_HEADERS) -add_library(acq_adapters ${ACQ_ADAPTER_SOURCES} ${ACQ_ADAPTER_HEADERS}) -source_group(Headers FILES ${ACQ_ADAPTER_HEADERS}) -target_link_libraries(acq_adapters gnss_sp_libs gnss_sdr_flags acq_gr_blocks ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES}) +target_include_directories(acquisition_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(acquisition_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET acquisition_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc new file mode 100644 index 000000000..7ee2a7277 --- /dev/null +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc @@ -0,0 +1,345 @@ +/*! + * \file beidou_b1i_pcps_acquisition.cc + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * BeiDou B1I signals + * \authors
    + *
  • Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + *
+ * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_b1i_pcps_acquisition.h" +#include "Beidou_B1I.h" +#include "acq_conf.h" +#include "beidou_b1i_signal_processing.h" +#include "configuration_interface.h" +#include "gnss_sdr_flags.h" +#include +#include + + +using google::LogMessage; + +BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + Acq_Conf acq_parameters = Acq_Conf(); + configuration_ = configuration; + std::string default_item_type = "gr_complex"; + std::string default_dump_filename = "./data/acquisition.dat"; + + DLOG(INFO) << "role " << role; + + item_type_ = configuration_->property(role + ".item_type", default_item_type); + + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + acq_parameters.fs_in = fs_in_; + dump_ = configuration_->property(role + ".dump", false); + acq_parameters.dump = dump_; + blocking_ = configuration_->property(role + ".blocking", true); + acq_parameters.blocking = blocking_; + doppler_max_ = configuration_->property(role + ".doppler_max", 5000); + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } + acq_parameters.doppler_max = doppler_max_; + sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); + acq_parameters.sampled_ms = sampled_ms_; + bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); + acq_parameters.bit_transition_flag = bit_transition_flag_; + use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions + acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; + max_dwells_ = configuration_->property(role + ".max_dwells", 1); + acq_parameters.max_dwells = max_dwells_; + dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); + acq_parameters.dump_filename = dump_filename_; + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::round(static_cast(fs_in_) / (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS))); + + vector_length_ = code_length_ * sampled_ms_; + + if (bit_transition_flag_) + { + vector_length_ *= 2; + } + + code_ = new gr_complex[vector_length_]; + + if (item_type_ == "cshort") + { + item_size_ = sizeof(lv_16sc_t); + } + else + { + item_size_ = sizeof(gr_complex); + } + acq_parameters.it_size = item_size_; + acq_parameters.sampled_ms = sampled_ms_; + acq_parameters.samples_per_ms = code_length_; + acq_parameters.samples_per_code = code_length_; + acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); + acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); + acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acquisition_ = pcps_make_acquisition(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; + + stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); + DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; + + if (item_type_ == "cbyte") + { + cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); + float_to_complex_ = gr::blocks::float_to_complex::make(); + } + + channel_ = 0; + threshold_ = 0.0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } +} + + +BeidouB1iPcpsAcquisition::~BeidouB1iPcpsAcquisition() +{ + delete[] code_; +} + + +void BeidouB1iPcpsAcquisition::stop_acquisition() +{ +} + +void BeidouB1iPcpsAcquisition::set_channel(uint32_t channel) +{ + channel_ = channel; + acquisition_->set_channel(channel_); +} + + +void BeidouB1iPcpsAcquisition::set_threshold(float threshold) +{ + float pfa = configuration_->property(role_ + ".pfa", 0.0); + + if (pfa == 0.0) + { + threshold_ = threshold; + } + else + { + threshold_ = calculate_threshold(pfa); + } + + DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; + + acquisition_->set_threshold(threshold_); +} + + +void BeidouB1iPcpsAcquisition::set_doppler_max(uint32_t doppler_max) +{ + doppler_max_ = doppler_max; + + acquisition_->set_doppler_max(doppler_max_); +} + + +void BeidouB1iPcpsAcquisition::set_doppler_step(uint32_t doppler_step) +{ + doppler_step_ = doppler_step; + + acquisition_->set_doppler_step(doppler_step_); +} + + +void BeidouB1iPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + + acquisition_->set_gnss_synchro(gnss_synchro_); +} + + +signed int BeidouB1iPcpsAcquisition::mag() +{ + return acquisition_->mag(); +} + + +void BeidouB1iPcpsAcquisition::init() +{ + acquisition_->init(); + set_local_code(); +} + + +void BeidouB1iPcpsAcquisition::set_local_code() +{ + auto* code = new std::complex[code_length_]; + + beidou_b1i_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); + + for (uint32_t i = 0; i < sampled_ms_; i++) + { + memcpy(&(code_[i * code_length_]), code, + sizeof(gr_complex) * code_length_); + } + + acquisition_->set_local_code(code_); + delete[] code; +} + + +void BeidouB1iPcpsAcquisition::reset() +{ + acquisition_->set_active(true); +} + + +void BeidouB1iPcpsAcquisition::set_state(int state) +{ + acquisition_->set_state(state); +} + + +float BeidouB1iPcpsAcquisition::calculate_threshold(float pfa) +{ + //Calculate the threshold + uint32_t frequency_bins = 0; + /* + for (int doppler = (int)(-doppler_max_); doppler <= (int)doppler_max_; doppler += doppler_step_) + { + frequency_bins++; + } + */ + + frequency_bins = (2 * doppler_max_ + doppler_step_) / doppler_step_; + + DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; + uint32_t ncells = vector_length_ * frequency_bins; + double exponent = 1 / static_cast(ncells); + double val = pow(1.0 - pfa, exponent); + auto lambda = static_cast(vector_length_); + boost::math::exponential_distribution mydist(lambda); + auto threshold = static_cast(quantile(mydist, val)); + + return threshold; +} + + +void BeidouB1iPcpsAcquisition::connect(gr::top_block_sptr top_block) +{ + if (item_type_ == "gr_complex") + { + // nothing to connect + } + else if (item_type_ == "cshort") + { + // nothing to connect + } + else if (item_type_ == "cbyte") + { + top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); + top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); + top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); + } + else + { + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + } +} + + +void BeidouB1iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) +{ + if (item_type_ == "gr_complex") + { + // nothing to disconnect + } + else if (item_type_ == "cshort") + { + // nothing to disconnect + } + else if (item_type_ == "cbyte") + { + // Since a byte-based acq implementation is not available, + // we just convert cshorts to gr_complex + top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); + top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); + top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); + } + else + { + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + } +} + + +gr::basic_block_sptr BeidouB1iPcpsAcquisition::get_left_block() +{ + if (item_type_ == "gr_complex") + { + return acquisition_; + } + if (item_type_ == "cshort") + { + return acquisition_; + } + else if (item_type_ == "cbyte") + { + return cbyte_to_float_x2_; + } + else + { + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; + } +} + + +gr::basic_block_sptr BeidouB1iPcpsAcquisition::get_right_block() +{ + return acquisition_; +} + +void BeidouB1iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) +{ + acquisition_->set_resampler_latency(latency_samples); +} diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h new file mode 100644 index 000000000..334aff555 --- /dev/null +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h @@ -0,0 +1,180 @@ +/*! + * \file beidou_bi1_pcps_acquisition.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Beidou B1I signals + * \authors
    + *
  • Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + *
+ * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BEIDOU_B1I_PCPS_ACQUISITION_H_ +#define GNSS_SDR_BEIDOU_B1I_PCPS_ACQUISITION_H_ + +#include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" +#include "gnss_synchro.h" +#include "pcps_acquisition.h" +#include +#include +#include +#include +#include + + +class ConfigurationInterface; + +/*! + * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface + * for GPS L1 C/A signals + */ +class BeidouB1iPcpsAcquisition : public AcquisitionInterface +{ +public: + BeidouB1iPcpsAcquisition(ConfigurationInterface* configuration, + const std::string& role, unsigned int in_streams, + unsigned int out_streams); + + virtual ~BeidouB1iPcpsAcquisition(); + + inline std::string role() override + { + return role_; + } + + /*! + * \brief Returns "BEIDOU_B1I_PCPS_Acquisition" + */ + inline std::string implementation() override + { + return "BEIDOU_B1I_PCPS_Acquisition"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(uint32_t channel) override; + + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) override; + + /*! + * \brief Set maximum Doppler off grid search + */ + void set_doppler_max(uint32_t doppler_max) override; + + /*! + * \brief Set Doppler steps for the grid search + */ + void set_doppler_step(uint32_t doppler_step) override; + + /*! + * \brief Initializes acquisition algorithm. + */ + void init() override; + + /*! + * \brief Sets local code for GPS L1/CA PCPS acquisition algorithm. + */ + void set_local_code() override; + + /*! + * \brief Returns the maximum peak of grid search + */ + signed int mag() override; + + /*! + * \brief Restart acquisition algorithm + */ + void reset() override; + + /*! + * \brief If state = 1, it forces the block to start acquiring from the first sample + */ + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ + void set_resampler_latency(uint32_t latency_samples) override; + + +private: + ConfigurationInterface* configuration_; + pcps_acquisition_sptr acquisition_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; + gr::blocks::float_to_complex::sptr float_to_complex_; + complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + size_t item_size_; + std::string item_type_; + uint32_t vector_length_; + uint32_t code_length_; + bool bit_transition_flag_; + bool use_CFAR_algorithm_flag_; + uint32_t channel_; + float threshold_; + uint32_t doppler_max_; + uint32_t doppler_step_; + uint32_t sampled_ms_; + uint32_t max_dwells_; + int64_t fs_in_; + bool dump_; + bool blocking_; + std::string dump_filename_; + std::complex* code_; + Gnss_Synchro* gnss_synchro_; + std::string role_; + uint32_t in_streams_; + uint32_t out_streams_; + + float calculate_threshold(float pfa); +}; + +#endif /* GNSS_SDR_BEIDOU_B1I_PCPS_ACQUISITION_H_ */ diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc index 58848a9a7..14aa840fa 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc @@ -30,19 +30,23 @@ */ #include "galileo_e1_pcps_8ms_ambiguous_acquisition.h" -#include -#include -#include -#include "galileo_e1_signal_processing.h" #include "Galileo_E1.h" #include "configuration_interface.h" +#include "galileo_e1_signal_processing.h" #include "gnss_sdr_flags.h" +#include +#include using google::LogMessage; + GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -53,12 +57,14 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); if (sampled_ms_ % 4 != 0) @@ -76,7 +82,7 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( //--- Find number of samples per spreading code (4 ms) ----------------- code_length_ = round( - fs_in_ / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS)); + fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); vector_length_ = code_length_ * static_cast(sampled_ms_ / 4); @@ -84,11 +90,11 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = galileo_pcps_8ms_make_acquisition_cc(sampled_ms_, max_dwells_, - doppler_max_, if_, fs_in_, samples_per_ms, code_length_, + doppler_max_, fs_in_, samples_per_ms, code_length_, dump_, dump_filename_); stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); DLOG(INFO) << "stream_to_vector(" @@ -105,7 +111,15 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -115,10 +129,15 @@ GalileoE1Pcps8msAmbiguousAcquisition::~GalileoE1Pcps8msAmbiguousAcquisition() } +void GalileoE1Pcps8msAmbiguousAcquisition::stop_acquisition() +{ +} + + void GalileoE1Pcps8msAmbiguousAcquisition::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -127,9 +146,12 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_channel(unsigned int channel) void GalileoE1Pcps8msAmbiguousAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { @@ -142,7 +164,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -153,7 +175,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_doppler_max(unsigned int doppler_ { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -163,7 +185,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_doppler_max(unsigned int doppler_ void GalileoE1Pcps8msAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -174,7 +196,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_gnss_synchro( Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -183,14 +205,11 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_gnss_synchro( signed int GalileoE1Pcps8msAmbiguousAcquisition::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } - else - { - return 0; - } + return 0; } @@ -203,12 +222,12 @@ void GalileoE1Pcps8msAmbiguousAcquisition::init() void GalileoE1Pcps8msAmbiguousAcquisition::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { bool cboc = configuration_->property( - "Acquisition" + boost::lexical_cast(channel_) + ".cboc", false); + "Acquisition" + std::to_string(channel_) + ".cboc", false); - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal, cboc, gnss_synchro_->PRN, fs_in_, 0, false); @@ -228,7 +247,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_local_code() void GalileoE1Pcps8msAmbiguousAcquisition::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -247,9 +266,9 @@ float GalileoE1Pcps8msAmbiguousAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -257,7 +276,7 @@ float GalileoE1Pcps8msAmbiguousAcquisition::calculate_threshold(float pfa) void GalileoE1Pcps8msAmbiguousAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); } @@ -266,7 +285,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::connect(gr::top_block_sptr top_block) void GalileoE1Pcps8msAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h index 8cc3f3383..ce9cd440b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h @@ -32,12 +32,11 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_8MS_AMBIGUOUS_ACQUISITION_H_ #define GNSS_SDR_GALILEO_E1_PCPS_8MS_AMBIGUOUS_ACQUISITION_H_ -#include -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" #include "galileo_pcps_8ms_acquisition_cc.h" - +#include "gnss_synchro.h" +#include +#include class ConfigurationInterface; @@ -49,7 +48,8 @@ class GalileoE1Pcps8msAmbiguousAcquisition : public AcquisitionInterface { public: GalileoE1Pcps8msAmbiguousAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GalileoE1Pcps8msAmbiguousAcquisition(); @@ -124,6 +124,16 @@ public: */ void reset() override; + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_state(int state __attribute__((unused))) override{}; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; + + private: ConfigurationInterface* configuration_; galileo_pcps_8ms_acquisition_cc_sptr acquisition_cc_; @@ -138,8 +148,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc index c58b5b6f2..24bdc155e 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc @@ -30,61 +30,100 @@ */ #include "galileo_e1_pcps_ambiguous_acquisition.h" +#include "Galileo_E1.h" +#include "acq_conf.h" #include "configuration_interface.h" #include "galileo_e1_signal_processing.h" -#include "Galileo_E1.h" #include "gnss_sdr_flags.h" -#include #include #include using google::LogMessage; + GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - pcpsconf_t acq_parameters; configuration_ = configuration; std::string default_item_type = "gr_complex"; - std::string default_dump_filename = "./data/acquisition.dat"; + std::string default_dump_filename = "./acquisition.mat"; DLOG(INFO) << "role " << role; item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - acq_parameters.fs_in = fs_in_; - if_ = configuration_->property(role + ".if", 0); - acq_parameters.freq = if_; - dump_ = configuration_->property(role + ".dump", false); - acq_parameters.dump = dump_; - blocking_ = configuration_->property(role + ".blocking", true); - acq_parameters.blocking = blocking_; + acq_parameters_.fs_in = fs_in_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; - acq_parameters.doppler_max = doppler_max_; - sampled_ms_ = 4; - acq_parameters.sampled_ms = sampled_ms_; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } + acq_parameters_.doppler_max = doppler_max_; + acq_parameters_.ms_per_code = 4; + sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", acq_parameters_.ms_per_code); + acq_parameters_.sampled_ms = sampled_ms_; + if ((acq_parameters_.sampled_ms % acq_parameters_.ms_per_code) != 0) + { + LOG(WARNING) << "Parameter coherent_integration_time_ms should be a multiple of 4. Setting it to 4"; + acq_parameters_.sampled_ms = acq_parameters_.ms_per_code; + } bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - acq_parameters.bit_transition_flag = bit_transition_flag_; + acq_parameters_.bit_transition_flag = bit_transition_flag_; use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions - acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; + acq_parameters_.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; acquire_pilot_ = configuration_->property(role + ".acquire_pilot", false); //will be true in future versions - max_dwells_ = configuration_->property(role + ".max_dwells", 1); - acq_parameters.max_dwells = max_dwells_; + acq_parameters_.max_dwells = max_dwells_; + dump_ = configuration_->property(role + ".dump", false); + acq_parameters_.dump = dump_; + acq_parameters_.dump_channel = configuration_->property(role + ".dump_channel", 0); + blocking_ = configuration_->property(role + ".blocking", true); + acq_parameters_.blocking = blocking_; dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - acq_parameters.dump_filename = dump_filename_; - //--- Find number of samples per spreading code (4 ms) ----------------- - code_length_ = static_cast(std::round(static_cast(fs_in_) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - acq_parameters.samples_per_code = code_length_; - int samples_per_ms = static_cast(std::round(static_cast(fs_in_) * 0.001)); - acq_parameters.samples_per_ms = samples_per_ms; - vector_length_ = sampled_ms_ * samples_per_ms; + acq_parameters_.dump_filename = dump_filename_; + acq_parameters_.use_automatic_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); + if (acq_parameters_.use_automatic_resampler == true and item_type_ != "gr_complex") + { + LOG(WARNING) << "Galileo E1 acqisition disabled the automatic resampler feature because its item_type is not set to gr_complex"; + acq_parameters_.use_automatic_resampler = false; + } + if (acq_parameters_.use_automatic_resampler) + { + if (acq_parameters_.fs_in > GALILEO_E1_OPT_ACQ_FS_HZ) + { + acq_parameters_.resampler_ratio = floor(static_cast(acq_parameters_.fs_in) / GALILEO_E1_OPT_ACQ_FS_HZ); + uint32_t decimation = acq_parameters_.fs_in / GALILEO_E1_OPT_ACQ_FS_HZ; + while (acq_parameters_.fs_in % decimation > 0) + { + decimation--; + }; + acq_parameters_.resampler_ratio = decimation; + acq_parameters_.resampled_fs = acq_parameters_.fs_in / static_cast(acq_parameters_.resampler_ratio); + } + //--- Find number of samples per spreading code (4 ms) ----------------- + code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(acq_parameters_.resampled_fs) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GALILEO_E1_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters_.resampled_fs))); + } + else + { + //--- Find number of samples per spreading code (4 ms) ----------------- + code_length_ = static_cast(std::floor(static_cast(fs_in_) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(fs_in_) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GALILEO_E1_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters_.fs_in))); + } + + acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast(GALILEO_E1_CODE_PERIOD_MS); + vector_length_ = sampled_ms_ * acq_parameters_.samples_per_ms; if (bit_transition_flag_) { vector_length_ *= 2; @@ -92,7 +131,7 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -100,17 +139,15 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( { item_size_ = sizeof(gr_complex); } - acq_parameters.it_size = item_size_; - acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); - acquisition_ = pcps_make_acquisition(acq_parameters); + acq_parameters_.it_size = item_size_; + acq_parameters_.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); + acq_parameters_.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); + acq_parameters_.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acq_parameters_.blocking_on_standby = configuration_->property(role + ".blocking_on_standby", false); + acquisition_ = pcps_make_acquisition(acq_parameters_); DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); float_to_complex_ = gr::blocks::float_to_complex::make(); @@ -119,7 +156,15 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -129,6 +174,11 @@ GalileoE1PcpsAmbiguousAcquisition::~GalileoE1PcpsAmbiguousAcquisition() } +void GalileoE1PcpsAmbiguousAcquisition::stop_acquisition() +{ +} + + void GalileoE1PcpsAmbiguousAcquisition::set_channel(unsigned int channel) { channel_ = channel; @@ -138,9 +188,12 @@ void GalileoE1PcpsAmbiguousAcquisition::set_channel(unsigned int channel) void GalileoE1PcpsAmbiguousAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { @@ -197,21 +250,37 @@ void GalileoE1PcpsAmbiguousAcquisition::init() void GalileoE1PcpsAmbiguousAcquisition::set_local_code() { bool cboc = configuration_->property( - "Acquisition" + boost::lexical_cast(channel_) + ".cboc", false); + "Acquisition" + std::to_string(channel_) + ".cboc", false); - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; if (acquire_pilot_ == true) { //set local signal generator to Galileo E1 pilot component (1C) char pilot_signal[3] = "1C"; - galileo_e1_code_gen_complex_sampled(code, pilot_signal, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); + if (acq_parameters_.use_automatic_resampler) + { + galileo_e1_code_gen_complex_sampled(code, pilot_signal, + cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false); + } + else + { + galileo_e1_code_gen_complex_sampled(code, pilot_signal, + cboc, gnss_synchro_->PRN, fs_in_, 0, false); + } } else { - galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); + if (acq_parameters_.use_automatic_resampler) + { + galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal, + cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false); + } + else + { + galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal, + cboc, gnss_synchro_->PRN, fs_in_, 0, false); + } } @@ -250,9 +319,9 @@ float GalileoE1PcpsAmbiguousAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -260,20 +329,21 @@ float GalileoE1PcpsAmbiguousAcquisition::calculate_threshold(float pfa) void GalileoE1PcpsAmbiguousAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { + // Since a byte-based acq implementation is not available, + // we just convert cshorts to gr_complex top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + top_block->connect(float_to_complex_, 0, acquisition_, 0); } else { @@ -284,22 +354,19 @@ void GalileoE1PcpsAmbiguousAcquisition::connect(gr::top_block_sptr top_block) void GalileoE1PcpsAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { - // Since a byte-based acq implementation is not available, - // we just convert cshorts to gr_complex top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + top_block->disconnect(float_to_complex_, 0, acquisition_, 0); } else { @@ -310,23 +377,21 @@ void GalileoE1PcpsAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } @@ -334,3 +399,8 @@ gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_right_block() { return acquisition_; } + +void GalileoE1PcpsAmbiguousAcquisition::set_resampler_latency(uint32_t latency_samples) +{ + acquisition_->set_resampler_latency(latency_samples); +} diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h index 9020cf15f..ee4538022 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h @@ -32,11 +32,11 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_H_ #define GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_H_ +#include "acq_conf.h" #include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include "complex_byte_to_float_x2.h" -#include #include #include #include @@ -52,7 +52,8 @@ class GalileoE1PcpsAmbiguousAcquisition : public AcquisitionInterface { public: GalileoE1PcpsAmbiguousAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GalileoE1PcpsAmbiguousAcquisition(); @@ -130,12 +131,24 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ + + void set_resampler_latency(uint32_t latency_samples) override; + private: ConfigurationInterface* configuration_; + Acq_Conf acq_parameters_; pcps_acquisition_sptr acquisition_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; size_t item_size_; @@ -151,8 +164,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc new file mode 100644 index 000000000..9f2b53e59 --- /dev/null +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -0,0 +1,280 @@ +/*! + * \file galileo_e1_pcps_ambiguous_acquisition_fpga.cc + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Galileo E1 Signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.es + * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" +#include "Galileo_E1.h" +#include "configuration_interface.h" +#include "galileo_e1_signal_processing.h" +#include "gnss_sdr_flags.h" +#include +#include +#include + + +using google::LogMessage; + + +GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + pcpsconf_fpga_t acq_parameters; + configuration_ = configuration; + + std::string default_item_type = "cshort"; + std::string default_dump_filename = "./data/acquisition.dat"; + + + DLOG(INFO) << "role " << role; + + // item_type_ = configuration_->property(role + ".item_type", default_item_type); + + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); + acq_parameters.downsampling_factor = downsampling_factor; + + fs_in = fs_in / downsampling_factor; + + acq_parameters.fs_in = fs_in; + + doppler_max_ = configuration_->property(role + ".doppler_max", 5000); + if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + acq_parameters.doppler_max = doppler_max_; + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 4); + acq_parameters.sampled_ms = sampled_ms; + + acquire_pilot_ = configuration_->property(role + ".acquire_pilot", false); //will be true in future versions + + //--- Find number of samples per spreading code (4 ms) ----------------- + auto code_length = static_cast(std::round(static_cast(fs_in) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + + acq_parameters.code_length = code_length; + // The FPGA can only use FFT lengths that are a power of two. + float nbits = ceilf(log2f((float)code_length * 2)); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); + + acq_parameters.select_queue_Fpga = select_queue_Fpga; + std::string default_device_name = "/dev/uio0"; + std::string device_name = configuration_->property(role + ".devicename", default_device_name); + acq_parameters.device_name = device_name; + acq_parameters.samples_per_ms = nsamples_total / sampled_ms; + acq_parameters.samples_per_code = nsamples_total; + acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GALILEO_E1_CODE_CHIP_RATE_HZ)); + + // compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time + // a channel is assigned) + auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT + auto* code = new std::complex[nsamples_total]; // buffer for the local code + auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_all_fft_codes_ = new lv_16sc_t[nsamples_total * GALILEO_E1_NUMBER_OF_CODES]; // memory containing all the possible fft codes for PRN 0 to 32 + float max; // temporary maxima search + + for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) + { + bool cboc = false; // cboc is set to 0 when using the FPGA + + if (acquire_pilot_ == true) + { + //set local signal generator to Galileo E1 pilot component (1C) + char pilot_signal[3] = "1C"; + galileo_e1_code_gen_complex_sampled(code, pilot_signal, + cboc, PRN, fs_in, 0, false); + } + else + { + char data_signal[3] = "1B"; + galileo_e1_code_gen_complex_sampled(code, data_signal, + cboc, PRN, fs_in, 0, false); + } + + for (uint32_t s = code_length; s < 2 * code_length; s++) + { + code[s] = code[s - code_length]; + } + + + // fill in zero padding + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) + { + code[s] = std::complex(static_cast(0, 0)); + } + + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + fft_if->execute(); // Run the FFT of local code + volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values + + // normalize the code + max = 0; // initialize maximum value + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima + { + if (std::abs(fft_codes_padded[i].real()) > max) + { + max = std::abs(fft_codes_padded[i].real()); + } + if (std::abs(fft_codes_padded[i].imag()) > max) + { + max = std::abs(fft_codes_padded[i].imag()); + } + } + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + { + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + } + } + + acq_parameters.all_fft_codes = d_all_fft_codes_; + + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); + + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + channel_ = 0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + + // temporary buffers that we can delete + delete[] code; + delete fft_if; + delete[] fft_codes_padded; +} + + +GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga() +{ + delete[] d_all_fft_codes_; +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::stop_acquisition() +{ + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + acquisition_fpga_->set_channel(channel_); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_threshold(float threshold) +{ + DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; + acquisition_fpga_->set_threshold(threshold); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_doppler_max(unsigned int doppler_max) +{ + doppler_max_ = doppler_max; + acquisition_fpga_->set_doppler_max(doppler_max_); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_doppler_step(unsigned int doppler_step) +{ + doppler_step_ = doppler_step; + acquisition_fpga_->set_doppler_step(doppler_step_); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + acquisition_fpga_->set_gnss_synchro(gnss_synchro_); +} + + +signed int GalileoE1PcpsAmbiguousAcquisitionFpga::mag() +{ + return acquisition_fpga_->mag(); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::init() +{ + acquisition_fpga_->init(); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_local_code() +{ + acquisition_fpga_->set_local_code(); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::reset() +{ + // This command starts the acquisition process + acquisition_fpga_->set_active(true); +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_state(int state) +{ + acquisition_fpga_->set_state(state); +} + +void GalileoE1PcpsAmbiguousAcquisitionFpga::connect(gr::top_block_sptr top_block) +{ + // nothing to connect +} + + +void GalileoE1PcpsAmbiguousAcquisitionFpga::disconnect(gr::top_block_sptr top_block) +{ + // nothing to disconnect +} + + +gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisitionFpga::get_left_block() +{ + return nullptr; +} + + +gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisitionFpga::get_right_block() +{ + return acquisition_fpga_; +} diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h new file mode 100644 index 000000000..428f13210 --- /dev/null +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -0,0 +1,169 @@ +/*! + * \file galileo_e1_pcps_ambiguous_acquisition_fpga.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Galileo E1 Signals + * \author Marc Majoral, 2019. mmajoral(at)cttc.es + * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ +#define GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ + +#include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" +#include "gnss_synchro.h" +#include "pcps_acquisition_fpga.h" +#include +#include +#include +#include + + +class ConfigurationInterface; + +/*! + * \brief This class adapts a PCPS acquisition block to an + * AcquisitionInterface for Galileo E1 Signals + */ +class GalileoE1PcpsAmbiguousAcquisitionFpga : public AcquisitionInterface +{ +public: + GalileoE1PcpsAmbiguousAcquisitionFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GalileoE1PcpsAmbiguousAcquisitionFpga(); + + inline std::string role() override + { + return role_; + } + + /*! + * \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga" + */ + inline std::string implementation() override + { + return "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga"; + } + + size_t item_size() override + { + size_t item_size = sizeof(lv_16sc_t); + return item_size; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) override; + + /*! + * \brief Set maximum Doppler off grid search + */ + void set_doppler_max(unsigned int doppler_max) override; + + /*! + * \brief Set Doppler steps for the grid search + */ + void set_doppler_step(unsigned int doppler_step) override; + + /*! + * \brief Initializes acquisition algorithm. + */ + void init() override; + + /*! + * \brief Sets local code for Galileo E1 PCPS acquisition algorithm. + */ + void set_local_code() override; + + /*! + * \brief Returns the maximum peak of grid search + */ + signed int mag() override; + + /*! + * \brief Restart acquisition algorithm + */ + void reset() override; + + /*! + * \brief If state = 1, it forces the block to start acquiring from the first sample + */ + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; + +private: + ConfigurationInterface* configuration_; + pcps_acquisition_fpga_sptr acquisition_fpga_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; + gr::blocks::float_to_complex::sptr float_to_complex_; + complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + bool bit_transition_flag_; + bool use_CFAR_algorithm_flag_; + bool acquire_pilot_; + uint32_t channel_; + uint32_t doppler_max_; + uint32_t doppler_step_; + uint32_t max_dwells_; + bool dump_; + bool blocking_; + std::string dump_filename_; + Gnss_Synchro* gnss_synchro_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; + + lv_16sc_t* d_all_fft_codes_; // memory that contains all the code ffts +}; + +#endif /* GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ */ diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc index 12fe08849..eab75852e 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc @@ -30,19 +30,23 @@ */ #include "galileo_e1_pcps_cccwsr_ambiguous_acquisition.h" -#include -#include -#include -#include "galileo_e1_signal_processing.h" #include "Galileo_E1.h" #include "configuration_interface.h" +#include "galileo_e1_signal_processing.h" #include "gnss_sdr_flags.h" +#include +#include using google::LogMessage; + GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -52,12 +56,14 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); if (sampled_ms_ % 4 != 0) @@ -76,7 +82,7 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition //--- Find number of samples per spreading code (4 ms) ----------------- code_length_ = round( - fs_in_ / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS)); + fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); vector_length_ = code_length_ * static_cast(sampled_ms_ / 4); @@ -85,11 +91,11 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition code_data_ = new gr_complex[vector_length_]; code_pilot_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = pcps_cccwsr_make_acquisition_cc(sampled_ms_, max_dwells_, - doppler_max_, if_, fs_in_, samples_per_ms, code_length_, + doppler_max_, fs_in_, samples_per_ms, code_length_, dump_, dump_filename_); stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); DLOG(INFO) << "stream_to_vector(" @@ -106,7 +112,15 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -117,10 +131,15 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::~GalileoE1PcpsCccwsrAmbiguousAcquisitio } +void GalileoE1PcpsCccwsrAmbiguousAcquisition::stop_acquisition() +{ +} + + void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -129,7 +148,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_channel(unsigned int channel) void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_threshold(float threshold) { - // float pfa = configuration_->property(role_+ boost::lexical_cast(channel_) + ".pfa", 0.0); + // float pfa = configuration_->property(role_+ std::to_string(channel_) + ".pfa", 0.0); // if(pfa==0.0) pfa = configuration_->property(role_+".pfa", 0.0); @@ -146,7 +165,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -157,7 +176,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_doppler_max(unsigned int doppl { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -167,7 +186,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_doppler_max(unsigned int doppl void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -177,7 +196,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_gnss_synchro( Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -186,14 +205,11 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_gnss_synchro( signed int GalileoE1PcpsCccwsrAmbiguousAcquisition::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } - else - { - return 0; - } + return 0; } @@ -206,10 +222,10 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::init() void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { bool cboc = configuration_->property( - "Acquisition" + boost::lexical_cast(channel_) + ".cboc", false); + "Acquisition" + std::to_string(channel_) + ".cboc", false); char signal[3]; @@ -230,7 +246,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_local_code() void GalileoE1PcpsCccwsrAmbiguousAcquisition::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -253,7 +269,7 @@ float GalileoE1PcpsCccwsrAmbiguousAcquisition::calculate_threshold(float pfa) void GalileoE1PcpsCccwsrAmbiguousAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); } @@ -262,7 +278,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::connect(gr::top_block_sptr top_blo void GalileoE1PcpsCccwsrAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h index 01e63c256..4e472c112 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h @@ -32,12 +32,11 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_CCCWSR_AMBIGUOUS_ACQUISITION_H_ #define GNSS_SDR_GALILEO_E1_PCPS_CCCWSR_AMBIGUOUS_ACQUISITION_H_ -#include -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" +#include "gnss_synchro.h" #include "pcps_cccwsr_acquisition_cc.h" - +#include +#include class ConfigurationInterface; @@ -49,7 +48,8 @@ class GalileoE1PcpsCccwsrAmbiguousAcquisition : public AcquisitionInterface { public: GalileoE1PcpsCccwsrAmbiguousAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GalileoE1PcpsCccwsrAmbiguousAcquisition(); @@ -124,7 +124,14 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; @@ -141,8 +148,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_data_; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc index 519dccc86..490ff99bd 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc @@ -30,19 +30,23 @@ */ #include "galileo_e1_pcps_quicksync_ambiguous_acquisition.h" -#include -#include -#include -#include "galileo_e1_signal_processing.h" #include "Galileo_E1.h" #include "configuration_interface.h" +#include "galileo_e1_signal_processing.h" #include "gnss_sdr_flags.h" +#include +#include using google::LogMessage; + GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -53,24 +57,26 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 8); /*--- Find number of samples per spreading code (4 ms) -----------------*/ code_length_ = round( - fs_in_ / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS)); + fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); int samples_per_ms = round(code_length_ / 4.0); /*Calculate the folding factor value based on the formula described in the paper. This may be a bug, but acquisition also work by variying the folding factor at va- lues different that the expressed in the paper. In adition, it is important to point - out that by making the folding factor smaller we were able to get QuickSync work with + out that by making the folding factor smaller we were able to get QuickSync work with Galileo. Future work should be directed to test this asumption statistically.*/ //folding_factor_ = static_cast(ceil(sqrt(log2(code_length_)))); @@ -116,11 +122,11 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui << ", Folding factor: " << folding_factor_ << ", Sampled ms: " << sampled_ms_ << ", Code Length: " << code_length_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = pcps_quicksync_make_acquisition_cc(folding_factor_, - sampled_ms_, max_dwells_, doppler_max_, if_, fs_in_, + sampled_ms_, max_dwells_, doppler_max_, fs_in_, samples_per_ms, code_length_, bit_transition_flag_, dump_, dump_filename_); stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, @@ -139,7 +145,15 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -149,10 +163,15 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::~GalileoE1PcpsQuickSyncAmbiguousAcqu } +void GalileoE1PcpsQuickSyncAmbiguousAcquisition::stop_acquisition() +{ +} + + void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -161,9 +180,12 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_channel(unsigned int channe void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { @@ -176,7 +198,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -187,7 +209,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_doppler_max(unsigned int do { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -197,7 +219,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_doppler_max(unsigned int do void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -207,7 +229,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_gnss_synchro( Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -217,14 +239,11 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_gnss_synchro( signed int GalileoE1PcpsQuickSyncAmbiguousAcquisition::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } - else - { - return 0; - } + return 0; } @@ -237,12 +256,12 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::init() void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { bool cboc = configuration_->property( - "Acquisition" + boost::lexical_cast(channel_) + ".cboc", false); + "Acquisition" + std::to_string(channel_) + ".cboc", false); - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal, cboc, gnss_synchro_->PRN, fs_in_, 0, false); @@ -258,14 +277,14 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_local_code() acquisition_cc_->set_local_code(code_); delete[] code; - code = NULL; + code = nullptr; } } void GalileoE1PcpsQuickSyncAmbiguousAcquisition::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -273,7 +292,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::reset() void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_state(int state) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_state(state); } @@ -295,7 +314,7 @@ float GalileoE1PcpsQuickSyncAmbiguousAcquisition::calculate_threshold(float pfa) double val = pow(1.0 - pfa, exponent); double lambda = static_cast(code_length_) / static_cast(folding_factor_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -303,7 +322,7 @@ float GalileoE1PcpsQuickSyncAmbiguousAcquisition::calculate_threshold(float pfa) void GalileoE1PcpsQuickSyncAmbiguousAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); } @@ -312,7 +331,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::connect(gr::top_block_sptr top_ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h index 8c9f0b43a..981cf46a6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h @@ -32,11 +32,11 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_QUICKSYNC_AMBIGUOUS_ACQUISITION_H_ #define GNSS_SDR_GALILEO_E1_PCPS_QUICKSYNC_AMBIGUOUS_ACQUISITION_H_ -#include -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" +#include "gnss_synchro.h" #include "pcps_quicksync_acquisition_cc.h" +#include +#include class ConfigurationInterface; @@ -49,7 +49,8 @@ class GalileoE1PcpsQuickSyncAmbiguousAcquisition : public AcquisitionInterface { public: GalileoE1PcpsQuickSyncAmbiguousAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GalileoE1PcpsQuickSyncAmbiguousAcquisition(); @@ -127,7 +128,14 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; @@ -145,8 +153,7 @@ private: unsigned int sampled_ms_; unsigned int max_dwells_; unsigned int folding_factor_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc index 757ed5bfc..2f538e8f8 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc @@ -30,19 +30,23 @@ */ #include "galileo_e1_pcps_tong_ambiguous_acquisition.h" -#include -#include -#include -#include "galileo_e1_signal_processing.h" #include "Galileo_E1.h" #include "configuration_interface.h" +#include "galileo_e1_signal_processing.h" #include "gnss_sdr_flags.h" +#include +#include using google::LogMessage; + GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -53,12 +57,14 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); if (sampled_ms_ % 4 != 0) @@ -79,7 +85,7 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( //--- Find number of samples per spreading code (4 ms) ----------------- code_length_ = round( - fs_in_ / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS)); + fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); vector_length_ = code_length_ * static_cast(sampled_ms_ / 4); @@ -87,11 +93,11 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = pcps_tong_make_acquisition_cc(sampled_ms_, doppler_max_, - if_, fs_in_, samples_per_ms, code_length_, tong_init_val_, + fs_in_, samples_per_ms, code_length_, tong_init_val_, tong_max_val_, tong_max_dwells_, dump_, dump_filename_); stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); @@ -109,7 +115,15 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -119,10 +133,15 @@ GalileoE1PcpsTongAmbiguousAcquisition::~GalileoE1PcpsTongAmbiguousAcquisition() } +void GalileoE1PcpsTongAmbiguousAcquisition::stop_acquisition() +{ +} + + void GalileoE1PcpsTongAmbiguousAcquisition::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -131,9 +150,12 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_channel(unsigned int channel) void GalileoE1PcpsTongAmbiguousAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { @@ -146,7 +168,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -157,7 +179,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_doppler_max(unsigned int doppler { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -167,7 +189,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_doppler_max(unsigned int doppler void GalileoE1PcpsTongAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -178,7 +200,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_gnss_synchro( Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -187,14 +209,11 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_gnss_synchro( signed int GalileoE1PcpsTongAmbiguousAcquisition::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } - else - { - return 0; - } + return 0; } @@ -207,12 +226,12 @@ void GalileoE1PcpsTongAmbiguousAcquisition::init() void GalileoE1PcpsTongAmbiguousAcquisition::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { bool cboc = configuration_->property( - "Acquisition" + boost::lexical_cast(channel_) + ".cboc", false); + "Acquisition" + std::to_string(channel_) + ".cboc", false); - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal, cboc, gnss_synchro_->PRN, fs_in_, 0, false); @@ -232,7 +251,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_local_code() void GalileoE1PcpsTongAmbiguousAcquisition::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -257,9 +276,9 @@ float GalileoE1PcpsTongAmbiguousAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -267,7 +286,7 @@ float GalileoE1PcpsTongAmbiguousAcquisition::calculate_threshold(float pfa) void GalileoE1PcpsTongAmbiguousAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); } @@ -276,7 +295,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::connect(gr::top_block_sptr top_block void GalileoE1PcpsTongAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h index 675d79770..95fbaee0b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h @@ -32,12 +32,11 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_TONG_AMBIGUOUS_ACQUISITION_H_ #define GNSS_SDR_GALILEO_E1_PCPS_TONG_AMBIGUOUS_ACQUISITION_H_ -#include -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" +#include "gnss_synchro.h" #include "pcps_tong_acquisition_cc.h" - +#include +#include class ConfigurationInterface; @@ -49,7 +48,8 @@ class GalileoE1PcpsTongAmbiguousAcquisition : public AcquisitionInterface { public: GalileoE1PcpsTongAmbiguousAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GalileoE1PcpsTongAmbiguousAcquisition(); @@ -127,7 +127,14 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; @@ -145,8 +152,7 @@ private: unsigned int tong_init_val_; unsigned int tong_max_val_; unsigned int tong_max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc index 9f23a55f3..277c48b91 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc @@ -36,19 +36,23 @@ */ #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" -#include -#include -#include -#include "galileo_e5_signal_processing.h" #include "Galileo_E5a.h" #include "configuration_interface.h" +#include "galileo_e5_signal_processing.h" #include "gnss_sdr_flags.h" +#include +#include using google::LogMessage; + GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -58,12 +62,14 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } CAF_window_hz_ = configuration_->property(role + ".CAF_window_hz", 0); Zero_padding = configuration_->property(role + ".Zero_padding", 0); sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); @@ -85,7 +91,7 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); //--- Find number of samples per spreading code (1ms)------------------------- - code_length_ = round(static_cast(fs_in_) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS)); + code_length_ = round(static_cast(fs_in_) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS)); vector_length_ = code_length_ * sampled_ms_; @@ -98,11 +104,11 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( { both_signal_components = true; } - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = galileo_e5a_noncoherentIQ_make_acquisition_caf_cc(sampled_ms_, max_dwells_, - doppler_max_, if_, fs_in_, code_length_, code_length_, bit_transition_flag_, + doppler_max_, fs_in_, code_length_, code_length_, bit_transition_flag_, dump_, dump_filename_, both_signal_components, CAF_window_hz_, Zero_padding); } else @@ -114,7 +120,15 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -125,10 +139,15 @@ GalileoE5aNoncoherentIQAcquisitionCaf::~GalileoE5aNoncoherentIQAcquisitionCaf() } +void GalileoE5aNoncoherentIQAcquisitionCaf::stop_acquisition() +{ +} + + void GalileoE5aNoncoherentIQAcquisitionCaf::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -137,9 +156,12 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_channel(unsigned int channel) void GalileoE5aNoncoherentIQAcquisitionCaf::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { @@ -152,7 +174,7 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -163,7 +185,7 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_doppler_max(unsigned int doppler { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -173,7 +195,7 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_doppler_max(unsigned int doppler void GalileoE5aNoncoherentIQAcquisitionCaf::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -184,7 +206,7 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_gnss_synchro( Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -193,14 +215,11 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_gnss_synchro( signed int GalileoE5aNoncoherentIQAcquisitionCaf::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } - else - { - return 0; - } + return 0; } @@ -213,10 +232,10 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::init() void GalileoE5aNoncoherentIQAcquisitionCaf::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - std::complex* codeI = new std::complex[code_length_]; - std::complex* codeQ = new std::complex[code_length_]; + auto* codeI = new std::complex[code_length_]; + auto* codeQ = new std::complex[code_length_]; if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') { @@ -270,7 +289,7 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_local_code() void GalileoE5aNoncoherentIQAcquisitionCaf::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -289,9 +308,9 @@ float GalileoE5aNoncoherentIQAcquisitionCaf::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h index 002744426..3e4d936aa 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h @@ -38,10 +38,10 @@ #ifndef GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_H_ #define GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_H_ -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h" +#include "gnss_synchro.h" +#include class ConfigurationInterface; @@ -49,7 +49,8 @@ class GalileoE5aNoncoherentIQAcquisitionCaf : public AcquisitionInterface { public: GalileoE5aNoncoherentIQAcquisitionCaf(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GalileoE5aNoncoherentIQAcquisitionCaf(); @@ -129,7 +130,14 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; @@ -145,8 +153,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; int Zero_padding; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc index 1367c0272..963cfe5f3 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc @@ -29,11 +29,11 @@ */ #include "galileo_e5a_pcps_acquisition.h" +#include "Galileo_E5a.h" +#include "acq_conf.h" #include "configuration_interface.h" #include "galileo_e5_signal_processing.h" -#include "Galileo_E5a.h" #include "gnss_sdr_flags.h" -#include #include #include #include @@ -41,22 +41,25 @@ using google::LogMessage; + GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - pcpsconf_t acq_parameters; configuration_ = configuration; std::string default_item_type = "gr_complex"; - std::string default_dump_filename = "../data/acquisition.dat"; + std::string default_dump_filename = "./acquisition.mat"; DLOG(INFO) << "Role " << role; item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - acq_parameters.fs_in = fs_in_; - acq_parameters.freq = 0; + acq_parameters_.fs_in = fs_in_; acq_pilot_ = configuration_->property(role + ".acquire_pilot", false); acq_iq_ = configuration_->property(role + ".acquire_iq", false); if (acq_iq_) @@ -64,32 +67,72 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con acq_pilot_ = false; } dump_ = configuration_->property(role + ".dump", false); - acq_parameters.dump = dump_; + acq_parameters_.dump = dump_; + acq_parameters_.dump_channel = configuration_->property(role + ".dump_channel", 0); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; - acq_parameters.doppler_max = doppler_max_; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } + acq_parameters_.doppler_max = doppler_max_; sampled_ms_ = 1; max_dwells_ = configuration_->property(role + ".max_dwells", 1); - acq_parameters.max_dwells = max_dwells_; + acq_parameters_.max_dwells = max_dwells_; dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - acq_parameters.dump_filename = dump_filename_; + acq_parameters_.dump_filename = dump_filename_; bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - acq_parameters.bit_transition_flag = bit_transition_flag_; + acq_parameters_.bit_transition_flag = bit_transition_flag_; use_CFAR_ = configuration_->property(role + ".use_CFAR_algorithm", false); - acq_parameters.use_CFAR_algorithm_flag = use_CFAR_; + acq_parameters_.use_CFAR_algorithm_flag = use_CFAR_; blocking_ = configuration_->property(role + ".blocking", true); - acq_parameters.blocking = blocking_; + acq_parameters_.blocking = blocking_; + + + acq_parameters_.use_automatic_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); + if (acq_parameters_.use_automatic_resampler == true and item_type_ != "gr_complex") + { + LOG(WARNING) << "Galileo E5a acquisition disabled the automatic resampler feature because its item_type is not set to gr_complex"; + acq_parameters_.use_automatic_resampler = false; + } + if (acq_parameters_.use_automatic_resampler) + { + if (acq_parameters_.fs_in > GALILEO_E5A_OPT_ACQ_FS_HZ) + { + acq_parameters_.resampler_ratio = floor(static_cast(acq_parameters_.fs_in) / GALILEO_E5A_OPT_ACQ_FS_HZ); + uint32_t decimation = acq_parameters_.fs_in / GALILEO_E5A_OPT_ACQ_FS_HZ; + while (acq_parameters_.fs_in % decimation > 0) + { + decimation--; + }; + acq_parameters_.resampler_ratio = decimation; + acq_parameters_.resampled_fs = acq_parameters_.fs_in / static_cast(acq_parameters_.resampler_ratio); + } + + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(acq_parameters_.resampled_fs) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GALILEO_E5A_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters_.resampled_fs))); + } + else + { + acq_parameters_.resampled_fs = fs_in_; + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(fs_in_) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(fs_in_) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GALILEO_E5A_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters_.fs_in))); + } + //--- Find number of samples per spreading code (1ms)------------------------- - code_length_ = static_cast(std::round(static_cast(fs_in_) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + code_length_ = static_cast(std::round(static_cast(fs_in_) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); vector_length_ = code_length_ * sampled_ms_; code_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -98,20 +141,28 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con item_size_ = sizeof(gr_complex); LOG(WARNING) << item_type_ << " unknown acquisition item type"; } - acq_parameters.it_size = item_size_; - acq_parameters.samples_per_code = code_length_; - acq_parameters.samples_per_ms = code_length_; - acq_parameters.sampled_ms = sampled_ms_; - acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); - acquisition_ = pcps_make_acquisition(acq_parameters); + acq_parameters_.it_size = item_size_; + acq_parameters_.sampled_ms = sampled_ms_; + acq_parameters_.ms_per_code = 1; + acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast(GALILEO_E5A_CODE_PERIOD_MS); + acq_parameters_.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); + acq_parameters_.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); + acq_parameters_.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acq_parameters_.blocking_on_standby = configuration_->property(role + ".blocking_on_standby", false); + acquisition_ = pcps_make_acquisition(acq_parameters_); - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -121,6 +172,11 @@ GalileoE5aPcpsAcquisition::~GalileoE5aPcpsAcquisition() } +void GalileoE5aPcpsAcquisition::stop_acquisition() +{ +} + + void GalileoE5aPcpsAcquisition::set_channel(unsigned int channel) { channel_ = channel; @@ -130,7 +186,7 @@ void GalileoE5aPcpsAcquisition::set_channel(unsigned int channel) void GalileoE5aPcpsAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); if (pfa == 0.0) { @@ -188,7 +244,7 @@ void GalileoE5aPcpsAcquisition::init() void GalileoE5aPcpsAcquisition::set_local_code() { - gr_complex* code = new gr_complex[code_length_]; + auto* code = new gr_complex[code_length_]; char signal_[3]; if (acq_iq_) @@ -204,7 +260,14 @@ void GalileoE5aPcpsAcquisition::set_local_code() strcpy(signal_, "5I"); } - galileo_e5_a_code_gen_complex_sampled(code, signal_, gnss_synchro_->PRN, fs_in_, 0); + if (acq_parameters_.use_automatic_resampler) + { + galileo_e5_a_code_gen_complex_sampled(code, signal_, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0); + } + else + { + galileo_e5_a_code_gen_complex_sampled(code, signal_, gnss_synchro_->PRN, fs_in_, 0); + } for (unsigned int i = 0; i < sampled_ms_; i++) { @@ -233,9 +296,9 @@ float GalileoE5aPcpsAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -247,15 +310,15 @@ void GalileoE5aPcpsAcquisition::set_state(int state) } -void GalileoE5aPcpsAcquisition::connect(gr::top_block_sptr top_block) +void GalileoE5aPcpsAcquisition::connect(gr::top_block_sptr top_block __attribute__((unused))) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } else { @@ -264,15 +327,15 @@ void GalileoE5aPcpsAcquisition::connect(gr::top_block_sptr top_block) } -void GalileoE5aPcpsAcquisition::disconnect(gr::top_block_sptr top_block) +void GalileoE5aPcpsAcquisition::disconnect(gr::top_block_sptr top_block __attribute__((unused))) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } else { @@ -283,7 +346,7 @@ void GalileoE5aPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GalileoE5aPcpsAcquisition::get_left_block() { - return stream_to_vector_; + return acquisition_; } @@ -291,3 +354,8 @@ gr::basic_block_sptr GalileoE5aPcpsAcquisition::get_right_block() { return acquisition_; } + +void GalileoE5aPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) +{ + acquisition_->set_resampler_latency(latency_samples); +} diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h index 807a307b2..5a4d71fc1 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h @@ -35,7 +35,6 @@ #include "acquisition_interface.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include #include class ConfigurationInterface; @@ -44,7 +43,8 @@ class GalileoE5aPcpsAcquisition : public AcquisitionInterface { public: GalileoE5aPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GalileoE5aPcpsAcquisition(); @@ -121,7 +121,18 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ + + void set_resampler_latency(uint32_t latency_samples) override; private: float calculate_threshold(float pfa); @@ -129,8 +140,7 @@ private: ConfigurationInterface* configuration_; pcps_acquisition_sptr acquisition_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; - + Acq_Conf acq_parameters_; size_t item_size_; std::string item_type_; @@ -154,7 +164,7 @@ private: unsigned int in_streams_; unsigned int out_streams_; - long fs_in_; + int64_t fs_in_; float threshold_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc new file mode 100644 index 000000000..69520f1a9 --- /dev/null +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -0,0 +1,276 @@ +/*! + * \file galileo_e5a_pcps_acquisition_fpga.cc + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Galileo E5a data and pilot Signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.es + * \author Antonio Ramos, 2018. antonio.ramos(at)cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "galileo_e5a_pcps_acquisition_fpga.h" +#include "Galileo_E5a.h" +#include "configuration_interface.h" +#include "galileo_e5_signal_processing.h" +#include "gnss_sdr_flags.h" +#include +#include +#include + + +using google::LogMessage; + + +GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + pcpsconf_fpga_t acq_parameters; + configuration_ = configuration; + std::string default_dump_filename = "../data/acquisition.dat"; + + DLOG(INFO) << "Role " << role; + + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 1.0); + acq_parameters.downsampling_factor = downsampling_factor; + fs_in = fs_in / downsampling_factor; + + acq_parameters.fs_in = fs_in; + + doppler_max_ = configuration_->property(role + ".doppler_max", 5000); + if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + acq_parameters.doppler_max = doppler_max_; + + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + acq_parameters.sampled_ms = sampled_ms; + + acq_pilot_ = configuration_->property(role + ".acquire_pilot", false); + acq_iq_ = configuration_->property(role + ".acquire_iq", false); + if (acq_iq_) + { + acq_pilot_ = false; + } + + auto code_length = static_cast(std::round(static_cast(fs_in) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); + acq_parameters.code_length = code_length; + + // The FPGA can only use FFT lengths that are a power of two. + float nbits = ceilf(log2f((float)code_length * 2)); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); + acq_parameters.select_queue_Fpga = select_queue_Fpga; + std::string default_device_name = "/dev/uio0"; + std::string device_name = configuration_->property(role + ".devicename", default_device_name); + acq_parameters.device_name = device_name; + acq_parameters.samples_per_ms = nsamples_total / sampled_ms; + acq_parameters.samples_per_code = nsamples_total; + + acq_parameters.excludelimit = static_cast(ceil((1.0 / GALILEO_E5A_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters.fs_in))); + + // compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time + // a channel is assigned) + auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT + auto* code = new std::complex[nsamples_total]; // buffer for the local code + auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_all_fft_codes_ = new lv_16sc_t[nsamples_total * GALILEO_E5A_NUMBER_OF_CODES]; // memory containing all the possible fft codes for PRN 0 to 32 + float max; // temporary maxima search + + for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) + { + char signal_[3]; + + if (acq_iq_) + { + strcpy(signal_, "5X"); + } + else if (acq_pilot_) + { + strcpy(signal_, "5Q"); + } + else + { + strcpy(signal_, "5I"); + } + + + galileo_e5_a_code_gen_complex_sampled(code, signal_, PRN, fs_in, 0); + + for (uint32_t s = code_length; s < 2 * code_length; s++) + { + code[s] = code[s - code_length]; + } + + // fill in zero padding + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) + { + code[s] = std::complex(0.0, 0.0); + } + + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + fft_if->execute(); // Run the FFT of local code + volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values + + max = 0; // initialize maximum value + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima + { + if (std::abs(fft_codes_padded[i].real()) > max) + { + max = std::abs(fft_codes_padded[i].real()); + } + if (std::abs(fft_codes_padded[i].imag()) > max) + { + max = std::abs(fft_codes_padded[i].imag()); + } + } + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + { + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + } + } + + + acq_parameters.all_fft_codes = d_all_fft_codes_; + + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); + + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + channel_ = 0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + + // temporary buffers that we can delete + delete[] code; + delete fft_if; + delete[] fft_codes_padded; +} + + +GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga() +{ + delete[] d_all_fft_codes_; +} + + +void GalileoE5aPcpsAcquisitionFpga::stop_acquisition() +{ + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); +} + + +void GalileoE5aPcpsAcquisitionFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + acquisition_fpga_->set_channel(channel_); +} + + +void GalileoE5aPcpsAcquisitionFpga::set_threshold(float threshold) +{ + DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; + acquisition_fpga_->set_threshold(threshold); +} + + +void GalileoE5aPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max) +{ + doppler_max_ = doppler_max; + acquisition_fpga_->set_doppler_max(doppler_max_); +} + + +void GalileoE5aPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step) +{ + doppler_step_ = doppler_step; + acquisition_fpga_->set_doppler_step(doppler_step_); +} + + +void GalileoE5aPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + acquisition_fpga_->set_gnss_synchro(gnss_synchro_); +} + + +signed int GalileoE5aPcpsAcquisitionFpga::mag() +{ + return acquisition_fpga_->mag(); +} + + +void GalileoE5aPcpsAcquisitionFpga::init() +{ + acquisition_fpga_->init(); +} + + +void GalileoE5aPcpsAcquisitionFpga::set_local_code() +{ + acquisition_fpga_->set_local_code(); +} + + +void GalileoE5aPcpsAcquisitionFpga::reset() +{ + acquisition_fpga_->set_active(true); +} + +void GalileoE5aPcpsAcquisitionFpga::set_state(int state) +{ + acquisition_fpga_->set_state(state); +} + +void GalileoE5aPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) +{ + // nothing to connect +} + + +void GalileoE5aPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) +{ + // nothing to connect +} + + +gr::basic_block_sptr GalileoE5aPcpsAcquisitionFpga::get_left_block() +{ + return nullptr; +} + + +gr::basic_block_sptr GalileoE5aPcpsAcquisitionFpga::get_right_block() +{ + return acquisition_fpga_; +} diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h new file mode 100644 index 000000000..8e8a08972 --- /dev/null +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -0,0 +1,187 @@ +/*! + * \file galileo_e5a_pcps_acquisition_fpga.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Galileo E5a data and pilot Signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.es + * \author Antonio Ramos, 2018. antonio.ramos(at)cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GALILEO_E5A_PCPS_ACQUISITION_FPGA_H_ +#define GALILEO_E5A_PCPS_ACQUISITION_FPGA_H_ + + +#include "acquisition_interface.h" +#include "gnss_synchro.h" +#include "pcps_acquisition_fpga.h" +#include +#include +#include + +class ConfigurationInterface; + +class GalileoE5aPcpsAcquisitionFpga : public AcquisitionInterface +{ +public: + GalileoE5aPcpsAcquisitionFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GalileoE5aPcpsAcquisitionFpga(); + + inline std::string role() override + { + return role_; + } + + /*! + * \brief Returns "Galileo_E5a_Pcps_Acquisition_Fpga" + */ + inline std::string implementation() override + { + return "Galileo_E5a_Pcps_Acquisition_Fpga"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) override; + + /*! + * \brief Set maximum Doppler off grid search + */ + void set_doppler_max(unsigned int doppler_max) override; + + /*! + * \brief Set Doppler steps for the grid search + */ + void set_doppler_step(unsigned int doppler_step) override; + + /*! + * \brief Initializes acquisition algorithm. + */ + void init() override; + + /*! + * \brief Sets local Galileo E5a code for PCPS acquisition algorithm. + */ + void set_local_code() override; + + /*! + * \brief Returns the maximum peak of grid search + */ + signed int mag() override; + + /*! + * \brief Restart acquisition algorithm + */ + void reset() override; + + /*! + * \brief If set to 1, ensures that acquisition starts at the + * first available sample. + * \param state - int=1 forces start of acquisition + */ + void set_state(int state) override; + + /*! + * \brief This function is only used in the unit tests + */ + void set_single_doppler_flag(unsigned int single_doppler_flag); + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; + +private: + ConfigurationInterface* configuration_; + + pcps_acquisition_fpga_sptr acquisition_fpga_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; + + size_t item_size_; + + std::string item_type_; + std::string dump_filename_; + std::string role_; + + bool bit_transition_flag_; + bool dump_; + bool acq_pilot_; + bool use_CFAR_; + bool blocking_; + bool acq_iq_; + + uint32_t vector_length_; + uint32_t code_length_; + uint32_t channel_; + uint32_t doppler_max_; + uint32_t doppler_step_; + uint32_t sampled_ms_; + uint32_t max_dwells_; + unsigned int in_streams_; + unsigned int out_streams_; + + int64_t fs_in_; + + + float threshold_; + + gr_complex* code_; + + Gnss_Synchro* gnss_synchro_; + + lv_16sc_t* d_all_fft_codes_; // memory that contains all the code ffts +}; +#endif /* GALILEO_E5A_PCPS_ACQUISITION_FPGA_H_ */ diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc index 99d13e2db..4480fd30b 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc @@ -32,21 +32,27 @@ */ #include "glonass_l1_ca_pcps_acquisition.h" +#include "GLONASS_L1_L2_CA.h" +#include "acq_conf.h" #include "configuration_interface.h" #include "glonass_l1_signal_processing.h" #include "gnss_sdr_flags.h" -#include "GLONASS_L1_L2_CA.h" #include #include using google::LogMessage; + GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - pcpsconf_t acq_parameters; + Acq_Conf acq_parameters = Acq_Conf(); configuration_ = configuration; std::string default_item_type = "gr_complex"; std::string default_dump_filename = "./data/acquisition.dat"; @@ -55,17 +61,20 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); acq_parameters.fs_in = fs_in_; - if_ = configuration_->property(role + ".if", 0); - acq_parameters.freq = if_; + acq_parameters.samples_per_chip = static_cast(ceil(GLONASS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters.fs_in))); dump_ = configuration_->property(role + ".dump", false); acq_parameters.dump = dump_; + acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0); blocking_ = configuration_->property(role + ".blocking", true); acq_parameters.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms_; @@ -89,7 +98,7 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -99,18 +108,17 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( } acq_parameters.it_size = item_size_; acq_parameters.sampled_ms = sampled_ms_; - acq_parameters.samples_per_ms = code_length_; - acq_parameters.samples_per_code = code_length_; + acq_parameters.samples_per_ms = static_cast(fs_in_) * 0.001; + acq_parameters.ms_per_code = 1; + acq_parameters.samples_per_code = acq_parameters.samples_per_ms * static_cast(GLONASS_L1_CA_CODE_PERIOD * 1000.0); acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acq_parameters.blocking_on_standby = configuration_->property(role + ".blocking_on_standby", false); acquisition_ = pcps_make_acquisition(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); float_to_complex_ = gr::blocks::float_to_complex::make(); @@ -119,7 +127,15 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -129,6 +145,11 @@ GlonassL1CaPcpsAcquisition::~GlonassL1CaPcpsAcquisition() } +void GlonassL1CaPcpsAcquisition::stop_acquisition() +{ +} + + void GlonassL1CaPcpsAcquisition::set_channel(unsigned int channel) { channel_ = channel; @@ -195,7 +216,7 @@ void GlonassL1CaPcpsAcquisition::init() void GlonassL1CaPcpsAcquisition::set_local_code() { - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; glonass_l1_ca_code_gen_complex_sampled(code, /* gnss_synchro_->PRN,*/ fs_in_, 0); @@ -239,9 +260,9 @@ float GlonassL1CaPcpsAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = static_cast(vector_length_); + auto lambda = static_cast(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -249,20 +270,19 @@ float GlonassL1CaPcpsAcquisition::calculate_threshold(float pfa) void GlonassL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + top_block->connect(float_to_complex_, 0, acquisition_, 0); } else { @@ -273,22 +293,21 @@ void GlonassL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block) void GlonassL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { // Since a byte-based acq implementation is not available, // we just convert cshorts to gr_complex top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + top_block->disconnect(float_to_complex_, 0, acquisition_, 0); } else { @@ -299,23 +318,21 @@ void GlonassL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GlonassL1CaPcpsAcquisition::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h index 8250f9d28..17affc67c 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h @@ -35,10 +35,9 @@ #define GNSS_SDR_GLONASS_L1_CA_PCPS_ACQUISITION_H_ #include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include "complex_byte_to_float_x2.h" -#include #include #include @@ -52,7 +51,8 @@ class GlonassL1CaPcpsAcquisition : public AcquisitionInterface { public: GlonassL1CaPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GlonassL1CaPcpsAcquisition(); @@ -130,12 +130,18 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; pcps_acquisition_sptr acquisition_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; size_t item_size_; @@ -150,8 +156,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc index ff61a0c2f..6770310d7 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc @@ -31,9 +31,10 @@ */ #include "glonass_l2_ca_pcps_acquisition.h" +#include "GLONASS_L1_L2_CA.h" +#include "acq_conf.h" #include "configuration_interface.h" #include "glonass_l2_signal_processing.h" -#include "GLONASS_L1_L2_CA.h" #include "gnss_sdr_flags.h" #include #include @@ -41,11 +42,16 @@ using google::LogMessage; + GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - pcpsconf_t acq_parameters; + Acq_Conf acq_parameters = Acq_Conf(); configuration_ = configuration; std::string default_item_type = "gr_complex"; std::string default_dump_filename = "./data/acquisition.dat"; @@ -54,17 +60,20 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); acq_parameters.fs_in = fs_in_; - if_ = configuration_->property(role + ".if", 0); - acq_parameters.freq = if_; + acq_parameters.samples_per_chip = static_cast(ceil(GLONASS_L2_CA_CHIP_PERIOD * static_cast(acq_parameters.fs_in))); dump_ = configuration_->property(role + ".dump", false); acq_parameters.dump = dump_; + acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0); blocking_ = configuration_->property(role + ".blocking", true); acq_parameters.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); @@ -88,7 +97,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -98,18 +107,17 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( } acq_parameters.it_size = item_size_; acq_parameters.sampled_ms = sampled_ms_; - acq_parameters.samples_per_ms = code_length_; - acq_parameters.samples_per_code = code_length_; + acq_parameters.samples_per_ms = static_cast(fs_in_) * 0.001; + acq_parameters.ms_per_code = 1; + acq_parameters.samples_per_code = acq_parameters.samples_per_ms * static_cast(GLONASS_L2_CA_CODE_PERIOD * 1000.0); acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acq_parameters.blocking_on_standby = configuration_->property(role + ".blocking_on_standby", false); acquisition_ = pcps_make_acquisition(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); float_to_complex_ = gr::blocks::float_to_complex::make(); @@ -118,7 +126,15 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -128,6 +144,11 @@ GlonassL2CaPcpsAcquisition::~GlonassL2CaPcpsAcquisition() } +void GlonassL2CaPcpsAcquisition::stop_acquisition() +{ +} + + void GlonassL2CaPcpsAcquisition::set_channel(unsigned int channel) { channel_ = channel; @@ -194,7 +215,7 @@ void GlonassL2CaPcpsAcquisition::init() void GlonassL2CaPcpsAcquisition::set_local_code() { - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; glonass_l2_ca_code_gen_complex_sampled(code, /* gnss_synchro_->PRN,*/ fs_in_, 0); @@ -238,9 +259,9 @@ float GlonassL2CaPcpsAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = static_cast(vector_length_); + auto lambda = static_cast(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -248,20 +269,21 @@ float GlonassL2CaPcpsAcquisition::calculate_threshold(float pfa) void GlonassL2CaPcpsAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { + // Since a byte-based acq implementation is not available, + // we just convert cshorts to gr_complex top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + top_block->connect(float_to_complex_, 0, acquisition_, 0); } else { @@ -272,22 +294,19 @@ void GlonassL2CaPcpsAcquisition::connect(gr::top_block_sptr top_block) void GlonassL2CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { - // Since a byte-based acq implementation is not available, - // we just convert cshorts to gr_complex top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + top_block->disconnect(float_to_complex_, 0, acquisition_, 0); } else { @@ -298,23 +317,21 @@ void GlonassL2CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GlonassL2CaPcpsAcquisition::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h index bb4e0090f..ad99d9d5a 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h @@ -34,10 +34,9 @@ #define GNSS_SDR_GLONASS_L2_CA_PCPS_ACQUISITION_H_ #include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include "complex_byte_to_float_x2.h" -#include #include #include @@ -51,7 +50,8 @@ class GlonassL2CaPcpsAcquisition : public AcquisitionInterface { public: GlonassL2CaPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GlonassL2CaPcpsAcquisition(); @@ -129,12 +129,18 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; pcps_acquisition_sptr acquisition_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; size_t item_size_; @@ -149,8 +155,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc index 01f3f7f62..e27f37581 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc @@ -34,66 +34,99 @@ */ #include "gps_l1_ca_pcps_acquisition.h" -#include "configuration_interface.h" -#include "gps_sdr_signal_processing.h" #include "GPS_L1_CA.h" +#include "acq_conf.h" +#include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" #include #include using google::LogMessage; + GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - pcpsconf_t acq_parameters; configuration_ = configuration; std::string default_item_type = "gr_complex"; - std::string default_dump_filename = "./data/acquisition.dat"; + std::string default_dump_filename = "./acquisition.mat"; DLOG(INFO) << "role " << role; item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - acq_parameters.fs_in = fs_in_; - if_ = configuration_->property(role + ".if", 0); - acq_parameters.freq = if_; + acq_parameters_.fs_in = fs_in_; dump_ = configuration_->property(role + ".dump", false); - acq_parameters.dump = dump_; + acq_parameters_.dump = dump_; + acq_parameters_.dump_channel = configuration_->property(role + ".dump_channel", 0); blocking_ = configuration_->property(role + ".blocking", true); - acq_parameters.blocking = blocking_; + acq_parameters_.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; - acq_parameters.doppler_max = doppler_max_; - sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); - acq_parameters.sampled_ms = sampled_ms_; - bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - acq_parameters.bit_transition_flag = bit_transition_flag_; - use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions - acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; - max_dwells_ = configuration_->property(role + ".max_dwells", 1); - acq_parameters.max_dwells = max_dwells_; - dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - acq_parameters.dump_filename = dump_filename_; - acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); - //--- Find number of samples per spreading code ------------------------- - code_length_ = static_cast(std::round(static_cast(fs_in_) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - - vector_length_ = code_length_ * sampled_ms_; - - if (bit_transition_flag_) + if (FLAGS_doppler_max != 0) { - vector_length_ *= 2; + doppler_max_ = FLAGS_doppler_max; + } + acq_parameters_.doppler_max = doppler_max_; + sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); + acq_parameters_.sampled_ms = sampled_ms_; + acq_parameters_.ms_per_code = 1; + bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); + acq_parameters_.bit_transition_flag = bit_transition_flag_; + use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions + acq_parameters_.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; + max_dwells_ = configuration_->property(role + ".max_dwells", 1); + acq_parameters_.max_dwells = max_dwells_; + dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); + acq_parameters_.dump_filename = dump_filename_; + acq_parameters_.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); + acq_parameters_.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); + acq_parameters_.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acq_parameters_.use_automatic_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); + if (acq_parameters_.use_automatic_resampler == true and item_type_ != "gr_complex") + { + LOG(WARNING) << "GPS L1 CA acquisition disabled the automatic resampler feature because its item_type is not set to gr_complex"; + acq_parameters_.use_automatic_resampler = false; + } + if (acq_parameters_.use_automatic_resampler) + { + if (acq_parameters_.fs_in > GPS_L1_CA_OPT_ACQ_FS_HZ) + { + acq_parameters_.resampler_ratio = floor(static_cast(acq_parameters_.fs_in) / GPS_L1_CA_OPT_ACQ_FS_HZ); + uint32_t decimation = acq_parameters_.fs_in / GPS_L1_CA_OPT_ACQ_FS_HZ; + while (acq_parameters_.fs_in % decimation > 0) + { + decimation--; + }; + acq_parameters_.resampler_ratio = decimation; + acq_parameters_.resampled_fs = acq_parameters_.fs_in / static_cast(acq_parameters_.resampler_ratio); + } + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(acq_parameters_.resampled_fs) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters_.resampled_fs))); + } + else + { + acq_parameters_.resampled_fs = fs_in_; + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(fs_in_) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(fs_in_) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters_.fs_in))); } + acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast(GPS_L1_CA_CODE_PERIOD * 1000.0); + vector_length_ = std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2 : 1); code_ = new gr_complex[vector_length_]; - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -101,16 +134,13 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( { item_size_ = sizeof(gr_complex); } - acq_parameters.samples_per_ms = code_length_; - acq_parameters.samples_per_code = code_length_; - acq_parameters.it_size = item_size_; - acquisition_ = pcps_make_acquisition(acq_parameters); + + acq_parameters_.it_size = item_size_; + acq_parameters_.blocking_on_standby = configuration_->property(role + ".blocking_on_standby", false); + acquisition_ = pcps_make_acquisition(acq_parameters_); DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); float_to_complex_ = gr::blocks::float_to_complex::make(); @@ -119,7 +149,15 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -129,6 +167,11 @@ GpsL1CaPcpsAcquisition::~GpsL1CaPcpsAcquisition() } +void GpsL1CaPcpsAcquisition::stop_acquisition() +{ +} + + void GpsL1CaPcpsAcquisition::set_channel(unsigned int channel) { channel_ = channel; @@ -188,16 +231,21 @@ signed int GpsL1CaPcpsAcquisition::mag() void GpsL1CaPcpsAcquisition::init() { acquisition_->init(); - //set_local_code(); } void GpsL1CaPcpsAcquisition::set_local_code() { - std::complex* code = new std::complex[code_length_]; - - gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); + auto* code = new std::complex[code_length_]; + if (acq_parameters_.use_automatic_resampler) + { + gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0); + } + else + { + gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); + } for (unsigned int i = 0; i < sampled_ms_; i++) { memcpy(&(code_[i * code_length_]), code, @@ -233,9 +281,9 @@ float GpsL1CaPcpsAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -243,20 +291,21 @@ float GpsL1CaPcpsAcquisition::calculate_threshold(float pfa) void GpsL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { + // Since a byte-based acq implementation is not available, + // we just convert cshorts to gr_complex top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + top_block->connect(float_to_complex_, 0, acquisition_, 0); } else { @@ -267,22 +316,19 @@ void GpsL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block) void GpsL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { - // Since a byte-based acq implementation is not available, - // we just convert cshorts to gr_complex top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + top_block->disconnect(float_to_complex_, 0, acquisition_, 0); } else { @@ -293,23 +339,21 @@ void GpsL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GpsL1CaPcpsAcquisition::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } @@ -317,3 +361,8 @@ gr::basic_block_sptr GpsL1CaPcpsAcquisition::get_right_block() { return acquisition_; } + +void GpsL1CaPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) +{ + acquisition_->set_resampler_latency(latency_samples); +} diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h index edf79e42c..efca26bdd 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h @@ -36,11 +36,11 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_H_ #define GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_H_ +#include "acq_conf.h" #include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include "complex_byte_to_float_x2.h" -#include #include #include #include @@ -56,7 +56,8 @@ class GpsL1CaPcpsAcquisition : public AcquisitionInterface { public: GpsL1CaPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL1CaPcpsAcquisition(); @@ -134,12 +135,24 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ + + void set_resampler_latency(uint32_t latency_samples) override; + private: ConfigurationInterface* configuration_; pcps_acquisition_sptr acquisition_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; + Acq_Conf acq_parameters_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; size_t item_size_; @@ -154,8 +167,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc index 05f987b0f..4fb0e46cf 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc @@ -33,46 +33,61 @@ */ #include "gps_l1_ca_pcps_acquisition_fine_doppler.h" -#include -#include "gps_sdr_signal_processing.h" #include "GPS_L1_CA.h" +#include "acq_conf.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include using google::LogMessage; + GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { std::string default_item_type = "gr_complex"; - std::string default_dump_filename = "./data/acquisition.dat"; + std::string default_dump_filename = "./acquisition.mat"; DLOG(INFO) << "role " << role; + Acq_Conf acq_parameters = Acq_Conf(); item_type_ = configuration->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration->property(role + ".if", 0); + acq_parameters.fs_in = fs_in_; + acq_parameters.samples_per_chip = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters.fs_in))); dump_ = configuration->property(role + ".dump", false); + acq_parameters.dump = dump_; dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); + acq_parameters.dump_filename = dump_filename_; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; - doppler_min_ = configuration->property(role + ".doppler_min", -doppler_max_); + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } + acq_parameters.doppler_max = doppler_max_; sampled_ms_ = configuration->property(role + ".coherent_integration_time_ms", 1); + acq_parameters.sampled_ms = sampled_ms_; max_dwells_ = configuration->property(role + ".max_dwells", 1); + acq_parameters.max_dwells = max_dwells_; + + acq_parameters.blocking_on_standby = configuration->property(role + ".blocking_on_standby", false); //--- Find number of samples per spreading code ------------------------- vector_length_ = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); - + acq_parameters.samples_per_ms = vector_length_; code_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); - acquisition_cc_ = pcps_make_acquisition_fine_doppler_cc(max_dwells_, sampled_ms_, - doppler_max_, doppler_min_, if_, fs_in_, vector_length_, - dump_, dump_filename_); + acquisition_cc_ = pcps_make_acquisition_fine_doppler_cc(acq_parameters); } else { @@ -83,7 +98,15 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -93,6 +116,11 @@ GpsL1CaPcpsAcquisitionFineDoppler::~GpsL1CaPcpsAcquisitionFineDoppler() } +void GpsL1CaPcpsAcquisitionFineDoppler::stop_acquisition() +{ +} + + void GpsL1CaPcpsAcquisitionFineDoppler::set_channel(unsigned int channel) { channel_ = channel; @@ -154,6 +182,12 @@ void GpsL1CaPcpsAcquisitionFineDoppler::reset() } +void GpsL1CaPcpsAcquisitionFineDoppler::set_state(int state) +{ + acquisition_cc_->set_state(state); +} + + void GpsL1CaPcpsAcquisitionFineDoppler::connect(boost::shared_ptr top_block) { if (top_block) diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h index e0bfcf14e..b1b64d6eb 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h @@ -34,11 +34,10 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FINE_DOPPLER_H_ #define GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FINE_DOPPLER_H_ -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" +#include "gnss_synchro.h" #include "pcps_acquisition_fine_doppler_cc.h" - +#include class ConfigurationInterface; @@ -50,7 +49,8 @@ class GpsL1CaPcpsAcquisitionFineDoppler : public AcquisitionInterface { public: GpsL1CaPcpsAcquisitionFineDoppler(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL1CaPcpsAcquisitionFineDoppler(); @@ -122,6 +122,18 @@ public: */ void reset() override; + /*! + * \brief If state = 1, it forces the block to start acquiring from the first sample + */ + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; + private: pcps_acquisition_fine_doppler_cc_sptr acquisition_cc_; size_t item_size_; @@ -131,11 +143,9 @@ private: float threshold_; int doppler_max_; unsigned int doppler_step_; - int doppler_min_; unsigned int sampled_ms_; int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 3cbc81bfa..dabf94a15 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -1,9 +1,9 @@ /*! * \file gps_l1_ca_pcps_acquisition_fpga.cc - * \brief Adapts a PCPS acquisition block to an FPGA AcquisitionInterface - * for GPS L1 C/A signals + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface + * for GPS L1 C/A signals for the FPGA * \authors
    - *
  • Marc Majoral, 2018. mmajoral(at)cttc.es + *
  • Marc Majoral, 2019. mmajoral(at)cttc.es *
  • Javier Arribas, 2011. jarribas(at)cttc.es *
  • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
  • Marc Molina, 2013. marc.molina.pena(at)gmail.com @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -29,82 +29,97 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . + * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- */ #include "gps_l1_ca_pcps_acquisition_fpga.h" +#include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include "GPS_L1_CA.h" #include "gps_sdr_signal_processing.h" -#include #include +#include #include + #define NUM_PRNs 32 using google::LogMessage; + GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - std::string default_item_type = "gr_complex"; + std::string default_item_type = "cshort"; DLOG(INFO) << "role " << role; - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); - long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); + acq_parameters.downsampling_factor = downsampling_factor; + + fs_in = fs_in / downsampling_factor; + acq_parameters.fs_in = fs_in; - long ifreq = configuration_->property(role + ".if", 0); - acq_parameters.freq = ifreq; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms; - unsigned int code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - + auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length)); - unsigned int nsamples_total = pow(2, nbits); - unsigned int vector_length = nsamples_total * sampled_ms; - unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); + float nbits = ceilf(log2f((float)code_length * 2)); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); acq_parameters.device_name = device_name; - acq_parameters.samples_per_ms = nsamples_total; + acq_parameters.samples_per_ms = nsamples_total / sampled_ms; acq_parameters.samples_per_code = nsamples_total; + acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L1_CA_CODE_RATE_HZ)); // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - - gr::fft::fft_complex* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT + auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT // allocate memory to compute all the PRNs and compute all the possible codes - std::complex* code = new std::complex[nsamples_total]; // buffer for the local code - gr_complex* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + auto* code = new std::complex[nsamples_total]; // buffer for the local code + auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32 float max; // temporary maxima search - - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in, 0); // generate PRN code - // fill in zero padding - for (int s = code_length; s < nsamples_total; s++) + + for (uint32_t s = code_length; s < 2 * code_length; s++) { - code[s] = 0; + code[s] = code[s - code_length]; } - int offset = 0; - memcpy(fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + + // fill in zero padding + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) + { + code[s] = std::complex(0.0, 0.0); + } + + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values - max = 0; // initialize maximum value - for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima + + max = 0; // initialize maximum value + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima { if (std::abs(fft_codes_padded[i].real()) > max) { @@ -115,27 +130,30 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( max = std::abs(fft_codes_padded[i].imag()); } } - for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } } - // acq_parameters + //acq_parameters acq_parameters.all_fft_codes = d_all_fft_codes_; - // temporary buffers that we can delete - delete[] code; - delete fft_if; - delete[] fft_codes_padded; + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; channel_ = 0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + + // temporary buffers that we can delete + delete[] code; + delete fft_if; + delete[] fft_codes_padded; } @@ -145,6 +163,13 @@ GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga() } +void GpsL1CaPcpsAcquisitionFpga::stop_acquisition() +{ + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); +} + + void GpsL1CaPcpsAcquisitionFpga::set_channel(unsigned int channel) { channel_ = channel; @@ -200,6 +225,7 @@ void GpsL1CaPcpsAcquisitionFpga::set_local_code() void GpsL1CaPcpsAcquisitionFpga::reset() { + // this function starts the acquisition process acquisition_fpga_->set_active(true); } @@ -212,23 +238,19 @@ void GpsL1CaPcpsAcquisitionFpga::set_state(int state) void GpsL1CaPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { - if (top_block) - { // nothing to disconnect - } + // nothing to connect } void GpsL1CaPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) { - if (top_block) - { // nothing to disconnect - } + // nothing to disconnect } gr::basic_block_sptr GpsL1CaPcpsAcquisitionFpga::get_left_block() { - return acquisition_fpga_; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index b658942d5..7d91f04d0 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -1,9 +1,9 @@ /*! * \file gps_l1_ca_pcps_acquisition_fpga.h - * \brief Adapts a PCPS acquisition block that uses the FPGA to - * an AcquisitionInterface for GPS L1 C/A signals + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface + * for GPS L1 C/A signals for the FPGA * \authors
      - *
    • Marc Majoral, 2018. mmajoral(at)cttc.es + *
    • Marc Majoral, 2019. mmajoral(at)cttc.es *
    • Javier Arribas, 2011. jarribas(at)cttc.es *
    • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
    • Marc Molina, 2013. marc.molina.pena(at)gmail.com @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -53,7 +53,8 @@ class GpsL1CaPcpsAcquisitionFpga : public AcquisitionInterface { public: GpsL1CaPcpsAcquisitionFpga(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL1CaPcpsAcquisitionFpga(); @@ -64,11 +65,11 @@ public: } /*! - * \brief Returns "GPS_L1_CA_PCPS_Acquisition" + * \brief Returns "GPS_L1_CA_PCPS_Acquisition_Fpga" */ inline std::string implementation() override { - return "GPS_L1_CA_PCPS_Acquisition"; + return "GPS_L1_CA_PCPS_Acquisition_Fpga"; } inline size_t item_size() override @@ -132,14 +133,21 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; pcps_acquisition_fpga_sptr acquisition_fpga_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; + uint32_t channel_; + uint32_t doppler_max_; + uint32_t doppler_step_; Gnss_Synchro* gnss_synchro_; std::string role_; unsigned int in_streams_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc index 513497946..3770b7c7a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc @@ -33,18 +33,23 @@ */ #include "gps_l1_ca_pcps_assisted_acquisition.h" -#include -#include "gps_sdr_signal_processing.h" #include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include using google::LogMessage; + GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { std::string default_item_type = "gr_complex"; std::string default_dump_filename = "./data/acquisition.dat"; @@ -52,12 +57,14 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( DLOG(INFO) << "role " << role; item_type_ = configuration->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration->property(role + ".if", 0); dump_ = configuration->property(role + ".dump", false); doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } doppler_min_ = configuration->property(role + ".doppler_min", -doppler_max_); sampled_ms_ = configuration->property(role + ".coherent_integration_time_ms", 1); max_dwells_ = configuration->property(role + ".max_dwells", 1); @@ -68,11 +75,11 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = pcps_make_assisted_acquisition_cc(max_dwells_, sampled_ms_, - doppler_max_, doppler_min_, if_, fs_in_, vector_length_, + doppler_max_, doppler_min_, fs_in_, vector_length_, dump_, dump_filename_); } else @@ -84,7 +91,15 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -94,6 +109,11 @@ GpsL1CaPcpsAssistedAcquisition::~GpsL1CaPcpsAssistedAcquisition() } +void GpsL1CaPcpsAssistedAcquisition::stop_acquisition() +{ +} + + void GpsL1CaPcpsAssistedAcquisition::set_channel(unsigned int channel) { channel_ = channel; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h index 06c7728df..04b653440 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h @@ -34,11 +34,10 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ASSISTED_ACQUISITION_H_ #define GNSS_SDR_GPS_L1_CA_PCPS_ASSISTED_ACQUISITION_H_ -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" +#include "gnss_synchro.h" #include "pcps_assisted_acquisition_cc.h" - +#include class ConfigurationInterface; @@ -50,7 +49,8 @@ class GpsL1CaPcpsAssistedAcquisition : public AcquisitionInterface { public: GpsL1CaPcpsAssistedAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL1CaPcpsAssistedAcquisition(); @@ -121,6 +121,14 @@ public: * \brief Restart acquisition algorithm */ void reset() override; + void set_state(int state __attribute__((unused))) override{}; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: pcps_assisted_acquisition_cc_sptr acquisition_cc_; @@ -135,8 +143,7 @@ private: int doppler_min_; unsigned int sampled_ms_; int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc index eb2da7bea..1fd9b109f 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc @@ -30,19 +30,24 @@ */ #include "gps_l1_ca_pcps_opencl_acquisition.h" -#include -#include -#include "gps_sdr_signal_processing.h" #include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include +#include using google::LogMessage; + GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -53,9 +58,8 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; @@ -82,11 +86,11 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = pcps_make_opencl_acquisition_cc(sampled_ms_, max_dwells_, - doppler_max_, if_, fs_in_, code_length_, code_length_, + doppler_max_, fs_in_, code_length_, code_length_, bit_transition_flag_, dump_, dump_filename_); stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); @@ -103,7 +107,15 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -113,10 +125,15 @@ GpsL1CaPcpsOpenClAcquisition::~GpsL1CaPcpsOpenClAcquisition() } +void GpsL1CaPcpsOpenClAcquisition::stop_acquisition() +{ +} + + void GpsL1CaPcpsOpenClAcquisition::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -125,7 +142,7 @@ void GpsL1CaPcpsOpenClAcquisition::set_channel(unsigned int channel) void GpsL1CaPcpsOpenClAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); if (pfa == 0.0) { @@ -142,7 +159,7 @@ void GpsL1CaPcpsOpenClAcquisition::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -152,7 +169,7 @@ void GpsL1CaPcpsOpenClAcquisition::set_threshold(float threshold) void GpsL1CaPcpsOpenClAcquisition::set_doppler_max(unsigned int doppler_max) { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -162,7 +179,7 @@ void GpsL1CaPcpsOpenClAcquisition::set_doppler_max(unsigned int doppler_max) void GpsL1CaPcpsOpenClAcquisition::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -172,7 +189,7 @@ void GpsL1CaPcpsOpenClAcquisition::set_doppler_step(unsigned int doppler_step) void GpsL1CaPcpsOpenClAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -181,7 +198,7 @@ void GpsL1CaPcpsOpenClAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) signed int GpsL1CaPcpsOpenClAcquisition::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } @@ -201,9 +218,9 @@ void GpsL1CaPcpsOpenClAcquisition::init() void GpsL1CaPcpsOpenClAcquisition::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); @@ -222,7 +239,7 @@ void GpsL1CaPcpsOpenClAcquisition::set_local_code() void GpsL1CaPcpsOpenClAcquisition::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -244,9 +261,9 @@ float GpsL1CaPcpsOpenClAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -254,7 +271,7 @@ float GpsL1CaPcpsOpenClAcquisition::calculate_threshold(float pfa) void GpsL1CaPcpsOpenClAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); } @@ -263,7 +280,7 @@ void GpsL1CaPcpsOpenClAcquisition::connect(gr::top_block_sptr top_block) void GpsL1CaPcpsOpenClAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h index ab7e19c94..a7dbe1bc9 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h @@ -32,12 +32,11 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_OPENCL_ACQUISITION_H_ #define GNSS_SDR_GPS_L1_CA_PCPS_OPENCL_ACQUISITION_H_ -#include -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" +#include "gnss_synchro.h" #include "pcps_opencl_acquisition_cc.h" - +#include +#include class ConfigurationInterface; @@ -49,7 +48,8 @@ class GpsL1CaPcpsOpenClAcquisition : public AcquisitionInterface { public: GpsL1CaPcpsOpenClAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL1CaPcpsOpenClAcquisition(); @@ -123,6 +123,14 @@ public: * \brief Restart acquisition algorithm */ void reset() override; + void set_state(int state __attribute__((unused))) override{}; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; @@ -139,8 +147,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc index 9fa165513..2691b1161 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc @@ -31,19 +31,24 @@ */ #include "gps_l1_ca_pcps_quicksync_acquisition.h" -#include -#include -#include "gps_sdr_signal_processing.h" #include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include +#include using google::LogMessage; + GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -52,19 +57,21 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( DLOG(INFO) << "role " << role; item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); //--- Find number of samples per spreading code ------------------------- code_length_ = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); /*Calculate the folding factor value based on the calculations*/ - unsigned int temp = static_cast(ceil(sqrt(log2(code_length_)))); + auto temp = static_cast(ceil(sqrt(log2(code_length_)))); folding_factor_ = configuration_->property(role + ".folding_factor", temp); if (sampled_ms_ % folding_factor_ != 0) @@ -109,11 +116,11 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( << ", Sampled ms: " << sampled_ms_ << ", Code Length: " << code_length_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); acquisition_cc_ = pcps_quicksync_make_acquisition_cc(folding_factor_, - sampled_ms_, max_dwells_, doppler_max_, if_, fs_in_, + sampled_ms_, max_dwells_, doppler_max_, fs_in_, samples_per_ms, code_length_, bit_transition_flag_, dump_, dump_filename_); @@ -132,7 +139,15 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -142,10 +157,15 @@ GpsL1CaPcpsQuickSyncAcquisition::~GpsL1CaPcpsQuickSyncAcquisition() } +void GpsL1CaPcpsQuickSyncAcquisition::stop_acquisition() +{ +} + + void GpsL1CaPcpsQuickSyncAcquisition::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -154,9 +174,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_channel(unsigned int channel) void GpsL1CaPcpsQuickSyncAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + - boost::lexical_cast(channel_) + ".pfa", - 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); if (pfa == 0.0) { @@ -173,7 +191,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -183,7 +201,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_threshold(float threshold) void GpsL1CaPcpsQuickSyncAcquisition::set_doppler_max(unsigned int doppler_max) { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -193,7 +211,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_doppler_max(unsigned int doppler_max) void GpsL1CaPcpsQuickSyncAcquisition::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -203,7 +221,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_doppler_step(unsigned int doppler_step void GpsL1CaPcpsQuickSyncAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -212,14 +230,11 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchr signed int GpsL1CaPcpsQuickSyncAcquisition::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } - else - { - return 0; - } + return 0; } @@ -232,13 +247,12 @@ void GpsL1CaPcpsQuickSyncAcquisition::init() void GpsL1CaPcpsQuickSyncAcquisition::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - std::complex* code = new std::complex[code_length_](); + auto* code = new std::complex[code_length_](); gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); - for (unsigned int i = 0; i < (sampled_ms_ / folding_factor_); i++) { memcpy(&(code_[i * code_length_]), code, @@ -255,7 +269,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_local_code() void GpsL1CaPcpsQuickSyncAcquisition::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -264,7 +278,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::reset() void GpsL1CaPcpsQuickSyncAcquisition::set_state(int state) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_state(state); } @@ -285,7 +299,7 @@ float GpsL1CaPcpsQuickSyncAcquisition::calculate_threshold(float pfa) double val = pow(1.0 - pfa, exponent); double lambda = static_cast(code_length_) / static_cast(folding_factor_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -293,7 +307,7 @@ float GpsL1CaPcpsQuickSyncAcquisition::calculate_threshold(float pfa) void GpsL1CaPcpsQuickSyncAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); } @@ -302,7 +316,7 @@ void GpsL1CaPcpsQuickSyncAcquisition::connect(gr::top_block_sptr top_block) void GpsL1CaPcpsQuickSyncAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h index 17e3da109..482db0f44 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h @@ -33,13 +33,12 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_QUICKSYNC_ACQUISITION_H_ #define GNSS_SDR_GPS_L1_CA_PCPS_QUICKSYNC_ACQUISITION_H_ -#include -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" -#include "pcps_quicksync_acquisition_cc.h" #include "configuration_interface.h" - +#include "gnss_synchro.h" +#include "pcps_quicksync_acquisition_cc.h" +#include +#include class ConfigurationInterface; @@ -51,7 +50,8 @@ class GpsL1CaPcpsQuickSyncAcquisition : public AcquisitionInterface { public: GpsL1CaPcpsQuickSyncAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL1CaPcpsQuickSyncAcquisition(); @@ -129,7 +129,14 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; @@ -147,8 +154,7 @@ private: unsigned int sampled_ms_; unsigned int max_dwells_; unsigned int folding_factor_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc index 07dfecfd3..162ea96ae 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc @@ -30,19 +30,24 @@ */ #include "gps_l1_ca_pcps_tong_acquisition.h" -#include -#include -#include "gps_sdr_signal_processing.h" #include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include +#include using google::LogMessage; + GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -52,12 +57,14 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - if_ = configuration_->property(role + ".if", 0); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); tong_init_val_ = configuration->property(role + ".tong_init_val", 1); @@ -73,10 +80,10 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); - acquisition_cc_ = pcps_tong_make_acquisition_cc(sampled_ms_, doppler_max_, if_, fs_in_, + acquisition_cc_ = pcps_tong_make_acquisition_cc(sampled_ms_, doppler_max_, fs_in_, code_length_, code_length_, tong_init_val_, tong_max_val_, tong_max_dwells_, dump_, dump_filename_); @@ -94,7 +101,15 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -104,10 +119,15 @@ GpsL1CaPcpsTongAcquisition::~GpsL1CaPcpsTongAcquisition() } +void GpsL1CaPcpsTongAcquisition::stop_acquisition() +{ +} + + void GpsL1CaPcpsTongAcquisition::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_channel(channel_); } @@ -116,7 +136,7 @@ void GpsL1CaPcpsTongAcquisition::set_channel(unsigned int channel) void GpsL1CaPcpsTongAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); if (pfa == 0.0) { @@ -133,7 +153,7 @@ void GpsL1CaPcpsTongAcquisition::set_threshold(float threshold) DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_threshold(threshold_); } @@ -143,7 +163,7 @@ void GpsL1CaPcpsTongAcquisition::set_threshold(float threshold) void GpsL1CaPcpsTongAcquisition::set_doppler_max(unsigned int doppler_max) { doppler_max_ = doppler_max; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_max(doppler_max_); } @@ -153,7 +173,7 @@ void GpsL1CaPcpsTongAcquisition::set_doppler_max(unsigned int doppler_max) void GpsL1CaPcpsTongAcquisition::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_doppler_step(doppler_step_); } @@ -163,7 +183,7 @@ void GpsL1CaPcpsTongAcquisition::set_doppler_step(unsigned int doppler_step) void GpsL1CaPcpsTongAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_gnss_synchro(gnss_synchro_); } @@ -172,14 +192,11 @@ void GpsL1CaPcpsTongAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) signed int GpsL1CaPcpsTongAcquisition::mag() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_cc_->mag(); } - else - { - return 0; - } + return 0; } @@ -191,9 +208,9 @@ void GpsL1CaPcpsTongAcquisition::init() void GpsL1CaPcpsTongAcquisition::set_local_code() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); @@ -212,7 +229,7 @@ void GpsL1CaPcpsTongAcquisition::set_local_code() void GpsL1CaPcpsTongAcquisition::reset() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_active(true); } @@ -221,7 +238,7 @@ void GpsL1CaPcpsTongAcquisition::reset() void GpsL1CaPcpsTongAcquisition::set_state(int state) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { acquisition_cc_->set_state(state); } @@ -242,9 +259,9 @@ float GpsL1CaPcpsTongAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -252,7 +269,7 @@ float GpsL1CaPcpsTongAcquisition::calculate_threshold(float pfa) void GpsL1CaPcpsTongAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); } @@ -261,7 +278,7 @@ void GpsL1CaPcpsTongAcquisition::connect(gr::top_block_sptr top_block) void GpsL1CaPcpsTongAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h index 2514a532e..63e89b8a5 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h @@ -32,12 +32,12 @@ #ifndef GNSS_SDR_GPS_L1_CA_TONG_ACQUISITION_H_ #define GNSS_SDR_GPS_L1_CA_TONG_ACQUISITION_H_ -#include -#include -#include "gnss_synchro.h" #include "acquisition_interface.h" -#include "pcps_tong_acquisition_cc.h" #include "configuration_interface.h" +#include "gnss_synchro.h" +#include "pcps_tong_acquisition_cc.h" +#include +#include class ConfigurationInterface; @@ -49,7 +49,8 @@ class GpsL1CaPcpsTongAcquisition : public AcquisitionInterface { public: GpsL1CaPcpsTongAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL1CaPcpsTongAcquisition(); @@ -127,7 +128,14 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: ConfigurationInterface* configuration_; @@ -145,8 +153,7 @@ private: unsigned int tong_init_val_; unsigned int tong_max_val_; unsigned int tong_max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; std::string dump_filename_; std::complex* code_; diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc index bb5f27bc7..00fcb7624 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc @@ -32,63 +32,106 @@ */ #include "gps_l2_m_pcps_acquisition.h" -#include "configuration_interface.h" -#include "gps_l2c_signal.h" #include "GPS_L2C.h" +#include "acq_conf.h" +#include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_l2c_signal.h" #include #include using google::LogMessage; + GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - pcpsconf_t acq_parameters; configuration_ = configuration; std::string default_item_type = "gr_complex"; - std::string default_dump_filename = "./data/acquisition.dat"; + std::string default_dump_filename = "./acquisition.mat"; LOG(INFO) << "role " << role; item_type_ = configuration_->property(role + ".item_type", default_item_type); - //float pfa = configuration_->property(role + ".pfa", 0.0); - - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - acq_parameters.fs_in = fs_in_; - if_ = configuration_->property(role + ".if", 0); - acq_parameters.freq = if_; + acq_parameters_.fs_in = fs_in_; dump_ = configuration_->property(role + ".dump", false); - acq_parameters.dump = dump_; + acq_parameters_.dump = dump_; + acq_parameters_.dump_channel = configuration_->property(role + ".dump_channel", 0); blocking_ = configuration_->property(role + ".blocking", true); - acq_parameters.blocking = blocking_; + acq_parameters_.blocking = blocking_; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; - acq_parameters.doppler_max = doppler_max_; - bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - acq_parameters.bit_transition_flag = bit_transition_flag_; - use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions - acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; - max_dwells_ = configuration_->property(role + ".max_dwells", 1); - acq_parameters.max_dwells = max_dwells_; - dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - acq_parameters.dump_filename = dump_filename_; - //--- Find number of samples per spreading code ------------------------- - code_length_ = std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); - - vector_length_ = code_length_; - - if (bit_transition_flag_) + if (FLAGS_doppler_max != 0) { - vector_length_ *= 2; + doppler_max_ = FLAGS_doppler_max; + } + acq_parameters_.doppler_max = doppler_max_; + bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); + acq_parameters_.bit_transition_flag = bit_transition_flag_; + use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions + acq_parameters_.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; + max_dwells_ = configuration_->property(role + ".max_dwells", 1); + acq_parameters_.max_dwells = max_dwells_; + dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); + acq_parameters_.dump_filename = dump_filename_; + acq_parameters_.ms_per_code = 20; + acq_parameters_.sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", acq_parameters_.ms_per_code); + if ((acq_parameters_.sampled_ms % acq_parameters_.ms_per_code) != 0) + { + LOG(WARNING) << "Parameter coherent_integration_time_ms should be a multiple of 20. Setting it to 20"; + acq_parameters_.sampled_ms = acq_parameters_.ms_per_code; } + acq_parameters_.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); + acq_parameters_.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); + acq_parameters_.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acq_parameters_.blocking_on_standby = configuration_->property(role + ".blocking_on_standby", false); + acq_parameters_.use_automatic_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); + if (acq_parameters_.use_automatic_resampler == true and item_type_ != "gr_complex") + { + LOG(WARNING) << "GPS L2CM acquisition disabled the automatic resampler feature because its item_type is not set to gr_complex"; + acq_parameters_.use_automatic_resampler = false; + } + if (acq_parameters_.use_automatic_resampler) + { + if (acq_parameters_.fs_in > GPS_L2C_OPT_ACQ_FS_HZ) + { + acq_parameters_.resampler_ratio = floor(static_cast(acq_parameters_.fs_in) / GPS_L2C_OPT_ACQ_FS_HZ); + uint32_t decimation = acq_parameters_.fs_in / GPS_L2C_OPT_ACQ_FS_HZ; + while (acq_parameters_.fs_in % decimation > 0) + { + decimation--; + }; + acq_parameters_.resampler_ratio = decimation; + acq_parameters_.resampled_fs = acq_parameters_.fs_in / static_cast(acq_parameters_.resampler_ratio); + } + + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GPS_L2_M_CODE_RATE_HZ / GPS_L2_M_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(acq_parameters_.resampled_fs) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GPS_L2_M_CODE_RATE_HZ) * static_cast(acq_parameters_.resampled_fs))); + } + else + { + acq_parameters_.resampled_fs = fs_in_; + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_HZ / GPS_L2_M_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(fs_in_) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GPS_L2_M_CODE_RATE_HZ) * static_cast(acq_parameters_.fs_in))); + } + + acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast(GPS_L2_M_PERIOD * 1000.0); + vector_length_ = acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms * (acq_parameters_.bit_transition_flag ? 2 : 1); code_ = new gr_complex[vector_length_]; - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -96,20 +139,12 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( { item_size_ = sizeof(gr_complex); } - acq_parameters.samples_per_ms = static_cast(std::round(static_cast(fs_in_) * 0.001)); - acq_parameters.samples_per_code = code_length_; - acq_parameters.it_size = item_size_; - acq_parameters.sampled_ms = 20; - acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", true); - acquisition_ = pcps_make_acquisition(acq_parameters); + + acq_parameters_.it_size = item_size_; + acquisition_ = pcps_make_acquisition(acq_parameters_); DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); float_to_complex_ = gr::blocks::float_to_complex::make(); @@ -118,7 +153,16 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + num_codes_ = acq_parameters_.sampled_ms / acq_parameters_.ms_per_code; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -128,6 +172,11 @@ GpsL2MPcpsAcquisition::~GpsL2MPcpsAcquisition() } +void GpsL2MPcpsAcquisition::stop_acquisition() +{ +} + + void GpsL2MPcpsAcquisition::set_channel(unsigned int channel) { channel_ = channel; @@ -137,7 +186,7 @@ void GpsL2MPcpsAcquisition::set_channel(unsigned int channel) void GpsL2MPcpsAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); if (pfa == 0.0) { @@ -199,9 +248,27 @@ void GpsL2MPcpsAcquisition::init() void GpsL2MPcpsAcquisition::set_local_code() { - gps_l2c_m_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_); + auto* code = new std::complex[code_length_]; + + + if (acq_parameters_.use_automatic_resampler) + { + gps_l2c_m_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs); + } + else + { + gps_l2c_m_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_); + } + + + for (unsigned int i = 0; i < num_codes_; i++) + { + memcpy(&(code_[i * code_length_]), code, + sizeof(gr_complex) * code_length_); + } acquisition_->set_local_code(code_); + delete[] code; } @@ -228,9 +295,9 @@ float GpsL2MPcpsAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1.0 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -238,20 +305,21 @@ float GpsL2MPcpsAcquisition::calculate_threshold(float pfa) void GpsL2MPcpsAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { + // Since a byte-based acq implementation is not available, + // we just convert cshorts to gr_complex top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + top_block->connect(float_to_complex_, 0, acquisition_, 0); } else { @@ -262,22 +330,19 @@ void GpsL2MPcpsAcquisition::connect(gr::top_block_sptr top_block) void GpsL2MPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { - // Since a byte-based acq implementation is not available, - // we just convert cshorts to gr_complex top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + top_block->disconnect(float_to_complex_, 0, acquisition_, 0); } else { @@ -288,23 +353,21 @@ void GpsL2MPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GpsL2MPcpsAcquisition::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } @@ -312,3 +375,7 @@ gr::basic_block_sptr GpsL2MPcpsAcquisition::get_right_block() { return acquisition_; } +void GpsL2MPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) +{ + acquisition_->set_resampler_latency(latency_samples); +} diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h index c6ad236cf..da1c7ef6e 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h @@ -35,10 +35,9 @@ #define GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_H_ #include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include "complex_byte_to_float_x2.h" -#include #include #include #include @@ -54,7 +53,8 @@ class GpsL2MPcpsAcquisition : public AcquisitionInterface { public: GpsL2MPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL2MPcpsAcquisition(); @@ -132,12 +132,24 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ + + void set_resampler_latency(uint32_t latency_samples) override; + private: ConfigurationInterface* configuration_; pcps_acquisition_sptr acquisition_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; + Acq_Conf acq_parameters_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; size_t item_size_; @@ -151,8 +163,7 @@ private: unsigned int doppler_max_; unsigned int doppler_step_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; @@ -161,6 +172,7 @@ private: std::string role_; unsigned int in_streams_; unsigned int out_streams_; + unsigned int num_codes_; float calculate_threshold(float pfa); }; diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc new file mode 100644 index 000000000..c3cd96275 --- /dev/null +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -0,0 +1,404 @@ +/*! + * \file gps_l2_m_pcps_acquisition.cc + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * GPS L2 M signals + * \authors
        + *
      • Javier Arribas, 2015. jarribas(at)cttc.es + *
      + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "gps_l2_m_pcps_acquisition_fpga.h" +#include "GPS_L2C.h" +#include "configuration_interface.h" +#include "gnss_sdr_flags.h" +#include "gps_l2c_signal.h" +#include +#include + +#define NUM_PRNs 32 + +using google::LogMessage; + + +GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + //pcpsconf_t acq_parameters; + pcpsconf_fpga_t acq_parameters; + configuration_ = configuration; + std::string default_item_type = "gr_complex"; + std::string default_dump_filename = "./acquisition.mat"; + + LOG(INFO) << "role " << role; + + item_type_ = configuration_->property(role + ".item_type", default_item_type); + //float pfa = configuration_->property(role + ".pfa", 0.0); + + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + acq_parameters.fs_in = fs_in_; + //if_ = configuration_->property(role + ".if", 0); + //acq_parameters.freq = if_; + //dump_ = configuration_->property(role + ".dump", false); + //acq_parameters.dump = dump_; + //blocking_ = configuration_->property(role + ".blocking", true); + //acq_parameters.blocking = blocking_; + doppler_max_ = configuration->property(role + ".doppler_max", 5000); + if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + acq_parameters.doppler_max = doppler_max_; + //bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); + //acq_parameters.bit_transition_flag = bit_transition_flag_; + //use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions + //acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; + //max_dwells_ = configuration_->property(role + ".max_dwells", 1); + //acq_parameters.max_dwells = max_dwells_; + //dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); + //acq_parameters.dump_filename = dump_filename_; + //--- Find number of samples per spreading code ------------------------- + //code_length_ = std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); + + acq_parameters.sampled_ms = 20; + unsigned code_length = std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); + acq_parameters.code_length = code_length; + // The FPGA can only use FFT lengths that are a power of two. + float nbits = ceilf(log2f((float)code_length)); + unsigned int nsamples_total = pow(2, nbits); + unsigned int vector_length = nsamples_total; + unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); + acq_parameters.select_queue_Fpga = select_queue_Fpga; + std::string default_device_name = "/dev/uio0"; + std::string device_name = configuration_->property(role + ".devicename", default_device_name); + acq_parameters.device_name = device_name; + acq_parameters.samples_per_ms = nsamples_total / acq_parameters.sampled_ms; + //acq_parameters.samples_per_ms = static_cast(std::round(static_cast(fs_in_) * 0.001)); + acq_parameters.samples_per_code = nsamples_total; + + // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time + // a channel is assigned) + auto* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT + // allocate memory to compute all the PRNs and compute all the possible codes + auto* code = new std::complex[nsamples_total]; // buffer for the local code + auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32 + float max; // temporary maxima search + for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + { + gps_l2c_m_code_gen_complex_sampled(code, PRN, fs_in_); + // fill in zero padding + for (int s = code_length; s < nsamples_total; s++) + { + code[s] = std::complex(0.0, 0.0); + //code[s] = 0; + } + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + fft_if->execute(); // Run the FFT of local code + volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values + max = 0; // initialize maximum value + for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima + { + if (std::abs(fft_codes_padded[i].real()) > max) + { + max = std::abs(fft_codes_padded[i].real()); + } + if (std::abs(fft_codes_padded[i].imag()) > max) + { + max = std::abs(fft_codes_padded[i].imag()); + } + } + for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + { + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max))); + } + } + + //acq_parameters + acq_parameters.all_fft_codes = d_all_fft_codes_; + + // temporary buffers that we can delete + delete[] code; + delete fft_if; + delete[] fft_codes_padded; + + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + channel_ = 0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + + + // vector_length_ = code_length_; + // + // if (bit_transition_flag_) + // { + // vector_length_ *= 2; + // } + + // code_ = new gr_complex[vector_length_]; + // + // if (item_type_.compare("cshort") == 0) + // { + // item_size_ = sizeof(lv_16sc_t); + // } + // else + // { + // item_size_ = sizeof(gr_complex); + // } + //acq_parameters.samples_per_ms = static_cast(std::round(static_cast(fs_in_) * 0.001)); + //acq_parameters.samples_per_code = code_length_; + //acq_parameters.it_size = item_size_; + //acq_parameters.sampled_ms = 20; + //acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); + //acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); + //acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", true); + //acquisition_ = pcps_make_acquisition(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + // stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); + // DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; + // + // if (item_type_.compare("cbyte") == 0) + // { + // cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); + // float_to_complex_ = gr::blocks::float_to_complex::make(); + // } + + // channel_ = 0; + threshold_ = 0.0; + // doppler_step_ = 0; + // gnss_synchro_ = 0; +} + + +GpsL2MPcpsAcquisitionFpga::~GpsL2MPcpsAcquisitionFpga() +{ + //delete[] code_; + delete[] d_all_fft_codes_; +} + + +void GpsL2MPcpsAcquisitionFpga::stop_acquisition() +{ +} + + +void GpsL2MPcpsAcquisitionFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + acquisition_fpga_->set_channel(channel_); +} + + +void GpsL2MPcpsAcquisitionFpga::set_threshold(float threshold) +{ + // float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); + // + // if (pfa == 0.0) + // { + // pfa = configuration_->property(role_ + ".pfa", 0.0); + // } + // if (pfa == 0.0) + // { + // threshold_ = threshold; + // } + // else + // { + // threshold_ = calculate_threshold(pfa); + // } + + DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; + + acquisition_fpga_->set_threshold(threshold_); +} + + +void GpsL2MPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max) +{ + doppler_max_ = doppler_max; + + acquisition_fpga_->set_doppler_max(doppler_max_); +} + + +// Be aware that Doppler step should be set to 2/(3T) Hz, where T is the coherent integration time (GPS L2 period is 0.02s) +// Doppler bin minimum size= 33 Hz +void GpsL2MPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step) +{ + doppler_step_ = doppler_step; + + acquisition_fpga_->set_doppler_step(doppler_step_); +} + + +void GpsL2MPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + + acquisition_fpga_->set_gnss_synchro(gnss_synchro_); +} + + +signed int GpsL2MPcpsAcquisitionFpga::mag() +{ + return acquisition_fpga_->mag(); +} + + +void GpsL2MPcpsAcquisitionFpga::init() +{ + acquisition_fpga_->init(); + //set_local_code(); +} + + +void GpsL2MPcpsAcquisitionFpga::set_local_code() +{ + //gps_l2c_m_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_); + + //acquisition_fpga_->set_local_code(code_); + acquisition_fpga_->set_local_code(); +} + + +void GpsL2MPcpsAcquisitionFpga::reset() +{ + acquisition_fpga_->set_active(true); +} + +void GpsL2MPcpsAcquisitionFpga::set_state(int state) +{ + acquisition_fpga_->set_state(state); +} + + +//float GpsL2MPcpsAcquisitionFpga::calculate_threshold(float pfa) +//{ +// //Calculate the threshold +// unsigned int frequency_bins = 0; +// for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += doppler_step_) +// { +// frequency_bins++; +// } +// DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; +// unsigned int ncells = vector_length_ * frequency_bins; +// double exponent = 1.0 / static_cast(ncells); +// double val = pow(1.0 - pfa, exponent); +// double lambda = double(vector_length_); +// boost::math::exponential_distribution mydist(lambda); +// float threshold = static_cast(quantile(mydist, val)); +// +// return threshold; +//} + + +void GpsL2MPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) +{ + // if (item_type_.compare("gr_complex") == 0) + // { + // top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // } + // else if (item_type_.compare("cshort") == 0) + // { + // top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // } + // else if (item_type_.compare("cbyte") == 0) + // { + // top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); + // top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); + // top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); + // top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // } + // else + // { + // LOG(WARNING) << item_type_ << " unknown acquisition item type"; + // } + + // nothing to connect +} + + +void GpsL2MPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) +{ + // if (item_type_.compare("gr_complex") == 0) + // { + // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // } + // else if (item_type_.compare("cshort") == 0) + // { + // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // } + // else if (item_type_.compare("cbyte") == 0) + // { + // // Since a byte-based acq implementation is not available, + // // we just convert cshorts to gr_complex + // top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); + // top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); + // top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); + // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // } + // else + // { + // LOG(WARNING) << item_type_ << " unknown acquisition item type"; + // } + + // nothing to disconnect +} + + +gr::basic_block_sptr GpsL2MPcpsAcquisitionFpga::get_left_block() +{ + // if (item_type_.compare("gr_complex") == 0) + // { + // return stream_to_vector_; + // } + // else if (item_type_.compare("cshort") == 0) + // { + // return stream_to_vector_; + // } + // else if (item_type_.compare("cbyte") == 0) + // { + // return cbyte_to_float_x2_; + // } + // else + // { + // LOG(WARNING) << item_type_ << " unknown acquisition item type"; + // return nullptr; + // } + return nullptr; +} + + +gr::basic_block_sptr GpsL2MPcpsAcquisitionFpga::get_right_block() +{ + return acquisition_fpga_; +} diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h new file mode 100644 index 000000000..102911d3d --- /dev/null +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -0,0 +1,179 @@ +/*! + * \file gps_l2_m_pcps_acquisition.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * GPS L2 M signals + * \authors
        + *
      • Javier Arribas, 2015. jarribas(at)cttc.es + *
      + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_FPGA_H_ +#define GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_FPGA_H_ + +#include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" +#include "gnss_synchro.h" +#include "pcps_acquisition_fpga.h" +#include +#include +#include +#include + + +class ConfigurationInterface; + +/*! + * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface + * for GPS L2 M signals + */ +class GpsL2MPcpsAcquisitionFpga : public AcquisitionInterface +{ +public: + GpsL2MPcpsAcquisitionFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GpsL2MPcpsAcquisitionFpga(); + + inline std::string role() override + { + return role_; + } + + /*! + * \brief Returns "GPS_L2_M_PCPS_Acquisition" + */ + inline std::string implementation() override + { + return "GPS_L2_M_PCPS_Acquisition"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) override; + + /*! + * \brief Set maximum Doppler off grid search + */ + void set_doppler_max(unsigned int doppler_max) override; + + /*! + * \brief Set Doppler steps for the grid search + */ + void set_doppler_step(unsigned int doppler_step) override; + + /*! + * \brief Initializes acquisition algorithm. + */ + void init() override; + + /*! + * \brief Sets local code for GPS L2/M PCPS acquisition algorithm. + */ + void set_local_code() override; + + /*! + * \brief Returns the maximum peak of grid search + */ + signed int mag() override; + + /*! + * \brief Restart acquisition algorithm + */ + void reset() override; + + /*! + * \brief If state = 1, it forces the block to start acquiring from the first sample + */ + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; + +private: + ConfigurationInterface* configuration_; + //pcps_acquisition_sptr acquisition_; + pcps_acquisition_fpga_sptr acquisition_fpga_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; + gr::blocks::float_to_complex::sptr float_to_complex_; + complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + size_t item_size_; + std::string item_type_; + unsigned int vector_length_; + unsigned int code_length_; + bool bit_transition_flag_; + bool use_CFAR_algorithm_flag_; + unsigned int channel_; + float threshold_; + unsigned int doppler_max_; + unsigned int doppler_step_; + unsigned int max_dwells_; + int64_t fs_in_; + //long if_; + bool dump_; + bool blocking_; + std::string dump_filename_; + std::complex* code_; + Gnss_Synchro* gnss_synchro_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; + + lv_16sc_t* d_all_fft_codes_; // memory that contains all the code ffts + + //float calculate_threshold(float pfa); +}; + +#endif /* GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_FPGA_H_ */ diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc index 78030bfbc..69503c7bd 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc @@ -1,5 +1,5 @@ /*! - * \file gps_l5i pcps_acquisition.cc + * \file gps_l5i_pcps_acquisition.cc * \brief Adapts a PCPS acquisition block to an Acquisition Interface for * GPS L5i signals * \authors
        @@ -32,62 +32,59 @@ */ #include "gps_l5i_pcps_acquisition.h" -#include "configuration_interface.h" -#include "gps_l5_signal.h" #include "GPS_L5.h" +#include "acq_conf.h" +#include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include "gps_l5_signal.h" #include #include using google::LogMessage; + GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - pcpsconf_t acq_parameters; configuration_ = configuration; std::string default_item_type = "gr_complex"; - std::string default_dump_filename = "./data/acquisition.dat"; + std::string default_dump_filename = "./acquisition.mat"; LOG(INFO) << "role " << role; item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - acq_parameters.fs_in = fs_in_; - if_ = configuration_->property(role + ".if", 0); - acq_parameters.freq = if_; + acq_parameters_.fs_in = fs_in_; dump_ = configuration_->property(role + ".dump", false); - acq_parameters.dump = dump_; + acq_parameters_.dump = dump_; + acq_parameters_.dump_channel = configuration_->property(role + ".dump_channel", 0); blocking_ = configuration_->property(role + ".blocking", true); - acq_parameters.blocking = blocking_; + acq_parameters_.blocking = blocking_; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; - acq_parameters.doppler_max = doppler_max_; - bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - acq_parameters.bit_transition_flag = bit_transition_flag_; - use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions - acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; - max_dwells_ = configuration_->property(role + ".max_dwells", 1); - acq_parameters.max_dwells = max_dwells_; - dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - acq_parameters.dump_filename = dump_filename_; - //--- Find number of samples per spreading code ------------------------- - code_length_ = static_cast(std::round(static_cast(fs_in_) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); - - vector_length_ = code_length_; - - if (bit_transition_flag_) + if (FLAGS_doppler_max != 0) { - vector_length_ *= 2; + doppler_max_ = FLAGS_doppler_max; } + acq_parameters_.doppler_max = doppler_max_; + bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); + acq_parameters_.bit_transition_flag = bit_transition_flag_; + use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions + acq_parameters_.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; + max_dwells_ = configuration_->property(role + ".max_dwells", 1); + acq_parameters_.max_dwells = max_dwells_; + dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); + acq_parameters_.dump_filename = dump_filename_; + acq_parameters_.sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); - code_ = new gr_complex[vector_length_]; - - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -95,20 +92,55 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( { item_size_ = sizeof(gr_complex); } - acq_parameters.samples_per_code = code_length_; - acq_parameters.samples_per_ms = code_length_; - acq_parameters.it_size = item_size_; - acq_parameters.sampled_ms = 1; - acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); - acquisition_ = pcps_make_acquisition(acq_parameters); + + acq_parameters_.ms_per_code = 1; + acq_parameters_.it_size = item_size_; + num_codes_ = acq_parameters_.sampled_ms; + acq_parameters_.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); + acq_parameters_.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); + acq_parameters_.make_2_steps = configuration_->property(role + ".make_two_steps", false); + acq_parameters_.blocking_on_standby = configuration_->property(role + ".blocking_on_standby", false); + acq_parameters_.use_automatic_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); + if (acq_parameters_.use_automatic_resampler == true and item_type_ != "gr_complex") + { + LOG(WARNING) << "GPS L5 acquisition disabled the automatic resampler feature because its item_type is not set to gr_complex"; + acq_parameters_.use_automatic_resampler = false; + } + if (acq_parameters_.use_automatic_resampler) + { + if (acq_parameters_.fs_in > GPS_L5_OPT_ACQ_FS_HZ) + { + acq_parameters_.resampler_ratio = floor(static_cast(acq_parameters_.fs_in) / GPS_L5_OPT_ACQ_FS_HZ); + uint32_t decimation = acq_parameters_.fs_in / GPS_L5_OPT_ACQ_FS_HZ; + while (acq_parameters_.fs_in % decimation > 0) + { + decimation--; + }; + acq_parameters_.resampler_ratio = decimation; + acq_parameters_.resampled_fs = acq_parameters_.fs_in / static_cast(acq_parameters_.resampler_ratio); + } + + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GPS_L5I_CODE_RATE_HZ / GPS_L5I_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(acq_parameters_.resampled_fs) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GPS_L5I_CODE_RATE_HZ) * static_cast(acq_parameters_.resampled_fs))); + } + else + { + acq_parameters_.resampled_fs = fs_in_; + //--- Find number of samples per spreading code ------------------------- + code_length_ = static_cast(std::floor(static_cast(fs_in_) / (GPS_L5I_CODE_RATE_HZ / GPS_L5I_CODE_LENGTH_CHIPS))); + acq_parameters_.samples_per_ms = static_cast(fs_in_) * 0.001; + acq_parameters_.samples_per_chip = static_cast(ceil((1.0 / GPS_L5I_CODE_RATE_HZ) * static_cast(acq_parameters_.fs_in))); + } + + acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast(GPS_L5I_PERIOD * 1000.0); + vector_length_ = std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2 : 1); + code_ = new gr_complex[vector_length_]; + acquisition_ = pcps_make_acquisition(acq_parameters_); DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); float_to_complex_ = gr::blocks::float_to_complex::make(); @@ -117,7 +149,15 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } } @@ -127,6 +167,11 @@ GpsL5iPcpsAcquisition::~GpsL5iPcpsAcquisition() } +void GpsL5iPcpsAcquisition::stop_acquisition() +{ +} + + void GpsL5iPcpsAcquisition::set_channel(unsigned int channel) { channel_ = channel; @@ -136,7 +181,7 @@ void GpsL5iPcpsAcquisition::set_channel(unsigned int channel) void GpsL5iPcpsAcquisition::set_threshold(float threshold) { - float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); + float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); if (pfa == 0.0) { @@ -196,9 +241,26 @@ void GpsL5iPcpsAcquisition::init() void GpsL5iPcpsAcquisition::set_local_code() { - gps_l5i_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_); + auto* code = new std::complex[code_length_]; + + + if (acq_parameters_.use_automatic_resampler) + { + gps_l5i_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs); + } + else + { + gps_l5i_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_); + } + + for (unsigned int i = 0; i < num_codes_; i++) + { + memcpy(&(code_[i * code_length_]), code, + sizeof(gr_complex) * code_length_); + } acquisition_->set_local_code(code_); + delete[] code; } @@ -225,9 +287,9 @@ float GpsL5iPcpsAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1.0 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = double(vector_length_); + auto lambda = double(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -235,20 +297,21 @@ float GpsL5iPcpsAcquisition::calculate_threshold(float pfa) void GpsL5iPcpsAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + // nothing to connect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { + // Since a byte-based acq implementation is not available, + // we just convert cshorts to gr_complex top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->connect(stream_to_vector_, 0, acquisition_, 0); + top_block->connect(float_to_complex_, 0, acquisition_, 0); } else { @@ -259,22 +322,19 @@ void GpsL5iPcpsAcquisition::connect(gr::top_block_sptr top_block) void GpsL5iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + // nothing to disconnect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { - // Since a byte-based acq implementation is not available, - // we just convert cshorts to gr_complex top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + top_block->disconnect(float_to_complex_, 0, acquisition_, 0); } else { @@ -285,23 +345,21 @@ void GpsL5iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GpsL5iPcpsAcquisition::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { - return stream_to_vector_; + return acquisition_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } @@ -309,3 +367,8 @@ gr::basic_block_sptr GpsL5iPcpsAcquisition::get_right_block() { return acquisition_; } + +void GpsL5iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) +{ + acquisition_->set_resampler_latency(latency_samples); +} diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h index 41b0e347b..af8cabb81 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h @@ -1,5 +1,5 @@ /*! - * \file GPS_L5i_PCPS_Acquisition.h + * \file gps_l5i_pcps_acquisition.h * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for * GPS L5i signals * \authors
          @@ -35,10 +35,9 @@ #define GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_H_ #include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include "complex_byte_to_float_x2.h" -#include #include #include #include @@ -54,7 +53,8 @@ class GpsL5iPcpsAcquisition : public AcquisitionInterface { public: GpsL5iPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, + unsigned int in_streams, unsigned int out_streams); virtual ~GpsL5iPcpsAcquisition(); @@ -132,12 +132,23 @@ public: /*! * \brief If state = 1, it forces the block to start acquiring from the first sample */ - void set_state(int state); + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ + + void set_resampler_latency(uint32_t latency_samples) override; private: ConfigurationInterface* configuration_; pcps_acquisition_sptr acquisition_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; + Acq_Conf acq_parameters_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; size_t item_size_; @@ -151,14 +162,14 @@ private: unsigned int doppler_max_; unsigned int doppler_step_; unsigned int max_dwells_; - long fs_in_; - long if_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; std::complex* code_; Gnss_Synchro* gnss_synchro_; std::string role_; + unsigned int num_codes_; unsigned int in_streams_; unsigned int out_streams_; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc new file mode 100644 index 000000000..04e30c63c --- /dev/null +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -0,0 +1,257 @@ +/*! + * \file gps_l5i pcps_acquisition_fpga.cc + * \brief Adapts a PCPS acquisition block to an Acquisition Interface for + * GPS L5i signals for the FPGA + * \authors
            + *
          • Marc Majoral, 2017. mmajoral(at)cttc.es + *
          • Javier Arribas, 2017. jarribas(at)cttc.es + *
          + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "gps_l5i_pcps_acquisition_fpga.h" +#include "GPS_L5.h" +#include "configuration_interface.h" +#include "gnss_sdr_flags.h" +#include "gps_l5_signal.h" +#include +#include + +#define NUM_PRNs 32 + +using google::LogMessage; + + +GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( + ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + pcpsconf_fpga_t acq_parameters; + configuration_ = configuration; + std::string default_dump_filename = "./data/acquisition.dat"; + + LOG(INFO) << "role " << role; + + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 1.0); + acq_parameters.downsampling_factor = downsampling_factor; + + fs_in = fs_in / downsampling_factor; + + + acq_parameters.fs_in = fs_in; + doppler_max_ = configuration->property(role + ".doppler_max", 5000); + if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + acq_parameters.doppler_max = doppler_max_; + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + acq_parameters.sampled_ms = sampled_ms; + + //--- Find number of samples per spreading code ------------------------- + auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); + acq_parameters.code_length = code_length; + // The FPGA can only use FFT lengths that are a power of two. + float nbits = ceilf(log2f((float)code_length * 2)); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); + acq_parameters.select_queue_Fpga = select_queue_Fpga; + std::string default_device_name = "/dev/uio0"; + std::string device_name = configuration_->property(role + ".devicename", default_device_name); + acq_parameters.device_name = device_name; + acq_parameters.samples_per_ms = nsamples_total / sampled_ms; + acq_parameters.samples_per_code = nsamples_total; + + acq_parameters.excludelimit = static_cast(ceil((1.0 / GPS_L5I_CODE_RATE_HZ) * static_cast(acq_parameters.fs_in))); + + // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time + // a channel is assigned) + gr::fft::fft_complex* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT + std::complex* code = new gr_complex[nsamples_total]; + auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32 + + float max; // temporary maxima search + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) + { + gps_l5i_code_gen_complex_sampled(code, PRN, fs_in); + + for (uint32_t s = code_length; s < 2 * code_length; s++) + { + code[s] = code[s - code_length]; + } + + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) + { + // fill in zero padding + code[s] = std::complex(static_cast(0, 0)); + } + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + fft_if->execute(); // Run the FFT of local code + volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values + + max = 0; // initialize maximum value + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima + { + if (std::abs(fft_codes_padded[i].real()) > max) + { + max = std::abs(fft_codes_padded[i].real()); + } + if (std::abs(fft_codes_padded[i].imag()) > max) + { + max = std::abs(fft_codes_padded[i].imag()); + } + } + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + { + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + } + } + + //acq_parameters + acq_parameters.all_fft_codes = d_all_fft_codes_; + + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); + + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + channel_ = 0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + + // temporary buffers that we can delete + delete[] code; + delete fft_if; + delete[] fft_codes_padded; +} + + +GpsL5iPcpsAcquisitionFpga::~GpsL5iPcpsAcquisitionFpga() +{ + //delete[] code_; + delete[] d_all_fft_codes_; +} + + +void GpsL5iPcpsAcquisitionFpga::stop_acquisition() +{ + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); +} + + +void GpsL5iPcpsAcquisitionFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + acquisition_fpga_->set_channel(channel_); +} + + +void GpsL5iPcpsAcquisitionFpga::set_threshold(float threshold) +{ + DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; + acquisition_fpga_->set_threshold(threshold); +} + + +void GpsL5iPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max) +{ + doppler_max_ = doppler_max; + acquisition_fpga_->set_doppler_max(doppler_max_); +} + +// Be aware that Doppler step should be set to 2/(3T) Hz, where T is the coherent integration time (GPS L2 period is 0.02s) +// Doppler bin minimum size= 33 Hz +void GpsL5iPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step) +{ + doppler_step_ = doppler_step; + acquisition_fpga_->set_doppler_step(doppler_step_); +} + + +void GpsL5iPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + acquisition_fpga_->set_gnss_synchro(gnss_synchro_); +} + + +signed int GpsL5iPcpsAcquisitionFpga::mag() +{ + return acquisition_fpga_->mag(); +} + + +void GpsL5iPcpsAcquisitionFpga::init() +{ + acquisition_fpga_->init(); +} + +void GpsL5iPcpsAcquisitionFpga::set_local_code() +{ + acquisition_fpga_->set_local_code(); +} + + +void GpsL5iPcpsAcquisitionFpga::reset() +{ + acquisition_fpga_->set_active(true); +} + +void GpsL5iPcpsAcquisitionFpga::set_state(int state) +{ + acquisition_fpga_->set_state(state); +} + +void GpsL5iPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) +{ + // nothing to connect +} + + +void GpsL5iPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) +{ + // nothing to disconnect +} + + +gr::basic_block_sptr GpsL5iPcpsAcquisitionFpga::get_left_block() +{ + return nullptr; +} + + +gr::basic_block_sptr GpsL5iPcpsAcquisitionFpga::get_right_block() +{ + return acquisition_fpga_; +} diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h new file mode 100644 index 000000000..8c22d8423 --- /dev/null +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -0,0 +1,178 @@ +/*! + * \file GPS_L5i_PCPS_Acquisition_fpga.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * GPS L5i signals for the FPGA + * \authors
            + *
          • Marc Majoral, 2019. mmajoral(at)cttc.es + *
          • Javier Arribas, 2017. jarribas(at)cttc.es + *
          + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_FPGA_H_ +#define GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_FPGA_H_ + +#include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" +#include "gnss_synchro.h" +#include "pcps_acquisition_fpga.h" +#include +#include +#include +#include + + +class ConfigurationInterface; + +/*! + * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface + * for GPS L5i signals + */ +class GpsL5iPcpsAcquisitionFpga : public AcquisitionInterface +{ +public: + GpsL5iPcpsAcquisitionFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GpsL5iPcpsAcquisitionFpga(); + + inline std::string role() override + { + return role_; + } + + /*! + * \brief Returns "GPS_L5i_PCPS_Acquisition_Fpga" + */ + inline std::string implementation() override + { + return "GPS_L5i_PCPS_Acquisition_Fpga"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) override; + + /*! + * \brief Set maximum Doppler off grid search + */ + void set_doppler_max(unsigned int doppler_max) override; + + /*! + * \brief Set Doppler steps for the grid search + */ + void set_doppler_step(unsigned int doppler_step) override; + + /*! + * \brief Initializes acquisition algorithm. + */ + void init() override; + + /*! + * \brief Sets local code for GPS L2/M PCPS acquisition algorithm. + */ + void set_local_code() override; + + /*! + * \brief Returns the maximum peak of grid search + */ + signed int mag() override; + + /*! + * \brief Restart acquisition algorithm + */ + void reset() override; + + /*! + * \brief If state = 1, it forces the block to start acquiring from the first sample + */ + void set_state(int state) override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; + +private: + ConfigurationInterface* configuration_; + pcps_acquisition_fpga_sptr acquisition_fpga_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; + gr::blocks::float_to_complex::sptr float_to_complex_; + complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + size_t item_size_; + std::string item_type_; + uint32_t vector_length_; + uint32_t code_length_; + bool bit_transition_flag_; + bool use_CFAR_algorithm_flag_; + uint32_t channel_; + float threshold_; + uint32_t doppler_max_; + uint32_t doppler_step_; + uint32_t max_dwells_; + int64_t fs_in_; + bool dump_; + bool blocking_; + std::string dump_filename_; + std::complex* code_; + Gnss_Synchro* gnss_synchro_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; + + lv_16sc_t* d_all_fft_codes_; // memory that contains all the code ffts + + float calculate_threshold(float pfa); +}; + +#endif /* GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_FPGA_H_ */ diff --git a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt index fbc33410e..5a135364b 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -26,52 +26,84 @@ set(ACQ_GR_BLOCKS_SOURCES pcps_quicksync_acquisition_cc.cc galileo_pcps_8ms_acquisition_cc.cc galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc -) +) + +set(ACQ_GR_BLOCKS_HEADERS + pcps_acquisition.h + pcps_assisted_acquisition_cc.h + pcps_acquisition_fine_doppler_cc.h + pcps_tong_acquisition_cc.h + pcps_cccwsr_acquisition_cc.h + pcps_quicksync_acquisition_cc.h + galileo_pcps_8ms_acquisition_cc.h + galileo_e5a_noncoherent_iq_acquisition_caf_cc.h +) if(ENABLE_FPGA) set(ACQ_GR_BLOCKS_SOURCES ${ACQ_GR_BLOCKS_SOURCES} pcps_acquisition_fpga.cc) -endif(ENABLE_FPGA) - + set(ACQ_GR_BLOCKS_HEADERS ${ACQ_GR_BLOCKS_HEADERS} pcps_acquisition_fpga.h) +endif() + if(OPENCL_FOUND) set(ACQ_GR_BLOCKS_SOURCES ${ACQ_GR_BLOCKS_SOURCES} pcps_opencl_acquisition_cc.cc) -endif(OPENCL_FOUND) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${ARMADILLO_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} - ${MATIO_INCLUDE_DIRS} -) + set(ACQ_GR_BLOCKS_HEADERS ${ACQ_GR_BLOCKS_HEADERS} pcps_opencl_acquisition_cc.h) +endif() if(OPENCL_FOUND) - include_directories( ${OPENCL_INCLUDE_DIRS} ) + include_directories(${OPENCL_INCLUDE_DIRS}) if(OS_IS_MACOSX) - set(OPT_LIBRARIES ${OPT_LIBRARIES} "-framework OpenCL") - else(OS_IS_MACOSX) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES}) - endif(OS_IS_MACOSX) -endif(OPENCL_FOUND) + set(OPT_LIBRARIES ${OPT_LIBRARIES} "-framework OpenCL") + else() + set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES}) + endif() +endif() -file(GLOB ACQ_GR_BLOCKS_HEADERS "*.h") list(SORT ACQ_GR_BLOCKS_HEADERS) -add_library(acq_gr_blocks ${ACQ_GR_BLOCKS_SOURCES} ${ACQ_GR_BLOCKS_HEADERS}) -source_group(Headers FILES ${ACQ_GR_BLOCKS_HEADERS}) +list(SORT ACQ_GR_BLOCKS_SOURCES) -if(ENABLE_FPGA) - target_link_libraries(acq_gr_blocks acquisition_lib gnss_sp_libs gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FFT_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_LIBRARIES} ${OPT_ACQUISITION_LIBRARIES}) -else(ENABLE_FPGA) - target_link_libraries(acq_gr_blocks gnss_sp_libs gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FFT_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_LIBRARIES} ${OPT_ACQUISITION_LIBRARIES} ${MATIO_LIBRARIES}) -endif(ENABLE_FPGA) +source_group(Headers FILES ${ACQ_GR_BLOCKS_HEADERS}) -if(NOT VOLK_GNSSSDR_FOUND) - add_dependencies(acq_gr_blocks volk_gnsssdr_module) -endif(NOT VOLK_GNSSSDR_FOUND) +add_library(acquisition_gr_blocks ${ACQ_GR_BLOCKS_SOURCES} ${ACQ_GR_BLOCKS_HEADERS}) + +target_link_libraries(acquisition_gr_blocks + PUBLIC + Gnuradio::runtime + Gnuradio::fft + Volk::volk + acquisition_libs + core_system_parameters + ${OPT_LIBRARIES} + PRIVATE + Boost::filesystem + Gflags::gflags + Glog::glog + Matio::matio + Volkgnsssdr::volkgnsssdr + algorithms_libs +) + +target_include_directories(acquisition_gr_blocks + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs + PRIVATE + ${CMAKE_SOURCE_DIR}/src/core/receiver +) + +if(OPENCL_FOUND) + target_include_directories(acquisition_gr_blocks PUBLIC ${OPENCL_INCLUDE_DIRS}) +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(acquisition_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET acquisition_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index 568ca22f0..c6f14d597 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -36,19 +36,20 @@ */ #include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h" -#include "control_message_factory.h" #include #include #include #include +#include #include +#include using google::LogMessage; galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc( unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, + unsigned int doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, @@ -58,8 +59,8 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make int Zero_padding_) { return galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr( - new galileo_e5a_noncoherentIQ_acquisition_caf_cc(sampled_ms, max_dwells, doppler_max, freq, fs_in, samples_per_ms, - samples_per_code, bit_transition_flag, dump, dump_filename, both_signal_components_, CAF_window_hz_, Zero_padding_)); + new galileo_e5a_noncoherentIQ_acquisition_caf_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, + samples_per_code, bit_transition_flag, dump, std::move(dump_filename), both_signal_components_, CAF_window_hz_, Zero_padding_)); } @@ -67,8 +68,7 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit unsigned int sampled_ms, unsigned int max_dwells, unsigned int doppler_max, - long freq, - long fs_in, + int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, @@ -81,10 +81,9 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit gr::io_signature::make(0, 0, sizeof(gr_complex))) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; - d_freq = freq; d_fs_in = fs_in; d_samples_per_ms = samples_per_ms; d_samples_per_code = samples_per_code; @@ -119,8 +118,8 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit } else { - d_fft_code_Q_A = 0; - d_magnitudeQA = 0; + d_fft_code_Q_A = nullptr; + d_magnitudeQA = nullptr; } // IF COHERENT INTEGRATION TIME > 1 if (d_sampled_ms > 1) @@ -134,16 +133,16 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit } else { - d_fft_code_Q_B = 0; - d_magnitudeQB = 0; + d_fft_code_Q_B = nullptr; + d_magnitudeQB = nullptr; } } else { - d_fft_code_I_B = 0; - d_magnitudeIB = 0; - d_fft_code_Q_B = 0; - d_magnitudeQB = 0; + d_fft_code_I_B = nullptr; + d_magnitudeIB = nullptr; + d_fft_code_Q_B = nullptr; + d_magnitudeQB = nullptr; } // Direct FFT @@ -154,19 +153,19 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit // For dumping samples into a file d_dump = dump; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); d_doppler_resolution = 0; d_threshold = 0; d_doppler_step = 250; - d_grid_doppler_wipeoffs = 0; - d_gnss_synchro = 0; + d_grid_doppler_wipeoffs = nullptr; + d_gnss_synchro = nullptr; d_code_phase = 0; d_doppler_freq = 0; d_test_statistics = 0; - d_CAF_vector = 0; - d_CAF_vector_I = 0; - d_CAF_vector_Q = 0; + d_CAF_vector = nullptr; + d_CAF_vector_I = nullptr; + d_CAF_vector_Q = nullptr; d_channel = 0; d_gr_stream_buffer = 0; } @@ -215,9 +214,20 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::~galileo_e5a_noncoherentIQ_acquisi delete d_fft_if; delete d_ifft; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } @@ -282,7 +292,8 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::init() d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_doppler_step = 0U; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_mag = 0.0; d_input_power = 0.0; const double GALILEO_TWO_PI = 6.283185307179600; @@ -302,7 +313,7 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::init() { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = GALILEO_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); + float phase_step_rad = GALILEO_TWO_PI * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size); @@ -330,7 +341,8 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_state(int state) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -378,21 +390,22 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items //restart acquisition variables d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; d_state = 1; } - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; } case 1: { - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer unsigned int buff_increment; if ((ninput_items[0] + d_buffer_count) <= d_fft_size) { @@ -409,19 +422,19 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items d_state = 2; } d_buffer_count += buff_increment; - d_sample_counter += buff_increment; // sample counter + d_sample_counter += static_cast(buff_increment); // sample counter consume_each(buff_increment); break; } case 2: { // Fill last part of the buffer and reset counter - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer if (d_buffer_count < d_fft_size) { memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex) * (d_fft_size - d_buffer_count)); } - d_sample_counter += (d_fft_size - d_buffer_count); // sample counter + d_sample_counter += static_cast(d_fft_size - d_buffer_count); // sample counter // initialize acquisition algorithm int doppler; @@ -635,7 +648,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - + d_gnss_synchro->Acq_doppler_step = d_doppler_step; // 5- Compute the test statistics and compare to the threshold d_test_statistics = d_mag / d_input_power; } @@ -673,7 +686,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items if (d_CAF_window_hz > 0) { int CAF_bins_half; - float *accum = static_cast(volk_gnsssdr_malloc(sizeof(float), volk_gnsssdr_get_alignment())); + auto *accum = static_cast(volk_gnsssdr_malloc(sizeof(float), volk_gnsssdr_get_alignment())); CAF_bins_half = d_CAF_window_hz / (2 * d_doppler_step); float weighting_factor; weighting_factor = 0.5 / static_cast(CAF_bins_half); @@ -808,7 +821,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items acquisition_message = 1; this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; } @@ -828,7 +841,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items d_active = false; d_state = 0; - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 2; this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h index 58cc608b0..c95a74b82 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h @@ -38,21 +38,21 @@ #ifndef GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_CC_H_ #define GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_CC_H_ +#include "gnss_synchro.h" +#include +#include +#include #include #include -#include -#include -#include -#include "gnss_synchro.h" class galileo_e5a_noncoherentIQ_acquisition_caf_cc; -typedef boost::shared_ptr galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr; +using galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr = boost::shared_ptr; galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, + unsigned int doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, @@ -74,7 +74,7 @@ private: galileo_e5a_noncoherentIQ_make_acquisition_caf_cc( unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, + unsigned int doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, @@ -86,7 +86,7 @@ private: galileo_e5a_noncoherentIQ_acquisition_caf_cc( unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, + unsigned int doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, @@ -99,8 +99,7 @@ private: int doppler_offset); float estimate_input_power(gr_complex* in); - long d_fs_in; - long d_freq; + int64_t d_fs_in; int d_samples_per_ms; int d_sampled_ms; int d_samples_per_code; @@ -112,7 +111,7 @@ private: unsigned int d_max_dwells; unsigned int d_well_count; unsigned int d_fft_size; - unsigned long int d_sample_counter; + uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; unsigned int d_num_doppler_bins; gr_complex* d_fft_code_I_A; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index a86b27c04..cb528d0b1 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -30,40 +30,47 @@ */ #include "galileo_pcps_8ms_acquisition_cc.h" -#include #include #include #include #include -#include "control_message_factory.h" +#include +#include +#include using google::LogMessage; galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) { return galileo_pcps_8ms_acquisition_cc_sptr( - new galileo_pcps_8ms_acquisition_cc(sampled_ms, max_dwells, doppler_max, freq, fs_in, samples_per_ms, - samples_per_code, dump, dump_filename)); + new galileo_pcps_8ms_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, + samples_per_code, dump, std::move(dump_filename))); } + galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) : gr::block("galileo_pcps_8ms_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms), gr::io_signature::make(0, 0, sizeof(gr_complex) * sampled_ms * samples_per_ms)) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; - d_freq = freq; d_fs_in = fs_in; d_samples_per_ms = samples_per_ms; d_samples_per_code = samples_per_code; @@ -88,24 +95,25 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); d_doppler_resolution = 0; d_threshold = 0; d_doppler_step = 0; - d_grid_doppler_wipeoffs = 0; - d_gnss_synchro = 0; + d_grid_doppler_wipeoffs = nullptr; + d_gnss_synchro = nullptr; d_code_phase = 0; d_doppler_freq = 0; d_test_statistics = 0; d_channel = 0; } + galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); } @@ -119,12 +127,24 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc() delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } + void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex *code) { // code A: two replicas of a primary code @@ -146,23 +166,24 @@ void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex *code) volk_32fc_conjugate_32fc(d_fft_code_B, d_fft_if->get_outbuf(), d_fft_size); } + void galileo_pcps_8ms_acquisition_cc::init() { d_gnss_synchro->Flag_valid_acquisition = false; d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; d_gnss_synchro->Flag_valid_word = false; - + d_gnss_synchro->Acq_doppler_step = 0U; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_mag = 0.0; d_input_power = 0.0; const double GALILEO_TWO_PI = 6.283185307179600; // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -170,11 +191,11 @@ void galileo_pcps_8ms_acquisition_cc::init() // Create the carrier Doppler wipeoff signals d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(GALILEO_TWO_PI) * (d_freq + doppler) / static_cast(d_fs_in); + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + float phase_step_rad = static_cast(GALILEO_TWO_PI) * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size); @@ -182,14 +203,15 @@ void galileo_pcps_8ms_acquisition_cc::init() } -void galileo_pcps_8ms_acquisition_cc::set_state(int state) +void galileo_pcps_8ms_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -209,7 +231,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) { - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL switch (d_state) { @@ -220,7 +242,8 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, //restart acquisition variables d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -229,7 +252,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, d_state = 1; } - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; @@ -238,19 +261,19 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, case 1: { // initialize acquisition algorithm - int doppler; + int32_t doppler; uint32_t indext = 0; uint32_t indext_A = 0; uint32_t indext_B = 0; float magt = 0.0; float magt_A = 0.0; float magt_B = 0.0; - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; - d_sample_counter += d_fft_size; // sample counter + d_sample_counter += static_cast(d_fft_size); // sample counter d_well_count++; @@ -266,10 +289,10 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -329,6 +352,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + d_gnss_synchro->Acq_doppler_step = d_doppler_step; } // Record results to file if required @@ -405,7 +429,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 2; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h index 62778ca06..0c1b81e20 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h @@ -32,22 +32,26 @@ #ifndef GNSS_SDR_PCPS_8MS_ACQUISITION_CC_H_ #define GNSS_SDR_PCPS_8MS_ACQUISITION_CC_H_ +#include "gnss_synchro.h" +#include +#include +#include #include #include -#include -#include -#include -#include "gnss_synchro.h" class galileo_pcps_8ms_acquisition_cc; -typedef boost::shared_ptr galileo_pcps_8ms_acquisition_cc_sptr; +using galileo_pcps_8ms_acquisition_cc_sptr = boost::shared_ptr; galileo_pcps_8ms_acquisition_cc_sptr -galileo_pcps_8ms_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); +galileo_pcps_8ms_make_acquisition_cc(uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); /*! * \brief This class implements a Parallel Code Phase Search Acquisition for @@ -57,42 +61,52 @@ class galileo_pcps_8ms_acquisition_cc : public gr::block { private: friend galileo_pcps_8ms_acquisition_cc_sptr - galileo_pcps_8ms_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); + galileo_pcps_8ms_make_acquisition_cc( + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); + galileo_pcps_8ms_acquisition_cc( + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); - galileo_pcps_8ms_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); + void calculate_magnitudes( + gr_complex* fft_begin, + int32_t doppler_shift, + int32_t doppler_offset); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); - - long d_fs_in; - long d_freq; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_fft_size; - unsigned long int d_sample_counter; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_max_dwells; + uint32_t d_well_count; + uint32_t d_fft_size; + uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_code_A; gr_complex* d_fft_code_B; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -100,9 +114,9 @@ private: float d_test_statistics; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -124,7 +138,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -155,13 +169,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -180,7 +194,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -189,7 +203,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 3513a41da..8a806c80f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -34,8 +34,10 @@ */ #include "pcps_acquisition.h" +#include "GLONASS_L1_L2_CA.h" // for GLONASS_TWO_PI #include "GPS_L1_CA.h" // for GPS_TWO_PI -#include "GLONASS_L1_L2_CA.h" // for GLONASS_TWO_PI" +#include "gnss_sdr_create_directory.h" +#include #include #include #include @@ -45,33 +47,43 @@ using google::LogMessage; -pcps_acquisition_sptr pcps_make_acquisition(pcpsconf_t conf_) +pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_) { return pcps_acquisition_sptr(new pcps_acquisition(conf_)); } -pcps_acquisition::pcps_acquisition(pcpsconf_t conf_) : gr::block("pcps_acquisition", - gr::io_signature::make(1, 1, conf_.it_size * conf_.sampled_ms * conf_.samples_per_ms * (conf_.bit_transition_flag ? 2 : 1)), - gr::io_signature::make(0, 0, conf_.it_size * conf_.sampled_ms * conf_.samples_per_ms * (conf_.bit_transition_flag ? 2 : 1))) +pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acquisition", + gr::io_signature::make(1, 1, conf_.it_size), + gr::io_signature::make(0, 0, conf_.it_size)) { this->message_port_register_out(pmt::mp("events")); acq_parameters = conf_; - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; + d_positive_acq = 0; d_state = 0; - d_old_freq = conf_.freq; - d_well_count = 0; - d_fft_size = acq_parameters.sampled_ms * acq_parameters.samples_per_ms; + d_old_freq = 0LL; + d_num_noncoherent_integrations_counter = 0U; + d_consumed_samples = acq_parameters.sampled_ms * acq_parameters.samples_per_ms * (acq_parameters.bit_transition_flag ? 2 : 1); + if (acq_parameters.sampled_ms == acq_parameters.ms_per_code) + { + d_fft_size = d_consumed_samples; + } + else + { + d_fft_size = d_consumed_samples * 2; + } + // d_fft_size = next power of two? //// d_mag = 0; d_input_power = 0.0; - d_num_doppler_bins = 0; + d_num_doppler_bins = 0U; d_threshold = 0.0; - d_doppler_step = 0; + d_doppler_step = 0U; d_doppler_center_step_two = 0.0; d_test_statistics = 0.0; - d_channel = 0; + d_channel = 0U; if (conf_.it_size == sizeof(gr_complex)) { d_cshort = false; @@ -93,12 +105,14 @@ pcps_acquisition::pcps_acquisition(pcpsconf_t conf_) : gr::block("pcps_acquisiti // size of the input buffer and padding the code with zeros. if (acq_parameters.bit_transition_flag) { - d_fft_size *= 2; - acq_parameters.max_dwells = 1; //Activation of acq_parameters.bit_transition_flag invalidates the value of acq_parameters.max_dwells + d_fft_size = d_consumed_samples * 2; + acq_parameters.max_dwells = 1; // Activation of acq_parameters.bit_transition_flag invalidates the value of acq_parameters.max_dwells } + d_tmp_buffer = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); d_fft_codes = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_magnitude = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); + d_input_signal = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // Direct FFT d_fft_if = new gr::fft::fft_complex(d_fft_size, true); @@ -106,37 +120,88 @@ pcps_acquisition::pcps_acquisition(pcpsconf_t conf_) : gr::block("pcps_acquisiti // Inverse FFT d_ifft = new gr::fft::fft_complex(d_fft_size, false); - d_gnss_synchro = 0; + d_gnss_synchro = nullptr; d_grid_doppler_wipeoffs = nullptr; d_grid_doppler_wipeoffs_step_two = nullptr; + d_magnitude_grid = nullptr; d_worker_active = false; - d_data_buffer = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_data_buffer = static_cast(volk_gnsssdr_malloc(d_consumed_samples * sizeof(gr_complex), volk_gnsssdr_get_alignment())); if (d_cshort) { - d_data_buffer_sc = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); + d_data_buffer_sc = static_cast(volk_gnsssdr_malloc(d_consumed_samples * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); } else { d_data_buffer_sc = nullptr; } grid_ = arma::fmat(); + narrow_grid_ = arma::fmat(); d_step_two = false; -} + d_num_doppler_bins_step2 = acq_parameters.num_doppler_bins_step2; + d_samplesPerChip = acq_parameters.samples_per_chip; + d_buffer_count = 0U; + // todo: CFAR statistic not available for non-coherent integration + if (acq_parameters.max_dwells == 1) + { + d_use_CFAR_algorithm_flag = acq_parameters.use_CFAR_algorithm_flag; + } + else + { + d_use_CFAR_algorithm_flag = false; + } + d_dump_number = 0LL; + d_dump_channel = acq_parameters.dump_channel; + d_dump = acq_parameters.dump; + d_dump_filename = acq_parameters.dump_filename; + if (d_dump) + { + std::string dump_path; + // Get path + if (d_dump_filename.find_last_of('/') != std::string::npos) + { + std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); + dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); + d_dump_filename = dump_filename_; + } + else + { + dump_path = std::string("."); + } + if (d_dump_filename.empty()) + { + d_dump_filename = "acquisition"; + } + // remove extension if any + if (d_dump_filename.substr(1).find_last_of('.') != std::string::npos) + { + d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); + } + d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + // create directory + if (!gnss_sdr_create_directory(dump_path)) + { + std::cerr << "GNSS-SDR cannot create dump file for the Acquisition block. Wrong permissions?" << std::endl; + d_dump = false; + } + } +} pcps_acquisition::~pcps_acquisition() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); + volk_gnsssdr_free(d_magnitude_grid[i]); } delete[] d_grid_doppler_wipeoffs; + delete[] d_magnitude_grid; } if (acq_parameters.make_2_steps) { - for (unsigned int i = 0; i < acq_parameters.num_doppler_bins_step2; i++) + for (uint32_t i = 0; i < d_num_doppler_bins_step2; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs_step_two[i]); } @@ -144,6 +209,8 @@ pcps_acquisition::~pcps_acquisition() } volk_gnsssdr_free(d_fft_codes); volk_gnsssdr_free(d_magnitude); + volk_gnsssdr_free(d_tmp_buffer); + volk_gnsssdr_free(d_input_signal); delete d_ifft; delete d_fft_if; volk_gnsssdr_free(d_data_buffer); @@ -154,10 +221,16 @@ pcps_acquisition::~pcps_acquisition() } +void pcps_acquisition::set_resampler_latency(uint32_t latency_samples) +{ + gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler + acq_parameters.resampler_latency_samples = latency_samples; +} + void pcps_acquisition::set_local_code(std::complex* code) { // reset the intermediate frequency - acq_parameters.freq = d_old_freq; + d_old_freq = 0LL; // This will check if it's fdma, if yes will update the intermediate frequency and the doppler grid if (is_fdma()) { @@ -170,13 +243,21 @@ void pcps_acquisition::set_local_code(std::complex* code) gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler if (acq_parameters.bit_transition_flag) { - int offset = d_fft_size / 2; + int32_t offset = d_fft_size / 2; std::fill_n(d_fft_if->get_inbuf(), offset, gr_complex(0.0, 0.0)); memcpy(d_fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * offset); } else { - memcpy(d_fft_if->get_inbuf(), code, sizeof(gr_complex) * d_fft_size); + if (acq_parameters.sampled_ms == acq_parameters.ms_per_code) + { + memcpy(d_fft_if->get_inbuf(), code, sizeof(gr_complex) * d_consumed_samples); + } + else + { + std::fill_n(d_fft_if->get_inbuf(), d_fft_size - d_consumed_samples, gr_complex(0.0, 0.0)); + memcpy(d_fft_if->get_inbuf() + d_consumed_samples, code, sizeof(gr_complex) * d_consumed_samples); + } } d_fft_if->execute(); // We need the FFT of local code @@ -189,28 +270,33 @@ bool pcps_acquisition::is_fdma() // Dealing with FDMA system if (strcmp(d_gnss_synchro->Signal, "1G") == 0) { - acq_parameters.freq += DFRQ1_GLO * GLONASS_PRN.at(d_gnss_synchro->PRN); - LOG(INFO) << "Trying to acquire SV PRN " << d_gnss_synchro->PRN << " with freq " << acq_parameters.freq << " in Glonass Channel " << GLONASS_PRN.at(d_gnss_synchro->PRN) << std::endl; + d_old_freq += DFRQ1_GLO * GLONASS_PRN.at(d_gnss_synchro->PRN); + LOG(INFO) << "Trying to acquire SV PRN " << d_gnss_synchro->PRN << " with freq " << d_old_freq << " in Glonass Channel " << GLONASS_PRN.at(d_gnss_synchro->PRN) << std::endl; return true; } - else if (strcmp(d_gnss_synchro->Signal, "2G") == 0) + if (strcmp(d_gnss_synchro->Signal, "2G") == 0) { - acq_parameters.freq += DFRQ2_GLO * GLONASS_PRN.at(d_gnss_synchro->PRN); - LOG(INFO) << "Trying to acquire SV PRN " << d_gnss_synchro->PRN << " with freq " << acq_parameters.freq << " in Glonass Channel " << GLONASS_PRN.at(d_gnss_synchro->PRN) << std::endl; + d_old_freq += DFRQ2_GLO * GLONASS_PRN.at(d_gnss_synchro->PRN); + LOG(INFO) << "Trying to acquire SV PRN " << d_gnss_synchro->PRN << " with freq " << d_old_freq << " in Glonass Channel " << GLONASS_PRN.at(d_gnss_synchro->PRN) << std::endl; return true; } - else - { - return false; - } + return false; } -void pcps_acquisition::update_local_carrier(gr_complex* carrier_vector, int correlator_length_samples, float freq) +void pcps_acquisition::update_local_carrier(gr_complex* carrier_vector, int32_t correlator_length_samples, float freq) { - float phase_step_rad = GPS_TWO_PI * freq / static_cast(acq_parameters.fs_in); + float phase_step_rad; + if (acq_parameters.use_automatic_resampler) + { + phase_step_rad = GPS_TWO_PI * freq / static_cast(acq_parameters.resampled_fs); + } + else + { + phase_step_rad = GPS_TWO_PI * freq / static_cast(acq_parameters.fs_in); + } float _phase[1]; - _phase[0] = 0; + _phase[0] = 0.0; volk_gnsssdr_s32f_sincos_32fc(carrier_vector, -phase_step_rad, _phase, correlator_length_samples); } @@ -221,60 +307,81 @@ void pcps_acquisition::init() d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; d_gnss_synchro->Flag_valid_word = false; - + d_gnss_synchro->Acq_doppler_step = 0U; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_mag = 0.0; d_input_power = 0.0; - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))); + d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))); // Create the carrier Doppler wipeoff signals - d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins]; - if (acq_parameters.make_2_steps) + if (d_grid_doppler_wipeoffs == nullptr) { - d_grid_doppler_wipeoffs_step_two = new gr_complex*[acq_parameters.num_doppler_bins_step2]; - for (unsigned int doppler_index = 0; doppler_index < acq_parameters.num_doppler_bins_step2; doppler_index++) + d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins]; + } + if (acq_parameters.make_2_steps && (d_grid_doppler_wipeoffs_step_two == nullptr)) + { + d_grid_doppler_wipeoffs_step_two = new gr_complex*[d_num_doppler_bins_step2]; + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins_step2; doppler_index++) { d_grid_doppler_wipeoffs_step_two[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); } } - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + + if (d_magnitude_grid == nullptr) { - d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; - update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, acq_parameters.freq + doppler); + d_magnitude_grid = new float*[d_num_doppler_bins]; + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_magnitude_grid[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); + } } + + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + for (uint32_t k = 0; k < d_fft_size; k++) + { + d_magnitude_grid[doppler_index][k] = 0.0; + } + int32_t doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; + update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, d_old_freq + doppler); + } + d_worker_active = false; - if (acq_parameters.dump) + if (d_dump) { - unsigned int effective_fft_size = (acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); + uint32_t effective_fft_size = (acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); grid_ = arma::fmat(effective_fft_size, d_num_doppler_bins, arma::fill::zeros); + narrow_grid_ = arma::fmat(effective_fft_size, d_num_doppler_bins_step2, arma::fill::zeros); } } void pcps_acquisition::update_grid_doppler_wipeoffs() { - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - int doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; - update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, acq_parameters.freq + doppler); + int32_t doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; + update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, d_old_freq + doppler); } } + void pcps_acquisition::update_grid_doppler_wipeoffs_step2() { - for (unsigned int doppler_index = 0; doppler_index < acq_parameters.num_doppler_bins_step2; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins_step2; doppler_index++) { - float doppler = (static_cast(doppler_index) - static_cast(acq_parameters.num_doppler_bins_step2) / 2.0) * acq_parameters.doppler_step2; + float doppler = (static_cast(doppler_index) - static_cast(floor(d_num_doppler_bins_step2 / 2.0))) * acq_parameters.doppler_step2; update_local_carrier(d_grid_doppler_wipeoffs_step_two[doppler_index], d_fft_size, d_doppler_center_step_two + doppler); } } -void pcps_acquisition::set_state(int state) + +void pcps_acquisition::set_state(int32_t state) { gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler d_state = state; @@ -282,8 +389,8 @@ void pcps_acquisition::set_state(int state) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; - d_well_count = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; @@ -301,8 +408,8 @@ void pcps_acquisition::set_state(int state) void pcps_acquisition::send_positive_acquisition() { - // 6.1- Declare positive acquisition using a message port - //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + // Declare positive acquisition using a message port + // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL DLOG(INFO) << "positive acquisition" << ", satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << ", sample_stamp " << d_sample_counter @@ -312,15 +419,15 @@ void pcps_acquisition::send_positive_acquisition() << ", doppler " << d_gnss_synchro->Acq_doppler_hz << ", magnitude " << d_mag << ", input signal power " << d_input_power; - + d_positive_acq = 1; this->message_port_pub(pmt::mp("events"), pmt::from_long(1)); } void pcps_acquisition::send_negative_acquisition() { - // 6.2- Declare negative acquisition using a message port - //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + // Declare negative acquisition using a message port + // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL DLOG(INFO) << "negative acquisition" << ", satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << ", sample_stamp " << d_sample_counter @@ -330,162 +437,327 @@ void pcps_acquisition::send_negative_acquisition() << ", doppler " << d_gnss_synchro->Acq_doppler_hz << ", magnitude " << d_mag << ", input signal power " << d_input_power; - + d_positive_acq = 0; this->message_port_pub(pmt::mp("events"), pmt::from_long(2)); } -void pcps_acquisition::acquisition_core(unsigned long int samp_count) +void pcps_acquisition::dump_results(int32_t effective_fft_size) +{ + d_dump_number++; + std::string filename = d_dump_filename; + filename.append("_"); + filename.append(1, d_gnss_synchro->System); + filename.append("_"); + filename.append(1, d_gnss_synchro->Signal[0]); + filename.append(1, d_gnss_synchro->Signal[1]); + filename.append("_ch_"); + filename.append(std::to_string(d_channel)); + filename.append("_"); + filename.append(std::to_string(d_dump_number)); + filename.append("_sat_"); + filename.append(std::to_string(d_gnss_synchro->PRN)); + filename.append(".mat"); + + mat_t* matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (matfp == nullptr) + { + std::cout << "Unable to create or open Acquisition dump file" << std::endl; + //acq_parameters.dump = false; + } + else + { + size_t dims[2] = {static_cast(effective_fft_size), static_cast(d_num_doppler_bins)}; + matvar_t* matvar = Mat_VarCreate("acq_grid", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, grid_.memptr(), 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + dims[0] = static_cast(1); + dims[1] = static_cast(1); + matvar = Mat_VarCreate("doppler_max", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &acq_parameters.doppler_max, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("doppler_step", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_doppler_step, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("d_positive_acq", MAT_C_INT32, MAT_T_INT32, 1, dims, &d_positive_acq, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + auto aux = static_cast(d_gnss_synchro->Acq_doppler_hz); + matvar = Mat_VarCreate("acq_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + aux = static_cast(d_gnss_synchro->Acq_delay_samples); + matvar = Mat_VarCreate("acq_delay_samples", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("test_statistic", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_test_statistics, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("threshold", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_threshold, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("input_power", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_input_power, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("sample_counter", MAT_C_UINT64, MAT_T_UINT64, 1, dims, &d_sample_counter, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_gnss_synchro->PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("num_dwells", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_num_noncoherent_integrations_counter, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + if (acq_parameters.make_2_steps) + { + dims[0] = static_cast(effective_fft_size); + dims[1] = static_cast(d_num_doppler_bins_step2); + matvar = Mat_VarCreate("acq_grid_narrow", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, narrow_grid_.memptr(), 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + dims[0] = static_cast(1); + dims[1] = static_cast(1); + matvar = Mat_VarCreate("doppler_step_narrow", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &acq_parameters.doppler_step2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + aux = d_doppler_center_step_two - static_cast(floor(d_num_doppler_bins_step2 / 2.0)) * acq_parameters.doppler_step2; + matvar = Mat_VarCreate("doppler_grid_narrow_min", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + + Mat_Close(matfp); + } +} + + +float pcps_acquisition::max_to_input_power_statistic(uint32_t& indext, int32_t& doppler, float input_power, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step) +{ + float grid_maximum = 0.0; + uint32_t index_doppler = 0U; + uint32_t tmp_intex_t = 0U; + uint32_t index_time = 0U; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); + + // Find the correlation peak and the carrier frequency + for (uint32_t i = 0; i < num_doppler_bins; i++) + { + volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_magnitude_grid[i], d_fft_size); + if (d_magnitude_grid[i][tmp_intex_t] > grid_maximum) + { + grid_maximum = d_magnitude_grid[i][tmp_intex_t]; + index_doppler = i; + index_time = tmp_intex_t; + } + } + indext = index_time; + if (!d_step_two) + { + doppler = -static_cast(doppler_max) + doppler_step * static_cast(index_doppler); + } + else + { + doppler = static_cast(d_doppler_center_step_two + (static_cast(index_doppler) - static_cast(floor(d_num_doppler_bins_step2 / 2.0))) * acq_parameters.doppler_step2); + } + + float magt = grid_maximum / (fft_normalization_factor * fft_normalization_factor); + return magt / input_power; +} + + +float pcps_acquisition::first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step) +{ + // Look for correlation peaks in the results + // Find the highest peak and compare it to the second highest peak + // The second peak is chosen not closer than 1 chip to the highest peak + + float firstPeak = 0.0; + uint32_t index_doppler = 0U; + uint32_t tmp_intex_t = 0U; + uint32_t index_time = 0U; + + // Find the correlation peak and the carrier frequency + for (uint32_t i = 0; i < num_doppler_bins; i++) + { + volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_magnitude_grid[i], d_fft_size); + if (d_magnitude_grid[i][tmp_intex_t] > firstPeak) + { + firstPeak = d_magnitude_grid[i][tmp_intex_t]; + index_doppler = i; + index_time = tmp_intex_t; + } + } + indext = index_time; + + if (!d_step_two) + { + doppler = -static_cast(doppler_max) + doppler_step * static_cast(index_doppler); + } + else + { + doppler = static_cast(d_doppler_center_step_two + (static_cast(index_doppler) - static_cast(floor(d_num_doppler_bins_step2 / 2.0))) * acq_parameters.doppler_step2); + } + + // Find 1 chip wide code phase exclude range around the peak + int32_t excludeRangeIndex1 = index_time - d_samplesPerChip; + int32_t excludeRangeIndex2 = index_time + d_samplesPerChip; + + // Correct code phase exclude range if the range includes array boundaries + if (excludeRangeIndex1 < 0) + { + excludeRangeIndex1 = d_fft_size + excludeRangeIndex1; + } + else if (excludeRangeIndex2 >= static_cast(d_fft_size)) + { + excludeRangeIndex2 = excludeRangeIndex2 - d_fft_size; + } + + int32_t idx = excludeRangeIndex1; + memcpy(d_tmp_buffer, d_magnitude_grid[index_doppler], d_fft_size); + do + { + d_tmp_buffer[idx] = 0.0; + idx++; + if (idx == static_cast(d_fft_size)) + { + idx = 0; + } + } + while (idx != excludeRangeIndex2); + + // Find the second highest correlation peak in the same freq. bin --- + volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_tmp_buffer, d_fft_size); + float secondPeak = d_tmp_buffer[tmp_intex_t]; + + // Compute the test statistics and compare to the threshold + return firstPeak / secondPeak; +} + + +void pcps_acquisition::acquisition_core(uint64_t samp_count) { gr::thread::scoped_lock lk(d_setlock); - // initialize acquisition algorithm - uint32_t indext = 0; - float magt = 0.0; - const gr_complex* in = d_data_buffer; //Get the input samples pointer - int effective_fft_size = (acq_parameters.bit_transition_flag ? d_fft_size / 2 : d_fft_size); + // Initialize acquisition algorithm + int32_t doppler = 0; + uint32_t indext = 0U; + int32_t effective_fft_size = (acq_parameters.bit_transition_flag ? d_fft_size / 2 : d_fft_size); if (d_cshort) { - volk_gnsssdr_16ic_convert_32fc(d_data_buffer, d_data_buffer_sc, d_fft_size); + volk_gnsssdr_16ic_convert_32fc(d_data_buffer, d_data_buffer_sc, d_consumed_samples); } - float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); + memcpy(d_input_signal, d_data_buffer, d_consumed_samples * sizeof(gr_complex)); + if (d_fft_size > d_consumed_samples) + { + for (uint32_t i = d_consumed_samples; i < d_fft_size; i++) + { + d_input_signal[i] = gr_complex(0.0, 0.0); + } + } + const gr_complex* in = d_input_signal; // Get the input samples pointer d_input_power = 0.0; d_mag = 0.0; - d_well_count++; + d_num_noncoherent_integrations_counter++; DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << samp_count << ", threshold: " << d_threshold << ", doppler_max: " << acq_parameters.doppler_max << ", doppler_step: " << d_doppler_step - << ", use_CFAR_algorithm_flag: " << (acq_parameters.use_CFAR_algorithm_flag ? "true" : "false"); + << ", use_CFAR_algorithm_flag: " << (d_use_CFAR_algorithm_flag ? "true" : "false"); lk.unlock(); - if (acq_parameters.use_CFAR_algorithm_flag) + + if (d_use_CFAR_algorithm_flag or acq_parameters.bit_transition_flag) { - // 1- (optional) Compute the input signal power estimation - volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); - volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size); + // Compute the input signal power estimation + volk_32fc_magnitude_squared_32f(d_tmp_buffer, in, d_fft_size); + volk_32f_accumulator_s32f(&d_input_power, d_tmp_buffer, d_fft_size); d_input_power /= static_cast(d_fft_size); } - // 2- Doppler frequency search loop + + // Doppler frequency grid loop if (!d_step_two) { - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - // doppler search steps - int doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; - + // Remove Doppler volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); - // 3- Perform the FFT-based convolution (parallel time search) + // Perform the FFT-based convolution (parallel time search) // Compute the FFT of the carrier wiped--off incoming signal d_fft_if->execute(); - // Multiply carrier wiped--off, Fourier transformed incoming signal - // with the local FFT'd code reference using SIMD operations with VOLK library + // Multiply carrier wiped--off, Fourier transformed incoming signal with the local FFT'd code reference volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), d_fft_if->get_outbuf(), d_fft_codes, d_fft_size); - // compute the inverse FFT + // Compute the inverse FFT d_ifft->execute(); - // Search maximum + // Compute squared magnitude (and accumulate in case of non-coherent integration) size_t offset = (acq_parameters.bit_transition_flag ? effective_fft_size : 0); - volk_32fc_magnitude_squared_32f(d_magnitude, d_ifft->get_outbuf() + offset, effective_fft_size); - volk_gnsssdr_32f_index_max_32u(&indext, d_magnitude, effective_fft_size); - magt = d_magnitude[indext]; - - if (acq_parameters.use_CFAR_algorithm_flag) + if (d_num_noncoherent_integrations_counter == 1) { - // Normalize the maximum value to correct the scale factor introduced by FFTW - magt = d_magnitude[indext] / (fft_normalization_factor * fft_normalization_factor); + volk_32fc_magnitude_squared_32f(d_magnitude_grid[doppler_index], d_ifft->get_outbuf() + offset, effective_fft_size); } - // 4- record the maximum peak and the associated synchronization parameters - if (d_mag < magt) + else { - d_mag = magt; - - if (!acq_parameters.use_CFAR_algorithm_flag) - { - // Search grid noise floor approximation for this doppler line - volk_32f_accumulator_s32f(&d_input_power, d_magnitude, effective_fft_size); - d_input_power = (d_input_power - d_mag) / (effective_fft_size - 1); - } - - // In case that acq_parameters.bit_transition_flag = true, we compare the potentially - // new maximum test statistics (d_mag/d_input_power) with the value in - // d_test_statistics. When the second dwell is being processed, the value - // of d_mag/d_input_power could be lower than d_test_statistics (i.e, - // the maximum test statistics in the previous dwell is greater than - // current d_mag/d_input_power). Note that d_test_statistics is not - // restarted between consecutive dwells in multidwell operation. - - if (d_test_statistics < (d_mag / d_input_power) or !acq_parameters.bit_transition_flag) - { - d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); - d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); - d_gnss_synchro->Acq_samplestamp_samples = samp_count; - - // 5- Compute the test statistics and compare to the threshold - //d_test_statistics = 2 * d_fft_size * d_mag / d_input_power; - d_test_statistics = d_mag / d_input_power; - } + volk_32fc_magnitude_squared_32f(d_tmp_buffer, d_ifft->get_outbuf() + offset, effective_fft_size); + volk_32f_x2_add_32f(d_magnitude_grid[doppler_index], d_magnitude_grid[doppler_index], d_tmp_buffer, effective_fft_size); } // Record results to file if required - if (acq_parameters.dump) + if (d_dump and d_channel == d_dump_channel) { - memcpy(grid_.colptr(doppler_index), d_magnitude, sizeof(float) * effective_fft_size); - if (doppler_index == (d_num_doppler_bins - 1)) - { - std::string filename = acq_parameters.dump_filename; - filename.append("_"); - filename.append(1, d_gnss_synchro->System); - filename.append("_"); - filename.append(1, d_gnss_synchro->Signal[0]); - filename.append(1, d_gnss_synchro->Signal[1]); - filename.append("_sat_"); - filename.append(std::to_string(d_gnss_synchro->PRN)); - filename.append(".mat"); - mat_t* matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (matfp == NULL) - { - std::cout << "Unable to create or open Acquisition dump file" << std::endl; - acq_parameters.dump = false; - } - else - { - size_t dims[2] = {static_cast(effective_fft_size), static_cast(d_num_doppler_bins)}; - matvar_t* matvar = Mat_VarCreate("grid", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, grid_.memptr(), 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - dims[0] = static_cast(1); - dims[1] = static_cast(1); - matvar = Mat_VarCreate("doppler_max", MAT_C_SINGLE, MAT_T_UINT32, 1, dims, &acq_parameters.doppler_max, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("doppler_step", MAT_C_SINGLE, MAT_T_UINT32, 1, dims, &d_doppler_step, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - Mat_Close(matfp); - } - } + memcpy(grid_.colptr(doppler_index), d_magnitude_grid[doppler_index], sizeof(float) * effective_fft_size); } } + + // Compute the test statistic + if (d_use_CFAR_algorithm_flag) + { + d_test_statistics = max_to_input_power_statistic(indext, doppler, d_input_power, d_num_doppler_bins, acq_parameters.doppler_max, d_doppler_step); + } + else + { + d_test_statistics = first_vs_second_peak_statistic(indext, doppler, d_num_doppler_bins, acq_parameters.doppler_max, d_doppler_step); + } + if (acq_parameters.use_automatic_resampler) + { + //take into account the acquisition resampler ratio + d_gnss_synchro->Acq_delay_samples = static_cast(std::fmod(static_cast(indext), acq_parameters.samples_per_code)) * acq_parameters.resampler_ratio; + d_gnss_synchro->Acq_delay_samples -= static_cast(acq_parameters.resampler_latency_samples); //account the resampler filter latency + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); + d_gnss_synchro->Acq_samplestamp_samples = rint(static_cast(samp_count) * acq_parameters.resampler_ratio); + } + else + { + d_gnss_synchro->Acq_delay_samples = static_cast(std::fmod(static_cast(indext), acq_parameters.samples_per_code)); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); + d_gnss_synchro->Acq_samplestamp_samples = samp_count; + } } else { - for (unsigned int doppler_index = 0; doppler_index < acq_parameters.num_doppler_bins_step2; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins_step2; doppler_index++) { - // doppler search steps - float doppler = d_doppler_center_step_two + (static_cast(doppler_index) - static_cast(acq_parameters.num_doppler_bins_step2) / 2.0) * acq_parameters.doppler_step2; - volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs_step_two[doppler_index], d_fft_size); - // 3- Perform the FFT-based convolution (parallel time search) + // Perform the FFT-based convolution (parallel time search) // Compute the FFT of the carrier wiped--off incoming signal d_fft_if->execute(); @@ -496,50 +768,50 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) // compute the inverse FFT d_ifft->execute(); - // Search maximum size_t offset = (acq_parameters.bit_transition_flag ? effective_fft_size : 0); - volk_32fc_magnitude_squared_32f(d_magnitude, d_ifft->get_outbuf() + offset, effective_fft_size); - volk_gnsssdr_32f_index_max_32u(&indext, d_magnitude, effective_fft_size); - magt = d_magnitude[indext]; - - if (acq_parameters.use_CFAR_algorithm_flag) + if (d_num_noncoherent_integrations_counter == 1) { - // Normalize the maximum value to correct the scale factor introduced by FFTW - magt = d_magnitude[indext] / (fft_normalization_factor * fft_normalization_factor); + volk_32fc_magnitude_squared_32f(d_magnitude_grid[doppler_index], d_ifft->get_outbuf() + offset, effective_fft_size); } - // 4- record the maximum peak and the associated synchronization parameters - if (d_mag < magt) + else { - d_mag = magt; - - if (!acq_parameters.use_CFAR_algorithm_flag) - { - // Search grid noise floor approximation for this doppler line - volk_32f_accumulator_s32f(&d_input_power, d_magnitude, effective_fft_size); - d_input_power = (d_input_power - d_mag) / (effective_fft_size - 1); - } - - // In case that acq_parameters.bit_transition_flag = true, we compare the potentially - // new maximum test statistics (d_mag/d_input_power) with the value in - // d_test_statistics. When the second dwell is being processed, the value - // of d_mag/d_input_power could be lower than d_test_statistics (i.e, - // the maximum test statistics in the previous dwell is greater than - // current d_mag/d_input_power). Note that d_test_statistics is not - // restarted between consecutive dwells in multidwell operation. - - if (d_test_statistics < (d_mag / d_input_power) or !acq_parameters.bit_transition_flag) - { - d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); - d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); - d_gnss_synchro->Acq_samplestamp_samples = samp_count; - - // 5- Compute the test statistics and compare to the threshold - //d_test_statistics = 2 * d_fft_size * d_mag / d_input_power; - d_test_statistics = d_mag / d_input_power; - } + volk_32fc_magnitude_squared_32f(d_tmp_buffer, d_ifft->get_outbuf() + offset, effective_fft_size); + volk_32f_x2_add_32f(d_magnitude_grid[doppler_index], d_magnitude_grid[doppler_index], d_tmp_buffer, effective_fft_size); + } + // Record results to file if required + if (d_dump and d_channel == d_dump_channel) + { + memcpy(narrow_grid_.colptr(doppler_index), d_magnitude_grid[doppler_index], sizeof(float) * effective_fft_size); } } + // Compute the test statistic + if (d_use_CFAR_algorithm_flag) + { + d_test_statistics = max_to_input_power_statistic(indext, doppler, d_input_power, d_num_doppler_bins_step2, static_cast(d_doppler_center_step_two - (static_cast(d_num_doppler_bins_step2) / 2.0) * acq_parameters.doppler_step2), acq_parameters.doppler_step2); + } + else + { + d_test_statistics = first_vs_second_peak_statistic(indext, doppler, d_num_doppler_bins_step2, static_cast(d_doppler_center_step_two - (static_cast(d_num_doppler_bins_step2) / 2.0) * acq_parameters.doppler_step2), acq_parameters.doppler_step2); + } + + if (acq_parameters.use_automatic_resampler) + { + //take into account the acquisition resampler ratio + d_gnss_synchro->Acq_delay_samples = static_cast(std::fmod(static_cast(indext), acq_parameters.samples_per_code)) * acq_parameters.resampler_ratio; + d_gnss_synchro->Acq_delay_samples -= static_cast(acq_parameters.resampler_latency_samples); //account the resampler filter latency + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); + d_gnss_synchro->Acq_samplestamp_samples = rint(static_cast(samp_count) * acq_parameters.resampler_ratio); + d_gnss_synchro->Acq_doppler_step = acq_parameters.doppler_step2; + } + else + { + d_gnss_synchro->Acq_delay_samples = static_cast(std::fmod(static_cast(indext), acq_parameters.samples_per_code)); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); + d_gnss_synchro->Acq_samplestamp_samples = samp_count; + d_gnss_synchro->Acq_doppler_step = acq_parameters.doppler_step2; + } } + lk.lock(); if (!acq_parameters.bit_transition_flag) { @@ -557,6 +829,8 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) else { d_step_two = true; // Clear input buffer and make small grid acquisition + d_num_noncoherent_integrations_counter = 0; + d_positive_acq = 0; d_state = 0; } } @@ -566,12 +840,21 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) d_state = 0; // Positive acquisition } } - else if (d_well_count == acq_parameters.max_dwells) + else { + d_buffer_count = 0; + d_state = 1; + } + + if (d_num_noncoherent_integrations_counter == acq_parameters.max_dwells) + { + if (d_state != 0) + { + send_negative_acquisition(); + } d_state = 0; d_active = false; d_step_two = false; - send_negative_acquisition(); } } else @@ -590,6 +873,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) else { d_step_two = true; // Clear input buffer and make small grid acquisition + d_num_noncoherent_integrations_counter = 0U; d_state = 0; } } @@ -607,8 +891,33 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) } } d_worker_active = false; + + if ((d_num_noncoherent_integrations_counter == acq_parameters.max_dwells) or (d_positive_acq == 1)) + { + // Record results to file if required + if (d_dump and d_channel == d_dump_channel) + { + pcps_acquisition::dump_results(effective_fft_size); + } + d_num_noncoherent_integrations_counter = 0U; + d_positive_acq = 0; + // Reset grid + for (uint32_t i = 0; i < d_num_doppler_bins; i++) + { + for (uint32_t k = 0; k < d_fft_size; k++) + { + d_magnitude_grid[i][k] = 0.0; + } + } + } } +// Called by gnuradio to enable drivers, etc for i/o devices. +bool pcps_acquisition::start() +{ + d_sample_counter = 0ULL; + return true; +} int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, @@ -624,12 +933,14 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), * 5. Compute the test statistics and compare to the threshold * 6. Declare positive or negative acquisition using a message port */ - gr::thread::scoped_lock lk(d_setlock); if (!d_active or d_worker_active) { - d_sample_counter += d_fft_size * ninput_items[0]; - consume_each(ninput_items[0]); + if (!acq_parameters.blocking_on_standby) + { + d_sample_counter += static_cast(ninput_items[0]); + consume_each(ninput_items[0]); + } if (d_step_two) { d_doppler_center_step_two = static_cast(d_gnss_synchro->Acq_doppler_hz); @@ -644,31 +955,66 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), { case 0: { - //restart acquisition variables + // Restart acquisition variables d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; - d_well_count = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; d_state = 1; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter - consume_each(ninput_items[0]); + d_buffer_count = 0U; + if (!acq_parameters.blocking_on_standby) + { + d_sample_counter += static_cast(ninput_items[0]); // sample counter + consume_each(ninput_items[0]); + } break; } - case 1: { - // Copy the data to the core and let it know that new data is available + uint32_t buff_increment; if (d_cshort) { - memcpy(d_data_buffer_sc, input_items[0], d_fft_size * sizeof(lv_16sc_t)); + const auto* in = reinterpret_cast(input_items[0]); // Get the input samples pointer + if ((ninput_items[0] + d_buffer_count) <= d_consumed_samples) + { + buff_increment = ninput_items[0]; + } + else + { + buff_increment = d_consumed_samples - d_buffer_count; + } + memcpy(&d_data_buffer_sc[d_buffer_count], in, sizeof(lv_16sc_t) * buff_increment); } else { - memcpy(d_data_buffer, input_items[0], d_fft_size * sizeof(gr_complex)); + const auto* in = reinterpret_cast(input_items[0]); // Get the input samples pointer + if ((ninput_items[0] + d_buffer_count) <= d_consumed_samples) + { + buff_increment = ninput_items[0]; + } + else + { + buff_increment = d_consumed_samples - d_buffer_count; + } + memcpy(&d_data_buffer[d_buffer_count], in, sizeof(gr_complex) * buff_increment); } + + // If buffer will be full in next iteration + if (d_buffer_count >= d_consumed_samples) + { + d_state = 2; + } + d_buffer_count += buff_increment; + d_sample_counter += static_cast(buff_increment); + consume_each(buff_increment); + break; + } + case 2: + { + // Copy the data to the core and let it know that new data is available if (acq_parameters.blocking) { lk.unlock(); @@ -679,8 +1025,8 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), gr::thread::thread d_worker(&pcps_acquisition::acquisition_core, this, d_sample_counter); d_worker_active = true; } - d_sample_counter += d_fft_size; - consume_each(1); + consume_each(0); + d_buffer_count = 0U; break; } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h index e16edd83f..0447dd308 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h @@ -52,6 +52,7 @@ #ifndef GNSS_SDR_PCPS_ACQUISITION_H_ #define GNSS_SDR_PCPS_ACQUISITION_H_ +#include "acq_conf.h" #include "gnss_synchro.h" #include #include @@ -59,33 +60,13 @@ #include #include -typedef struct -{ - /* pcps acquisition configuration */ - unsigned int sampled_ms; - unsigned int max_dwells; - unsigned int doppler_max; - unsigned int num_doppler_bins_step2; - float doppler_step2; - long freq; - long fs_in; - int samples_per_ms; - int samples_per_code; - bool bit_transition_flag; - bool use_CFAR_algorithm_flag; - bool dump; - bool blocking; - bool make_2_steps; - std::string dump_filename; - size_t it_size; -} pcpsconf_t; class pcps_acquisition; -typedef boost::shared_ptr pcps_acquisition_sptr; +using pcps_acquisition_sptr = boost::shared_ptr; pcps_acquisition_sptr -pcps_make_acquisition(pcpsconf_t conf_); +pcps_make_acquisition(const Acq_Conf& conf_); /*! * \brief This class implements a Parallel Code Phase Search Acquisition. @@ -97,40 +78,55 @@ class pcps_acquisition : public gr::block { private: friend pcps_acquisition_sptr - pcps_make_acquisition(pcpsconf_t conf_); + pcps_make_acquisition(const Acq_Conf& conf_); - pcps_acquisition(pcpsconf_t conf_); + pcps_acquisition(const Acq_Conf& conf_); - void update_local_carrier(gr_complex* carrier_vector, int correlator_length_samples, float freq); + void update_local_carrier(gr_complex* carrier_vector, int32_t correlator_length_samples, float freq); void update_grid_doppler_wipeoffs(); void update_grid_doppler_wipeoffs_step2(); bool is_fdma(); - void acquisition_core(unsigned long int samp_count); + void acquisition_core(uint64_t samp_count); void send_negative_acquisition(); void send_positive_acquisition(); - pcpsconf_t acq_parameters; + void dump_results(int32_t effective_fft_size); + + float first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step); + float max_to_input_power_statistic(uint32_t& indext, int32_t& doppler, float input_power, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step); + + bool start(); + + + Acq_Conf acq_parameters; bool d_active; bool d_worker_active; bool d_cshort; bool d_step_two; + bool d_use_CFAR_algorithm_flag; + int32_t d_positive_acq; float d_threshold; float d_mag; float d_input_power; float d_test_statistics; float* d_magnitude; - long d_old_freq; - int d_state; - unsigned int d_channel; - unsigned int d_doppler_step; + float** d_magnitude_grid; + float* d_tmp_buffer; + gr_complex* d_input_signal; + uint32_t d_samplesPerChip; + int64_t d_old_freq; + int32_t d_state; + uint32_t d_channel; + uint32_t d_doppler_step; float d_doppler_center_step_two; - unsigned int d_well_count; - unsigned int d_fft_size; - unsigned int d_num_doppler_bins; - unsigned long int d_sample_counter; + uint32_t d_num_noncoherent_integrations_counter; + uint32_t d_fft_size; + uint32_t d_consumed_samples; + uint32_t d_num_doppler_bins; + uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; gr_complex** d_grid_doppler_wipeoffs_step_two; gr_complex* d_fft_codes; @@ -140,6 +136,13 @@ private: gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; arma::fmat grid_; + arma::fmat narrow_grid_; + uint32_t d_num_doppler_bins_step2; + int64_t d_dump_number; + uint32_t d_dump_channel; + uint32_t d_buffer_count; + bool d_dump; + std::string d_dump_filename; public: ~pcps_acquisition(); @@ -158,13 +161,13 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } /*! - * \brief Initializes acquisition algorithm. + * \brief Initializes acquisition algorithm and reserves memory. */ void init(); @@ -190,13 +193,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler d_channel = channel; @@ -217,7 +220,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler acq_parameters.doppler_max = doppler_max; @@ -227,12 +230,15 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler d_doppler_step = doppler_step; } + + void set_resampler_latency(uint32_t latency_samples); + /*! * \brief Parallel Code Phase Search Acquisition signal processing. */ diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index 90b96acbb..db21bbc2b 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -31,11 +31,13 @@ */ #include "pcps_acquisition_fine_doppler_cc.h" -#include "gps_sdr_signal_processing.h" -#include "control_message_factory.h" #include "GPS_L1_CA.h" +#include "gnss_sdr_create_directory.h" +#include "gps_sdr_signal_processing.h" +#include #include #include +#include #include #include #include // std::rotate, std::fill_n @@ -44,43 +46,36 @@ using google::LogMessage; -pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc( - int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min, long freq, - long fs_in, int samples_per_ms, bool dump, - std::string dump_filename) +pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf &conf_) { return pcps_acquisition_fine_doppler_cc_sptr( - new pcps_acquisition_fine_doppler_cc(max_dwells, sampled_ms, doppler_max, doppler_min, freq, - fs_in, samples_per_ms, dump, dump_filename)); + new pcps_acquisition_fine_doppler_cc(conf_)); } -pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc( - int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min, long freq, - long fs_in, int samples_per_ms, bool dump, - std::string dump_filename) : gr::block("pcps_acquisition_fine_doppler_cc", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(0, 0, sizeof(gr_complex))) +pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Conf &conf_) + : gr::block("pcps_acquisition_fine_doppler_cc", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(0, 0, sizeof(gr_complex))) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + acq_parameters = conf_; + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; - d_freq = freq; - d_fs_in = fs_in; - d_samples_per_ms = samples_per_ms; - d_sampled_ms = sampled_ms; - d_config_doppler_max = doppler_max; - d_config_doppler_min = doppler_min; - d_fft_size = d_sampled_ms * d_samples_per_ms; + d_fs_in = conf_.fs_in; + d_samples_per_ms = conf_.samples_per_ms; + d_config_doppler_max = conf_.doppler_max; + d_fft_size = d_samples_per_ms; // HS Acquisition - d_max_dwells = max_dwells; + d_max_dwells = conf_.max_dwells; d_gnuradio_forecast_samples = d_fft_size; - d_input_power = 0.0; d_state = 0; d_carrier = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_fft_codes = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_magnitude = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); + d_10_ms_buffer = static_cast(volk_gnsssdr_malloc(50 * d_samples_per_ms * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + // Direct FFT d_fft_if = new gr::fft::fft_complex(d_fft_size, true); @@ -88,36 +83,93 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc( d_ifft = new gr::fft::fft_complex(d_fft_size, false); // For dumping samples into a file - d_dump = dump; - d_dump_filename = dump_filename; + d_dump = conf_.dump; + d_dump_filename = conf_.dump_filename; - d_doppler_resolution = 0; + if (d_dump) + { + std::string dump_path; + // Get path + if (d_dump_filename.find_last_of('/') != std::string::npos) + { + std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); + dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); + d_dump_filename = dump_filename_; + } + else + { + dump_path = std::string("."); + } + if (d_dump_filename.empty()) + { + d_dump_filename = "acquisition"; + } + // remove extension if any + if (d_dump_filename.substr(1).find_last_of('.') != std::string::npos) + { + d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); + } + d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + // create directory + if (!gnss_sdr_create_directory(dump_path)) + { + std::cerr << "GNSS-SDR cannot create dump file for the Acquisition block. Wrong permissions?" << std::endl; + d_dump = false; + } + } + + d_n_samples_in_buffer = 0; d_threshold = 0; d_num_doppler_points = 0; d_doppler_step = 0; - d_grid_data = 0; - d_grid_doppler_wipeoffs = 0; - d_gnss_synchro = 0; + d_grid_data = nullptr; + d_grid_doppler_wipeoffs = nullptr; + d_gnss_synchro = nullptr; d_code_phase = 0; d_doppler_freq = 0; d_test_statistics = 0; d_well_count = 0; d_channel = 0; + d_positive_acq = 0; + d_dump_number = 0; + d_dump_channel = 0; // this implementation can only produce dumps in channel 0 + //todo: migrate config parameters to the unified acquisition config class } +// Finds next power of two +// for n. If n itself is a +// power of two then returns n +unsigned int pcps_acquisition_fine_doppler_cc::nextPowerOf2(unsigned int n) +{ + n--; + n |= n >> 1; + n |= n >> 2; + n |= n >> 4; + n |= n >> 8; + n |= n >> 16; + n++; + return n; +} + void pcps_acquisition_fine_doppler_cc::set_doppler_step(unsigned int doppler_step) { d_doppler_step = doppler_step; // Create the search grid array - d_num_doppler_points = floor(std::abs(d_config_doppler_max - d_config_doppler_min) / d_doppler_step); + d_num_doppler_points = floor(std::abs(2 * d_config_doppler_max) / d_doppler_step); d_grid_data = new float *[d_num_doppler_points]; for (int i = 0; i < d_num_doppler_points; i++) { d_grid_data[i] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); } + + if (d_dump) + { + grid_ = arma::fmat(d_fft_size, d_num_doppler_points, arma::fill::zeros); + } + update_carrier_wipeoff(); } @@ -139,12 +191,9 @@ pcps_acquisition_fine_doppler_cc::~pcps_acquisition_fine_doppler_cc() volk_gnsssdr_free(d_carrier); volk_gnsssdr_free(d_fft_codes); volk_gnsssdr_free(d_magnitude); + volk_gnsssdr_free(d_10_ms_buffer); delete d_ifft; delete d_fft_if; - if (d_dump) - { - d_dump_file.close(); - } free_grid_memory(); } @@ -164,11 +213,10 @@ void pcps_acquisition_fine_doppler_cc::init() d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; d_gnss_synchro->Flag_valid_word = false; - + d_gnss_synchro->Acq_doppler_step = 0U; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; - d_input_power = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_state = 0; } @@ -188,6 +236,7 @@ void pcps_acquisition_fine_doppler_cc::reset_grid() d_well_count = 0; for (int i = 0; i < d_num_doppler_points; i++) { + //todo: use memset here for (unsigned int j = 0; j < d_fft_size; j++) { d_grid_data[i][j] = 0.0; @@ -204,10 +253,10 @@ void pcps_acquisition_fine_doppler_cc::update_carrier_wipeoff() d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_points]; for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { - doppler_hz = d_config_doppler_min + d_doppler_step * doppler_index; + doppler_hz = d_doppler_step * doppler_index - d_config_doppler_max; // doppler search steps // compute the carrier doppler wipe-off signal and store it - phase_step_rad = static_cast(GPS_TWO_PI) * (d_freq + doppler_hz) / static_cast(d_fs_in); + phase_step_rad = static_cast(GPS_TWO_PI) * doppler_hz / static_cast(d_fs_in); d_grid_doppler_wipeoffs[doppler_index] = new gr_complex[d_fft_size]; float _phase[1]; _phase[0] = 0; @@ -216,51 +265,73 @@ void pcps_acquisition_fine_doppler_cc::update_carrier_wipeoff() } -double pcps_acquisition_fine_doppler_cc::search_maximum() +double pcps_acquisition_fine_doppler_cc::compute_CAF() { - float magt = 0.0; - float fft_normalization_factor; + float firstPeak = 0.0; int index_doppler = 0; uint32_t tmp_intex_t = 0; uint32_t index_time = 0; + // Look for correlation peaks in the results ============================== + // Find the highest peak and compare it to the second highest peak + // The second peak is chosen not closer than 1 chip to the highest peak + //--- Find the correlation peak and the carrier frequency -------------- for (int i = 0; i < d_num_doppler_points; i++) { volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_grid_data[i], d_fft_size); - if (d_grid_data[i][tmp_intex_t] > magt) + if (d_grid_data[i][tmp_intex_t] > firstPeak) { - magt = d_grid_data[i][tmp_intex_t]; - //std::cout<(d_fft_size) * static_cast(d_fft_size); - magt = magt / (fft_normalization_factor * fft_normalization_factor); + // -- - Find 1 chip wide code phase exclude range around the peak + uint32_t samplesPerChip = ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(this->d_fs_in)); + int32_t excludeRangeIndex1 = index_time - samplesPerChip; + int32_t excludeRangeIndex2 = index_time + samplesPerChip; + + // -- - Correct code phase exclude range if the range includes array boundaries + if (excludeRangeIndex1 < 0) + { + excludeRangeIndex1 = d_fft_size + excludeRangeIndex1; + } + else if (excludeRangeIndex2 >= static_cast(d_fft_size)) + { + excludeRangeIndex2 = excludeRangeIndex2 - d_fft_size; + } + + int32_t idx = excludeRangeIndex1; + do + { + d_grid_data[index_doppler][idx] = 0.0; + idx++; + if (idx == static_cast(d_fft_size)) + { + idx = 0; + } + } + while (idx != excludeRangeIndex2); + + //--- Find the second highest correlation peak in the same freq. bin --- + volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_grid_data[index_doppler], d_fft_size); + float secondPeak = d_grid_data[index_doppler][tmp_intex_t]; // 5- Compute the test statistics and compare to the threshold - d_test_statistics = magt / (d_input_power * std::sqrt(d_well_count)); + d_test_statistics = firstPeak / secondPeak; // 4- record the maximum peak and the associated synchronization parameters d_gnss_synchro->Acq_delay_samples = static_cast(index_time); - d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_doppler_step + d_config_doppler_min); + d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_doppler_step - d_config_doppler_max); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - - // Record results to file if required - if (d_dump) - { - std::stringstream filename; - std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write - filename.str(""); - filename << "../data/test_statistics_" << d_gnss_synchro->System - << "_" << d_gnss_synchro->Signal << "_sat_" - << d_gnss_synchro->PRN << "_doppler_" << d_gnss_synchro->Acq_doppler_hz << ".dat"; - d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary); - d_dump_file.write(reinterpret_cast(d_grid_data[index_doppler]), n); //write directly |abs(x)|^2 in this Doppler bin? - d_dump_file.close(); - } + d_gnss_synchro->Acq_doppler_step = d_doppler_step; return d_test_statistics; } @@ -268,7 +339,7 @@ double pcps_acquisition_fine_doppler_cc::search_maximum() float pcps_acquisition_fine_doppler_cc::estimate_input_power(gr_vector_const_void_star &input_items) { - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer // Compute the input signal power estimation float power = 0; volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); @@ -281,7 +352,7 @@ float pcps_acquisition_fine_doppler_cc::estimate_input_power(gr_vector_const_voi int pcps_acquisition_fine_doppler_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items) { // initialize acquisition algorithm - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN @@ -290,13 +361,14 @@ int pcps_acquisition_fine_doppler_cc::compute_and_accumulate_grid(gr_vector_cons << ", doppler_step: " << d_doppler_step; // 2- Doppler frequency search loop - float *p_tmp_vector = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); + auto *p_tmp_vector = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { // doppler search steps // Perform the carrier wipe-off volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); + // 3- Perform the FFT-based convolution (parallel time search) // Compute the FFT of the carrier wiped--off incoming signal d_fft_if->execute(); @@ -309,29 +381,38 @@ int pcps_acquisition_fine_doppler_cc::compute_and_accumulate_grid(gr_vector_cons d_ifft->execute(); // save the grid matrix delay file - volk_32fc_magnitude_squared_32f(p_tmp_vector, d_ifft->get_outbuf(), d_fft_size); - const float *old_vector = d_grid_data[doppler_index]; - volk_32f_x2_add_32f(d_grid_data[doppler_index], old_vector, p_tmp_vector, d_fft_size); + //accumulate grid values + volk_32f_x2_add_32f(d_grid_data[doppler_index], d_grid_data[doppler_index], p_tmp_vector, d_fft_size); } volk_gnsssdr_free(p_tmp_vector); return d_fft_size; + //debug + // std::cout << "iff=["; + // for (int n = 0; n < d_fft_size; n++) + // { + // std::cout << std::real(d_ifft->get_outbuf()[n]) << "+" << std::imag(d_ifft->get_outbuf()[n]) << "i,"; + // } + // std::cout << "]\n"; + // getchar(); } -int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star &input_items) +int pcps_acquisition_fine_doppler_cc::estimate_Doppler() { // Direct FFT - int zero_padding_factor = 2; - int fft_size_extended = d_fft_size * zero_padding_factor; - gr::fft::fft_complex *fft_operator = new gr::fft::fft_complex(fft_size_extended, true); - + int zero_padding_factor = 8; + int prn_replicas = 10; + int signal_samples = prn_replicas * d_fft_size; + //int fft_size_extended = nextPowerOf2(signal_samples * zero_padding_factor); + int fft_size_extended = signal_samples * zero_padding_factor; + auto *fft_operator = new gr::fft::fft_complex(fft_size_extended, true); //zero padding the entire vector std::fill_n(fft_operator->get_inbuf(), fft_size_extended, gr_complex(0.0, 0.0)); //1. generate local code aligned with the acquisition code phase estimation - gr_complex *code_replica = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + auto *code_replica = static_cast(volk_gnsssdr_malloc(signal_samples * sizeof(gr_complex), volk_gnsssdr_get_alignment())); gps_l1_ca_code_gen_complex_sampled(code_replica, d_gnss_synchro->PRN, d_fs_in, 0); @@ -343,16 +424,18 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star std::rotate(code_replica, code_replica + (d_fft_size - shift_index), code_replica + d_fft_size - 1); } + for (int n = 0; n < prn_replicas - 1; n++) + { + memcpy(&code_replica[(n + 1) * d_fft_size], code_replica, d_fft_size * sizeof(gr_complex)); + } //2. Perform code wipe-off - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer - - volk_32fc_x2_multiply_32fc(fft_operator->get_inbuf(), in, code_replica, d_fft_size); + volk_32fc_x2_multiply_32fc(fft_operator->get_inbuf(), d_10_ms_buffer, code_replica, signal_samples); // 3. Perform the FFT (zero padded!) fft_operator->execute(); // 4. Compute the magnitude and find the maximum - float *p_tmp_vector = static_cast(volk_gnsssdr_malloc(fft_size_extended * sizeof(float), volk_gnsssdr_get_alignment())); + auto *p_tmp_vector = static_cast(volk_gnsssdr_malloc(fft_size_extended * sizeof(float), volk_gnsssdr_get_alignment())); volk_32fc_magnitude_squared_32f(p_tmp_vector, fft_operator->get_outbuf(), fft_size_extended); @@ -361,8 +444,8 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star //case even int counter = 0; + auto *fftFreqBins = new float[fft_size_extended]; - float fftFreqBins[fft_size_extended]; std::fill_n(fftFreqBins, fft_size_extended, 0.0); for (int k = 0; k < (fft_size_extended / 2); k++) @@ -373,7 +456,7 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star for (int k = fft_size_extended / 2; k > 0; k--) { - fftFreqBins[counter] = ((-static_cast(d_fs_in) / 2) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); + fftFreqBins[counter] = ((-static_cast(d_fs_in) / 2.0) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); counter++; } @@ -381,50 +464,57 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star if (std::abs(fftFreqBins[tmp_index_freq] - d_gnss_synchro->Acq_doppler_hz) < 1000) { d_gnss_synchro->Acq_doppler_hz = static_cast(fftFreqBins[tmp_index_freq]); - //std::cout<<"FFT maximum present at "<PRN << ".dat"; - // d_dump_file.open(filename.str().c_str(), std::ios::out - // | std::ios::binary); - // d_dump_file.write(reinterpret_cast(code_replica), n); //write directly |abs(x)|^2 in this Doppler bin? - // d_dump_file.close(); - // - // filename.str(""); - // filename << "../data/signal_prn_" << d_gnss_synchro->PRN << ".dat"; - // d_dump_file.open(filename.str().c_str(), std::ios::out - // | std::ios::binary); - // d_dump_file.write(reinterpret_cast(in), n); //write directly |abs(x)|^2 in this Doppler bin? - // d_dump_file.close(); - // - // - // n = sizeof(float) * (fft_size_extended); - // filename.str(""); - // filename << "../data/fft_prn_" << d_gnss_synchro->PRN << ".dat"; - // d_dump_file.open(filename.str().c_str(), std::ios::out - // | std::ios::binary); - // d_dump_file.write(reinterpret_cast(p_tmp_vector), n); //write directly |abs(x)|^2 in this Doppler bin? - // d_dump_file.close(); } // free memory!! delete fft_operator; volk_gnsssdr_free(code_replica); volk_gnsssdr_free(p_tmp_vector); + delete[] fftFreqBins; return d_fft_size; } +// Called by gnuradio to enable drivers, etc for i/o devices. +bool pcps_acquisition_fine_doppler_cc::start() +{ + d_sample_counter = 0ULL; + return true; +} + + +void pcps_acquisition_fine_doppler_cc::set_state(int state) +{ + //gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler + d_state = state; + + if (d_state == 1) + { + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; + d_well_count = 0; + d_test_statistics = 0.0; + d_active = true; + reset_grid(); + } + else if (d_state == 0) + { + } + else + { + LOG(ERROR) << "State can only be set to 0 or 1"; + } +} + + int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) @@ -443,29 +533,36 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, * S5. Negative_Acq: Send message and stop acq -> S0 */ + int samples_remaining; switch (d_state) { case 0: // S0. StandBy - //DLOG(INFO) <<"S0"<(d_fft_size); // sample counter + consume_each(d_fft_size); + } break; case 1: // S1. ComputeGrid - //DLOG(INFO) <<"S1"<(input_items[0]), d_fft_size * sizeof(gr_complex)); + d_n_samples_in_buffer += d_fft_size; d_well_count++; if (d_well_count >= d_max_dwells) { d_state = 2; } + d_sample_counter += static_cast(d_fft_size); // sample counter + consume_each(d_fft_size); break; case 2: // Compute test statistics and decide - //DLOG(INFO) <<"S2"< d_threshold) { d_state = 3; //perform fine doppler estimation @@ -473,16 +570,34 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, else { d_state = 5; //negative acquisition + d_n_samples_in_buffer = 0; } + break; case 3: // Fine doppler estimation - //DLOG(INFO) <<"S3"< noutput_items) + { + memcpy(&d_10_ms_buffer[d_n_samples_in_buffer], reinterpret_cast(input_items[0]), noutput_items * sizeof(gr_complex)); + d_n_samples_in_buffer += noutput_items; + d_sample_counter += static_cast(noutput_items); // sample counter + consume_each(noutput_items); + } + else + { + if (samples_remaining > 0) + { + memcpy(&d_10_ms_buffer[d_n_samples_in_buffer], reinterpret_cast(input_items[0]), samples_remaining * sizeof(gr_complex)); + d_sample_counter += static_cast(samples_remaining); // sample counter + consume_each(samples_remaining); + } + estimate_Doppler(); //disabled in repo + d_n_samples_in_buffer = 0; + d_state = 4; + } break; case 4: // Positive_Acq - //DLOG(INFO) <<"S4"<System << " " << d_gnss_synchro->PRN; DLOG(INFO) << "sample_stamp " << d_sample_counter; @@ -490,15 +605,23 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; - DLOG(INFO) << "input signal power " << d_input_power; - + d_positive_acq = 1; d_active = false; + // Record results to file if required + if (d_dump and d_channel == d_dump_channel) + { + dump_results(d_fft_size); + } // Send message to channel port //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL this->message_port_pub(pmt::mp("events"), pmt::from_long(1)); d_state = 0; + if (!acq_parameters.blocking_on_standby) + { + d_sample_counter += static_cast(noutput_items); // sample counter + consume_each(noutput_items); + } break; case 5: // Negative_Acq - //DLOG(INFO) <<"S5"<System << " " << d_gnss_synchro->PRN; DLOG(INFO) << "sample_stamp " << d_sample_counter; @@ -506,20 +629,108 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; - DLOG(INFO) << "input signal power " << d_input_power; - + d_positive_acq = 0; d_active = false; + // Record results to file if required + if (d_dump and d_channel == d_dump_channel) + { + dump_results(d_fft_size); + } // Send message to channel port //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL this->message_port_pub(pmt::mp("events"), pmt::from_long(2)); d_state = 0; + if (!acq_parameters.blocking_on_standby) + { + d_sample_counter += static_cast(noutput_items); // sample counter + consume_each(noutput_items); + } break; default: d_state = 0; + if (!acq_parameters.blocking_on_standby) + { + d_sample_counter += static_cast(noutput_items); // sample counter + consume_each(noutput_items); + } break; } - - //DLOG(INFO)<<"d_sample_counter="<System); + filename.append("_"); + filename.append(1, d_gnss_synchro->Signal[0]); + filename.append(1, d_gnss_synchro->Signal[1]); + filename.append("_ch_"); + filename.append(std::to_string(d_channel)); + filename.append("_"); + filename.append(std::to_string(d_dump_number)); + filename.append("_sat_"); + filename.append(std::to_string(d_gnss_synchro->PRN)); + filename.append(".mat"); + + mat_t *matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (matfp == nullptr) + { + std::cout << "Unable to create or open Acquisition dump file" << std::endl; + d_dump = false; + } + else + { + size_t dims[2] = {static_cast(effective_fft_size), static_cast(d_num_doppler_points)}; + matvar_t *matvar = Mat_VarCreate("acq_grid", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, grid_.memptr(), 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + dims[0] = static_cast(1); + dims[1] = static_cast(1); + matvar = Mat_VarCreate("doppler_max", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_config_doppler_max, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("doppler_step", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_doppler_step, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("d_positive_acq", MAT_C_INT32, MAT_T_INT32, 1, dims, &d_positive_acq, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + auto aux = static_cast(d_gnss_synchro->Acq_doppler_hz); + matvar = Mat_VarCreate("acq_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + aux = static_cast(d_gnss_synchro->Acq_delay_samples); + matvar = Mat_VarCreate("acq_delay_samples", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("test_statistic", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_test_statistics, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("threshold", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_threshold, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + aux = 0.0; + matvar = Mat_VarCreate("input_power", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("sample_counter", MAT_C_UINT64, MAT_T_UINT64, 1, dims, &d_sample_counter, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_gnss_synchro->PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + Mat_Close(matfp); + } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h index 652250cac..e414c6611 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h @@ -1,8 +1,9 @@ /*! * \file pcps_acquisition_fine_doppler_acquisition_cc.h * \brief This class implements a Parallel Code Phase Search Acquisition with multi-dwells and fine Doppler estimation + * for GPS L1 C/A signal * - * Acquisition strategy (Kay Borre book + CFAR threshold). + * Acquisition strategy (Kay Borre book). *
            *
          1. Compute the input signal power estimation *
          2. Doppler serial search loop @@ -48,73 +49,59 @@ #ifndef GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H_ #define GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H_ +#include "acq_conf.h" #include "gnss_synchro.h" +#include #include -#include #include +#include +#include #include #include class pcps_acquisition_fine_doppler_cc; -typedef boost::shared_ptr - pcps_acquisition_fine_doppler_cc_sptr; +using pcps_acquisition_fine_doppler_cc_sptr = boost::shared_ptr; pcps_acquisition_fine_doppler_cc_sptr -pcps_make_acquisition_fine_doppler_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long freq, long fs_in, int samples_per_ms, - bool dump, std::string dump_filename); +pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_); /*! * \brief This class implements a Parallel Code Phase Search Acquisition. * - * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver", - * Algorithm 1, for a pseudocode description of this implementation. */ - class pcps_acquisition_fine_doppler_cc : public gr::block { private: friend pcps_acquisition_fine_doppler_cc_sptr - pcps_make_acquisition_fine_doppler_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long freq, long fs_in, - int samples_per_ms, bool dump, - std::string dump_filename); - - pcps_acquisition_fine_doppler_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long freq, long fs_in, - int samples_per_ms, bool dump, - std::string dump_filename); - - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_); + pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_); int compute_and_accumulate_grid(gr_vector_const_void_star& input_items); - int estimate_Doppler(gr_vector_const_void_star& input_items); + int estimate_Doppler(); float estimate_input_power(gr_vector_const_void_star& input_items); - double search_maximum(); + double compute_CAF(); void reset_grid(); void update_carrier_wipeoff(); void free_grid_memory(); + bool start(); - long d_fs_in; - long d_freq; + Acq_Conf acq_parameters; + int64_t d_fs_in; int d_samples_per_ms; int d_max_dwells; - unsigned int d_doppler_resolution; int d_gnuradio_forecast_samples; float d_threshold; std::string d_satellite_str; int d_config_doppler_max; - int d_config_doppler_min; int d_num_doppler_points; int d_doppler_step; - unsigned int d_sampled_ms; unsigned int d_fft_size; - unsigned long int d_sample_counter; + uint64_t d_sample_counter; gr_complex* d_carrier; gr_complex* d_fft_codes; + gr_complex* d_10_ms_buffer; float* d_magnitude; float** d_grid_data; @@ -125,17 +112,22 @@ private: Gnss_Synchro* d_gnss_synchro; unsigned int d_code_phase; float d_doppler_freq; - float d_input_power; float d_test_statistics; - std::ofstream d_dump_file; + int d_positive_acq; + int d_state; bool d_active; int d_well_count; + int d_n_samples_in_buffer; bool d_dump; unsigned int d_channel; std::string d_dump_filename; + arma ::fmat grid_; + int64_t d_dump_number; + unsigned int d_dump_channel; + public: /*! * \brief Default destructor. @@ -188,6 +180,7 @@ public: inline void set_channel(unsigned int channel) { d_channel = channel; + d_dump_channel = d_channel; } /*! @@ -215,6 +208,13 @@ public: */ void set_doppler_step(unsigned int doppler_step); + /*! + * \brief If set to 1, ensures that acquisition starts at the + * first available sample. + * \param state - int=1 forces start of acquisition + */ + void set_state(int state); + /*! * \brief Parallel Code Phase Search Acquisition signal processing. */ @@ -223,6 +223,14 @@ public: gr_vector_void_star& output_items); void forecast(int noutput_items, gr_vector_int& ninput_items_required); + + /*! + * \brief Obtains the next power of 2 greater or equal to the input parameter + * \param n - Integer value to obtain the next power of 2. + */ + unsigned int nextPowerOf2(unsigned int n); + + void dump_results(int effective_fft_size); }; #endif /* pcps_acquisition_fine_doppler_cc*/ diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 66d23ba16..8aed78c5a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -1,12 +1,8 @@ /*! * \file pcps_acquisition_fpga.cc - * \brief This class implements a Parallel Code Phase Search Acquisition in the FPGA - * - * Note: The CFAR algorithm is not implemented in the FPGA. - * Note 2: The bit transition flag is not implemented in the FPGA - * + * \brief This class implements a Parallel Code Phase Search Acquisition for the FPGA * \authors
              - *
            • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
            • Marc Majoral, 2019. mmajoral(at)cttc.es *
            • Javier Arribas, 2011. jarribas(at)cttc.es *
            • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
            • Marc Molina, 2013. marc.molina.pena@gmail.com @@ -15,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -38,16 +34,19 @@ * ------------------------------------------------------------------------- */ + #include "pcps_acquisition_fpga.h" #include #include +#include +#define AQ_DOWNSAMPLING_DELAY 40 // delay due to the downsampling filter in the acquisition using google::LogMessage; pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_) { - return pcps_acquisition_fpga_sptr(new pcps_acquisition_fpga(conf_)); + return pcps_acquisition_fpga_sptr(new pcps_acquisition_fpga(std::move(conf_))); } @@ -57,22 +56,27 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( { this->message_port_register_out(pmt::mp("events")); - acq_parameters = conf_; - d_sample_counter = 0; // SAMPLE COUNTER + acq_parameters = std::move(conf_); + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; - d_fft_size = acq_parameters.sampled_ms * acq_parameters.samples_per_ms; + d_fft_size = acq_parameters.samples_per_code; d_mag = 0; d_input_power = 0.0; - d_num_doppler_bins = 0; + d_num_doppler_bins = 0U; d_threshold = 0.0; - d_doppler_step = 0; + d_doppler_step = 0U; d_test_statistics = 0.0; - d_channel = 0; - d_gnss_synchro = 0; + d_channel = 0U; + d_gnss_synchro = nullptr; - acquisition_fpga = std::make_shared(acq_parameters.device_name, d_fft_size, acq_parameters.doppler_max, acq_parameters.samples_per_ms, - acq_parameters.fs_in, acq_parameters.freq, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); + d_downsampling_factor = acq_parameters.downsampling_factor; + d_select_queue_Fpga = acq_parameters.select_queue_Fpga; + + d_total_block_exp = acq_parameters.total_block_exp; + + acquisition_fpga = std::make_shared(acq_parameters.device_name, acq_parameters.code_length, acq_parameters.doppler_max, d_fft_size, + acq_parameters.fs_in, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes, acq_parameters.excludelimit); } @@ -99,13 +103,14 @@ void pcps_acquisition_fpga::init() d_gnss_synchro->Acq_samplestamp_samples = 0; d_mag = 0.0; d_input_power = 0.0; - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))); + + d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; acquisition_fpga->init(); } -void pcps_acquisition_fpga::set_state(int state) +void pcps_acquisition_fpga::set_state(int32_t state) { d_state = state; if (d_state == 1) @@ -113,7 +118,6 @@ void pcps_acquisition_fpga::set_state(int state) d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; d_gnss_synchro->Acq_samplestamp_samples = 0; - //d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; @@ -131,7 +135,7 @@ void pcps_acquisition_fpga::set_state(int state) void pcps_acquisition_fpga::send_positive_acquisition() { - // 6.1- Declare positive acquisition using a message port + // Declare positive acquisition using a message port //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL DLOG(INFO) << "positive acquisition" << ", satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN @@ -149,8 +153,7 @@ void pcps_acquisition_fpga::send_positive_acquisition() void pcps_acquisition_fpga::send_negative_acquisition() { - // 6.2- Declare negative acquisition using a message port - //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + // Declare negative acquisition using a message port DLOG(INFO) << "negative acquisition" << ", satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << ", sample_stamp " << d_sample_counter @@ -170,13 +173,16 @@ void pcps_acquisition_fpga::set_active(bool active) d_active = active; // initialize acquisition algorithm - uint32_t indext = 0; - float magt = 0.0; - float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); + uint32_t indext = 0U; + float firstpeak = 0.0; + float secondpeak = 0.0; + uint32_t total_block_exp; d_input_power = 0.0; d_mag = 0.0; + int32_t doppler; + DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " @@ -185,37 +191,53 @@ void pcps_acquisition_fpga::set_active(bool active) // no CFAR algorithm in the FPGA << ", use_CFAR_algorithm_flag: false"; - unsigned int initial_sample; - float input_power_all = 0.0; - float input_power_computed = 0.0; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + uint64_t initial_sample; + + acquisition_fpga->configure_acquisition(); + acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); + acquisition_fpga->write_local_code(); + acquisition_fpga->set_block_exp(d_total_block_exp); + acquisition_fpga->run_acquisition(); + acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); + + if (total_block_exp > d_total_block_exp) { - // doppler search steps - int doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; + // if the attenuation factor of the FPGA FFT-IFFT is smaller than the reference attenuation factor then we need to update the reference attenuation factor + std::cout << "changing blk exp..... d_total_block_exp = " << d_total_block_exp << " total_block_exp = " << total_block_exp << " chan = " << d_channel << std::endl; + d_total_block_exp = total_block_exp; + } - acquisition_fpga->set_phase_step(doppler_index); - acquisition_fpga->run_acquisition(); // runs acquisition and waits until it is finished - acquisition_fpga->read_acquisition_results(&indext, &magt, - &initial_sample, &d_input_power); - d_sample_counter = initial_sample; + doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); - if (d_mag < magt) + if (secondpeak > 0) + { + d_test_statistics = firstpeak / secondpeak; + } + else + { + d_test_statistics = 0.0; + } + + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); + d_sample_counter = initial_sample; + + if (d_select_queue_Fpga == 0) + { + if (d_downsampling_factor > 1) { - d_mag = magt; - - input_power_all = d_input_power / (d_fft_size - 1); - input_power_computed = (d_input_power - d_mag) / (d_fft_size - 1); - d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); - - d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); - d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); - d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - - d_test_statistics = (d_mag / d_input_power); //* correction_factor; + d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor * (indext)); + d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor * d_sample_counter - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition } - - // In the case of the FPGA the option of dumping the results of the acquisition to a file is not available - // because the IFFT vector is not available + else + { + d_gnss_synchro->Acq_delay_samples = static_cast(indext); + d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + } + } + else + { + d_gnss_synchro->Acq_delay_samples = static_cast(indext); + d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition } if (d_test_statistics > d_threshold) @@ -240,3 +262,14 @@ int pcps_acquisition_fpga::general_work(int noutput_items __attribute__((unused) // the general work is not used with the acquisition that uses the FPGA return noutput_items; } + +void pcps_acquisition_fpga::reset_acquisition(void) +{ + // this function triggers a HW reset of the FPGA PL. + acquisition_fpga->reset_acquisition(); +} + +void pcps_acquisition_fpga::read_fpga_total_scale_factor(uint32_t* total_scale_factor, uint32_t* fw_scale_factor) +{ + acquisition_fpga->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +} diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index 1ee9a773a..bdb83a257 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -1,26 +1,14 @@ /*! * \file pcps_acquisition_fpga.h - * \brief This class implements a Parallel Code Phase Search Acquisition in the FPGA. + * \brief This class implements a Parallel Code Phase Search Acquisition for the FPGA * - * Note: The CFAR algorithm is not implemented in the FPGA. - * Note 2: The bit transition flag is not implemented in the FPGA - * - * Acquisition strategy (Kay Borre book + CFAR threshold). - *
                - *
              1. Compute the input signal power estimation - *
              2. Doppler serial search loop - *
              3. Perform the FFT-based circular convolution (parallel time search) - *
              4. Record the maximum peak and the associated synchronization parameters - *
              5. Compute the test statistics and compare to the threshold - *
              6. Declare positive or negative acquisition using a message queue - *
              * * Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, * "A Software-Defined GPS and Galileo Receiver. A Single-Frequency * Approach", Birkhauser, 2007. pp 81-84 * * \authors
                - *
              • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
              • Marc Majoral, 2019. mmajoral(at)cttc.es *
              • Javier Arribas, 2011. jarribas(at)cttc.es *
              • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
              • Marc Molina, 2013. marc.molina.pena@gmail.com @@ -30,7 +18,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -64,16 +52,18 @@ typedef struct { /* pcps acquisition configuration */ - unsigned int sampled_ms; - unsigned int doppler_max; - long freq; - long fs_in; - int samples_per_ms; - int samples_per_code; - unsigned int select_queue_Fpga; + uint32_t sampled_ms; + uint32_t doppler_max; + int64_t fs_in; + int32_t samples_per_ms; + int32_t samples_per_code; + int32_t code_length; + uint32_t select_queue_Fpga; std::string device_name; lv_16sc_t* all_fft_codes; // memory that contains all the code ffts - + float downsampling_factor; + uint32_t total_block_exp; + uint32_t excludelimit; } pcpsconf_fpga_t; class pcps_acquisition_fpga; @@ -102,21 +92,30 @@ private: void send_positive_acquisition(); + float first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step); + pcpsconf_fpga_t acq_parameters; bool d_active; float d_threshold; float d_mag; float d_input_power; + uint32_t d_doppler_index; float d_test_statistics; - int d_state; - unsigned int d_channel; - unsigned int d_doppler_step; - unsigned int d_fft_size; - unsigned int d_num_doppler_bins; - unsigned long int d_sample_counter; + int32_t d_state; + uint32_t d_channel; + uint32_t d_doppler_step; + uint32_t d_fft_size; + uint32_t d_num_doppler_bins; + uint64_t d_sample_counter; Gnss_Synchro* d_gnss_synchro; std::shared_ptr acquisition_fpga; + float d_downsampling_factor; + uint32_t d_select_queue_Fpga; + + uint32_t d_total_block_exp; + + public: ~pcps_acquisition_fpga(); @@ -133,7 +132,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -154,7 +153,7 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Starts acquisition algorithm, turning from standby mode to @@ -167,7 +166,7 @@ public: * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -186,7 +185,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { acq_parameters.doppler_max = doppler_max; acquisition_fpga->set_doppler_max(doppler_max); @@ -196,7 +195,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; acquisition_fpga->set_doppler_step(doppler_step); @@ -208,6 +207,16 @@ public: int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); + + /*! + * \brief This funciton triggers a HW reset of the FPGA PL. + */ + void reset_acquisition(void); + + /*! + * \brief This funciton is only used for the unit tests + */ + void read_fpga_total_scale_factor(uint32_t* total_scale_factor, uint32_t* fw_scale_factor); }; #endif /* GNSS_SDR_PCPS_ACQUISITION_FPGA_H_*/ diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc index 78a82fd8c..bf7184488 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc @@ -31,42 +31,42 @@ */ #include "pcps_assisted_acquisition_cc.h" -#include +#include "GPS_L1_CA.h" +#include "concurrent_map.h" +#include "gps_acq_assist.h" #include #include #include #include -#include "concurrent_map.h" -#include "control_message_factory.h" -#include "gps_acq_assist.h" -#include "GPS_L1_CA.h" +#include +#include +#include -extern concurrent_map global_gps_acq_assist_map; +extern Concurrent_Map global_gps_acq_assist_map; using google::LogMessage; pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc( - int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min, long freq, - long fs_in, int samples_per_ms, bool dump, + int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min, + int64_t fs_in, int32_t samples_per_ms, bool dump, std::string dump_filename) { return pcps_assisted_acquisition_cc_sptr( - new pcps_assisted_acquisition_cc(max_dwells, sampled_ms, doppler_max, doppler_min, freq, - fs_in, samples_per_ms, dump, dump_filename)); + new pcps_assisted_acquisition_cc(max_dwells, sampled_ms, doppler_max, doppler_min, + fs_in, samples_per_ms, dump, std::move(dump_filename))); } pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( - int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min, long freq, - long fs_in, int samples_per_ms, bool dump, + int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min, + int64_t fs_in, int32_t samples_per_ms, bool dump, std::string dump_filename) : gr::block("pcps_assisted_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(0, 0, sizeof(gr_complex))) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; - d_freq = freq; d_fs_in = fs_in; d_samples_per_ms = samples_per_ms; d_sampled_ms = sampled_ms; @@ -90,7 +90,7 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); d_doppler_resolution = 0; d_threshold = 0; @@ -98,9 +98,9 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( d_doppler_min = 0; d_num_doppler_points = 0; d_doppler_step = 0; - d_grid_data = 0; - d_grid_doppler_wipeoffs = 0; - d_gnss_synchro = 0; + d_grid_data = nullptr; + d_grid_doppler_wipeoffs = nullptr; + d_gnss_synchro = nullptr; d_code_phase = 0; d_doppler_freq = 0; d_test_statistics = 0; @@ -109,7 +109,7 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( } -void pcps_assisted_acquisition_cc::set_doppler_step(unsigned int doppler_step) +void pcps_assisted_acquisition_cc::set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } @@ -117,7 +117,7 @@ void pcps_assisted_acquisition_cc::set_doppler_step(unsigned int doppler_step) void pcps_assisted_acquisition_cc::free_grid_memory() { - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { delete[] d_grid_data[i]; delete[] d_grid_doppler_wipeoffs[i]; @@ -132,9 +132,20 @@ pcps_assisted_acquisition_cc::~pcps_assisted_acquisition_cc() volk_gnsssdr_free(d_fft_codes); delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } @@ -151,10 +162,10 @@ void pcps_assisted_acquisition_cc::init() d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; d_gnss_synchro->Flag_valid_word = false; - + d_gnss_synchro->Acq_doppler_step = 0U; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_input_power = 0.0; d_state = 0; @@ -206,9 +217,9 @@ void pcps_assisted_acquisition_cc::get_assistance() void pcps_assisted_acquisition_cc::reset_grid() { d_well_count = 0; - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { - for (unsigned int j = 0; j < d_fft_size; j++) + for (uint32_t j = 0; j < d_fft_size; j++) { d_grid_data[i][j] = 0.0; } @@ -227,16 +238,16 @@ void pcps_assisted_acquisition_cc::redefine_grid() d_num_doppler_points = floor(std::abs(d_doppler_max - d_doppler_min) / d_doppler_step); d_grid_data = new float *[d_num_doppler_points]; - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { d_grid_data[i] = new float[d_fft_size]; } // create the carrier Doppler wipeoff signals - int doppler_hz; + int32_t doppler_hz; float phase_step_rad; d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_points]; - for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) + for (int32_t doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { doppler_hz = d_doppler_min + d_doppler_step * doppler_index; // doppler search steps @@ -254,11 +265,11 @@ double pcps_assisted_acquisition_cc::search_maximum() { float magt = 0.0; float fft_normalization_factor; - int index_doppler = 0; + int32_t index_doppler = 0; uint32_t tmp_intex_t = 0; uint32_t index_time = 0; - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_grid_data[i], d_fft_size); if (d_grid_data[i][tmp_intex_t] > magt) @@ -280,6 +291,7 @@ double pcps_assisted_acquisition_cc::search_maximum() d_gnss_synchro->Acq_delay_samples = static_cast(index_time); d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_doppler_step + d_doppler_min); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + d_gnss_synchro->Acq_doppler_step = d_doppler_step; // Record results to file if required if (d_dump) @@ -301,9 +313,9 @@ double pcps_assisted_acquisition_cc::search_maximum() float pcps_assisted_acquisition_cc::estimate_input_power(gr_vector_const_void_star &input_items) { - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer // 1- Compute the input signal power estimation - float *p_tmp_vector = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); + auto *p_tmp_vector = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); volk_32fc_magnitude_squared_32f(p_tmp_vector, in, d_fft_size); @@ -315,10 +327,10 @@ float pcps_assisted_acquisition_cc::estimate_input_power(gr_vector_const_void_st } -int pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items) +int32_t pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items) { // initialize acquisition algorithm - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " @@ -328,9 +340,9 @@ int pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_vo << ", doppler_step: " << d_doppler_step; // 2- Doppler frequency search loop - float *p_tmp_vector = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); + auto *p_tmp_vector = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); - for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) + for (int32_t doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { // doppler search steps // Perform the carrier wipe-off @@ -380,27 +392,30 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, switch (d_state) { case 0: // S0. StandBy - if (d_active == true) d_state = 1; - d_sample_counter += ninput_items[0]; // sample counter + if (d_active == true) + { + d_state = 1; + } + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; case 1: // S1. GetAssist get_assistance(); redefine_grid(); reset_grid(); - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); d_state = 2; break; case 2: // S2. ComputeGrid - int consumed_samples; + int32_t consumed_samples; consumed_samples = compute_and_accumulate_grid(input_items); d_well_count++; if (d_well_count >= d_max_dwells) { d_state = 3; } - d_sample_counter += consumed_samples; + d_sample_counter += static_cast(consumed_samples); consume_each(consumed_samples); break; case 3: // Compute test statistics and decide @@ -423,14 +438,14 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, d_state = 6; } } - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; case 4: // RedefineGrid free_grid_memory(); redefine_grid(); reset_grid(); - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); d_state = 2; break; @@ -448,7 +463,7 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, this->message_port_pub(pmt::mp("events"), pmt::from_long(1)); free_grid_memory(); // consume samples to not block the GNU Radio flowgraph - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); d_state = 0; break; @@ -466,7 +481,7 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, this->message_port_pub(pmt::mp("events"), pmt::from_long(2)); free_grid_memory(); // consume samples to not block the GNU Radio flowgraph - d_sample_counter += ninput_items[0]; // sample counter + d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); d_state = 0; break; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h index 1b312980e..b27f920df 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h @@ -48,21 +48,25 @@ #ifndef GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H_ #define GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H_ +#include "gnss_synchro.h" +#include +#include +#include #include #include -#include -#include -#include -#include "gnss_synchro.h" class pcps_assisted_acquisition_cc; -typedef boost::shared_ptr - pcps_assisted_acquisition_cc_sptr; +using pcps_assisted_acquisition_cc_sptr = boost::shared_ptr; pcps_assisted_acquisition_cc_sptr -pcps_make_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long freq, long fs_in, int samples_per_ms, +pcps_make_assisted_acquisition_cc( + int32_t max_dwells, + uint32_t sampled_ms, + int32_t doppler_max, + int32_t doppler_min, + int64_t fs_in, + int32_t samples_per_ms, bool dump, std::string dump_filename); /*! @@ -75,20 +79,20 @@ class pcps_assisted_acquisition_cc : public gr::block { private: friend pcps_assisted_acquisition_cc_sptr - pcps_make_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long freq, long fs_in, - int samples_per_ms, bool dump, + pcps_make_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms, + int32_t doppler_max, int32_t doppler_min, int64_t fs_in, + int32_t samples_per_ms, bool dump, std::string dump_filename); - pcps_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long freq, long fs_in, - int samples_per_ms, bool dump, + pcps_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms, + int32_t doppler_max, int32_t doppler_min, int64_t fs_in, + int32_t samples_per_ms, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); - int compute_and_accumulate_grid(gr_vector_const_void_star& input_items); + int32_t compute_and_accumulate_grid(gr_vector_const_void_star& input_items); float estimate_input_power(gr_vector_const_void_star& input_items); double search_maximum(); void get_assistance(); @@ -96,24 +100,23 @@ private: void redefine_grid(); void free_grid_memory(); - long d_fs_in; - long d_freq; - int d_samples_per_ms; - int d_max_dwells; - unsigned int d_doppler_resolution; - int d_gnuradio_forecast_samples; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_max_dwells; + uint32_t d_doppler_resolution; + int32_t d_gnuradio_forecast_samples; float d_threshold; std::string d_satellite_str; - int d_doppler_max; - int d_doppler_min; - int d_config_doppler_max; - int d_config_doppler_min; + int32_t d_doppler_max; + int32_t d_doppler_min; + int32_t d_config_doppler_max; + int32_t d_config_doppler_min; - int d_num_doppler_points; - int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_fft_size; - unsigned long int d_sample_counter; + int32_t d_num_doppler_points; + int32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_fft_size; + uint64_t d_sample_counter; gr_complex* d_carrier; gr_complex* d_fft_codes; @@ -123,17 +126,17 @@ private: gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_input_power; float d_test_statistics; std::ofstream d_dump_file; - int d_state; + int32_t d_state; bool d_active; bool d_disable_assist; - int d_well_count; + int32_t d_well_count; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; @@ -156,7 +159,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_test_statistics; } @@ -186,7 +189,7 @@ public: * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -205,7 +208,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -214,7 +217,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - void set_doppler_step(unsigned int doppler_step); + void set_doppler_step(uint32_t doppler_step); /*! * \brief Parallel Code Phase Search Acquisition signal processing. diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index 8b7250e67..17082ae25 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -35,42 +35,48 @@ */ #include "pcps_cccwsr_acquisition_cc.h" -#include +#include "GPS_L1_CA.h" // GPS_TWO_PI #include #include #include #include -#include "control_message_factory.h" -#include "GPS_L1_CA.h" //GPS_TWO_PI - +#include +#include +#include using google::LogMessage; pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) { return pcps_cccwsr_acquisition_cc_sptr( - new pcps_cccwsr_acquisition_cc(sampled_ms, max_dwells, doppler_max, freq, fs_in, - samples_per_ms, samples_per_code, dump, dump_filename)); + new pcps_cccwsr_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, + samples_per_ms, samples_per_code, dump, std::move(dump_filename))); } + pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) : gr::block("pcps_cccwsr_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms), gr::io_signature::make(0, 0, sizeof(gr_complex) * sampled_ms * samples_per_ms)) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; - d_freq = freq; d_fs_in = fs_in; d_samples_per_ms = samples_per_ms; d_samples_per_code = samples_per_code; @@ -99,24 +105,25 @@ pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); d_doppler_resolution = 0; d_threshold = 0; d_doppler_step = 0; - d_grid_doppler_wipeoffs = 0; - d_gnss_synchro = 0; + d_grid_doppler_wipeoffs = nullptr; + d_gnss_synchro = nullptr; d_code_phase = 0; d_doppler_freq = 0; d_test_statistics = 0; d_channel = 0; } + pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); } @@ -134,12 +141,24 @@ pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc() delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } + void pcps_cccwsr_acquisition_cc::set_local_code(std::complex *code_data, std::complex *code_pilot) { @@ -160,23 +179,24 @@ void pcps_cccwsr_acquisition_cc::set_local_code(std::complex *code_data, volk_32fc_conjugate_32fc(d_fft_code_pilot, d_fft_if->get_outbuf(), d_fft_size); } + void pcps_cccwsr_acquisition_cc::init() { d_gnss_synchro->Flag_valid_acquisition = false; d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; d_gnss_synchro->Flag_valid_word = false; - + d_gnss_synchro->Acq_doppler_step = 0U; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_mag = 0.0; d_input_power = 0.0; // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -184,12 +204,12 @@ void pcps_cccwsr_acquisition_cc::init() // Create the carrier Doppler wipeoff signals d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + float phase_step_rad = GPS_TWO_PI * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size); @@ -197,14 +217,15 @@ void pcps_cccwsr_acquisition_cc::init() } -void pcps_cccwsr_acquisition_cc::set_state(int state) +void pcps_cccwsr_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -224,7 +245,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) { - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL switch (d_state) { @@ -235,7 +256,8 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, //restart acquisition variables d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -244,7 +266,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, d_state = 1; } - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; @@ -252,7 +274,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, case 1: { // initialize acquisition algorithm - int doppler; + int32_t doppler; uint32_t indext = 0; uint32_t indext_plus = 0; @@ -260,10 +282,10 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, float magt = 0.0; float magt_plus = 0.0; float magt_minus = 0.0; - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); - d_sample_counter += d_fft_size; // sample counter + d_sample_counter += static_cast(d_fft_size); // sample counter d_well_count++; @@ -279,11 +301,11 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -318,7 +340,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, // d_data_correlation. memcpy(d_pilot_correlation, d_ifft->get_outbuf(), sizeof(gr_complex) * d_fft_size); - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_correlation_plus[i] = std::complex( d_data_correlation[i].real() - d_pilot_correlation[i].imag(), @@ -355,6 +377,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + d_gnss_synchro->Acq_doppler_step = d_doppler_step; } // Record results to file if required @@ -407,7 +430,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 1; @@ -432,7 +455,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 2; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h index 46954e5ca..b1edf0106 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h @@ -37,23 +37,28 @@ #ifndef GNSS_SDR_PCPS_CCCWSR_ACQUISITION_CC_H_ #define GNSS_SDR_PCPS_CCCWSR_ACQUISITION_CC_H_ +#include "gnss_synchro.h" +#include +#include +#include #include #include -#include -#include -#include -#include "gnss_synchro.h" class pcps_cccwsr_acquisition_cc; -typedef boost::shared_ptr pcps_cccwsr_acquisition_cc_sptr; +using pcps_cccwsr_acquisition_cc_sptr = boost::shared_ptr; pcps_cccwsr_acquisition_cc_sptr -pcps_cccwsr_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); +pcps_cccwsr_make_acquisition_cc( + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); /*! * \brief This class implements a Parallel Code Phase Search Acquisition with @@ -63,41 +68,40 @@ class pcps_cccwsr_acquisition_cc : public gr::block { private: friend pcps_cccwsr_acquisition_cc_sptr - pcps_cccwsr_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_cccwsr_make_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool dump, std::string dump_filename); - pcps_cccwsr_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_cccwsr_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); - long d_fs_in; - long d_freq; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_fft_size; - unsigned long int d_sample_counter; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_max_dwells; + uint32_t d_well_count; + uint32_t d_fft_size; + uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_code_data; gr_complex* d_fft_code_pilot; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -109,9 +113,9 @@ private: float d_test_statistics; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -133,7 +137,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -165,13 +169,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -190,7 +194,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -199,7 +203,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc index af9413158..774022fb2 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc @@ -49,42 +49,42 @@ */ #include "pcps_opencl_acquisition_cc.h" -#include "control_message_factory.h" +#include "GPS_L1_CA.h" //GPS_TWO_PI #include "opencl/fft_base_kernels.h" #include "opencl/fft_internal.h" -#include "GPS_L1_CA.h" //GPS_TWO_PI #include #include #include #include #include +#include #include #include #include +#include using google::LogMessage; pcps_opencl_acquisition_cc_sptr pcps_make_opencl_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, + uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename) { return pcps_opencl_acquisition_cc_sptr( - new pcps_opencl_acquisition_cc(sampled_ms, max_dwells, doppler_max, freq, fs_in, samples_per_ms, - samples_per_code, bit_transition_flag, dump, dump_filename)); + new pcps_opencl_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, + samples_per_code, bit_transition_flag, dump, std::move(dump_filename))); } pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, - long freq, - long fs_in, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, @@ -94,11 +94,10 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( gr::io_signature::make(0, 0, sizeof(gr_complex) * sampled_ms * samples_per_ms)) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; d_core_working = false; - d_freq = freq; d_fs_in = fs_in; d_samples_per_ms = samples_per_ms; d_samples_per_code = samples_per_code; @@ -116,7 +115,7 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( d_cl_fft_batch_size = 1; d_in_buffer = new gr_complex *[d_max_dwells]; - for (unsigned int i = 0; i < d_max_dwells; i++) + for (uint32_t i = 0; i < d_max_dwells; i++) { d_in_buffer[i] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); } @@ -124,7 +123,7 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( d_fft_codes = static_cast(volk_gnsssdr_malloc(d_fft_size_pow2 * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_zero_vector = static_cast(volk_gnsssdr_malloc((d_fft_size_pow2 - d_fft_size) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (unsigned int i = 0; i < (d_fft_size_pow2 - d_fft_size); i++) + for (uint32_t i = 0; i < (d_fft_size_pow2 - d_fft_size); i++) { d_zero_vector[i] = gr_complex(0.0, 0.0); } @@ -142,7 +141,7 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); } @@ -150,14 +149,14 @@ pcps_opencl_acquisition_cc::~pcps_opencl_acquisition_cc() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); } delete[] d_grid_doppler_wipeoffs; } - for (unsigned int i = 0; i < d_max_dwells; i++) + for (uint32_t i = 0; i < d_max_dwells; i++) { volk_gnsssdr_free(d_in_buffer[i]); } @@ -188,14 +187,25 @@ pcps_opencl_acquisition_cc::~pcps_opencl_acquisition_cc() delete d_fft_if; } - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } -int pcps_opencl_acquisition_cc::init_opencl_environment(std::string kernel_filename) +int pcps_opencl_acquisition_cc::init_opencl_environment(const std::string &kernel_filename) { //get all platforms (drivers) std::vector all_platforms; @@ -292,10 +302,10 @@ void pcps_opencl_acquisition_cc::init() d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; d_gnss_synchro->Flag_valid_word = false; - + d_gnss_synchro->Acq_doppler_step = 0U; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_mag = 0.0; d_input_power = 0.0; @@ -315,12 +325,12 @@ void pcps_opencl_acquisition_cc::init() d_cl_buffer_grid_doppler_wipeoffs = new cl::Buffer *[d_num_doppler_bins]; } - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(GPS_TWO_PI) * (d_freq + doppler) / static_cast(d_fs_in); + float phase_step_rad = static_cast(GPS_TWO_PI) * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size); @@ -361,7 +371,7 @@ void pcps_opencl_acquisition_cc::set_local_code(std::complex *code) clFFT_ExecuteInterleaved((*d_cl_queue)(), d_cl_fft_plan, d_cl_fft_batch_size, clFFT_Forward, (*d_cl_buffer_2)(), (*d_cl_buffer_2)(), - 0, NULL, NULL); + 0, nullptr, nullptr); //Conjucate the local code cl::Kernel kernel = cl::Kernel(d_cl_program, "conj_vector"); @@ -389,7 +399,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() float magt = 0.0; float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); gr_complex *in = d_in_buffer[d_well_count]; - unsigned long int samplestamp = d_sample_counter_buffer[d_well_count]; + uint64_t samplestamp = d_sample_counter_buffer[d_well_count]; d_input_power = 0.0; d_mag = 0.0; @@ -408,7 +418,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; @@ -452,6 +462,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = samplestamp; + d_gnss_synchro->Acq_doppler_step = d_doppler_step; // 5- Compute the test statistics and compare to the threshold //d_test_statistics = 2 * d_fft_size * d_mag / d_input_power; @@ -512,7 +523,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() float magt = 0.0; float fft_normalization_factor = (static_cast(d_fft_size_pow2) * static_cast(d_fft_size)); //This works, but I am not sure why. gr_complex *in = d_in_buffer[d_well_count]; - unsigned long int samplestamp = d_sample_counter_buffer[d_well_count]; + uint64_t samplestamp = d_sample_counter_buffer[d_well_count]; d_input_power = 0.0; d_mag = 0.0; @@ -543,7 +554,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() cl::Kernel kernel; // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps @@ -563,7 +574,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() clFFT_ExecuteInterleaved((*d_cl_queue)(), d_cl_fft_plan, d_cl_fft_batch_size, clFFT_Forward, (*d_cl_buffer_1)(), (*d_cl_buffer_2)(), - 0, NULL, NULL); + 0, nullptr, nullptr); // Multiply carrier wiped--off, Fourier transformed incoming signal // with the local FFT'd code reference @@ -577,7 +588,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() // compute the inverse FFT clFFT_ExecuteInterleaved((*d_cl_queue)(), d_cl_fft_plan, d_cl_fft_batch_size, clFFT_Inverse, (*d_cl_buffer_2)(), (*d_cl_buffer_2)(), - 0, NULL, NULL); + 0, nullptr, nullptr); // Compute magnitude kernel = cl::Kernel(d_cl_program, "magnitude_squared"); @@ -615,6 +626,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = samplestamp; + d_gnss_synchro->Acq_doppler_step = d_doppler_step; // 5- Compute the test statistics and compare to the threshold //d_test_statistics = 2 * d_fft_size * d_mag / d_input_power; @@ -678,7 +690,8 @@ void pcps_opencl_acquisition_cc::set_state(int state) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -710,7 +723,8 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, //restart acquisition variables d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -721,7 +735,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, d_state = 1; } - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter break; } @@ -733,25 +747,25 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, // Fill internal buffer with d_max_dwells signal blocks. This step ensures that // consecutive signal blocks will be processed in multi-dwell operation. This is // essential when d_bit_transition_flag = true. - unsigned int num_dwells = std::min(static_cast(d_max_dwells - d_in_dwell_count), ninput_items[0]); - for (unsigned int i = 0; i < num_dwells; i++) + uint32_t num_dwells = std::min(static_cast(d_max_dwells - d_in_dwell_count), ninput_items[0]); + for (uint32_t i = 0; i < num_dwells; i++) { memcpy(d_in_buffer[d_in_dwell_count++], static_cast(input_items[i]), sizeof(gr_complex) * d_fft_size); - d_sample_counter += d_fft_size; + d_sample_counter += static_cast(d_fft_size); d_sample_counter_buffer.push_back(d_sample_counter); } if (ninput_items[0] > static_cast(num_dwells)) { - d_sample_counter += d_fft_size * (ninput_items[0] - num_dwells); + d_sample_counter += static_cast(d_fft_size * (ninput_items[0] - num_dwells)); } } else { // We already have d_max_dwells consecutive blocks in the internal buffer, // just skip input blocks. - d_sample_counter += d_fft_size * ninput_items[0]; + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); } // We create a new thread to process next block if the following @@ -795,7 +809,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter acquisition_message = 1; this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); @@ -819,7 +833,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter acquisition_message = 2; this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h index c4ce11707..20b53d082 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h @@ -54,8 +54,9 @@ #include "gnss_synchro.h" #include "opencl/fft_internal.h" #include -#include #include +#include +#include #include #include #include @@ -71,8 +72,8 @@ class pcps_opencl_acquisition_cc; typedef boost::shared_ptr pcps_opencl_acquisition_cc_sptr; pcps_opencl_acquisition_cc_sptr -pcps_make_opencl_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, +pcps_make_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, @@ -88,15 +89,15 @@ class pcps_opencl_acquisition_cc : public gr::block { private: friend pcps_opencl_acquisition_cc_sptr - pcps_make_opencl_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, + pcps_make_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename); - pcps_opencl_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, + pcps_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, int samples_per_ms, int samples_per_code, bool bit_transition_flag, bool dump, @@ -105,31 +106,30 @@ private: void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, int doppler_offset); - int init_opencl_environment(std::string kernel_filename); + int init_opencl_environment(const std::string& kernel_filename); - long d_fs_in; - long d_freq; + int64_t d_fs_in; int d_samples_per_ms; int d_samples_per_code; - unsigned int d_doppler_resolution; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_fft_size; - unsigned int d_fft_size_pow2; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_max_dwells; + uint32_t d_well_count; + uint32_t d_fft_size; + uint32_t d_fft_size_pow2; int* d_max_doppler_indexs; - unsigned long int d_sample_counter; + uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_codes; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -141,12 +141,12 @@ private: int d_state; bool d_core_working; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; gr_complex* d_zero_vector; gr_complex** d_in_buffer; - std::vector d_sample_counter_buffer; - unsigned int d_in_dwell_count; + std::vector d_sample_counter_buffer; + uint32_t d_in_dwell_count; cl::Platform d_cl_platform; cl::Device d_cl_device; @@ -183,7 +183,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -220,7 +220,7 @@ public: * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -239,7 +239,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -248,7 +248,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 17d06f62b..a55b352c9 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -29,23 +29,27 @@ */ #include "pcps_quicksync_acquisition_cc.h" -#include "control_message_factory.h" #include "GPS_L1_CA.h" -#include #include +#include #include #include #include +#include #include +#include using google::LogMessage; pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( - unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t folding_factor, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename) @@ -54,18 +58,18 @@ pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( new pcps_quicksync_acquisition_cc( folding_factor, sampled_ms, max_dwells, doppler_max, - freq, fs_in, samples_per_ms, + fs_in, samples_per_ms, samples_per_code, bit_transition_flag, - dump, dump_filename)); + dump, std::move(dump_filename))); } pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( - unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t folding_factor, + uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename) : gr::block("pcps_quicksync_acquisition_cc", @@ -73,10 +77,9 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( gr::io_signature::make(0, 0, (sizeof(gr_complex) * sampled_ms * samples_per_ms))) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; - d_freq = freq; d_fs_in = fs_in; d_samples_per_ms = samples_per_ms; d_samples_per_code = samples_per_code; @@ -97,7 +100,7 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( d_magnitude = static_cast(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(float), volk_gnsssdr_get_alignment())); d_magnitude_folded = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); - d_possible_delay = new unsigned int[d_folding_factor]; + d_possible_delay = new uint32_t[d_folding_factor]; d_corr_output_f = new float[d_folding_factor]; /*Create the d_code signal , which would store the values of the code in its @@ -111,18 +114,18 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); - d_corr_acumulator = 0; - d_signal_folded = 0; + d_corr_acumulator = nullptr; + d_signal_folded = nullptr; d_code_folded = new gr_complex[d_fft_size](); d_noise_floor_power = 0; d_doppler_resolution = 0; d_threshold = 0; d_doppler_step = 0; - d_grid_doppler_wipeoffs = 0; - d_fft_if2 = 0; - d_gnss_synchro = 0; + d_grid_doppler_wipeoffs = nullptr; + d_fft_if2 = nullptr; + d_gnss_synchro = nullptr; d_code_phase = 0; d_doppler_freq = 0; d_test_statistics = 0; @@ -138,7 +141,7 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc() //DLOG(INFO) << "START DESTROYER"; if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); } @@ -156,11 +159,21 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc() delete d_corr_output_f; delete[] d_code_folded; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure& e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; } - // DLOG(INFO) << "END DESTROYER"; } @@ -176,7 +189,7 @@ void pcps_quicksync_acquisition_cc::set_local_code(std::complex* code) /*perform folding of the code by the factorial factor parameter. Notice that folding of the code in the time stage would result in a downsampled spectrum in the frequency domain after applying the fftw operation*/ - for (unsigned int i = 0; i < d_folding_factor; i++) + for (uint32_t i = 0; i < d_folding_factor; i++) { std::transform((code + i * d_fft_size), (code + ((i + 1) * d_fft_size)), d_fft_if->get_inbuf(), d_fft_if->get_inbuf(), @@ -200,16 +213,20 @@ void pcps_quicksync_acquisition_cc::init() //DLOG(INFO) << "START init"; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_mag = 0.0; d_input_power = 0.0; - if (d_doppler_step == 0) d_doppler_step = 250; + if (d_doppler_step == 0) + { + d_doppler_step = 250; + } // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -217,11 +234,11 @@ void pcps_quicksync_acquisition_cc::init() // Create the carrier Doppler wipeoff signals d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + float phase_step_rad = GPS_TWO_PI * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_samples_per_code * d_folding_factor); @@ -230,19 +247,20 @@ void pcps_quicksync_acquisition_cc::init() } -void pcps_quicksync_acquisition_cc::set_state(int state) +void pcps_quicksync_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; - d_active = 1; + d_active = true; } else if (d_state == 0) { @@ -268,7 +286,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, * 6. Declare positive or negative acquisition using a message queue */ //DLOG(INFO) << "START GENERAL WORK"; - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL //std::cout<<"general_work in quicksync gnuradio block"<Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; @@ -289,7 +308,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_state = 1; } - d_sample_counter += d_sampled_ms * d_samples_per_ms * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_sampled_ms * d_samples_per_ms * ninput_items[0]); // sample counter consume_each(ninput_items[0]); //DLOG(INFO) << "END CASE 0"; break; @@ -299,21 +318,21 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, { /* initialize acquisition implementing the QuickSync algorithm*/ //DLOG(INFO) << "START CASE 1"; - int doppler; + int32_t doppler; uint32_t indext = 0; float magt = 0.0; - const gr_complex* in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto* in = reinterpret_cast(input_items[0]); //Get the input samples pointer - gr_complex* in_temp = static_cast(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - gr_complex* in_temp_folded = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + auto* in_temp = static_cast(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + auto* in_temp_folded = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); /*Create a signal to store a signal of size 1ms, to perform correlation in time. No folding on this data is required*/ - gr_complex* in_1code = static_cast(volk_gnsssdr_malloc(d_samples_per_code * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + auto* in_1code = static_cast(volk_gnsssdr_malloc(d_samples_per_code * sizeof(gr_complex), volk_gnsssdr_get_alignment())); /*Stores the values of the correlation output between the local code and the signal with doppler shift corrected */ - gr_complex* corr_output = static_cast(volk_gnsssdr_malloc(d_samples_per_code * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + auto* corr_output = static_cast(volk_gnsssdr_malloc(d_samples_per_code * sizeof(gr_complex), volk_gnsssdr_get_alignment())); /*Stores a copy of the folded version of the signal.This is used for the FFT operations in future steps of execution*/ @@ -325,7 +344,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_test_statistics = 0.0; d_noise_floor_power = 0.0; - d_sample_counter += d_sampled_ms * d_samples_per_ms; // sample counter + d_sample_counter += static_cast(d_sampled_ms * d_samples_per_ms); // sample counter d_well_count++; @@ -346,7 +365,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_samples_per_code * d_folding_factor); d_input_power /= static_cast(d_samples_per_code * d_folding_factor); - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { /*Ensure that the signal is going to start with all samples at zero. This is done to avoid over acumulation when performing @@ -357,7 +376,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, /*Doppler search steps and then multiplication of the incoming signal with the doppler wipeoffs to eliminate frequency offset */ - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; /*Perform multiplication of the incoming signal with the complex exponential vector. This removes the frequency doppler @@ -369,7 +388,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, /*Perform folding of the carrier wiped-off incoming signal. Since superlinear method is being used the folding factor in the incoming raw data signal is of d_folding_factor^2*/ - for (int i = 0; i < static_cast(d_folding_factor * d_folding_factor); i++) + for (int32_t i = 0; i < static_cast(d_folding_factor * d_folding_factor); i++) { std::transform((in_temp + i * d_fft_size), (in_temp + ((i + 1) * d_fft_size)), @@ -420,17 +439,17 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, restarted between consecutive dwells in multidwell operation.*/ if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) { - unsigned int detected_delay_samples_folded = 0; + uint32_t detected_delay_samples_folded = 0; detected_delay_samples_folded = (indext % d_samples_per_code); gr_complex complex_acumulator[100]; //gr_complex complex_acumulator[d_folding_factor]; - for (int i = 0; i < static_cast(d_folding_factor); i++) + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) { d_possible_delay[i] = detected_delay_samples_folded + (i)*d_fft_size; } - for (int i = 0; i < static_cast(d_folding_factor); i++) + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) { /*Copy a signal of 1 code length into suggested buffer. The copied signal must have doppler effect corrected*/ @@ -444,7 +463,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, of a shift*/ volk_32fc_x2_multiply_32fc(corr_output, in_1code, d_code, d_samples_per_code); - for (int j = 0; j < d_samples_per_code; j++) + for (int32_t j = 0; j < d_samples_per_code; j++) { complex_acumulator[i] += (corr_output[j]); } @@ -457,6 +476,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_gnss_synchro->Acq_delay_samples = static_cast(d_possible_delay[indext]); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + d_gnss_synchro->Acq_doppler_step = d_doppler_step; /* 5- Compute the test statistics and compare to the threshold d_test_statistics = 2 * d_fft_size * d_mag / d_input_power;*/ d_test_statistics = d_mag / d_input_power; @@ -528,7 +548,10 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor " << d_folding_factor; DLOG(INFO) << "possible delay correlation output"; - for (int i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) + { + DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + } DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; @@ -537,7 +560,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_sampled_ms * d_samples_per_ms * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_sampled_ms * d_samples_per_ms * ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 1; @@ -557,7 +580,10 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor " << d_folding_factor; DLOG(INFO) << "possible delay corr output"; - for (int i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) + { + DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + } DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; @@ -566,7 +592,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_sampled_ms * d_samples_per_ms * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_sampled_ms * d_samples_per_ms * ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 2; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h index 6352cc3bd..cf24625a5 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h @@ -53,24 +53,27 @@ #include "gnss_synchro.h" #include -#include #include -#include -#include +#include #include -#include #include +#include +#include +#include class pcps_quicksync_acquisition_cc; -typedef boost::shared_ptr - pcps_quicksync_acquisition_cc_sptr; +using pcps_quicksync_acquisition_cc_sptr = boost::shared_ptr; pcps_quicksync_acquisition_cc_sptr -pcps_quicksync_make_acquisition_cc(unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, +pcps_quicksync_make_acquisition_cc( + uint32_t folding_factor, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename); @@ -86,57 +89,56 @@ class pcps_quicksync_acquisition_cc : public gr::block { private: friend pcps_quicksync_acquisition_cc_sptr - pcps_quicksync_make_acquisition_cc(unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_quicksync_make_acquisition_cc(uint32_t folding_factor, + uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename); - pcps_quicksync_acquisition_cc(unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_quicksync_acquisition_cc(uint32_t folding_factor, + uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); gr_complex* d_code; - unsigned int d_folding_factor; // also referred in the paper as 'p' + uint32_t d_folding_factor; // also referred in the paper as 'p' float* d_corr_acumulator; - unsigned int* d_possible_delay; + uint32_t* d_possible_delay; float* d_corr_output_f; float* d_magnitude_folded; gr_complex* d_signal_folded; gr_complex* d_code_folded; float d_noise_floor_power; - long d_fs_in; - long d_freq; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_fft_size; - unsigned long int d_sample_counter; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_max_dwells; + uint32_t d_well_count; + uint32_t d_fft_size; + uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_codes; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_fft_if2; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -145,9 +147,9 @@ private: bool d_bit_transition_flag; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -169,7 +171,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -200,13 +202,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -225,7 +227,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -234,7 +236,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index 44d09b134..7fc685028 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -49,43 +49,52 @@ */ #include "pcps_tong_acquisition_cc.h" -#include "control_message_factory.h" #include "GPS_L1_CA.h" // for GPS_TWO_PI #include #include #include #include +#include #include +#include using google::LogMessage; pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc( - unsigned int sampled_ms, unsigned int doppler_max, - long freq, long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + uint32_t sampled_ms, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells, bool dump, std::string dump_filename) { return pcps_tong_acquisition_cc_sptr( - new pcps_tong_acquisition_cc(sampled_ms, doppler_max, freq, fs_in, samples_per_ms, samples_per_code, - tong_init_val, tong_max_val, tong_max_dwells, dump, dump_filename)); + new pcps_tong_acquisition_cc(sampled_ms, doppler_max, fs_in, samples_per_ms, samples_per_code, + tong_init_val, tong_max_val, tong_max_dwells, dump, std::move(dump_filename))); } + pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( - unsigned int sampled_ms, unsigned int doppler_max, - long freq, long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + uint32_t sampled_ms, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells, bool dump, std::string dump_filename) : gr::block("pcps_tong_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms), gr::io_signature::make(0, 0, sizeof(gr_complex) * sampled_ms * samples_per_ms)) { this->message_port_register_out(pmt::mp("events")); - d_sample_counter = 0; // SAMPLE COUNTER + d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; - d_freq = freq; d_fs_in = fs_in; d_samples_per_ms = samples_per_ms; d_samples_per_code = samples_per_code; @@ -112,14 +121,14 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); d_doppler_resolution = 0; d_threshold = 0; d_doppler_step = 0; - d_grid_data = 0; - d_grid_doppler_wipeoffs = 0; - d_gnss_synchro = 0; + d_grid_data = nullptr; + d_grid_doppler_wipeoffs = nullptr; + d_gnss_synchro = nullptr; d_code_phase = 0; d_doppler_freq = 0; d_test_statistics = 0; @@ -130,7 +139,7 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); volk_gnsssdr_free(d_grid_data[i]); @@ -145,12 +154,24 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc() delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } + void pcps_tong_acquisition_cc::set_local_code(std::complex *code) { memcpy(d_fft_if->get_inbuf(), code, sizeof(gr_complex) * d_fft_size); @@ -161,23 +182,24 @@ void pcps_tong_acquisition_cc::set_local_code(std::complex *code) volk_32fc_conjugate_32fc(d_fft_codes, d_fft_if->get_outbuf(), d_fft_size); } + void pcps_tong_acquisition_cc::init() { d_gnss_synchro->Flag_valid_acquisition = false; d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; d_gnss_synchro->Flag_valid_word = false; - + d_gnss_synchro->Acq_doppler_step = 0U; d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; d_mag = 0.0; d_input_power = 0.0; // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -186,42 +208,44 @@ void pcps_tong_acquisition_cc::init() // Create the carrier Doppler wipeoff signals and allocate data grid. d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins]; d_grid_data = new float *[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + float phase_step_rad = GPS_TWO_PI * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size); d_grid_data[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_grid_data[doppler_index][i] = 0; } } } -void pcps_tong_acquisition_cc::set_state(int state) + +void pcps_tong_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_dwell_count = 0; d_tong_count = d_tong_init_val; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_grid_data[doppler_index][i] = 0; } @@ -236,11 +260,12 @@ void pcps_tong_acquisition_cc::set_state(int state) } } + int pcps_tong_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) { - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL switch (d_state) { @@ -251,16 +276,17 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, //restart acquisition variables d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; d_dwell_count = 0; d_tong_count = d_tong_init_val; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_grid_data[doppler_index][i] = 0; } @@ -269,7 +295,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, d_state = 1; } - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; @@ -278,15 +304,15 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, case 1: { // initialize acquisition algorithm - int doppler; + int32_t doppler; uint32_t indext = 0; float magt = 0.0; - const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer + const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; - d_sample_counter += d_fft_size; // sample counter + d_sample_counter += static_cast(d_fft_size); // sample counter d_dwell_count++; @@ -302,11 +328,11 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -346,6 +372,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + d_gnss_synchro->Acq_doppler_step = d_doppler_step; } // Record results to file if required @@ -408,7 +435,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 1; @@ -433,7 +460,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_fft_size * ninput_items[0]); // sample counter consume_each(ninput_items[0]); acquisition_message = 2; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h index 00eba93f5..e2443fa33 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h @@ -53,22 +53,28 @@ #include "gnss_synchro.h" #include -#include #include +#include #include #include class pcps_tong_acquisition_cc; -typedef boost::shared_ptr pcps_tong_acquisition_cc_sptr; +using pcps_tong_acquisition_cc_sptr = boost::shared_ptr; pcps_tong_acquisition_cc_sptr -pcps_tong_make_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max, - long freq, long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, - bool dump, std::string dump_filename); +pcps_tong_make_acquisition_cc( + uint32_t sampled_ms, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells, + bool dump, + std::string dump_filename); /*! * \brief This class implements a Parallel Code Phase Search Acquisition with @@ -78,46 +84,45 @@ class pcps_tong_acquisition_cc : public gr::block { private: friend pcps_tong_acquisition_cc_sptr - pcps_tong_make_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max, - long freq, long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + pcps_tong_make_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max, + int64_t fs_in, int32_t samples_per_ms, + int32_t samples_per_code, uint32_t tong_init_val, + uint32_t tong_max_val, uint32_t tong_max_dwells, bool dump, std::string dump_filename); - pcps_tong_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max, - long freq, long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + pcps_tong_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max, + int64_t fs_in, int32_t samples_per_ms, + int32_t samples_per_code, uint32_t tong_init_val, + uint32_t tong_max_val, uint32_t tong_max_dwells, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); - long d_fs_in; - long d_freq; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_dwell_count; - unsigned int d_tong_count; - unsigned int d_tong_init_val; - unsigned int d_tong_max_val; - unsigned int d_tong_max_dwells; - unsigned int d_fft_size; - unsigned long int d_sample_counter; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_dwell_count; + uint32_t d_tong_count; + uint32_t d_tong_init_val; + uint32_t d_tong_max_val; + uint32_t d_tong_max_dwells; + uint32_t d_fft_size; + uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_codes; float** d_grid_data; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -125,9 +130,9 @@ private: float d_test_statistics; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -149,7 +154,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -180,13 +185,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -205,7 +210,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -214,7 +219,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/libs/CMakeLists.txt b/src/algorithms/acquisition/libs/CMakeLists.txt index 332d83723..4b8eefec8 100644 --- a/src/algorithms/acquisition/libs/CMakeLists.txt +++ b/src/algorithms/acquisition/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,31 +16,45 @@ # along with GNSS-SDR. If not, see . # - -set(ACQUISITION_LIB_SOURCES - fpga_acquisition.cc -) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${VOLK_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} -) - -file(GLOB ACQUISITION_LIB_HEADERS "*.h") -list(SORT ACQUISITION_LIB_HEADERS) -add_library(acquisition_lib ${ACQUISITION_LIB_SOURCES} ${ACQUISITION_LIB_HEADERS}) -source_group(Headers FILES ${ACQUISITION_LIB_HEADERS}) -target_link_libraries(acquisition_lib ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}) -if(VOLK_GNSSSDR_FOUND) - add_dependencies(acquisition_lib glog-${glog_RELEASE}) -else(VOLK_GNSSSDR_FOUND) - add_dependencies(acquisition_lib glog-${glog_RELEASE} volk_gnsssdr_module) +if(ENABLE_FPGA) + set(ACQUISITION_LIB_SOURCES fpga_acquisition.cc) + set(ACQUISITION_LIB_HEADERS fpga_acquisition.h) endif() +set(ACQUISITION_LIB_HEADERS ${ACQUISITION_LIB_HEADERS} acq_conf.h) +set(ACQUISITION_LIB_SOURCES ${ACQUISITION_LIB_SOURCES} acq_conf.cc) + +list(SORT ACQUISITION_LIB_HEADERS) +list(SORT ACQUISITION_LIB_SOURCES) + +source_group(Headers FILES ${ACQUISITION_LIB_HEADERS}) + +add_library(acquisition_libs + ${ACQUISITION_LIB_SOURCES} + ${ACQUISITION_LIB_HEADERS} +) + +target_link_libraries(acquisition_libs + PUBLIC + Volk::volk + Gnuradio::fft + PRIVATE + Gflags::gflags + Glog::glog + algorithms_libs + core_system_parameters +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(acquisition_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET acquisition_libs + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/acquisition/libs/acq_conf.cc b/src/algorithms/acquisition/libs/acq_conf.cc new file mode 100644 index 000000000..8e8d48d5e --- /dev/null +++ b/src/algorithms/acquisition/libs/acq_conf.cc @@ -0,0 +1,60 @@ +/*! + * \file acq_conf.cc + * \brief Class that contains all the configuration parameters for generic + * acquisition block based on the PCPS algoritm. + * \author Carles Fernandez, 2018. cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "acq_conf.h" + +Acq_Conf::Acq_Conf() +{ + /* PCPS acquisition configuration */ + sampled_ms = 0U; + ms_per_code = 0U; + max_dwells = 0U; + samples_per_chip = 0U; + doppler_max = 0U; + num_doppler_bins_step2 = 0U; + doppler_step2 = 0.0; + fs_in = 0LL; + samples_per_ms = 0.0; + samples_per_code = 0.0; + bit_transition_flag = false; + use_CFAR_algorithm_flag = false; + dump = false; + blocking = false; + make_2_steps = false; + dump_filename = ""; + dump_channel = 0U; + it_size = sizeof(char); + blocking_on_standby = false; + use_automatic_resampler = false; + resampler_ratio = 1.0; + resampled_fs = 0LL; + resampler_latency_samples = 0U; +} diff --git a/src/algorithms/acquisition/libs/acq_conf.h b/src/algorithms/acquisition/libs/acq_conf.h new file mode 100644 index 000000000..af81d8806 --- /dev/null +++ b/src/algorithms/acquisition/libs/acq_conf.h @@ -0,0 +1,70 @@ +/*! + * \file acq_conf.cc + * \brief Class that contains all the configuration parameters for generic + * acquisition block based on the PCPS algoritm. + * \author Carles Fernandez, 2018. cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_ACQ_CONF_H_ +#define GNSS_SDR_ACQ_CONF_H_ + +#include +#include +#include + +class Acq_Conf +{ +public: + /* PCPS Acquisition configuration */ + uint32_t sampled_ms; + uint32_t ms_per_code; + uint32_t samples_per_chip; + uint32_t max_dwells; + uint32_t doppler_max; + uint32_t num_doppler_bins_step2; + float doppler_step2; + int64_t fs_in; + float samples_per_ms; + float samples_per_code; + bool bit_transition_flag; + bool use_CFAR_algorithm_flag; + bool dump; + bool blocking; + bool blocking_on_standby; // enable it only for unit testing to avoid sample consume on idle status + bool make_2_steps; + bool use_automatic_resampler; + float resampler_ratio; + int64_t resampled_fs; + uint32_t resampler_latency_samples; + std::string dump_filename; + uint32_t dump_channel; + size_t it_size; + + Acq_Conf(); +}; + +#endif diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index c14452d93..979fd47ea 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -2,7 +2,7 @@ * \file fpga_acquisition.cc * \brief High optimized FPGA vector correlator class * \authors
                  - *
                • Marc Majoral, 2018. mmajoral(at)cttc.cat + *
                • Marc Majoral, 2019. mmajoral(at)cttc.cat *
                * * Class that controls and executes a high optimized acquisition HW @@ -37,10 +37,13 @@ #include "GPS_L1_CA.h" #include "gps_sdr_signal_processing.h" #include -#include // libraries used by the GIPO +#include // libraries used by the GIPO +#include #include // libraries used by the GIPO +#include +// FPGA register parameters #define PAGE_SIZE 0x10000 // default page size for the multicorrelator memory map #define MAX_PHASE_STEP_RAD 0.999999999534339 // 1 - pow(2,-31); #define RESET_ACQUISITION 2 // command to reset the multicorrelator @@ -54,38 +57,47 @@ #define SELECT_MSB 0XFF00 // value to select the most significant byte #define SELECT_16_BITS 0xFFFF // value to select 16 bits #define SHL_8_BITS 256 // value used to shift a value 8 bits to the left +#define SELECT_LSBits 0x000003FF // Select the 10 LSbits out of a 20-bit word +#define SELECT_MSBbits 0x000FFC00 // Select the 10 MSbits out of a 20-bit word +#define SELECT_ALL_CODE_BITS 0x000FFFFF // Select a 20 bit word +#define SHL_CODE_BITS 1024 // shift left by 10 bits bool fpga_acquisition::init() { - // configure the acquisition with the main initialization values - fpga_acquisition::configure_acquisition(); return true; } -bool fpga_acquisition::set_local_code(unsigned int PRN) +bool fpga_acquisition::set_local_code(uint32_t PRN) { // select the code with the chosen PRN - fpga_acquisition::fpga_configure_acquisition_local_code( - &d_all_fft_codes[d_nsamples_total * (PRN - 1)]); + d_PRN = PRN; return true; } -fpga_acquisition::fpga_acquisition(std::string device_name, - unsigned int nsamples, - unsigned int doppler_max, - unsigned int nsamples_total, long fs_in, long freq, - unsigned int sampled_ms, unsigned select_queue, - lv_16sc_t *all_fft_codes) +void fpga_acquisition::write_local_code() { - unsigned int vector_length = nsamples_total * sampled_ms; + fpga_acquisition::fpga_configure_acquisition_local_code( + &d_all_fft_codes[d_nsamples_total * (d_PRN - 1)]); +} + +fpga_acquisition::fpga_acquisition(std::string device_name, + uint32_t nsamples, + uint32_t doppler_max, + uint32_t nsamples_total, int64_t fs_in, + uint32_t sampled_ms, uint32_t select_queue, + lv_16sc_t *all_fft_codes, + uint32_t excludelimit) +{ + uint32_t vector_length = nsamples_total; + // initial values - d_device_name = device_name; - d_freq = freq; + d_device_name = std::move(device_name); d_fs_in = fs_in; d_vector_length = vector_length; + d_excludelimit = excludelimit; d_nsamples = nsamples; // number of samples not including padding d_select_queue = select_queue; d_nsamples_total = nsamples_total; @@ -95,39 +107,35 @@ fpga_acquisition::fpga_acquisition(std::string device_name, d_map_base = nullptr; // driver memory map d_all_fft_codes = all_fft_codes; + fpga_acquisition::reset_acquisition(); + fpga_acquisition::open_device(); + fpga_acquisition::fpga_acquisition_test_register(); + fpga_acquisition::close_device(); + + d_PRN = 0; + DLOG(INFO) << "Acquisition FPGA class created"; +} + +void fpga_acquisition::open_device() +{ // open communication with HW accelerator if ((d_fd = open(d_device_name.c_str(), O_RDWR | O_SYNC)) == -1) { LOG(WARNING) << "Cannot open deviceio" << d_device_name; + std::cout << "Acq: cannot open deviceio" << d_device_name << std::endl; } - d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, + d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_fd, 0)); if (d_map_base == reinterpret_cast(-1)) { LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; + std::cout << "Acq: cannot map deviceio" << d_device_name << std::endl; } - - // sanity check : check test register - unsigned writeval = TEST_REG_SANITY_CHECK; - unsigned readval; - readval = fpga_acquisition::fpga_acquisition_test_register(writeval); - if (writeval != readval) - { - LOG(WARNING) << "Acquisition test register sanity check failed"; - } - else - { - LOG(INFO) << "Acquisition test register sanity check success!"; - } - fpga_acquisition::reset_acquisition(); - DLOG(INFO) << "Acquisition FPGA class created"; } - fpga_acquisition::~fpga_acquisition() { - close_device(); } @@ -137,33 +145,45 @@ bool fpga_acquisition::free() } -unsigned fpga_acquisition::fpga_acquisition_test_register(unsigned writeval) +void fpga_acquisition::fpga_acquisition_test_register() { - unsigned readval; + // sanity check : check test register + uint32_t writeval = TEST_REG_SANITY_CHECK; + uint32_t readval; + // write value to test register d_map_base[15] = writeval; // read value from test register readval = d_map_base[15]; - // return read value - return readval; + + + if (writeval != readval) + { + LOG(WARNING) << "Acquisition test register sanity check failed"; + } + else + { + LOG(INFO) << "Acquisition test register sanity check success!"; + } } void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]) { - unsigned short local_code; - unsigned int k, tmp, tmp2; - unsigned int fft_data; - // clear memory address counter - d_map_base[4] = LOCAL_CODE_CLEAR_MEM; + uint32_t local_code; + uint32_t k, tmp, tmp2; + uint32_t fft_data; + + d_map_base[9] = LOCAL_CODE_CLEAR_MEM; // write local code for (k = 0; k < d_vector_length; k++) { tmp = fft_local_code[k].real(); tmp2 = fft_local_code[k].imag(); - local_code = (tmp & SELECT_LSB) | ((tmp2 * SHL_8_BITS) & SELECT_MSB); // put together the real part and the imaginary part - fft_data = MEM_LOCAL_CODE_WR_ENABLE | (local_code & SELECT_16_BITS); - d_map_base[4] = fft_data; + + local_code = (tmp & SELECT_LSBits) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBbits); // put together the real part and the imaginary part + fft_data = local_code & SELECT_ALL_CODE_BITS; + d_map_base[6] = fft_data; } } @@ -171,39 +191,86 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local void fpga_acquisition::run_acquisition(void) { // enable interrupts - int reenable = 1; - write(d_fd, reinterpret_cast(&reenable), sizeof(int)); - // launch the acquisition process - d_map_base[6] = LAUNCH_ACQUISITION; // writing anything to reg 6 launches the acquisition process + int32_t reenable = 1; + int32_t disable_int = 0; + write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); - int irq_count; + // launch the acquisition process + d_map_base[8] = LAUNCH_ACQUISITION; // writing a 1 to reg 8 launches the acquisition process + int32_t irq_count; ssize_t nb; + // wait for interrupt nb = read(d_fd, &irq_count, sizeof(irq_count)); if (nb != sizeof(irq_count)) { - printf("acquisition module Read failed to retrieve 4 bytes!\n"); - printf("acquisition module Interrupt number %d\n", irq_count); + std::cout << "acquisition module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "acquisition module Interrupt number " << irq_count << std::endl; } + + write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t)); } - -void fpga_acquisition::configure_acquisition() +void fpga_acquisition::set_block_exp(uint32_t total_block_exp) { - d_map_base[0] = d_select_queue; - d_map_base[1] = d_vector_length; - d_map_base[2] = d_nsamples; - d_map_base[5] = (int)log2((float)d_vector_length); // log2 FFTlength + d_map_base[11] = total_block_exp; } - -void fpga_acquisition::set_phase_step(unsigned int doppler_index) +void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) { float phase_step_rad_real; float phase_step_rad_int_temp; int32_t phase_step_rad_int; - int doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); + int32_t doppler = static_cast(-d_doppler_max); + float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing + // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) + // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); + + // avoid saturation of the fixed point representation in the fpga + // (only the positive value can saturate due to the 2's complement representation) + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + d_map_base[3] = phase_step_rad_int; + + // repeat the calculation with the doppler step + doppler = static_cast(d_doppler_step); + phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + d_map_base[4] = phase_step_rad_int; + d_map_base[5] = num_sweeps; +} + +void fpga_acquisition::configure_acquisition() +{ + fpga_acquisition::open_device(); + + d_map_base[0] = d_select_queue; + d_map_base[1] = d_vector_length; + d_map_base[2] = d_nsamples; + d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength + d_map_base[12] = d_excludelimit; +} + + +void fpga_acquisition::set_phase_step(uint32_t doppler_index) +{ + float phase_step_rad_real; + float phase_step_rad_int_temp; + int32_t phase_step_rad_int; + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) @@ -215,24 +282,49 @@ void fpga_acquisition::set_phase_step(unsigned int doppler_index) { phase_step_rad_real = MAX_PHASE_STEP_RAD; } - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = (int32_t)(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings d_map_base[3] = phase_step_rad_int; } void fpga_acquisition::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, unsigned *initial_sample, float *power_sum) + float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp) { - unsigned readval = 0; + uint64_t initial_sample_tmp = 0; + uint32_t readval = 0; + uint64_t readval_long = 0; + uint64_t readval_long_shifted = 0; + readval = d_map_base[1]; - *initial_sample = readval; - readval = d_map_base[2]; - *max_magnitude = static_cast(readval); - readval = d_map_base[4]; - *power_sum = static_cast(readval); + initial_sample_tmp = readval; + + readval_long = d_map_base[2]; + readval_long_shifted = readval_long << 32; // 2^32 + + initial_sample_tmp = initial_sample_tmp + readval_long_shifted; // 2^32 + *initial_sample = initial_sample_tmp; + readval = d_map_base[3]; + *firstpeak = static_cast(readval); + + readval = d_map_base[4]; + *secondpeak = static_cast(readval); + + readval = d_map_base[5]; *max_index = readval; + + *power_sum = 0; + + readval = d_map_base[8]; + *total_blk_exp = readval; + + readval = d_map_base[7]; // read doppler index -- this read releases the interrupt line + *doppler_index = readval; + + readval = d_map_base[15]; // read dummy + + fpga_acquisition::close_device(); } @@ -250,10 +342,10 @@ void fpga_acquisition::unblock_samples() void fpga_acquisition::close_device() { - unsigned *aux = const_cast(d_map_base); + uint32_t *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(d_fd); } @@ -261,5 +353,26 @@ void fpga_acquisition::close_device() void fpga_acquisition::reset_acquisition(void) { - d_map_base[6] = RESET_ACQUISITION; // writing a 2 to d_map_base[6] resets the multicorrelator + fpga_acquisition::open_device(); + d_map_base[8] = RESET_ACQUISITION; // writing a 2 to d_map_base[8] resets the multicorrelator + fpga_acquisition::close_device(); +} + + +// this function is only used for the unit tests +void fpga_acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +{ + uint32_t readval = 0; + readval = d_map_base[8]; + *total_scale_factor = readval; + + //readval = d_map_base[8]; + *fw_scale_factor = 0; +} + +void fpga_acquisition::read_result_valid(uint32_t *result_valid) +{ + uint32_t readval = 0; + readval = d_map_base[0]; + *result_valid = readval; } diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index 88e6802b6..6140e9ade 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -2,7 +2,7 @@ * \file fpga_acquisition.h * \brief High optimized FPGA vector correlator class * \authors
                  - *
                • Marc Majoral, 2018. mmajoral(at)cttc.cat + *
                • Marc Majoral, 2019. mmajoral(at)cttc.cat *
                * * Class that controls and executes a high optimized acquisition HW @@ -10,7 +10,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -38,6 +38,7 @@ #include #include +#include /*! * \brief Class that implements carrier wipe-off and correlators. @@ -46,20 +47,24 @@ class fpga_acquisition { public: fpga_acquisition(std::string device_name, - unsigned int nsamples, - unsigned int doppler_max, - unsigned int nsamples_total, long fs_in, long freq, - unsigned int sampled_ms, unsigned select_queue, - lv_16sc_t *all_fft_codes); + uint32_t nsamples, + uint32_t doppler_max, + uint32_t nsamples_total, + int64_t fs_in, + uint32_t sampled_ms, + uint32_t select_queue, + lv_16sc_t *all_fft_codes, + uint32_t excludelimit); + ~fpga_acquisition(); bool init(); - bool set_local_code( - unsigned int PRN); + bool set_local_code(uint32_t PRN); bool free(); + void set_doppler_sweep(uint32_t num_sweeps); void run_acquisition(void); - void set_phase_step(unsigned int doppler_index); - void read_acquisition_results(uint32_t *max_index, float *max_magnitude, - unsigned *initial_sample, float *power_sum); + void set_phase_step(uint32_t doppler_index); + void read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp); + void block_samples(); void unblock_samples(); @@ -67,7 +72,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - void set_doppler_max(unsigned int doppler_max) + void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -76,32 +81,49 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - void set_doppler_step(unsigned int doppler_step) + void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } -private: - long d_freq; - long d_fs_in; - gr::fft::fft_complex *d_fft_if; // function used to run the fft of the local codes - // data related to the hardware module and the driver - int d_fd; // driver descriptor - volatile unsigned *d_map_base; // driver memory map - lv_16sc_t *d_all_fft_codes; // memory that contains all the code ffts - unsigned int d_vector_length; // number of samples incluing padding and number of ms - unsigned int d_nsamples_total; // number of samples including padding - unsigned int d_nsamples; // number of samples not including padding - unsigned int d_select_queue; // queue selection - std::string d_device_name; // HW device name - unsigned int d_doppler_max; // max doppler - unsigned int d_doppler_step; // doppler step - // FPGA private functions - unsigned fpga_acquisition_test_register(unsigned writeval); - void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); - void configure_acquisition(); + /*! + * \brief Reset the FPGA PL. + */ void reset_acquisition(void); + + /*! + * \brief read the scaling factor that has been used by the FFT-IFFT + */ + void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + + void set_block_exp(uint32_t total_block_exp); + + void write_local_code(void); + + void configure_acquisition(void); + void close_device(); + void open_device(); + +private: + int64_t d_fs_in; + // data related to the hardware module and the driver + int32_t d_fd; // driver descriptor + volatile uint32_t *d_map_base; // driver memory map + lv_16sc_t *d_all_fft_codes; // memory that contains all the code ffts + uint32_t d_vector_length; // number of samples incluing padding and number of ms + uint32_t d_excludelimit; + uint32_t d_nsamples_total; // number of samples including padding + uint32_t d_nsamples; // number of samples not including padding + uint32_t d_select_queue; // queue selection + std::string d_device_name; // HW device name + uint32_t d_doppler_max; // max doppler + uint32_t d_doppler_step; // doppler step + uint32_t d_PRN; // PRN + // FPGA private functions + void fpga_acquisition_test_register(void); + void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); + void read_result_valid(uint32_t *result_valid); }; #endif /* GNSS_SDR_FPGA_ACQUISITION_H_ */ diff --git a/src/algorithms/channel/CMakeLists.txt b/src/algorithms/channel/CMakeLists.txt index 077b74808..cd5604218 100644 --- a/src/algorithms/channel/CMakeLists.txt +++ b/src/algorithms/channel/CMakeLists.txt @@ -17,4 +17,4 @@ # add_subdirectory(adapters) -add_subdirectory(libs) \ No newline at end of file +add_subdirectory(libs) diff --git a/src/algorithms/channel/adapters/CMakeLists.txt b/src/algorithms/channel/adapters/CMakeLists.txt index a6d5245cd..7bf49e73d 100644 --- a/src/algorithms/channel/adapters/CMakeLists.txt +++ b/src/algorithms/channel/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,22 +17,40 @@ # set(CHANNEL_ADAPTER_SOURCES channel.cc) +set(CHANNEL_ADAPTER_HEADERS channel.h) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/channel/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} +add_library(channel_adapters + ${CHANNEL_ADAPTER_SOURCES} + ${CHANNEL_ADAPTER_HEADERS} ) -file(GLOB CHANNEL_ADAPTER_HEADERS "*.h") -list(SORT CHANNEL_ADAPTER_HEADERS) -add_library(channel_adapters ${CHANNEL_ADAPTER_SOURCES} ${CHANNEL_ADAPTER_HEADERS}) source_group(Headers FILES ${CHANNEL_ADAPTER_HEADERS}) -target_link_libraries(channel_adapters channel_fsm ${GNURADIO_RUNTIME_LIBRARIES} ${Boost_LIBRARIES} gnss_sdr_flags) + +target_link_libraries(channel_adapters + PUBLIC + Gnuradio::runtime + channel_libs + PRIVATE + Gflags::gflags + Glog::glog + gnss_sdr_flags +) + +target_include_directories(channel_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(channel_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET channel_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 480212e3a..12fafc3de 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -32,26 +32,23 @@ #include "channel.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include #include - +#include using google::LogMessage; // Constructor -Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, - std::shared_ptr pass_through, std::shared_ptr acq, +Channel::Channel(ConfigurationInterface* configuration, uint32_t channel, std::shared_ptr acq, std::shared_ptr trk, std::shared_ptr nav, std::string role, std::string implementation, gr::msg_queue::sptr queue) { - pass_through_ = pass_through; - acq_ = acq; - trk_ = trk; - nav_ = nav; - role_ = role; - implementation_ = implementation; + acq_ = std::move(acq); + trk_ = std::move(trk); + nav_ = std::move(nav); + role_ = std::move(role); + implementation_ = std::move(implementation); channel_ = channel; - queue_ = queue; + queue_ = std::move(queue); channel_fsm_ = std::make_shared(); flag_enable_fpga = configuration->property("Channel.enable_FPGA", false); @@ -59,6 +56,7 @@ Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, trk_->set_channel(channel_); nav_->set_channel(channel_); + gnss_synchro_ = Gnss_Synchro(); gnss_synchro_.Channel_ID = channel_; acq_->set_gnss_synchro(&gnss_synchro_); trk_->set_gnss_synchro(&gnss_synchro_); @@ -66,7 +64,7 @@ Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, // Provide a warning to the user about the change of parameter name if (channel_ == 0) { - long int deprecation_warning = configuration->property("GNSS-SDR.internal_fs_hz", 0); + int64_t deprecation_warning = configuration->property("GNSS-SDR.internal_fs_hz", 0); if (deprecation_warning != 0) { std::cout << "WARNING: The global parameter name GNSS-SDR.internal_fs_hz has been DEPRECATED." << std::endl; @@ -76,21 +74,30 @@ Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, // IMPORTANT: Do not change the order between set_doppler_step and set_threshold - unsigned int doppler_step = configuration->property("Acquisition_" + implementation_ + boost::lexical_cast(channel_) + ".doppler_step", 0); - if (doppler_step == 0) doppler_step = configuration->property("Acquisition_" + implementation_ + ".doppler_step", 500); - if (FLAGS_doppler_step != 0) doppler_step = static_cast(FLAGS_doppler_step); + uint32_t doppler_step = configuration->property("Acquisition_" + implementation_ + std::to_string(channel_) + ".doppler_step", 0); + if (doppler_step == 0) + { + doppler_step = configuration->property("Acquisition_" + implementation_ + ".doppler_step", 500); + } + if (FLAGS_doppler_step != 0) + { + doppler_step = static_cast(FLAGS_doppler_step); + } DLOG(INFO) << "Channel " << channel_ << " Doppler_step = " << doppler_step; acq_->set_doppler_step(doppler_step); - float threshold = configuration->property("Acquisition_" + implementation_ + boost::lexical_cast(channel_) + ".threshold", 0.0); - if (threshold == 0.0) threshold = configuration->property("Acquisition_" + implementation_ + ".threshold", 0.0); + float threshold = configuration->property("Acquisition_" + implementation_ + std::to_string(channel_) + ".threshold", 0.0); + if (threshold == 0.0) + { + threshold = configuration->property("Acquisition_" + implementation_ + ".threshold", 0.0); + } acq_->set_threshold(threshold); acq_->init(); - repeat_ = configuration->property("Acquisition_" + implementation_ + boost::lexical_cast(channel_) + ".repeat_satellite", false); + repeat_ = configuration->property("Acquisition_" + implementation_ + std::to_string(channel_) + ".repeat_satellite", false); DLOG(INFO) << "Channel " << channel_ << " satellite repeat = " << repeat_; channel_fsm_->set_acquisition(acq_); @@ -107,35 +114,20 @@ Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, // Destructor -Channel::~Channel() {} +Channel::~Channel() = default; + + void Channel::connect(gr::top_block_sptr top_block) { - if (connected_) - { - LOG(WARNING) << "channel already connected internally"; - return; - } - if (flag_enable_fpga == false) - { - pass_through_->connect(top_block); - } acq_->connect(top_block); trk_->connect(top_block); nav_->connect(top_block); //Synchronous ports - if (flag_enable_fpga == false) - { - top_block->connect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0); - DLOG(INFO) << "pass_through_ -> acquisition"; - top_block->connect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0); - DLOG(INFO) << "pass_through_ -> tracking"; - } top_block->connect(trk_->get_right_block(), 0, nav_->get_left_block(), 0); DLOG(INFO) << "tracking -> telemetry_decoder"; // Message ports - top_block->msg_connect(acq_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events")); top_block->msg_connect(trk_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events")); @@ -151,17 +143,8 @@ void Channel::disconnect(gr::top_block_sptr top_block) return; } - if (flag_enable_fpga == false) - { - top_block->disconnect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0); - top_block->disconnect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0); - } top_block->disconnect(trk_->get_right_block(), 0, nav_->get_left_block(), 0); - if (flag_enable_fpga == false) - { - pass_through_->disconnect(top_block); - } acq_->disconnect(top_block); trk_->disconnect(top_block); nav_->disconnect(top_block); @@ -171,9 +154,19 @@ void Channel::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr Channel::get_left_block() { - return pass_through_->get_left_block(); + LOG(ERROR) << "Deprecated call to get_left_block() in channel interface"; + return nullptr; } +gr::basic_block_sptr Channel::get_left_block_trk() +{ + return trk_->get_left_block(); +} + +gr::basic_block_sptr Channel::get_left_block_acq() +{ + return acq_->get_left_block(); +} gr::basic_block_sptr Channel::get_right_block() { @@ -196,6 +189,19 @@ void Channel::set_signal(const Gnss_Signal& gnss_signal) } +void Channel::stop_channel() +{ + std::lock_guard lk(mx); + bool result = channel_fsm_->Event_stop_channel(); + if (!result) + { + LOG(WARNING) << "Invalid channel event"; + return; + } + DLOG(INFO) + << "Channel stop_channel()"; +} + void Channel::start_acquisition() { std::lock_guard lk(mx); diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index d82ad0870..9eda9e474 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -35,15 +35,15 @@ #ifndef GNSS_SDR_CHANNEL_H_ #define GNSS_SDR_CHANNEL_H_ -#include "channel_interface.h" #include "channel_fsm.h" -#include "gnss_synchro.h" +#include "channel_interface.h" #include "channel_msg_receiver_cc.h" -#include +#include "gnss_synchro.h" #include +#include #include -#include #include +#include class ConfigurationInterface; class AcquisitionInterface; @@ -60,46 +60,42 @@ class Channel : public ChannelInterface { public: //! Constructor - Channel(ConfigurationInterface* configuration, unsigned int channel, - std::shared_ptr pass_through, std::shared_ptr acq, + Channel(ConfigurationInterface* configuration, uint32_t channel, std::shared_ptr acq, std::shared_ptr trk, std::shared_ptr nav, std::string role, std::string implementation, gr::msg_queue::sptr queue); //! Virtual destructor virtual ~Channel(); - void connect(gr::top_block_sptr top_block) override; + void connect(gr::top_block_sptr top_block) override; //!< connects the tracking block to the top_block and to the telemetry void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_left_block() override; //!< gets the gnuradio tracking block pointer + gr::basic_block_sptr get_left_block_trk() override; //!< gets the gnuradio tracking block pointer + gr::basic_block_sptr get_left_block_acq() override; //!< gets the gnuradio tracking block pointer gr::basic_block_sptr get_right_block() override; inline std::string role() override { return role_; } - //! Returns "Channel" inline std::string implementation() override { return implementation_; } - inline size_t item_size() override { return 0; } - inline Gnss_Signal get_signal() const override { return gnss_signal_; } - void start_acquisition() override; //!< Start the State Machine + void stop_channel() override; //!< Stop the State Machine void set_signal(const Gnss_Signal& gnss_signal_) override; //!< Sets the channel GNSS signal inline std::shared_ptr acquisition() { return acq_; } inline std::shared_ptr tracking() { return trk_; } inline std::shared_ptr telemetry() { return nav_; } - void msg_handler_events(pmt::pmt_t msg); private: channel_msg_receiver_cc_sptr channel_msg_rx; - std::shared_ptr pass_through_; std::shared_ptr acq_; std::shared_ptr trk_; std::shared_ptr nav_; std::string role_; std::string implementation_; bool flag_enable_fpga; - unsigned int channel_; + uint32_t channel_; Gnss_Synchro gnss_synchro_; Gnss_Signal gnss_signal_; bool connected_; diff --git a/src/algorithms/channel/libs/CMakeLists.txt b/src/algorithms/channel/libs/CMakeLists.txt index ffbc21a42..c055123bc 100644 --- a/src/algorithms/channel/libs/CMakeLists.txt +++ b/src/algorithms/channel/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,28 +16,43 @@ # along with GNSS-SDR. If not, see . # -set(CHANNEL_FSM_SOURCES - channel_fsm.cc +set(CHANNEL_FSM_SOURCES + channel_fsm.cc channel_msg_receiver_cc.cc - ) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/channel/adapters - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} ) -file(GLOB CHANNEL_FSM_HEADERS "*.h") +set(CHANNEL_FSM_HEADERS + channel_fsm.h + channel_msg_receiver_cc.h +) + list(SORT CHANNEL_FSM_HEADERS) -add_library(channel_fsm ${CHANNEL_FSM_SOURCES} ${CHANNEL_FSM_HEADERS}) +list(SORT CHANNEL_FSM_SOURCES) + source_group(Headers FILES ${CHANNEL_FSM_HEADERS}) -add_dependencies(channel_fsm glog-${glog_RELEASE}) -target_link_libraries(channel_fsm gnss_rx) +add_library(channel_libs ${CHANNEL_FSM_SOURCES} ${CHANNEL_FSM_HEADERS}) +target_link_libraries(channel_libs + PUBLIC + Gnuradio::runtime + core_system_parameters + PRIVATE + Gflags::gflags + Glog::glog + core_receiver +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(channel_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET channel_libs + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/channel/libs/channel_fsm.cc b/src/algorithms/channel/libs/channel_fsm.cc index 5ac015f2d..968ea2393 100644 --- a/src/algorithms/channel/libs/channel_fsm.cc +++ b/src/algorithms/channel/libs/channel_fsm.cc @@ -39,19 +39,41 @@ ChannelFsm::ChannelFsm() { acq_ = nullptr; trk_ = nullptr; - channel_ = 0; - d_state = 0; + channel_ = 0U; + d_state = 0U; } -ChannelFsm::ChannelFsm(std::shared_ptr acquisition) : acq_(acquisition) +ChannelFsm::ChannelFsm(std::shared_ptr acquisition) : acq_(std::move(acquisition)) { trk_ = nullptr; - channel_ = 0; - d_state = 0; + channel_ = 0U; + d_state = 0U; } +bool ChannelFsm::Event_stop_channel() +{ + std::lock_guard lk(mx); + DLOG(INFO) << "CH = " << channel_ << ". Ev stop channel"; + switch (d_state) + { + case 0: //already in stanby + break; + case 1: //acquisition + d_state = 0; + stop_acquisition(); + break; + case 2: //tracking + d_state = 0; + stop_tracking(); + break; + default: + break; + } + return true; +} + bool ChannelFsm::Event_start_acquisition() { std::lock_guard lk(mx); @@ -59,13 +81,10 @@ bool ChannelFsm::Event_start_acquisition() { return false; } - else - { - d_state = 1; - start_acquisition(); - DLOG(INFO) << "CH = " << channel_ << ". Ev start acquisition"; - return true; - } + d_state = 1; + start_acquisition(); + DLOG(INFO) << "CH = " << channel_ << ". Ev start acquisition"; + return true; } @@ -76,13 +95,10 @@ bool ChannelFsm::Event_valid_acquisition() { return false; } - else - { - d_state = 2; - start_tracking(); - DLOG(INFO) << "CH = " << channel_ << ". Ev valid acquisition"; - return true; - } + d_state = 2; + start_tracking(); + DLOG(INFO) << "CH = " << channel_ << ". Ev valid acquisition"; + return true; } @@ -93,13 +109,10 @@ bool ChannelFsm::Event_failed_acquisition_repeat() { return false; } - else - { - d_state = 1; - start_acquisition(); - DLOG(INFO) << "CH = " << channel_ << ". Ev failed acquisition repeat"; - return true; - } + d_state = 1; + start_acquisition(); + DLOG(INFO) << "CH = " << channel_ << ". Ev failed acquisition repeat"; + return true; } @@ -110,13 +123,10 @@ bool ChannelFsm::Event_failed_acquisition_no_repeat() { return false; } - else - { - d_state = 3; - request_satellite(); - DLOG(INFO) << "CH = " << channel_ << ". Ev failed acquisition no repeat"; - return true; - } + d_state = 3; + request_satellite(); + DLOG(INFO) << "CH = " << channel_ << ". Ev failed acquisition no repeat"; + return true; } @@ -127,44 +137,52 @@ bool ChannelFsm::Event_failed_tracking_standby() { return false; } - else - { - d_state = 0; - notify_stop_tracking(); - DLOG(INFO) << "CH = " << channel_ << ". Ev failed tracking standby"; - return true; - } + d_state = 0U; + notify_stop_tracking(); + DLOG(INFO) << "CH = " << channel_ << ". Ev failed tracking standby"; + return true; } void ChannelFsm::set_acquisition(std::shared_ptr acquisition) { std::lock_guard lk(mx); - acq_ = acquisition; + acq_ = std::move(acquisition); } void ChannelFsm::set_tracking(std::shared_ptr tracking) { std::lock_guard lk(mx); - trk_ = tracking; + trk_ = std::move(tracking); } void ChannelFsm::set_queue(gr::msg_queue::sptr queue) { std::lock_guard lk(mx); - queue_ = queue; + queue_ = std::move(queue); } -void ChannelFsm::set_channel(unsigned int channel) +void ChannelFsm::set_channel(uint32_t channel) { std::lock_guard lk(mx); channel_ = channel; } +void ChannelFsm::stop_acquisition() +{ + acq_->stop_acquisition(); +} + +void ChannelFsm::stop_tracking() +{ + trk_->stop_tracking(); +} + + void ChannelFsm::start_acquisition() { acq_->reset(); diff --git a/src/algorithms/channel/libs/channel_fsm.h b/src/algorithms/channel/libs/channel_fsm.h index 7489ca171..2ecc6eb20 100644 --- a/src/algorithms/channel/libs/channel_fsm.h +++ b/src/algorithms/channel/libs/channel_fsm.h @@ -33,9 +33,10 @@ #define GNSS_SDR_CHANNEL_FSM_H #include "acquisition_interface.h" -#include "tracking_interface.h" #include "telemetry_decoder_interface.h" +#include "tracking_interface.h" #include +#include #include #include @@ -52,11 +53,12 @@ public: void set_acquisition(std::shared_ptr acquisition); void set_tracking(std::shared_ptr tracking); void set_queue(gr::msg_queue::sptr queue); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); //FSM EVENTS bool Event_start_acquisition(); bool Event_valid_acquisition(); + bool Event_stop_channel(); bool Event_failed_acquisition_repeat(); bool Event_failed_acquisition_no_repeat(); bool Event_failed_tracking_standby(); @@ -64,14 +66,16 @@ public: private: void start_acquisition(); void start_tracking(); + void stop_acquisition(); + void stop_tracking(); void request_satellite(); void notify_stop_tracking(); std::shared_ptr acq_; std::shared_ptr trk_; gr::msg_queue::sptr queue_; - unsigned int channel_; - unsigned int d_state; + uint32_t channel_; + uint32_t d_state; std::mutex mx; }; diff --git a/src/algorithms/channel/libs/channel_msg_receiver_cc.cc b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc index ca4105f8e..82333e6a7 100644 --- a/src/algorithms/channel/libs/channel_msg_receiver_cc.cc +++ b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc @@ -30,16 +30,17 @@ #include "channel_msg_receiver_cc.h" +#include #include #include -#include +#include using google::LogMessage; channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(std::shared_ptr channel_fsm, bool repeat) { - return channel_msg_receiver_cc_sptr(new channel_msg_receiver_cc(channel_fsm, repeat)); + return channel_msg_receiver_cc_sptr(new channel_msg_receiver_cc(std::move(channel_fsm), repeat)); } @@ -48,7 +49,7 @@ void channel_msg_receiver_cc::msg_handler_events(pmt::pmt_t msg) bool result = false; try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); switch (message) { case 1: // positive acquisition @@ -88,9 +89,9 @@ channel_msg_receiver_cc::channel_msg_receiver_cc(std::shared_ptr cha this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&channel_msg_receiver_cc::msg_handler_events, this, _1)); - d_channel_fsm = channel_fsm; + d_channel_fsm = std::move(channel_fsm); d_repeat = repeat; } -channel_msg_receiver_cc::~channel_msg_receiver_cc() {} +channel_msg_receiver_cc::~channel_msg_receiver_cc() = default; diff --git a/src/algorithms/channel/libs/channel_msg_receiver_cc.h b/src/algorithms/channel/libs/channel_msg_receiver_cc.h index 7fc172923..cc05892d8 100644 --- a/src/algorithms/channel/libs/channel_msg_receiver_cc.h +++ b/src/algorithms/channel/libs/channel_msg_receiver_cc.h @@ -36,7 +36,7 @@ class channel_msg_receiver_cc; -typedef boost::shared_ptr channel_msg_receiver_cc_sptr; +using channel_msg_receiver_cc_sptr = boost::shared_ptr; channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(std::shared_ptr channel_fsm, bool repeat); diff --git a/src/algorithms/conditioner/CMakeLists.txt b/src/algorithms/conditioner/CMakeLists.txt index de941b536..166f27d36 100644 --- a/src/algorithms/conditioner/CMakeLists.txt +++ b/src/algorithms/conditioner/CMakeLists.txt @@ -17,4 +17,3 @@ # add_subdirectory(adapters) -#add_subdirectory(gnuradio_blocks) \ No newline at end of file diff --git a/src/algorithms/conditioner/adapters/CMakeLists.txt b/src/algorithms/conditioner/adapters/CMakeLists.txt index cb83608aa..6e0e68a45 100644 --- a/src/algorithms/conditioner/adapters/CMakeLists.txt +++ b/src/algorithms/conditioner/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,25 +17,46 @@ # -set(COND_ADAPTER_SOURCES - signal_conditioner.cc - array_signal_conditioner.cc +set(COND_ADAPTER_SOURCES + signal_conditioner.cc + array_signal_conditioner.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} +set(COND_ADAPTER_HEADERS + signal_conditioner.h + array_signal_conditioner.h ) -file(GLOB COND_ADAPTER_HEADERS "*.h") list(SORT COND_ADAPTER_HEADERS) -add_library(conditioner_adapters ${COND_ADAPTER_SOURCES} ${COND_ADAPTER_HEADERS}) +list(SORT COND_ADAPTER_SOURCES) + source_group(Headers FILES ${COND_ADAPTER_HEADERS}) -add_dependencies(conditioner_adapters glog-${glog_RELEASE}) \ No newline at end of file + +add_library(conditioner_adapters ${COND_ADAPTER_SOURCES} ${COND_ADAPTER_HEADERS}) + +target_link_libraries(conditioner_adapters + PUBLIC + Gnuradio::runtime + PRIVATE + Gflags::gflags + Glog::glog +) + +target_include_directories(conditioner_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(conditioner_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET conditioner_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc index 098a9e365..55970c4d7 100644 --- a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc @@ -31,6 +31,7 @@ #include "array_signal_conditioner.h" #include +#include using google::LogMessage; @@ -41,11 +42,11 @@ ArraySignalConditioner::ArraySignalConditioner(ConfigurationInterface *configura std::shared_ptr in_filt, std::shared_ptr res, std::string role, - std::string implementation) : data_type_adapt_(data_type_adapt), - in_filt_(in_filt), - res_(res), - role_(role), - implementation_(implementation) + std::string implementation) : data_type_adapt_(std::move(data_type_adapt)), + in_filt_(std::move(in_filt)), + res_(std::move(res)), + role_(std::move(role)), + implementation_(std::move(implementation)) { connected_ = false; if (configuration) @@ -55,7 +56,7 @@ ArraySignalConditioner::ArraySignalConditioner(ConfigurationInterface *configura // Destructor -ArraySignalConditioner::~ArraySignalConditioner() {} +ArraySignalConditioner::~ArraySignalConditioner() = default; void ArraySignalConditioner::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/conditioner/adapters/array_signal_conditioner.h b/src/algorithms/conditioner/adapters/array_signal_conditioner.h index d3f1c9382..76809be53 100644 --- a/src/algorithms/conditioner/adapters/array_signal_conditioner.h +++ b/src/algorithms/conditioner/adapters/array_signal_conditioner.h @@ -33,9 +33,9 @@ #define GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_H_ -#include -#include #include "gnss_block_interface.h" +#include +#include class ConfigurationInterface; diff --git a/src/algorithms/conditioner/adapters/signal_conditioner.cc b/src/algorithms/conditioner/adapters/signal_conditioner.cc index 72034c375..e55ba9e1a 100644 --- a/src/algorithms/conditioner/adapters/signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/signal_conditioner.cc @@ -31,6 +31,7 @@ #include "signal_conditioner.h" #include +#include using google::LogMessage; @@ -41,11 +42,11 @@ SignalConditioner::SignalConditioner(ConfigurationInterface *configuration, std::shared_ptr in_filt, std::shared_ptr res, std::string role, - std::string implementation) : data_type_adapt_(data_type_adapt), - in_filt_(in_filt), - res_(res), - role_(role), - implementation_(implementation) + std::string implementation) : data_type_adapt_(std::move(data_type_adapt)), + in_filt_(std::move(in_filt)), + res_(std::move(res)), + role_(std::move(role)), + implementation_(std::move(implementation)) { connected_ = false; if (configuration) @@ -55,7 +56,7 @@ SignalConditioner::SignalConditioner(ConfigurationInterface *configuration, // Destructor -SignalConditioner::~SignalConditioner() {} +SignalConditioner::~SignalConditioner() = default; void SignalConditioner::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/data_type_adapter/CMakeLists.txt b/src/algorithms/data_type_adapter/CMakeLists.txt index 6037ad61f..1c15cc0ca 100644 --- a/src/algorithms/data_type_adapter/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/CMakeLists.txt @@ -19,4 +19,3 @@ add_subdirectory(adapters) add_subdirectory(gnuradio_blocks) - diff --git a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt index 836e2bfd8..a9042d832 100644 --- a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,31 +17,62 @@ # -set(DATATYPE_ADAPTER_SOURCES +set(DATATYPE_ADAPTER_SOURCES byte_to_short.cc ibyte_to_cbyte.cc ibyte_to_complex.cc ibyte_to_cshort.cc ishort_to_cshort.cc - ishort_to_complex.cc - ) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} + ishort_to_complex.cc ) -file(GLOB DATATYPE_ADAPTER_HEADERS "*.h") -list(SORT DATATYPE_ADAPTER_HEADERS) -add_library(datatype_adapters ${DATATYPE_ADAPTER_SOURCES} ${DATATYPE_ADAPTER_HEADERS}) -source_group(Headers FILES ${DATATYPE_ADAPTER_HEADERS}) -add_dependencies(datatype_adapters glog-${glog_RELEASE}) -target_link_libraries(datatype_adapters data_type_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES}) +set(DATATYPE_ADAPTER_HEADERS + byte_to_short.h + ibyte_to_cbyte.h + ibyte_to_complex.h + ibyte_to_cshort.h + ishort_to_cshort.h + ishort_to_complex.h +) +list(SORT DATATYPE_ADAPTER_HEADERS) +list(SORT DATATYPE_ADAPTER_SOURCES) + +source_group(Headers FILES ${DATATYPE_ADAPTER_HEADERS}) + +add_library(data_type_adapters + ${DATATYPE_ADAPTER_SOURCES} + ${DATATYPE_ADAPTER_HEADERS} +) + +target_link_libraries(data_type_adapters + PUBLIC + Gnuradio::blocks + data_type_gr_blocks + algorithms_libs + core_system_parameters + PRIVATE + Gflags::gflags + Glog::glog + Volk::volk +) + +target_include_directories(data_type_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(data_type_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET data_type_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/data_type_adapter/adapters/byte_to_short.cc b/src/algorithms/data_type_adapter/adapters/byte_to_short.cc index da842f7b7..b89fec1ed 100644 --- a/src/algorithms/data_type_adapter/adapters/byte_to_short.cc +++ b/src/algorithms/data_type_adapter/adapters/byte_to_short.cc @@ -31,12 +31,14 @@ #include "byte_to_short.h" #include "configuration_interface.h" #include +#include +#include using google::LogMessage; ByteToShort::ByteToShort(ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) + unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(std::move(role)), in_streams_(in_streams), out_streams_(out_streams) { std::string default_input_item_type = "byte"; std::string default_output_item_type = "short"; @@ -49,7 +51,7 @@ ByteToShort::ByteToShort(ConfigurationInterface* configuration, std::string role dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); - size_t item_size = sizeof(short); + size_t item_size = sizeof(int16_t); gr_char_to_short_ = gr::blocks::char_to_short::make(); @@ -60,12 +62,18 @@ ByteToShort::ByteToShort(ConfigurationInterface* configuration, std::string role DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -ByteToShort::~ByteToShort() -{ -} +ByteToShort::~ByteToShort() = default; void ByteToShort::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc index 1e75bccaa..5cfbd4186 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc @@ -36,7 +36,7 @@ using google::LogMessage; -IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string role, +IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) { std::string default_input_item_type = "byte"; @@ -66,12 +66,18 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro { conjugate_ic_ = make_conjugate_ic(); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -IbyteToCbyte::~IbyteToCbyte() -{ -} +IbyteToCbyte::~IbyteToCbyte() = default; void IbyteToCbyte::connect(gr::top_block_sptr top_block) @@ -138,8 +144,5 @@ gr::basic_block_sptr IbyteToCbyte::get_right_block() { return conjugate_ic_; } - else - { - return ibyte_to_cbyte_; - } + return ibyte_to_cbyte_; } diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h index 7f0b83483..3fb202a1a 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h @@ -48,7 +48,7 @@ class IbyteToCbyte : public GNSSBlockInterface { public: IbyteToCbyte(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~IbyteToCbyte(); diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc index 5862ee71d..cd8c14850 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc @@ -34,7 +34,7 @@ using google::LogMessage; -IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::string role, +IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) { std::string default_input_item_type = "byte"; @@ -64,12 +64,18 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -IbyteToComplex::~IbyteToComplex() -{ -} +IbyteToComplex::~IbyteToComplex() = default; void IbyteToComplex::connect(gr::top_block_sptr top_block) @@ -136,8 +142,5 @@ gr::basic_block_sptr IbyteToComplex::get_right_block() { return conjugate_cc_; } - else - { - return gr_interleaved_char_to_complex_; - } + return gr_interleaved_char_to_complex_; } diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h index c768e4b46..9271689bc 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h @@ -34,8 +34,8 @@ #include "conjugate_cc.h" #include "gnss_block_interface.h" #include "gnss_synchro.h" -#include #include +#include #include class ConfigurationInterface; @@ -48,7 +48,7 @@ class IbyteToComplex : public GNSSBlockInterface { public: IbyteToComplex(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~IbyteToComplex(); diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc index 353004f9f..f4c8b6207 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc @@ -37,7 +37,7 @@ using google::LogMessage; -IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string role, +IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) { std::string default_input_item_type = "byte"; @@ -67,12 +67,18 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string { conjugate_sc_ = make_conjugate_sc(); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -IbyteToCshort::~IbyteToCshort() -{ -} +IbyteToCshort::~IbyteToCshort() = default; void IbyteToCshort::connect(gr::top_block_sptr top_block) @@ -135,8 +141,5 @@ gr::basic_block_sptr IbyteToCshort::get_right_block() { return conjugate_sc_; } - else - { - return interleaved_byte_to_complex_short_; - } + return interleaved_byte_to_complex_short_; } diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h index cc94b866f..9e7c5b74b 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h @@ -32,8 +32,8 @@ #define GNSS_SDR_IBYTE_TO_CSHORT_H_ #include "conjugate_sc.h" -#include "interleaved_byte_to_complex_short.h" #include "gnss_block_interface.h" +#include "interleaved_byte_to_complex_short.h" #include #include @@ -48,7 +48,7 @@ class IbyteToCshort : public GNSSBlockInterface { public: IbyteToCshort(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~IbyteToCshort(); diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc index af29494c0..918dbd8a3 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc @@ -34,7 +34,7 @@ using google::LogMessage; -IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::string role, +IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) { std::string default_input_item_type = "short"; @@ -64,12 +64,18 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -IshortToComplex::~IshortToComplex() -{ -} +IshortToComplex::~IshortToComplex() = default; void IshortToComplex::connect(gr::top_block_sptr top_block) @@ -136,8 +142,5 @@ gr::basic_block_sptr IshortToComplex::get_right_block() { return conjugate_cc_; } - else - { - return gr_interleaved_short_to_complex_; - } + return gr_interleaved_short_to_complex_; } diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h index 8a60afa15..73d1133a8 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h @@ -33,8 +33,8 @@ #include "conjugate_cc.h" #include "gnss_block_interface.h" -#include #include +#include #include class ConfigurationInterface; @@ -47,7 +47,7 @@ class IshortToComplex : public GNSSBlockInterface { public: IshortToComplex(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~IshortToComplex(); diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc index 225f0d6a9..c6a7d7490 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc @@ -36,7 +36,7 @@ using google::LogMessage; -IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::string role, +IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) { std::string default_input_item_type = "short"; @@ -66,12 +66,18 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin { conjugate_sc_ = make_conjugate_sc(); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -IshortToCshort::~IshortToCshort() -{ -} +IshortToCshort::~IshortToCshort() = default; void IshortToCshort::connect(gr::top_block_sptr top_block) @@ -138,8 +144,5 @@ gr::basic_block_sptr IshortToCshort::get_right_block() { return conjugate_sc_; } - else - { - return interleaved_short_to_complex_short_; - } + return interleaved_short_to_complex_short_; } diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h index 382ce7716..925065a1d 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h @@ -48,7 +48,7 @@ class IshortToCshort : public GNSSBlockInterface { public: IshortToCshort(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~IshortToCshort(); diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt index 872dabfcf..9090d9c43 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,20 +17,38 @@ # -set(DATA_TYPE_GR_BLOCKS_SOURCES - interleaved_byte_to_complex_byte.cc - interleaved_short_to_complex_short.cc - interleaved_byte_to_complex_short.cc +set(DATA_TYPE_GR_BLOCKS_SOURCES + interleaved_byte_to_complex_byte.cc + interleaved_short_to_complex_short.cc + interleaved_byte_to_complex_short.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} +set(DATA_TYPE_GR_BLOCKS_HEADERS + interleaved_byte_to_complex_byte.h + interleaved_short_to_complex_short.h + interleaved_byte_to_complex_short.h ) -file(GLOB DATA_TYPE_GR_BLOCKS_HEADERS "*.h") list(SORT DATA_TYPE_GR_BLOCKS_HEADERS) -add_library(data_type_gr_blocks ${DATA_TYPE_GR_BLOCKS_SOURCES} ${DATA_TYPE_GR_BLOCKS_HEADERS}) +list(SORT DATA_TYPE_GR_BLOCKS_SOURCES) + source_group(Headers FILES ${DATA_TYPE_GR_BLOCKS_HEADERS}) -target_link_libraries(data_type_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES}) \ No newline at end of file + +add_library(data_type_gr_blocks + ${DATA_TYPE_GR_BLOCKS_SOURCES} + ${DATA_TYPE_GR_BLOCKS_HEADERS} +) + +target_link_libraries(data_type_gr_blocks + PUBLIC + Gnuradio::runtime + Boost::boost + algorithms_libs + PRIVATE + Volk::volk +) + +set_property(TARGET data_type_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc index f41662ed7..c5c854334 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc @@ -54,8 +54,8 @@ int interleaved_byte_to_complex_byte::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const int8_t *in = reinterpret_cast(input_items[0]); - lv_8sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); // This could be put into a Volk kernel int8_t real_part; int8_t imag_part; diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.h b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.h index c9ce17b4a..437d60d4e 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.h +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.h @@ -37,7 +37,7 @@ class interleaved_byte_to_complex_byte; -typedef boost::shared_ptr interleaved_byte_to_complex_byte_sptr; +using interleaved_byte_to_complex_byte_sptr = boost::shared_ptr; interleaved_byte_to_complex_byte_sptr make_interleaved_byte_to_complex_byte(); diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.cc b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.cc index c8b288f9b..b6e5368b8 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.cc +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.cc @@ -54,8 +54,8 @@ int interleaved_byte_to_complex_short::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const int8_t *in = reinterpret_cast(input_items[0]); - lv_16sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); // This could be put into a Volk kernel int8_t real_part; int8_t imag_part; diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.h b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.h index 5eab0f314..0b0fbdf1b 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.h +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_short.h @@ -36,7 +36,7 @@ class interleaved_byte_to_complex_short; -typedef boost::shared_ptr interleaved_byte_to_complex_short_sptr; +using interleaved_byte_to_complex_short_sptr = boost::shared_ptr; interleaved_byte_to_complex_short_sptr make_interleaved_byte_to_complex_short(); diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.cc b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.cc index fe4106ea8..bf88a2ea5 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.cc +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.cc @@ -54,8 +54,8 @@ int interleaved_short_to_complex_short::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const int16_t *in = reinterpret_cast(input_items[0]); - lv_16sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); // This could be put into a Volk kernel int16_t real_part; int16_t imag_part; diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.h b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.h index 10287459a..e31b6ac98 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.h +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_short_to_complex_short.h @@ -36,7 +36,7 @@ class interleaved_short_to_complex_short; -typedef boost::shared_ptr interleaved_short_to_complex_short_sptr; +using interleaved_short_to_complex_short_sptr = boost::shared_ptr; interleaved_short_to_complex_short_sptr make_interleaved_short_to_complex_short(); diff --git a/src/algorithms/input_filter/CMakeLists.txt b/src/algorithms/input_filter/CMakeLists.txt index 64cb2a571..1841d3dfc 100644 --- a/src/algorithms/input_filter/CMakeLists.txt +++ b/src/algorithms/input_filter/CMakeLists.txt @@ -17,4 +17,4 @@ # add_subdirectory(adapters) -add_subdirectory(gnuradio_blocks) \ No newline at end of file +add_subdirectory(gnuradio_blocks) diff --git a/src/algorithms/input_filter/adapters/CMakeLists.txt b/src/algorithms/input_filter/adapters/CMakeLists.txt index f12efd609..8459dea90 100644 --- a/src/algorithms/input_filter/adapters/CMakeLists.txt +++ b/src/algorithms/input_filter/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,30 +16,66 @@ # along with GNSS-SDR. If not, see . # -set(INPUT_FILTER_ADAPTER_SOURCES - fir_filter.cc - freq_xlating_fir_filter.cc - beamformer_filter.cc - pulse_blanking_filter.cc - notch_filter.cc - notch_filter_lite.cc +set(INPUT_FILTER_ADAPTER_SOURCES + fir_filter.cc + freq_xlating_fir_filter.cc + beamformer_filter.cc + pulse_blanking_filter.cc + notch_filter.cc + notch_filter_lite.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} +set(INPUT_FILTER_ADAPTER_HEADERS + fir_filter.h + freq_xlating_fir_filter.h + beamformer_filter.h + pulse_blanking_filter.h + notch_filter.h + notch_filter_lite.h ) -file(GLOB INPUT_FILTER_ADAPTER_HEADERS "*.h") list(SORT INPUT_FILTER_ADAPTER_HEADERS) -add_library(input_filter_adapters ${INPUT_FILTER_ADAPTER_SOURCES} ${INPUT_FILTER_ADAPTER_HEADERS}) +list(SORT INPUT_FILTER_ADAPTER_SOURCES) + source_group(Headers FILES ${INPUT_FILTER_ADAPTER_HEADERS}) -add_dependencies(input_filter_adapters glog-${glog_RELEASE} gnss_sp_libs) -target_link_libraries(input_filter_adapters input_filter_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES} gnss_sp_libs) + +add_library(input_filter_adapters + ${INPUT_FILTER_ADAPTER_SOURCES} + ${INPUT_FILTER_ADAPTER_HEADERS} +) + +target_link_libraries(input_filter_adapters + PUBLIC + Gnuradio::blocks + Gnuradio::filter + input_filter_gr_blocks + algorithms_libs + PRIVATE + Gflags::gflags + Glog::glog + Volk::volk +) + +target_include_directories(input_filter_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13.4") + target_compile_definitions(input_filter_adapters PUBLIC -DGR_GREATER_38=1) +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(input_filter_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET input_filter_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/input_filter/adapters/beamformer_filter.cc b/src/algorithms/input_filter/adapters/beamformer_filter.cc index f65034325..dae0d1386 100644 --- a/src/algorithms/input_filter/adapters/beamformer_filter.cc +++ b/src/algorithms/input_filter/adapters/beamformer_filter.cc @@ -38,7 +38,7 @@ using google::LogMessage; BeamformerFilter::BeamformerFilter( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream) : role_(role), in_stream_(in_stream), out_stream_(out_stream) { std::string default_item_type = "gr_complex"; @@ -48,7 +48,7 @@ BeamformerFilter::BeamformerFilter( DLOG(INFO) << "dump_ is " << dump_; dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); beamformer_ = make_beamformer(); @@ -67,11 +67,19 @@ BeamformerFilter::BeamformerFilter( file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } - samples_ = 0; + samples_ = 0ULL; + if (in_stream_ > 8) + { + LOG(ERROR) << "This implementation only supports eight input streams"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -BeamformerFilter::~BeamformerFilter() {} +BeamformerFilter::~BeamformerFilter() = default; void BeamformerFilter::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/input_filter/adapters/beamformer_filter.h b/src/algorithms/input_filter/adapters/beamformer_filter.h index 78fec45ca..89df25223 100644 --- a/src/algorithms/input_filter/adapters/beamformer_filter.h +++ b/src/algorithms/input_filter/adapters/beamformer_filter.h @@ -34,6 +34,7 @@ #include "gnss_block_interface.h" #include +#include #include class ConfigurationInterface; @@ -46,7 +47,7 @@ class BeamformerFilter : public GNSSBlockInterface { public: BeamformerFilter(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream); virtual ~BeamformerFilter(); @@ -78,7 +79,7 @@ private: unsigned int out_stream_; std::string item_type_; size_t item_size_; - unsigned long long samples_; + uint64_t samples_; bool dump_; std::string dump_filename_; gr::block_sptr beamformer_; diff --git a/src/algorithms/input_filter/adapters/fir_filter.cc b/src/algorithms/input_filter/adapters/fir_filter.cc index 13775e2a1..48dfb4871 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.cc +++ b/src/algorithms/input_filter/adapters/fir_filter.cc @@ -31,20 +31,20 @@ #include "fir_filter.h" #include "configuration_interface.h" -#include -#include #include +#include #include +#include using google::LogMessage; FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) + unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(std::move(role)), in_streams_(in_streams), out_streams_(out_streams) { size_t item_size; (*this).init(); - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { item_size = sizeof(gr_complex); fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(1, taps_); @@ -55,7 +55,7 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("cshort") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "cshort")) { item_size = sizeof(lv_16sc_t); cshort_to_float_x2_ = make_cshort_to_float_x2(); @@ -72,7 +72,7 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) { item_size = sizeof(gr_complex); cshort_to_float_x2_ = make_cshort_to_float_x2(); @@ -88,7 +88,7 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) { item_size = sizeof(gr_complex); cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); @@ -106,7 +106,7 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("cbyte") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) { item_size = sizeof(lv_8sc_t); cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); @@ -131,17 +131,23 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, { LOG(ERROR) << " Unknown item type conversion"; } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -FirFilter::~FirFilter() -{ -} +FirFilter::~FirFilter() = default; void FirFilter::connect(gr::top_block_sptr top_block) { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { if (dump_) { @@ -152,7 +158,7 @@ void FirFilter::connect(gr::top_block_sptr top_block) DLOG(INFO) << "Nothing to connect internally"; } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("cshort") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "cshort")) { top_block->connect(cshort_to_float_x2_, 0, fir_filter_fff_1_, 0); top_block->connect(cshort_to_float_x2_, 1, fir_filter_fff_2_, 0); @@ -165,7 +171,7 @@ void FirFilter::connect(gr::top_block_sptr top_block) top_block->connect(short_x2_to_cshort_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) { top_block->connect(cbyte_to_float_x2_, 0, fir_filter_fff_1_, 0); top_block->connect(cbyte_to_float_x2_, 1, fir_filter_fff_2_, 0); @@ -176,7 +182,7 @@ void FirFilter::connect(gr::top_block_sptr top_block) top_block->connect(float_to_complex_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("cbyte") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) { top_block->connect(cbyte_to_float_x2_, 0, fir_filter_fff_1_, 0); top_block->connect(cbyte_to_float_x2_, 1, fir_filter_fff_2_, 0); @@ -189,7 +195,7 @@ void FirFilter::connect(gr::top_block_sptr top_block) top_block->connect(char_x2_cbyte_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) { top_block->connect(cshort_to_float_x2_, 0, fir_filter_fff_1_, 0); top_block->connect(cshort_to_float_x2_, 1, fir_filter_fff_2_, 0); @@ -209,14 +215,14 @@ void FirFilter::connect(gr::top_block_sptr top_block) void FirFilter::disconnect(gr::top_block_sptr top_block) { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { if (dump_) { top_block->disconnect(fir_filter_ccf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) { top_block->disconnect(fir_filter_fff_2_, 0, float_to_complex_, 1); top_block->disconnect(fir_filter_fff_1_, 0, float_to_complex_, 0); @@ -227,7 +233,7 @@ void FirFilter::disconnect(gr::top_block_sptr top_block) top_block->disconnect(float_to_complex_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("cshort") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "cshort")) { top_block->disconnect(cshort_to_float_x2_, 0, fir_filter_fff_1_, 0); top_block->disconnect(cshort_to_float_x2_, 1, fir_filter_fff_2_, 0); @@ -240,7 +246,7 @@ void FirFilter::disconnect(gr::top_block_sptr top_block) top_block->disconnect(short_x2_to_cshort_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("cbyte") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) { top_block->disconnect(float_to_char_2_, 0, char_x2_cbyte_, 1); top_block->disconnect(float_to_char_1_, 0, char_x2_cbyte_, 0); @@ -253,7 +259,7 @@ void FirFilter::disconnect(gr::top_block_sptr top_block) top_block->disconnect(char_x2_cbyte_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) { top_block->disconnect(cshort_to_float_x2_, 0, fir_filter_fff_1_, 0); top_block->disconnect(cshort_to_float_x2_, 1, fir_filter_fff_2_, 0); @@ -273,61 +279,55 @@ void FirFilter::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr FirFilter::get_left_block() { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { return fir_filter_ccf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("cshort") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "cshort")) { return cshort_to_float_x2_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) { return cbyte_to_float_x2_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("cbyte") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) { return cbyte_to_float_x2_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) { return cshort_to_float_x2_; } - else - { - return nullptr; - LOG(ERROR) << " Unknown item type conversion"; - } + LOG(WARNING) << "Unknown item type conversion"; + return nullptr; } gr::basic_block_sptr FirFilter::get_right_block() { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { return fir_filter_ccf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("cshort") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "cshort")) { return short_x2_to_cshort_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) { return float_to_complex_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0) && (output_item_type_.compare("cbyte") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) { return char_x2_cbyte_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) { return float_to_complex_; } - else - { - return nullptr; - LOG(ERROR) << " unknown input filter item type"; - } + LOG(WARNING) << "Unknown input filter taps item type"; + return nullptr; } @@ -362,23 +362,23 @@ void FirFilter::init() double option_value; for (unsigned int i = 0; i < number_of_bands; i++) { - option = ".band" + boost::lexical_cast(i + 1) + "_begin"; + option = ".band" + std::to_string(i + 1) + "_begin"; option_value = config_->property(role_ + option, default_bands[i]); bands.push_back(option_value); - option = ".band" + boost::lexical_cast(i + 1) + "_end"; + option = ".band" + std::to_string(i + 1) + "_end"; option_value = config_->property(role_ + option, default_bands[i]); bands.push_back(option_value); - option = ".ampl" + boost::lexical_cast(i + 1) + "_begin"; + option = ".ampl" + std::to_string(i + 1) + "_begin"; option_value = config_->property(role_ + option, default_bands[i]); ampl.push_back(option_value); - option = ".ampl" + boost::lexical_cast(i + 1) + "_end"; + option = ".ampl" + std::to_string(i + 1) + "_end"; option_value = config_->property(role_ + option, default_bands[i]); ampl.push_back(option_value); - option = ".band" + boost::lexical_cast(i + 1) + "_error"; + option = ".band" + std::to_string(i + 1) + "_error"; option_value = config_->property(role_ + option, default_bands[i]); error_w.push_back(option_value); } @@ -392,8 +392,8 @@ void FirFilter::init() // those bands, and the weight given to the error in those bands. std::vector taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); taps_.reserve(taps_d.size()); - for (std::vector::iterator it = taps_d.begin(); it != taps_d.end(); it++) + for (double& it : taps_d) { - taps_.push_back(float(*it)); + taps_.push_back(float(it)); } } diff --git a/src/algorithms/input_filter/adapters/fir_filter.h b/src/algorithms/input_filter/adapters/fir_filter.h index 05c494b5f..85626f2cc 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.h +++ b/src/algorithms/input_filter/adapters/fir_filter.h @@ -33,18 +33,22 @@ #ifndef GNSS_SDR_FIR_FILTER_H_ #define GNSS_SDR_FIR_FILTER_H_ -#include "gnss_block_interface.h" -#include "complex_byte_to_float_x2.h" #include "byte_x2_to_complex_byte.h" -#include "short_x2_to_cshort.h" +#include "complex_byte_to_float_x2.h" #include "cshort_to_float_x2.h" -#include +#include "gnss_block_interface.h" +#include "short_x2_to_cshort.h" #include #include #include #include +#include +#ifdef GR_GREATER_38 +#include +#else #include #include +#endif #include #include #include diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc index 8503b8ce0..17ab25dab 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc @@ -31,70 +31,144 @@ #include "freq_xlating_fir_filter.h" #include "configuration_interface.h" -#include -#include -#include -#include #include +#include +#include +#include #include +#include using google::LogMessage; FreqXlatingFirFilter::FreqXlatingFirFilter(ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) + unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(std::move(role)), in_streams_(in_streams), out_streams_(out_streams) { - size_t item_size; - (*this).init(); - int decimation_factor; + std::string default_input_item_type = "gr_complex"; + std::string default_output_item_type = "gr_complex"; + std::string default_taps_item_type = "float"; + std::string default_dump_filename = "../data/input_filter.dat"; + double default_intermediate_freq = 0.0; + double default_sampling_freq = 4000000.0; + int default_number_of_taps = 6; + unsigned int default_number_of_bands = 2; + std::vector default_bands = {0.0, 0.4, 0.6, 1.0}; + std::vector default_ampl = {1.0, 1.0, 0.0, 0.0}; + std::vector default_error_w = {1.0, 1.0}; + std::string default_filter_type = "bandpass"; + int default_grid_density = 16; int default_decimation_factor = 1; - decimation_factor = config_->property(role_ + ".decimation_factor", default_decimation_factor); - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + DLOG(INFO) << "role " << role_; + + input_item_type_ = config_->property(role_ + ".input_item_type", default_input_item_type); + output_item_type_ = config_->property(role_ + ".output_item_type", default_output_item_type); + taps_item_type_ = config_->property(role_ + ".taps_item_type", default_taps_item_type); + dump_ = config_->property(role_ + ".dump", false); + dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + intermediate_freq_ = config_->property(role_ + ".IF", default_intermediate_freq); + sampling_freq_ = config_->property(role_ + ".sampling_frequency", default_sampling_freq); + int number_of_taps = config_->property(role_ + ".number_of_taps", default_number_of_taps); + unsigned int number_of_bands = config_->property(role_ + ".number_of_bands", default_number_of_bands); + std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type); + decimation_factor_ = config_->property(role_ + ".decimation_factor", default_decimation_factor); + + if (filter_type != "lowpass") + { + std::vector taps_d; + std::vector bands; + std::vector ampl; + std::vector error_w; + std::string option; + double option_value; + + for (unsigned int i = 0; i < number_of_bands; i++) + { + option = ".band" + std::to_string(i + 1) + "_begin"; + option_value = config_->property(role_ + option, default_bands[i]); + bands.push_back(option_value); + + option = ".band" + std::to_string(i + 1) + "_end"; + option_value = config_->property(role_ + option, default_bands[i]); + bands.push_back(option_value); + + option = ".ampl" + std::to_string(i + 1) + "_begin"; + option_value = config_->property(role_ + option, default_bands[i]); + ampl.push_back(option_value); + + option = ".ampl" + std::to_string(i + 1) + "_end"; + option_value = config_->property(role_ + option, default_bands[i]); + ampl.push_back(option_value); + + option = ".band" + std::to_string(i + 1) + "_error"; + option_value = config_->property(role_ + option, default_bands[i]); + error_w.push_back(option_value); + } + + int grid_density = config_->property(role_ + ".grid_density", default_grid_density); + taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); + taps_.reserve(taps_d.size()); + for (double& it : taps_d) + { + taps_.push_back(static_cast(it)); + } + } + else + { + double default_bw = (sampling_freq_ / decimation_factor_) / 2; + double bw_ = config_->property(role_ + ".bw", default_bw); + double default_tw = bw_ / 10.0; + double tw_ = config_->property(role_ + ".tw", default_tw); + taps_ = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_, tw_); + } + + size_t item_size; + + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { item_size = sizeof(gr_complex); //output input_size_ = sizeof(gr_complex); //input - freq_xlating_fir_filter_ccf_ = gr::filter::freq_xlating_fir_filter_ccf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_); + freq_xlating_fir_filter_ccf_ = gr::filter::freq_xlating_fir_filter_ccf::make(decimation_factor_, taps_, intermediate_freq_, sampling_freq_); DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_ccf_->unique_id() << ")"; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "float") && (output_item_type_ == "gr_complex")) { item_size = sizeof(gr_complex); input_size_ = sizeof(float); //input - freq_xlating_fir_filter_fcf_ = gr::filter::freq_xlating_fir_filter_fcf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_); + freq_xlating_fir_filter_fcf_ = gr::filter::freq_xlating_fir_filter_fcf::make(decimation_factor_, taps_, intermediate_freq_, sampling_freq_); DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_fcf_->unique_id() << ")"; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) { item_size = sizeof(gr_complex); input_size_ = sizeof(int16_t); //input - freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_); + freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor_, taps_, intermediate_freq_, sampling_freq_); DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")"; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("cshort") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) { item_size = sizeof(lv_16sc_t); input_size_ = sizeof(int16_t); //input - freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_); + freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor_, taps_, intermediate_freq_, sampling_freq_); DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")"; complex_to_float_ = gr::blocks::complex_to_float::make(); float_to_short_1_ = gr::blocks::float_to_short::make(); float_to_short_2_ = gr::blocks::float_to_short::make(); short_x2_to_cshort_ = make_short_x2_to_cshort(); } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) { item_size = sizeof(gr_complex); input_size_ = sizeof(int8_t); //input gr_char_to_short_ = gr::blocks::char_to_short::make(); - freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_); + freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor_, taps_, intermediate_freq_, sampling_freq_); DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")"; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("cbyte") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "cbyte")) { item_size = sizeof(lv_8sc_t); input_size_ = sizeof(int8_t); //input gr_char_to_short_ = gr::blocks::char_to_short::make(); - freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_); + freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor_, taps_, intermediate_freq_, sampling_freq_); DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")"; complex_to_complex_byte_ = make_complex_float_to_complex_byte(); } @@ -111,38 +185,44 @@ FreqXlatingFirFilter::FreqXlatingFirFilter(ConfigurationInterface* configuration std::cout << "Dumping output into file " << dump_filename_ << std::endl; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -FreqXlatingFirFilter::~FreqXlatingFirFilter() -{ -} +FreqXlatingFirFilter::~FreqXlatingFirFilter() = default; void FreqXlatingFirFilter::connect(gr::top_block_sptr top_block) { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { if (dump_) { top_block->connect(freq_xlating_fir_filter_ccf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "float") && (output_item_type_ == "gr_complex")) { if (dump_) { top_block->connect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) { if (dump_) { top_block->connect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("cshort") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) { top_block->connect(freq_xlating_fir_filter_scf_, 0, complex_to_float_, 0); top_block->connect(complex_to_float_, 0, float_to_short_1_, 0); @@ -154,7 +234,7 @@ void FreqXlatingFirFilter::connect(gr::top_block_sptr top_block) top_block->connect(short_x2_to_cshort_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) { top_block->connect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0); if (dump_) @@ -162,7 +242,7 @@ void FreqXlatingFirFilter::connect(gr::top_block_sptr top_block) top_block->connect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("cbyte") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "cbyte")) { top_block->connect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0); top_block->connect(freq_xlating_fir_filter_scf_, 0, complex_to_complex_byte_, 0); @@ -180,28 +260,28 @@ void FreqXlatingFirFilter::connect(gr::top_block_sptr top_block) void FreqXlatingFirFilter::disconnect(gr::top_block_sptr top_block) { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { if (dump_) { top_block->disconnect(freq_xlating_fir_filter_ccf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "float") && (output_item_type_ == "gr_complex")) { if (dump_) { top_block->disconnect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) { if (dump_) { top_block->disconnect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("cshort") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) { top_block->disconnect(freq_xlating_fir_filter_scf_, 0, complex_to_float_, 0); top_block->disconnect(complex_to_float_, 0, float_to_short_1_, 0); @@ -213,7 +293,7 @@ void FreqXlatingFirFilter::disconnect(gr::top_block_sptr top_block) top_block->disconnect(short_x2_to_cshort_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) { top_block->disconnect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0); if (dump_) @@ -221,7 +301,7 @@ void FreqXlatingFirFilter::disconnect(gr::top_block_sptr top_block) top_block->disconnect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0); } } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("cbyte") == 0)) + else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "cbyte")) { top_block->disconnect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0); top_block->disconnect(freq_xlating_fir_filter_scf_, 0, complex_to_complex_byte_, 0); @@ -239,27 +319,27 @@ void FreqXlatingFirFilter::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr FreqXlatingFirFilter::get_left_block() { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_ccf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "float") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_fcf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_scf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("cshort") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) { return freq_xlating_fir_filter_scf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) { return gr_char_to_short_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("cbyte") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "cbyte")) { return gr_char_to_short_; } @@ -273,27 +353,27 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_left_block() gr::basic_block_sptr FreqXlatingFirFilter::get_right_block() { - if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_ccf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "float") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_fcf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_scf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0) && (output_item_type_.compare("cshort") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) { return short_x2_to_cshort_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("gr_complex") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_scf_; } - else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0) && (output_item_type_.compare("cbyte") == 0)) + if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "cbyte")) { return complex_to_complex_byte_; } @@ -303,83 +383,3 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_right_block() LOG(ERROR) << " Unknown input filter input/output item type conversion"; } } - - -void FreqXlatingFirFilter::init() -{ - std::string default_input_item_type = "gr_complex"; - std::string default_output_item_type = "gr_complex"; - std::string default_taps_item_type = "float"; - std::string default_dump_filename = "../data/input_filter.dat"; - double default_intermediate_freq = 0.0; - double default_sampling_freq = 4000000.0; - int default_number_of_taps = 6; - unsigned int default_number_of_bands = 2; - std::vector default_bands = {0.0, 0.4, 0.6, 1.0}; - std::vector default_ampl = {1.0, 1.0, 0.0, 0.0}; - std::vector default_error_w = {1.0, 1.0}; - std::string default_filter_type = "bandpass"; - int default_grid_density = 16; - - DLOG(INFO) << "role " << role_; - - input_item_type_ = config_->property(role_ + ".input_item_type", default_input_item_type); - output_item_type_ = config_->property(role_ + ".output_item_type", default_output_item_type); - taps_item_type_ = config_->property(role_ + ".taps_item_type", default_taps_item_type); - dump_ = config_->property(role_ + ".dump", false); - dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); - intermediate_freq_ = config_->property(role_ + ".IF", default_intermediate_freq); - sampling_freq_ = config_->property(role_ + ".sampling_frequency", default_sampling_freq); - int number_of_taps = config_->property(role_ + ".number_of_taps", default_number_of_taps); - unsigned int number_of_bands = config_->property(role_ + ".number_of_bands", default_number_of_bands); - std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type); - - if (filter_type.compare("lowpass") != 0) - { - std::vector taps_d; - std::vector bands; - std::vector ampl; - std::vector error_w; - std::string option; - double option_value; - - for (unsigned int i = 0; i < number_of_bands; i++) - { - option = ".band" + boost::lexical_cast(i + 1) + "_begin"; - option_value = config_->property(role_ + option, default_bands[i]); - bands.push_back(option_value); - - option = ".band" + boost::lexical_cast(i + 1) + "_end"; - option_value = config_->property(role_ + option, default_bands[i]); - bands.push_back(option_value); - - option = ".ampl" + boost::lexical_cast(i + 1) + "_begin"; - option_value = config_->property(role_ + option, default_bands[i]); - ampl.push_back(option_value); - - option = ".ampl" + boost::lexical_cast(i + 1) + "_end"; - option_value = config_->property(role_ + option, default_bands[i]); - ampl.push_back(option_value); - - option = ".band" + boost::lexical_cast(i + 1) + "_error"; - option_value = config_->property(role_ + option, default_bands[i]); - error_w.push_back(option_value); - } - - int grid_density = config_->property(role_ + ".grid_density", default_grid_density); - taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); - taps_.reserve(taps_d.size()); - for (std::vector::iterator it = taps_d.begin(); it != taps_d.end(); it++) - { - taps_.push_back(static_cast(*it)); - } - } - else - { - double default_bw = 2000000.0; - double bw_ = config_->property(role_ + ".bw", default_bw); - double default_tw = bw_ / 10.0; - double tw_ = config_->property(role_ + ".tw", default_tw); - taps_ = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_, tw_); - } -} diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h index d7549d9ab..fad4f89cd 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h @@ -33,15 +33,19 @@ #ifndef GNSS_SDR_FREQ_XLATING_FIR_FILTER_H_ #define GNSS_SDR_FREQ_XLATING_FIR_FILTER_H_ +#include "complex_float_to_complex_byte.h" #include "gnss_block_interface.h" #include "short_x2_to_cshort.h" -#include "complex_float_to_complex_byte.h" +#ifdef GR_GREATER_38 +#include +#else #include #include #include -#include -#include +#endif #include +#include +#include #include #include #include @@ -95,6 +99,7 @@ private: gr::filter::freq_xlating_fir_filter_fcf::sptr freq_xlating_fir_filter_fcf_; gr::filter::freq_xlating_fir_filter_scf::sptr freq_xlating_fir_filter_scf_; ConfigurationInterface* config_; + int decimation_factor_; bool dump_; std::string dump_filename_; std::string input_item_type_; @@ -114,7 +119,6 @@ private: gr::blocks::float_to_short::sptr float_to_short_2_; short_x2_to_cshort_sptr short_x2_to_cshort_; complex_float_to_complex_byte_sptr complex_to_complex_byte_; - void init(); }; #endif // GNSS_SDR_FREQ_XLATING_FIR_FILTER_H_ diff --git a/src/algorithms/input_filter/adapters/notch_filter.cc b/src/algorithms/input_filter/adapters/notch_filter.cc index a83372d17..c9264e0f7 100644 --- a/src/algorithms/input_filter/adapters/notch_filter.cc +++ b/src/algorithms/input_filter/adapters/notch_filter.cc @@ -38,7 +38,7 @@ using google::LogMessage; -NotchFilter::NotchFilter(ConfigurationInterface* configuration, std::string role, +NotchFilter::NotchFilter(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { size_t item_size_; @@ -63,7 +63,7 @@ NotchFilter::NotchFilter(ConfigurationInterface* configuration, std::string role length_ = configuration->property(role + ".length", default_length_); n_segments_est = configuration->property(role + ".segments_est", default_n_segments_est); n_segments_reset = configuration->property(role + ".segments_reset", default_n_segments_reset); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); notch_filter_ = make_notch_filter(pfa, p_c_factor, length_, n_segments_est, n_segments_reset); @@ -81,12 +81,18 @@ NotchFilter::NotchFilter(ConfigurationInterface* configuration, std::string role file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -NotchFilter::~NotchFilter() -{ -} +NotchFilter::~NotchFilter() = default; void NotchFilter::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/input_filter/adapters/notch_filter.h b/src/algorithms/input_filter/adapters/notch_filter.h index 3bdf5c688..c0e1f9510 100644 --- a/src/algorithms/input_filter/adapters/notch_filter.h +++ b/src/algorithms/input_filter/adapters/notch_filter.h @@ -33,8 +33,8 @@ #ifndef GNSS_SDR_NOTCH_FILTER_H_ #define GNSS_SDR_NOTCH_FILTER_H_ -#include "notch_cc.h" #include "gnss_block_interface.h" +#include "notch_cc.h" #include #include #include @@ -45,7 +45,7 @@ class NotchFilter : public GNSSBlockInterface { public: NotchFilter(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~NotchFilter(); diff --git a/src/algorithms/input_filter/adapters/notch_filter_lite.cc b/src/algorithms/input_filter/adapters/notch_filter_lite.cc index dea6ec7c7..3c83369d5 100644 --- a/src/algorithms/input_filter/adapters/notch_filter_lite.cc +++ b/src/algorithms/input_filter/adapters/notch_filter_lite.cc @@ -38,7 +38,7 @@ using google::LogMessage; -NotchFilterLite::NotchFilterLite(ConfigurationInterface* configuration, std::string role, +NotchFilterLite::NotchFilterLite(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { size_t item_size_; @@ -70,7 +70,7 @@ NotchFilterLite::NotchFilterLite(ConfigurationInterface* configuration, std::str n_segments_reset = configuration->property(role + ".segments_reset", default_n_segments_reset); int n_segments_coeff = static_cast((samp_freq / coeff_rate) / static_cast(length_)); n_segments_coeff = std::max(1, n_segments_coeff); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); notch_filter_lite_ = make_notch_filter_lite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff); @@ -88,12 +88,18 @@ NotchFilterLite::NotchFilterLite(ConfigurationInterface* configuration, std::str file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -NotchFilterLite::~NotchFilterLite() -{ -} +NotchFilterLite::~NotchFilterLite() = default; void NotchFilterLite::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/input_filter/adapters/notch_filter_lite.h b/src/algorithms/input_filter/adapters/notch_filter_lite.h index 901326579..d8352706d 100644 --- a/src/algorithms/input_filter/adapters/notch_filter_lite.h +++ b/src/algorithms/input_filter/adapters/notch_filter_lite.h @@ -45,7 +45,7 @@ class NotchFilterLite : public GNSSBlockInterface { public: NotchFilterLite(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~NotchFilterLite(); diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index 031a0a035..fffdefe9f 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -33,13 +33,14 @@ #include #include #include -#include #include +#include +#include using google::LogMessage; PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(role), in_streams_(in_streams), out_streams_(out_streams) + unsigned int in_streams, unsigned int out_streams) : config_(configuration), role_(std::move(role)), in_streams_(in_streams), out_streams_(out_streams) { size_t item_size; xlat_ = false; @@ -61,7 +62,7 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, int n_segments_est = config_->property(role_ + ".segments_est", default_n_segments_est); int default_n_segments_reset = 5000000; int n_segments_reset = config_->property(role_ + ".segments_reset", default_n_segments_reset); - if (input_item_type_.compare("gr_complex") == 0) + if (input_item_type_ == "gr_complex") { item_size = sizeof(gr_complex); //output input_size_ = sizeof(gr_complex); //input @@ -94,17 +95,23 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, std::cout << "Dumping output into file " << dump_filename_ << std::endl; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -PulseBlankingFilter::~PulseBlankingFilter() -{ -} +PulseBlankingFilter::~PulseBlankingFilter() = default; void PulseBlankingFilter::connect(gr::top_block_sptr top_block) { - if (input_item_type_.compare("gr_complex") == 0) + if (input_item_type_ == "gr_complex") { if (dump_) { @@ -125,7 +132,7 @@ void PulseBlankingFilter::connect(gr::top_block_sptr top_block) void PulseBlankingFilter::disconnect(gr::top_block_sptr top_block) { - if (input_item_type_.compare("gr_complex") == 0) + if (input_item_type_ == "gr_complex") { if (dump_) { @@ -145,34 +152,25 @@ void PulseBlankingFilter::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr PulseBlankingFilter::get_left_block() { - if (input_item_type_.compare("gr_complex") == 0) + if (input_item_type_ == "gr_complex") { if (xlat_) { return freq_xlating_; } - else - { - return pulse_blanking_cc_; - } - } - else - { - return nullptr; - LOG(ERROR) << " Unknown input filter input/output item type conversion"; + return pulse_blanking_cc_; } + LOG(ERROR) << " Unknown input filter input/output item type conversion"; + return nullptr; } gr::basic_block_sptr PulseBlankingFilter::get_right_block() { - if (input_item_type_.compare("gr_complex") == 0) + if (input_item_type_ == "gr_complex") { return pulse_blanking_cc_; } - else - { - return nullptr; - LOG(ERROR) << " Unknown input filter input/output item type conversion"; - } + LOG(ERROR) << " Unknown input filter input/output item type conversion"; + return nullptr; } diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h index 0d9d17cb4..87f8c4994 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h @@ -35,7 +35,11 @@ #include "gnss_block_interface.h" #include "pulse_blanking_cc.h" #include +#ifdef GR_GREATER_38 +#include +#else #include +#endif #include class ConfigurationInterface; diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index 698c828dd..e45410533 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -18,30 +18,47 @@ set(INPUT_FILTER_GR_BLOCKS_SOURCES - beamformer.cc - pulse_blanking_cc.cc - notch_cc.cc - notch_lite_cc.cc + beamformer.cc + pulse_blanking_cc.cc + notch_cc.cc + notch_lite_cc.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${GNURADIO_BLOCKS_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} +set(INPUT_FILTER_GR_BLOCKS_HEADERS + beamformer.h + pulse_blanking_cc.h + notch_cc.h + notch_lite_cc.h ) -file(GLOB INPUT_FILTER_GR_BLOCKS_HEADERS "*.h") list(SORT INPUT_FILTER_GR_BLOCKS_HEADERS) -add_library(input_filter_gr_blocks ${INPUT_FILTER_GR_BLOCKS_SOURCES} ${INPUT_FILTER_GR_BLOCKS_HEADERS}) +list(SORT INPUT_FILTER_GR_BLOCKS_SOURCES) + source_group(Headers FILES ${INPUT_FILTER_GR_BLOCKS_HEADERS}) -target_link_libraries(input_filter_gr_blocks ${GNURADIO_FILTER_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${LOG4CPP_LIBRARIES}) +add_library(input_filter_gr_blocks + ${INPUT_FILTER_GR_BLOCKS_SOURCES} + ${INPUT_FILTER_GR_BLOCKS_HEADERS}) -if(NOT VOLK_GNSSSDR_FOUND) - add_dependencies(input_filter_gr_blocks volk_gnsssdr_module glog-${glog_RELEASE}) -else(NOT VOLK_GNSSSDR_FOUND) - add_dependencies(input_filter_gr_blocks glog-${glog_RELEASE}) -endif(NOT VOLK_GNSSSDR_FOUND) +target_link_libraries(input_filter_gr_blocks + PUBLIC + Gnuradio::blocks + Gnuradio::filter + Volkgnsssdr::volkgnsssdr + PRIVATE + Log4cpp::log4cpp +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(input_filter_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET input_filter_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc b/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc index afd217338..6f53c6099 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc @@ -49,7 +49,7 @@ beamformer::beamformer() { //initialize weight vector - if (posix_memalign((void **)&weight_vector, 16, GNSS_SDR_BEAMFORMER_CHANNELS * sizeof(gr_complex)) == 0) + if (posix_memalign(reinterpret_cast(&weight_vector), 16, GNSS_SDR_BEAMFORMER_CHANNELS * sizeof(gr_complex)) == 0) { }; @@ -69,7 +69,7 @@ beamformer::~beamformer() int beamformer::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr_complex *out = reinterpret_cast(output_items[0]); + auto *out = reinterpret_cast(output_items[0]); // channel output buffers // gr_complex *ch1 = (gr_complex *) input_items[0]; // gr_complex *ch2 = (gr_complex *) input_items[1]; diff --git a/src/algorithms/input_filter/gnuradio_blocks/beamformer.h b/src/algorithms/input_filter/gnuradio_blocks/beamformer.h index 8236b11d3..6fc126272 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/beamformer.h +++ b/src/algorithms/input_filter/gnuradio_blocks/beamformer.h @@ -34,7 +34,7 @@ #include class beamformer; -typedef boost::shared_ptr beamformer_sptr; +using beamformer_sptr = boost::shared_ptr; beamformer_sptr make_beamformer(); diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc index 5e7870cd4..dee531eaf 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc @@ -30,16 +30,14 @@ #include "notch_cc.h" #include -#include #include #include -#include #include +#include -using google::LogMessage; notch_sptr make_notch_filter(float pfa, float p_c_factor, - int length_, int n_segments_est, int n_segments_reset) + int32_t length_, int32_t n_segments_est, int32_t n_segments_reset) { return notch_sptr(new Notch(pfa, p_c_factor, length_, n_segments_est, n_segments_reset)); } @@ -47,31 +45,31 @@ notch_sptr make_notch_filter(float pfa, float p_c_factor, Notch::Notch(float pfa, float p_c_factor, - int length_, - int n_segments_est, - int n_segments_reset) : gr::block("Notch", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))) + int32_t length_, + int32_t n_segments_est, + int32_t n_segments_reset) : gr::block("Notch", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))) { - const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex); set_alignment(std::max(1, alignment_multiple)); set_history(2); this->pfa = pfa; noise_pow_est = 0.0; - this->p_c_factor = gr_complex(p_c_factor, 0); - this->length_ = length_; //Set the number of samples per segment - filter_state_ = false; //Initial state of the filter - n_deg_fred = 2 * length_; //Number of dregrees of freedom + this->p_c_factor = gr_complex(p_c_factor, 0.0); + this->length_ = length_; // Set the number of samples per segment + filter_state_ = false; // Initial state of the filter + n_deg_fred = 2 * length_; // Number of dregrees of freedom n_segments = 0; this->n_segments_est = n_segments_est; // Set the number of segments for noise power estimation this->n_segments_reset = n_segments_reset; // Set the period (in segments) when the noise power is estimated - z_0 = gr_complex(0, 0); + z_0 = gr_complex(0.0, 0.0); boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); c_samples = static_cast(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); angle_ = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); power_spect = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); - last_out = gr_complex(0, 0); + last_out = gr_complex(0.0, 0.0); d_fft = std::unique_ptr(new gr::fft::fft_complex(length_, true)); } @@ -86,9 +84,9 @@ Notch::~Notch() void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) { - for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) + for (int &aux : ninput_items_required) { - ninput_items_required[aux] = length_; + aux = length_; } } @@ -96,12 +94,12 @@ void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &n int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int index_out = 0; + int32_t index_out = 0; float sig2dB = 0.0; float sig2lin = 0.0; lv_32fc_t dot_prod_; - const gr_complex *in = reinterpret_cast(input_items[0]); - gr_complex *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); in++; while ((index_out + length_) < noutput_items) { @@ -127,7 +125,7 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu } volk_32fc_x2_multiply_conjugate_32fc(c_samples, in, (in - 1), length_); volk_32fc_s32f_atan2_32f(angle_, c_samples, static_cast(1.0), length_); - for (int aux = 0; aux < length_; aux++) + for (int32_t aux = 0; aux < length_; aux++) { z_0 = std::exp(gr_complex(0, 1) * (*(angle_ + aux))); *(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out; diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h index 160494346..186d1feb1 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h @@ -34,14 +34,15 @@ #include #include #include +#include #include class Notch; -typedef boost::shared_ptr notch_sptr; +using notch_sptr = boost::shared_ptr; notch_sptr make_notch_filter(float pfa, float p_c_factor, - int length_, int n_segments_est, int n_segments_reset); + int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); /*! * \brief This class implements a real-time software-defined multi state notch filter @@ -53,11 +54,11 @@ private: float pfa; float noise_pow_est; float thres_; - int length_; - int n_deg_fred; - unsigned int n_segments; - unsigned int n_segments_est; - unsigned int n_segments_reset; + int32_t length_; + int32_t n_deg_fred; + uint32_t n_segments; + uint32_t n_segments_est; + uint32_t n_segments_reset; bool filter_state_; gr_complex last_out; gr_complex z_0; @@ -68,7 +69,7 @@ private: std::unique_ptr d_fft; public: - Notch(float pfa, float p_c_factor, int length_, int n_segments_est, int n_segments_reset); + Notch(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); ~Notch(); diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc index 41d684a2a..d73b5cbb8 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc @@ -30,15 +30,13 @@ #include "notch_lite_cc.h" #include -#include #include #include -#include #include +#include -using google::LogMessage; -notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff) +notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff) { return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff)); } @@ -46,17 +44,17 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, NotchLite::NotchLite(float p_c_factor, float pfa, - int length_, - int n_segments_est, - int n_segments_reset, - int n_segments_coeff) : gr::block("NotchLite", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))) + int32_t length_, + int32_t n_segments_est, + int32_t n_segments_reset, + int32_t n_segments_coeff) : gr::block("NotchLite", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))) { - const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex); set_alignment(std::max(1, alignment_multiple)); set_history(2); - this->p_c_factor = gr_complex(p_c_factor, 0); + this->p_c_factor = gr_complex(p_c_factor, 0.0); this->n_segments_est = n_segments_est; this->n_segments_reset = n_segments_reset; this->n_segments_coeff_reset = n_segments_coeff; @@ -68,12 +66,12 @@ NotchLite::NotchLite(float p_c_factor, n_deg_fred = 2 * length_; noise_pow_est = 0.0; filter_state_ = false; - z_0 = gr_complex(0, 0); - last_out = gr_complex(0, 0); + z_0 = gr_complex(0.0, 0.0); + last_out = gr_complex(0.0, 0.0); boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); - c_samples1 = gr_complex(0, 0); - c_samples2 = gr_complex(0, 0); + c_samples1 = gr_complex(0.0, 0.0); + c_samples2 = gr_complex(0.0, 0.0); angle1 = 0.0; angle2 = 0.0; power_spect = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); @@ -89,9 +87,9 @@ NotchLite::~NotchLite() void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) { - for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) + for (int &aux : ninput_items_required) { - ninput_items_required[aux] = length_; + aux = length_; } } @@ -99,12 +97,12 @@ void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_in int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int index_out = 0; + int32_t index_out = 0; float sig2dB = 0.0; float sig2lin = 0.0; lv_32fc_t dot_prod_; - const gr_complex *in = reinterpret_cast(input_items[0]); - gr_complex *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); in++; while ((index_out + length_) < noutput_items) { @@ -138,7 +136,7 @@ int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __att float angle_ = (angle1 + angle2) / 2.0; z_0 = std::exp(gr_complex(0, 1) * angle_); } - for (int aux = 0; aux < length_; aux++) + for (int32_t aux = 0; aux < length_; aux++) { *(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out; last_out = *(out + aux); diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h index 531bedc13..111dd65b0 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h @@ -34,13 +34,14 @@ #include #include #include +#include #include class NotchLite; -typedef boost::shared_ptr notch_lite_sptr; +using notch_lite_sptr = boost::shared_ptr; -notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff); +notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); /*! * \brief This class implements a real-time software-defined multi state notch filter light version @@ -49,13 +50,13 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, class NotchLite : public gr::block { private: - int length_; - int n_segments; - int n_segments_est; - int n_segments_reset; - int n_segments_coeff_reset; - int n_segments_coeff; - int n_deg_fred; + int32_t length_; + int32_t n_segments; + int32_t n_segments_est; + int32_t n_segments_reset; + int32_t n_segments_coeff_reset; + int32_t n_segments_coeff; + int32_t n_deg_fred; float pfa; float thres_; float noise_pow_est; @@ -71,7 +72,7 @@ private: std::unique_ptr d_fft; public: - NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff); + NotchLite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); ~NotchLite(); diff --git a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc index 4a65097d0..593339bc6 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc @@ -30,28 +30,26 @@ #include "pulse_blanking_cc.h" #include -#include #include #include #include -using google::LogMessage; -pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, - int n_segments_est, int n_segments_reset) +pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, + int32_t n_segments_est, int32_t n_segments_reset) { return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset)); } pulse_blanking_cc::pulse_blanking_cc(float pfa, - int length_, - int n_segments_est, - int n_segments_reset) : gr::block("pulse_blanking_cc", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))) + int32_t length_, + int32_t n_segments_est, + int32_t n_segments_reset) : gr::block("pulse_blanking_cc", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))) { - const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex); set_alignment(std::max(1, alignment_multiple)); this->pfa = pfa; this->length_ = length_; @@ -64,9 +62,9 @@ pulse_blanking_cc::pulse_blanking_cc(float pfa, boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); zeros_ = static_cast(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); - for (int aux = 0; aux < length_; aux++) + for (int32_t aux = 0; aux < length_; aux++) { - zeros_[aux] = gr_complex(0, 0); + zeros_[aux] = gr_complex(0.0, 0.0); } } @@ -79,9 +77,9 @@ pulse_blanking_cc::~pulse_blanking_cc() void pulse_blanking_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) { - for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) + for (int &aux : ninput_items_required) { - ninput_items_required[aux] = length_; + aux = length_; } } @@ -89,11 +87,11 @@ void pulse_blanking_cc::forecast(int noutput_items __attribute__((unused)), gr_v int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const gr_complex *in = reinterpret_cast(input_items[0]); - gr_complex *out = reinterpret_cast(output_items[0]); - float *magnitude = static_cast(volk_malloc(noutput_items * sizeof(float), volk_get_alignment())); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); + auto *magnitude = static_cast(volk_malloc(noutput_items * sizeof(float), volk_get_alignment())); volk_32fc_magnitude_squared_32f(magnitude, in, noutput_items); - int sample_index = 0; + int32_t sample_index = 0; float segment_energy; while ((sample_index + length_) < noutput_items) { diff --git a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h index 62e8ee0a7..af5584463 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h @@ -33,22 +33,23 @@ #include #include +#include class pulse_blanking_cc; -typedef boost::shared_ptr pulse_blanking_cc_sptr; +using pulse_blanking_cc_sptr = boost::shared_ptr; -pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset); +pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); class pulse_blanking_cc : public gr::block { private: - int length_; - int n_segments; - int n_segments_est; - int n_segments_reset; - int n_deg_fred; + int32_t length_; + int32_t n_segments; + int32_t n_segments_est; + int32_t n_segments_reset; + int32_t n_deg_fred; bool last_filtered; float noise_power_estimation; float thres_; @@ -56,7 +57,7 @@ private: gr_complex *zeros_; public: - pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset); + pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); ~pulse_blanking_cc(); diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index bdce5d1cf..78878897b 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -18,111 +18,176 @@ add_subdirectory(rtklib) +set(GNSS_SPLIBS_SOURCES + gps_l2c_signal.cc + gps_l5_signal.cc + galileo_e1_signal_processing.cc + gnss_sdr_sample_counter.cc + gnss_signal_processing.cc + gps_sdr_signal_processing.cc + glonass_l1_signal_processing.cc + glonass_l2_signal_processing.cc + pass_through.cc + galileo_e5_signal_processing.cc + beidou_b1i_signal_processing.cc + complex_byte_to_float_x2.cc + byte_x2_to_complex_byte.cc + cshort_to_float_x2.cc + short_x2_to_cshort.cc + complex_float_to_complex_byte.cc + conjugate_cc.cc + conjugate_sc.cc + conjugate_ic.cc + gnss_sdr_create_directory.cc + geofunctions.cc + rtcm.cc +) + +set(GNSS_SPLIBS_HEADERS + gps_l2c_signal.h + gps_l5_signal.h + galileo_e1_signal_processing.h + gnss_sdr_sample_counter.h + gnss_signal_processing.h + gps_sdr_signal_processing.h + glonass_l1_signal_processing.h + glonass_l2_signal_processing.h + pass_through.h + galileo_e5_signal_processing.h + beidou_b1i_signal_processing.h + complex_byte_to_float_x2.h + byte_x2_to_complex_byte.h + cshort_to_float_x2.h + short_x2_to_cshort.h + complex_float_to_complex_byte.h + conjugate_cc.h + conjugate_sc.h + conjugate_ic.h + gnss_sdr_create_directory.h + gnss_circular_deque.h + geofunctions.h + rtcm.h +) + if(ENABLE_FPGA) set(GNSS_SPLIBS_SOURCES - gps_l2c_signal.cc - gps_l5_signal.cc - galileo_e1_signal_processing.cc - gnss_sdr_valve.cc - gnss_sdr_sample_counter.cc + ${GNSS_SPLIBS_SOURCES} gnss_sdr_time_counter.cc - gnss_signal_processing.cc - gps_sdr_signal_processing.cc - glonass_l1_signal_processing.cc - glonass_l2_signal_processing.cc - pass_through.cc - galileo_e5_signal_processing.cc - complex_byte_to_float_x2.cc - byte_x2_to_complex_byte.cc - cshort_to_float_x2.cc - short_x2_to_cshort.cc - complex_float_to_complex_byte.cc - conjugate_cc.cc - conjugate_sc.cc - conjugate_ic.cc - ) -else(ENABLE_FPGA) - set(GNSS_SPLIBS_SOURCES - gps_l2c_signal.cc - gps_l5_signal.cc - galileo_e1_signal_processing.cc - gnss_sdr_valve.cc - gnss_sdr_sample_counter.cc - gnss_signal_processing.cc - gps_sdr_signal_processing.cc - glonass_l1_signal_processing.cc - glonass_l2_signal_processing.cc - pass_through.cc - galileo_e5_signal_processing.cc - complex_byte_to_float_x2.cc - byte_x2_to_complex_byte.cc - cshort_to_float_x2.cc - short_x2_to_cshort.cc - complex_float_to_complex_byte.cc - conjugate_cc.cc - conjugate_sc.cc - conjugate_ic.cc + gnss_sdr_fpga_sample_counter.cc ) -endif(ENABLE_FPGA) + set(GNSS_SPLIBS_HEADERS + ${GNSS_SPLIBS_HEADERS} + gnss_sdr_time_counter.h + gnss_sdr_fpga_sample_counter.h + ) +endif() if(OPENCL_FOUND) set(GNSS_SPLIBS_SOURCES ${GNSS_SPLIBS_SOURCES} - opencl/fft_execute.cc # Needs OpenCL - opencl/fft_setup.cc # Needs OpenCL - opencl/fft_kernelstring.cc # Needs OpenCL - ) -endif(OPENCL_FOUND) + opencl/fft_execute.cc # Needs OpenCL + opencl/fft_setup.cc # Needs OpenCL + opencl/fft_kernelstring.cc # Needs OpenCL + ) +endif() -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${GNURADIO_BLOCKS_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} -) if(OPENCL_FOUND) - include_directories( ${OPENCL_INCLUDE_DIRS} ) + include_directories(${OPENCL_INCLUDE_DIRS}) if(OS_IS_MACOSX) set(OPT_LIBRARIES ${OPT_LIBRARIES} "-framework OpenCL") - else(OS_IS_MACOSX) + else() set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES}) - endif(OS_IS_MACOSX) -endif(OPENCL_FOUND) + endif() +endif() -add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}") - -file(GLOB GNSS_SPLIBS_HEADERS "*.h") -list(REMOVE_ITEM GNSS_SPLIBS_HEADERS gnss_sdr_flags.h) list(SORT GNSS_SPLIBS_HEADERS) -add_library(gnss_sp_libs ${GNSS_SPLIBS_SOURCES} ${GNSS_SPLIBS_HEADERS}) +list(SORT GNSS_SPLIBS_SOURCES) + source_group(Headers FILES ${GNSS_SPLIBS_HEADERS}) -target_link_libraries(gnss_sp_libs ${GNURADIO_RUNTIME_LIBRARIES} - ${VOLK_LIBRARIES} ${ORC_LIBRARIES} - ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} - ${GFlags_LIBS} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FFT_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${OPT_LIBRARIES} - gnss_rx +add_library(algorithms_libs ${GNSS_SPLIBS_SOURCES} ${GNSS_SPLIBS_HEADERS}) + +target_link_libraries(algorithms_libs + PUBLIC + Armadillo::armadillo + Boost::boost + Gflags::gflags + Gnuradio::runtime + Gnuradio::blocks + Volk::volk ${ORC_LIBRARIES} + Volkgnsssdr::volkgnsssdr + core_system_parameters + ${OPT_LIBRARIES} + PRIVATE + Boost::filesystem + Gflags::gflags + Glog::glog ) -if(NOT VOLK_GNSSSDR_FOUND) - add_dependencies(gnss_sp_libs volk_gnsssdr_module) -endif(NOT VOLK_GNSSSDR_FOUND) +target_include_directories(algorithms_libs + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces + ${CMAKE_SOURCE_DIR}/src/core/receiver +) -if(${GFLAGS_GREATER_20}) - add_definitions(-DGFLAGS_GREATER_2_0=1) -endif(${GFLAGS_GREATER_20}) +target_compile_definitions(algorithms_libs + PUBLIC -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" +) + +set_property(TARGET algorithms_libs + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) + +if(OS_IS_MACOSX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # not AppleClang + target_compile_definitions(algorithms_libs + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW + ) + endif() +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(algorithms_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +############################################################################### + +source_group(Headers FILES gnss_sdr_flags.h) add_library(gnss_sdr_flags gnss_sdr_flags.cc gnss_sdr_flags.h) -source_group(Headers FILES gnss_sdr_flags.h) -target_link_libraries(gnss_sdr_flags ${GFlags_LIBS}) + +target_link_libraries(gnss_sdr_flags + PUBLIC + Gflags::gflags + PRIVATE + Boost::filesystem +) + +if(${GFLAGS_GREATER_20}) + target_compile_definitions(gnss_sdr_flags PRIVATE -DGFLAGS_GREATER_2_0=1) +endif() + +target_compile_definitions(gnss_sdr_flags + PRIVATE -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(gnss_sdr_flags + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET gnss_sdr_flags + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.cc b/src/algorithms/libs/beidou_b1i_signal_processing.cc new file mode 100644 index 000000000..61e1ffa47 --- /dev/null +++ b/src/algorithms/libs/beidou_b1i_signal_processing.cc @@ -0,0 +1,191 @@ +/*! + * \file beidou_b1i_signal_processing.cc + * \brief This class implements various functions for BeiDou B1I signal + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * Detailed description of the file here if needed. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_b1i_signal_processing.h" + +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; + +void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift) +{ + const uint32_t _code_length = 2046; + bool G1[_code_length]; + bool G2[_code_length]; + bool G1_register[11] = {false, true, false, true, false, true, false, true, false, true, false}; + bool G2_register[11] = {false, true, false, true, false, true, false, true, false, true, false}; + bool feedback1, feedback2; + bool aux; + uint32_t lcv, lcv2; + uint32_t delay; + int32_t prn_idx; + /* G2 Delays as defined in GPS-ISD-200D */ + const int32_t delays[33] = {712 /*PRN1*/, 1581, 1414, 1550, 581, 771, 1311, 1043, 1549, 359, 710, 1579, 1548, 1103, 579, 769, 358, 709, 1411, 1547, + 1102, 578, 357, 1577, 1410, 1546, 1101, 707, 1576, 1409, 1545, 354 /*PRN32*/, + 705}; + const int32_t phase1[37] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 8, 8, 8, 9, 9, 10}; + const int32_t phase2[37] = {3, 4, 5, 6, 8, 9, 10, 11, 7, 4, 5, 6, 8, 9, 10, 11, 5, 6, 8, 9, 10, 11, 6, 8, 9, 10, 11, 8, 9, 10, 11, 9, 10, 11, 10, 11, 11}; + + // compute delay array index for given PRN number + prn_idx = _prn - 1; + + /* A simple error check */ + if ((prn_idx < 0) || (prn_idx > 32)) + { + return; + } + + /*for (lcv = 0; lcv < 11; lcv++) + { + G1_register[lcv] = 1; + G2_register[lcv] = 1; + }*/ + + /* Generate G1 & G2 Register */ + for (lcv = 0; lcv < _code_length; lcv++) + { + G1[lcv] = G1_register[0]; + G2[lcv] = G2_register[-(phase1[prn_idx] - 11)] ^ G2_register[-(phase2[prn_idx] - 11)]; + + feedback1 = (G1_register[0] + G1_register[1] + G1_register[2] + G1_register[3] + G1_register[4] + G1_register[10]) & 0x1; + feedback2 = (G2_register[0] + G2_register[2] + G2_register[3] + G2_register[6] + G2_register[7] + G2_register[8] + G2_register[9] + G2_register[10]) & 0x1; + + for (lcv2 = 0; lcv2 < 10; lcv2++) + { + G1_register[lcv2] = G1_register[lcv2 + 1]; + G2_register[lcv2] = G2_register[lcv2 + 1]; + } + + G1_register[10] = feedback1; + G2_register[10] = feedback2; + } + + /* Set the delay */ + delay = _code_length - delays[prn_idx] * 0; //********************************** + delay += _chip_shift; + delay %= _code_length; + + /* Generate PRN from G1 and G2 Registers */ + for (lcv = 0; lcv < _code_length; lcv++) + { + aux = G1[(lcv + _chip_shift) % _code_length] ^ G2[delay]; + if (aux == true) + { + _dest[lcv] = 1; + } + else + { + _dest[lcv] = -1; + } + + delay++; + //std::cout << _dest[lcv] << " "; + delay %= _code_length; + } +} + + +void beidou_b1i_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift) +{ + uint32_t _code_length = 2046; + int32_t b1i_code_int[_code_length]; + + beidou_b1i_code_gen_int(b1i_code_int, _prn, _chip_shift); + + for (uint32_t ii = 0; ii < _code_length; ++ii) + { + _dest[ii] = static_cast(b1i_code_int[ii]); + } +} + + +void beidou_b1i_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift) +{ + uint32_t _code_length = 2046; + int32_t b1i_code_int[_code_length]; + + beidou_b1i_code_gen_int(b1i_code_int, _prn, _chip_shift); + + for (uint32_t ii = 0; ii < _code_length; ++ii) + { + _dest[ii] = std::complex(static_cast(b1i_code_int[ii]), 0.0f); + } +} + + +/* + * Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency + */ +void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) +{ + // This function is based on the GNU software GPS for MATLAB in the Kay Borre book + std::complex _code[2046]; + int32_t _samplesPerCode, _codeValueIndex; + float _ts; + float _tc; + float aux; + const int32_t _codeFreqBasis = 2046000; //Hz + const int32_t _codeLength = 2046; + + //--- Find number of samples per spreading code ---------------------------- + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + + //--- Find time constants -------------------------------------------------- + _ts = 1.0 / static_cast(_fs); // Sampling period in sec + _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec + beidou_b1i_code_gen_complex(_code, _prn, _chip_shift); //generate C/A code 1 sample per chip + + for (int32_t i = 0; i < _samplesPerCode; i++) + { + //=== Digitizing ======================================================= + + //--- Make index array to read C/A code values ------------------------- + // The length of the index array depends on the sampling frequency - + // number of samples per millisecond (because one C/A code period is one + // millisecond). + + // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; + aux = (_ts * (i + 1)) / _tc; + _codeValueIndex = auxCeil(aux) - 1; + + //--- Make the digitized version of the C/A code ----------------------- + // The "upsampled" code is made by selecting values form the CA code + // chip array (caCode) for the time instances of each sample. + if (i == _samplesPerCode - 1) + { + //--- Correct the last index (due to number rounding issues) ----------- + _dest[i] = _code[_codeLength - 1]; + } + else + { + _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + } + } +} diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.h b/src/algorithms/libs/beidou_b1i_signal_processing.h new file mode 100644 index 000000000..2e420eaae --- /dev/null +++ b/src/algorithms/libs/beidou_b1i_signal_processing.h @@ -0,0 +1,55 @@ +/*! + * \file beidou_b1i_signal_processing.h + * \brief This class implements various functions for BeiDou B1I signals + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * Detailed description of the file here if needed. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ +#define GNSS_SDR_BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ + +#include +#include +#include + +//! Generates int32_t GPS L1 C/A code for the desired SV ID and code shift +void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift); + +//! Generates float GPS L1 C/A code for the desired SV ID and code shift +void beidou_b1i_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift); + +//! Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency +void beidou_b1i_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift); + +//! Generates N complex GPS L1 C/A codes for the desired SV ID and code shift +void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); + +//! Generates complex GPS L1 C/A code for the desired SV ID and code shift +void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); + +#endif /* BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/byte_x2_to_complex_byte.cc b/src/algorithms/libs/byte_x2_to_complex_byte.cc index 7945f9573..a3a78c067 100644 --- a/src/algorithms/libs/byte_x2_to_complex_byte.cc +++ b/src/algorithms/libs/byte_x2_to_complex_byte.cc @@ -53,9 +53,9 @@ int byte_x2_to_complex_byte::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const int8_t *in0 = reinterpret_cast(input_items[0]); - const int8_t *in1 = reinterpret_cast(input_items[1]); - lv_8sc_t *out = reinterpret_cast(output_items[0]); + const auto *in0 = reinterpret_cast(input_items[0]); + const auto *in1 = reinterpret_cast(input_items[1]); + auto *out = reinterpret_cast(output_items[0]); // This could be put into a volk kernel int8_t real_part; int8_t imag_part; diff --git a/src/algorithms/libs/byte_x2_to_complex_byte.h b/src/algorithms/libs/byte_x2_to_complex_byte.h index c7e49bc98..05db6cb2d 100644 --- a/src/algorithms/libs/byte_x2_to_complex_byte.h +++ b/src/algorithms/libs/byte_x2_to_complex_byte.h @@ -37,7 +37,7 @@ class byte_x2_to_complex_byte; -typedef boost::shared_ptr byte_x2_to_complex_byte_sptr; +using byte_x2_to_complex_byte_sptr = boost::shared_ptr; byte_x2_to_complex_byte_sptr make_byte_x2_to_complex_byte(); diff --git a/src/algorithms/libs/complex_byte_to_float_x2.cc b/src/algorithms/libs/complex_byte_to_float_x2.cc index ae0409d99..04f4a54b2 100644 --- a/src/algorithms/libs/complex_byte_to_float_x2.cc +++ b/src/algorithms/libs/complex_byte_to_float_x2.cc @@ -53,9 +53,9 @@ int complex_byte_to_float_x2::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const lv_8sc_t *in = reinterpret_cast(input_items[0]); - float *out0 = reinterpret_cast(output_items[0]); - float *out1 = reinterpret_cast(output_items[1]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out0 = reinterpret_cast(output_items[0]); + auto *out1 = reinterpret_cast(output_items[1]); const float scalar = 1; volk_8ic_s32f_deinterleave_32f_x2(out0, out1, in, scalar, noutput_items); return noutput_items; diff --git a/src/algorithms/libs/complex_byte_to_float_x2.h b/src/algorithms/libs/complex_byte_to_float_x2.h index 74c2e9c55..170cd6033 100644 --- a/src/algorithms/libs/complex_byte_to_float_x2.h +++ b/src/algorithms/libs/complex_byte_to_float_x2.h @@ -37,7 +37,7 @@ class complex_byte_to_float_x2; -typedef boost::shared_ptr complex_byte_to_float_x2_sptr; +using complex_byte_to_float_x2_sptr = boost::shared_ptr; complex_byte_to_float_x2_sptr make_complex_byte_to_float_x2(); diff --git a/src/algorithms/libs/complex_float_to_complex_byte.cc b/src/algorithms/libs/complex_float_to_complex_byte.cc index 57576a9b1..d7106bedd 100644 --- a/src/algorithms/libs/complex_float_to_complex_byte.cc +++ b/src/algorithms/libs/complex_float_to_complex_byte.cc @@ -53,8 +53,8 @@ int complex_float_to_complex_byte::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const gr_complex *in = reinterpret_cast(input_items[0]); - lv_8sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); volk_gnsssdr_32fc_convert_8ic(out, in, noutput_items); return noutput_items; } diff --git a/src/algorithms/libs/complex_float_to_complex_byte.h b/src/algorithms/libs/complex_float_to_complex_byte.h index 74eb0b5c3..f8368543e 100644 --- a/src/algorithms/libs/complex_float_to_complex_byte.h +++ b/src/algorithms/libs/complex_float_to_complex_byte.h @@ -36,7 +36,7 @@ class complex_float_to_complex_byte; -typedef boost::shared_ptr complex_float_to_complex_byte_sptr; +using complex_float_to_complex_byte_sptr = boost::shared_ptr; complex_float_to_complex_byte_sptr make_complex_float_to_complex_byte(); diff --git a/src/algorithms/libs/conjugate_cc.cc b/src/algorithms/libs/conjugate_cc.cc index 2a61e1526..67077ba23 100644 --- a/src/algorithms/libs/conjugate_cc.cc +++ b/src/algorithms/libs/conjugate_cc.cc @@ -52,8 +52,8 @@ int conjugate_cc::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const gr_complex *in = reinterpret_cast(input_items[0]); - gr_complex *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); volk_32fc_conjugate_32fc(out, in, noutput_items); return noutput_items; } diff --git a/src/algorithms/libs/conjugate_cc.h b/src/algorithms/libs/conjugate_cc.h index a04cd2410..56a3ece78 100644 --- a/src/algorithms/libs/conjugate_cc.h +++ b/src/algorithms/libs/conjugate_cc.h @@ -36,7 +36,7 @@ class conjugate_cc; -typedef boost::shared_ptr conjugate_cc_sptr; +using conjugate_cc_sptr = boost::shared_ptr; conjugate_cc_sptr make_conjugate_cc(); diff --git a/src/algorithms/libs/conjugate_ic.cc b/src/algorithms/libs/conjugate_ic.cc index c26f48388..d3d00932e 100644 --- a/src/algorithms/libs/conjugate_ic.cc +++ b/src/algorithms/libs/conjugate_ic.cc @@ -52,8 +52,8 @@ int conjugate_ic::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const lv_8sc_t *in = reinterpret_cast(input_items[0]); - lv_8sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); volk_gnsssdr_8ic_conjugate_8ic(out, in, noutput_items); return noutput_items; } diff --git a/src/algorithms/libs/conjugate_ic.h b/src/algorithms/libs/conjugate_ic.h index 4b51f86da..4acc7af3a 100644 --- a/src/algorithms/libs/conjugate_ic.h +++ b/src/algorithms/libs/conjugate_ic.h @@ -36,7 +36,7 @@ class conjugate_ic; -typedef boost::shared_ptr conjugate_ic_sptr; +using conjugate_ic_sptr = boost::shared_ptr; conjugate_ic_sptr make_conjugate_ic(); diff --git a/src/algorithms/libs/conjugate_sc.cc b/src/algorithms/libs/conjugate_sc.cc index e62c6cc42..e23f1c1a4 100644 --- a/src/algorithms/libs/conjugate_sc.cc +++ b/src/algorithms/libs/conjugate_sc.cc @@ -52,8 +52,8 @@ int conjugate_sc::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const lv_16sc_t *in = reinterpret_cast(input_items[0]); - lv_16sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); volk_gnsssdr_16ic_conjugate_16ic(out, in, noutput_items); return noutput_items; } diff --git a/src/algorithms/libs/conjugate_sc.h b/src/algorithms/libs/conjugate_sc.h index 019d16dcb..a26b39ad7 100644 --- a/src/algorithms/libs/conjugate_sc.h +++ b/src/algorithms/libs/conjugate_sc.h @@ -36,7 +36,7 @@ class conjugate_sc; -typedef boost::shared_ptr conjugate_sc_sptr; +using conjugate_sc_sptr = boost::shared_ptr; conjugate_sc_sptr make_conjugate_sc(); diff --git a/src/algorithms/libs/cshort_to_float_x2.cc b/src/algorithms/libs/cshort_to_float_x2.cc index accdb7826..cfde3f79c 100644 --- a/src/algorithms/libs/cshort_to_float_x2.cc +++ b/src/algorithms/libs/cshort_to_float_x2.cc @@ -53,9 +53,9 @@ int cshort_to_float_x2::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const lv_16sc_t *in = reinterpret_cast(input_items[0]); - float *out0 = reinterpret_cast(output_items[0]); - float *out1 = reinterpret_cast(output_items[1]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out0 = reinterpret_cast(output_items[0]); + auto *out1 = reinterpret_cast(output_items[1]); const float scalar = 1; volk_16ic_s32f_deinterleave_32f_x2(out0, out1, in, scalar, noutput_items); return noutput_items; diff --git a/src/algorithms/libs/cshort_to_float_x2.h b/src/algorithms/libs/cshort_to_float_x2.h index 7a235e68a..87a5d89a7 100644 --- a/src/algorithms/libs/cshort_to_float_x2.h +++ b/src/algorithms/libs/cshort_to_float_x2.h @@ -37,7 +37,7 @@ class cshort_to_float_x2; -typedef boost::shared_ptr cshort_to_float_x2_sptr; +using cshort_to_float_x2_sptr = boost::shared_ptr; cshort_to_float_x2_sptr make_cshort_to_float_x2(); diff --git a/src/algorithms/libs/galileo_e1_signal_processing.cc b/src/algorithms/libs/galileo_e1_signal_processing.cc index 2e0d224cf..d3e92c804 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.cc +++ b/src/algorithms/libs/galileo_e1_signal_processing.cc @@ -33,16 +33,17 @@ #include "galileo_e1_signal_processing.h" #include "Galileo_E1.h" #include "gnss_signal_processing.h" +#include #include -void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn) +void galileo_e1_code_gen_int(int* _dest, char _Signal[3], int32_t _prn) { std::string _galileo_signal = _Signal; - signed int prn = _prn - 1; - int index = 0; + int32_t prn = _prn - 1; + int32_t index = 0; - /* A simple error check */ + // A simple error check if ((_prn < 1) || (_prn > 50)) { return; @@ -50,34 +51,34 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn) if (_galileo_signal.rfind("1B") != std::string::npos && _galileo_signal.length() >= 2) { - for (size_t i = 0; i < Galileo_E1_B_PRIMARY_CODE[prn].length(); i++) + for (char i : GALILEO_E1_B_PRIMARY_CODE[prn]) { - hex_to_binary_converter(&_dest[index], Galileo_E1_B_PRIMARY_CODE[prn].at(i)); + hex_to_binary_converter(&_dest[index], i); index += 4; } } else if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2) { - for (size_t i = 0; i < Galileo_E1_C_PRIMARY_CODE[prn].length(); i++) + for (char i : GALILEO_E1_C_PRIMARY_CODE[prn]) { - hex_to_binary_converter(&_dest[index], Galileo_E1_C_PRIMARY_CODE[prn].at(i)); + hex_to_binary_converter(&_dest[index], i); index += 4; } } } -void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, unsigned int _length_out) +void galileo_e1_sinboc_11_gen_int(int* _dest, const int* _prn, uint32_t _length_out) { - const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; - unsigned int _period = static_cast(_length_out / _length_in); - for (unsigned int i = 0; i < _length_in; i++) + const uint32_t _length_in = GALILEO_E1_B_CODE_LENGTH_CHIPS; + auto _period = static_cast(_length_out / _length_in); + for (uint32_t i = 0; i < _length_in; i++) { - for (unsigned int j = 0; j < (_period / 2); j++) + for (uint32_t j = 0; j < (_period / 2); j++) { _dest[i * _period + j] = _prn[i]; } - for (unsigned int j = (_period / 2); j < _period; j++) + for (uint32_t j = (_period / 2); j < _period; j++) { _dest[i * _period + j] = -_prn[i]; } @@ -85,53 +86,55 @@ void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, unsigned int _length_ou } -void galileo_e1_sinboc_61_gen_int(int* _dest, int* _prn, unsigned int _length_out) +void galileo_e1_sinboc_61_gen_int(int* _dest, const int* _prn, uint32_t _length_out) { - const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; - unsigned int _period = static_cast(_length_out / _length_in); + const uint32_t _length_in = GALILEO_E1_B_CODE_LENGTH_CHIPS; + auto _period = static_cast(_length_out / _length_in); - for (unsigned int i = 0; i < _length_in; i++) + for (uint32_t i = 0; i < _length_in; i++) { - for (unsigned int j = 0; j < _period; j += 2) + for (uint32_t j = 0; j < _period; j += 2) { _dest[i * _period + j] = _prn[i]; } - for (unsigned int j = 1; j < _period; j += 2) + for (uint32_t j = 1; j < _period; j += 2) { _dest[i * _period + j] = -_prn[i]; } } } -void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned int _prn) + +void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], uint32_t _prn) { std::string _galileo_signal = _Signal; - unsigned int _codeLength = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); - int primary_code_E1_chips[4092]; // _codeLength not accepted by Clang + const auto _codeLength = static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS); + int32_t primary_code_E1_chips[4092]; // _codeLength not accepted by Clang galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip - for (unsigned int i = 0; i < _codeLength; i++) + for (uint32_t i = 0; i < _codeLength; i++) { _dest[2 * i] = static_cast(primary_code_E1_chips[i]); _dest[2 * i + 1] = -_dest[2 * i]; } } + void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) { std::string _galileo_signal = _Signal; - const unsigned int _codeLength = 12 * Galileo_E1_B_CODE_LENGTH_CHIPS; + const uint32_t _codeLength = 12 * GALILEO_E1_B_CODE_LENGTH_CHIPS; const float alpha = sqrt(10.0 / 11.0); const float beta = sqrt(1.0 / 11.0); - int sinboc_11[12 * 4092]; // _codeLength not accepted by Clang - int sinboc_61[12 * 4092]; + int32_t sinboc_11[12 * 4092] = {0}; // _codeLength not accepted by Clang + int32_t sinboc_61[12 * 4092] = {0}; galileo_e1_sinboc_11_gen_int(sinboc_11, _prn, _codeLength); //generate sinboc(1,1) 12 samples per chip galileo_e1_sinboc_61_gen_int(sinboc_61, _prn, _codeLength); //generate sinboc(6,1) 12 samples per chip if (_galileo_signal.rfind("1B") != std::string::npos && _galileo_signal.length() >= 2) { - for (unsigned int i = 0; i < _codeLength; i++) + for (uint32_t i = 0; i < _codeLength; i++) { _dest[i] = alpha * static_cast(sinboc_11[i]) + beta * static_cast(sinboc_61[i]); @@ -139,7 +142,7 @@ void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) } else if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2) { - for (unsigned int i = 0; i < _codeLength; i++) + for (uint32_t i = 0; i < _codeLength; i++) { _dest[i] = alpha * static_cast(sinboc_11[i]) - beta * static_cast(sinboc_61[i]); @@ -149,47 +152,50 @@ void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag) { // This function is based on the GNU software GPS for MATLAB in Kay Borre's book std::string _galileo_signal = _Signal; - unsigned int _samplesPerCode; - const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz - unsigned int _codeLength = Galileo_E1_B_CODE_LENGTH_CHIPS; - int primary_code_E1_chips[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)]; - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); - const int _samplesPerChip = (_cboc == true) ? 12 : 2; + uint32_t _samplesPerCode; + const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz + auto _codeLength = static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS); + auto* primary_code_E1_chips = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * sizeof(int32_t), volk_gnsssdr_get_alignment())); - const unsigned int delay = ((static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / Galileo_E1_B_CODE_LENGTH_CHIPS; + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); + const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2; - galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip + const uint32_t delay = ((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS; + + galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); // generate Galileo E1 code, 1 sample per chip float* _signal_E1; - _codeLength = _samplesPerChip * Galileo_E1_B_CODE_LENGTH_CHIPS; + _codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS; _signal_E1 = new float[_codeLength]; if (_cboc == true) { - galileo_e1_gen_float(_signal_E1, primary_code_E1_chips, _Signal); //generate cboc 12 samples per chip + galileo_e1_gen_float(_signal_E1, primary_code_E1_chips, _Signal); // generate cboc 12 samples per chip } else { - int _signal_E1_int[_codeLength]; - galileo_e1_sinboc_11_gen_int(_signal_E1_int, primary_code_E1_chips, _codeLength); //generate sinboc(1,1) 2 samples per chip + auto* _signal_E1_int = static_cast(volk_gnsssdr_malloc(_codeLength * sizeof(int32_t), volk_gnsssdr_get_alignment())); + galileo_e1_sinboc_11_gen_int(_signal_E1_int, primary_code_E1_chips, _codeLength); // generate sinboc(1,1) 2 samples per chip - for (unsigned int ii = 0; ii < _codeLength; ++ii) + for (uint32_t ii = 0; ii < _codeLength; ++ii) { _signal_E1[ii] = static_cast(_signal_E1_int[ii]); } + volk_gnsssdr_free(_signal_E1_int); } if (_fs != _samplesPerChip * _codeFreqBasis) { - float* _resampled_signal = new float[_samplesPerCode]; + auto* _resampled_signal = new float[_samplesPerCode]; + resampler(_signal_E1, _resampled_signal, _samplesPerChip * _codeFreqBasis, _fs, - _codeLength, _samplesPerCode); //resamples code to fs + _codeLength, _samplesPerCode); // resamples code to fs delete[] _signal_E1; _signal_E1 = _resampled_signal; @@ -197,65 +203,67 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) { - float* _signal_E1C_secondary = new float[static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode]; + auto* _signal_E1C_secondary = new float[static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode]; - for (unsigned int i = 0; i < static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); i++) + for (uint32_t i = 0; i < static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH); i++) { for (unsigned k = 0; k < _samplesPerCode; k++) { - _signal_E1C_secondary[i * _samplesPerCode + k] = _signal_E1[k] * (Galileo_E1_C_SECONDARY_CODE.at(i) == '0' ? 1.0f : -1.0f); + _signal_E1C_secondary[i * _samplesPerCode + k] = _signal_E1[k] * (GALILEO_E1_C_SECONDARY_CODE.at(i) == '0' ? 1.0f : -1.0f); } } - _samplesPerCode *= static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); + _samplesPerCode *= static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH); delete[] _signal_E1; _signal_E1 = _signal_E1C_secondary; } - for (unsigned int i = 0; i < _samplesPerCode; i++) + for (uint32_t i = 0; i < _samplesPerCode; i++) { _dest[(i + delay) % _samplesPerCode] = _signal_E1[i]; } delete[] _signal_E1; + volk_gnsssdr_free(primary_code_E1_chips); } void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag) { std::string _galileo_signal = _Signal; - const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz - unsigned int _samplesPerCode = static_cast(static_cast(_fs) / - (static_cast(_codeFreqBasis) / static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS))); + const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz + auto _samplesPerCode = static_cast(static_cast(_fs) / + (static_cast(_codeFreqBasis) / static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS))); if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) { - _samplesPerCode *= static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); + _samplesPerCode *= static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH); } - float real_code[_samplesPerCode]; + auto* real_code = static_cast(volk_gnsssdr_malloc(_samplesPerCode * sizeof(float), volk_gnsssdr_get_alignment())); galileo_e1_code_gen_float_sampled(real_code, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag); - for (unsigned int ii = 0; ii < _samplesPerCode; ++ii) + for (uint32_t ii = 0; ii < _samplesPerCode; ++ii) { _dest[ii] = std::complex(real_code[ii], 0.0f); } + volk_gnsssdr_free(real_code); } void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift) + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { galileo_e1_code_gen_float_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false); } void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift) + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { galileo_e1_code_gen_complex_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false); } diff --git a/src/algorithms/libs/galileo_e1_signal_processing.h b/src/algorithms/libs/galileo_e1_signal_processing.h index f7133fd2d..6784e6f22 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.h +++ b/src/algorithms/libs/galileo_e1_signal_processing.h @@ -33,12 +33,13 @@ #define GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ #include +#include /*! * \brief This function generates Galileo E1 code (can select E1B or E1C sinboc). * */ -void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned int _prn); +void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], uint32_t _prn); /*! * \brief This function generates Galileo E1 code (can select E1B or E1C, cboc or sinboc @@ -46,7 +47,7 @@ void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned * */ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag); /*! @@ -55,7 +56,7 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], * */ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift); + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); /*! * \brief This function generates Galileo E1 code (can select E1B or E1C, cboc or sinboc @@ -63,13 +64,13 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], * */ void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag); /*! * \brief galileo_e1_code_gen_complex_sampled without _secondary_flag for backward compatibility. */ void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift); + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/galileo_e5_signal_processing.cc b/src/algorithms/libs/galileo_e5_signal_processing.cc index ca6eb675a..dab7e1d77 100644 --- a/src/algorithms/libs/galileo_e5_signal_processing.cc +++ b/src/algorithms/libs/galileo_e5_signal_processing.cc @@ -37,20 +37,20 @@ #include -void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed int _prn, char _Signal[3]) +void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, int32_t _prn, const char _Signal[3]) { - unsigned int prn = _prn - 1; - unsigned int index = 0; - int a[4]; + uint32_t prn = _prn - 1; + uint32_t index = 0; + int32_t a[4]; if ((_prn < 1) || (_prn > 50)) { return; } if (_Signal[0] == '5' && _Signal[1] == 'Q') { - for (size_t i = 0; i < Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1; i++) + for (size_t i = 0; i < GALILEO_E5A_Q_PRIMARY_CODE[prn].length() - 1; i++) { - hex_to_binary_converter(a, Galileo_E5a_Q_PRIMARY_CODE[prn].at(i)); + hex_to_binary_converter(a, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(i)); _dest[index] = std::complex(0.0, float(a[0])); _dest[index + 1] = std::complex(0.0, float(a[1])); _dest[index + 2] = std::complex(0.0, float(a[2])); @@ -58,15 +58,15 @@ void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed in index = index + 4; } // last 2 bits are filled up zeros - hex_to_binary_converter(a, Galileo_E5a_Q_PRIMARY_CODE[prn].at(Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1)); + hex_to_binary_converter(a, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(GALILEO_E5A_Q_PRIMARY_CODE[prn].length() - 1)); _dest[index] = std::complex(float(0.0), a[0]); _dest[index + 1] = std::complex(float(0.0), a[1]); } else if (_Signal[0] == '5' && _Signal[1] == 'I') { - for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1; i++) + for (size_t i = 0; i < GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1; i++) { - hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(i)); + hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(i)); _dest[index] = std::complex(float(a[0]), 0.0); _dest[index + 1] = std::complex(float(a[1]), 0.0); _dest[index + 2] = std::complex(float(a[2]), 0.0); @@ -74,17 +74,17 @@ void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed in index = index + 4; } // last 2 bits are filled up zeros - hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1)); + hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1)); _dest[index] = std::complex(float(a[0]), 0.0); _dest[index + 1] = std::complex(float(a[1]), 0.0); } else if (_Signal[0] == '5' && _Signal[1] == 'X') { - int b[4]; - for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1; i++) + int32_t b[4]; + for (size_t i = 0; i < GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1; i++) { - hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(i)); - hex_to_binary_converter(b, Galileo_E5a_Q_PRIMARY_CODE[prn].at(i)); + hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(i)); + hex_to_binary_converter(b, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(i)); _dest[index] = std::complex(float(a[0]), float(b[0])); _dest[index + 1] = std::complex(float(a[1]), float(b[1])); _dest[index + 2] = std::complex(float(a[2]), float(b[2])); @@ -92,50 +92,45 @@ void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed in index = index + 4; } // last 2 bits are filled up zeros - hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1)); - hex_to_binary_converter(b, Galileo_E5a_Q_PRIMARY_CODE[prn].at(Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1)); + hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1)); + hex_to_binary_converter(b, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(GALILEO_E5A_Q_PRIMARY_CODE[prn].length() - 1)); _dest[index] = std::complex(float(a[0]), float(b[0])); _dest[index + 1] = std::complex(float(a[1]), float(b[1])); } } -void galileo_e5_a_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - unsigned int _prn, signed int _fs, unsigned int _chip_shift) -{ - unsigned int _samplesPerCode; - unsigned int delay; - const unsigned int _codeLength = Galileo_E5a_CODE_LENGTH_CHIPS; - const int _codeFreqBasis = Galileo_E5a_CODE_CHIP_RATE_HZ; - std::complex* _code = new std::complex[_codeLength](); +void galileo_e5_a_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], + uint32_t _prn, int32_t _fs, uint32_t _chip_shift) +{ + uint32_t _samplesPerCode; + uint32_t delay; + const uint32_t _codeLength = GALILEO_E5A_CODE_LENGTH_CHIPS; + const int32_t _codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_HZ; + + auto* _code = new std::complex[_codeLength](); galileo_e5_a_code_gen_complex_primary(_code, _prn, _Signal); - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength; if (_fs != _codeFreqBasis) { std::complex* _resampled_signal; - if (posix_memalign((void**)&_resampled_signal, 16, _samplesPerCode * sizeof(gr_complex)) == 0) + if (posix_memalign(reinterpret_cast(&_resampled_signal), 16, _samplesPerCode * sizeof(gr_complex)) == 0) { }; - resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); //resamples code to fs + resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); // resamples code to fs delete[] _code; _code = _resampled_signal; } - for (unsigned int i = 0; i < _samplesPerCode; i++) + for (uint32_t i = 0; i < _samplesPerCode; i++) { _dest[(i + delay) % _samplesPerCode] = _code[i]; } - if (_fs != _codeFreqBasis) - { - free(_code); - } - else - { - delete[] _code; - } + + delete[] _code; } diff --git a/src/algorithms/libs/galileo_e5_signal_processing.h b/src/algorithms/libs/galileo_e5_signal_processing.h index 998d3b98f..7a7dfc8cc 100644 --- a/src/algorithms/libs/galileo_e5_signal_processing.h +++ b/src/algorithms/libs/galileo_e5_signal_processing.h @@ -35,23 +35,23 @@ #define GNSS_SDR_GALILEO_E5_SIGNAL_PROCESSING_H_ #include +#include /*! * \brief Generates Galileo E5a code at 1 sample/chip * bool _pilot generates E5aQ code if true and E5aI (data signal) if false. */ -void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed int _prn, char _Signal[3]); +void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, int32_t _prn, const char _Signal[3]); - -void galileo_e5_a_code_gen_tiered(std::complex* _dest, std::complex* _primary, unsigned int _prn, char _Signal[3]); +void galileo_e5_a_code_gen_tiered(std::complex* _dest, std::complex* _primary, uint32_t _prn, char _Signal[3]); /*! * \brief Generates Galileo E5a complex code, shifted to the desired chip and sampled at a frequency fs * bool _pilot generates E5aQ code if true and E5aI (data signal) if false. */ void galileo_e5_a_code_gen_complex_sampled(std::complex* _dest, - char _Signal[3], unsigned int _prn, signed int _fs, unsigned int _chip_shift); + char _Signal[3], uint32_t _prn, int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GALILEO_E5_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/geofunctions.cc b/src/algorithms/libs/geofunctions.cc new file mode 100644 index 000000000..48137050b --- /dev/null +++ b/src/algorithms/libs/geofunctions.cc @@ -0,0 +1,790 @@ +/*! + * \file geofunctions.cc + * \brief A set of coordinate transformations functions and helpers, + * some of them migrated from MATLAB, for geographic information systems. + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "geofunctions.h" + +const double STRP_PI = 3.1415926535898; // Pi as defined in IS-GPS-200E + +arma::mat Skew_symmetric(const arma::vec &a) +{ + arma::mat A = arma::zeros(3, 3); + + A << 0.0 << -a(2) << a(1) << arma::endr + << a(2) << 0.0 << -a(0) << arma::endr + << -a(1) << a(0) << 0 << arma::endr; + + // {{0, -a(2), a(1)}, + // {a(2), 0, -a(0)}, + // {-a(1), a(0), 0}}; + return A; +} + + +double WGS84_g0(double Lat_rad) +{ + const double k = 0.001931853; // normal gravity constant + const double e2 = 0.00669438002290; // the square of the first numerical eccentricity + const double nge = 9.7803253359; // normal gravity value on the equator (m/sec^2) + double b = sin(Lat_rad); // Lat in degrees + b = b * b; + double g0 = nge * (1 + k * b) / (sqrt(1 - e2 * b)); + return g0; +} + + +double WGS84_geocentric_radius(double Lat_geodetic_rad) +{ + // WGS84 earth model Geocentric radius (Eq. 2.88) + const double WGS84_A = 6378137.0; // Semi-major axis of the Earth, a [m] + const double WGS84_IF = 298.257223563; // Inverse flattening of the Earth + const double WGS84_F = (1.0 / WGS84_IF); // The flattening of the Earth + // double WGS84_B=(WGS84_A*(1-WGS84_F)); // Semi-minor axis of the Earth [m] + double WGS84_E = (sqrt(2 * WGS84_F - WGS84_F * WGS84_F)); // Eccentricity of the Earth + + // transverse radius of curvature + double R_E = WGS84_A / sqrt(1 - WGS84_E * WGS84_E * sin(Lat_geodetic_rad) * sin(Lat_geodetic_rad)); // (Eq. 2.66) + + // geocentric radius at the Earth surface + double r_eS = R_E * sqrt(cos(Lat_geodetic_rad) * cos(Lat_geodetic_rad) + + (1 - WGS84_E * WGS84_E) * (1 - WGS84_E * WGS84_E) * sin(Lat_geodetic_rad) * sin(Lat_geodetic_rad)); // (Eq. 2.88) + return r_eS; +} + + +int topocent(double *Az, double *El, double *D, const arma::vec &x, const arma::vec &dx) +{ + double lambda; + double phi; + double h; + const double dtr = STRP_PI / 180.0; + const double a = 6378137.0; // semi-major axis of the reference ellipsoid WGS-84 + const double finv = 298.257223563; // inverse of flattening of the reference ellipsoid WGS-84 + + // Transform x into geodetic coordinates + togeod(&phi, &lambda, &h, a, finv, x(0), x(1), x(2)); + + double cl = cos(lambda * dtr); + double sl = sin(lambda * dtr); + double cb = cos(phi * dtr); + double sb = sin(phi * dtr); + + arma::mat F = {{-sl, -sb * cl, cb * cl}, + {cl, -sb * sl, cb * sl}, + {0.0, cb, sb}}; + + arma::vec local_vector; + + local_vector = arma::htrans(F) * dx; + + double E = local_vector(0); + double N = local_vector(1); + double U = local_vector(2); + + double hor_dis; + hor_dis = sqrt(E * E + N * N); + + if (hor_dis < 1.0E-20) + { + *Az = 0.0; + *El = 90.0; + } + else + { + *Az = atan2(E, N) / dtr; + *El = atan2(U, hor_dis) / dtr; + } + + if (*Az < 0) + { + *Az = *Az + 360.0; + } + + *D = sqrt(dx(0) * dx(0) + dx(1) * dx(1) + dx(2) * dx(2)); + return 0; +} + + +int togeod(double *dphi, double *dlambda, double *h, double a, double finv, double X, double Y, double Z) +{ + *h = 0.0; + const double tolsq = 1.e-10; // tolerance to accept convergence + const int maxit = 10; // max number of iterations + const double rtd = 180.0 / STRP_PI; + + // compute square of eccentricity + double esq; + if (finv < 1.0E-20) + { + esq = 0.0; + } + else + { + esq = (2.0 - 1.0 / finv) / finv; + } + + // first guess + double P = sqrt(X * X + Y * Y); // P is distance from spin axis + + // direct calculation of longitude + if (P > 1.0E-20) + { + *dlambda = atan2(Y, X) * rtd; + } + else + { + *dlambda = 0.0; + } + + // correct longitude bound + if (*dlambda < 0) + { + *dlambda = *dlambda + 360.0; + } + + double r = sqrt(P * P + Z * Z); // r is distance from origin (0,0,0) + + double sinphi; + if (r > 1.0E-20) + { + sinphi = Z / r; + } + else + { + sinphi = 0.0; + } + *dphi = asin(sinphi); + + // initial value of height = distance from origin minus + // approximate distance from origin to surface of ellipsoid + if (r < 1.0E-20) + { + *h = 0.0; + return 1; + } + + *h = r - a * (1 - sinphi * sinphi / finv); + + // iterate + double cosphi; + double N_phi; + double dP; + double dZ; + double oneesq = 1.0 - esq; + + for (int i = 0; i < maxit; i++) + { + sinphi = sin(*dphi); + cosphi = cos(*dphi); + + // compute radius of curvature in prime vertical direction + N_phi = a / sqrt(1.0 - esq * sinphi * sinphi); + + // compute residuals in P and Z + dP = P - (N_phi + (*h)) * cosphi; + dZ = Z - (N_phi * oneesq + (*h)) * sinphi; + + // update height and latitude + *h = *h + (sinphi * dZ + cosphi * dP); + *dphi = *dphi + (cosphi * dZ - sinphi * dP) / (N_phi + (*h)); + + // test for convergence + if ((dP * dP + dZ * dZ) < tolsq) + { + break; + } + if (i == (maxit - 1)) + { + // LOG(WARNING) << "The computation of geodetic coordinates did not converge"; + } + } + *dphi = (*dphi) * rtd; + return 0; +} + + +arma::mat Gravity_ECEF(const arma::vec &r_eb_e) +{ + // Parameters + const double R_0 = 6378137.0; // WGS84 Equatorial radius in meters + const double mu = 3.986004418E14; // WGS84 Earth gravitational constant (m^3 s^-2) + const double J_2 = 1.082627E-3; // WGS84 Earth's second gravitational constant + const double omega_ie = 7.292115E-5; // Earth rotation rate (rad/s) + // Calculate distance from center of the Earth + double mag_r = sqrt(arma::as_scalar(r_eb_e.t() * r_eb_e)); + // If the input position is 0,0,0, produce a dummy output + arma::vec g = arma::zeros(3, 1); + if (mag_r != 0) + { + // Calculate gravitational acceleration using (2.142) + double z_scale = 5 * pow((r_eb_e(2) / mag_r), 2); + arma::vec tmp_vec = {(1 - z_scale) * r_eb_e(0), + (1 - z_scale) * r_eb_e(1), + (3 - z_scale) * r_eb_e(2)}; + arma::vec gamma_ = (-mu / pow(mag_r, 3)) * (r_eb_e + 1.5 * J_2 * pow(R_0 / mag_r, 2) * tmp_vec); + + // Add centripetal acceleration using (2.133) + g(0) = gamma_(0) + pow(omega_ie, 2) * r_eb_e(0); + g(1) = gamma_(1) + pow(omega_ie, 2) * r_eb_e(1); + g(2) = gamma_(2); + } + return g; +} + + +arma::vec LLH_to_deg(const arma::vec &LLH) +{ + const double rtd = 180.0 / STRP_PI; + arma::vec deg = arma::zeros(3, 1); + deg(0) = LLH(0) * rtd; + deg(1) = LLH(1) * rtd; + deg(2) = LLH(2); + return deg; +} + + +double degtorad(double angleInDegrees) +{ + double angleInRadians = (STRP_PI / 180.0) * angleInDegrees; + return angleInRadians; +} + + +double radtodeg(double angleInRadians) +{ + double angleInDegrees = (180.0 / STRP_PI) * angleInRadians; + return angleInDegrees; +} + + +double mstoknotsh(double MetersPerSeconds) +{ + double knots = mstokph(MetersPerSeconds) * 0.539957; + return knots; +} + + +double mstokph(double MetersPerSeconds) +{ + double kph = 3600.0 * MetersPerSeconds / 1e3; + return kph; +} + + +arma::vec CTM_to_Euler(const arma::mat &C) +{ + // Calculate Euler angles using (2.23) + arma::mat CTM(C); + arma::vec eul = arma::zeros(3, 1); + eul(0) = atan2(CTM(1, 2), CTM(2, 2)); // roll + if (CTM(0, 2) < -1.0) + { + CTM(0, 2) = -1.0; + } + if (CTM(0, 2) > 1.0) + { + CTM(0, 2) = 1.0; + } + eul(1) = -asin(CTM(0, 2)); // pitch + eul(2) = atan2(CTM(0, 1), CTM(0, 0)); // yaw + return eul; +} + + +arma::mat Euler_to_CTM(const arma::vec &eul) +{ + // Eq.2.15 + // Euler angles to Attitude matrix is equivalent to rotate the body + // in the three axes: + // arma::mat Ax= {{1,0,0}, {0,cos(Att_phi),sin(Att_phi)} ,{0,-sin(Att_phi),cos(Att_phi)}}; + // arma::mat Ay= {{cos(Att_theta), 0, -sin(Att_theta)}, {0,1,0} , {sin(Att_theta), 0, cos(Att_theta)}}; + // arma::mat Az= {{cos(Att_psi), sin(Att_psi), 0}, {-sin(Att_psi), cos(Att_psi), 0},{0,0,1}}; + // arma::mat C_b_n=Ax*Ay*Az; // Attitude expressed in the LOCAL FRAME (NED) + // C_b_n=C_b_n.t(); + + // Precalculate sines and cosines of the Euler angles + double sin_phi = sin(eul(0)); + double cos_phi = cos(eul(0)); + double sin_theta = sin(eul(1)); + double cos_theta = cos(eul(1)); + double sin_psi = sin(eul(2)); + double cos_psi = cos(eul(2)); + + // Calculate coordinate transformation matrix using (2.22) + arma::mat C = {{cos_theta * cos_psi, cos_theta * sin_psi, -sin_theta}, + {-cos_phi * sin_psi + sin_phi * sin_theta * cos_psi, cos_phi * cos_psi + sin_phi * sin_theta * sin_psi, sin_phi * cos_theta}, + {sin_phi * sin_psi + cos_phi * sin_theta * cos_psi, -sin_phi * cos_psi + cos_phi * sin_theta * sin_psi, cos_phi * cos_theta}}; + return C; +} + + +arma::vec cart2geo(const arma::vec &XYZ, int elipsoid_selection) +{ + const double a[5] = {6378388.0, 6378160.0, 6378135.0, 6378137.0, 6378137.0}; + const double f[5] = {1.0 / 297.0, 1.0 / 298.247, 1.0 / 298.26, 1.0 / 298.257222101, 1.0 / 298.257223563}; + + double lambda = atan2(XYZ[1], XYZ[0]); + double ex2 = (2.0 - f[elipsoid_selection]) * f[elipsoid_selection] / ((1.0 - f[elipsoid_selection]) * (1.0 - f[elipsoid_selection])); + double c = a[elipsoid_selection] * sqrt(1.0 + ex2); + double phi = atan(XYZ[2] / ((sqrt(XYZ[0] * XYZ[0] + XYZ[1] * XYZ[1]) * (1.0 - (2.0 - f[elipsoid_selection])) * f[elipsoid_selection]))); + + double h = 0.1; + double oldh = 0.0; + double N; + int iterations = 0; + do + { + oldh = h; + N = c / sqrt(1.0 + ex2 * (cos(phi) * cos(phi))); + phi = atan(XYZ[2] / ((sqrt(XYZ[0] * XYZ[0] + XYZ[1] * XYZ[1]) * (1.0 - (2.0 - f[elipsoid_selection]) * f[elipsoid_selection] * N / (N + h))))); + h = sqrt(XYZ[0] * XYZ[0] + XYZ[1] * XYZ[1]) / cos(phi) - N; + iterations = iterations + 1; + if (iterations > 100) + { + // std::cout << "Failed to approximate h with desired precision. h-oldh= " << h - oldh; + break; + } + } + while (std::fabs(h - oldh) > 1.0e-12); + + arma::vec LLH = {{phi, lambda, h}}; // radians + return LLH; +} + + +void ECEF_to_Geo(const arma::vec &r_eb_e, const arma::vec &v_eb_e, const arma::mat &C_b_e, arma::vec &LLH, arma::vec &v_eb_n, arma::mat &C_b_n) +{ + // Compute the Latitude of the ECEF position + LLH = cart2geo(r_eb_e, 4); // ECEF -> WGS84 geographical + + // Calculate ECEF to Geographical coordinate transformation matrix using (2.150) + double cos_lat = cos(LLH(0)); + double sin_lat = sin(LLH(0)); + double cos_long = cos(LLH(1)); + double sin_long = sin(LLH(1)); + // C++11 and arma >= 5.2 + // arma::mat C_e_n = {{-sin_lat * cos_long, -sin_lat * sin_long, cos_lat}, + // {-sin_long, cos_long, 0}, + // {-cos_lat * cos_long, -cos_lat * sin_long, -sin_lat}}; //ECEF to Geo + arma::mat C_e_n = arma::zeros(3, 3); + C_e_n << -sin_lat * cos_long << -sin_lat * sin_long << cos_lat << arma::endr + << -sin_long << cos_long << 0 << arma::endr + << -cos_lat * cos_long << -cos_lat * sin_long << -sin_lat << arma::endr; // ECEF to Geo + // Transform velocity using (2.73) + v_eb_n = C_e_n * v_eb_e; + + C_b_n = C_e_n * C_b_e; // Attitude conversion from ECEF to NED +} + + +void Geo_to_ECEF(const arma::vec &LLH, const arma::vec &v_eb_n, const arma::mat &C_b_n, arma::vec &r_eb_e, arma::vec &v_eb_e, arma::mat &C_b_e) +{ + // Parameters + double R_0 = 6378137.0; // WGS84 Equatorial radius in meters + double e = 0.0818191908425; // WGS84 eccentricity + + // Calculate transverse radius of curvature using (2.105) + double R_E = R_0 / sqrt(1.0 - (e * sin(LLH(0))) * (e * sin(LLH(0)))); + + // Convert position using (2.112) + double cos_lat = cos(LLH(0)); + double sin_lat = sin(LLH(0)); + double cos_long = cos(LLH(1)); + double sin_long = sin(LLH(1)); + r_eb_e = {(R_E + LLH(2)) * cos_lat * cos_long, + (R_E + LLH(2)) * cos_lat * sin_long, + ((1 - e * e) * R_E + LLH(2)) * sin_lat}; + + // Calculate ECEF to Geo coordinate transformation matrix using (2.150) + // C++11 and arma>=5.2 + // arma::mat C_e_n = {{-sin_lat * cos_long, -sin_lat * sin_long, cos_lat}, + // {-sin_long, cos_long, 0}, + // {-cos_lat * cos_long, -cos_lat * sin_long, -sin_lat}}; + arma::mat C_e_n = arma::zeros(3, 3); + C_e_n << -sin_lat * cos_long << -sin_lat * sin_long << cos_lat << arma::endr + << -sin_long << cos_long << 0 << arma::endr + << -cos_lat * cos_long << -cos_lat * sin_long << -sin_lat << arma::endr; + + // Transform velocity using (2.73) + v_eb_e = C_e_n.t() * v_eb_n; + + // Transform attitude using (2.15) + C_b_e = C_e_n.t() * C_b_n; +} + + +void pv_Geo_to_ECEF(double L_b, double lambda_b, double h_b, const arma::vec &v_eb_n, arma::vec &r_eb_e, arma::vec &v_eb_e) +{ + // Parameters + const double R_0 = 6378137.0; // WGS84 Equatorial radius in meters + const double e = 0.0818191908425; // WGS84 eccentricity + + // Calculate transverse radius of curvature using (2.105) + double R_E = R_0 / sqrt(1 - pow(e * sin(L_b), 2)); + + // Convert position using (2.112) + double cos_lat = cos(L_b); + double sin_lat = sin(L_b); + double cos_long = cos(lambda_b); + double sin_long = sin(lambda_b); + r_eb_e = {(R_E + h_b) * cos_lat * cos_long, + (R_E + h_b) * cos_lat * sin_long, + ((1 - pow(e, 2)) * R_E + h_b) * sin_lat}; + + // Calculate ECEF to Geo coordinate transformation matrix using (2.150) + arma::mat C_e_n = arma::zeros(3, 3); + C_e_n << -sin_lat * cos_long << -sin_lat * sin_long << cos_lat << arma::endr + << -sin_long << cos_long << 0 << arma::endr + << -cos_lat * cos_long << -cos_lat * sin_long << -sin_lat << arma::endr; + + // Transform velocity using (2.73) + v_eb_e = C_e_n.t() * v_eb_n; +} + + +double great_circle_distance(double lat1, double lon1, double lat2, double lon2) +{ + // The Haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes. + // generally used geo measurement function + double R = 6378.137; // Radius of earth in KM + double dLat = lat2 * STRP_PI / 180.0 - lat1 * STRP_PI / 180.0; + double dLon = lon2 * STRP_PI / 180.0 - lon1 * STRP_PI / 180.0; + double a = sin(dLat / 2.0) * sin(dLat / 2.0) + + cos(lat1 * STRP_PI / 180.0) * cos(lat2 * STRP_PI / 180.0) * + sin(dLon / 2) * sin(dLon / 2.0); + double c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a)); + double d = R * c; + return d * 1000.0; // meters +} + + +void cart2utm(const arma::vec &r_eb_e, int zone, arma::vec &r_enu) +{ + // Transformation of (X,Y,Z) to (E,N,U) in UTM, zone 'zone' + // + // Inputs: + // r_eb_e - Cartesian coordinates. Coordinates are referenced + // with respect to the International Terrestrial Reference + // Frame 1996 (ITRF96) + // zone - UTM zone of the given position + // + // Outputs: + // r_enu - UTM coordinates (Easting, Northing, Uping) + // + // Originally written in Matlab by Kai Borre, Nov. 1994 + // Implemented in C++ by J.Arribas + // + // This implementation is based upon + // O. Andersson & K. Poder (1981) Koordinattransformationer + // ved Geod\ae{}tisk Institut. Landinspekt\oe{}ren + // Vol. 30: 552--571 and Vol. 31: 76 + // + // An excellent, general reference (KW) is + // R. Koenig & K.H. Weise (1951) Mathematische Grundlagen der + // h\"oheren Geod\"asie und Kartographie. + // Erster Band, Springer Verlag + // + // Explanation of variables used: + // f flattening of ellipsoid + // a semi major axis in m + // m0 1 - scale at central meridian; for UTM 0.0004 + // Q_n normalized meridian quadrant + // E0 Easting of central meridian + // L0 Longitude of central meridian + // bg constants for ellipsoidal geogr. to spherical geogr. + // gb constants for spherical geogr. to ellipsoidal geogr. + // gtu constants for ellipsoidal N, E to spherical N, E + // utg constants for spherical N, E to ellipoidal N, E + // tolutm tolerance for utm, 1.2E-10*meridian quadrant + // tolgeo tolerance for geographical, 0.00040 second of arc + // + // B, L refer to latitude and longitude. Southern latitude is negative + // International ellipsoid of 1924, valid for ED50 + + double a = 6378388.0; + double f = 1.0 / 297.0; + double ex2 = (2.0 - f) * f / ((1.0 - f) * (1.0 - f)); + double c = a * sqrt(1.0 + ex2); + arma::vec vec = r_eb_e; + vec(2) = vec(2) - 4.5; + double alpha = 0.756e-6; + arma::mat R = {{1.0, -alpha, 0.0}, {alpha, 1.0, 0.0}, {0.0, 0.0, 1.0}}; + arma::vec trans = {89.5, 93.8, 127.6}; + double scale = 0.9999988; + arma::vec v = scale * R * vec + trans; // coordinate vector in ED50 + double L = atan2(v(1), v(0)); + double N1 = 6395000.0; // preliminary value + double B = atan2(v(2) / ((1.0 - f) * (1.0 - f) * N1), arma::norm(v.subvec(0, 1)) / N1); // preliminary value + double U = 0.1; + double oldU = 0.0; + int iterations = 0; + while (fabs(U - oldU) > 1.0E-4) + { + oldU = U; + N1 = c / sqrt(1.0 + ex2 * (cos(B) * cos(B))); + B = atan2(v(2) / ((1.0 - f) * (1.0 - f) * N1 + U), arma::norm(v.subvec(0, 1)) / (N1 + U)); + U = arma::norm(v.subvec(0, 1)) / cos(B) - N1; + iterations = iterations + 1; + if (iterations > 100) + { + std::cout << "Failed to approximate U with desired precision. U-oldU:" << U - oldU << std::endl; + break; + } + } + // Normalized meridian quadrant, KW p. 50 (96), p. 19 (38b), p. 5 (21) + double m0 = 0.0004; + double n = f / (2.0 - f); + double m = n * n * (1.0 / 4.0 + n * n / 64.0); + double w = (a * (-n - m0 + m * (1.0 - m0))) / (1.0 + n); + double Q_n = a + w; + + // Easting and longitude of central meridian + double E0 = 500000.0; + double L0 = (zone - 30) * 6.0 - 3.0; + + // Check tolerance for reverse transformation + // double tolutm = STRP_PI / 2.0 * 1.2e-10 * Q_n; + // double tolgeo = 0.000040; + // Coefficients of trigonometric series + // + // ellipsoidal to spherical geographical, KW p .186 --187, (51) - (52) + // bg[1] = n * (-2 + n * (2 / 3 + n * (4 / 3 + n * (-82 / 45)))); + // bg[2] = n ^ 2 * (5 / 3 + n * (-16 / 15 + n * (-13 / 9))); + // bg[3] = n ^ 3 * (-26 / 15 + n * 34 / 21); + // bg[4] = n ^ 4 * 1237 / 630; + // + // spherical to ellipsoidal geographical, KW p.190 --191, (61) - (62) % gb[1] = n * (2 + n * (-2 / 3 + n * (-2 + n * 116 / 45))); + // gb[2] = n ^ 2 * (7 / 3 + n * (-8 / 5 + n * (-227 / 45))); + // gb[3] = n ^ 3 * (56 / 15 + n * (-136 / 35)); + // gb[4] = n ^ 4 * 4279 / 630; + // + // spherical to ellipsoidal N, E, KW p.196, (69) % gtu[1] = n * (1 / 2 + n * (-2 / 3 + n * (5 / 16 + n * 41 / 180))); + // gtu[2] = n ^ 2 * (13 / 48 + n * (-3 / 5 + n * 557 / 1440)); + // gtu[3] = n ^ 3 * (61 / 240 + n * (-103 / 140)); + // gtu[4] = n ^ 4 * 49561 / 161280; + // + // ellipsoidal to spherical N, E, KW p.194, (65) % utg[1] = n * (-1 / 2 + n * (2 / 3 + n * (-37 / 96 + n * 1 / 360))); + // utg[2] = n ^ 2 * (-1 / 48 + n * (-1 / 15 + n * 437 / 1440)); + // utg[3] = n ^ 3 * (-17 / 480 + n * 37 / 840); + // utg[4] = n ^ 4 * (-4397 / 161280); + // + // With f = 1 / 297 we get + + arma::colvec bg = {-3.37077907e-3, + 4.73444769e-6, + -8.29914570e-9, + 1.58785330e-11}; + + arma::colvec gb = {3.37077588e-3, + 6.62769080e-6, + 1.78718601e-8, + 5.49266312e-11}; + + arma::colvec gtu = {8.41275991e-4, + 7.67306686e-7, + 1.21291230e-9, + 2.48508228e-12}; + + arma::colvec utg = {-8.41276339e-4, + -5.95619298e-8, + -1.69485209e-10, + -2.20473896e-13}; + + // Ellipsoidal latitude, longitude to spherical latitude, longitude + bool neg_geo = false; + + if (B < 0.0) + { + neg_geo = true; + } + + double Bg_r = fabs(B); + double res_clensin = clsin(bg, 4, 2.0 * Bg_r); + Bg_r = Bg_r + res_clensin; + L0 = L0 * STRP_PI / 180.0; + double Lg_r = L - L0; + + // Spherical latitude, longitude to complementary spherical latitude % i.e.spherical N, E + double cos_BN = cos(Bg_r); + double Np = atan2(sin(Bg_r), cos(Lg_r) * cos_BN); + double Ep = atanh(sin(Lg_r) * cos_BN); + + // Spherical normalized N, E to ellipsoidal N, E + Np = 2.0 * Np; + Ep = 2.0 * Ep; + + double dN; + double dE; + clksin(gtu, 4, Np, Ep, &dN, &dE); + Np = Np / 2.0; + Ep = Ep / 2.0; + Np = Np + dN; + Ep = Ep + dE; + double N = Q_n * Np; + double E = Q_n * Ep + E0; + if (neg_geo) + { + N = -N + 20000000.0; + } + r_enu(0) = E; + r_enu(1) = N; + r_enu(2) = U; +} + + +double clsin(const arma::colvec &ar, int degree, double argument) +{ + // Clenshaw summation of sinus of argument. + // + // result = clsin(ar, degree, argument); + // + // Originally written in Matlab by Kai Borre + // Implemented in C++ by J.Arribas + + double cos_arg = 2.0 * cos(argument); + double hr1 = 0.0; + double hr = 0.0; + double hr2; + for (int t = degree; t > 0; t--) + { + hr2 = hr1; + hr1 = hr; + hr = ar(t - 1) + cos_arg * hr1 - hr2; + } + + return (hr * sin(argument)); +} + + +void clksin(const arma::colvec &ar, int degree, double arg_real, double arg_imag, double *re, double *im) +{ + // Clenshaw summation of sinus with complex argument + // [re, im] = clksin(ar, degree, arg_real, arg_imag); + // + // Originally written in Matlab by Kai Borre + // Implemented in C++ by J.Arribas + + double sin_arg_r = sin(arg_real); + double cos_arg_r = cos(arg_real); + double sinh_arg_i = sinh(arg_imag); + double cosh_arg_i = cosh(arg_imag); + + double r = 2.0 * cos_arg_r * cosh_arg_i; + double i = -2.0 * sin_arg_r * sinh_arg_i; + + double hr1 = 0.0; + double hr = 0.0; + double hi1 = 0.0; + double hi = 0.0; + double hi2; + double hr2; + for (int t = degree; t > 0; t--) + { + hr2 = hr1; + hr1 = hr; + hi2 = hi1; + hi1 = hi; + double z = ar(t - 1) + r * hr1 - i * hi - hr2; + hi = i * hr1 + r * hi1 - hi2; + hr = z; + } + + r = sin_arg_r * cosh_arg_i; + i = cos_arg_r * sinh_arg_i; + + *re = r * hr - i * hi; + *im = r * hi + i * hr; +} + + +int findUtmZone(double latitude_deg, double longitude_deg) +{ + // Function finds the UTM zone number for given longitude and latitude. + // The longitude value must be between -180 (180 degree West) and 180 (180 + // degree East) degree. The latitude must be within -80 (80 degree South) and + // 84 (84 degree North). + // + // utmZone = findUtmZone(latitude, longitude); + // + // Latitude and longitude must be in decimal degrees (e.g. 15.5 degrees not + // 15 deg 30 min). + // + // Originally written in Matlab by Darius Plausinaitis + // Implemented in C++ by J.Arribas + + // Check value bounds + if ((longitude_deg > 180.0) || (longitude_deg < -180.0)) + { + std::cout << "Longitude value exceeds limits (-180:180).\n"; + } + + if ((latitude_deg > 84.0) || (latitude_deg < -80.0)) + { + std::cout << "Latitude value exceeds limits (-80:84).\n"; + } + + // + // Find zone + // + + // Start at 180 deg west = -180 deg + int utmZone = floor((180 + longitude_deg) / 6) + 1; + + // Correct zone numbers for particular areas + if (latitude_deg > 72.0) + { + // Corrections for zones 31 33 35 37 + if ((longitude_deg >= 0.0) && (longitude_deg < 9.0)) + { + utmZone = 31; + } + else if ((longitude_deg >= 9.0) && (longitude_deg < 21.0)) + { + utmZone = 33; + } + else if ((longitude_deg >= 21.0) && (longitude_deg < 33.0)) + { + utmZone = 35; + } + else if ((longitude_deg >= 33.0) && (longitude_deg < 42.0)) + { + utmZone = 37; + } + } + else if ((latitude_deg >= 56.0) && (latitude_deg < 64.0)) + { + // Correction for zone 32 + if ((longitude_deg >= 3.0) && (longitude_deg < 12.0)) + { + utmZone = 32; + } + } + return utmZone; +} diff --git a/src/algorithms/libs/geofunctions.h b/src/algorithms/libs/geofunctions.h new file mode 100644 index 000000000..6ab773504 --- /dev/null +++ b/src/algorithms/libs/geofunctions.h @@ -0,0 +1,184 @@ +/*! + * \file geofunctions.h + * \brief A set of coordinate transformations functions and helpers, + * some of them migrated from MATLAB, for geographic information systems. + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GEOFUNCTIONS_H +#define GNSS_SDR_GEOFUNCTIONS_H + +#include + +arma::mat Skew_symmetric(const arma::vec &a); //!< Calculates skew-symmetric matrix + +double WGS84_g0(double Lat_rad); + +double WGS84_geocentric_radius(double Lat_geodetic_rad); + +/*! + * \brief Transformation of vector dx into topocentric coordinate + * system with origin at x + * Inputs: + * x - vector origin coordinates (in ECEF system [X; Y; Z;]) + * dx - vector ([dX; dY; dZ;]). + * + * Outputs: + * D - vector length. Units like the input + * Az - azimuth from north positive clockwise, degrees + * El - elevation angle, degrees + * + * Based on a Matlab function by Kai Borre + */ +int topocent(double *Az, double *El, double *D, const arma::vec &x, const arma::vec &dx); + +/*! + * \brief Subroutine to calculate geodetic coordinates latitude, longitude, + * height given Cartesian coordinates X,Y,Z, and reference ellipsoid + * values semi-major axis (a) and the inverse of flattening (finv). + * + * The output units of angular quantities will be in decimal degrees + * (15.5 degrees not 15 deg 30 min). The output units of h will be the + * same as the units of X,Y,Z,a. + * + * Inputs: + * a - semi-major axis of the reference ellipsoid + * finv - inverse of flattening of the reference ellipsoid + * X,Y,Z - Cartesian coordinates + * + * Outputs: + * dphi - latitude + * dlambda - longitude + * h - height above reference ellipsoid + * + * Based in a Matlab function by Kai Borre + */ +int togeod(double *dphi, double *dlambda, double *h, double a, double finv, double X, double Y, double Z); + +arma::mat Gravity_ECEF(const arma::vec &r_eb_e); //!< Calculates acceleration due to gravity resolved about ECEF-frame + +/*! + * \brief Conversion of Cartesian coordinates (X,Y,Z) to geographical + * coordinates (latitude, longitude, h) on a selected reference ellipsoid. + * + * Choices of Reference Ellipsoid for Geographical Coordinates + * 0. International Ellipsoid 1924 + * 1. International Ellipsoid 1967 + * 2. World Geodetic System 1972 + * 3. Geodetic Reference System 1980 + * 4. World Geodetic System 1984 + */ +arma::vec cart2geo(const arma::vec &XYZ, int elipsoid_selection); + +arma::vec LLH_to_deg(const arma::vec &LLH); + +double degtorad(double angleInDegrees); + +double radtodeg(double angleInRadians); + +double mstoknotsh(double MetersPerSeconds); + +double mstokph(double MetersPerSeconds); + +arma::vec CTM_to_Euler(const arma::mat &C); + +arma::mat Euler_to_CTM(const arma::vec &eul); + +void ECEF_to_Geo(const arma::vec &r_eb_e, const arma::vec &v_eb_e, const arma::mat &C_b_e, arma::vec &LLH, arma::vec &v_eb_n, arma::mat &C_b_n); + + +/*! + * \brief From Geographic to ECEF coordinates + * + * Inputs: + * LLH latitude (rad), longitude (rad), height (m) + * v_eb_n velocity of body frame w.r.t. ECEF frame, resolved along + * north, east, and down (m/s) + * C_b_n body-to-NED coordinate transformation matrix + * + * Outputs: + * r_eb_e Cartesian position of body frame w.r.t. ECEF frame, resolved + * along ECEF-frame axes (m) + * v_eb_e velocity of body frame w.r.t. ECEF frame, resolved along + * ECEF-frame axes (m/s) + * C_b_e body-to-ECEF-frame coordinate transformation matrix + * + */ +void Geo_to_ECEF(const arma::vec &LLH, const arma::vec &v_eb_n, const arma::mat &C_b_n, arma::vec &r_eb_e, arma::vec &v_eb_e, arma::mat &C_b_e); + + +/*! + * \brief Converts curvilinear to Cartesian position and velocity + * resolving axes from NED to ECEF + * This function created 11/4/2012 by Paul Groves + * + * Inputs: + * L_b latitude (rad) + * lambda_b longitude (rad) + * h_b height (m) + * v_eb_n velocity of body frame w.r.t. ECEF frame, resolved along + * north, east, and down (m/s) + * + * Outputs: + * r_eb_e Cartesian position of body frame w.r.t. ECEF frame, resolved + * along ECEF-frame axes (m) + * v_eb_e velocity of body frame w.r.t. ECEF frame, resolved along + * ECEF-frame axes (m/s) + */ +void pv_Geo_to_ECEF(double L_b, double lambda_b, double h_b, const arma::vec &v_eb_n, arma::vec &r_eb_e, arma::vec &v_eb_e); + + +/*! + * \brief The Haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes. + */ +double great_circle_distance(double lat1, double lon1, double lat2, double lon2); + + +/*! + * \brief Transformation of ECEF (X,Y,Z) to (E,N,U) in UTM, zone 'zone'. + */ +void cart2utm(const arma::vec &r_eb_e, int zone, arma::vec &r_enu); + + +/*! + * \brief Function finds the UTM zone number for given longitude and latitude. + */ +int findUtmZone(double latitude_deg, double longitude_deg); + + +/*! + * \brief Clenshaw summation of sinus of argument. + */ +double clsin(const arma::colvec &ar, int degree, double argument); + + +/*! + * \brief Clenshaw summation of sinus with complex argument. + */ +void clksin(const arma::colvec &ar, int degree, double arg_real, double arg_imag, double *re, double *im); + +#endif diff --git a/src/algorithms/libs/glonass_l1_signal_processing.cc b/src/algorithms/libs/glonass_l1_signal_processing.cc index 509137d15..8707985b4 100644 --- a/src/algorithms/libs/glonass_l1_signal_processing.cc +++ b/src/algorithms/libs/glonass_l1_signal_processing.cc @@ -32,21 +32,21 @@ #include "glonass_l1_signal_processing.h" -auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; -void glonass_l1_ca_code_gen_complex(std::complex* _dest, /* signed int _prn,*/ unsigned int _chip_shift) +void glonass_l1_ca_code_gen_complex(std::complex* _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { - const unsigned int _code_length = 511; + const uint32_t _code_length = 511; bool G1[_code_length]; bool G1_register[9]; bool feedback1; bool aux; - unsigned int delay; - unsigned int lcv, lcv2; + uint32_t delay; + uint32_t lcv, lcv2; for (lcv = 0; lcv < 9; lcv++) { - G1_register[lcv] = 1; + G1_register[lcv] = true; } /* Generate G1 Register */ @@ -104,26 +104,26 @@ void glonass_l1_ca_code_gen_complex(std::complex* _dest, /* signed int _p /* * Generates complex GLONASS L1 C/A code for the desired SV ID and sampled to specific sampling frequency */ -void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift) +void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift) { // This function is based on the GNU software GPS for MATLAB in the Kay Borre book std::complex _code[511]; - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; float aux; - const signed int _codeFreqBasis = 511000; //Hz - const signed int _codeLength = 511; + const int32_t _codeFreqBasis = 511000; //Hz + const int32_t _codeLength = 511; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec glonass_l1_ca_code_gen_complex(_code, _chip_shift); //generate C/A code 1 sample per chip - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= diff --git a/src/algorithms/libs/glonass_l1_signal_processing.h b/src/algorithms/libs/glonass_l1_signal_processing.h index bcf1e89f2..0b1a26cfc 100644 --- a/src/algorithms/libs/glonass_l1_signal_processing.h +++ b/src/algorithms/libs/glonass_l1_signal_processing.h @@ -34,14 +34,15 @@ #define GNSS_SDR_GLONASS_SDR_SIGNAL_PROCESSING_H_ #include +#include //!Generates complex GLONASS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency -void glonass_l1_ca_code_gen_complex(std::complex* _dest, /*signed int _prn,*/ unsigned int _chip_shift); +void glonass_l1_ca_code_gen_complex(std::complex* _dest, /*int32_t _prn,*/ uint32_t _chip_shift); //! Generates N complex GLONASS L1 C/A codes for the desired SV ID and code shift -void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift, unsigned int _ncodes); +void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); //! Generates complex GLONASS L1 C/A code for the desired SV ID and code shift -void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift); +void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GLONASS_SDR_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/glonass_l2_signal_processing.cc b/src/algorithms/libs/glonass_l2_signal_processing.cc index fa82b88b1..491b0e735 100644 --- a/src/algorithms/libs/glonass_l2_signal_processing.cc +++ b/src/algorithms/libs/glonass_l2_signal_processing.cc @@ -32,21 +32,21 @@ #include "glonass_l2_signal_processing.h" -auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; -void glonass_l2_ca_code_gen_complex(std::complex* _dest, /* signed int _prn,*/ unsigned int _chip_shift) +void glonass_l2_ca_code_gen_complex(std::complex* _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { - const unsigned int _code_length = 511; + const uint32_t _code_length = 511; bool G1[_code_length]; bool G1_register[9]; bool feedback1; bool aux; - unsigned int delay; - unsigned int lcv, lcv2; + uint32_t delay; + uint32_t lcv, lcv2; for (lcv = 0; lcv < 9; lcv++) { - G1_register[lcv] = 1; + G1_register[lcv] = true; } /* Generate G1 Register */ @@ -104,26 +104,26 @@ void glonass_l2_ca_code_gen_complex(std::complex* _dest, /* signed int _p /* * Generates complex GLONASS L2 C/A code for the desired SV ID and sampled to specific sampling frequency */ -void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift) +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift) { // This function is based on the GNU software GPS for MATLAB in the Kay Borre book std::complex _code[511]; - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; float aux; - const signed int _codeFreqBasis = 511000; //Hz - const signed int _codeLength = 511; + const int32_t _codeFreqBasis = 511000; //Hz + const int32_t _codeLength = 511; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec glonass_l2_ca_code_gen_complex(_code, _chip_shift); //generate C/A code 1 sample per chip - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= diff --git a/src/algorithms/libs/glonass_l2_signal_processing.h b/src/algorithms/libs/glonass_l2_signal_processing.h index ff4a699e1..7c798f45a 100644 --- a/src/algorithms/libs/glonass_l2_signal_processing.h +++ b/src/algorithms/libs/glonass_l2_signal_processing.h @@ -34,14 +34,15 @@ #define GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ #include +#include //!Generates complex GLONASS L2 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency -void glonass_l2_ca_code_gen_complex(std::complex* _dest, /*signed int _prn,*/ unsigned int _chip_shift); +void glonass_l2_ca_code_gen_complex(std::complex* _dest, /*int32_t _prn,*/ uint32_t _chip_shift); //! Generates N complex GLONASS L2 C/A codes for the desired SV ID and code shift -void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift, unsigned int _ncodes); +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); //! Generates complex GLONASS L2 C/A code for the desired SV ID and code shift -void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift); +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/gnss_circular_deque.h b/src/algorithms/libs/gnss_circular_deque.h index 030044f91..23d89752b 100644 --- a/src/algorithms/libs/gnss_circular_deque.h +++ b/src/algorithms/libs/gnss_circular_deque.h @@ -33,8 +33,9 @@ #ifndef GNSS_SDR_CIRCULAR_DEQUE_H_ #define GNSS_SDR_CIRCULAR_DEQUE_H_ -#include + #include +#include template class Gnss_circular_deque diff --git a/src/algorithms/libs/gnss_sdr_create_directory.cc b/src/algorithms/libs/gnss_sdr_create_directory.cc new file mode 100644 index 000000000..d0af41952 --- /dev/null +++ b/src/algorithms/libs/gnss_sdr_create_directory.cc @@ -0,0 +1,85 @@ +/*! + * \file gnss_sdr_create_directory.cc + * \brief Create a directory + * \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "gnss_sdr_create_directory.h" +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem +#include + + +bool gnss_sdr_create_directory(const std::string& foldername) +{ + std::string new_folder; + for (auto& folder : boost::filesystem::path(foldername)) + { + new_folder += folder.string(); + boost::system::error_code ec; + if (!boost::filesystem::exists(new_folder)) + { + try + { + if (!boost::filesystem::create_directory(new_folder, ec)) + { + return false; + } + } + catch (std::exception& e) + { + return false; + } + } + new_folder += boost::filesystem::path::preferred_separator; + } + + // Check if we have writing permissions + std::string test_file = foldername + "/test_file.txt"; + std::ofstream os_test_file; + os_test_file.open(test_file.c_str(), std::ios::out | std::ios::binary); + + if (os_test_file.is_open()) + { + boost::system::error_code ec; + os_test_file.close(); + try + { + boost::filesystem::remove(test_file, ec); + } + catch (std::exception& e) + { + return false; + } + return true; + } + + os_test_file.close(); + return false; +} diff --git a/src/utils/gpstk/gnsspvt/src/kml_printer_gpstk.h b/src/algorithms/libs/gnss_sdr_create_directory.h similarity index 58% rename from src/utils/gpstk/gnsspvt/src/kml_printer_gpstk.h rename to src/algorithms/libs/gnss_sdr_create_directory.h index dc30ce42b..23de7ec14 100644 --- a/src/utils/gpstk/gnsspvt/src/kml_printer_gpstk.h +++ b/src/algorithms/libs/gnss_sdr_create_directory.h @@ -1,9 +1,7 @@ /*! - * \file kml_printer.h - * \brief Interface of a class that prints PVT information to a kml file - * for GPSTK data structures - * \author Javier Arribas, 2012. jarribas(at)cttc.es - * + * \file gnss_sdr_create_directory.h + * \brief Create a directory + * \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.es * * ------------------------------------------------------------------------- * @@ -30,31 +28,11 @@ * ------------------------------------------------------------------------- */ +#ifndef GNSS_SDR_GNSS_SDR_CREATE_DIRECTORY_H_ +#define GNSS_SDR_GNSS_SDR_CREATE_DIRECTORY_H_ -#ifndef GNSS_SDR_KML_PRINTER_H_ -#define GNSS_SDR_KML_PRINTER_H_ +#include -#include -#include -#include "gpstk/Position.hpp" - - -/*! - * \brief Prints PVT information to OGC KML format file (can be viewed with Google Earth) - * - * See http://www.opengeospatial.org/standards/kml - */ -class Kml_Printer_gpstk -{ -private: - std::ofstream kml_file; - -public: - bool set_headers(std::string filename); - bool print_position(gpstk::Position position); - bool close_file(); - Kml_Printer_gpstk(); - ~Kml_Printer_gpstk(); -}; +bool gnss_sdr_create_directory(const std::string& foldername); #endif diff --git a/src/algorithms/libs/gnss_sdr_flags.cc b/src/algorithms/libs/gnss_sdr_flags.cc index a43351916..e44812281 100644 --- a/src/algorithms/libs/gnss_sdr_flags.cc +++ b/src/algorithms/libs/gnss_sdr_flags.cc @@ -69,8 +69,10 @@ DEFINE_double(pll_bw_hz, 0.0, "If defined, bandwidth of the PLL low pass filter, static bool ValidateC(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare("-") == 0) // value is ok - return true; + if (boost::filesystem::exists(value) or value == "-") + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -78,8 +80,10 @@ static bool ValidateC(const char* flagname, const std::string& value) static bool ValidateConfigFile(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare(std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) == 0) // value is ok - return true; + if (boost::filesystem::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -87,8 +91,10 @@ static bool ValidateConfigFile(const char* flagname, const std::string& value) static bool ValidateS(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare("-") == 0) // value is ok - return true; + if (boost::filesystem::exists(value) or value == "-") + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -96,8 +102,10 @@ static bool ValidateS(const char* flagname, const std::string& value) static bool ValidateSignalSource(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare("-") == 0) // value is ok - return true; + if (boost::filesystem::exists(value) or value == "-") + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -106,8 +114,10 @@ static bool ValidateSignalSource(const char* flagname, const std::string& value) static bool ValidateDopplerMax(const char* flagname, int32_t value) { const int32_t max_value = 1000000; - if (value >= 0 && value < max_value) // value is ok - return true; + if (value >= 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -116,8 +126,10 @@ static bool ValidateDopplerMax(const char* flagname, int32_t value) static bool ValidateDopplerStep(const char* flagname, int32_t value) { const int32_t max_value = 10000; - if (value >= 0 && value < max_value) // value is ok - return true; + if (value >= 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -126,8 +138,10 @@ static bool ValidateDopplerStep(const char* flagname, int32_t value) static bool ValidateCn0Samples(const char* flagname, int32_t value) { const int32_t max_value = 10000; - if (value > 0 && value < max_value) // value is ok - return true; + if (value > 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " samples." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -136,8 +150,10 @@ static bool ValidateCn0Samples(const char* flagname, int32_t value) static bool ValidateCn0Min(const char* flagname, int32_t value) { const int32_t max_value = 100; - if (value > 0 && value < max_value) // value is ok - return true; + if (value > 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " dB-Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -146,8 +162,10 @@ static bool ValidateCn0Min(const char* flagname, int32_t value) static bool ValidateMaxLockFail(const char* flagname, int32_t value) { const int32_t max_value = 10000; - if (value > 0 && value < max_value) // value is ok - return true; + if (value > 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " fails." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -156,8 +174,10 @@ static bool ValidateMaxLockFail(const char* flagname, int32_t value) static bool ValidateCarrierLockTh(const char* flagname, double value) { const double max_value = 1.508; - if (value > 0.0 && value < max_value) // value is ok - return true; + if (value > 0.0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " rad." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -166,8 +186,10 @@ static bool ValidateCarrierLockTh(const char* flagname, double value) static bool ValidateDllBw(const char* flagname, double value) { const double max_value = 10000.0; - if (value >= 0.0 && value < max_value) // value is ok - return true; + if (value >= 0.0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -176,8 +198,10 @@ static bool ValidateDllBw(const char* flagname, double value) static bool ValidatePllBw(const char* flagname, double value) { const double max_value = 10000.0; - if (value >= 0.0 && value < max_value) // value is ok - return true; + if (value >= 0.0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc new file mode 100644 index 000000000..51f3a6547 --- /dev/null +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -0,0 +1,283 @@ +/*! + * \file gnss_sdr_fpga_sample_counter.cc + * \brief Simple block to report the current receiver time based on the output of the tracking or telemetry blocks + * \author Javier Arribas 2018. jarribas(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "gnss_sdr_fpga_sample_counter.h" +#include "gnss_synchro.h" +#include +#include +#include +#include +#include // libraries used by the GIPO +#include +#include +#include // libraries used by the GIPO + +#define PAGE_SIZE 0x10000 // default page size for the multicorrelator memory map +#define TEST_REG_SANITY_CHECK 0x55AA // value to check the presence of the test register (to detect the hw) + +gnss_sdr_fpga_sample_counter::gnss_sdr_fpga_sample_counter( + double _fs, + int32_t _interval_ms) : gr::block("fpga_fpga_sample_counter", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + message_port_register_out(pmt::mp("fpga_sample_counter")); + set_max_noutput_items(1); + interval_ms = _interval_ms; + fs = _fs; + samples_per_output = std::round(fs * static_cast(interval_ms) / 1e3); + //todo: Load here the hardware counter register with this amount of samples. It should produce an + //interrupt every samples_per_output count. + //The hardware timer must keep always interrupting the PS. It must not wait for the interrupt to + //be served. + open_device(); + + sample_counter = 0ULL; + current_T_rx_ms = 0; + current_s = 0; + current_m = 0; + current_h = 0; + current_days = 0; + report_interval_ms = 1000; // default reporting 1 second + flag_enable_send_msg = false; // enable it for reporting time with asynchronous message + flag_m = false; + flag_h = false; + flag_days = false; +} + + +gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms) +{ + gnss_sdr_fpga_sample_counter_sptr fpga_sample_counter_(new gnss_sdr_fpga_sample_counter(_fs, _interval_ms)); + return fpga_sample_counter_; +} + + +// Called by gnuradio to enable drivers, etc for i/o devices. +bool gnss_sdr_fpga_sample_counter::start() +{ + //todo: place here the RE-INITIALIZATION routines. This function will be called by GNURadio at every start of the flowgraph. + + // configure the number of samples per output in the FPGA and enable the interrupts + configure_samples_per_output(samples_per_output); + + // return true if everything is ok. + return true; +} + + +// Called by GNURadio to disable drivers, etc for i/o devices. +bool gnss_sdr_fpga_sample_counter::stop() +{ + //todo: place here the routines to stop the associated hardware (if needed).This function will be called by GNURadio at every stop of the flowgraph. + // return true if everything is ok. + close_device(); + + return true; +} + + +int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__((unused)), + __attribute__((unused)) gr_vector_int &ninput_items, + __attribute__((unused)) gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + //todo: Call here a function that waits for an interrupt. Do not open a thread, + //it must be a simple call to a BLOCKING function. + // The function will return the actual absolute sample count of the internal counter of the timmer. + // store the sample count in class member sample_counter + // Possible problem: what happen if the PS is overloaded and gnuradio does not call this function + // with the sufficient rate to catch all the interrupts in the counter. To be evaluated later. + + uint32_t counter = wait_for_interrupt_and_read_counter(); + uint64_t samples_passed = 2 * static_cast(samples_per_output) - static_cast(counter); // ellapsed samples + // Note: at this moment the sample counter is implemented as a sample counter that decreases to zero and then it is automatically + // reloaded again and keeps counter. It is done in this way to minimize the logic in the FPGA and maximize the FPGA clock performance + // (it takes less resources and latency in the FPGA to compare a number against a fixed value like zero than to compare it to a programmable + // variable number). + + sample_counter = sample_counter + samples_passed; //samples_per_output; + auto *out = reinterpret_cast(output_items[0]); + out[0] = Gnss_Synchro(); + out[0].Flag_valid_symbol_output = false; + out[0].Flag_valid_word = false; + out[0].Channel_ID = -1; + out[0].fs = fs; + if ((current_T_rx_ms % report_interval_ms) == 0) + { + current_s++; + if ((current_s % 60) == 0) + { + current_s = 0; + current_m++; + flag_m = true; + if ((current_m % 60) == 0) + { + current_m = 0; + current_h++; + flag_h = true; + if ((current_h % 24) == 0) + { + current_h = 0; + current_days++; + flag_days = true; + } + } + } + + if (flag_days) + { + std::string day; + if (current_days == 1) + { + day = " day "; + } + else + { + day = " days "; + } + std::cout << "Current receiver time: " << current_days << day << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + if (flag_h) + { + std::cout << "Current receiver time: " << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + if (flag_m) + { + std::cout << "Current receiver time: " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + std::cout << "Current receiver time: " << current_s << " s" << std::endl; + } + } + } + if (flag_enable_send_msg) + { + message_port_pub(pmt::mp("receiver_time"), pmt::from_double(static_cast(current_T_rx_ms) / 1000.0)); + } + } + out[0].Tracking_sample_counter = sample_counter; + //current_T_rx_ms = (sample_counter * 1000) / samples_per_output; + current_T_rx_ms = interval_ms * (sample_counter) / samples_per_output; + return 1; +} + +uint32_t gnss_sdr_fpga_sample_counter::test_register(uint32_t writeval) +{ + uint32_t readval; + // write value to test register + map_base[3] = writeval; + // read value from test register + readval = map_base[3]; + // return read value + return readval; +} + +void gnss_sdr_fpga_sample_counter::configure_samples_per_output(uint32_t interval) +{ + // note : the counter is a 48-bit value in the HW. + map_base[0] = interval - 1; +} + +void gnss_sdr_fpga_sample_counter::open_device() +{ + // open communication with HW accelerator + if ((fd = open(device_name.c_str(), O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" << device_name; + std::cout << "Counter-Intr: cannot open deviceio" << device_name << std::endl; + } + map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); + + if (map_base == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; + std::cout << "Counter-Intr: cannot map deviceio" << device_name << std::endl; + } + + // sanity check : check test register + uint32_t writeval = TEST_REG_SANITY_CHECK; + uint32_t readval; + readval = gnss_sdr_fpga_sample_counter::test_register(writeval); + if (writeval != readval) + { + LOG(WARNING) << "Acquisition test register sanity check failed"; + } + else + { + LOG(INFO) << "Acquisition test register sanity check success!"; + //std::cout << "Acquisition test register sanity check success!" << std::endl; + } +} + +void gnss_sdr_fpga_sample_counter::close_device() +{ + map_base[2] = 0; // disable the generation of the interrupt in the device + + auto *aux = const_cast(map_base); + if (munmap(static_cast(aux), PAGE_SIZE) == -1) + { + std::cout << "Failed to unmap memory uio" << std::endl; + } + close(fd); +} + +uint32_t gnss_sdr_fpga_sample_counter::wait_for_interrupt_and_read_counter() +{ + int32_t irq_count; + ssize_t nb; + int32_t counter; + + // enable interrupts + int32_t reenable = 1; + write(fd, reinterpret_cast(&reenable), sizeof(int32_t)); + + // wait for interrupt + nb = read(fd, &irq_count, sizeof(irq_count)); + if (nb != sizeof(irq_count)) + { + std::cout << "fpga sample counter module read failed to retrieve 4 bytes!" << std::endl; + std::cout << "fpga sample counter module interrupt number " << irq_count << std::endl; + } + + // it is a rising edge interrupt, the interrupt does not need to be acknowledged + //map_base[1] = 0; // writing anything to reg 1 acknowledges the interrupt + + // add number of passed samples or read the current counter value for more accuracy + counter = samples_per_output; //map_base[0]; + return counter; +} diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h new file mode 100644 index 000000000..a11a94be5 --- /dev/null +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h @@ -0,0 +1,81 @@ +/*! + * \file gnss_sdr_fpga_sample_counter.h + * \brief Simple block to report the current receiver time based on the output of the tracking or telemetry blocks + * \author Javier Arribas 2018. jarribas(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ +#ifndef GNSS_SDR_FPGA_sample_counter_H_ +#define GNSS_SDR_FPGA_sample_counter_H_ + +#include +#include +#include + +class gnss_sdr_fpga_sample_counter; + +typedef boost::shared_ptr gnss_sdr_fpga_sample_counter_sptr; + +gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms); + +class gnss_sdr_fpga_sample_counter : public gr::block +{ +private: + gnss_sdr_fpga_sample_counter(double _fs, int32_t _interval_ms); + uint32_t test_register(uint32_t writeval); + void configure_samples_per_output(uint32_t interval); + void close_device(void); + void open_device(void); + bool start(); + bool stop(); + uint32_t wait_for_interrupt_and_read_counter(void); + uint32_t samples_per_output; + double fs; + uint64_t sample_counter; + uint32_t interval_ms; + uint64_t current_T_rx_ms; // Receiver time in ms since the beginning of the run + uint32_t current_s; // Receiver time in seconds, modulo 60 + bool flag_m; // True if the receiver has been running for at least 1 minute + uint32_t current_m; // Receiver time in minutes, modulo 60 + bool flag_h; // True if the receiver has been running for at least 1 hour + uint32_t current_h; // Receiver time in hours, modulo 24 + bool flag_days; // True if the receiver has been running for at least 1 day + uint32_t current_days; // Receiver time in days since the beginning of the run + int32_t report_interval_ms; + bool flag_enable_send_msg; + int32_t fd; // driver descriptor + volatile uint32_t *map_base; // driver memory map + std::string device_name = "/dev/uio2"; // HW device name + +public: + friend gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /*GNSS_SDR_FPGA_sample_counter_H_*/ diff --git a/src/algorithms/libs/gnss_sdr_sample_counter.cc b/src/algorithms/libs/gnss_sdr_sample_counter.cc index a94d4ddeb..e7d939582 100644 --- a/src/algorithms/libs/gnss_sdr_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_sample_counter.cc @@ -36,13 +36,20 @@ #include #include -gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs, size_t _size) : gr::sync_decimator("sample_counter", - gr::io_signature::make(1, 1, _size), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), - static_cast(std::floor(_fs * 0.001))) +gnss_sdr_sample_counter::gnss_sdr_sample_counter( + double _fs, + int32_t _interval_ms, + size_t _size) : gr::sync_decimator("sample_counter", + gr::io_signature::make(1, 1, _size), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + static_cast(std::round(_fs * static_cast(_interval_ms) / 1e3))) { message_port_register_out(pmt::mp("sample_counter")); set_max_noutput_items(1); + interval_ms = _interval_ms; + fs = _fs; + samples_per_output = std::round(fs * static_cast(interval_ms) / 1e3); + sample_counter = 0; current_T_rx_ms = 0; current_s = 0; current_m = 0; @@ -56,9 +63,9 @@ gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs, size_t _size) : gr: } -gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, size_t _size) +gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, int32_t _interval_ms, size_t _size) { - gnss_sdr_sample_counter_sptr sample_counter_(new gnss_sdr_sample_counter(_fs, _size)); + gnss_sdr_sample_counter_sptr sample_counter_(new gnss_sdr_sample_counter(_fs, _interval_ms, _size)); return sample_counter_; } @@ -67,8 +74,12 @@ int gnss_sdr_sample_counter::work(int noutput_items __attribute__((unused)), gr_vector_const_void_star &input_items __attribute__((unused)), gr_vector_void_star &output_items) { - Gnss_Synchro *out = reinterpret_cast(output_items[0]); + auto *out = reinterpret_cast(output_items[0]); out[0] = Gnss_Synchro(); + out[0].Flag_valid_symbol_output = false; + out[0].Flag_valid_word = false; + out[0].Channel_ID = -1; + out[0].fs = fs; if ((current_T_rx_ms % report_interval_ms) == 0) { current_s++; @@ -127,6 +138,8 @@ int gnss_sdr_sample_counter::work(int noutput_items __attribute__((unused)), message_port_pub(pmt::mp("receiver_time"), pmt::from_double(static_cast(current_T_rx_ms) / 1000.0)); } } - current_T_rx_ms++; + sample_counter += samples_per_output; + out[0].Tracking_sample_counter = sample_counter; + current_T_rx_ms += interval_ms; return 1; } diff --git a/src/algorithms/libs/gnss_sdr_sample_counter.h b/src/algorithms/libs/gnss_sdr_sample_counter.h index f398684f5..ed065b193 100644 --- a/src/algorithms/libs/gnss_sdr_sample_counter.h +++ b/src/algorithms/libs/gnss_sdr_sample_counter.h @@ -31,33 +31,41 @@ #ifndef GNSS_SDR_SAMPLE_COUNTER_H_ #define GNSS_SDR_SAMPLE_COUNTER_H_ -#include #include +#include +#include class gnss_sdr_sample_counter; -typedef boost::shared_ptr gnss_sdr_sample_counter_sptr; +using gnss_sdr_sample_counter_sptr = boost::shared_ptr; -gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, size_t _size); +gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter( + double _fs, + int32_t _interval_ms, + size_t _size); class gnss_sdr_sample_counter : public gr::sync_decimator { private: - gnss_sdr_sample_counter(double _fs, size_t _size); - long long int current_T_rx_ms; // Receiver time in ms since the beginning of the run - unsigned int current_s; // Receiver time in seconds, modulo 60 - bool flag_m; // True if the receiver has been running for at least 1 minute - unsigned int current_m; // Receiver time in minutes, modulo 60 - bool flag_h; // True if the receiver has been running for at least 1 hour - unsigned int current_h; // Receiver time in hours, modulo 24 - bool flag_days; // True if the receiver has been running for at least 1 day - unsigned int current_days; // Receiver time in days since the beginning of the run - int report_interval_ms; + gnss_sdr_sample_counter(double _fs, int32_t _interval_ms, size_t _size); + uint32_t samples_per_output; + double fs; + uint64_t sample_counter; + int32_t interval_ms; + int64_t current_T_rx_ms; // Receiver time in ms since the beginning of the run + uint32_t current_s; // Receiver time in seconds, modulo 60 + bool flag_m; // True if the receiver has been running for at least 1 minute + uint32_t current_m; // Receiver time in minutes, modulo 60 + bool flag_h; // True if the receiver has been running for at least 1 hour + uint32_t current_h; // Receiver time in hours, modulo 24 + bool flag_days; // True if the receiver has been running for at least 1 day + uint32_t current_days; // Receiver time in days since the beginning of the run + int32_t report_interval_ms; bool flag_enable_send_msg; public: - friend gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, size_t _size); + friend gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, int32_t _interval_ms, size_t _size); int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/src/algorithms/libs/gnss_sdr_time_counter.cc b/src/algorithms/libs/gnss_sdr_time_counter.cc index a4874ac4b..0cd06517b 100644 --- a/src/algorithms/libs/gnss_sdr_time_counter.cc +++ b/src/algorithms/libs/gnss_sdr_time_counter.cc @@ -61,10 +61,10 @@ gnss_sdr_time_counter_sptr gnss_sdr_make_time_counter() int gnss_sdr_time_counter::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), - gr_vector_const_void_star &input_items __attribute__((unused)), gr_vector_void_star &output_items) + gr_vector_const_void_star &input_items __attribute__((unused)), gr_vector_void_star &output_items) { - Gnss_Synchro *out = reinterpret_cast(output_items[0]); - const Gnss_Synchro *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); out[0] = in[0]; if ((current_T_rx_ms % report_interval_ms) == 0) { diff --git a/src/algorithms/libs/gnss_sdr_time_counter.h b/src/algorithms/libs/gnss_sdr_time_counter.h index 91261e37d..870f6717c 100644 --- a/src/algorithms/libs/gnss_sdr_time_counter.h +++ b/src/algorithms/libs/gnss_sdr_time_counter.h @@ -31,9 +31,9 @@ #ifndef GNSS_SDR_TIME_COUNTER_H_ #define GNSS_SDR_TIME_COUNTER_H_ -#include #include - +#include +#include class gnss_sdr_time_counter; @@ -45,20 +45,20 @@ class gnss_sdr_time_counter : public gr::block { private: gnss_sdr_time_counter(); - long long int current_T_rx_ms; // Receiver time in ms since the beginning of the run - unsigned int current_s; // Receiver time in seconds, modulo 60 - bool flag_m; // True if the receiver has been running for at least 1 minute - unsigned int current_m; // Receiver time in minutes, modulo 60 - bool flag_h; // True if the receiver has been running for at least 1 hour - unsigned int current_h; // Receiver time in hours, modulo 24 - bool flag_days; // True if the receiver has been running for at least 1 day - unsigned int current_days; // Receiver time in days since the beginning of the run - int report_interval_ms; + int64_t current_T_rx_ms; // Receiver time in ms since the beginning of the run + uint32_t current_s; // Receiver time in seconds, modulo 60 + bool flag_m; // True if the receiver has been running for at least 1 minute + uint32_t current_m; // Receiver time in minutes, modulo 60 + bool flag_h; // True if the receiver has been running for at least 1 hour + uint32_t current_h; // Receiver time in hours, modulo 24 + bool flag_days; // True if the receiver has been running for at least 1 day + uint32_t current_days; // Receiver time in days since the beginning of the run + int32_t report_interval_ms; public: friend gnss_sdr_time_counter_sptr gnss_sdr_make_time_counter(); int general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), - gr_vector_const_void_star &input_items __attribute__((unused)), gr_vector_void_star &output_items); + gr_vector_const_void_star &input_items __attribute__((unused)), gr_vector_void_star &output_items); }; #endif /*GNSS_SDR_SAMPLE_COUNTER_H_*/ diff --git a/src/algorithms/libs/gnss_sdr_valve.cc b/src/algorithms/libs/gnss_sdr_valve.cc deleted file mode 100644 index b49ab50f9..000000000 --- a/src/algorithms/libs/gnss_sdr_valve.cc +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file gnss_sdr_valve.cc - * \brief Implementation of a GNU Radio block that sends a STOP message to the - * control queue right after a specific number of samples have passed through it. - * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include "gnss_sdr_valve.h" -#include "control_message_factory.h" -#include -#include -#include // for min -#include // for memcpy - -gnss_sdr_valve::gnss_sdr_valve(size_t sizeof_stream_item, - unsigned long long nitems, - gr::msg_queue::sptr queue) : gr::sync_block("valve", - gr::io_signature::make(1, 1, sizeof_stream_item), - gr::io_signature::make(1, 1, sizeof_stream_item)), - d_nitems(nitems), - d_ncopied_items(0), - d_queue(queue) -{ -} - - -boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, unsigned long long nitems, gr::msg_queue::sptr queue) -{ - boost::shared_ptr valve_(new gnss_sdr_valve(sizeof_stream_item, nitems, queue)); - return valve_; -} - - -int gnss_sdr_valve::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - if (d_ncopied_items >= d_nitems) - { - ControlMessageFactory *cmf = new ControlMessageFactory(); - d_queue->handle(cmf->GetQueueMessage(200, 0)); - LOG(INFO) << "Stopping receiver, " << d_ncopied_items << " samples processed"; - delete cmf; - return -1; // Done! - } - unsigned long long n = std::min(d_nitems - d_ncopied_items, static_cast(noutput_items)); - if (n == 0) return 0; - memcpy(output_items[0], input_items[0], n * input_signature()->sizeof_stream_item(0)); - //for(long long i = 0; i++; i -auto auxCeil2 = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil2 = [](float x) { return static_cast(static_cast((x) + 1)); }; -void complex_exp_gen(std::complex* _dest, double _f, double _fs, unsigned int _samps) +void complex_exp_gen(std::complex* _dest, double _f, double _fs, uint32_t _samps) { gr::fxpt_nco d_nco; d_nco.set_freq((GPS_TWO_PI * _f) / _fs); @@ -46,14 +46,15 @@ void complex_exp_gen(std::complex* _dest, double _f, double _fs, unsigned } -void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, unsigned int _samps) +void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, uint32_t _samps) { gr::fxpt_nco d_nco; d_nco.set_freq(-(GPS_TWO_PI * _f) / _fs); d_nco.sincos(_dest, _samps, 1); } -void hex_to_binary_converter(int* _dest, char _from) + +void hex_to_binary_converter(int32_t* _dest, char _from) { switch (_from) { @@ -156,15 +157,16 @@ void hex_to_binary_converter(int* _dest, char _from) } } -void resampler(float* _from, float* _dest, float _fs_in, - float _fs_out, unsigned int _length_in, unsigned int _length_out) + +void resampler(const float* _from, float* _dest, float _fs_in, + float _fs_out, uint32_t _length_in, uint32_t _length_out) { - unsigned int _codeValueIndex; + uint32_t _codeValueIndex; float aux; //--- Find time constants -------------------------------------------------- const float _t_in = 1 / _fs_in; // Incoming sampling period in sec const float _t_out = 1 / _fs_out; // Out sampling period in sec - for (unsigned int i = 0; i < _length_out - 1; i++) + for (uint32_t i = 0; i < _length_out - 1; i++) { //=== Digitizing ======================================================= //--- compute index array to read sampled values ------------------------- @@ -179,15 +181,16 @@ void resampler(float* _from, float* _dest, float _fs_in, _dest[_length_out - 1] = _from[_length_in - 1]; } -void resampler(std::complex* _from, std::complex* _dest, float _fs_in, - float _fs_out, unsigned int _length_in, unsigned int _length_out) + +void resampler(const std::complex* _from, std::complex* _dest, float _fs_in, + float _fs_out, uint32_t _length_in, uint32_t _length_out) { - unsigned int _codeValueIndex; + uint32_t _codeValueIndex; float aux; //--- Find time constants -------------------------------------------------- const float _t_in = 1 / _fs_in; // Incoming sampling period in sec const float _t_out = 1 / _fs_out; // Out sampling period in sec - for (unsigned int i = 0; i < _length_out - 1; i++) + for (uint32_t i = 0; i < _length_out - 1; i++) { //=== Digitizing ======================================================= //--- compute index array to read sampled values ------------------------- diff --git a/src/algorithms/libs/gnss_signal_processing.h b/src/algorithms/libs/gnss_signal_processing.h index 514815d82..3ed363e3e 100644 --- a/src/algorithms/libs/gnss_signal_processing.h +++ b/src/algorithms/libs/gnss_signal_processing.h @@ -36,6 +36,7 @@ #define GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ #include +#include /*! @@ -43,14 +44,14 @@ * */ void complex_exp_gen(std::complex* _dest, double _f, double _fs, - unsigned int _samps); + uint32_t _samps); /*! * \brief This function generates a conjugate complex exponential in _dest. * */ void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, - unsigned int _samps); + uint32_t _samps); /*! @@ -58,21 +59,21 @@ void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, * to binary (the output are 4 ints with +1 or -1 values). * */ -void hex_to_binary_converter(int* _dest, char _from); +void hex_to_binary_converter(int32_t* _dest, char _from); /*! * \brief This function resamples a sequence of float values. * */ -void resampler(float* _from, float* _dest, - float _fs_in, float _fs_out, unsigned int _length_in, - unsigned int _length_out); +void resampler(const float* _from, float* _dest, + float _fs_in, float _fs_out, uint32_t _length_in, + uint32_t _length_out); /*! * \brief This function resamples a sequence of complex values. * */ -void resampler(std::complex* _from, std::complex* _dest, - float _fs_in, float _fs_out, unsigned int _length_in, - unsigned int _length_out); +void resampler(const std::complex* _from, std::complex* _dest, + float _fs_in, float _fs_out, uint32_t _length_in, + uint32_t _length_out); #endif /* GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/gps_l2c_signal.cc b/src/algorithms/libs/gps_l2c_signal.cc index 81ad79c78..d8995a1f2 100644 --- a/src/algorithms/libs/gps_l2c_signal.cc +++ b/src/algorithms/libs/gps_l2c_signal.cc @@ -32,7 +32,6 @@ #include "gps_l2c_signal.h" #include "GPS_L2C.h" -#include #include @@ -42,11 +41,11 @@ int32_t gps_l2c_m_shift(int32_t x) } -void gps_l2c_m_code(int32_t* _dest, unsigned int _prn) +void gps_l2c_m_code(int32_t* _dest, uint32_t _prn) { int32_t x; x = GPS_L2C_M_INIT_REG[_prn - 1]; - for (int n = 0; n < GPS_L2_M_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L2_M_CODE_LENGTH_CHIPS; n++) { _dest[n] = static_cast(x & 1); x = gps_l2c_m_shift(x); @@ -54,16 +53,16 @@ void gps_l2c_m_code(int32_t* _dest, unsigned int _prn) } -void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn) +void gps_l2c_m_code_gen_complex(std::complex* _dest, uint32_t _prn) { - int32_t* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { gps_l2c_m_code(_code, _prn); } - for (signed int i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) { _dest[i] = std::complex(1.0 - 2.0 * _code[i], 0.0); } @@ -71,16 +70,17 @@ void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } -void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn) + +void gps_l2c_m_code_gen_float(float* _dest, uint32_t _prn) { - int32_t* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { gps_l2c_m_code(_code, _prn); } - for (signed int i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) { _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } @@ -92,36 +92,36 @@ void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn) /* * Generates complex GPS L2C M code for the desired SV ID and sampled to specific sampling frequency */ -void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs) +void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs) { - int32_t* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { gps_l2c_m_code(_code, _prn); } - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; - const signed int _codeLength = GPS_L2_M_CODE_LENGTH_CHIPS; + const int32_t _codeLength = GPS_L2_M_CODE_LENGTH_CHIPS; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L2_M_CODE_RATE_HZ) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L2_M_CODE_RATE_HZ) / static_cast(_codeLength))); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(GPS_L2_M_CODE_RATE_HZ); // C/A chip period in sec //float aux; - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= //--- Make index array to read L2C code values ------------------------- //TODO: Check this formula! Seems to start with an extra sample - _codeValueIndex = ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; + _codeValueIndex = std::ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; //aux = (_ts * (i + 1)) / _tc; - //_codeValueIndex = static_cast(static_cast(aux)) - 1; + //_codeValueIndex = static_cast(static_cast(aux)) - 1; //--- Make the digitized version of the L2C code ----------------------- if (i == _samplesPerCode - 1) diff --git a/src/algorithms/libs/gps_l2c_signal.h b/src/algorithms/libs/gps_l2c_signal.h index c76c4692f..84d51e485 100644 --- a/src/algorithms/libs/gps_l2c_signal.h +++ b/src/algorithms/libs/gps_l2c_signal.h @@ -34,13 +34,14 @@ #define GNSS_SDR_GPS_L2C_SIGNAL_H_ #include +#include -//!Generates complex GPS L2C M code for the desired SV ID -void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn); -void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn); +//! Generates complex GPS L2C M code for the desired SV ID +void gps_l2c_m_code_gen_complex(std::complex* _dest, uint32_t _prn); +void gps_l2c_m_code_gen_float(float* _dest, uint32_t _prn); //! Generates complex GPS L2C M code for the desired SV ID, and sampled to specific sampling frequency -void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); +void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs); #endif /* GNSS_GPS_L2C_SIGNAL_H_ */ diff --git a/src/algorithms/libs/gps_l5_signal.cc b/src/algorithms/libs/gps_l5_signal.cc index 84cc1843e..c1f234506 100644 --- a/src/algorithms/libs/gps_l5_signal.cc +++ b/src/algorithms/libs/gps_l5_signal.cc @@ -40,31 +40,25 @@ std::deque l5i_xa_shift(std::deque xa) { - if (xa == std::deque{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}) + if (xa == std::deque{true, true, true, true, true, true, true, true, true, true, true, false, true}) { - return std::deque{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - } - else - { - std::deque out(xa.begin(), xa.end() - 1); - out.push_front(xa[12] xor xa[11] xor xa[9] xor xa[8]); - return out; + return std::deque{true, true, true, true, true, true, true, true, true, true, true, true, true}; } + std::deque out(xa.begin(), xa.end() - 1); + out.push_front(xa[12] xor xa[11] xor xa[9] xor xa[8]); + return out; } std::deque l5q_xa_shift(std::deque xa) { - if (xa == std::deque{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}) + if (xa == std::deque{true, true, true, true, true, true, true, true, true, true, true, false, true}) { - return std::deque{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - } - else - { - std::deque out(xa.begin(), xa.end() - 1); - out.push_front(xa[12] xor xa[11] xor xa[9] xor xa[8]); - return out; + return std::deque{true, true, true, true, true, true, true, true, true, true, true, true, true}; } + std::deque out(xa.begin(), xa.end() - 1); + out.push_front(xa[12] xor xa[11] xor xa[9] xor xa[8]); + return out; } @@ -86,10 +80,10 @@ std::deque l5q_xb_shift(std::deque xb) std::deque make_l5i_xa() { - std::deque xa = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - std::deque y(GPS_L5i_CODE_LENGTH_CHIPS, 0); + std::deque xa = {true, true, true, true, true, true, true, true, true, true, true, true, true}; + std::deque y(GPS_L5I_CODE_LENGTH_CHIPS, false); - for (int i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { y[i] = xa[12]; xa = l5i_xa_shift(xa); @@ -100,10 +94,10 @@ std::deque make_l5i_xa() std::deque make_l5i_xb() { - std::deque xb = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - std::deque y(GPS_L5i_CODE_LENGTH_CHIPS, 0); + std::deque xb = {true, true, true, true, true, true, true, true, true, true, true, true, true}; + std::deque y(GPS_L5I_CODE_LENGTH_CHIPS, false); - for (int i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { y[i] = xb[12]; xb = l5i_xb_shift(xb); @@ -114,10 +108,10 @@ std::deque make_l5i_xb() std::deque make_l5q_xa() { - std::deque xa = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - std::deque y(GPS_L5q_CODE_LENGTH_CHIPS, 0); + std::deque xa = {true, true, true, true, true, true, true, true, true, true, true, true, true}; + std::deque y(GPS_L5Q_CODE_LENGTH_CHIPS, false); - for (int i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { y[i] = xa[12]; xa = l5q_xa_shift(xa); @@ -128,10 +122,10 @@ std::deque make_l5q_xa() std::deque make_l5q_xb() { - std::deque xb = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - std::deque y(GPS_L5q_CODE_LENGTH_CHIPS, 0); + std::deque xb = {true, true, true, true, true, true, true, true, true, true, true, true, true}; + std::deque y(GPS_L5Q_CODE_LENGTH_CHIPS, false); - for (int i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { y[i] = xb[12]; xb = l5q_xb_shift(xb); @@ -140,56 +134,56 @@ std::deque make_l5q_xb() } -void make_l5i(int32_t* _dest, int prn) +void make_l5i(int32_t* _dest, int32_t prn) { - int xb_offset = GPS_L5i_INIT_REG[prn]; + int32_t xb_offset = GPS_L5I_INIT_REG[prn]; std::deque xb = make_l5i_xb(); std::deque xa = make_l5i_xa(); - std::deque xb_shift(GPS_L5i_CODE_LENGTH_CHIPS, 0); + std::deque xb_shift(GPS_L5I_CODE_LENGTH_CHIPS, false); - for (int n = 0; n < GPS_L5i_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L5I_CODE_LENGTH_CHIPS; n++) { - xb_shift[n] = xb[(xb_offset + n) % GPS_L5i_CODE_LENGTH_CHIPS]; + xb_shift[n] = xb[(xb_offset + n) % GPS_L5I_CODE_LENGTH_CHIPS]; } - std::deque out_code(GPS_L5i_CODE_LENGTH_CHIPS, 0); - for (int n = 0; n < GPS_L5i_CODE_LENGTH_CHIPS; n++) + std::deque out_code(GPS_L5I_CODE_LENGTH_CHIPS, false); + for (int32_t n = 0; n < GPS_L5I_CODE_LENGTH_CHIPS; n++) { _dest[n] = xa[n] xor xb_shift[n]; } } -void make_l5q(int32_t* _dest, int prn) +void make_l5q(int32_t* _dest, int32_t prn) { - int xb_offset = GPS_L5q_INIT_REG[prn]; + int32_t xb_offset = GPS_L5Q_INIT_REG[prn]; std::deque xb = make_l5q_xb(); std::deque xa = make_l5q_xa(); - std::deque xb_shift(GPS_L5q_CODE_LENGTH_CHIPS, 0); + std::deque xb_shift(GPS_L5Q_CODE_LENGTH_CHIPS, false); - for (int n = 0; n < GPS_L5q_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L5Q_CODE_LENGTH_CHIPS; n++) { - xb_shift[n] = xb[(xb_offset + n) % GPS_L5q_CODE_LENGTH_CHIPS]; + xb_shift[n] = xb[(xb_offset + n) % GPS_L5Q_CODE_LENGTH_CHIPS]; } - std::deque out_code(GPS_L5q_CODE_LENGTH_CHIPS, 0); - for (int n = 0; n < GPS_L5q_CODE_LENGTH_CHIPS; n++) + std::deque out_code(GPS_L5Q_CODE_LENGTH_CHIPS, false); + for (int32_t n = 0; n < GPS_L5Q_CODE_LENGTH_CHIPS; n++) { _dest[n] = xa[n] xor xb_shift[n]; } } -void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn) +void gps_l5i_code_gen_complex(std::complex* _dest, uint32_t _prn) { - int32_t* _code = new int32_t[GPS_L5i_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { make_l5i(_code, _prn - 1); } - for (signed int i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { _dest[i] = std::complex(1.0 - 2.0 * _code[i], 0.0); } @@ -197,16 +191,17 @@ void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } -void gps_l5i_code_gen_float(float* _dest, unsigned int _prn) + +void gps_l5i_code_gen_float(float* _dest, uint32_t _prn) { - int32_t* _code = new int32_t[GPS_L5i_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { make_l5i(_code, _prn - 1); } - for (signed int i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } @@ -214,39 +209,40 @@ void gps_l5i_code_gen_float(float* _dest, unsigned int _prn) delete[] _code; } + /* * Generates complex GPS L5i code for the desired SV ID and sampled to specific sampling frequency */ -void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs) +void gps_l5i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs) { - int32_t* _code = new int32_t[GPS_L5i_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { make_l5i(_code, _prn - 1); } - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; - const signed int _codeLength = GPS_L5i_CODE_LENGTH_CHIPS; + const int32_t _codeLength = GPS_L5I_CODE_LENGTH_CHIPS; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5i_CODE_RATE_HZ) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5I_CODE_RATE_HZ) / static_cast(_codeLength))); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec - _tc = 1.0 / static_cast(GPS_L5i_CODE_RATE_HZ); // C/A chip period in sec + _tc = 1.0 / static_cast(GPS_L5I_CODE_RATE_HZ); // C/A chip period in sec //float aux; - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= //--- Make index array to read L5 code values ------------------------- //TODO: Check this formula! Seems to start with an extra sample - _codeValueIndex = ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; + _codeValueIndex = std::ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; //aux = (_ts * (i + 1)) / _tc; - //_codeValueIndex = static_cast(static_cast(aux)) - 1; + //_codeValueIndex = static_cast (static_cast(aux)) - 1; //--- Make the digitized version of the L2C code ----------------------- if (i == _samplesPerCode - 1) @@ -263,16 +259,16 @@ void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _ } -void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn) +void gps_l5q_code_gen_complex(std::complex* _dest, uint32_t _prn) { - int32_t* _code = new int32_t[GPS_L5q_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { make_l5q(_code, _prn - 1); } - for (signed int i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { _dest[i] = std::complex(1.0 - 2.0 * _code[i], 0.0); } @@ -280,55 +276,58 @@ void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } -void gps_l5q_code_gen_float(float* _dest, unsigned int _prn) + +void gps_l5q_code_gen_float(float* _dest, uint32_t _prn) { - int32_t* _code = new int32_t[GPS_L5q_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { make_l5q(_code, _prn - 1); } - for (signed int i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } delete[] _code; } + + /* * Generates complex GPS L5i code for the desired SV ID and sampled to specific sampling frequency */ -void gps_l5q_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs) +void gps_l5q_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs) { - int32_t* _code = new int32_t[GPS_L5q_CODE_LENGTH_CHIPS]; + auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) { make_l5q(_code, _prn - 1); } - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; - const signed int _codeLength = GPS_L5q_CODE_LENGTH_CHIPS; + const int32_t _codeLength = GPS_L5Q_CODE_LENGTH_CHIPS; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5q_CODE_RATE_HZ) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5Q_CODE_RATE_HZ) / static_cast(_codeLength))); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec - _tc = 1.0 / static_cast(GPS_L5q_CODE_RATE_HZ); // C/A chip period in sec + _tc = 1.0 / static_cast(GPS_L5Q_CODE_RATE_HZ); // C/A chip period in sec //float aux; - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= //--- Make index array to read L5 code values ------------------------- //TODO: Check this formula! Seems to start with an extra sample - _codeValueIndex = ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; + _codeValueIndex = std::ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; //aux = (_ts * (i + 1)) / _tc; - //_codeValueIndex = static_cast(static_cast(aux)) - 1; + //_codeValueIndex = static_cast (static_cast(aux)) - 1; //--- Make the digitized version of the L2C code ----------------------- if (i == _samplesPerCode - 1) diff --git a/src/algorithms/libs/gps_l5_signal.h b/src/algorithms/libs/gps_l5_signal.h index d226b0288..b0b24d2a5 100644 --- a/src/algorithms/libs/gps_l5_signal.h +++ b/src/algorithms/libs/gps_l5_signal.h @@ -34,21 +34,21 @@ #define GNSS_SDR_GPS_L5_SIGNAL_H_ #include - +#include //!Generates complex GPS L5i M code for the desired SV ID -void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn); -void gps_l5i_code_gen_float(float* _dest, unsigned int _prn); +void gps_l5i_code_gen_complex(std::complex* _dest, uint32_t _prn); +void gps_l5i_code_gen_float(float* _dest, uint32_t _prn); //!Generates complex GPS L5q M code for the desired SV ID -void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn); -void gps_l5q_code_gen_float(float* _dest, unsigned int _prn); +void gps_l5q_code_gen_complex(std::complex* _dest, uint32_t _prn); +void gps_l5q_code_gen_float(float* _dest, uint32_t _prn); //! Generates complex GPS L5i M code for the desired SV ID, and sampled to specific sampling frequency -void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); +void gps_l5i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs); //! Generates complex GPS L5q M code for the desired SV ID, and sampled to specific sampling frequency -void gps_l5q_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); +void gps_l5q_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs); #endif /* GNSS_SDR_GPS_L5_SIGNAL_H_ */ diff --git a/src/algorithms/libs/gps_sdr_signal_processing.cc b/src/algorithms/libs/gps_sdr_signal_processing.cc index 4dee98f05..945be5607 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.cc +++ b/src/algorithms/libs/gps_sdr_signal_processing.cc @@ -32,22 +32,22 @@ #include "gps_sdr_signal_processing.h" -auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; -void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift) +void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift) { - const unsigned int _code_length = 1023; + const uint32_t _code_length = 1023; bool G1[_code_length]; bool G2[_code_length]; bool G1_register[10], G2_register[10]; bool feedback1, feedback2; bool aux; - unsigned int lcv, lcv2; - unsigned int delay; - signed int prn_idx; + uint32_t lcv, lcv2; + uint32_t delay; + int32_t prn_idx; /* G2 Delays as defined in GPS-ISD-200D */ - const signed int delays[51] = {5 /*PRN1*/, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254, 255, 256, 257, 258, 469, 470, 471, 472, + const int32_t delays[51] = {5 /*PRN1*/, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254, 255, 256, 257, 258, 469, 470, 471, 472, 473, 474, 509, 512, 513, 514, 515, 516, 859, 860, 861, 862 /*PRN32*/, 145 /*PRN120*/, 175, 52, 21, 237, 235, 886, 657, 634, 762, 355, 1012, 176, 603, 130, 359, 595, 68, 386 /*PRN138*/}; @@ -64,12 +64,14 @@ void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shif /* A simple error check */ if ((prn_idx < 0) || (prn_idx > 51)) - return; + { + return; + } for (lcv = 0; lcv < 10; lcv++) { - G1_register[lcv] = 1; - G2_register[lcv] = 1; + G1_register[lcv] = true; + G2_register[lcv] = true; } /* Generate G1 & G2 Register */ @@ -114,28 +116,28 @@ void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shif } -void gps_l1_ca_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift) +void gps_l1_ca_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift) { - unsigned int _code_length = 1023; - int ca_code_int[_code_length]; + const uint32_t _code_length = 1023; + int32_t ca_code_int[_code_length]; gps_l1_ca_code_gen_int(ca_code_int, _prn, _chip_shift); - for (unsigned int ii = 0; ii < _code_length; ++ii) + for (uint32_t ii = 0; ii < _code_length; ++ii) { _dest[ii] = static_cast(ca_code_int[ii]); } } -void gps_l1_ca_code_gen_complex(std::complex* _dest, signed int _prn, unsigned int _chip_shift) +void gps_l1_ca_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift) { - unsigned int _code_length = 1023; - int ca_code_int[_code_length]; + const uint32_t _code_length = 1023; + int32_t ca_code_int[_code_length] = {0}; gps_l1_ca_code_gen_int(ca_code_int, _prn, _chip_shift); - for (unsigned int ii = 0; ii < _code_length; ++ii) + for (uint32_t ii = 0; ii < _code_length; ++ii) { _dest[ii] = std::complex(static_cast(ca_code_int[ii]), 0.0f); } @@ -144,27 +146,28 @@ void gps_l1_ca_code_gen_complex(std::complex* _dest, signed int _prn, uns /* * Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency + * NOTICE: the number of samples is rounded towards zero (integer truncation) */ -void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift) +void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { // This function is based on the GNU software GPS for MATLAB in the Kay Borre book std::complex _code[1023]; - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; float aux; - const signed int _codeFreqBasis = 1023000; //Hz - const signed int _codeLength = 1023; + const int32_t _codeFreqBasis = 1023000; //Hz + const int32_t _codeLength = 1023; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec gps_l1_ca_code_gen_complex(_code, _prn, _chip_shift); //generate C/A code 1 sample per chip - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= diff --git a/src/algorithms/libs/gps_sdr_signal_processing.h b/src/algorithms/libs/gps_sdr_signal_processing.h index b65db9144..44bb815dd 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.h +++ b/src/algorithms/libs/gps_sdr_signal_processing.h @@ -34,20 +34,21 @@ #define GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ #include +#include -//!Generates int GPS L1 C/A code for the desired SV ID and code shift -void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates int GPS L1 C/A code for the desired SV ID and code shift +void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift); -//!Generates float GPS L1 C/A code for the desired SV ID and code shift -void gps_l1_ca_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates float GPS L1 C/A code for the desired SV ID and code shift +void gps_l1_ca_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift); -//!Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency -void gps_l1_ca_code_gen_complex(std::complex* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency +void gps_l1_ca_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift); //! Generates N complex GPS L1 C/A codes for the desired SV ID and code shift -void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift, unsigned int _ncodes); +void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); //! Generates complex GPS L1 C/A code for the desired SV ID and code shift -void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift); +void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/opencl/cl.hpp b/src/algorithms/libs/opencl/cl.hpp index 62ba50cfc..b10828523 100644 --- a/src/algorithms/libs/opencl/cl.hpp +++ b/src/algorithms/libs/opencl/cl.hpp @@ -23,15 +23,15 @@ /*! \file * - * \brief C++ bindings for OpenCL 1.0 (rev 48), OpenCL 1.1 (rev 33) and - * OpenCL 1.2 (rev 15) + * \brief C++ bindings for OpenCL 1.0 (rev 48), OpenCL 1.1 (rev 33) and + * OpenCL 1.2 (rev 15) * \author Benedict R. Gaster, Laurent Morichetti and Lee Howes - * + * * Additions and fixes from: - * Brian Cole, March 3rd 2010 and April 2012 + * Brian Cole, March 3rd 2010 and April 2012 * Matt Gruenke, April 2012. * Bruce Merry, February 2013. - * + * * \version 1.2.5 * \date June 2013 * @@ -71,7 +71,7 @@ * * \code * #define __CL_ENABLE_EXCEPTIONS - * + * * #if defined(__APPLE__) || defined(__MACOSX) * #include * #else @@ -80,13 +80,13 @@ * #include * #include * #include - * + * * const char * helloStr = "__kernel void " * "hello(void) " * "{ " * " " * "} "; - * + * * int * main(void) * { @@ -100,33 +100,33 @@ * return -1; * } * - * cl_context_properties properties[] = + * cl_context_properties properties[] = * { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0}; - * cl::Context context(CL_DEVICE_TYPE_CPU, properties); - * + * cl::Context context(CL_DEVICE_TYPE_CPU, properties); + * * std::vector devices = context.getInfo(); - * + * * cl::Program::Sources source(1, * std::make_pair(helloStr,strlen(helloStr))); * cl::Program program_ = cl::Program(context, source); * program_.build(devices); - * + * * cl::Kernel kernel(program_, "hello", &err); - * + * * cl::Event event; * cl::CommandQueue queue(context, devices[0], 0, &err); * queue.enqueueNDRangeKernel( - * kernel, - * cl::NullRange, + * kernel, + * cl::NullRange, * cl::NDRange(4,4), * cl::NullRange, * NULL, - * &event); - * + * &event); + * * event.wait(); * } * catch (cl::Error err) { - * std::cerr + * std::cerr * << "ERROR: " * << err.what() * << "(" @@ -134,10 +134,10 @@ * << ")" * << std::endl; * } - * + * * return EXIT_SUCCESS; * } - * + * * \endcode * */ @@ -146,10 +146,10 @@ #ifdef _WIN32 -#include -#include -#include #include +#include +#include +#include #if defined(__CL_ENABLE_EXCEPTIONS) #include @@ -169,12 +169,12 @@ #endif #if defined(__APPLE__) || defined(__MACOSX) -#include #include +#include #include #else -#include #include +#include #endif // !__APPLE__ // To avoid accidentally taking ownership of core OpenCL types @@ -199,8 +199,8 @@ #define CL_CALLBACK #endif //CL_CALLBACK -#include #include +#include #if !defined(__NO_STD_VECTOR) #include @@ -212,7 +212,6 @@ #if defined(linux) || defined(__APPLE__) || defined(__MACOSX) #include - #include #include #endif // linux @@ -264,8 +263,8 @@ class Memory; class Buffer; #if defined(__CL_ENABLE_EXCEPTIONS) -/*! \brief Exception class - * +/*! \brief Exception class + * * This may be thrown by API functions when __CL_ENABLE_EXCEPTIONS is defined. */ class Error : public std::exception @@ -277,7 +276,7 @@ private: public: /*! \brief Create a new CL error exception for a given error code * and corresponding message. - * + * * \param err error code value. * * \param errStr a descriptive string that must remain in scope until @@ -476,7 +475,7 @@ typedef std::string STRING_CLASS; /*! \class string * \brief Simple string class, that provides a limited subset of std::string * functionality but avoids many of the issues that come with that class. - + * \note Deprecated. Please use std::string as default or * re-define the string class to match the std::string * interface by defining STRING_CLASS @@ -495,10 +494,10 @@ public: /*! \brief Constructs a string populated from an arbitrary value of * specified size. - * + * * An extra '\0' is added, in case none was contained in str. * - * \param str the initial value of the string instance. Note that '\0' + * \param str the initial value of the string instance. Note that '\0' * characters receive no special treatment. If NULL, * the string is left empty, with a size of 0. * @@ -678,7 +677,7 @@ typedef cl::string STRING_CLASS; #endif /*! \class vector - * \brief Fixed sized vector implementation that mirroring + * \brief Fixed sized vector implementation that mirroring * * \note Deprecated. Please use std::vector as default or * re-define the vector class to match the std::vector @@ -738,7 +737,7 @@ public: } /*! \brief Appends an element after the last valid element. - * Calling this on a vector that has reached capacity will throw an + * Calling this on a vector that has reached capacity will throw an * exception if exceptions are enabled. */ void push_back(const T& x) @@ -921,7 +920,7 @@ public: /** * Internal iterator constructor to capture reference - * to the vector it iterates over rather than taking + * to the vector it iterates over rather than taking * the vector by copy. */ iterator(const vector& vec, int index) : vec_(&vec) @@ -1617,7 +1616,7 @@ struct ReferenceHandler /** * Retain the device. * \param device A valid device created using createSubDevices - * \return + * \return * CL_SUCCESS if the function executed successfully. * CL_INVALID_DEVICE if device was not a valid subdevice * CL_OUT_OF_RESOURCES @@ -1630,7 +1629,7 @@ struct ReferenceHandler /** * Retain the device. * \param device A valid device created using createSubDevices - * \return + * \return * CL_SUCCESS if the function executed successfully. * CL_INVALID_DEVICE if device was not a valid subdevice * CL_OUT_OF_RESOURCES @@ -2055,13 +2054,13 @@ public: Device() : detail::Wrapper() {} /*! \brief Copy constructor. - * + * * This simply copies the device ID value, which is an inexpensive operation. */ Device(const Device& device) : detail::Wrapper(device) {} /*! \brief Constructor from cl_device_id. - * + * * This simply copies the device ID value, which is an inexpensive operation. */ Device(const cl_device_id& device) : detail::Wrapper(device) {} @@ -2073,7 +2072,7 @@ public: static Device getDefault(cl_int* err = NULL); /*! \brief Assignment operator from Device. - * + * * This simply copies the device ID value, which is an inexpensive operation. */ Device& operator=(const Device& rhs) @@ -2086,7 +2085,7 @@ public: } /*! \brief Assignment operator from cl_device_id. - * + * * This simply copies the device ID value, which is an inexpensive operation. */ Device& operator=(const cl_device_id& rhs) @@ -2201,19 +2200,19 @@ public: Platform() : detail::Wrapper() {} /*! \brief Copy constructor. - * + * * This simply copies the platform ID value, which is an inexpensive operation. */ Platform(const Platform& platform) : detail::Wrapper(platform) {} /*! \brief Constructor from cl_platform_id. - * + * * This simply copies the platform ID value, which is an inexpensive operation. */ Platform(const cl_platform_id& platform) : detail::Wrapper(platform) {} /*! \brief Assignment operator from Platform. - * + * * This simply copies the platform ID value, which is an inexpensive operation. */ Platform& operator=(const Platform& rhs) @@ -2226,7 +2225,7 @@ public: } /*! \brief Assignment operator from cl_platform_id. - * + * * This simply copies the platform ID value, which is an inexpensive operation. */ Platform& operator=(const cl_platform_id& rhs) @@ -2259,7 +2258,7 @@ public: } /*! \brief Gets a list of devices for this platform. - * + * * Wraps clGetDeviceIDs(). */ cl_int getDevices( @@ -2369,7 +2368,7 @@ public: #endif /*! \brief Gets a list of available platforms. - * + * * Wraps clGetPlatformIDs(). */ static cl_int get( @@ -2401,7 +2400,7 @@ public: } /*! \brief Gets the first available platform. - * + * * Wraps clGetPlatformIDs(), returning the first result. */ static cl_int get( @@ -2433,7 +2432,7 @@ public: } /*! \brief Gets the first available platform, returning it by value. - * + * * Wraps clGetPlatformIDs(), returning the first result. */ static Platform get( @@ -2694,20 +2693,20 @@ public: Context() : detail::Wrapper() {} /*! \brief Copy constructor. - * + * * This calls clRetainContext() on the parameter's cl_context. */ Context(const Context& context) : detail::Wrapper(context) {} /*! \brief Constructor from cl_context - takes ownership. - * + * * This effectively transfers ownership of a refcount on the cl_context * into the new Context object. */ __CL_EXPLICIT_CONSTRUCTORS Context(const cl_context& context) : detail::Wrapper(context) {} /*! \brief Assignment operator from Context. - * + * * This calls clRetainContext() on the parameter and clReleaseContext() on * the previous value held by this instance. */ @@ -2721,7 +2720,7 @@ public: } /*! \brief Assignment operator from cl_context - takes ownership. - * + * * This effectively transfers ownership of a refcount on the rhs and calls * clReleaseContext() on the value previously held by this instance. */ @@ -2756,7 +2755,7 @@ public: } /*! \brief Gets a list of supported image formats. - * + * * Wraps clGetSupportedImageFormats(). */ cl_int getSupportedImageFormats( @@ -2855,13 +2854,13 @@ public: Event() : detail::Wrapper() {} /*! \brief Copy constructor. - * + * * This calls clRetainEvent() on the parameter's cl_event. */ Event(const Event& event) : detail::Wrapper(event) {} /*! \brief Constructor from cl_event - takes ownership. - * + * * This effectively transfers ownership of a refcount on the cl_event * into the new Event object. */ @@ -2882,7 +2881,7 @@ public: } /*! \brief Assignment operator from cl_event. - * + * * This calls clRetainEvent() on the parameter and clReleaseEvent() on * the previous value held by this instance. */ @@ -2941,7 +2940,7 @@ public: } /*! \brief Blocks the calling thread until this event completes. - * + * * Wraps clWaitForEvents(). */ cl_int wait() const @@ -2972,7 +2971,7 @@ public: #endif /*! \brief Blocks the calling thread until every event specified is complete. - * + * * Wraps clWaitForEvents(). */ static cl_int @@ -2987,7 +2986,7 @@ public: #if defined(CL_VERSION_1_1) /*! \brief Class interface for user events (a subset of cl_event's). - * + * * See Event for details about copy semantics, etc. */ class UserEvent : public Event @@ -3043,7 +3042,7 @@ public: #endif /*! \brief Blocks the calling thread until every event specified is complete. - * + * * Wraps clWaitForEvents(). */ inline static cl_int @@ -3076,20 +3075,20 @@ public: Memory() : detail::Wrapper() {} /*! \brief Copy constructor - performs shallow copy. - * + * * This calls clRetainMemObject() on the parameter's cl_mem. */ Memory(const Memory& memory) : detail::Wrapper(memory) {} /*! \brief Constructor from cl_mem - takes ownership. - * + * * This effectively transfers ownership of a refcount on the cl_mem * into the new Memory object. */ __CL_EXPLICIT_CONSTRUCTORS Memory(const cl_mem& memory) : detail::Wrapper(memory) {} /*! \brief Assignment operator from Memory. - * + * * This calls clRetainMemObject() on the parameter and clReleaseMemObject() * on the previous value held by this instance. */ @@ -3173,7 +3172,7 @@ template cl_int copy(const cl::Buffer& buffer, IteratorType startIterator, IteratorType endIterator); /*! \brief Class interface for Buffer Memory Objects. - * + * * See Memory for details about copy semantics, etc. * * \see Memory @@ -3365,7 +3364,7 @@ public: /*! \brief Class interface for creating OpenCL buffers from ID3D10Buffer's. * * This is provided to facilitate interoperability with Direct3D. - * + * * See Memory for details about copy semantics, etc. * * \see Memory @@ -3463,9 +3462,9 @@ public: /*! \brief Class interface for GL Buffer Memory Objects. * * This is provided to facilitate interoperability with OpenGL. - * + * * See Memory for details about copy semantics, etc. - * + * * \see Memory */ class BufferGL : public Buffer @@ -3548,9 +3547,9 @@ public: /*! \brief Class interface for GL Render Buffer Memory Objects. * * This is provided to facilitate interoperability with OpenGL. - * + * * See Memory for details about copy semantics, etc. - * + * * \see Memory */ class BufferRenderGL : public Buffer @@ -3633,7 +3632,7 @@ public: /*! \brief C++ base class for Image Memory objects. * * See Memory for details about copy semantics, etc. - * + * * \see Memory */ class Image : public Memory @@ -3707,7 +3706,7 @@ public: /*! \brief Class interface for 1D Image Memory objects. * * See Memory for details about copy semantics, etc. - * + * * \see Memory */ class Image1D : public Image @@ -3913,7 +3912,7 @@ public: /*! \brief Class interface for 2D Image Memory objects. * * See Memory for details about copy semantics, etc. - * + * * \see Memory */ class Image2D : public Image @@ -4033,9 +4032,9 @@ public: /*! \brief Class interface for GL 2D Image Memory objects. * * This is provided to facilitate interoperability with OpenGL. - * + * * See Memory for details about copy semantics, etc. - * + * * \see Memory * \note Deprecated for OpenCL 1.2. Please use ImageGL instead. */ @@ -4182,7 +4181,7 @@ public: /*! \brief Class interface for 3D Image Memory objects. * * See Memory for details about copy semantics, etc. - * + * * \see Memory */ class Image3D : public Image @@ -4306,9 +4305,9 @@ public: /*! \brief Class interface for GL 3D Image Memory objects. * * This is provided to facilitate interoperability with OpenGL. - * + * * See Memory for details about copy semantics, etc. - * + * * \see Memory */ class Image3DGL : public Image3D @@ -4446,7 +4445,7 @@ public: * to the same underlying cl_sampler as the original. For details, see * clRetainSampler() and clReleaseSampler(). * - * \see cl_sampler + * \see cl_sampler */ class Sampler : public detail::Wrapper { @@ -4487,20 +4486,20 @@ public: } /*! \brief Copy constructor - performs shallow copy. - * + * * This calls clRetainSampler() on the parameter's cl_sampler. */ Sampler(const Sampler& sampler) : detail::Wrapper(sampler) {} /*! \brief Constructor from cl_sampler - takes ownership. - * + * * This effectively transfers ownership of a refcount on the cl_sampler * into the new Sampler object. */ Sampler(const cl_sampler& sampler) : detail::Wrapper(sampler) {} /*! \brief Assignment operator from Sampler. - * + * * This calls clRetainSampler() on the parameter and clReleaseSampler() * on the previous value held by this instance. */ @@ -4592,7 +4591,7 @@ public: } /*! \brief Conversion operator to const ::size_t *. - * + * * \returns a pointer to the size of the first dimension. */ operator const ::size_t*() const @@ -4680,20 +4679,20 @@ public: Kernel() {} /*! \brief Copy constructor - performs shallow copy. - * + * * This calls clRetainKernel() on the parameter's cl_kernel. */ Kernel(const Kernel& kernel) : detail::Wrapper(kernel) {} /*! \brief Constructor from cl_kernel - takes ownership. - * + * * This effectively transfers ownership of a refcount on the cl_kernel * into the new Kernel object. */ __CL_EXPLICIT_CONSTRUCTORS Kernel(const cl_kernel& kernel) : detail::Wrapper(kernel) {} /*! \brief Assignment operator from Kernel. - * + * * This calls clRetainKernel() on the parameter and clReleaseKernel() * on the previous value held by this instance. */ @@ -4962,7 +4961,7 @@ public: * Set to CL_INVALID_BINARY if the binary provided is not valid for the matching device. * \param err if non-NULL will be set to CL_SUCCESS on successful operation or one of the following errors: * CL_INVALID_CONTEXT if context is not a valid context. - * CL_INVALID_VALUE if the length of devices is zero; or if the length of binaries does not match the length of devices; + * CL_INVALID_VALUE if the length of devices is zero; or if the length of binaries does not match the length of devices; * or if any entry in binaries is NULL or has length 0. * CL_INVALID_DEVICE if OpenCL devices listed in devices are not in the list of devices associated with context. * CL_INVALID_BINARY if an invalid program binary was encountered for any device. binaryStatus will return specific status for each device. @@ -5688,7 +5687,7 @@ public: /** * Enqueue a command to fill a buffer object with a pattern * of a given size. The pattern is specified a as vector. - * \tparam PatternType The datatype of the pattern field. + * \tparam PatternType The datatype of the pattern field. * The pattern type must be an accepted OpenCL data type. */ template @@ -6033,14 +6032,14 @@ public: #if defined(CL_VERSION_1_2) /** - * Enqueues a marker command which waits for either a list of events to complete, + * Enqueues a marker command which waits for either a list of events to complete, * or all previously enqueued commands to complete. * - * Enqueues a marker command which waits for either a list of events to complete, - * or if the list is empty it waits for all commands previously enqueued in command_queue - * to complete before it completes. This command returns an event which can be waited on, - * i.e. this event can be waited on to insure that all events either in the event_wait_list - * or all previously enqueued commands, queued before this command to command_queue, + * Enqueues a marker command which waits for either a list of events to complete, + * or if the list is empty it waits for all commands previously enqueued in command_queue + * to complete before it completes. This command returns an event which can be waited on, + * i.e. this event can be waited on to insure that all events either in the event_wait_list + * or all previously enqueued commands, queued before this command to command_queue, * have completed. */ cl_int enqueueMarkerWithWaitList( @@ -6065,12 +6064,12 @@ public: /** * A synchronization point that enqueues a barrier operation. * - * Enqueues a barrier command which waits for either a list of events to complete, - * or if the list is empty it waits for all commands previously enqueued in command_queue - * to complete before it completes. This command blocks command execution, that is, any - * following commands enqueued after it do not execute until it completes. This command - * returns an event which can be waited on, i.e. this event can be waited on to insure that - * all events either in the event_wait_list or all previously enqueued commands, queued + * Enqueues a barrier command which waits for either a list of events to complete, + * or if the list is empty it waits for all commands previously enqueued in command_queue + * to complete before it completes. This command blocks command execution, that is, any + * following commands enqueued after it do not execute until it completes. This command + * returns an event which can be waited on, i.e. this event can be waited on to insure that + * all events either in the event_wait_list or all previously enqueued commands, queued * before this command to command_queue, have completed. */ cl_int enqueueBarrierWithWaitList( diff --git a/src/algorithms/libs/opencl/fft_execute.cc b/src/algorithms/libs/opencl/fft_execute.cc index baf3873be..23b2d1c83 100644 --- a/src/algorithms/libs/opencl/fft_execute.cc +++ b/src/algorithms/libs/opencl/fft_execute.cc @@ -46,11 +46,11 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#include "fft_internal.h" #include "clFFT.h" -#include -#include -#include +#include "fft_internal.h" +#include +#include +#include #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) @@ -67,7 +67,7 @@ allocateTemporaryBufferInterleaved(cl_fft_plan *plan, cl_uint batchSize) if (plan->tempmemobj) clReleaseMemObject(plan->tempmemobj); - plan->tempmemobj = clCreateBuffer(plan->context, CL_MEM_READ_WRITE, tmpLength, NULL, &err); + plan->tempmemobj = clCreateBuffer(plan->context, CL_MEM_READ_WRITE, tmpLength, nullptr, &err); } return err; } @@ -88,8 +88,8 @@ allocateTemporaryBufferPlannar(cl_fft_plan *plan, cl_uint batchSize) if (plan->tempmemobj_imag) clReleaseMemObject(plan->tempmemobj_imag); - plan->tempmemobj_real = clCreateBuffer(plan->context, CL_MEM_READ_WRITE, tmpLength, NULL, &err); - plan->tempmemobj_imag = clCreateBuffer(plan->context, CL_MEM_READ_WRITE, tmpLength, NULL, &terr); + plan->tempmemobj_real = clCreateBuffer(plan->context, CL_MEM_READ_WRITE, tmpLength, nullptr, &err); + plan->tempmemobj_imag = clCreateBuffer(plan->context, CL_MEM_READ_WRITE, tmpLength, nullptr, &terr); err |= terr; } return err; @@ -126,7 +126,7 @@ clFFT_ExecuteInterleaved(cl_command_queue queue, clFFT_Plan Plan, cl_int batchSi cl_int num_events, cl_event *event_list, cl_event *event) { int s; - cl_fft_plan *plan = (cl_fft_plan *)Plan; + auto *plan = (cl_fft_plan *)Plan; if (plan->format != clFFT_InterleavedComplexFormat) return CL_INVALID_VALUE; @@ -180,7 +180,7 @@ clFFT_ExecuteInterleaved(cl_command_queue queue, clFFT_Plan Plan, cl_int batchSi err |= clSetKernelArg(kernelInfo->kernel, 2, sizeof(cl_int), &dir); err |= clSetKernelArg(kernelInfo->kernel, 3, sizeof(cl_int), &s); - err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, NULL, &gWorkItems, &lWorkItems, 0, NULL, NULL); + err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, nullptr, &gWorkItems, &lWorkItems, 0, nullptr, nullptr); if (err) return err; @@ -203,7 +203,7 @@ clFFT_ExecuteInterleaved(cl_command_queue queue, clFFT_Plan Plan, cl_int batchSi err |= clSetKernelArg(kernelInfo->kernel, 2, sizeof(cl_int), &dir); err |= clSetKernelArg(kernelInfo->kernel, 3, sizeof(cl_int), &s); - err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, NULL, &gWorkItems, &lWorkItems, 0, NULL, NULL); + err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, nullptr, &gWorkItems, &lWorkItems, 0, nullptr, nullptr); if (err) return err; @@ -223,7 +223,7 @@ clFFT_ExecutePlannar(cl_command_queue queue, clFFT_Plan Plan, cl_int batchSize, cl_int num_events, cl_event *event_list, cl_event *event) { int s; - cl_fft_plan *plan = (cl_fft_plan *)Plan; + auto *plan = (cl_fft_plan *)Plan; if (plan->format != clFFT_SplitComplexFormat) return CL_INVALID_VALUE; @@ -285,7 +285,7 @@ clFFT_ExecutePlannar(cl_command_queue queue, clFFT_Plan Plan, cl_int batchSize, err |= clSetKernelArg(kernelInfo->kernel, 4, sizeof(cl_int), &dir); err |= clSetKernelArg(kernelInfo->kernel, 5, sizeof(cl_int), &s); - err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, NULL, &gWorkItems, &lWorkItems, 0, NULL, NULL); + err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, nullptr, &gWorkItems, &lWorkItems, 0, nullptr, nullptr); if (err) return err; @@ -309,7 +309,7 @@ clFFT_ExecutePlannar(cl_command_queue queue, clFFT_Plan Plan, cl_int batchSize, err |= clSetKernelArg(kernelInfo->kernel, 4, sizeof(cl_int), &dir); err |= clSetKernelArg(kernelInfo->kernel, 5, sizeof(cl_int), &s); - err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, NULL, &gWorkItems, &lWorkItems, 0, NULL, NULL); + err |= clEnqueueNDRangeKernel(queue, kernelInfo->kernel, 1, nullptr, &gWorkItems, &lWorkItems, 0, nullptr, nullptr); if (err) return err; @@ -327,7 +327,7 @@ cl_int clFFT_1DTwistInterleaved(clFFT_Plan Plan, cl_command_queue queue, cl_mem array, unsigned numRows, unsigned numCols, unsigned startRow, unsigned rowsToProcess, clFFT_Direction dir) { - cl_fft_plan *plan = (cl_fft_plan *)Plan; + auto *plan = (cl_fft_plan *)Plan; unsigned int N = numRows * numCols; unsigned int nCols = numCols; @@ -337,12 +337,12 @@ clFFT_1DTwistInterleaved(clFFT_Plan Plan, cl_command_queue queue, cl_mem array, int err = 0; cl_device_id device_id; - err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, sizeof(cl_device_id), &device_id, NULL); + err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, sizeof(cl_device_id), &device_id, nullptr); if (err) return err; size_t gSize; - err = clGetKernelWorkGroupInfo(plan->twist_kernel, device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &gSize, NULL); + err = clGetKernelWorkGroupInfo(plan->twist_kernel, device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &gSize, nullptr); if (err) return err; @@ -357,7 +357,7 @@ clFFT_1DTwistInterleaved(clFFT_Plan Plan, cl_command_queue queue, cl_mem array, err |= clSetKernelArg(plan->twist_kernel, 4, sizeof(unsigned int), &rToProcess); err |= clSetKernelArg(plan->twist_kernel, 5, sizeof(int), &d); - err |= clEnqueueNDRangeKernel(queue, plan->twist_kernel, 1, NULL, numGlobalThreads, numLocalThreads, 0, NULL, NULL); + err |= clEnqueueNDRangeKernel(queue, plan->twist_kernel, 1, nullptr, numGlobalThreads, numLocalThreads, 0, nullptr, nullptr); return err; } @@ -366,7 +366,7 @@ cl_int clFFT_1DTwistPlannar(clFFT_Plan Plan, cl_command_queue queue, cl_mem array_real, cl_mem array_imag, unsigned numRows, unsigned numCols, unsigned startRow, unsigned rowsToProcess, clFFT_Direction dir) { - cl_fft_plan *plan = (cl_fft_plan *)Plan; + auto *plan = (cl_fft_plan *)Plan; unsigned int N = numRows * numCols; unsigned int nCols = numCols; @@ -376,12 +376,12 @@ clFFT_1DTwistPlannar(clFFT_Plan Plan, cl_command_queue queue, cl_mem array_real, int err = 0; cl_device_id device_id; - err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, sizeof(cl_device_id), &device_id, NULL); + err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, sizeof(cl_device_id), &device_id, nullptr); if (err) return err; size_t gSize; - err = clGetKernelWorkGroupInfo(plan->twist_kernel, device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &gSize, NULL); + err = clGetKernelWorkGroupInfo(plan->twist_kernel, device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &gSize, nullptr); if (err) return err; @@ -397,7 +397,7 @@ clFFT_1DTwistPlannar(clFFT_Plan Plan, cl_command_queue queue, cl_mem array_real, err |= clSetKernelArg(plan->twist_kernel, 5, sizeof(unsigned int), &rToProcess); err |= clSetKernelArg(plan->twist_kernel, 6, sizeof(int), &d); - err |= clEnqueueNDRangeKernel(queue, plan->twist_kernel, 1, NULL, numGlobalThreads, numLocalThreads, 0, NULL, NULL); + err |= clEnqueueNDRangeKernel(queue, plan->twist_kernel, 1, nullptr, numGlobalThreads, numLocalThreads, 0, nullptr, nullptr); return err; } diff --git a/src/algorithms/libs/opencl/fft_internal.h b/src/algorithms/libs/opencl/fft_internal.h index 5e462f455..96a41c6de 100644 --- a/src/algorithms/libs/opencl/fft_internal.h +++ b/src/algorithms/libs/opencl/fft_internal.h @@ -51,8 +51,8 @@ #include "clFFT.h" #include -#include #include +#include using namespace std; diff --git a/src/algorithms/libs/opencl/fft_kernelstring.cc b/src/algorithms/libs/opencl/fft_kernelstring.cc index 733b60f42..33b3109e8 100644 --- a/src/algorithms/libs/opencl/fft_kernelstring.cc +++ b/src/algorithms/libs/opencl/fft_kernelstring.cc @@ -46,16 +46,16 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include +#include "clFFT.h" +#include "fft_internal.h" +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include "fft_internal.h" -#include "clFFT.h" using namespace std; @@ -806,13 +806,13 @@ createLocalMemfftKernelString(cl_fft_plan *plan) kernelName = string("fft") + num2str(kCount); *kInfo = (cl_fft_kernel_info *)malloc(sizeof(cl_fft_kernel_info)); - (*kInfo)->kernel = 0; + (*kInfo)->kernel = nullptr; (*kInfo)->lmem_size = 0; (*kInfo)->num_workgroups = 0; (*kInfo)->num_workitems_per_workgroup = 0; (*kInfo)->dir = cl_fft_kernel_x; (*kInfo)->in_place_possible = 1; - (*kInfo)->next = NULL; + (*kInfo)->next = nullptr; (*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1)); strcpy((*kInfo)->kernel_name, kernelName.c_str()); @@ -1015,7 +1015,7 @@ createGlobalFFTKernelString(cl_fft_plan *plan, int n, int BS, cl_fft_kernel_dir kernelName = string("fft") + num2str(kCount); *kInfo = (cl_fft_kernel_info *)malloc(sizeof(cl_fft_kernel_info)); - (*kInfo)->kernel = 0; + (*kInfo)->kernel = nullptr; if (R2 == 1) (*kInfo)->lmem_size = 0; else @@ -1033,7 +1033,7 @@ createGlobalFFTKernelString(cl_fft_plan *plan, int n, int BS, cl_fft_kernel_dir (*kInfo)->in_place_possible = 1; else (*kInfo)->in_place_possible = 0; - (*kInfo)->next = NULL; + (*kInfo)->next = nullptr; (*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1)); strcpy((*kInfo)->kernel_name, kernelName.c_str()); diff --git a/src/algorithms/libs/opencl/fft_setup.cc b/src/algorithms/libs/opencl/fft_setup.cc index 1349d65f7..a56c05328 100644 --- a/src/algorithms/libs/opencl/fft_setup.cc +++ b/src/algorithms/libs/opencl/fft_setup.cc @@ -46,16 +46,16 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#include "fft_internal.h" #include "fft_base_kernels.h" -#include -#include -#include -#include +#include "fft_internal.h" +#include +#include #include -#include -#include #include +#include +#include +#include +#include using namespace std; @@ -128,37 +128,37 @@ destroy_plan(cl_fft_plan *Plan) kernel_info = tmp; } - Plan->kernel_info = NULL; + Plan->kernel_info = nullptr; if (Plan->kernel_string) { delete Plan->kernel_string; - Plan->kernel_string = NULL; + Plan->kernel_string = nullptr; } if (Plan->twist_kernel) { clReleaseKernel(Plan->twist_kernel); - Plan->twist_kernel = NULL; + Plan->twist_kernel = nullptr; } if (Plan->program) { clReleaseProgram(Plan->program); - Plan->program = NULL; + Plan->program = nullptr; } if (Plan->tempmemobj) { clReleaseMemObject(Plan->tempmemobj); - Plan->tempmemobj = NULL; + Plan->tempmemobj = nullptr; } if (Plan->tempmemobj_real) { clReleaseMemObject(Plan->tempmemobj_real); - Plan->tempmemobj_real = NULL; + Plan->tempmemobj_real = nullptr; } if (Plan->tempmemobj_imag) { clReleaseMemObject(Plan->tempmemobj_imag); - Plan->tempmemobj_imag = NULL; + Plan->tempmemobj_imag = nullptr; } } @@ -201,7 +201,7 @@ int getMaxKernelWorkGroupSize(cl_fft_plan *plan, unsigned int *max_wg_size, unsi cl_fft_kernel_info *kInfo = plan->kernel_info; while (kInfo) { - err = clGetKernelWorkGroupInfo(kInfo->kernel, devices[i], CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &wg_size, NULL); + err = clGetKernelWorkGroupInfo(kInfo->kernel, devices[i], CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &wg_size, nullptr); if (err != CL_SUCCESS) return -1; @@ -235,7 +235,7 @@ clFFT_CreatePlan(cl_context context, clFFT_Dim3 n, clFFT_Dimension dim, clFFT_Da int i; cl_int err; int isPow2 = 1; - cl_fft_plan *plan = NULL; + cl_fft_plan *plan = nullptr; ostringstream kString; int num_devices; int gpu_found = 0; @@ -265,15 +265,15 @@ clFFT_CreatePlan(cl_context context, clFFT_Dim3 n, clFFT_Dimension dim, clFFT_Da plan->n = n; plan->dim = dim; plan->format = dataFormat; - plan->kernel_info = 0; + plan->kernel_info = nullptr; plan->num_kernels = 0; - plan->twist_kernel = 0; - plan->program = 0; + plan->twist_kernel = nullptr; + plan->program = nullptr; plan->temp_buffer_needed = 0; plan->last_batch_size = 0; - plan->tempmemobj = 0; - plan->tempmemobj_real = 0; - plan->tempmemobj_imag = 0; + plan->tempmemobj = nullptr; + plan->tempmemobj_real = nullptr; + plan->tempmemobj_imag = nullptr; plan->max_localmem_fft_size = 2048; plan->max_work_item_per_workgroup = 256; plan->max_radix = 16; @@ -289,7 +289,7 @@ patch_kernel_source: getBlockConfigAndKernelString(plan); const char *source_str = plan->kernel_string->c_str(); - plan->program = clCreateProgramWithSource(context, 1, (const char **)&source_str, NULL, &err); + plan->program = clCreateProgramWithSource(context, 1, (const char **)&source_str, nullptr, &err); ERR_MACRO(err); err = clGetContextInfo(context, CL_CONTEXT_DEVICES, sizeof(devices), devices, &ret_size); @@ -299,28 +299,28 @@ patch_kernel_source: for (i = 0; i < num_devices; i++) { - err = clGetDeviceInfo(devices[i], CL_DEVICE_TYPE, sizeof(device_type), &device_type, NULL); + err = clGetDeviceInfo(devices[i], CL_DEVICE_TYPE, sizeof(device_type), &device_type, nullptr); ERR_MACRO(err); if (device_type == CL_DEVICE_TYPE_GPU) { gpu_found = 1; - err = clBuildProgram(plan->program, 1, &devices[i], "-cl-mad-enable", NULL, NULL); + err = clBuildProgram(plan->program, 1, &devices[i], "-cl-mad-enable", nullptr, nullptr); if (err != CL_SUCCESS) { char *build_log; char devicename[200]; size_t log_size; - err = clGetProgramBuildInfo(plan->program, devices[i], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); + err = clGetProgramBuildInfo(plan->program, devices[i], CL_PROGRAM_BUILD_LOG, 0, nullptr, &log_size); ERR_MACRO(err); build_log = (char *)malloc(log_size + 1); - err = clGetProgramBuildInfo(plan->program, devices[i], CL_PROGRAM_BUILD_LOG, log_size, build_log, NULL); + err = clGetProgramBuildInfo(plan->program, devices[i], CL_PROGRAM_BUILD_LOG, log_size, build_log, nullptr); ERR_MACRO(err); - err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(devicename), devicename, NULL); + err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(devicename), devicename, nullptr); ERR_MACRO(err); fprintf(stdout, "FFT program build log on device %s\n", devicename); @@ -370,7 +370,7 @@ patch_kernel_source: void clFFT_DestroyPlan(clFFT_Plan plan) { - cl_fft_plan *Plan = (cl_fft_plan *)plan; + auto *Plan = (cl_fft_plan *)plan; if (Plan) { destroy_plan(Plan); @@ -388,7 +388,7 @@ void clFFT_DumpPlan(clFFT_Plan Plan, FILE *file) else out = file; - cl_fft_plan *plan = (cl_fft_plan *)Plan; + auto *plan = (cl_fft_plan *)Plan; cl_fft_kernel_info *kInfo = plan->kernel_info; while (kInfo) diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index 4859af83d..c2caa83db 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -38,7 +38,7 @@ using google::LogMessage; -Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string role, +Pass_Through::Pass_Through(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -47,7 +47,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro std::string default_item_type = "gr_complex"; std::string input_type = configuration->property(role + ".input_item_type", default_item_type); std::string output_type = configuration->property(role + ".output_item_type", default_item_type); - if (input_type.compare(output_type) != 0) + if (input_type != output_type) { LOG(WARNING) << "input_item_type and output_item_type are different in a Pass_Through implementation! Taking " << input_type @@ -57,11 +57,11 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro item_type_ = configuration->property(role + ".item_type", input_type); inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); - if (item_type_.compare("float") == 0) + if (item_type_ == "float") { item_size_ = sizeof(float); } - else if (item_type_.compare("gr_complex") == 0) + else if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); if (inverted_spectrum) @@ -69,15 +69,15 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro conjugate_cc_ = make_conjugate_cc(); } } - else if (item_type_.compare("short") == 0) + else if (item_type_ == "short") { item_size_ = sizeof(int16_t); } - else if (item_type_.compare("ishort") == 0) + else if (item_type_ == "ishort") { item_size_ = sizeof(int16_t); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); if (inverted_spectrum) @@ -85,15 +85,15 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro conjugate_sc_ = make_conjugate_sc(); } } - else if (item_type_.compare("byte") == 0) + else if (item_type_ == "byte") { item_size_ = sizeof(int8_t); } - else if (item_type_.compare("ibyte") == 0) + else if (item_type_ == "ibyte") { item_size_ = sizeof(int8_t); } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { item_size_ = sizeof(lv_8sc_t); if (inverted_spectrum) @@ -109,12 +109,20 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro kludge_copy_ = gr::blocks::copy::make(item_size_); DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + LOG(ERROR) << in_streams_; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + LOG(ERROR) << out_streams_; + } } -Pass_Through::~Pass_Through() -{ -} +Pass_Through::~Pass_Through() = default; void Pass_Through::connect(gr::top_block_sptr top_block) @@ -139,23 +147,20 @@ gr::basic_block_sptr Pass_Through::get_left_block() { if (inverted_spectrum) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return conjugate_cc_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return conjugate_sc_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return conjugate_ic_; } - else - { - LOG(WARNING) << "Setting inverted_spectrum to true with item_type " - << item_type_ << " is not defined and has no effect."; - } + LOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; } return kludge_copy_; @@ -166,23 +171,20 @@ gr::basic_block_sptr Pass_Through::get_right_block() { if (inverted_spectrum) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return conjugate_cc_; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return conjugate_sc_; } - else if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { return conjugate_ic_; } - else - { - DLOG(WARNING) << "Setting inverted_spectrum to true with item_type " - << item_type_ << " is not defined and has no effect."; - } + DLOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; } return kludge_copy_; diff --git a/src/algorithms/libs/pass_through.h b/src/algorithms/libs/pass_through.h index 83100eab2..7ef1838bf 100644 --- a/src/algorithms/libs/pass_through.h +++ b/src/algorithms/libs/pass_through.h @@ -34,11 +34,11 @@ #define GNSS_SDR_PASS_THROUGH_H_ #include "conjugate_cc.h" -#include "conjugate_sc.h" #include "conjugate_ic.h" +#include "conjugate_sc.h" #include "gnss_block_interface.h" -#include #include +#include #include @@ -51,7 +51,7 @@ class Pass_Through : public GNSSBlockInterface { public: Pass_Through(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_stream, unsigned int out_stream); diff --git a/src/core/system_parameters/rtcm.cc b/src/algorithms/libs/rtcm.cc similarity index 69% rename from src/core/system_parameters/rtcm.cc rename to src/algorithms/libs/rtcm.cc index 6fb5666bf..43915ee3b 100644 --- a/src/core/system_parameters/rtcm.cc +++ b/src/algorithms/libs/rtcm.cc @@ -29,13 +29,12 @@ */ #include "rtcm.h" -#include "Galileo_E1.h" #include "GPS_L2C.h" +#include "Galileo_E1.h" #include // for to_upper_copy #include #include #include -#include #include // for std::reverse #include // std::chrono::seconds #include // for std::fmod @@ -46,14 +45,14 @@ using google::LogMessage; -Rtcm::Rtcm(unsigned short port) +Rtcm::Rtcm(uint16_t port) { RTCM_port = port; preamble = std::bitset<8>("11010011"); reserved_field = std::bitset<6>("000000"); - rtcm_message_queue = std::make_shared >(); + rtcm_message_queue = std::make_shared >(); boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), RTCM_port); - servers.emplace_back(io_service, endpoint); + servers.emplace_back(io_context, endpoint); server_is_running = false; } @@ -85,13 +84,13 @@ Rtcm::~Rtcm() // ***************************************************************************************************** void Rtcm::run_server() { - std::cout << "Starting a TCP Server on port " << RTCM_port << std::endl; + std::cout << "Starting a TCP/IP server of RTCM messages on port " << RTCM_port << std::endl; try { - std::thread tq([&] { std::make_shared(io_service, rtcm_message_queue, RTCM_port)->do_read_queue(); }); + std::thread tq([&] { std::make_shared(io_context, rtcm_message_queue, RTCM_port)->do_read_queue(); }); tq.detach(); - std::thread t([&] { io_service.run(); }); + std::thread t([&] { io_context.run(); }); server_is_running = true; t.detach(); } @@ -104,13 +103,13 @@ void Rtcm::run_server() void Rtcm::stop_service() { - io_service.stop(); + io_context.stop(); } void Rtcm::stop_server() { - std::cout << "Stopping TCP Server on port " << RTCM_port << std::endl; + std::cout << "Stopping TCP/IP server on port " << RTCM_port << std::endl; rtcm_message_queue->push("Goodbye"); // this terminates tq Rtcm::stop_service(); servers.front().close_server(); @@ -141,9 +140,9 @@ std::string Rtcm::add_CRC(const std::string& message_without_crc) const { // ****** Computes Qualcomm CRC-24Q ****** boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> CRC_RTCM; - // 1) Converts the string to a vector of unsigned char: - boost::dynamic_bitset frame_bits(message_without_crc); - std::vector bytes; + // 1) Converts the string to a vector of uint8_t: + boost::dynamic_bitset frame_bits(message_without_crc); + std::vector bytes; boost::to_block_range(frame_bits, std::back_inserter(bytes)); std::reverse(bytes.begin(), bytes.end()); @@ -167,8 +166,8 @@ bool Rtcm::check_CRC(const std::string& message) const std::bitset<24> read_crc = std::bitset<24>(crc); std::string msg_without_crc = message_bin.substr(0, message_bin.length() - 24); - boost::dynamic_bitset frame_bits(msg_without_crc); - std::vector bytes; + boost::dynamic_bitset frame_bits(msg_without_crc); + std::vector bytes; boost::to_block_range(frame_bits, std::back_inserter(bytes)); std::reverse(bytes.begin(), bytes.end()); @@ -178,42 +177,42 @@ bool Rtcm::check_CRC(const std::string& message) const { return true; } - else - { - return false; - } + + return false; } std::string Rtcm::bin_to_binary_data(const std::string& s) const { std::string s_aux; - int remainder = static_cast(std::fmod(s.length(), 8)); - unsigned char c[s.length()]; - unsigned int k = 0; + auto remainder = static_cast(std::fmod(s.length(), 8)); + std::vector c; + c.reserve(s.length()); + + uint32_t k = 0; if (remainder != 0) { s_aux.assign(s, 0, remainder); boost::dynamic_bitset<> rembits(s_aux); - unsigned long int n = rembits.to_ulong(); - c[0] = static_cast(n); + uint64_t n = rembits.to_ulong(); + c[0] = static_cast(n); k++; } - unsigned int start = std::max(remainder, 0); - for (unsigned int i = start; i < s.length() - 1; i = i + 8) + uint32_t start = std::max(remainder, 0); + for (uint32_t i = start; i < s.length() - 1; i = i + 8) { s_aux.assign(s, i, 4); std::bitset<4> bs(s_aux); - unsigned n = bs.to_ulong(); + uint32_t n = bs.to_ulong(); s_aux.assign(s, i + 4, 4); std::bitset<4> bs2(s_aux); - unsigned n2 = bs2.to_ulong(); - c[k] = static_cast(n * 16) + static_cast(n2); + uint32_t n2 = bs2.to_ulong(); + c[k] = static_cast(n * 16) + static_cast(n2); k++; } - std::string ret(c, c + k / sizeof(c[0])); + std::string ret(c.begin(), c.begin() + k); return ret; } @@ -223,9 +222,9 @@ std::string Rtcm::binary_data_to_bin(const std::string& s) const std::string s_aux; std::stringstream ss; - for (unsigned int i = 0; i < s.length(); i++) + for (char i : s) { - unsigned char val = static_cast(s.at(i)); + auto val = static_cast(i); std::bitset<8> bs(val); ss << bs; } @@ -239,22 +238,22 @@ std::string Rtcm::bin_to_hex(const std::string& s) const { std::string s_aux; std::stringstream ss; - int remainder = static_cast(std::fmod(s.length(), 4)); + auto remainder = static_cast(std::fmod(s.length(), 4)); if (remainder != 0) { s_aux.assign(s, 0, remainder); boost::dynamic_bitset<> rembits(s_aux); - unsigned n = rembits.to_ulong(); + uint32_t n = rembits.to_ulong(); ss << std::hex << n; } - unsigned int start = std::max(remainder, 0); - for (unsigned int i = start; i < s.length() - 1; i = i + 4) + uint32_t start = std::max(remainder, 0); + for (uint32_t i = start; i < s.length() - 1; i = i + 4) { s_aux.assign(s, i, 4); std::bitset<4> bs(s_aux); - unsigned n = bs.to_ulong(); + uint32_t n = bs.to_ulong(); ss << std::hex << n; } return boost::to_upper_copy(ss.str()); @@ -268,9 +267,9 @@ std::string Rtcm::hex_to_bin(const std::string& s) const std::stringstream ss; ss << s; std::string s_lower = boost::to_upper_copy(ss.str()); - for (unsigned int i = 0; i < s.length(); i++) + for (uint32_t i = 0; i < s.length(); i++) { - unsigned long int n; + uint64_t n; std::istringstream(s_lower.substr(i, 1)) >> std::hex >> n; std::bitset<4> bs(n); s_aux += bs.to_string(); @@ -279,29 +278,29 @@ std::string Rtcm::hex_to_bin(const std::string& s) const } -unsigned long int Rtcm::bin_to_uint(const std::string& s) const +uint32_t Rtcm::bin_to_uint(const std::string& s) const { if (s.length() > 32) { - LOG(WARNING) << "Cannot convert to a unsigned long int"; + LOG(WARNING) << "Cannot convert to a uint32_t"; return 0; } - unsigned long int reading = strtoul(s.c_str(), NULL, 2); + uint32_t reading = strtoul(s.c_str(), nullptr, 2); return reading; } -long int Rtcm::bin_to_int(const std::string& s) const +int32_t Rtcm::bin_to_int(const std::string& s) const { if (s.length() > 32) { - LOG(WARNING) << "Cannot convert to a long int"; + LOG(WARNING) << "Cannot convert to a int32_t"; return 0; } - long int reading; + int32_t reading; // Handle negative numbers - if (s.substr(0, 1).compare("0")) + if (s.substr(0, 1) != "0") { // Computing two's complement boost::dynamic_bitset<> original_bitset(s); @@ -310,43 +309,49 @@ long int Rtcm::bin_to_int(const std::string& s) const } else { - reading = strtol(s.c_str(), NULL, 2); + reading = strtol(s.c_str(), nullptr, 2); } return reading; } -long int Rtcm::bin_to_sint(const std::string& s) const +int32_t Rtcm::bin_to_sint(const std::string& s) const { if (s.length() > 32) { - LOG(WARNING) << "Cannot convert to a long int"; + LOG(WARNING) << "Cannot convert to a int32_t"; return 0; } - long int reading; - long int sign; + int32_t reading; + int32_t sign; // Check for sign bit as defined RTCM doc - if (s.substr(0, 1).compare("0") == 0) + if (s.substr(0, 1) != "0") { sign = 1; // Get the magnitude of the value - reading = strtol((s.substr(1)).c_str(), NULL, 2); + reading = strtol((s.substr(1)).c_str(), nullptr, 2); } else { sign = -1; // Get the magnitude of the value - reading = strtol((s.substr(1)).c_str(), NULL, 2); + reading = strtol((s.substr(1)).c_str(), nullptr, 2); } return sign * reading; } // Find the sign for glonass data fields (neg = 1, pos = 0) -static inline unsigned long glo_sgn(double val) +static inline uint64_t glo_sgn(double val) { - if (val < 0) return 1; // If value is negative return 1 - if (val == 0) return 0; // Positive or equal to zero return 0 + if (val < 0) + { + return 1; // If value is negative return 1 + } + if (val == 0) + { + return 0; // Positive or equal to zero return 0 + } return 0; } @@ -360,21 +365,21 @@ double Rtcm::bin_to_double(const std::string& s) const return 0; } - long long int reading_int; + int64_t reading_int; // Handle negative numbers - if (s.substr(0, 1).compare("0")) + if (s.substr(0, 1) != "0") { // Computing two's complement boost::dynamic_bitset<> original_bitset(s); original_bitset.flip(); std::string aux; to_string(original_bitset, aux); - reading_int = -(strtoll(aux.c_str(), NULL, 2) + 1); + reading_int = -(strtoll(aux.c_str(), nullptr, 2) + 1); } else { - reading_int = strtoll(s.c_str(), NULL, 2); + reading_int = strtoll(s.c_str(), nullptr, 2); } reading = static_cast(reading_int); @@ -382,36 +387,36 @@ double Rtcm::bin_to_double(const std::string& s) const } -unsigned long int Rtcm::hex_to_uint(const std::string& s) const +uint64_t Rtcm::hex_to_uint(const std::string& s) const { if (s.length() > 32) { - LOG(WARNING) << "Cannot convert to a unsigned long int"; + LOG(WARNING) << "Cannot convert to a uint64_t"; return 0; } - unsigned long int reading = strtoul(s.c_str(), NULL, 16); + uint64_t reading = strtoul(s.c_str(), nullptr, 16); return reading; } -long int Rtcm::hex_to_int(const std::string& s) const +int64_t Rtcm::hex_to_int(const std::string& s) const { if (s.length() > 32) { - LOG(WARNING) << "Cannot convert to a long int"; + LOG(WARNING) << "Cannot convert to a int64_t"; return 0; } - long int reading = strtol(s.c_str(), NULL, 16); + int64_t reading = strtol(s.c_str(), nullptr, 16); return reading; } std::string Rtcm::build_message(const std::string& data) const { - unsigned int msg_length_bits = data.length(); - unsigned int msg_length_bytes = std::ceil(static_cast(msg_length_bits) / 8.0); + uint32_t msg_length_bits = data.length(); + uint32_t msg_length_bytes = std::ceil(static_cast(msg_length_bits) / 8.0); std::bitset<10> message_length = std::bitset<10>(msg_length_bytes); - unsigned int zeros_to_fill = 8 * msg_length_bytes - msg_length_bits; + uint32_t zeros_to_fill = 8 * msg_length_bytes - msg_length_bits; std::string b(zeros_to_fill, '0'); std::string msg_content = data + b; std::string msg_without_crc = preamble.to_string() + @@ -435,14 +440,14 @@ std::string Rtcm::build_message(const std::string& data) const // // ******************************************************** -std::bitset<64> Rtcm::get_MT1001_4_header(unsigned int msg_number, double obs_time, const std::map& observables, - unsigned int ref_id, unsigned int smooth_int, bool sync_flag, bool divergence_free) +std::bitset<64> Rtcm::get_MT1001_4_header(uint32_t msg_number, double obs_time, const std::map& observables, + uint32_t ref_id, uint32_t smooth_int, bool sync_flag, bool divergence_free) { - unsigned int reference_station_id = ref_id; // Max: 4095 - const std::map observables_ = observables; + uint32_t reference_station_id = ref_id; // Max: 4095 + const std::map& observables_ = observables; bool synchronous_GNSS_flag = sync_flag; bool divergence_free_smoothing_indicator = divergence_free; - unsigned int smoothing_interval = smooth_int; + uint32_t smoothing_interval = smooth_int; Rtcm::set_DF002(msg_number); Rtcm::set_DF003(reference_station_id); Rtcm::set_DF004(obs_time); @@ -484,16 +489,16 @@ std::bitset<58> Rtcm::get_MT1001_sat_content(const Gps_Ephemeris& eph, double ob } -std::string Rtcm::print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get a map with GPS L1 only observations - std::map observablesL1; - std::map::const_iterator observables_iter; + std::map observablesL1; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); @@ -501,9 +506,9 @@ std::string Rtcm::print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, co { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("G") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "G") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } } @@ -533,16 +538,16 @@ std::string Rtcm::print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, co // // ******************************************************** -std::string Rtcm::print_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get a map with GPS L1 only observations - std::map observablesL1; - std::map::const_iterator observables_iter; + std::map observablesL1; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); @@ -550,9 +555,9 @@ std::string Rtcm::print_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, co { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("G") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "G") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } } @@ -604,18 +609,18 @@ std::bitset<74> Rtcm::get_MT1002_sat_content(const Gps_Ephemeris& eph, double ob // // ******************************************************** -std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get maps with GPS L1 and L2 observations - std::map observablesL1; - std::map observablesL2; - std::map::const_iterator observables_iter; - std::map::const_iterator observables_iter2; + std::map observablesL1; + std::map observablesL2; + std::map::const_iterator observables_iter; + std::map::const_iterator observables_iter2; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); @@ -623,26 +628,26 @@ std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("G") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "G") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("G") == 0) && (sig_.compare("2S") == 0)) + if ((system_ == "G") && (sig_ == "2S")) { - observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); } } // Get common observables std::vector > common_observables; std::vector >::const_iterator common_observables_iter; - std::map observablesL1_with_L2; + std::map observablesL1_with_L2; for (observables_iter = observablesL1.cbegin(); observables_iter != observablesL1.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.cbegin(); observables_iter2 != observablesL2.cend(); observables_iter2++) @@ -654,7 +659,7 @@ std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme Gnss_Synchro pr2 = observables_iter2->second; p = std::make_pair(pr1, pr2); common_observables.push_back(p); - observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); } } } @@ -713,18 +718,18 @@ std::bitset<101> Rtcm::get_MT1003_sat_content(const Gps_Ephemeris& ephL1, const // // ****************************************************************** -std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get maps with GPS L1 and L2 observations - std::map observablesL1; - std::map observablesL2; - std::map::const_iterator observables_iter; - std::map::const_iterator observables_iter2; + std::map observablesL1; + std::map observablesL2; + std::map::const_iterator observables_iter; + std::map::const_iterator observables_iter2; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); @@ -732,26 +737,26 @@ std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("G") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "G") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("G") == 0) && (sig_.compare("2S") == 0)) + if ((system_ == "G") && (sig_ == "2S")) { - observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); } } // Get common observables std::vector > common_observables; std::vector >::const_iterator common_observables_iter; - std::map observablesL1_with_L2; + std::map observablesL1_with_L2; for (observables_iter = observablesL1.cbegin(); observables_iter != observablesL1.cend(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.cbegin(); observables_iter2 != observablesL2.cend(); observables_iter2++) @@ -763,7 +768,7 @@ std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme Gnss_Synchro pr2 = observables_iter2->second; p = std::make_pair(pr1, pr2); common_observables.push_back(p); - observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); } } } @@ -840,11 +845,11 @@ std::bitset<125> Rtcm::get_MT1004_sat_content(const Gps_Ephemeris& ephL1, const */ std::bitset<152> Rtcm::get_MT1005_test() { - unsigned int mt1005 = 1005; - unsigned int reference_station_id = 2003; // Max: 4095 - double ECEF_X = 1114104.5999; // units: m - double ECEF_Y = -4850729.7108; // units: m - double ECEF_Z = 3975521.4643; // units: m + uint32_t mt1005 = 1005; + uint32_t reference_station_id = 2003; // Max: 4095 + double ECEF_X = 1114104.5999; // units: m + double ECEF_Y = -4850729.7108; // units: m + double ECEF_Z = 3975521.4643; // units: m std::bitset<1> DF001_; @@ -881,9 +886,9 @@ std::bitset<152> Rtcm::get_MT1005_test() } -std::string Rtcm::print_MT1005(unsigned int ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, unsigned int quarter_cycle_indicator) +std::string Rtcm::print_MT1005(uint32_t ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, uint32_t quarter_cycle_indicator) { - unsigned int msg_number = 1005; + uint32_t msg_number = 1005; std::bitset<1> DF001_; Rtcm::set_DF002(msg_number); @@ -923,7 +928,7 @@ std::string Rtcm::print_MT1005(unsigned int ref_id, double ecef_x, double ecef_y } -int Rtcm::read_MT1005(const std::string& message, unsigned int& ref_id, double& ecef_x, double& ecef_y, double& ecef_z, bool& gps, bool& glonass, bool& galileo) +int32_t Rtcm::read_MT1005(const std::string& message, uint32_t& ref_id, double& ecef_x, double& ecef_y, double& ecef_z, bool& gps, bool& glonass, bool& galileo) { // Convert message to binary std::string message_bin = Rtcm::binary_data_to_bin(message); @@ -935,11 +940,11 @@ int Rtcm::read_MT1005(const std::string& message, unsigned int& ref_id, double& } // Check than the message number is correct - unsigned int preamble_length = 8; - unsigned int reserved_field_length = 6; - unsigned int index = preamble_length + reserved_field_length; + uint32_t preamble_length = 8; + uint32_t reserved_field_length = 6; + uint32_t index = preamble_length + reserved_field_length; - unsigned int read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; if (read_message_length != 19) { @@ -947,7 +952,7 @@ int Rtcm::read_MT1005(const std::string& message, unsigned int& ref_id, double& return 1; } - unsigned int msg_number = 1005; + uint32_t msg_number = 1005; Rtcm::set_DF002(msg_number); std::bitset<12> read_msg_number(message_bin.substr(index, 12)); index += 12; @@ -1002,9 +1007,9 @@ std::string Rtcm::print_MT1005_test() // // ******************************************************** -std::string Rtcm::print_MT1006(unsigned int ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, unsigned int quarter_cycle_indicator, double height) +std::string Rtcm::print_MT1006(uint32_t ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, uint32_t quarter_cycle_indicator, double height) { - unsigned int msg_number = 1006; + uint32_t msg_number = 1006; std::bitset<1> DF001_; Rtcm::set_DF002(msg_number); @@ -1051,13 +1056,13 @@ std::string Rtcm::print_MT1006(unsigned int ref_id, double ecef_x, double ecef_y // MESSAGE TYPE 1008 (ANTENNA DESCRIPTOR & SERIAL NUMBER) // // ******************************************************** -std::string Rtcm::print_MT1008(unsigned int ref_id, const std::string& antenna_descriptor, unsigned int antenna_setup_id, const std::string& antenna_serial_number) +std::string Rtcm::print_MT1008(uint32_t ref_id, const std::string& antenna_descriptor, uint32_t antenna_setup_id, const std::string& antenna_serial_number) { - unsigned int msg_number = 1008; + uint32_t msg_number = 1008; std::bitset<12> DF002_ = std::bitset<12>(msg_number); Rtcm::set_DF003(ref_id); std::string ant_descriptor = antenna_descriptor; - unsigned int len = ant_descriptor.length(); + uint32_t len = ant_descriptor.length(); if (len > 31) { ant_descriptor = ant_descriptor.substr(0, 31); @@ -1066,9 +1071,8 @@ std::string Rtcm::print_MT1008(unsigned int ref_id, const std::string& antenna_d DF029 = std::bitset<8>(len); std::string DF030_str_; - for (auto it = ant_descriptor.cbegin(); it != ant_descriptor.cend(); it++) + for (char c : ant_descriptor) { - char c = *it; std::bitset<8> character = std::bitset<8>(c); DF030_str_ += character.to_string(); } @@ -1076,7 +1080,7 @@ std::string Rtcm::print_MT1008(unsigned int ref_id, const std::string& antenna_d Rtcm::set_DF031(antenna_setup_id); std::string ant_sn(antenna_serial_number); - unsigned int len2 = ant_sn.length(); + uint32_t len2 = ant_sn.length(); if (len2 > 31) { ant_sn = ant_sn.substr(0, 31); @@ -1085,9 +1089,8 @@ std::string Rtcm::print_MT1008(unsigned int ref_id, const std::string& antenna_d DF032 = std::bitset<8>(len2); std::string DF033_str_; - for (auto it = ant_sn.cbegin(); it != ant_sn.cend(); it++) + for (char c : ant_sn) { - char c = *it; std::bitset<8> character = std::bitset<8>(c); DF033_str_ += character.to_string(); } @@ -1114,14 +1117,14 @@ std::string Rtcm::print_MT1008(unsigned int ref_id, const std::string& antenna_d // MESSAGE TYPE 1009 (GLONASS L1 Basic RTK Observables) // // ******************************************************** -std::bitset<61> Rtcm::get_MT1009_12_header(unsigned int msg_number, double obs_time, const std::map& observables, - unsigned int ref_id, unsigned int smooth_int, bool sync_flag, bool divergence_free) +std::bitset<61> Rtcm::get_MT1009_12_header(uint32_t msg_number, double obs_time, const std::map& observables, + uint32_t ref_id, uint32_t smooth_int, bool sync_flag, bool divergence_free) { - unsigned int reference_station_id = ref_id; // Max: 4095 - const std::map observables_ = observables; + uint32_t reference_station_id = ref_id; // Max: 4095 + const std::map& observables_ = observables; bool synchronous_GNSS_flag = sync_flag; bool divergence_free_smoothing_indicator = divergence_free; - unsigned int smoothing_interval = smooth_int; + uint32_t smoothing_interval = smooth_int; Rtcm::set_DF002(msg_number); Rtcm::set_DF003(reference_station_id); Rtcm::set_DF034(obs_time); @@ -1165,16 +1168,16 @@ std::bitset<64> Rtcm::get_MT1009_sat_content(const Glonass_Gnav_Ephemeris& eph, } -std::string Rtcm::print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get a map with GLONASS L1 only observations - std::map observablesL1; - std::map::const_iterator observables_iter; + std::map observablesL1; + std::map::const_iterator observables_iter; for (observables_iter = observables.begin(); observables_iter != observables.end(); @@ -1182,9 +1185,9 @@ std::string Rtcm::print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, d { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("R") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "R") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } } @@ -1214,16 +1217,16 @@ std::string Rtcm::print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, d // // ******************************************************** -std::string Rtcm::print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get a map with GPS L1 only observations - std::map observablesL1; - std::map::const_iterator observables_iter; + std::map observablesL1; + std::map::const_iterator observables_iter; for (observables_iter = observables.begin(); observables_iter != observables.end(); @@ -1231,9 +1234,9 @@ std::string Rtcm::print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, d { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("R") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "R") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } } @@ -1289,18 +1292,18 @@ std::bitset<79> Rtcm::get_MT1010_sat_content(const Glonass_Gnav_Ephemeris& eph, // // ******************************************************** -std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get maps with GPS L1 and L2 observations - std::map observablesL1; - std::map observablesL2; - std::map::const_iterator observables_iter; - std::map::const_iterator observables_iter2; + std::map observablesL1; + std::map observablesL2; + std::map::const_iterator observables_iter; + std::map::const_iterator observables_iter2; for (observables_iter = observables.begin(); observables_iter != observables.end(); @@ -1308,26 +1311,26 @@ std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonas { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("R") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "R") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("R") == 0) && (sig_.compare("2C") == 0)) + if ((system_ == "R") && (sig_ == "2C")) { - observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); } } // Get common observables std::vector > common_observables; std::vector >::const_iterator common_observables_iter; - std::map observablesL1_with_L2; + std::map observablesL1_with_L2; for (observables_iter = observablesL1.begin(); observables_iter != observablesL1.end(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.begin(); observables_iter2 != observablesL2.end(); observables_iter2++) @@ -1339,7 +1342,7 @@ std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonas Gnss_Synchro pr2 = observables_iter2->second; p = std::make_pair(pr1, pr2); common_observables.push_back(p); - observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); } } } @@ -1400,18 +1403,18 @@ std::bitset<107> Rtcm::get_MT1011_sat_content(const Glonass_Gnav_Ephemeris& ephL // // ****************************************************************** -std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const std::map& observables, unsigned short station_id) +std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - unsigned int ref_id = static_cast(station_id); - unsigned int smooth_int = 0; + auto ref_id = static_cast(station_id); + uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; //Get maps with GLONASS L1 and L2 observations - std::map observablesL1; - std::map observablesL2; - std::map::const_iterator observables_iter; - std::map::const_iterator observables_iter2; + std::map observablesL1; + std::map observablesL2; + std::map::const_iterator observables_iter; + std::map::const_iterator observables_iter2; for (observables_iter = observables.begin(); observables_iter != observables.end(); @@ -1419,26 +1422,26 @@ std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonas { std::string system_(&observables_iter->second.System, 1); std::string sig_(observables_iter->second.Signal); - if ((system_.compare("R") == 0) && (sig_.compare("1C") == 0)) + if ((system_ == "R") && (sig_ == "1C")) { - observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } - if ((system_.compare("R") == 0) && (sig_.compare("2C") == 0)) + if ((system_ == "R") && (sig_ == "2C")) { - observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL2.insert(std::pair(observables_iter->first, observables_iter->second)); } } // Get common observables std::vector > common_observables; std::vector >::const_iterator common_observables_iter; - std::map observablesL1_with_L2; + std::map observablesL1_with_L2; for (observables_iter = observablesL1.begin(); observables_iter != observablesL1.end(); observables_iter++) { - unsigned int prn_ = observables_iter->second.PRN; + uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.begin(); observables_iter2 != observablesL2.end(); observables_iter2++) @@ -1450,7 +1453,7 @@ std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonas Gnss_Synchro pr2 = observables_iter2->second; p = std::make_pair(pr1, pr2); common_observables.push_back(p); - observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); + observablesL1_with_L2.insert(std::pair(observables_iter->first, observables_iter->second)); } } } @@ -1519,7 +1522,7 @@ std::bitset<130> Rtcm::get_MT1012_sat_content(const Glonass_Gnav_Ephemeris& ephL std::string Rtcm::print_MT1019(const Gps_Ephemeris& gps_eph) { - unsigned int msg_number = 1019; + uint32_t msg_number = 1019; Rtcm::set_DF002(msg_number); Rtcm::set_DF009(gps_eph); @@ -1601,7 +1604,7 @@ std::string Rtcm::print_MT1019(const Gps_Ephemeris& gps_eph) } -int Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) +int32_t Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) { // Convert message to binary std::string message_bin = Rtcm::binary_data_to_bin(message); @@ -1612,11 +1615,11 @@ int Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) return 1; } - unsigned int preamble_length = 8; - unsigned int reserved_field_length = 6; - unsigned int index = preamble_length + reserved_field_length; + uint32_t preamble_length = 8; + uint32_t reserved_field_length = 6; + uint32_t index = preamble_length + reserved_field_length; - unsigned int read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; if (read_message_length != 61) @@ -1626,7 +1629,7 @@ int Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) } // Check than the message number is correct - unsigned int read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); + uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); index += 12; if (1019 != read_msg_number) @@ -1636,16 +1639,16 @@ int Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) } // Fill Gps Ephemeris with message data content - gps_eph.i_satellite_PRN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); + gps_eph.i_satellite_PRN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); index += 6; - gps_eph.i_GPS_week = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + gps_eph.i_GPS_week = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; - gps_eph.i_SV_accuracy = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 4))); + gps_eph.i_SV_accuracy = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 4))); index += 4; - gps_eph.i_code_on_L2 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 2))); + gps_eph.i_code_on_L2 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 2))); index += 2; gps_eph.d_IDOT = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 14))) * I_DOT_LSB; @@ -1718,7 +1721,7 @@ int Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) gps_eph.d_TGD = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 8))) * T_GD_LSB; index += 8; - gps_eph.i_SV_health = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); + gps_eph.i_SV_health = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); index += 6; gps_eph.b_L2_P_data_flag = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); @@ -1738,10 +1741,10 @@ int Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) std::string Rtcm::print_MT1020(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - unsigned int msg_number = 1020; - unsigned int glonass_gnav_alm_health = 0; - unsigned int glonass_gnav_alm_health_ind = 0; - unsigned int fifth_str_additional_data_ind = 1; + uint32_t msg_number = 1020; + uint32_t glonass_gnav_alm_health = 0; + uint32_t glonass_gnav_alm_health_ind = 0; + uint32_t fifth_str_additional_data_ind = 1; Rtcm::set_DF002(msg_number); Rtcm::set_DF038(glonass_gnav_eph); @@ -1834,13 +1837,13 @@ std::string Rtcm::print_MT1020(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, c } -int Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonass_gnav_eph, Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) +int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonass_gnav_eph, Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { // Convert message to binary std::string message_bin = Rtcm::binary_data_to_bin(message); - int glonass_gnav_alm_health = 0; - int glonass_gnav_alm_health_ind = 0; - int fifth_str_additional_data_ind = 0; + int32_t glonass_gnav_alm_health = 0; + int32_t glonass_gnav_alm_health_ind = 0; + int32_t fifth_str_additional_data_ind = 0; if (!Rtcm::check_CRC(message)) { @@ -1848,11 +1851,11 @@ int Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonas return 1; } - unsigned int preamble_length = 8; - unsigned int reserved_field_length = 6; - unsigned int index = preamble_length + reserved_field_length; + uint32_t preamble_length = 8; + uint32_t reserved_field_length = 6; + uint32_t index = preamble_length + reserved_field_length; - unsigned int read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; if (read_message_length != 45) // 360 bits = 45 bytes @@ -1862,7 +1865,7 @@ int Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonas } // Check than the message number is correct - unsigned int read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); + uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); index += 12; if (1020 != read_msg_number) @@ -1872,19 +1875,19 @@ int Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonas } // Fill Gps Ephemeris with message data content - glonass_gnav_eph.i_satellite_slot_number = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); + glonass_gnav_eph.i_satellite_slot_number = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); index += 6; - glonass_gnav_eph.i_satellite_freq_channel = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 5)) - 7.0); + glonass_gnav_eph.i_satellite_freq_channel = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 5)) - 7.0); index += 5; - glonass_gnav_alm_health = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); + glonass_gnav_alm_health = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); index += 1; if (glonass_gnav_alm_health) { } //Avoid comiler warning - glonass_gnav_alm_health_ind = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); + glonass_gnav_alm_health_ind = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); index += 1; if (glonass_gnav_alm_health_ind) { @@ -1988,7 +1991,7 @@ int Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonas glonass_gnav_utc_model.d_tau_gps = static_cast(Rtcm::bin_to_sint(message_bin.substr(index, 22))) * TWO_N30; index += 22; - glonass_gnav_eph.d_l5th_n = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); + glonass_gnav_eph.d_l5th_n = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); } return 0; @@ -2001,21 +2004,20 @@ int Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonas // // ******************************************************** -std::string Rtcm::print_MT1029(unsigned int ref_id, const Gps_Ephemeris& gps_eph, double obs_time, const std::string& message) +std::string Rtcm::print_MT1029(uint32_t ref_id, const Gps_Ephemeris& gps_eph, double obs_time, const std::string& message) { - unsigned int msg_number = 1029; + uint32_t msg_number = 1029; Rtcm::set_DF002(msg_number); Rtcm::set_DF003(ref_id); Rtcm::set_DF051(gps_eph, obs_time); Rtcm::set_DF052(gps_eph, obs_time); - unsigned int i = 0; + uint32_t i = 0; bool first = true; std::string text_binary; - for (auto it = message.cbegin(); it != message.cend(); it++) + for (char c : message) { - char c = *it; if (isgraph(c)) { i++; @@ -2070,7 +2072,7 @@ std::string Rtcm::print_MT1029(unsigned int ref_id, const Gps_Ephemeris& gps_eph std::string Rtcm::print_MT1045(const Galileo_Ephemeris& gal_eph) { - unsigned int msg_number = 1045; + uint32_t msg_number = 1045; Rtcm::set_DF002(msg_number); Rtcm::set_DF252(gal_eph); @@ -2099,7 +2101,7 @@ std::string Rtcm::print_MT1045(const Galileo_Ephemeris& gal_eph) Rtcm::set_DF312(gal_eph); Rtcm::set_DF314(gal_eph); Rtcm::set_DF315(gal_eph); - unsigned int seven_zero = 0; + uint32_t seven_zero = 0; std::bitset<7> DF001_ = std::bitset<7>(seven_zero); std::string data; @@ -2148,7 +2150,7 @@ std::string Rtcm::print_MT1045(const Galileo_Ephemeris& gal_eph) } -int Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph) +int32_t Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph) { // Convert message to binary std::string message_bin = Rtcm::binary_data_to_bin(message); @@ -2159,11 +2161,11 @@ int Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph) return 1; } - unsigned int preamble_length = 8; - unsigned int reserved_field_length = 6; - unsigned int index = preamble_length + reserved_field_length; + uint32_t preamble_length = 8; + uint32_t reserved_field_length = 6; + uint32_t index = preamble_length + reserved_field_length; - unsigned int read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; if (read_message_length != 62) @@ -2173,7 +2175,7 @@ int Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph) } // Check than the message number is correct - unsigned int read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); + uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); index += 12; if (1045 != read_msg_number) @@ -2183,82 +2185,82 @@ int Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph) } // Fill Galileo Ephemeris with message data content - gal_eph.i_satellite_PRN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); + gal_eph.i_satellite_PRN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); index += 6; gal_eph.WN_5 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 12))); index += 12; - gal_eph.IOD_nav_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + gal_eph.IOD_nav_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; gal_eph.SISA_3 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 8))); index += 8; - gal_eph.iDot_2 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 14))) * iDot_2_LSB; + gal_eph.iDot_2 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 14))) * I_DOT_2_LSB; index += 14; - gal_eph.t0c_4 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 14))) * t0c_4_LSB; + gal_eph.t0c_4 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 14))) * T0C_4_LSB; index += 14; - gal_eph.af2_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 6))) * af2_4_LSB; + gal_eph.af2_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 6))) * AF2_4_LSB; index += 6; - gal_eph.af1_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 21))) * af1_4_LSB; + gal_eph.af1_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 21))) * AF1_4_LSB; index += 21; - gal_eph.af0_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 31))) * af0_4_LSB; + gal_eph.af0_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 31))) * AF0_4_LSB; index += 31; - gal_eph.C_rs_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_rs_3_LSB; + gal_eph.C_rs_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_RS_3_LSB; index += 16; - gal_eph.delta_n_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * delta_n_3_LSB; + gal_eph.delta_n_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * DELTA_N_3_LSB; index += 16; gal_eph.M0_1 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 32))) * M0_1_LSB; index += 32; - gal_eph.C_uc_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_uc_3_LSB; + gal_eph.C_uc_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_UC_3_LSB; index += 16; - gal_eph.e_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 32))) * e_1_LSB; + gal_eph.e_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 32))) * E_1_LSB; index += 32; - gal_eph.C_us_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_us_3_LSB; + gal_eph.C_us_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_US_3_LSB; index += 16; - gal_eph.A_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 32))) * A_1_LSB_gal; + gal_eph.A_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 32))) * A_1_LSB_GAL; index += 32; - gal_eph.t0e_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 14))) * t0e_1_LSB; + gal_eph.t0e_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 14))) * T0E_1_LSB; index += 14; - gal_eph.C_ic_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_ic_4_LSB; + gal_eph.C_ic_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_IC_4_LSB; index += 16; gal_eph.OMEGA_0_2 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 32))) * OMEGA_0_2_LSB; index += 32; - gal_eph.C_is_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_is_4_LSB; + gal_eph.C_is_4 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_IS_4_LSB; index += 16; - gal_eph.i_0_2 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 32))) * i_0_2_LSB; + gal_eph.i_0_2 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 32))) * I_0_2_LSB; index += 32; - gal_eph.C_rc_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_rc_3_LSB; + gal_eph.C_rc_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 16))) * C_RC_3_LSB; index += 16; - gal_eph.omega_2 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 32))) * omega_2_LSB; + gal_eph.omega_2 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 32))) * OMEGA_2_LSB; index += 32; - gal_eph.OMEGA_dot_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 24))) * OMEGA_dot_3_LSB; + gal_eph.OMEGA_dot_3 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 24))) * OMEGA_DOT_3_LSB; index += 24; gal_eph.BGD_E1E5a_5 = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 10))); index += 10; - gal_eph.E5a_HS = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 2))); + gal_eph.E5a_HS = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 2))); index += 2; gal_eph.E5a_DVS = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); @@ -2278,19 +2280,31 @@ std::string Rtcm::print_MSM_1(const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { - unsigned int msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1071; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1071; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1081; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1091; + uint32_t msg_number = 0; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1071; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1071; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1081; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1091; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2326,18 +2340,18 @@ std::string Rtcm::print_MSM_1(const Gps_Ephemeris& gps_eph, } -std::string Rtcm::get_MSM_header(unsigned int msg_number, +std::string Rtcm::get_MSM_header(uint32_t msg_number, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { // Find first element in observables block and define type of message - std::map::const_iterator observables_iter = observables.begin(); + auto observables_iter = observables.begin(); std::string sys(observables_iter->second.System, 1); Rtcm::set_DF002(msg_number); @@ -2355,7 +2369,7 @@ std::string Rtcm::get_MSM_header(unsigned int msg_number, std::string header = DF002.to_string() + DF003.to_string(); // GNSS Epoch Time Specific to each constellation - if ((sys.compare("R") == 0)) + if ((sys == "R")) { // GLONASS Epoch Time Rtcm::set_DF034(obs_time); @@ -2383,18 +2397,18 @@ std::string Rtcm::get_MSM_header(unsigned int msg_number, } -std::string Rtcm::get_MSM_1_content_sat_data(const std::map& observables) +std::string Rtcm::get_MSM_1_content_sat_data(const std::map& observables) { std::string sat_data; sat_data.clear(); Rtcm::set_DF394(observables); - unsigned int num_satellites = DF394.count(); + uint32_t num_satellites = DF394.count(); - std::vector > observables_vector; - std::map::const_iterator gnss_synchro_iter; - std::vector pos; - std::vector::iterator it; + std::vector > observables_vector; + std::map::const_iterator gnss_synchro_iter; + std::vector pos; + std::vector::iterator it; for (gnss_synchro_iter = observables.cbegin(); gnss_synchro_iter != observables.cend(); @@ -2408,9 +2422,9 @@ std::string Rtcm::get_MSM_1_content_sat_data(const std::map& } } - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); - for (unsigned int nsat = 0; nsat < num_satellites; nsat++) + for (uint32_t nsat = 0; nsat < num_satellites; nsat++) { Rtcm::set_DF398(ordered_by_PRN_pos.at(nsat).second); sat_data += DF398.to_string(); @@ -2420,14 +2434,14 @@ std::string Rtcm::get_MSM_1_content_sat_data(const std::map& } -std::string Rtcm::get_MSM_1_content_signal_data(const std::map& observables) +std::string Rtcm::get_MSM_1_content_signal_data(const std::map& observables) { std::string signal_data; signal_data.clear(); - unsigned int Ncells = observables.size(); + uint32_t Ncells = observables.size(); - std::vector > observables_vector; - std::map::const_iterator map_iter; + std::vector > observables_vector; + std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); map_iter != observables.cend(); @@ -2436,11 +2450,11 @@ std::string Rtcm::get_MSM_1_content_signal_data(const std::map > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); + std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); - for (unsigned int cell = 0; cell < Ncells; cell++) + for (uint32_t cell = 0; cell < Ncells; cell++) { Rtcm::set_DF400(ordered_by_PRN_pos.at(cell).second); signal_data += DF400.to_string(); @@ -2461,19 +2475,31 @@ std::string Rtcm::print_MSM_2(const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { - unsigned int msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1072; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1072; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1082; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1092; + uint32_t msg_number = 0; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1072; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1072; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1082; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1092; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2513,17 +2539,17 @@ std::string Rtcm::get_MSM_2_content_signal_data(const Gps_Ephemeris& ephNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, - const std::map& observables) + const std::map& observables) { std::string signal_data; std::string first_data_type; std::string second_data_type; std::string third_data_type; - unsigned int Ncells = observables.size(); + uint32_t Ncells = observables.size(); - std::vector > observables_vector; - std::map::const_iterator map_iter; + std::vector > observables_vector; + std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); map_iter != observables.cend(); @@ -2532,11 +2558,11 @@ std::string Rtcm::get_MSM_2_content_signal_data(const Gps_Ephemeris& ephNAV, observables_vector.push_back(*map_iter); } - std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); + std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); - for (unsigned int cell = 0; cell < Ncells; cell++) + for (uint32_t cell = 0; cell < Ncells; cell++) { Rtcm::set_DF401(ordered_by_PRN_pos.at(cell).second); Rtcm::set_DF402(ephNAV, ephCNAV, ephFNAV, ephGNAV, obs_time, ordered_by_PRN_pos.at(cell).second); @@ -2562,19 +2588,31 @@ std::string Rtcm::print_MSM_3(const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { - unsigned int msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1073; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1073; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1083; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1093; + uint32_t msg_number = 0; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1073; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1073; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1083; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1093; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2614,7 +2652,7 @@ std::string Rtcm::get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, - const std::map& observables) + const std::map& observables) { std::string signal_data; std::string first_data_type; @@ -2622,10 +2660,10 @@ std::string Rtcm::get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV, std::string third_data_type; std::string fourth_data_type; - unsigned int Ncells = observables.size(); + uint32_t Ncells = observables.size(); - std::vector > observables_vector; - std::map::const_iterator map_iter; + std::vector > observables_vector; + std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); map_iter != observables.cend(); @@ -2634,11 +2672,11 @@ std::string Rtcm::get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV, observables_vector.push_back(*map_iter); } - std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); + std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); - for (unsigned int cell = 0; cell < Ncells; cell++) + for (uint32_t cell = 0; cell < Ncells; cell++) { Rtcm::set_DF400(ordered_by_PRN_pos.at(cell).second); Rtcm::set_DF401(ordered_by_PRN_pos.at(cell).second); @@ -2666,19 +2704,31 @@ std::string Rtcm::print_MSM_4(const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { - unsigned int msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1074; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1074; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1084; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1094; + uint32_t msg_number = 0; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1074; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1074; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1084; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1094; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2713,19 +2763,19 @@ std::string Rtcm::print_MSM_4(const Gps_Ephemeris& gps_eph, } -std::string Rtcm::get_MSM_4_content_sat_data(const std::map& observables) +std::string Rtcm::get_MSM_4_content_sat_data(const std::map& observables) { std::string sat_data; std::string first_data_type; std::string second_data_type; Rtcm::set_DF394(observables); - unsigned int num_satellites = DF394.count(); + uint32_t num_satellites = DF394.count(); - std::vector > observables_vector; - std::map::const_iterator gnss_synchro_iter; - std::vector pos; - std::vector::iterator it; + std::vector > observables_vector; + std::map::const_iterator gnss_synchro_iter; + std::vector pos; + std::vector::iterator it; for (gnss_synchro_iter = observables.cbegin(); gnss_synchro_iter != observables.cend(); @@ -2739,9 +2789,9 @@ std::string Rtcm::get_MSM_4_content_sat_data(const std::map& } } - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); - for (unsigned int nsat = 0; nsat < num_satellites; nsat++) + for (uint32_t nsat = 0; nsat < num_satellites; nsat++) { Rtcm::set_DF397(ordered_by_PRN_pos.at(nsat).second); Rtcm::set_DF398(ordered_by_PRN_pos.at(nsat).second); @@ -2758,7 +2808,7 @@ std::string Rtcm::get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, - const std::map& observables) + const std::map& observables) { std::string signal_data; std::string first_data_type; @@ -2767,10 +2817,10 @@ std::string Rtcm::get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fourth_data_type; std::string fifth_data_type; - unsigned int Ncells = observables.size(); + uint32_t Ncells = observables.size(); - std::vector > observables_vector; - std::map::const_iterator map_iter; + std::vector > observables_vector; + std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); map_iter != observables.cend(); @@ -2779,11 +2829,11 @@ std::string Rtcm::get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV, observables_vector.push_back(*map_iter); } - std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); + std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); - for (unsigned int cell = 0; cell < Ncells; cell++) + for (uint32_t cell = 0; cell < Ncells; cell++) { Rtcm::set_DF400(ordered_by_PRN_pos.at(cell).second); Rtcm::set_DF401(ordered_by_PRN_pos.at(cell).second); @@ -2813,19 +2863,31 @@ std::string Rtcm::print_MSM_5(const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { - unsigned int msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1075; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1075; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1085; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1095; + uint32_t msg_number = 0; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1075; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1075; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1085; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1095; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2860,7 +2922,7 @@ std::string Rtcm::print_MSM_5(const Gps_Ephemeris& gps_eph, } -std::string Rtcm::get_MSM_5_content_sat_data(const std::map& observables) +std::string Rtcm::get_MSM_5_content_sat_data(const std::map& observables) { std::string sat_data; std::string first_data_type; @@ -2869,12 +2931,12 @@ std::string Rtcm::get_MSM_5_content_sat_data(const std::map& std::string fourth_data_type; Rtcm::set_DF394(observables); - unsigned int num_satellites = DF394.count(); + uint32_t num_satellites = DF394.count(); - std::vector > observables_vector; - std::map::const_iterator gnss_synchro_iter; - std::vector pos; - std::vector::iterator it; + std::vector > observables_vector; + std::map::const_iterator gnss_synchro_iter; + std::vector pos; + std::vector::iterator it; for (gnss_synchro_iter = observables.cbegin(); gnss_synchro_iter != observables.cend(); @@ -2888,9 +2950,9 @@ std::string Rtcm::get_MSM_5_content_sat_data(const std::map& } } - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); - for (unsigned int nsat = 0; nsat < num_satellites; nsat++) + for (uint32_t nsat = 0; nsat < num_satellites; nsat++) { Rtcm::set_DF397(ordered_by_PRN_pos.at(nsat).second); Rtcm::set_DF398(ordered_by_PRN_pos.at(nsat).second); @@ -2911,7 +2973,7 @@ std::string Rtcm::get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, - const std::map& observables) + const std::map& observables) { std::string signal_data; std::string first_data_type; @@ -2921,10 +2983,10 @@ std::string Rtcm::get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fifth_data_type; std::string sixth_data_type; - unsigned int Ncells = observables.size(); + uint32_t Ncells = observables.size(); - std::vector > observables_vector; - std::map::const_iterator map_iter; + std::vector > observables_vector; + std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); map_iter != observables.cend(); @@ -2933,11 +2995,11 @@ std::string Rtcm::get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV, observables_vector.push_back(*map_iter); } - std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); + std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); - for (unsigned int cell = 0; cell < Ncells; cell++) + for (uint32_t cell = 0; cell < Ncells; cell++) { Rtcm::set_DF400(ordered_by_PRN_pos.at(cell).second); Rtcm::set_DF401(ordered_by_PRN_pos.at(cell).second); @@ -2969,19 +3031,31 @@ std::string Rtcm::print_MSM_6(const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { - unsigned int msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1076; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1076; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1086; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1096; + uint32_t msg_number = 0; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1076; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1076; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1086; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1096; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -3021,7 +3095,7 @@ std::string Rtcm::get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, - const std::map& observables) + const std::map& observables) { std::string signal_data; std::string first_data_type; @@ -3030,10 +3104,10 @@ std::string Rtcm::get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fourth_data_type; std::string fifth_data_type; - unsigned int Ncells = observables.size(); + uint32_t Ncells = observables.size(); - std::vector > observables_vector; - std::map::const_iterator map_iter; + std::vector > observables_vector; + std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); map_iter != observables.cend(); @@ -3042,11 +3116,11 @@ std::string Rtcm::get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV, observables_vector.push_back(*map_iter); } - std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); + std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); - for (unsigned int cell = 0; cell < Ncells; cell++) + for (uint32_t cell = 0; cell < Ncells; cell++) { Rtcm::set_DF405(ordered_by_PRN_pos.at(cell).second); Rtcm::set_DF406(ordered_by_PRN_pos.at(cell).second); @@ -3076,19 +3150,31 @@ std::string Rtcm::print_MSM_7(const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages) { - unsigned int msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1077; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1077; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1087; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1097; + uint32_t msg_number = 0; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1077; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1077; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1087; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1097; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (glo_gnav_eph.i_satellite_PRN != 0) && (gal_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -3128,7 +3214,7 @@ std::string Rtcm::get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, - const std::map& observables) + const std::map& observables) { std::string signal_data; std::string first_data_type; @@ -3138,10 +3224,10 @@ std::string Rtcm::get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fifth_data_type; std::string sixth_data_type; - unsigned int Ncells = observables.size(); + uint32_t Ncells = observables.size(); - std::vector > observables_vector; - std::map::const_iterator map_iter; + std::vector > observables_vector; + std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); map_iter != observables.cend(); @@ -3150,11 +3236,11 @@ std::string Rtcm::get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, observables_vector.push_back(*map_iter); } - std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); + std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); - for (unsigned int cell = 0; cell < Ncells; cell++) + for (uint32_t cell = 0; cell < Ncells; cell++) { Rtcm::set_DF405(ordered_by_PRN_pos.at(cell).second); Rtcm::set_DF406(ordered_by_PRN_pos.at(cell).second); @@ -3179,16 +3265,16 @@ std::string Rtcm::get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, // Some utilities // ***************************************************************************************************** -std::vector > Rtcm::sort_by_PRN_mask(const std::vector >& synchro_map) const +std::vector > Rtcm::sort_by_PRN_mask(const std::vector >& synchro_map) const { - std::vector >::const_iterator synchro_map_iter; - std::vector > my_vec; + std::vector >::const_iterator synchro_map_iter; + std::vector > my_vec; struct { - bool operator()(const std::pair& a, const std::pair& b) + bool operator()(const std::pair& a, const std::pair& b) { - unsigned int value_a = 64 - a.second.PRN; - unsigned int value_b = 64 - b.second.PRN; + uint32_t value_a = 64 - a.second.PRN; + uint32_t value_b = 64 - b.second.PRN; return value_a < value_b; } } has_lower_pos; @@ -3198,7 +3284,7 @@ std::vector > Rtcm::sort_by_PRN_mask(const std::vec synchro_map_iter++) { - std::pair p(synchro_map_iter->first, synchro_map_iter->second); + std::pair p(synchro_map_iter->first, synchro_map_iter->second); my_vec.push_back(p); } @@ -3208,17 +3294,17 @@ std::vector > Rtcm::sort_by_PRN_mask(const std::vec } -std::vector > Rtcm::sort_by_signal(const std::vector >& synchro_map) const +std::vector > Rtcm::sort_by_signal(const std::vector >& synchro_map) const { - std::vector >::const_iterator synchro_map_iter; - std::vector > my_vec; + std::vector >::const_iterator synchro_map_iter; + std::vector > my_vec; struct { - bool operator()(const std::pair& a, const std::pair& b) + bool operator()(const std::pair& a, const std::pair& b) { - unsigned int value_a = 0; - unsigned int value_b = 0; + uint32_t value_a = 0; + uint32_t value_b = 0; std::string system_a(&a.second.System, 1); std::string system_b(&b.second.System, 1); std::string sig_a_(a.second.Signal); @@ -3226,22 +3312,22 @@ std::vector > Rtcm::sort_by_signal(const std::vecto std::string sig_b_(b.second.Signal); std::string sig_b = sig_b_.substr(0, 2); - if (system_a.compare("G") == 0) + if (system_a == "G") { value_a = gps_signal_map.at(sig_a); } - if (system_a.compare("E") == 0) + if (system_a == "E") { value_a = galileo_signal_map.at(sig_a); } - if (system_b.compare("G") == 0) + if (system_b == "G") { value_b = gps_signal_map.at(sig_b); } - if (system_b.compare("E") == 0) + if (system_b == "E") { value_b = galileo_signal_map.at(sig_b); } @@ -3256,7 +3342,7 @@ std::vector > Rtcm::sort_by_signal(const std::vecto synchro_map_iter++) { - std::pair p(synchro_map_iter->first, synchro_map_iter->second); + std::pair p(synchro_map_iter->first, synchro_map_iter->second); my_vec.push_back(p); } @@ -3313,7 +3399,7 @@ std::map Rtcm::galileo_signal_map = [] { boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -3322,7 +3408,7 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -3331,7 +3417,7 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, d boost::posix_time::ptime Rtcm::compute_Galileo_time(const Galileo_Ephemeris& eph, double obs_time) const { double galileo_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -3344,9 +3430,9 @@ boost::posix_time::ptime Rtcm::compute_GLONASS_time(const Glonass_Gnav_Ephemeris } -unsigned int Rtcm::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_in_seconds; + uint32_t lock_time_in_seconds; boost::posix_time::ptime current_time = Rtcm::compute_GPS_time(eph, obs_time); boost::posix_time::ptime last_lock_time = Rtcm::gps_L1_last_lock_time[65 - gnss_synchro.PRN]; if (last_lock_time.is_not_a_date_time()) // || CHECK LLI!!......) @@ -3354,16 +3440,16 @@ unsigned int Rtcm::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gn Rtcm::gps_L1_last_lock_time[65 - gnss_synchro.PRN] = current_time; } boost::posix_time::time_duration lock_duration = current_time - Rtcm::gps_L1_last_lock_time[65 - gnss_synchro.PRN]; - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + lock_time_in_seconds = static_cast(lock_duration.total_seconds()); // Debug: // std::cout << "lock time PRN " << gnss_synchro.PRN << ": " << lock_time_in_seconds << " current time: " << current_time << std::endl; return lock_time_in_seconds; } -unsigned int Rtcm::lock_time(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm::lock_time(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_in_seconds; + uint32_t lock_time_in_seconds; boost::posix_time::ptime current_time = Rtcm::compute_GPS_time(eph, obs_time); boost::posix_time::ptime last_lock_time = Rtcm::gps_L2_last_lock_time[65 - gnss_synchro.PRN]; if (last_lock_time.is_not_a_date_time()) // || CHECK LLI!!......) @@ -3371,135 +3457,201 @@ unsigned int Rtcm::lock_time(const Gps_CNAV_Ephemeris& eph, double obs_time, con Rtcm::gps_L2_last_lock_time[65 - gnss_synchro.PRN] = current_time; } boost::posix_time::time_duration lock_duration = current_time - Rtcm::gps_L2_last_lock_time[65 - gnss_synchro.PRN]; - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + lock_time_in_seconds = static_cast(lock_duration.total_seconds()); return lock_time_in_seconds; } -unsigned int Rtcm::lock_time(const Galileo_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm::lock_time(const Galileo_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_in_seconds; + uint32_t lock_time_in_seconds; boost::posix_time::ptime current_time = Rtcm::compute_Galileo_time(eph, obs_time); boost::posix_time::ptime last_lock_time; std::string sig_(gnss_synchro.Signal); - if (sig_.compare("1B") == 0) + if (sig_ == "1B") { last_lock_time = Rtcm::gal_E1_last_lock_time[65 - gnss_synchro.PRN]; } - if ((sig_.compare("5X") == 0) || (sig_.compare("8X") == 0) || (sig_.compare("7X") == 0)) + if ((sig_ == "5X") || (sig_ == "8X") || (sig_ == "7X")) { last_lock_time = Rtcm::gal_E5_last_lock_time[65 - gnss_synchro.PRN]; } if (last_lock_time.is_not_a_date_time()) // || CHECK LLI!!......) { - if (sig_.compare("1B") == 0) + if (sig_ == "1B") { Rtcm::gal_E1_last_lock_time[65 - gnss_synchro.PRN] = current_time; } - if ((sig_.compare("5X") == 0) || (sig_.compare("8X") == 0) || (sig_.compare("7X") == 0)) + if ((sig_ == "5X") || (sig_ == "8X") || (sig_ == "7X")) { Rtcm::gal_E5_last_lock_time[65 - gnss_synchro.PRN] = current_time; } } boost::posix_time::time_duration lock_duration = current_time - current_time; - if (sig_.compare("1B") == 0) + if (sig_ == "1B") { lock_duration = current_time - Rtcm::gal_E1_last_lock_time[65 - gnss_synchro.PRN]; } - if ((sig_.compare("5X") == 0) || (sig_.compare("8X") == 0) || (sig_.compare("7X") == 0)) + if ((sig_ == "5X") || (sig_ == "8X") || (sig_ == "7X")) { lock_duration = current_time - Rtcm::gal_E5_last_lock_time[65 - gnss_synchro.PRN]; } - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + lock_time_in_seconds = static_cast(lock_duration.total_seconds()); return lock_time_in_seconds; } -unsigned int Rtcm::lock_time(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +uint32_t Rtcm::lock_time(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_in_seconds; + uint32_t lock_time_in_seconds; boost::posix_time::ptime current_time = Rtcm::compute_GLONASS_time(eph, obs_time); boost::posix_time::ptime last_lock_time; std::string sig_(gnss_synchro.Signal); - if (sig_.compare("1C") == 0) + if (sig_ == "1C") { last_lock_time = Rtcm::glo_L1_last_lock_time[65 - gnss_synchro.PRN]; } - if (sig_.compare("2C") == 0) + if (sig_ == "2C") { last_lock_time = Rtcm::glo_L2_last_lock_time[65 - gnss_synchro.PRN]; } if (last_lock_time.is_not_a_date_time()) // || CHECK LLI!!......) { - if (sig_.compare("1C") == 0) + if (sig_ == "1C") { Rtcm::glo_L1_last_lock_time[65 - gnss_synchro.PRN] = current_time; } - if (sig_.compare("2C") == 0) + if (sig_ == "2C") { Rtcm::glo_L2_last_lock_time[65 - gnss_synchro.PRN] = current_time; } } boost::posix_time::time_duration lock_duration = current_time - current_time; - if (sig_.compare("1C") == 0) + if (sig_ == "1C") { lock_duration = current_time - Rtcm::glo_L1_last_lock_time[65 - gnss_synchro.PRN]; } - if (sig_.compare("2C") == 0) + if (sig_ == "2C") { lock_duration = current_time - Rtcm::glo_L2_last_lock_time[65 - gnss_synchro.PRN]; } - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + lock_time_in_seconds = static_cast(lock_duration.total_seconds()); return lock_time_in_seconds; } -unsigned int Rtcm::lock_time_indicator(unsigned int lock_time_period_s) +uint32_t Rtcm::lock_time_indicator(uint32_t lock_time_period_s) { // Table 3.4-2 - if (lock_time_period_s <= 0) return 0; - if (lock_time_period_s < 24) return lock_time_period_s; - if (lock_time_period_s < 72) return (lock_time_period_s + 24) / 2; - if (lock_time_period_s < 168) return (lock_time_period_s + 120) / 4; - if (lock_time_period_s < 360) return (lock_time_period_s + 408) / 8; - if (lock_time_period_s < 744) return (lock_time_period_s + 1176) / 16; - if (lock_time_period_s < 937) return (lock_time_period_s + 3096) / 32; + if (lock_time_period_s <= 0) + { + return 0; + } + if (lock_time_period_s < 24) + { + return lock_time_period_s; + } + if (lock_time_period_s < 72) + { + return (lock_time_period_s + 24) / 2; + } + if (lock_time_period_s < 168) + { + return (lock_time_period_s + 120) / 4; + } + if (lock_time_period_s < 360) + { + return (lock_time_period_s + 408) / 8; + } + if (lock_time_period_s < 744) + { + return (lock_time_period_s + 1176) / 16; + } + if (lock_time_period_s < 937) + { + return (lock_time_period_s + 3096) / 32; + } return 127; } -unsigned int Rtcm::msm_lock_time_indicator(unsigned int lock_time_period_s) +uint32_t Rtcm::msm_lock_time_indicator(uint32_t lock_time_period_s) { // Table 3.5-74 - if (lock_time_period_s < 32) return 0; - if (lock_time_period_s < 64) return 1; - if (lock_time_period_s < 128) return 2; - if (lock_time_period_s < 256) return 3; - if (lock_time_period_s < 512) return 4; - if (lock_time_period_s < 1024) return 5; - if (lock_time_period_s < 2048) return 6; - if (lock_time_period_s < 4096) return 7; - if (lock_time_period_s < 8192) return 8; - if (lock_time_period_s < 16384) return 9; - if (lock_time_period_s < 32768) return 10; - if (lock_time_period_s < 65536) return 11; - if (lock_time_period_s < 131072) return 12; - if (lock_time_period_s < 262144) return 13; - if (lock_time_period_s < 524288) return 14; + if (lock_time_period_s < 32) + { + return 0; + } + if (lock_time_period_s < 64) + { + return 1; + } + if (lock_time_period_s < 128) + { + return 2; + } + if (lock_time_period_s < 256) + { + return 3; + } + if (lock_time_period_s < 512) + { + return 4; + } + if (lock_time_period_s < 1024) + { + return 5; + } + if (lock_time_period_s < 2048) + { + return 6; + } + if (lock_time_period_s < 4096) + { + return 7; + } + if (lock_time_period_s < 8192) + { + return 8; + } + if (lock_time_period_s < 16384) + { + return 9; + } + if (lock_time_period_s < 32768) + { + return 10; + } + if (lock_time_period_s < 65536) + { + return 11; + } + if (lock_time_period_s < 131072) + { + return 12; + } + if (lock_time_period_s < 262144) + { + return 13; + } + if (lock_time_period_s < 524288) + { + return 14; + } return 15; } // clang-format off -unsigned int Rtcm::msm_extended_lock_time_indicator(unsigned int lock_time_period_s) +uint32_t Rtcm::msm_extended_lock_time_indicator(uint32_t lock_time_period_s) { // Table 3.5-75 if( lock_time_period_s < 64 ) return ( lock_time_period_s ); @@ -3524,8 +3676,8 @@ unsigned int Rtcm::msm_extended_lock_time_indicator(unsigned int lock_time_perio if( 16777216 <= lock_time_period_s && lock_time_period_s < 33554432 ) return (640 + (lock_time_period_s - 16777216) / 524288 ); if( 33554432 <= lock_time_period_s && lock_time_period_s < 67108864 ) return (672 + (lock_time_period_s - 33554432) / 1048576); if( 67108864 <= lock_time_period_s ) return (704 ); - return 1023; // will never happen -} + return 1023; // will never happen + } // clang-format on // ***************************************************************************************************** @@ -3534,7 +3686,7 @@ unsigned int Rtcm::msm_extended_lock_time_indicator(unsigned int lock_time_perio // // ***************************************************************************************************** -int Rtcm::set_DF002(unsigned int message_number) +int32_t Rtcm::set_DF002(uint32_t message_number) { if (message_number > 4095) { @@ -3545,9 +3697,9 @@ int Rtcm::set_DF002(unsigned int message_number) } -int Rtcm::set_DF003(unsigned int ref_station_ID) +int32_t Rtcm::set_DF003(uint32_t ref_station_ID) { - //unsigned int station_ID = ref_station_ID; + //uint32_t station_ID = ref_station_ID; if (ref_station_ID > 4095) { LOG(WARNING) << "RTCM reference station ID must be between 0 and 4095, but it has been set to " << ref_station_ID; @@ -3557,10 +3709,10 @@ int Rtcm::set_DF003(unsigned int ref_station_ID) } -int Rtcm::set_DF004(double obs_time) +int32_t Rtcm::set_DF004(double obs_time) { // TOW in milliseconds from the beginning of the GPS week, measured in GPS time - unsigned long int tow = static_cast(std::round(obs_time * 1000)); + auto tow = static_cast(std::round(obs_time * 1000)); if (tow > 604799999) { LOG(WARNING) << "To large TOW! Set to the last millisecond of the week"; @@ -3571,7 +3723,7 @@ int Rtcm::set_DF004(double obs_time) } -int Rtcm::set_DF005(bool sync_flag) +int32_t Rtcm::set_DF005(bool sync_flag) { // 0 - No further GNSS observables referenced to the same Epoch Time will be transmitted. This enables the receiver to begin processing // the data immediately after decoding the message. @@ -3581,11 +3733,11 @@ int Rtcm::set_DF005(bool sync_flag) } -int Rtcm::set_DF006(const std::map& observables) +int32_t Rtcm::set_DF006(const std::map& observables) { //Number of satellites observed in current epoch - unsigned short int nsats = 0; - std::map::const_iterator observables_iter; + uint16_t nsats = 0; + std::map::const_iterator observables_iter; for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) @@ -3602,7 +3754,7 @@ int Rtcm::set_DF006(const std::map& observables) } -int Rtcm::set_DF007(bool divergence_free_smoothing_indicator) +int32_t Rtcm::set_DF007(bool divergence_free_smoothing_indicator) { // 0 - Divergence-free smoothing not used 1 - Divergence-free smoothing used DF007 = std::bitset<1>(divergence_free_smoothing_indicator); @@ -3610,16 +3762,16 @@ int Rtcm::set_DF007(bool divergence_free_smoothing_indicator) } -int Rtcm::set_DF008(short int smoothing_interval) +int32_t Rtcm::set_DF008(int16_t smoothing_interval) { DF008 = std::bitset<3>(smoothing_interval); return 0; } -int Rtcm::set_DF009(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF009(const Gnss_Synchro& gnss_synchro) { - unsigned int prn_ = gnss_synchro.PRN; + uint32_t prn_ = gnss_synchro.PRN; if (prn_ > 32) { LOG(WARNING) << "GPS satellite ID must be between 1 and 32, but PRN " << prn_ << " was found"; @@ -3629,9 +3781,9 @@ int Rtcm::set_DF009(const Gnss_Synchro& gnss_synchro) } -int Rtcm::set_DF009(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF009(const Gps_Ephemeris& gps_eph) { - unsigned int prn_ = gps_eph.i_satellite_PRN; + uint32_t prn_ = gps_eph.i_satellite_PRN; if (prn_ > 32) { LOG(WARNING) << "GPS satellite ID must be between 1 and 32, but PRN " << prn_ << " was found"; @@ -3641,88 +3793,88 @@ int Rtcm::set_DF009(const Gps_Ephemeris& gps_eph) } -int Rtcm::set_DF010(bool code_indicator) +int32_t Rtcm::set_DF010(bool code_indicator) { DF010 = std::bitset<1>(code_indicator); return 0; } -int Rtcm::set_DF011(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF011(const Gnss_Synchro& gnss_synchro) { double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 299792.458); - unsigned long int gps_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 299792.458) / 0.02)); + auto gps_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 299792.458) / 0.02)); DF011 = std::bitset<24>(gps_L1_pseudorange); return 0; } -int Rtcm::set_DF012(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF012(const Gnss_Synchro& gnss_synchro) { - const double lambda = GPS_C_m_s / GPS_L1_FREQ_HZ; + const double lambda = GPS_C_M_S / GPS_L1_FREQ_HZ; double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 299792.458); double gps_L1_pseudorange = std::round((gnss_synchro.Pseudorange_m - ambiguity * 299792.458) / 0.02); double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; double L1_phaserange_c = gnss_synchro.Carrier_phase_rads / GPS_TWO_PI; double L1_phaserange_c_r = std::fmod(L1_phaserange_c - gps_L1_pseudorange_c / lambda + 1500.0, 3000.0) - 1500.0; - long int gps_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); + auto gps_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); DF012 = std::bitset<20>(gps_L1_phaserange_minus_L1_pseudorange); return 0; } -int Rtcm::set_DF013(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF013(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_indicator; - unsigned int lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + uint32_t lock_time_indicator; + uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF013 = std::bitset<7>(lock_time_indicator); return 0; } -int Rtcm::set_DF014(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF014(const Gnss_Synchro& gnss_synchro) { - unsigned int gps_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 299792.458)); + auto gps_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 299792.458)); DF014 = std::bitset<8>(gps_L1_pseudorange_ambiguity); return 0; } -int Rtcm::set_DF015(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF015(const Gnss_Synchro& gnss_synchro) { double CN0_dB_Hz_est = gnss_synchro.CN0_dB_hz; if (CN0_dB_Hz_est > 63.75) { CN0_dB_Hz_est = 63.75; } - unsigned int CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF015 = std::bitset<8>(CN0_dB_Hz); return 0; } -int Rtcm::set_DF017(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) +int32_t Rtcm::set_DF017(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 299792.458); double gps_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 299792.458) / 0.02); double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; double l2_l1_pseudorange = gnss_synchroL2.Pseudorange_m - gps_L1_pseudorange_c; - int pseudorange_difference = 0xFFFFE000; // invalid value; + int32_t pseudorange_difference = 0xFFFFE000; // invalid value; if (std::fabs(l2_l1_pseudorange) <= 163.82) { - pseudorange_difference = static_cast(std::round(l2_l1_pseudorange / 0.02)); + pseudorange_difference = static_cast(std::round(l2_l1_pseudorange / 0.02)); } DF017 = std::bitset<14>(pseudorange_difference); return 0; } -int Rtcm::set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) +int32_t Rtcm::set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { - const double lambda2 = GPS_C_m_s / GPS_L2_FREQ_HZ; - int l2_phaserange_minus_l1_pseudorange = 0xFFF80000; + const double lambda2 = GPS_C_M_S / GPS_L2_FREQ_HZ; + int32_t l2_phaserange_minus_l1_pseudorange = 0xFFF80000; double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 299792.458); double gps_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 299792.458) / 0.02); double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; @@ -3731,7 +3883,7 @@ int Rtcm::set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss if (std::fabs(L1_phaserange_c_r * lambda2) <= 262.1435) { - l2_phaserange_minus_l1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda2 / 0.0005)); + l2_phaserange_minus_l1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda2 / 0.0005)); } DF018 = std::bitset<20>(l2_phaserange_minus_l1_pseudorange); @@ -3739,100 +3891,100 @@ int Rtcm::set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss } -int Rtcm::set_DF019(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF019(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_indicator; - unsigned int lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + uint32_t lock_time_indicator; + uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF019 = std::bitset<7>(lock_time_indicator); return 0; } -int Rtcm::set_DF020(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF020(const Gnss_Synchro& gnss_synchro) { double CN0_dB_Hz_est = gnss_synchro.CN0_dB_hz; if (CN0_dB_Hz_est > 63.75) { CN0_dB_Hz_est = 63.75; } - unsigned int CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF020 = std::bitset<8>(CN0_dB_Hz); return 0; } -int Rtcm::set_DF021() +int32_t Rtcm::set_DF021() { - unsigned short int itfr_year = 0; + uint16_t itfr_year = 0; DF021 = std::bitset<6>(itfr_year); return 0; } -int Rtcm::set_DF022(bool gps_indicator) +int32_t Rtcm::set_DF022(bool gps_indicator) { DF022 = std::bitset<1>(gps_indicator); return 0; } -int Rtcm::set_DF023(bool glonass_indicator) +int32_t Rtcm::set_DF023(bool glonass_indicator) { DF023 = std::bitset<1>(glonass_indicator); return 0; } -int Rtcm::set_DF024(bool galileo_indicator) +int32_t Rtcm::set_DF024(bool galileo_indicator) { DF024 = std::bitset<1>(galileo_indicator); return 0; } -int Rtcm::set_DF025(double antenna_ECEF_X_m) +int32_t Rtcm::set_DF025(double antenna_ECEF_X_m) { - long long int ant_ref_x = static_cast(std::round(antenna_ECEF_X_m * 10000)); + auto ant_ref_x = static_cast(std::round(antenna_ECEF_X_m * 10000)); DF025 = std::bitset<38>(ant_ref_x); return 0; } -int Rtcm::set_DF026(double antenna_ECEF_Y_m) +int32_t Rtcm::set_DF026(double antenna_ECEF_Y_m) { - long long int ant_ref_y = static_cast(std::round(antenna_ECEF_Y_m * 10000)); + auto ant_ref_y = static_cast(std::round(antenna_ECEF_Y_m * 10000)); DF026 = std::bitset<38>(ant_ref_y); return 0; } -int Rtcm::set_DF027(double antenna_ECEF_Z_m) +int32_t Rtcm::set_DF027(double antenna_ECEF_Z_m) { - long long int ant_ref_z = static_cast(std::round(antenna_ECEF_Z_m * 10000)); + auto ant_ref_z = static_cast(std::round(antenna_ECEF_Z_m * 10000)); DF027 = std::bitset<38>(ant_ref_z); return 0; } -int Rtcm::set_DF028(double height) +int32_t Rtcm::set_DF028(double height) { - unsigned int h_ = static_cast(std::round(height * 10000)); + auto h_ = static_cast(std::round(height * 10000)); DF028 = std::bitset<16>(h_); return 0; } -int Rtcm::set_DF031(unsigned int antenna_setup_id) +int32_t Rtcm::set_DF031(uint32_t antenna_setup_id) { DF031 = std::bitset<8>(antenna_setup_id); return 0; } -int Rtcm::set_DF034(double obs_time) +int32_t Rtcm::set_DF034(double obs_time) { // TOW in milliseconds from the beginning of the GLONASS day, measured in GLONASS time - unsigned long int tk = static_cast(std::round(obs_time * 1000)); + auto tk = static_cast(std::round(obs_time * 1000)); if (tk > 86400999) { LOG(WARNING) << "To large GLONASS Epoch Time (tk)! Set to the last millisecond of the day"; @@ -3843,11 +3995,11 @@ int Rtcm::set_DF034(double obs_time) } -int Rtcm::set_DF035(const std::map& observables) +int32_t Rtcm::set_DF035(const std::map& observables) { //Number of satellites observed in current epoch - unsigned short int nsats = 0; - std::map::const_iterator observables_iter; + uint16_t nsats = 0; + std::map::const_iterator observables_iter; for (observables_iter = observables.begin(); observables_iter != observables.end(); observables_iter++) @@ -3864,7 +4016,7 @@ int Rtcm::set_DF035(const std::map& observables) } -int Rtcm::set_DF036(bool divergence_free_smoothing_indicator) +int32_t Rtcm::set_DF036(bool divergence_free_smoothing_indicator) { // 0 - Divergence-free smoothing not used 1 - Divergence-free smoothing used DF036 = std::bitset<1>(divergence_free_smoothing_indicator); @@ -3872,16 +4024,16 @@ int Rtcm::set_DF036(bool divergence_free_smoothing_indicator) } -int Rtcm::set_DF037(short int smoothing_interval) +int32_t Rtcm::set_DF037(int16_t smoothing_interval) { DF037 = std::bitset<3>(smoothing_interval); return 0; } -int Rtcm::set_DF038(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF038(const Gnss_Synchro& gnss_synchro) { - unsigned int prn_ = gnss_synchro.PRN; + uint32_t prn_ = gnss_synchro.PRN; if (prn_ > 24) { LOG(WARNING) << "GLONASS satellite ID (Slot Number) must be between 1 and 24, but PRN " << prn_ << " was found"; @@ -3891,9 +4043,9 @@ int Rtcm::set_DF038(const Gnss_Synchro& gnss_synchro) } -int Rtcm::set_DF038(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF038(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int prn_ = glonass_gnav_eph.i_satellite_slot_number; + uint32_t prn_ = glonass_gnav_eph.i_satellite_slot_number; if (prn_ > 24) { LOG(WARNING) << "GLONASS satellite ID (Slot Number) must be between 0 and 24, but PRN " << prn_ << " was found"; @@ -3903,16 +4055,16 @@ int Rtcm::set_DF038(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF039(bool code_indicator) +int32_t Rtcm::set_DF039(bool code_indicator) { DF039 = std::bitset<1>(code_indicator); return 0; } -int Rtcm::set_DF040(int frequency_channel_number) +int32_t Rtcm::set_DF040(int32_t frequency_channel_number) { - unsigned int freq_ = frequency_channel_number + 7; + uint32_t freq_ = frequency_channel_number + 7; if (freq_ > 20) { LOG(WARNING) << "GLONASS Satellite Frequency Number Conversion Error." @@ -3925,9 +4077,9 @@ int Rtcm::set_DF040(int frequency_channel_number) } -int Rtcm::set_DF040(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF040(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int freq_ = glonass_gnav_eph.i_satellite_freq_channel + 7; + uint32_t freq_ = glonass_gnav_eph.i_satellite_freq_channel + 7; if (freq_ > 20) { LOG(WARNING) << "GLONASS Satellite Frequency Number Conversion Error." @@ -3940,48 +4092,48 @@ int Rtcm::set_DF040(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF041(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF041(const Gnss_Synchro& gnss_synchro) { double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 599584.92); - unsigned long int glonass_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 599584.92) / 0.02)); + auto glonass_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 599584.92) / 0.02)); DF041 = std::bitset<25>(glonass_L1_pseudorange); return 0; } -int Rtcm::set_DF042(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF042(const Gnss_Synchro& gnss_synchro) { - const double lambda = GLONASS_C_m_s / (GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN))); + const double lambda = GLONASS_C_M_S / (GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN))); double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 599584.92); double glonass_L1_pseudorange = std::round((gnss_synchro.Pseudorange_m - ambiguity * 599584.92) / 0.02); double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 299792.458; double L1_phaserange_c = gnss_synchro.Carrier_phase_rads / GLONASS_TWO_PI; double L1_phaserange_c_r = std::fmod(L1_phaserange_c - glonass_L1_pseudorange_c / lambda + 1500.0, 3000.0) - 1500.0; - long int glonass_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); + auto glonass_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); DF042 = std::bitset<20>(glonass_L1_phaserange_minus_L1_pseudorange); return 0; } -int Rtcm::set_DF043(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF043(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_indicator; - unsigned int lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + uint32_t lock_time_indicator; + uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF043 = std::bitset<7>(lock_time_indicator); return 0; } -int Rtcm::set_DF044(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF044(const Gnss_Synchro& gnss_synchro) { - unsigned int glonass_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 599584.916)); + auto glonass_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 599584.916)); DF044 = std::bitset<7>(glonass_L1_pseudorange_ambiguity); return 0; } -int Rtcm::set_DF045(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF045(const Gnss_Synchro& gnss_synchro) { double CN0_dB_Hz_est = gnss_synchro.CN0_dB_hz; if (CN0_dB_Hz_est > 63.75) @@ -3989,33 +4141,33 @@ int Rtcm::set_DF045(const Gnss_Synchro& gnss_synchro) LOG(WARNING) << "GLONASS L1 CNR must be between 0 and 63.75, but CNR " << CN0_dB_Hz_est << " was found. Setting to 63.75 dB-Hz"; CN0_dB_Hz_est = 63.75; } - unsigned int CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF045 = std::bitset<8>(CN0_dB_Hz); return 0; } -int Rtcm::set_DF047(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) +int32_t Rtcm::set_DF047(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 599584.92); double glonass_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 599584.92) / 0.02); double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 599584.92; double l2_l1_pseudorange = gnss_synchroL2.Pseudorange_m - glonass_L1_pseudorange_c; - int pseudorange_difference = 0xFFFFE000; // invalid value; + int32_t pseudorange_difference = 0xFFFFE000; // invalid value; if (std::fabs(l2_l1_pseudorange) <= 163.82) { - pseudorange_difference = static_cast(std::round(l2_l1_pseudorange / 0.02)); + pseudorange_difference = static_cast(std::round(l2_l1_pseudorange / 0.02)); } DF047 = std::bitset<14>(pseudorange_difference); return 0; } //TODO Need to consider frequency channel in this fields -int Rtcm::set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) +int32_t Rtcm::set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { - const double lambda2 = GLONASS_C_m_s / GLONASS_L2_CA_FREQ_HZ; - int l2_phaserange_minus_l1_pseudorange = 0xFFF80000; + const double lambda2 = GLONASS_C_M_S / GLONASS_L2_CA_FREQ_HZ; + int32_t l2_phaserange_minus_l1_pseudorange = 0xFFF80000; double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 599584.92); double glonass_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 599584.92) / 0.02); double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 599584.92; @@ -4024,7 +4176,7 @@ int Rtcm::set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss if (std::fabs(L1_phaserange_c_r * lambda2) <= 262.1435) { - l2_phaserange_minus_l1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda2 / 0.0005)); + l2_phaserange_minus_l1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda2 / 0.0005)); } DF048 = std::bitset<20>(l2_phaserange_minus_l1_pseudorange); @@ -4032,319 +4184,319 @@ int Rtcm::set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss } -int Rtcm::set_DF049(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF049(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_indicator; - unsigned int lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + uint32_t lock_time_indicator; + uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF049 = std::bitset<7>(lock_time_indicator); return 0; } -int Rtcm::set_DF050(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF050(const Gnss_Synchro& gnss_synchro) { double CN0_dB_Hz_est = gnss_synchro.CN0_dB_hz; if (CN0_dB_Hz_est > 63.75) { CN0_dB_Hz_est = 63.75; } - unsigned int CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF050 = std::bitset<8>(CN0_dB_Hz); return 0; } -int Rtcm::set_DF051(const Gps_Ephemeris& gps_eph, double obs_time) +int32_t Rtcm::set_DF051(const Gps_Ephemeris& gps_eph, double obs_time) { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((gps_t + 604800 * static_cast(gps_eph.i_GPS_week % 1024)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week % 1024)) * 1000)); boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); std::string now_ptime = to_iso_string(p_time); std::string today_ptime = now_ptime.substr(0, 8); boost::gregorian::date d(boost::gregorian::from_undelimited_string(today_ptime)); - unsigned int mjd = d.modjulian_day(); + uint32_t mjd = d.modjulian_day(); DF051 = std::bitset<16>(mjd); return 0; } -int Rtcm::set_DF052(const Gps_Ephemeris& gps_eph, double obs_time) +int32_t Rtcm::set_DF052(const Gps_Ephemeris& gps_eph, double obs_time) { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::millisec((gps_t + 604800 * static_cast(gps_eph.i_GPS_week % 1024)) * 1000); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week % 1024)) * 1000)); boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); std::string now_ptime = to_iso_string(p_time); std::string hours = now_ptime.substr(9, 2); std::string minutes = now_ptime.substr(11, 2); std::string seconds = now_ptime.substr(13, 8); //boost::gregorian::date d(boost::gregorian::from_undelimited_string(today_ptime)); - long unsigned int seconds_of_day = boost::lexical_cast(hours) * 60 * 60 + boost::lexical_cast(minutes) * 60 + boost::lexical_cast(seconds); + uint32_t seconds_of_day = boost::lexical_cast(hours) * 60 * 60 + boost::lexical_cast(minutes) * 60 + boost::lexical_cast(seconds); DF052 = std::bitset<17>(seconds_of_day); return 0; } -int Rtcm::set_DF071(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF071(const Gps_Ephemeris& gps_eph) { - unsigned int iode = static_cast(gps_eph.d_IODE_SF2); + auto iode = static_cast(gps_eph.d_IODE_SF2); DF071 = std::bitset<8>(iode); return 0; } -int Rtcm::set_DF076(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF076(const Gps_Ephemeris& gps_eph) { - unsigned int week_number = static_cast(gps_eph.i_GPS_week); + auto week_number = static_cast(gps_eph.i_GPS_week); DF076 = std::bitset<10>(week_number); return 0; } -int Rtcm::set_DF077(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF077(const Gps_Ephemeris& gps_eph) { - unsigned short int ura = static_cast(gps_eph.i_SV_accuracy); + auto ura = static_cast(gps_eph.i_SV_accuracy); DF077 = std::bitset<4>(ura); return 0; } -int Rtcm::set_DF078(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF078(const Gps_Ephemeris& gps_eph) { - unsigned short int code_on_L2 = static_cast(gps_eph.i_code_on_L2); + auto code_on_L2 = static_cast(gps_eph.i_code_on_L2); DF078 = std::bitset<2>(code_on_L2); return 0; } -int Rtcm::set_DF079(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF079(const Gps_Ephemeris& gps_eph) { - unsigned int idot = static_cast(std::round(gps_eph.d_IDOT / I_DOT_LSB)); + auto idot = static_cast(std::round(gps_eph.d_IDOT / I_DOT_LSB)); DF079 = std::bitset<14>(idot); return 0; } -int Rtcm::set_DF080(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF080(const Gps_Ephemeris& gps_eph) { - unsigned short int iode = static_cast(gps_eph.d_IODE_SF2); + auto iode = static_cast(gps_eph.d_IODE_SF2); DF080 = std::bitset<8>(iode); return 0; } -int Rtcm::set_DF081(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF081(const Gps_Ephemeris& gps_eph) { - unsigned int toc = static_cast(std::round(gps_eph.d_Toc / T_OC_LSB)); + auto toc = static_cast(std::round(gps_eph.d_Toc / T_OC_LSB)); DF081 = std::bitset<16>(toc); return 0; } -int Rtcm::set_DF082(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF082(const Gps_Ephemeris& gps_eph) { - short int af2 = static_cast(std::round(gps_eph.d_A_f2 / A_F2_LSB)); + auto af2 = static_cast(std::round(gps_eph.d_A_f2 / A_F2_LSB)); DF082 = std::bitset<8>(af2); return 0; } -int Rtcm::set_DF083(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF083(const Gps_Ephemeris& gps_eph) { - int af1 = static_cast(std::round(gps_eph.d_A_f1 / A_F1_LSB)); + auto af1 = static_cast(std::round(gps_eph.d_A_f1 / A_F1_LSB)); DF083 = std::bitset<16>(af1); return 0; } -int Rtcm::set_DF084(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF084(const Gps_Ephemeris& gps_eph) { - long int af0 = static_cast(std::round(gps_eph.d_A_f0 / A_F0_LSB)); + auto af0 = static_cast(std::round(gps_eph.d_A_f0 / A_F0_LSB)); DF084 = std::bitset<22>(af0); return 0; } -int Rtcm::set_DF085(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF085(const Gps_Ephemeris& gps_eph) { - unsigned int iodc = static_cast(gps_eph.d_IODC); + auto iodc = static_cast(gps_eph.d_IODC); DF085 = std::bitset<10>(iodc); return 0; } -int Rtcm::set_DF086(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF086(const Gps_Ephemeris& gps_eph) { - int crs = static_cast(std::round(gps_eph.d_Crs / C_RS_LSB)); + auto crs = static_cast(std::round(gps_eph.d_Crs / C_RS_LSB)); DF086 = std::bitset<16>(crs); return 0; } -int Rtcm::set_DF087(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF087(const Gps_Ephemeris& gps_eph) { - int delta_n = static_cast(std::round(gps_eph.d_Delta_n / DELTA_N_LSB)); + auto delta_n = static_cast(std::round(gps_eph.d_Delta_n / DELTA_N_LSB)); DF087 = std::bitset<16>(delta_n); return 0; } -int Rtcm::set_DF088(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF088(const Gps_Ephemeris& gps_eph) { - long int m0 = static_cast(std::round(gps_eph.d_M_0 / M_0_LSB)); + auto m0 = static_cast(std::round(gps_eph.d_M_0 / M_0_LSB)); DF088 = std::bitset<32>(m0); return 0; } -int Rtcm::set_DF089(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF089(const Gps_Ephemeris& gps_eph) { - int cuc = static_cast(std::round(gps_eph.d_Cuc / C_UC_LSB)); + auto cuc = static_cast(std::round(gps_eph.d_Cuc / C_UC_LSB)); DF089 = std::bitset<16>(cuc); return 0; } -int Rtcm::set_DF090(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF090(const Gps_Ephemeris& gps_eph) { - unsigned long int ecc = static_cast(std::round(gps_eph.d_e_eccentricity / E_LSB)); + auto ecc = static_cast(std::round(gps_eph.d_e_eccentricity / E_LSB)); DF090 = std::bitset<32>(ecc); return 0; } -int Rtcm::set_DF091(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF091(const Gps_Ephemeris& gps_eph) { - int cus = static_cast(std::round(gps_eph.d_Cus / C_US_LSB)); + auto cus = static_cast(std::round(gps_eph.d_Cus / C_US_LSB)); DF091 = std::bitset<16>(cus); return 0; } -int Rtcm::set_DF092(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF092(const Gps_Ephemeris& gps_eph) { - unsigned long int sqr_a = static_cast(std::round(gps_eph.d_sqrt_A / SQRT_A_LSB)); + auto sqr_a = static_cast(std::round(gps_eph.d_sqrt_A / SQRT_A_LSB)); DF092 = std::bitset<32>(sqr_a); return 0; } -int Rtcm::set_DF093(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF093(const Gps_Ephemeris& gps_eph) { - unsigned int toe = static_cast(std::round(gps_eph.d_Toe / T_OE_LSB)); + auto toe = static_cast(std::round(gps_eph.d_Toe / T_OE_LSB)); DF093 = std::bitset<16>(toe); return 0; } -int Rtcm::set_DF094(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF094(const Gps_Ephemeris& gps_eph) { - int cic = static_cast(std::round(gps_eph.d_Cic / C_IC_LSB)); + auto cic = static_cast(std::round(gps_eph.d_Cic / C_IC_LSB)); DF094 = std::bitset<16>(cic); return 0; } -int Rtcm::set_DF095(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF095(const Gps_Ephemeris& gps_eph) { - long int Omega0 = static_cast(std::round(gps_eph.d_OMEGA0 / OMEGA_0_LSB)); + auto Omega0 = static_cast(std::round(gps_eph.d_OMEGA0 / OMEGA_0_LSB)); DF095 = std::bitset<32>(Omega0); return 0; } -int Rtcm::set_DF096(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF096(const Gps_Ephemeris& gps_eph) { - int cis = static_cast(std::round(gps_eph.d_Cis / C_IS_LSB)); + auto cis = static_cast(std::round(gps_eph.d_Cis / C_IS_LSB)); DF096 = std::bitset<16>(cis); return 0; } -int Rtcm::set_DF097(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF097(const Gps_Ephemeris& gps_eph) { - long int i0 = static_cast(std::round(gps_eph.d_i_0 / I_0_LSB)); + auto i0 = static_cast(std::round(gps_eph.d_i_0 / I_0_LSB)); DF097 = std::bitset<32>(i0); return 0; } -int Rtcm::set_DF098(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF098(const Gps_Ephemeris& gps_eph) { - int crc = static_cast(std::round(gps_eph.d_Crc / C_RC_LSB)); + auto crc = static_cast(std::round(gps_eph.d_Crc / C_RC_LSB)); DF098 = std::bitset<16>(crc); return 0; } -int Rtcm::set_DF099(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF099(const Gps_Ephemeris& gps_eph) { - long int omega = static_cast(std::round(gps_eph.d_OMEGA / OMEGA_LSB)); + auto omega = static_cast(std::round(gps_eph.d_OMEGA / OMEGA_LSB)); DF099 = std::bitset<32>(omega); return 0; } -int Rtcm::set_DF100(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF100(const Gps_Ephemeris& gps_eph) { - long int omegadot = static_cast(std::round(gps_eph.d_OMEGA_DOT / OMEGA_DOT_LSB)); + auto omegadot = static_cast(std::round(gps_eph.d_OMEGA_DOT / OMEGA_DOT_LSB)); DF100 = std::bitset<24>(omegadot); return 0; } -int Rtcm::set_DF101(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF101(const Gps_Ephemeris& gps_eph) { - short int tgd = static_cast(std::round(gps_eph.d_TGD / T_GD_LSB)); + auto tgd = static_cast(std::round(gps_eph.d_TGD / T_GD_LSB)); DF101 = std::bitset<8>(tgd); return 0; } -int Rtcm::set_DF102(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF102(const Gps_Ephemeris& gps_eph) { - unsigned short int sv_heath = static_cast(gps_eph.i_SV_health); + auto sv_heath = static_cast(gps_eph.i_SV_health); DF102 = std::bitset<6>(sv_heath); return 0; } -int Rtcm::set_DF103(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF103(const Gps_Ephemeris& gps_eph) { DF103 = std::bitset<1>(gps_eph.b_L2_P_data_flag); return 0; } -int Rtcm::set_DF104(unsigned int glonass_gnav_alm_health) +int32_t Rtcm::set_DF104(uint32_t glonass_gnav_alm_health) { DF104 = std::bitset<1>(glonass_gnav_alm_health); return 0; } -int Rtcm::set_DF105(unsigned int glonass_gnav_alm_health_ind) +int32_t Rtcm::set_DF105(uint32_t glonass_gnav_alm_health_ind) { DF105 = std::bitset<1>(glonass_gnav_alm_health_ind); return 0; } -int Rtcm::set_DF106(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF106(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { // Convert the value from (15, 30, 45, 60) to (00, 01, 10, 11) - unsigned int P_1 = static_cast(std::round(glonass_gnav_eph.d_P_1 / 15.0 - 1.0)); + auto P_1 = static_cast(std::round(glonass_gnav_eph.d_P_1 / 15.0 - 1.0)); DF106 = std::bitset<2>(P_1); return 0; } -int Rtcm::set_DF107(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF107(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int hrs = 0; - unsigned int min = 0; - unsigned int sec = 0; - unsigned int tk = 0; - tk = static_cast(glonass_gnav_eph.d_t_k); + uint32_t hrs = 0; + uint32_t min = 0; + uint32_t sec = 0; + uint32_t tk = 0; + tk = static_cast(glonass_gnav_eph.d_t_k); hrs = tk / 3600; min = (tk - hrs * 3600) / 60; sec = (tk - hrs * 3600 - min * 60) / 60; @@ -4360,32 +4512,32 @@ int Rtcm::set_DF107(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF108(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF108(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { DF108 = std::bitset<1>(glonass_gnav_eph.d_B_n); return 0; } -int Rtcm::set_DF109(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF109(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { DF109 = std::bitset<1>(glonass_gnav_eph.d_P_2); return 0; } -int Rtcm::set_DF110(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF110(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int t_b = static_cast(std::round(glonass_gnav_eph.d_t_b / (15 * 60))); + auto t_b = static_cast(std::round(glonass_gnav_eph.d_t_b / (15 * 60))); DF110 = std::bitset<7>(t_b); return 0; } -int Rtcm::set_DF111(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF111(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int VXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VXn / TWO_N20))); - unsigned int VXn_sgn = glo_sgn(glonass_gnav_eph.d_VXn); + auto VXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VXn / TWO_N20))); + uint32_t VXn_sgn = glo_sgn(glonass_gnav_eph.d_VXn); DF111 = std::bitset<24>(VXn_mag); DF111.set(23, VXn_sgn); @@ -4393,10 +4545,10 @@ int Rtcm::set_DF111(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF112(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF112(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int Xn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Xn / TWO_N11))); - unsigned int Xn_sgn = glo_sgn(glonass_gnav_eph.d_Xn); + auto Xn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Xn / TWO_N11))); + uint32_t Xn_sgn = glo_sgn(glonass_gnav_eph.d_Xn); DF112 = std::bitset<27>(Xn_mag); DF112.set(26, Xn_sgn); @@ -4404,10 +4556,10 @@ int Rtcm::set_DF112(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF113(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF113(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int AXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AXn / TWO_N30))); - unsigned int AXn_sgn = glo_sgn(glonass_gnav_eph.d_AXn); + auto AXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AXn / TWO_N30))); + uint32_t AXn_sgn = glo_sgn(glonass_gnav_eph.d_AXn); DF113 = std::bitset<5>(AXn_mag); DF113.set(4, AXn_sgn); @@ -4415,10 +4567,10 @@ int Rtcm::set_DF113(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF114(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF114(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int VYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VYn / TWO_N20))); - unsigned int VYn_sgn = glo_sgn(glonass_gnav_eph.d_VYn); + auto VYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VYn / TWO_N20))); + uint32_t VYn_sgn = glo_sgn(glonass_gnav_eph.d_VYn); DF114 = std::bitset<24>(VYn_mag); DF114.set(23, VYn_sgn); @@ -4426,10 +4578,10 @@ int Rtcm::set_DF114(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF115(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF115(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int Yn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Yn / TWO_N11))); - unsigned int Yn_sgn = glo_sgn(glonass_gnav_eph.d_Yn); + auto Yn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Yn / TWO_N11))); + uint32_t Yn_sgn = glo_sgn(glonass_gnav_eph.d_Yn); DF115 = std::bitset<27>(Yn_mag); DF115.set(26, Yn_sgn); @@ -4437,10 +4589,10 @@ int Rtcm::set_DF115(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF116(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF116(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int AYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AYn / TWO_N30))); - unsigned int AYn_sgn = glo_sgn(glonass_gnav_eph.d_AYn); + auto AYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AYn / TWO_N30))); + uint32_t AYn_sgn = glo_sgn(glonass_gnav_eph.d_AYn); DF116 = std::bitset<5>(AYn_mag); DF116.set(4, AYn_sgn); @@ -4448,10 +4600,10 @@ int Rtcm::set_DF116(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF117(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF117(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int VZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VZn / TWO_N20))); - unsigned int VZn_sgn = glo_sgn(glonass_gnav_eph.d_VZn); + auto VZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VZn / TWO_N20))); + uint32_t VZn_sgn = glo_sgn(glonass_gnav_eph.d_VZn); DF117 = std::bitset<24>(VZn_mag); DF117.set(23, VZn_sgn); @@ -4459,10 +4611,10 @@ int Rtcm::set_DF117(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF118(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF118(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int Zn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Zn / TWO_N11))); - unsigned int Zn_sgn = glo_sgn(glonass_gnav_eph.d_Zn); + auto Zn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Zn / TWO_N11))); + uint32_t Zn_sgn = glo_sgn(glonass_gnav_eph.d_Zn); DF118 = std::bitset<27>(Zn_mag); DF118.set(26, Zn_sgn); @@ -4470,10 +4622,10 @@ int Rtcm::set_DF118(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int AZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AZn / TWO_N30))); - unsigned int AZn_sgn = glo_sgn(glonass_gnav_eph.d_AZn); + auto AZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AZn / TWO_N30))); + uint32_t AZn_sgn = glo_sgn(glonass_gnav_eph.d_AZn); DF119 = std::bitset<5>(AZn_mag); DF119.set(4, AZn_sgn); @@ -4481,18 +4633,18 @@ int Rtcm::set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF120(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF120(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int P3 = static_cast(std::round(glonass_gnav_eph.d_P_3)); + uint32_t P3 = static_cast(std::round(glonass_gnav_eph.d_P_3)); DF120 = std::bitset<1>(P3); return 0; } -int Rtcm::set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int gamma_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_gamma_n / TWO_N40))); - unsigned int gamma_sgn = glo_sgn(glonass_gnav_eph.d_gamma_n); + auto gamma_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_gamma_n / TWO_N40))); + uint32_t gamma_sgn = glo_sgn(glonass_gnav_eph.d_gamma_n); DF121 = std::bitset<11>(gamma_mag); DF121.set(10, gamma_sgn); @@ -4500,26 +4652,26 @@ int Rtcm::set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF122(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF122(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int P = static_cast(std::round(glonass_gnav_eph.d_P)); + auto P = static_cast(std::round(glonass_gnav_eph.d_P)); DF122 = std::bitset<2>(P); return 0; } -int Rtcm::set_DF123(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF123(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int ln = static_cast((glonass_gnav_eph.d_l3rd_n)); + auto ln = static_cast((glonass_gnav_eph.d_l3rd_n)); DF123 = std::bitset<1>(ln); return 0; } -int Rtcm::set_DF124(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF124(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_tau_n / TWO_N30))); - unsigned int tau_sgn = glo_sgn(glonass_gnav_eph.d_tau_n); + auto tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_tau_n / TWO_N30))); + uint32_t tau_sgn = glo_sgn(glonass_gnav_eph.d_tau_n); DF124 = std::bitset<22>(tau_mag); DF124.set(21, tau_sgn); @@ -4527,10 +4679,10 @@ int Rtcm::set_DF124(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF125(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF125(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - int delta_tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Delta_tau_n / TWO_N30))); - unsigned int delta_tau_sgn = glo_sgn(glonass_gnav_eph.d_Delta_tau_n); + auto delta_tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Delta_tau_n / TWO_N30))); + uint32_t delta_tau_sgn = glo_sgn(glonass_gnav_eph.d_Delta_tau_n); DF125 = std::bitset<5>(delta_tau_mag); DF125.set(4, delta_tau_sgn); @@ -4538,105 +4690,105 @@ int Rtcm::set_DF125(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) } -int Rtcm::set_DF126(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF126(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int ecc = static_cast(std::round(glonass_gnav_eph.d_E_n)); + auto ecc = static_cast(std::round(glonass_gnav_eph.d_E_n)); DF126 = std::bitset<5>(ecc); return 0; } -int Rtcm::set_DF127(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF127(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int P4 = static_cast(std::round(glonass_gnav_eph.d_P_4)); + auto P4 = static_cast(std::round(glonass_gnav_eph.d_P_4)); DF127 = std::bitset<1>(P4); return 0; } -int Rtcm::set_DF128(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF128(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int F_t = static_cast(std::round(glonass_gnav_eph.d_F_T)); + auto F_t = static_cast(std::round(glonass_gnav_eph.d_F_T)); DF128 = std::bitset<4>(F_t); return 0; } -int Rtcm::set_DF129(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF129(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int N_t = static_cast(std::round(glonass_gnav_eph.d_N_T)); + auto N_t = static_cast(std::round(glonass_gnav_eph.d_N_T)); DF129 = std::bitset<11>(N_t); return 0; } -int Rtcm::set_DF130(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF130(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int M = static_cast(std::round(glonass_gnav_eph.d_M)); + auto M = static_cast(std::round(glonass_gnav_eph.d_M)); DF130 = std::bitset<2>(M); return 0; } -int Rtcm::set_DF131(unsigned int fifth_str_additional_data_ind) +int32_t Rtcm::set_DF131(uint32_t fifth_str_additional_data_ind) { - unsigned int fith_str_data = static_cast(fifth_str_additional_data_ind); + auto fith_str_data = static_cast(fifth_str_additional_data_ind); DF131 = std::bitset<1>(fith_str_data); return 0; } -int Rtcm::set_DF132(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) +int32_t Rtcm::set_DF132(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - unsigned int N_A = static_cast(std::round(glonass_gnav_utc_model.d_N_A)); + auto N_A = static_cast(std::round(glonass_gnav_utc_model.d_N_A)); DF132 = std::bitset<11>(N_A); return 0; } -int Rtcm::set_DF133(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) +int32_t Rtcm::set_DF133(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - int tau_c = static_cast(std::round(glonass_gnav_utc_model.d_tau_c / TWO_N31)); + auto tau_c = static_cast(std::round(glonass_gnav_utc_model.d_tau_c / TWO_N31)); DF133 = std::bitset<32>(tau_c); return 0; } -int Rtcm::set_DF134(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) +int32_t Rtcm::set_DF134(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - unsigned int N_4 = static_cast(std::round(glonass_gnav_utc_model.d_N_4)); + auto N_4 = static_cast(std::round(glonass_gnav_utc_model.d_N_4)); DF134 = std::bitset<5>(N_4); return 0; } -int Rtcm::set_DF135(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) +int32_t Rtcm::set_DF135(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - int tau_gps = static_cast(std::round(glonass_gnav_utc_model.d_tau_gps) / TWO_N30); + auto tau_gps = static_cast(std::round(glonass_gnav_utc_model.d_tau_gps) / TWO_N30); DF135 = std::bitset<22>(tau_gps); return 0; } -int Rtcm::set_DF136(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) +int32_t Rtcm::set_DF136(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - unsigned int l_n = static_cast(std::round(glonass_gnav_eph.d_l5th_n)); + auto l_n = static_cast(std::round(glonass_gnav_eph.d_l5th_n)); DF136 = std::bitset<1>(l_n); return 0; } -int Rtcm::set_DF137(const Gps_Ephemeris& gps_eph) +int32_t Rtcm::set_DF137(const Gps_Ephemeris& gps_eph) { DF137 = std::bitset<1>(gps_eph.b_fit_interval_flag); return 0; } -int Rtcm::set_DF248(double obs_time) +int32_t Rtcm::set_DF248(double obs_time) { // TOW in milliseconds from the beginning of the Galileo week, measured in Galileo time - unsigned long int tow = static_cast(std::round(obs_time * 1000)); + auto tow = static_cast(std::round(obs_time * 1000)); if (tow > 604799999) { LOG(WARNING) << "To large TOW! Set to the last millisecond of the week"; @@ -4647,9 +4799,9 @@ int Rtcm::set_DF248(double obs_time) } -int Rtcm::set_DF252(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF252(const Galileo_Ephemeris& gal_eph) { - unsigned int prn_ = gal_eph.i_satellite_PRN; + uint32_t prn_ = gal_eph.i_satellite_PRN; if (prn_ > 63) { LOG(WARNING) << "Galileo satellite ID must be between 0 and 63, but PRN " << prn_ << " was found"; @@ -4659,9 +4811,9 @@ int Rtcm::set_DF252(const Galileo_Ephemeris& gal_eph) } -int Rtcm::set_DF289(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF289(const Galileo_Ephemeris& gal_eph) { - unsigned int galileo_week_number = static_cast(gal_eph.WN_5); + auto galileo_week_number = static_cast(gal_eph.WN_5); if (galileo_week_number > 4095) { LOG(WARNING) << "Error decoding Galileo week number (it has a 4096 roll-off, but " << galileo_week_number << " was detected)"; @@ -4671,9 +4823,9 @@ int Rtcm::set_DF289(const Galileo_Ephemeris& gal_eph) } -int Rtcm::set_DF290(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF290(const Galileo_Ephemeris& gal_eph) { - unsigned int iod_nav = static_cast(gal_eph.IOD_nav_1); + auto iod_nav = static_cast(gal_eph.IOD_nav_1); if (iod_nav > 1023) { LOG(WARNING) << "Error decoding Galileo IODnav (it has a max of 1023, but " << iod_nav << " was detected)"; @@ -4683,26 +4835,26 @@ int Rtcm::set_DF290(const Galileo_Ephemeris& gal_eph) } -int Rtcm::set_DF291(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF291(const Galileo_Ephemeris& gal_eph) { - unsigned short int SISA = static_cast(gal_eph.SISA_3); + auto SISA = static_cast(gal_eph.SISA_3); //SISA = 0; // SIS Accuracy, data content definition not given in Galileo OS SIS ICD, Issue 1.1, Sept 2010 DF291 = std::bitset<8>(SISA); return 0; } -int Rtcm::set_DF292(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF292(const Galileo_Ephemeris& gal_eph) { - int idot = static_cast(std::round(gal_eph.iDot_2 / FNAV_idot_2_LSB)); + auto idot = static_cast(std::round(gal_eph.iDot_2 / FNAV_IDOT_2_LSB)); DF292 = std::bitset<14>(idot); return 0; } -int Rtcm::set_DF293(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF293(const Galileo_Ephemeris& gal_eph) { - unsigned int toc = static_cast(gal_eph.t0c_4); + auto toc = static_cast(gal_eph.t0c_4); if (toc > 604740) { LOG(WARNING) << "Error decoding Galileo ephemeris time (max of 604740, but " << toc << " was detected)"; @@ -4712,193 +4864,193 @@ int Rtcm::set_DF293(const Galileo_Ephemeris& gal_eph) } -int Rtcm::set_DF294(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF294(const Galileo_Ephemeris& gal_eph) { - short int af2 = static_cast(std::round(gal_eph.af2_4 / FNAV_af2_1_LSB)); + auto af2 = static_cast(std::round(gal_eph.af2_4 / FNAV_AF2_1_LSB)); DF294 = std::bitset<6>(af2); return 0; } -int Rtcm::set_DF295(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF295(const Galileo_Ephemeris& gal_eph) { - long int af1 = static_cast(std::round(gal_eph.af1_4 / FNAV_af1_1_LSB)); + auto af1 = static_cast(std::round(gal_eph.af1_4 / FNAV_AF1_1_LSB)); DF295 = std::bitset<21>(af1); return 0; } -int Rtcm::set_DF296(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF296(const Galileo_Ephemeris& gal_eph) { - long int af0 = static_cast(std::round(gal_eph.af0_4 / FNAV_af0_1_LSB)); + int64_t af0 = static_cast(std::round(gal_eph.af0_4 / FNAV_AF0_1_LSB)); DF296 = std::bitset<31>(af0); return 0; } -int Rtcm::set_DF297(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF297(const Galileo_Ephemeris& gal_eph) { - int crs = static_cast(std::round(gal_eph.C_rs_3 / FNAV_Crs_3_LSB)); + auto crs = static_cast(std::round(gal_eph.C_rs_3 / FNAV_CRS_3_LSB)); DF297 = std::bitset<16>(crs); return 0; } -int Rtcm::set_DF298(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF298(const Galileo_Ephemeris& gal_eph) { - int delta_n = static_cast(std::round(gal_eph.delta_n_3 / FNAV_deltan_3_LSB)); + auto delta_n = static_cast(std::round(gal_eph.delta_n_3 / FNAV_DELTAN_3_LSB)); DF298 = std::bitset<16>(delta_n); return 0; } -int Rtcm::set_DF299(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF299(const Galileo_Ephemeris& gal_eph) { - long int m0 = static_cast(std::round(gal_eph.M0_1 / FNAV_M0_2_LSB)); + auto m0 = static_cast(std::round(gal_eph.M0_1 / FNAV_M0_2_LSB)); DF299 = std::bitset<32>(m0); return 0; } -int Rtcm::set_DF300(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF300(const Galileo_Ephemeris& gal_eph) { - int cuc = static_cast(std::round(gal_eph.C_uc_3 / FNAV_Cuc_3_LSB)); + int32_t cuc = static_cast(std::round(gal_eph.C_uc_3 / FNAV_CUC_3_LSB)); DF300 = std::bitset<16>(cuc); return 0; } -int Rtcm::set_DF301(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF301(const Galileo_Ephemeris& gal_eph) { - unsigned long int ecc = static_cast(std::round(gal_eph.e_1 / FNAV_e_2_LSB)); + auto ecc = static_cast(std::round(gal_eph.e_1 / FNAV_E_2_LSB)); DF301 = std::bitset<32>(ecc); return 0; } -int Rtcm::set_DF302(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF302(const Galileo_Ephemeris& gal_eph) { - int cus = static_cast(std::round(gal_eph.C_us_3 / FNAV_Cus_3_LSB)); + auto cus = static_cast(std::round(gal_eph.C_us_3 / FNAV_CUS_3_LSB)); DF302 = std::bitset<16>(cus); return 0; } -int Rtcm::set_DF303(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF303(const Galileo_Ephemeris& gal_eph) { - unsigned long int sqr_a = static_cast(std::round(gal_eph.A_1 / FNAV_a12_2_LSB)); + auto sqr_a = static_cast(std::round(gal_eph.A_1 / FNAV_A12_2_LSB)); DF303 = std::bitset<32>(sqr_a); return 0; } -int Rtcm::set_DF304(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF304(const Galileo_Ephemeris& gal_eph) { - unsigned int toe = static_cast(std::round(gal_eph.t0e_1 / FNAV_t0e_3_LSB)); + auto toe = static_cast(std::round(gal_eph.t0e_1 / FNAV_T0E_3_LSB)); DF304 = std::bitset<14>(toe); return 0; } -int Rtcm::set_DF305(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF305(const Galileo_Ephemeris& gal_eph) { - int cic = static_cast(std::round(gal_eph.C_ic_4 / FNAV_Cic_4_LSB)); + auto cic = static_cast(std::round(gal_eph.C_ic_4 / FNAV_CIC_4_LSB)); DF305 = std::bitset<16>(cic); return 0; } -int Rtcm::set_DF306(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF306(const Galileo_Ephemeris& gal_eph) { - long int Omega0 = static_cast(std::round(gal_eph.OMEGA_0_2 / FNAV_omega0_2_LSB)); + auto Omega0 = static_cast(std::round(gal_eph.OMEGA_0_2 / FNAV_OMEGA0_2_LSB)); DF306 = std::bitset<32>(Omega0); return 0; } -int Rtcm::set_DF307(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF307(const Galileo_Ephemeris& gal_eph) { - int cis = static_cast(std::round(gal_eph.C_is_4 / FNAV_Cis_4_LSB)); + auto cis = static_cast(std::round(gal_eph.C_is_4 / FNAV_CIS_4_LSB)); DF307 = std::bitset<16>(cis); return 0; } -int Rtcm::set_DF308(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF308(const Galileo_Ephemeris& gal_eph) { - long int i0 = static_cast(std::round(gal_eph.i_0_2 / FNAV_i0_3_LSB)); + auto i0 = static_cast(std::round(gal_eph.i_0_2 / FNAV_I0_3_LSB)); DF308 = std::bitset<32>(i0); return 0; } -int Rtcm::set_DF309(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF309(const Galileo_Ephemeris& gal_eph) { - int crc = static_cast(std::round(gal_eph.C_rc_3 / FNAV_Crc_3_LSB)); + int32_t crc = static_cast(std::round(gal_eph.C_rc_3 / FNAV_CRC_3_LSB)); DF309 = std::bitset<16>(crc); return 0; } -int Rtcm::set_DF310(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF310(const Galileo_Ephemeris& gal_eph) { - int omega = static_cast(std::round(gal_eph.omega_2 / FNAV_omega0_2_LSB)); + auto omega = static_cast(std::round(gal_eph.omega_2 / FNAV_OMEGA0_2_LSB)); DF310 = std::bitset<32>(omega); return 0; } -int Rtcm::set_DF311(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF311(const Galileo_Ephemeris& gal_eph) { - long int Omegadot = static_cast(std::round(gal_eph.OMEGA_dot_3 / FNAV_omegadot_2_LSB)); + auto Omegadot = static_cast(std::round(gal_eph.OMEGA_dot_3 / FNAV_OMEGADOT_2_LSB)); DF311 = std::bitset<24>(Omegadot); return 0; } -int Rtcm::set_DF312(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF312(const Galileo_Ephemeris& gal_eph) { - int bdg_E1_E5a = static_cast(std::round(gal_eph.BGD_E1E5a_5 / FNAV_BGD_1_LSB)); + auto bdg_E1_E5a = static_cast(std::round(gal_eph.BGD_E1E5a_5 / FNAV_BGD_1_LSB)); DF312 = std::bitset<10>(bdg_E1_E5a); return 0; } -int Rtcm::set_DF313(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF313(const Galileo_Ephemeris& gal_eph) { - unsigned int bdg_E5b_E1 = static_cast(std::round(gal_eph.BGD_E1E5b_5)); + auto bdg_E5b_E1 = static_cast(std::round(gal_eph.BGD_E1E5b_5)); //bdg_E5b_E1 = 0; //reserved DF313 = std::bitset<10>(bdg_E5b_E1); return 0; } -int Rtcm::set_DF314(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF314(const Galileo_Ephemeris& gal_eph) { DF314 = std::bitset<2>(gal_eph.E5a_HS); return 0; } -int Rtcm::set_DF315(const Galileo_Ephemeris& gal_eph) +int32_t Rtcm::set_DF315(const Galileo_Ephemeris& gal_eph) { DF315 = std::bitset<1>(gal_eph.E5a_DVS); return 0; } -int Rtcm::set_DF393(bool more_messages) +int32_t Rtcm::set_DF393(bool more_messages) { DF393 = std::bitset<1>(more_messages); return 0; } -int Rtcm::set_DF394(const std::map& gnss_synchro) +int32_t Rtcm::set_DF394(const std::map& gnss_synchro) { DF394.reset(); - std::map::const_iterator gnss_synchro_iter; - unsigned int mask_position; + std::map::const_iterator gnss_synchro_iter; + uint32_t mask_position; for (gnss_synchro_iter = gnss_synchro.cbegin(); gnss_synchro_iter != gnss_synchro.cend(); gnss_synchro_iter++) @@ -4910,16 +5062,16 @@ int Rtcm::set_DF394(const std::map& gnss_synchro) } -int Rtcm::set_DF395(const std::map& gnss_synchro) +int32_t Rtcm::set_DF395(const std::map& gnss_synchro) { DF395.reset(); - if (gnss_synchro.size() == 0) + if (gnss_synchro.empty()) { return 1; } - std::map::const_iterator gnss_synchro_iter; + std::map::const_iterator gnss_synchro_iter; std::string sig; - unsigned int mask_position; + uint32_t mask_position; for (gnss_synchro_iter = gnss_synchro.cbegin(); gnss_synchro_iter != gnss_synchro.cend(); gnss_synchro_iter++) @@ -4929,44 +5081,44 @@ int Rtcm::set_DF395(const std::map& gnss_synchro) std::string sys(&gnss_synchro_iter->second.System, 1); - if ((sig.compare("1C") == 0) && (sys.compare("G") == 0)) + if ((sig == "1C") && (sys == "G")) { mask_position = 32 - 2; DF395.set(mask_position, true); } - if ((sig.compare("2S") == 0) && (sys.compare("G") == 0)) + if ((sig == "2S") && (sys == "G")) { mask_position = 32 - 15; DF395.set(mask_position, true); } - if ((sig.compare("5X") == 0) && (sys.compare("G") == 0)) + if ((sig == "5X") && (sys == "G")) { mask_position = 32 - 24; DF395.set(mask_position, true); } - if ((sig.compare("1B") == 0) && (sys.compare("E") == 0)) + if ((sig == "1B") && (sys == "E")) { mask_position = 32 - 4; DF395.set(mask_position, true); } - if ((sig.compare("5X") == 0) && (sys.compare("E") == 0)) + if ((sig == "5X") && (sys == "E")) { mask_position = 32 - 24; DF395.set(mask_position, true); } - if ((sig.compare("7X") == 0) && (sys.compare("E") == 0)) + if ((sig == "7X") && (sys == "E")) { mask_position = 32 - 16; DF395.set(mask_position, true); } - if ((sig.compare("1C") == 0) && (sys.compare("R") == 0)) + if ((sig == "1C") && (sys == "R")) { mask_position = 32 - 2; DF395.set(mask_position, true); } - if ((sig.compare("2C") == 0) && (sys.compare("R") == 0)) + if ((sig == "2C") && (sys == "R")) { mask_position = 32 - 8; DF395.set(mask_position, true); @@ -4977,14 +5129,14 @@ int Rtcm::set_DF395(const std::map& gnss_synchro) } -std::string Rtcm::set_DF396(const std::map& observables) +std::string Rtcm::set_DF396(const std::map& observables) { std::string DF396; - std::map::const_iterator observables_iter; + std::map::const_iterator observables_iter; Rtcm::set_DF394(observables); Rtcm::set_DF395(observables); - unsigned int num_signals = DF395.count(); - unsigned int num_satellites = DF394.count(); + uint32_t num_signals = DF395.count(); + uint32_t num_satellites = DF394.count(); if ((num_signals == 0) || (num_satellites == 0)) { @@ -4994,7 +5146,7 @@ std::string Rtcm::set_DF396(const std::map& observables) std::vector > matrix(num_signals, std::vector()); std::string sig; - std::vector list_of_sats; + std::vector list_of_sats; std::vector list_of_signals; for (observables_iter = observables.cbegin(); @@ -5008,29 +5160,29 @@ std::string Rtcm::set_DF396(const std::map& observables) std::string sys(&observables_iter->second.System, 1); - if ((sig.compare("1C") == 0) && (sys.compare("G") == 0)) + if ((sig == "1C") && (sys == "G")) { list_of_signals.push_back(32 - 2); } - if ((sig.compare("2S") == 0) && (sys.compare("G") == 0)) + if ((sig == "2S") && (sys == "G")) { list_of_signals.push_back(32 - 15); } - if ((sig.compare("5X") == 0) && (sys.compare("G") == 0)) + if ((sig == "5X") && (sys == "G")) { list_of_signals.push_back(32 - 24); } - if ((sig.compare("1B") == 0) && (sys.compare("E") == 0)) + if ((sig == "1B") && (sys == "E")) { list_of_signals.push_back(32 - 4); } - if ((sig.compare("5X") == 0) && (sys.compare("E") == 0)) + if ((sig == "5X") && (sys == "E")) { list_of_signals.push_back(32 - 24); } - if ((sig.compare("7X") == 0) && (sys.compare("E") == 0)) + if ((sig == "7X") && (sys == "E")) { list_of_signals.push_back(32 - 16); } @@ -5046,9 +5198,9 @@ std::string Rtcm::set_DF396(const std::map& observables) // fill the matrix bool value; - for (unsigned int row = 0; row < num_signals; row++) + for (uint32_t row = 0; row < num_signals; row++) { - for (unsigned int sat = 0; sat < num_satellites; sat++) + for (uint32_t sat = 0; sat < num_satellites; sat++) { value = false; for (observables_iter = observables.cbegin(); @@ -5059,32 +5211,32 @@ std::string Rtcm::set_DF396(const std::map& observables) sig = sig_.substr(0, 2); std::string sys(&observables_iter->second.System, 1); - if ((sig.compare("1C") == 0) && (sys.compare("G") == 0) && (list_of_signals.at(row) == 32 - 2) && (observables_iter->second.PRN == list_of_sats.at(sat))) + if ((sig == "1C") && (sys == "G") && (list_of_signals.at(row) == 32 - 2) && (observables_iter->second.PRN == list_of_sats.at(sat))) { value = true; } - if ((sig.compare("2S") == 0) && (sys.compare("G") == 0) && (list_of_signals.at(row) == 32 - 15) && (observables_iter->second.PRN == list_of_sats.at(sat))) + if ((sig == "2S") && (sys == "G") && (list_of_signals.at(row) == 32 - 15) && (observables_iter->second.PRN == list_of_sats.at(sat))) { value = true; } - if ((sig.compare("5X") == 0) && (sys.compare("G") == 0) && (list_of_signals.at(row) == 32 - 24) && (observables_iter->second.PRN == list_of_sats.at(sat))) + if ((sig == "5X") && (sys == "G") && (list_of_signals.at(row) == 32 - 24) && (observables_iter->second.PRN == list_of_sats.at(sat))) { value = true; } - if ((sig.compare("1B") == 0) && (sys.compare("E") == 0) && (list_of_signals.at(row) == 32 - 4) && (observables_iter->second.PRN == list_of_sats.at(sat))) + if ((sig == "1B") && (sys == "E") && (list_of_signals.at(row) == 32 - 4) && (observables_iter->second.PRN == list_of_sats.at(sat))) { value = true; } - if ((sig.compare("5X") == 0) && (sys.compare("E") == 0) && (list_of_signals.at(row) == 32 - 24) && (observables_iter->second.PRN == list_of_sats.at(sat))) + if ((sig == "5X") && (sys == "E") && (list_of_signals.at(row) == 32 - 24) && (observables_iter->second.PRN == list_of_sats.at(sat))) { value = true; } - if ((sig.compare("7X") == 0) && (sys.compare("E") == 0) && (list_of_signals.at(row) == 32 - 16) && (observables_iter->second.PRN == list_of_sats.at(sat))) + if ((sig == "7X") && (sys == "E") && (list_of_signals.at(row) == 32 - 16) && (observables_iter->second.PRN == list_of_sats.at(sat))) { value = true; } @@ -5095,9 +5247,9 @@ std::string Rtcm::set_DF396(const std::map& observables) // write the matrix column-wise DF396.clear(); - for (unsigned int col = 0; col < num_satellites; col++) + for (uint32_t col = 0; col < num_satellites; col++) { - for (unsigned int row = 0; row < num_signals; row++) + for (uint32_t row = 0; row < num_signals; row++) { std::string ss; if (matrix[row].at(col)) @@ -5115,12 +5267,12 @@ std::string Rtcm::set_DF396(const std::map& observables) } -int Rtcm::set_DF397(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF397(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = GPS_C_m_s * 0.001; + double meters_to_miliseconds = GPS_C_M_S * 0.001; double rough_range_s = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; - unsigned int int_ms = 0; + uint32_t int_ms = 0; if (rough_range_s == 0.0) { @@ -5132,7 +5284,7 @@ int Rtcm::set_DF397(const Gnss_Synchro& gnss_synchro) } else { - int_ms = static_cast(std::floor(rough_range_s / meters_to_miliseconds / TWO_N10) + 0.5) >> 10; + int_ms = static_cast(std::floor(rough_range_s / meters_to_miliseconds / TWO_N10) + 0.5) >> 10; } DF397 = std::bitset<8>(int_ms); @@ -5140,66 +5292,72 @@ int Rtcm::set_DF397(const Gnss_Synchro& gnss_synchro) } -int Rtcm::set_DF398(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF398(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = GPS_C_m_s * 0.001; + double meters_to_miliseconds = GPS_C_M_S * 0.001; double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; - unsigned int rr_mod_ms; + uint32_t rr_mod_ms; if ((rough_range_m <= 0.0) || (rough_range_m > meters_to_miliseconds * 255.0)) { rr_mod_ms = 0; } else { - rr_mod_ms = static_cast(std::floor(rough_range_m / meters_to_miliseconds / TWO_N10) + 0.5) & 0x3FFu; + rr_mod_ms = static_cast(std::floor(rough_range_m / meters_to_miliseconds / TWO_N10) + 0.5) & 0x3FFu; } DF398 = std::bitset<10>(rr_mod_ms); return 0; } -int Rtcm::set_DF399(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF399(const Gnss_Synchro& gnss_synchro) { double lambda = 0.0; std::string sig_(gnss_synchro.Signal); std::string sig = sig_.substr(0, 2); - if (sig.compare("1C") == 0) + if (sig == "1C") { - lambda = GPS_C_m_s / GPS_L1_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L1_FREQ_HZ; } - if (sig.compare("2S") == 0) + if (sig == "2S") { - lambda = GPS_C_m_s / GPS_L2_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L2_FREQ_HZ; } - if (sig.compare("5X") == 0) + if (sig == "5X") { - lambda = GPS_C_m_s / Galileo_E5a_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E5A_FREQ_HZ; } - if (sig.compare("1B") == 0) + if (sig == "1B") { - lambda = GPS_C_m_s / Galileo_E1_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E1_FREQ_HZ; } - if (sig.compare("7X") == 0) + if (sig == "7X") { - lambda = GPS_C_m_s / 1.207140e9; // Galileo_E1b_FREQ_HZ; + lambda = GPS_C_M_S / 1.207140e9; // Galileo_E1b_FREQ_HZ; } double rough_phase_range_rate_ms = std::round(-gnss_synchro.Carrier_Doppler_hz * lambda); - if (rough_phase_range_rate_ms < -8191) rough_phase_range_rate_ms = -8192; - if (rough_phase_range_rate_ms > 8191) rough_phase_range_rate_ms = -8192; + if (rough_phase_range_rate_ms < -8191) + { + rough_phase_range_rate_ms = -8192; + } + if (rough_phase_range_rate_ms > 8191) + { + rough_phase_range_rate_ms = -8192; + } - DF399 = std::bitset<14>(static_cast(rough_phase_range_rate_ms)); + DF399 = std::bitset<14>(static_cast(rough_phase_range_rate_ms)); return 0; } -int Rtcm::set_DF400(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF400(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = GPS_C_m_s * 0.001; + double meters_to_miliseconds = GPS_C_M_S * 0.001; double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; double psrng_s; - int fine_pseudorange; + int32_t fine_pseudorange; psrng_s = gnss_synchro.Pseudorange_m - rough_range_m; @@ -5213,7 +5371,7 @@ int Rtcm::set_DF400(const Gnss_Synchro& gnss_synchro) } else { - fine_pseudorange = static_cast(std::round(psrng_s / meters_to_miliseconds / TWO_N24)); + fine_pseudorange = static_cast(std::round(psrng_s / meters_to_miliseconds / TWO_N24)); } DF400 = std::bitset<15>(fine_pseudorange); @@ -5221,46 +5379,46 @@ int Rtcm::set_DF400(const Gnss_Synchro& gnss_synchro) } -int Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = GPS_C_m_s * 0.001; + double meters_to_miliseconds = GPS_C_M_S * 0.001; double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; double phrng_m; - long int fine_phaserange; + int64_t fine_phaserange; double lambda = 0.0; std::string sig_(gnss_synchro.Signal); std::string sig = sig_.substr(0, 2); std::string sys(&gnss_synchro.System, 1); - if ((sig.compare("1C") == 0) && (sys.compare("G") == 0)) + if ((sig == "1C") && (sys == "G")) { - lambda = GPS_C_m_s / GPS_L1_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L1_FREQ_HZ; } - if ((sig.compare("2S")) == 0 && (sys.compare("G") == 0)) + if ((sig == "2S") && (sys == "G")) { - lambda = GPS_C_m_s / GPS_L2_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L2_FREQ_HZ; } - if ((sig.compare("5X")) == 0 && (sys.compare("E") == 0)) + if ((sig == "5X") && (sys == "E")) { - lambda = GPS_C_m_s / Galileo_E5a_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E5A_FREQ_HZ; } - if ((sig.compare("1B")) == 0 && (sys.compare("E") == 0)) + if ((sig == "1B") && (sys == "E")) { - lambda = GPS_C_m_s / Galileo_E1_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E1_FREQ_HZ; } - if ((sig.compare("7X")) == 0 && (sys.compare("E") == 0)) + if ((sig == "7X") && (sys == "E")) { - lambda = GPS_C_m_s / 1.207140e9; // Galileo_E1b_FREQ_HZ; + lambda = GPS_C_M_S / 1.207140e9; // Galileo_E1b_FREQ_HZ; } - if ((sig.compare("1C") == 0) && (sys.compare("R") == 0)) + if ((sig == "1C") && (sys == "R")) { - lambda = GLONASS_C_m_s / ((GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN)))); + lambda = GLONASS_C_M_S / ((GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN)))); } - if ((sig.compare("2C") == 0) && (sys.compare("R") == 0)) + if ((sig == "2C") && (sys == "R")) { // TODO Need to add slot number and freq number to gnss_syncro - lambda = GLONASS_C_m_s / (GLONASS_L2_CA_FREQ_HZ); + lambda = GLONASS_C_M_S / (GLONASS_L2_CA_FREQ_HZ); } phrng_m = (gnss_synchro.Carrier_phase_rads / GPS_TWO_PI) * lambda - rough_range_m; @@ -5284,7 +5442,7 @@ int Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) } else { - fine_phaserange = static_cast(std::round(phrng_m / meters_to_miliseconds / TWO_N29)); + fine_phaserange = static_cast(std::round(phrng_m / meters_to_miliseconds / TWO_N29)); } DF401 = std::bitset<22>(fine_phaserange); @@ -5292,30 +5450,30 @@ int Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) } -int Rtcm::set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_period_s = 0; - unsigned int lock_time_indicator; + uint32_t lock_time_period_s = 0; + uint32_t lock_time_indicator; std::string sig_(gnss_synchro.Signal); std::string sys(&gnss_synchro.System, 1); - if ((sig_.compare("1C") == 0) && (sys.compare("G") == 0)) + if ((sig_ == "1C") && (sys == "G")) { lock_time_period_s = Rtcm::lock_time(ephNAV, obs_time, gnss_synchro); } - if ((sig_.compare("2S") == 0) && (sys.compare("G") == 0)) + if ((sig_ == "2S") && (sys == "G")) { lock_time_period_s = Rtcm::lock_time(ephCNAV, obs_time, gnss_synchro); } // TODO Should add system for galileo satellites - if (sig_.compare("1B") || sig_.compare("5X") || sig_.compare("7X") || sig_.compare("8X")) + if ((sig_ == "1B") || (sig_ == "5X") || (sig_ == "7X") || (sig_ == "8X")) { lock_time_period_s = Rtcm::lock_time(ephFNAV, obs_time, gnss_synchro); } - if ((sig_.compare("1C") == 0) && (sys.compare("R") == 0)) + if ((sig_ == "1C") && (sys == "R")) { lock_time_period_s = Rtcm::lock_time(ephGNAV, obs_time, gnss_synchro); } - if ((sig_.compare("2C") == 0) && (sys.compare("R") == 0)) + if ((sig_ == "2C") && (sys == "R")) { lock_time_period_s = Rtcm::lock_time(ephGNAV, obs_time, gnss_synchro); } @@ -5325,51 +5483,51 @@ int Rtcm::set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCN } -int Rtcm::set_DF403(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF403(const Gnss_Synchro& gnss_synchro) { - unsigned int cnr_dB_Hz; - cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz)); + uint32_t cnr_dB_Hz; + cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz)); DF403 = std::bitset<6>(cnr_dB_Hz); return 0; } -int Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) { double lambda = 0.0; std::string sig_(gnss_synchro.Signal); std::string sig = sig_.substr(0, 2); - int fine_phaserange_rate; + int32_t fine_phaserange_rate; std::string sys_(&gnss_synchro.System, 1); - if ((sig_.compare("1C") == 0) && (sys_.compare("G") == 0)) + if ((sig_ == "1C") && (sys_ == "G")) { - lambda = GPS_C_m_s / GPS_L1_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L1_FREQ_HZ; } - if ((sig_.compare("2S") == 0) && (sys_.compare("G") == 0)) + if ((sig_ == "2S") && (sys_ == "G")) { - lambda = GPS_C_m_s / GPS_L2_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L2_FREQ_HZ; } - if ((sig_.compare("5X") == 0) && (sys_.compare("E") == 0)) + if ((sig_ == "5X") && (sys_ == "E")) { - lambda = GPS_C_m_s / Galileo_E5a_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E5A_FREQ_HZ; } - if ((sig_.compare("1B") == 0) && (sys_.compare("E") == 0)) + if ((sig_ == "1B") && (sys_ == "E")) { - lambda = GPS_C_m_s / Galileo_E1_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E1_FREQ_HZ; } - if ((sig_.compare("7X") == 0) && (sys_.compare("E") == 0)) + if ((sig_ == "7X") && (sys_ == "E")) { - lambda = GPS_C_m_s / 1.207140e9; // Galileo_E1b_FREQ_HZ; + lambda = GPS_C_M_S / 1.207140e9; // Galileo_E1b_FREQ_HZ; } - if ((sig_.compare("1C") == 0) && (sys_.compare("R") == 0)) + if ((sig_ == "1C") && (sys_ == "R")) { - lambda = GLONASS_C_m_s / (GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN))); + lambda = GLONASS_C_M_S / (GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN))); } - if ((sig_.compare("2C") == 0) && (sys_.compare("R") == 0)) + if ((sig_ == "2C") && (sys_ == "R")) { //TODO Need to add slot number and freq number to gnss syncro - lambda = GLONASS_C_m_s / (GLONASS_L2_CA_FREQ_HZ); + lambda = GLONASS_C_M_S / (GLONASS_L2_CA_FREQ_HZ); } double rough_phase_range_rate = std::round(-gnss_synchro.Carrier_Doppler_hz * lambda); double phrr = (-gnss_synchro.Carrier_Doppler_hz * lambda - rough_phase_range_rate); @@ -5384,7 +5542,7 @@ int Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) } else { - fine_phaserange_rate = static_cast(std::round(phrr / 0.0001)); + fine_phaserange_rate = static_cast(std::round(phrr / 0.0001)); } DF404 = std::bitset<15>(fine_phaserange_rate); @@ -5392,12 +5550,12 @@ int Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) } -int Rtcm::set_DF405(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF405(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = GPS_C_m_s * 0.001; + double meters_to_miliseconds = GPS_C_M_S * 0.001; double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; double psrng_s; - long int fine_pseudorange; + int64_t fine_pseudorange; psrng_s = gnss_synchro.Pseudorange_m - rough_range_m; @@ -5411,17 +5569,17 @@ int Rtcm::set_DF405(const Gnss_Synchro& gnss_synchro) } else { - fine_pseudorange = static_cast(std::round(psrng_s / meters_to_miliseconds / TWO_N29)); + fine_pseudorange = static_cast(std::round(psrng_s / meters_to_miliseconds / TWO_N29)); } DF405 = std::bitset<20>(fine_pseudorange); return 0; } -int Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) { - long int fine_phaserange_ex; - double meters_to_miliseconds = GPS_C_m_s * 0.001; + int64_t fine_phaserange_ex; + double meters_to_miliseconds = GPS_C_M_S * 0.001; double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; double phrng_m; double lambda = 0.0; @@ -5429,34 +5587,34 @@ int Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) sig_ = sig_.substr(0, 2); std::string sys_(&gnss_synchro.System, 1); - if ((sig_.compare("1C") == 0) && (sys_.compare("G") == 0)) + if ((sig_ == "1C") && (sys_ == "G")) { - lambda = GPS_C_m_s / GPS_L1_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L1_FREQ_HZ; } - if ((sig_.compare("2S") == 0) && (sys_.compare("G") == 0)) + if ((sig_ == "2S") && (sys_ == "G")) { - lambda = GPS_C_m_s / GPS_L2_FREQ_HZ; + lambda = GPS_C_M_S / GPS_L2_FREQ_HZ; } - if ((sig_.compare("5X") == 0) && (sys_.compare("E") == 0)) + if ((sig_ == "5X") && (sys_ == "E")) { - lambda = GPS_C_m_s / Galileo_E5a_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E5A_FREQ_HZ; } - if ((sig_.compare("1B") == 0) && (sys_.compare("E") == 0)) + if ((sig_ == "1B") && (sys_ == "E")) { - lambda = GPS_C_m_s / Galileo_E1_FREQ_HZ; + lambda = GPS_C_M_S / GALILEO_E1_FREQ_HZ; } - if ((sig_.compare("7X") == 0) && (sys_.compare("E") == 0)) + if ((sig_ == "7X") && (sys_ == "E")) { - lambda = GPS_C_m_s / 1.207140e9; // Galileo_E1b_FREQ_HZ; + lambda = GPS_C_M_S / 1.207140e9; // Galileo_E1b_FREQ_HZ; } - if ((sig_.compare("1C") == 0) && (sys_.compare("R") == 0)) + if ((sig_ == "1C") && (sys_ == "R")) { - lambda = GLONASS_C_m_s / (GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN))); + lambda = GLONASS_C_M_S / (GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN))); } - if ((sig_.compare("2C") == 0) && (sys_.compare("R") == 0)) + if ((sig_ == "2C") && (sys_ == "R")) { //TODO Need to add slot number and freq number to gnss syncro - lambda = GLONASS_C_m_s / (GLONASS_L2_CA_FREQ_HZ); + lambda = GLONASS_C_M_S / (GLONASS_L2_CA_FREQ_HZ); } phrng_m = (gnss_synchro.Carrier_phase_rads / GPS_TWO_PI) * lambda - rough_range_m; @@ -5479,7 +5637,7 @@ int Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) } else { - fine_phaserange_ex = static_cast(std::round(phrng_m / meters_to_miliseconds / TWO_N31)); + fine_phaserange_ex = static_cast(std::round(phrng_m / meters_to_miliseconds / TWO_N31)); } DF406 = std::bitset<24>(fine_phaserange_ex); @@ -5487,30 +5645,30 @@ int Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) } -int Rtcm::set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro) { - unsigned int lock_time_indicator; - unsigned int lock_time_period_s = 0; + uint32_t lock_time_indicator; + uint32_t lock_time_period_s = 0; std::string sig_(gnss_synchro.Signal); std::string sys_(&gnss_synchro.System, 1); - if ((sig_.compare("1C")) && (sys_.compare("G") == 0)) + if ((sig_ == "1C") && (sys_ == "G")) { lock_time_period_s = Rtcm::lock_time(ephNAV, obs_time, gnss_synchro); } - if ((sig_.compare("2S")) && (sys_.compare("G") == 0)) + if ((sig_ == "2S") && (sys_ == "G")) { lock_time_period_s = Rtcm::lock_time(ephCNAV, obs_time, gnss_synchro); } - if ((sig_.compare("1B") || sig_.compare("5X") || sig_.compare("7X") || sig_.compare("8X")) && (sys_.compare("E") == 0)) + if (((sig_ == "1B") || (sig_ == "5X") || (sig_ == "7X") || (sig_ == "8X")) && (sys_ == "E")) { lock_time_period_s = Rtcm::lock_time(ephFNAV, obs_time, gnss_synchro); } - if ((sig_.compare("1C") == 0) && (sys_.compare("R") == 0)) + if ((sig_ == "1C") && (sys_ == "R")) { lock_time_period_s = Rtcm::lock_time(ephGNAV, obs_time, gnss_synchro); } - if ((sig_.compare("2C") == 0) && (sys_.compare("R") == 0)) + if ((sig_ == "2C") && (sys_ == "R")) { lock_time_period_s = Rtcm::lock_time(ephGNAV, obs_time, gnss_synchro); } @@ -5520,44 +5678,44 @@ int Rtcm::set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCN } -int Rtcm::set_DF408(const Gnss_Synchro& gnss_synchro) +int32_t Rtcm::set_DF408(const Gnss_Synchro& gnss_synchro) { - unsigned int cnr_dB_Hz; - cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz / 0.0625)); + uint32_t cnr_dB_Hz; + cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz / 0.0625)); DF408 = std::bitset<10>(cnr_dB_Hz); return 0; } -int Rtcm::set_DF409(unsigned int iods) +int32_t Rtcm::set_DF409(uint32_t iods) { DF409 = std::bitset<3>(iods); return 0; } -int Rtcm::set_DF411(unsigned int clock_steering_indicator) +int32_t Rtcm::set_DF411(uint32_t clock_steering_indicator) { DF411 = std::bitset<2>(clock_steering_indicator); return 0; } -int Rtcm::set_DF412(unsigned int external_clock_indicator) +int32_t Rtcm::set_DF412(uint32_t external_clock_indicator) { DF412 = std::bitset<2>(external_clock_indicator); return 0; } -int Rtcm::set_DF417(bool using_divergence_free_smoothing) +int32_t Rtcm::set_DF417(bool using_divergence_free_smoothing) { DF417 = std::bitset<1>(using_divergence_free_smoothing); return 0; } -int Rtcm::set_DF418(int carrier_smoothing_interval_s) +int32_t Rtcm::set_DF418(int32_t carrier_smoothing_interval_s) { if (carrier_smoothing_interval_s < 0) { @@ -5598,7 +5756,7 @@ int Rtcm::set_DF418(int carrier_smoothing_interval_s) } -int Rtcm::set_DF420(const Gnss_Synchro& gnss_synchro __attribute__((unused))) +int32_t Rtcm::set_DF420(const Gnss_Synchro& gnss_synchro __attribute__((unused))) { // todo: read the value from gnss_synchro bool half_cycle_ambiguity_indicator = true; diff --git a/src/core/system_parameters/rtcm.h b/src/algorithms/libs/rtcm.h similarity index 64% rename from src/core/system_parameters/rtcm.h rename to src/algorithms/libs/rtcm.h index 735d21343..9196a0968 100644 --- a/src/core/system_parameters/rtcm.h +++ b/src/algorithms/libs/rtcm.h @@ -34,14 +34,16 @@ #include "concurrent_queue.h" -#include "gnss_synchro.h" #include "galileo_fnav_message.h" -#include "gps_navigation_message.h" -#include "gps_cnav_navigation_message.h" #include "glonass_gnav_navigation_message.h" +#include "gnss_synchro.h" +#include "gps_cnav_navigation_message.h" +#include "gps_navigation_message.h" #include #include +#include #include +#include #include #include #include @@ -50,7 +52,6 @@ #include #include #include -#include /*! @@ -85,50 +86,50 @@ class Rtcm { public: - Rtcm(unsigned short port = 2101); //& observables, unsigned short station_id); + std::string print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints message type 1002 (Extended L1-Only GPS RTK Observables) */ - std::string print_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, unsigned short station_id); + std::string print_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints message type 1003 (L1 & L2 GPS RTK Observables) */ - std::string print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, unsigned short station_id); + std::string print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints message type 1004 (Extended L1 & L2 GPS RTK Observables) */ - std::string print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, unsigned short station_id); + std::string print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints message type 1005 (Stationary Antenna Reference Point) */ - std::string print_MT1005(unsigned int ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, unsigned int quarter_cycle_indicator); + std::string print_MT1005(uint32_t ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, uint32_t quarter_cycle_indicator); /*! * \brief Verifies and reads messages of type 1005 (Stationary Antenna Reference Point). Returns 1 if anything goes wrong, 0 otherwise. */ - int read_MT1005(const std::string& message, unsigned int& ref_id, double& ecef_x, double& ecef_y, double& ecef_z, bool& gps, bool& glonass, bool& galileo); + int32_t read_MT1005(const std::string& message, uint32_t& ref_id, double& ecef_x, double& ecef_y, double& ecef_z, bool& gps, bool& glonass, bool& galileo); /*! * \brief Prints message type 1006 (Stationary Antenna Reference Point, with Height Information) */ - std::string print_MT1006(unsigned int ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, unsigned int quarter_cycle_indicator, double height); + std::string print_MT1006(uint32_t ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, uint32_t quarter_cycle_indicator, double height); std::string print_MT1005_test(); //& observables, unsigned short station_id); + std::string print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints Extended L1-Only GLONASS RTK Observables * \details This GLONASS message type is used when only L1 data is present and bandwidth is very tight, often 1012 is used in such cases. @@ -149,7 +150,7 @@ public: * \param observables Set of observables as defined by the platform * \return string with message contents */ - std::string print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, unsigned short station_id); + std::string print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints L1&L2 GLONASS RTK Observables * \details This GLONASS message type is not generally used or supported; type 1012 is to be preferred @@ -159,7 +160,7 @@ public: * \param observables Set of observables as defined by the platform * \return string with message contents */ - std::string print_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables, unsigned short station_id); + std::string print_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints Extended L1&L2 GLONASS RTK Observables * \details This GLONASS message type is the most common observational message type, with L1/L2/SNR content. This is one of the most common messages found. @@ -169,7 +170,7 @@ public: * \param observables Set of observables as defined by the platform * \return string with message contents */ - std::string print_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables, unsigned short station_id); + std::string print_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables, uint16_t station_id); /*! * \brief Prints message type 1019 (GPS Ephemeris), should be broadcast in the event that @@ -180,7 +181,7 @@ public: /*! * \brief Verifies and reads messages of type 1019 (GPS Ephemeris). Returns 1 if anything goes wrong, 0 otherwise. */ - int read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph); + int32_t read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph); /*! * \brief Prints message type 1020 (GLONASS Ephemeris). @@ -199,12 +200,12 @@ public: * \param glonass_gnav_utc_model GLONASS GNAV Clock Information * \return Returns 1 if anything goes wrong, 0 otherwise. */ - int read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonass_gnav_eph, Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); + int32_t read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonass_gnav_eph, Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); /*! * \brief Prints message type 1029 (Unicode Text String) */ - std::string print_MT1029(unsigned int ref_id, const Gps_Ephemeris& gps_eph, double obs_time, const std::string& message); + std::string print_MT1029(uint32_t ref_id, const Gps_Ephemeris& gps_eph, double obs_time, const std::string& message); /*! * \brief Prints message type 1045 (Galileo Ephemeris), should be broadcast every 2 minutes @@ -214,7 +215,7 @@ public: /*! * \brief Verifies and reads messages of type 1045 (Galileo Ephemeris). Returns 1 if anything goes wrong, 0 otherwise. */ - int read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph); + int32_t read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph); /*! * \brief Prints messages of type MSM1 (Compact GNSS observables) @@ -224,11 +225,11 @@ public: const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); @@ -240,11 +241,11 @@ public: const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); @@ -256,11 +257,11 @@ public: const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); @@ -272,11 +273,11 @@ public: const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); @@ -288,11 +289,11 @@ public: const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); @@ -304,11 +305,11 @@ public: const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); @@ -320,17 +321,17 @@ public: const Galileo_Ephemeris& gal_eph, const Glonass_Gnav_Ephemeris& glo_gnav_eph, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); - unsigned int lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); // get_MT1001_4_header(unsigned int msg_number, + std::bitset<64> get_MT1001_4_header(uint32_t msg_number, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t smooth_int, bool sync_flag, bool divergence_free); @@ -400,11 +401,11 @@ private: * \param divergence_free * \return Returns the message header content as set of bits */ - std::bitset<61> get_MT1009_12_header(unsigned int msg_number, + std::bitset<61> get_MT1009_12_header(uint32_t msg_number, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t smooth_int, bool sync_flag, bool divergence_free); @@ -439,7 +440,7 @@ private: * \param gnss_synchroL2 Information generated by channels while processing the GLONASS GNAV L2 satellite * \return Returns the message content as set of bits */ - std::bitset<107> get_MT1011_sat_content(const Glonass_Gnav_Ephemeris& ephGNAVL1, const Glonass_Gnav_Ephemeris& ephGNAVL2, double obs_time, const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); + std::bitset<107> get_MT1011_sat_content(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); /*! * \brief Get the contents of the satellite specific portion of a type 1012 Message (GLONASS Extended RTK, L1 & L2) * \details Contents generated for each satellite. See table 3.5-14 @@ -451,37 +452,37 @@ private: * \param gnss_synchroL2 Information generated by channels while processing the GLONASS GNAV L2 satellite * \return Returns the message content as set of bits */ - std::bitset<130> get_MT1012_sat_content(const Glonass_Gnav_Ephemeris& ephGNAVL1, const Glonass_Gnav_Ephemeris& ephGNAVL2, double obs_time, const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); + std::bitset<130> get_MT1012_sat_content(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); - std::string get_MSM_header(unsigned int msg_number, + std::string get_MSM_header(uint32_t msg_number, double obs_time, - const std::map& observables, - unsigned int ref_id, - unsigned int clock_steering_indicator, - unsigned int external_clock_indicator, - int smooth_int, + const std::map& observables, + uint32_t ref_id, + uint32_t clock_steering_indicator, + uint32_t external_clock_indicator, + int32_t smooth_int, bool divergence_free, bool more_messages); - std::string get_MSM_1_content_sat_data(const std::map& observables); - std::string get_MSM_4_content_sat_data(const std::map& observables); - std::string get_MSM_5_content_sat_data(const std::map& observables); + std::string get_MSM_1_content_sat_data(const std::map& observables); + std::string get_MSM_4_content_sat_data(const std::map& observables); + std::string get_MSM_5_content_sat_data(const std::map& observables); - std::string get_MSM_1_content_signal_data(const std::map& observables); - std::string get_MSM_2_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); - std::string get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); - std::string get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); - std::string get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); - std::string get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); - std::string get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); + std::string get_MSM_1_content_signal_data(const std::map& observables); + std::string get_MSM_2_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); + std::string get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); + std::string get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); + std::string get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); + std::string get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); + std::string get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const std::map& observables); // // Utilities // static std::map galileo_signal_map; static std::map gps_signal_map; - std::vector > sort_by_signal(const std::vector >& synchro_map) const; - std::vector > sort_by_PRN_mask(const std::vector >& synchro_map) const; + std::vector > sort_by_signal(const std::vector >& synchro_map) const; + std::vector > sort_by_PRN_mask(const std::vector >& synchro_map) const; boost::posix_time::ptime compute_GPS_time(const Gps_Ephemeris& eph, double obs_time) const; boost::posix_time::ptime compute_GPS_time(const Gps_CNAV_Ephemeris& eph, double obs_time) const; boost::posix_time::ptime compute_Galileo_time(const Galileo_Ephemeris& eph, double obs_time) const; @@ -492,15 +493,15 @@ private: boost::posix_time::ptime gal_E5_last_lock_time[64]; boost::posix_time::ptime glo_L1_last_lock_time[64]; boost::posix_time::ptime glo_L2_last_lock_time[64]; - unsigned int lock_time_indicator(unsigned int lock_time_period_s); - unsigned int msm_lock_time_indicator(unsigned int lock_time_period_s); - unsigned int msm_extended_lock_time_indicator(unsigned int lock_time_period_s); + uint32_t lock_time_indicator(uint32_t lock_time_period_s); + uint32_t msm_lock_time_indicator(uint32_t lock_time_period_s); + uint32_t msm_extended_lock_time_indicator(uint32_t lock_time_period_s); // // Classes for TCP communication // - unsigned short RTCM_port; - //unsigned short RTCM_Station_ID; + uint16_t RTCM_port; + //uint16_t RTCM_Station_ID; class Rtcm_Message { public: @@ -552,7 +553,9 @@ private: { body_length_ = new_length; if (body_length_ > max_body_length) - body_length_ = max_body_length; + { + body_length_ = max_body_length; + } } inline bool decode_header() @@ -593,10 +596,10 @@ private: }; - class Rtcm_Listener + class RtcmListener { public: - virtual ~Rtcm_Listener() {} + virtual ~RtcmListener() = default; virtual void deliver(const Rtcm_Message& msg) = 0; }; @@ -604,14 +607,16 @@ private: class Rtcm_Listener_Room { public: - inline void join(std::shared_ptr participant) + inline void join(const std::shared_ptr& participant) { participants_.insert(participant); for (auto msg : recent_msgs_) - participant->deliver(msg); + { + participant->deliver(msg); + } } - inline void leave(std::shared_ptr participant) + inline void leave(const std::shared_ptr& participant) { participants_.erase(participant); } @@ -620,14 +625,18 @@ private: { recent_msgs_.push_back(msg); while (recent_msgs_.size() > max_recent_msgs) - recent_msgs_.pop_front(); + { + recent_msgs_.pop_front(); + } - for (auto participant : participants_) - participant->deliver(msg); + for (const auto& participant : participants_) + { + participant->deliver(msg); + } } private: - std::set > participants_; + std::set > participants_; enum { max_recent_msgs = 1 @@ -637,7 +646,7 @@ private: class Rtcm_Session - : public Rtcm_Listener, + : public RtcmListener, public std::enable_shared_from_this { public: @@ -677,10 +686,10 @@ private: { if (first == true) { - std::cout << "Client from " << socket_.remote_endpoint().address() << " says "; + LOG(INFO) << "Client says:"; first = false; } - std::cout << client_says.substr(0, 80) << std::endl; + LOG(INFO) << client_says; client_says = client_says.substr(80, client_says.length() - 80); } do_read_message_header(); @@ -749,21 +758,21 @@ private: : public std::enable_shared_from_this { public: - Tcp_Internal_Client(boost::asio::io_service& io_service, + Tcp_Internal_Client(boost::asio::io_service& io_context, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) - : io_service_(io_service), socket_(io_service) + : io_context_(io_context), socket_(io_context) { - do_connect(endpoint_iterator); + do_connect(std::move(endpoint_iterator)); } inline void close() { - io_service_.post([this]() { socket_.close(); }); + io_context_.post([this]() { socket_.close(); }); } inline void write(const Rtcm_Message& msg) { - io_service_.post( + io_context_.post( [this, msg]() { bool write_in_progress = !write_msgs_.empty(); write_msgs_.push_back(msg); @@ -777,7 +786,7 @@ private: private: inline void do_connect(boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { - boost::asio::async_connect(socket_, endpoint_iterator, + boost::asio::async_connect(socket_, std::move(endpoint_iterator), [this](boost::system::error_code ec, boost::asio::ip::tcp::resolver::iterator) { if (!ec) { @@ -827,7 +836,7 @@ private: }); } - boost::asio::io_service& io_service_; + boost::asio::io_service& io_context_; boost::asio::ip::tcp::socket socket_; Rtcm_Message read_msg_; std::deque write_msgs_; @@ -837,13 +846,13 @@ private: class Queue_Reader { public: - Queue_Reader(boost::asio::io_service& io_service, std::shared_ptr >& queue, int port) : queue_(queue) + Queue_Reader(boost::asio::io_service& io_context, std::shared_ptr >& queue, int32_t port) : queue_(queue) { - boost::asio::ip::tcp::resolver resolver(io_service); + boost::asio::ip::tcp::resolver resolver(io_context); std::string host("localhost"); std::string port_str = std::to_string(port); auto queue_endpoint_iterator = resolver.resolve({host.c_str(), port_str.c_str()}); - c = std::make_shared(io_service, queue_endpoint_iterator); + c = std::make_shared(io_context, queue_endpoint_iterator); } inline void do_read_queue() @@ -853,7 +862,11 @@ private: std::string message; Rtcm_Message msg; queue_->wait_and_pop(message); //message += '\n'; - if (message.compare("Goodbye") == 0) break; + if (message == "Goodbye") + { + break; + } + const char* char_msg = message.c_str(); msg.body_length(message.length()); std::memcpy(msg.body(), char_msg, msg.body_length()); @@ -864,15 +877,15 @@ private: private: std::shared_ptr c; - std::shared_ptr >& queue_; + std::shared_ptr >& queue_; }; class Tcp_Server { public: - Tcp_Server(boost::asio::io_service& io_service, const boost::asio::ip::tcp::endpoint& endpoint) - : io_service_(io_service), acceptor_(io_service), socket_(io_service) + Tcp_Server(boost::asio::io_service& io_context, const boost::asio::ip::tcp::endpoint& endpoint) + : acceptor_(io_context), socket_(io_context) { acceptor_.open(endpoint.protocol()); acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); @@ -895,34 +908,51 @@ private: { if (first_client) { - std::cout << "The TCP Server is up and running. Accepting connections ..." << std::endl; + std::cout << "The TCP/IP server of RTCM messages is up and running. Accepting connections ..." << std::endl; first_client = false; } else { - std::cout << "Starting RTCM TCP server session..." << std::endl; - std::cout << "Serving client from " << socket_.remote_endpoint().address() << std::endl; - LOG(INFO) << "Serving client from " << socket_.remote_endpoint().address(); + std::cout << "Starting RTCM TCP/IP server session..." << std::endl; + boost::system::error_code ec2; + boost::asio::ip::tcp::endpoint endpoint = socket_.remote_endpoint(ec2); + if (ec2) + { + // Error creating remote_endpoint + std::cout << "Error getting remote IP address, closing session." << std::endl; + LOG(INFO) << "Error getting remote IP address"; + start_session = false; + } + else + { + std::string remote_addr = endpoint.address().to_string(); + std::cout << "Serving client from " << remote_addr << std::endl; + LOG(INFO) << "Serving client from " << remote_addr; + } + } + if (start_session) + { + std::make_shared(std::move(socket_), room_)->start(); } - std::make_shared(std::move(socket_), room_)->start(); } else { std::cout << "Error when invoking a RTCM session. " << ec << std::endl; } + start_session = true; do_accept(); }); } - boost::asio::io_service& io_service_; boost::asio::ip::tcp::acceptor acceptor_; boost::asio::ip::tcp::socket socket_; Rtcm_Listener_Room room_; bool first_client = true; + bool start_session = true; }; - boost::asio::io_service io_service; - std::shared_ptr > rtcm_message_queue; + boost::asio::io_service io_context; + std::shared_ptr > rtcm_message_queue; std::thread t; std::thread tq; std::list servers; @@ -941,88 +971,88 @@ private: // Data Fields // std::bitset<12> DF002; - int set_DF002(unsigned int message_number); + int32_t set_DF002(uint32_t message_number); std::bitset<12> DF003; - int set_DF003(unsigned int ref_station_ID); + int32_t set_DF003(uint32_t ref_station_ID); std::bitset<30> DF004; - int set_DF004(double obs_time); + int32_t set_DF004(double obs_time); std::bitset<1> DF005; - int set_DF005(bool sync_flag); + int32_t set_DF005(bool sync_flag); std::bitset<5> DF006; - int set_DF006(const std::map& observables); + int32_t set_DF006(const std::map& observables); std::bitset<1> DF007; - int set_DF007(bool divergence_free_smoothing_indicator); // 0 - Divergence-free smoothing not used 1 - Divergence-free smoothing used + int32_t set_DF007(bool divergence_free_smoothing_indicator); // 0 - Divergence-free smoothing not used 1 - Divergence-free smoothing used std::bitset<3> DF008; - int set_DF008(short int smoothing_interval); + int32_t set_DF008(int16_t smoothing_interval); std::bitset<6> DF009; - int set_DF009(const Gnss_Synchro& gnss_synchro); - int set_DF009(const Gps_Ephemeris& gps_eph); + int32_t set_DF009(const Gnss_Synchro& gnss_synchro); + int32_t set_DF009(const Gps_Ephemeris& gps_eph); std::bitset<1> DF010; - int set_DF010(bool code_indicator); + int32_t set_DF010(bool code_indicator); std::bitset<24> DF011; - int set_DF011(const Gnss_Synchro& gnss_synchro); + int32_t set_DF011(const Gnss_Synchro& gnss_synchro); std::bitset<20> DF012; - int set_DF012(const Gnss_Synchro& gnss_synchro); + int32_t set_DF012(const Gnss_Synchro& gnss_synchro); std::bitset<7> DF013; - int set_DF013(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); + int32_t set_DF013(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); std::bitset<8> DF014; - int set_DF014(const Gnss_Synchro& gnss_synchro); + int32_t set_DF014(const Gnss_Synchro& gnss_synchro); std::bitset<8> DF015; - int set_DF015(const Gnss_Synchro& gnss_synchro); + int32_t set_DF015(const Gnss_Synchro& gnss_synchro); std::bitset<14> DF017; - int set_DF017(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); + int32_t set_DF017(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); std::bitset<20> DF018; - int set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); + int32_t set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); std::bitset<7> DF019; - int set_DF019(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); + int32_t set_DF019(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); std::bitset<8> DF020; - int set_DF020(const Gnss_Synchro& gnss_synchro); + int32_t set_DF020(const Gnss_Synchro& gnss_synchro); std::bitset<6> DF021; - int set_DF021(); + int32_t set_DF021(); std::bitset<1> DF022; - int set_DF022(bool gps_indicator); + int32_t set_DF022(bool gps_indicator); std::bitset<1> DF023; - int set_DF023(bool glonass_indicator); + int32_t set_DF023(bool glonass_indicator); std::bitset<1> DF024; - int set_DF024(bool galileo_indicator); + int32_t set_DF024(bool galileo_indicator); std::bitset<38> DF025; - int set_DF025(double antenna_ECEF_X_m); + int32_t set_DF025(double antenna_ECEF_X_m); std::bitset<38> DF026; - int set_DF026(double antenna_ECEF_Y_m); + int32_t set_DF026(double antenna_ECEF_Y_m); std::bitset<38> DF027; - int set_DF027(double antenna_ECEF_Z_m); + int32_t set_DF027(double antenna_ECEF_Z_m); std::bitset<16> DF028; - int set_DF028(double height); + int32_t set_DF028(double height); std::bitset<8> DF029; std::bitset<8> DF031; - int set_DF031(unsigned int antenna_setup_id); + int32_t set_DF031(uint32_t antenna_setup_id); std::bitset<8> DF032; @@ -1032,417 +1062,417 @@ private: * \param obs_time Time of observation at the moment of printing * \return returns 0 upon success */ - int set_DF034(double obs_time); + int32_t set_DF034(double obs_time); std::bitset<27> DF034; //!< GLONASS Epoch Time (tk) std::bitset<5> DF035; //!< No. of GLONASS Satellite Signals Processed - int set_DF035(const std::map& observables); + int32_t set_DF035(const std::map& observables); std::bitset<1> DF036; //!< GLONASS Divergence-free Smoothing Indicator - int set_DF036(bool divergence_free_smoothing_indicator); + int32_t set_DF036(bool divergence_free_smoothing_indicator); std::bitset<3> DF037; //!< GLONASS Smoothing Interval - int set_DF037(short int smoothing_interval); + int32_t set_DF037(int16_t smoothing_interval); std::bitset<6> DF038; //!< GLONASS Satellite ID (Satellite Slot Number) - int set_DF038(const Gnss_Synchro& gnss_synchro); - int set_DF038(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF038(const Gnss_Synchro& gnss_synchro); + int32_t set_DF038(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF039; //!< GLONASS L1 Code Indicator - int set_DF039(bool code_indicator); + int32_t set_DF039(bool code_indicator); std::bitset<5> DF040; //!< GLONASS Satellite Frequency Number - int set_DF040(int frequency_channel_number); - int set_DF040(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF040(int32_t frequency_channel_number); + int32_t set_DF040(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<25> DF041; //!< GLONASS L1 Pseudorange - int set_DF041(const Gnss_Synchro& gnss_synchro); + int32_t set_DF041(const Gnss_Synchro& gnss_synchro); std::bitset<20> DF042; //!< GLONASS L1 PhaseRange - L1 Pseudorange - int set_DF042(const Gnss_Synchro& gnss_synchro); + int32_t set_DF042(const Gnss_Synchro& gnss_synchro); std::bitset<7> DF043; //!< GLONASS L1 Lock Time Indicator - int set_DF043(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); + int32_t set_DF043(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); std::bitset<7> DF044; //!< GLONASS Integer L1 Pseudorange Modulus Ambiguity - int set_DF044(const Gnss_Synchro& gnss_synchro); + int32_t set_DF044(const Gnss_Synchro& gnss_synchro); std::bitset<8> DF045; //!< GLONASS L1 CNR - int set_DF045(const Gnss_Synchro& gnss_synchro); + int32_t set_DF045(const Gnss_Synchro& gnss_synchro); std::bitset<2> DF046; //!< GLONASS L2 code indicator - int set_DF046(unsigned short code_indicator); + int32_t set_DF046(uint16_t code_indicator); std::bitset<14> DF047; //!< GLONASS L2 - L1 Pseudorange Difference - int set_DF047(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); + int32_t set_DF047(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); std::bitset<20> DF048; //!< GLONASS L2 PhaseRange - L1 Pseudorange - int set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); + int32_t set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2); std::bitset<7> DF049; //!< GLONASS L2 Lock Time Indicator - int set_DF049(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); + int32_t set_DF049(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); std::bitset<8> DF050; //!< GLONASS L2 CNR - int set_DF050(const Gnss_Synchro& gnss_synchro); + int32_t set_DF050(const Gnss_Synchro& gnss_synchro); std::bitset<16> DF051; - int set_DF051(const Gps_Ephemeris& gps_eph, double obs_time); + int32_t set_DF051(const Gps_Ephemeris& gps_eph, double obs_time); std::bitset<17> DF052; - int set_DF052(const Gps_Ephemeris& gps_eph, double obs_time); + int32_t set_DF052(const Gps_Ephemeris& gps_eph, double obs_time); // Contents of GPS Satellite Ephemeris Data, Message Type 1019 std::bitset<8> DF071; - int set_DF071(const Gps_Ephemeris& gps_eph); + int32_t set_DF071(const Gps_Ephemeris& gps_eph); std::bitset<10> DF076; - int set_DF076(const Gps_Ephemeris& gps_eph); + int32_t set_DF076(const Gps_Ephemeris& gps_eph); std::bitset<4> DF077; - int set_DF077(const Gps_Ephemeris& gps_eph); + int32_t set_DF077(const Gps_Ephemeris& gps_eph); std::bitset<2> DF078; - int set_DF078(const Gps_Ephemeris& gps_eph); + int32_t set_DF078(const Gps_Ephemeris& gps_eph); std::bitset<14> DF079; - int set_DF079(const Gps_Ephemeris& gps_eph); + int32_t set_DF079(const Gps_Ephemeris& gps_eph); std::bitset<8> DF080; - int set_DF080(const Gps_Ephemeris& gps_eph); + int32_t set_DF080(const Gps_Ephemeris& gps_eph); std::bitset<16> DF081; - int set_DF081(const Gps_Ephemeris& gps_eph); + int32_t set_DF081(const Gps_Ephemeris& gps_eph); std::bitset<8> DF082; - int set_DF082(const Gps_Ephemeris& gps_eph); + int32_t set_DF082(const Gps_Ephemeris& gps_eph); std::bitset<16> DF083; - int set_DF083(const Gps_Ephemeris& gps_eph); + int32_t set_DF083(const Gps_Ephemeris& gps_eph); std::bitset<22> DF084; - int set_DF084(const Gps_Ephemeris& gps_eph); + int32_t set_DF084(const Gps_Ephemeris& gps_eph); std::bitset<10> DF085; - int set_DF085(const Gps_Ephemeris& gps_eph); + int32_t set_DF085(const Gps_Ephemeris& gps_eph); std::bitset<16> DF086; - int set_DF086(const Gps_Ephemeris& gps_eph); + int32_t set_DF086(const Gps_Ephemeris& gps_eph); std::bitset<16> DF087; - int set_DF087(const Gps_Ephemeris& gps_eph); + int32_t set_DF087(const Gps_Ephemeris& gps_eph); std::bitset<32> DF088; - int set_DF088(const Gps_Ephemeris& gps_eph); + int32_t set_DF088(const Gps_Ephemeris& gps_eph); std::bitset<16> DF089; - int set_DF089(const Gps_Ephemeris& gps_eph); + int32_t set_DF089(const Gps_Ephemeris& gps_eph); std::bitset<32> DF090; - int set_DF090(const Gps_Ephemeris& gps_eph); + int32_t set_DF090(const Gps_Ephemeris& gps_eph); std::bitset<16> DF091; - int set_DF091(const Gps_Ephemeris& gps_eph); + int32_t set_DF091(const Gps_Ephemeris& gps_eph); std::bitset<32> DF092; - int set_DF092(const Gps_Ephemeris& gps_eph); + int32_t set_DF092(const Gps_Ephemeris& gps_eph); std::bitset<16> DF093; - int set_DF093(const Gps_Ephemeris& gps_eph); + int32_t set_DF093(const Gps_Ephemeris& gps_eph); std::bitset<16> DF094; - int set_DF094(const Gps_Ephemeris& gps_eph); + int32_t set_DF094(const Gps_Ephemeris& gps_eph); std::bitset<32> DF095; - int set_DF095(const Gps_Ephemeris& gps_eph); + int32_t set_DF095(const Gps_Ephemeris& gps_eph); std::bitset<16> DF096; - int set_DF096(const Gps_Ephemeris& gps_eph); + int32_t set_DF096(const Gps_Ephemeris& gps_eph); std::bitset<32> DF097; - int set_DF097(const Gps_Ephemeris& gps_eph); + int32_t set_DF097(const Gps_Ephemeris& gps_eph); std::bitset<16> DF098; - int set_DF098(const Gps_Ephemeris& gps_eph); + int32_t set_DF098(const Gps_Ephemeris& gps_eph); std::bitset<32> DF099; - int set_DF099(const Gps_Ephemeris& gps_eph); + int32_t set_DF099(const Gps_Ephemeris& gps_eph); std::bitset<24> DF100; - int set_DF100(const Gps_Ephemeris& gps_eph); + int32_t set_DF100(const Gps_Ephemeris& gps_eph); std::bitset<8> DF101; - int set_DF101(const Gps_Ephemeris& gps_eph); + int32_t set_DF101(const Gps_Ephemeris& gps_eph); std::bitset<6> DF102; - int set_DF102(const Gps_Ephemeris& gps_eph); + int32_t set_DF102(const Gps_Ephemeris& gps_eph); std::bitset<1> DF103; - int set_DF103(const Gps_Ephemeris& gps_eph); + int32_t set_DF103(const Gps_Ephemeris& gps_eph); std::bitset<1> DF104; //!< GLONASS Almanac Health - int set_DF104(unsigned int glonass_gnav_alm_health); + int32_t set_DF104(uint32_t glonass_gnav_alm_health); std::bitset<1> DF105; //!< GLONASS Almanac Health Availability Indicator - int set_DF105(unsigned int glonass_gnav_alm_health_ind); + int32_t set_DF105(uint32_t glonass_gnav_alm_health_ind); std::bitset<2> DF106; //!< GLONASS P1 Word - int set_DF106(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF106(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<12> DF107; //!< GLONASS Epoch (tk) - int set_DF107(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF107(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF108; //!< GLONASS MSB of Bn Word - int set_DF108(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF108(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF109; //!< GLONASS P2 Word - int set_DF109(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF109(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<7> DF110; //!< GLONASS Ephmeris Epoch (tb) - int set_DF110(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF110(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<24> DF111; //!< GLONASS Xn first derivative - int set_DF111(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF111(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<27> DF112; //!< GLONASS Xn - int set_DF112(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF112(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<5> DF113; //!< GLONASS Xn second derivative - int set_DF113(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF113(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<24> DF114; //!< GLONASS Yn first derivative - int set_DF114(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF114(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<27> DF115; //!< GLONASS Yn - int set_DF115(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF115(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<5> DF116; //!< GLONASS Yn second derivative - int set_DF116(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF116(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<24> DF117; //!< GLONASS Zn first derivative - int set_DF117(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF117(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<27> DF118; //!< GLONASS Zn - int set_DF118(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF118(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<5> DF119; //!< GLONASS Zn second derivative - int set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF120; //!< GLONASS P3 - int set_DF120(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF120(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<11> DF121; //!< GLONASS GAMMA_N - int set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<2> DF122; //!< GLONASS P - int set_DF122(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF122(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF123; //!< GLONASS ln (third string) - int set_DF123(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF123(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<22> DF124; //!< GLONASS TAU_N - int set_DF124(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF124(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<5> DF125; //!< GLONASS DELTA_TAU_N - int set_DF125(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF125(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<5> DF126; //!< GLONASS Eccentricity - int set_DF126(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF126(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF127; //!< GLONASS P4 - int set_DF127(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF127(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<4> DF128; //!< GLONASS F_T - int set_DF128(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF128(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<11> DF129; //!< GLONASS N_T - int set_DF129(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF129(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<2> DF130; //!< GLONASS M - int set_DF130(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF130(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF131; //!< GLONASS Availability of additional data - int set_DF131(unsigned int fifth_str_additional_data_ind); + int32_t set_DF131(uint32_t fifth_str_additional_data_ind); std::bitset<11> DF132; //!< GLONASS N_A - int set_DF132(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); + int32_t set_DF132(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); std::bitset<32> DF133; //!< GLONASS TAU_C - int set_DF133(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); + int32_t set_DF133(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); std::bitset<5> DF134; //!< GLONASS N_4 - int set_DF134(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); + int32_t set_DF134(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); std::bitset<22> DF135; //!< GLONASS TAU_GPS - int set_DF135(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); + int32_t set_DF135(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model); std::bitset<1> DF136; //!< GLONASS L_N (FIFTH STRING) - int set_DF136(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); + int32_t set_DF136(const Glonass_Gnav_Ephemeris& glonass_gnav_eph); std::bitset<1> DF137; - int set_DF137(const Gps_Ephemeris& gps_eph); + int32_t set_DF137(const Gps_Ephemeris& gps_eph); std::bitset<1> DF141; - int set_DF141(const Gps_Ephemeris& gps_eph); + int32_t set_DF141(const Gps_Ephemeris& gps_eph); std::bitset<1> DF142; - int set_DF142(const Gps_Ephemeris& gps_eph); + int32_t set_DF142(const Gps_Ephemeris& gps_eph); std::bitset<30> DF248; - int set_DF248(double obs_time); + int32_t set_DF248(double obs_time); // Contents of Galileo F/NAV Satellite Ephemeris Data, Message Type 1045 std::bitset<6> DF252; - int set_DF252(const Galileo_Ephemeris& gal_eph); + int32_t set_DF252(const Galileo_Ephemeris& gal_eph); std::bitset<12> DF289; - int set_DF289(const Galileo_Ephemeris& gal_eph); + int32_t set_DF289(const Galileo_Ephemeris& gal_eph); std::bitset<10> DF290; - int set_DF290(const Galileo_Ephemeris& gal_eph); + int32_t set_DF290(const Galileo_Ephemeris& gal_eph); std::bitset<8> DF291; - int set_DF291(const Galileo_Ephemeris& gal_eph); + int32_t set_DF291(const Galileo_Ephemeris& gal_eph); std::bitset<14> DF292; - int set_DF292(const Galileo_Ephemeris& gal_eph); + int32_t set_DF292(const Galileo_Ephemeris& gal_eph); std::bitset<14> DF293; - int set_DF293(const Galileo_Ephemeris& gal_eph); + int32_t set_DF293(const Galileo_Ephemeris& gal_eph); std::bitset<6> DF294; - int set_DF294(const Galileo_Ephemeris& gal_eph); + int32_t set_DF294(const Galileo_Ephemeris& gal_eph); std::bitset<21> DF295; - int set_DF295(const Galileo_Ephemeris& gal_eph); + int32_t set_DF295(const Galileo_Ephemeris& gal_eph); std::bitset<31> DF296; - int set_DF296(const Galileo_Ephemeris& gal_eph); + int32_t set_DF296(const Galileo_Ephemeris& gal_eph); std::bitset<16> DF297; - int set_DF297(const Galileo_Ephemeris& gal_eph); + int32_t set_DF297(const Galileo_Ephemeris& gal_eph); std::bitset<16> DF298; - int set_DF298(const Galileo_Ephemeris& gal_eph); + int32_t set_DF298(const Galileo_Ephemeris& gal_eph); std::bitset<32> DF299; - int set_DF299(const Galileo_Ephemeris& gal_eph); + int32_t set_DF299(const Galileo_Ephemeris& gal_eph); std::bitset<16> DF300; - int set_DF300(const Galileo_Ephemeris& gal_eph); + int32_t set_DF300(const Galileo_Ephemeris& gal_eph); std::bitset<32> DF301; - int set_DF301(const Galileo_Ephemeris& gal_eph); + int32_t set_DF301(const Galileo_Ephemeris& gal_eph); std::bitset<16> DF302; - int set_DF302(const Galileo_Ephemeris& gal_eph); + int32_t set_DF302(const Galileo_Ephemeris& gal_eph); std::bitset<32> DF303; - int set_DF303(const Galileo_Ephemeris& gal_eph); + int32_t set_DF303(const Galileo_Ephemeris& gal_eph); std::bitset<14> DF304; - int set_DF304(const Galileo_Ephemeris& gal_eph); + int32_t set_DF304(const Galileo_Ephemeris& gal_eph); std::bitset<16> DF305; - int set_DF305(const Galileo_Ephemeris& gal_eph); + int32_t set_DF305(const Galileo_Ephemeris& gal_eph); std::bitset<32> DF306; - int set_DF306(const Galileo_Ephemeris& gal_eph); + int32_t set_DF306(const Galileo_Ephemeris& gal_eph); std::bitset<16> DF307; - int set_DF307(const Galileo_Ephemeris& gal_eph); + int32_t set_DF307(const Galileo_Ephemeris& gal_eph); std::bitset<32> DF308; - int set_DF308(const Galileo_Ephemeris& gal_eph); + int32_t set_DF308(const Galileo_Ephemeris& gal_eph); std::bitset<16> DF309; - int set_DF309(const Galileo_Ephemeris& gal_eph); + int32_t set_DF309(const Galileo_Ephemeris& gal_eph); std::bitset<32> DF310; - int set_DF310(const Galileo_Ephemeris& gal_eph); + int32_t set_DF310(const Galileo_Ephemeris& gal_eph); std::bitset<24> DF311; - int set_DF311(const Galileo_Ephemeris& gal_eph); + int32_t set_DF311(const Galileo_Ephemeris& gal_eph); std::bitset<10> DF312; - int set_DF312(const Galileo_Ephemeris& gal_eph); + int32_t set_DF312(const Galileo_Ephemeris& gal_eph); std::bitset<10> DF313; - int set_DF313(const Galileo_Ephemeris& gal_eph); + int32_t set_DF313(const Galileo_Ephemeris& gal_eph); std::bitset<2> DF314; - int set_DF314(const Galileo_Ephemeris& gal_eph); + int32_t set_DF314(const Galileo_Ephemeris& gal_eph); std::bitset<1> DF315; - int set_DF315(const Galileo_Ephemeris& gal_eph); + int32_t set_DF315(const Galileo_Ephemeris& gal_eph); std::bitset<2> DF364; // Content of message header for MSM1, MSM2, MSM3, MSM4, MSM5, MSM6 and MSM7 std::bitset<1> DF393; - int set_DF393(bool more_messages); //1 indicates that more MSMs follow for given physical time and reference station ID + int32_t set_DF393(bool more_messages); //1 indicates that more MSMs follow for given physical time and reference station ID std::bitset<64> DF394; - int set_DF394(const std::map& observables); + int32_t set_DF394(const std::map& gnss_synchro); std::bitset<32> DF395; - int set_DF395(const std::map& observables); + int32_t set_DF395(const std::map& gnss_synchro); - std::string set_DF396(const std::map& observables); + std::string set_DF396(const std::map& observables); std::bitset<8> DF397; - int set_DF397(const Gnss_Synchro& gnss_synchro); + int32_t set_DF397(const Gnss_Synchro& gnss_synchro); std::bitset<10> DF398; - int set_DF398(const Gnss_Synchro& gnss_synchro); + int32_t set_DF398(const Gnss_Synchro& gnss_synchro); std::bitset<14> DF399; - int set_DF399(const Gnss_Synchro& gnss_synchro); + int32_t set_DF399(const Gnss_Synchro& gnss_synchro); std::bitset<15> DF400; - int set_DF400(const Gnss_Synchro& gnss_synchro); + int32_t set_DF400(const Gnss_Synchro& gnss_synchro); std::bitset<22> DF401; - int set_DF401(const Gnss_Synchro& gnss_synchro); + int32_t set_DF401(const Gnss_Synchro& gnss_synchro); std::bitset<4> DF402; - int set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro); + int32_t set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro); std::bitset<6> DF403; - int set_DF403(const Gnss_Synchro& gnss_synchro); + int32_t set_DF403(const Gnss_Synchro& gnss_synchro); std::bitset<15> DF404; - int set_DF404(const Gnss_Synchro& gnss_synchro); + int32_t set_DF404(const Gnss_Synchro& gnss_synchro); std::bitset<20> DF405; - int set_DF405(const Gnss_Synchro& gnss_synchro); + int32_t set_DF405(const Gnss_Synchro& gnss_synchro); std::bitset<24> DF406; - int set_DF406(const Gnss_Synchro& gnss_synchro); + int32_t set_DF406(const Gnss_Synchro& gnss_synchro); std::bitset<10> DF407; - int set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro); + int32_t set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro); std::bitset<10> DF408; - int set_DF408(const Gnss_Synchro& gnss_synchro); + int32_t set_DF408(const Gnss_Synchro& gnss_synchro); std::bitset<3> DF409; - int set_DF409(unsigned int iods); + int32_t set_DF409(uint32_t iods); std::bitset<2> DF411; - int set_DF411(unsigned int clock_steering_indicator); + int32_t set_DF411(uint32_t clock_steering_indicator); std::bitset<2> DF412; - int set_DF412(unsigned int external_clock_indicator); + int32_t set_DF412(uint32_t external_clock_indicator); std::bitset<1> DF417; - int set_DF417(bool using_divergence_free_smoothing); + int32_t set_DF417(bool using_divergence_free_smoothing); std::bitset<3> DF418; - int set_DF418(int carrier_smoothing_interval_s); + int32_t set_DF418(int32_t carrier_smoothing_interval_s); std::bitset<1> DF420; - int set_DF420(const Gnss_Synchro& gnss_synchro); + int32_t set_DF420(const Gnss_Synchro& gnss_synchro); }; #endif diff --git a/src/algorithms/libs/rtklib/CMakeLists.txt b/src/algorithms/libs/rtklib/CMakeLists.txt index 6cb2441a9..6a85ff21b 100644 --- a/src/algorithms/libs/rtklib/CMakeLists.txt +++ b/src/algorithms/libs/rtklib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,54 +16,70 @@ # along with GNSS-SDR. If not, see . # -add_definitions( -DGNSS_SDR_VERSION="${VERSION}" ) set(RTKLIB_LIB_SOURCES - rtklib_rtkcmn.cc - rtklib_ephemeris.cc - rtklib_preceph.cc - rtklib_sbas.cc - rtklib_ionex.cc - rtklib_pntpos.cc - rtklib_ppp.cc - rtklib_tides.cc - rtklib_lambda.cc - rtklib_rtkpos.cc - rtklib_conversions.cc - rtklib_stream.cc - rtklib_rtksvr.cc - rtklib_solution.cc - rtklib_rtcm.cc - rtklib_rtcm2.cc - rtklib_rtcm3.cc + rtklib_rtkcmn.cc + rtklib_ephemeris.cc + rtklib_preceph.cc + rtklib_sbas.cc + rtklib_ionex.cc + rtklib_pntpos.cc + rtklib_ppp.cc + rtklib_tides.cc + rtklib_lambda.cc + rtklib_rtkpos.cc + rtklib_conversions.cc + rtklib_stream.cc + rtklib_rtksvr.cc + rtklib_solution.cc + rtklib_rtcm.cc + rtklib_rtcm2.cc + rtklib_rtcm3.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${Boost_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} +set(RTKLIB_LIB_HEADERS + rtklib_rtkcmn.h + rtklib_ephemeris.h + rtklib_preceph.h + rtklib_sbas.h + rtklib_ionex.h + rtklib_pntpos.h + rtklib_ppp.h + rtklib_tides.h + rtklib_lambda.h + rtklib_rtkpos.h + rtklib_conversions.h + rtklib_stream.h + rtklib_rtksvr.h + rtklib_solution.h + rtklib_rtcm.h + rtklib_rtcm2.h + rtklib_rtcm3.h + rtklib.h ) -file(GLOB RTKLIB_LIB_HEADERS "*.h") list(SORT RTKLIB_LIB_HEADERS) -add_library(rtklib_lib ${RTKLIB_LIB_SOURCES} ${RTKLIB_LIB_HEADERS}) +list(SORT RTKLIB_LIB_SOURCES) + source_group(Headers FILES ${RTKLIB_LIB_HEADERS}) -add_dependencies(rtklib_lib glog-${glog_RELEASE}) + +add_library(algorithms_libs_rtklib ${RTKLIB_LIB_SOURCES} ${RTKLIB_LIB_HEADERS}) + +target_link_libraries(algorithms_libs_rtklib + PUBLIC + core_system_parameters + PRIVATE + Gflags::gflags + Glog::glog +) if(OS_IS_MACOSX) - set(MAC_LIBRARIES "-framework Accelerate") -endif(OS_IS_MACOSX) + target_link_libraries(algorithms_libs_rtklib PRIVATE "-framework Accelerate") +else() + target_link_libraries(algorithms_libs_rtklib PRIVATE ${LAPACK} ${BLAS}) +endif() -target_link_libraries( - rtklib_lib - ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${BLAS} - ${LAPACK} - ${MAC_LIBRARIES} +set_property(TARGET algorithms_libs_rtklib + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ ) diff --git a/src/algorithms/libs/rtklib/rtklib.h b/src/algorithms/libs/rtklib/rtklib.h index 88e8969e1..f4305a75a 100644 --- a/src/algorithms/libs/rtklib/rtklib.h +++ b/src/algorithms/libs/rtklib/rtklib.h @@ -56,13 +56,13 @@ #include "MATH_CONSTANTS.h" #include "gnss_frequencies.h" #include "gnss_obs_codes.h" -#include -#include #include #include #include -#include +#include #include +#include +#include /* macros --------------------------------------------------------------------*/ @@ -71,7 +71,6 @@ #define socket_t int #define closesocket close #define lock_t pthread_mutex_t -#define thread_t pthread_t #define initlock(f) pthread_mutex_init(f, NULL) #define rtk_lock(f) pthread_mutex_lock(f) #define rtk_unlock(f) pthread_mutex_unlock(f) @@ -201,7 +200,7 @@ const int NSATGLO = (MAXPRNGLO - MINPRNGLO + 1); //!< number of GLONASS satell const int NSYSGLO = 1; */ const int MINPRNGAL = 1; //!< min satellite PRN number of Galileo -const int MAXPRNGAL = 30; //!< max satellite PRN number of Galileo +const int MAXPRNGAL = 36; //!< max satellite PRN number of Galileo const int NSATGAL = (MAXPRNGAL - MINPRNGAL + 1); //!< number of Galileo satellites const int NSYSGAL = 1; @@ -221,10 +220,13 @@ const int NSATQZS = 0; const int NSYSQZS = 0; #endif +#ifndef __APPLE__ +#define ENABDS +#endif #ifdef ENABDS -const int MINPRNBDS = 1; //!< min satellite sat number of BeiDou -const int MAXPRNBDS = 35; //!< max satellite sat number of BeiDou -const int NSATBDS = (MAXPRNBDS - MINPRNCM + 1); //!< number of BeiDou satellites +const int MINPRNBDS = 1; //!< min satellite sat number of BeiDou +const int MAXPRNBDS = 37; //!< max satellite sat number of BeiDou +const int NSATBDS = (MAXPRNBDS - MINPRNBDS + 1); //!< number of BeiDou satellites const int NSYSBDS = 1; #else const int MINPRNBDS = 0; @@ -342,7 +344,7 @@ const int POSOPT_RINEX = 3; //!< pos option: rinex header pos const int MAXSTRPATH = 1024; //!< max length of stream path const int MAXSTRMSG = 1024; //!< max length of stream message -typedef void fatalfunc_t(const char *); //!< fatal callback function type +using fatalfunc_t = void(const char *); //!< fatal callback function type #define STR_MODE_R 0x1 /* stream mode: read */ #define STR_MODE_W 0x2 /* stream mode: write */ @@ -452,27 +454,28 @@ typedef struct } alm_t; -typedef struct { /* GPS/QZS/GAL broadcast ephemeris type */ - int sat; /* satellite number */ - int iode,iodc; /* IODE,IODC */ - int sva; /* SV accuracy (URA index) */ - int svh; /* SV health (0:ok) */ - int week; /* GPS/QZS: gps week, GAL: galileo week */ - int code; /* GPS/QZS: code on L2, GAL/BDS: data sources */ - int flag; /* GPS/QZS: L2 P data flag, BDS: nav type */ - gtime_t toe,toc,ttr; /* Toe,Toc,T_trans */ - /* SV orbit parameters */ - double A,e,i0,OMG0,omg,M0,deln,OMGd,idot; - double crc,crs,cuc,cus,cic,cis; - double toes; /* Toe (s) in week */ - double fit; /* fit interval (h) */ - double f0,f1,f2; /* SV clock parameters (af0,af1,af2) */ - double tgd[4]; /* group delay parameters */ - /* GPS/QZS:tgd[0]=TGD */ - /* GAL :tgd[0]=BGD E5a/E1,tgd[1]=BGD E5b/E1 */ - /* BDS :tgd[0]=BGD1,tgd[1]=BGD2 */ - double isc[4]; /* GPS :isc[0]=ISCL1, isc[1]=ISCL2, isc[2]=ISCL5I, isc[3]=ISCL5Q */ - double Adot,ndot; /* Adot,ndot for CNAV */ +typedef struct +{ /* GPS/QZS/GAL broadcast ephemeris type */ + int sat; /* satellite number */ + int iode, iodc; /* IODE,IODC */ + int sva; /* SV accuracy (URA index) */ + int svh; /* SV health (0:ok) */ + int week; /* GPS/QZS: gps week, GAL: galileo week */ + int code; /* GPS/QZS: code on L2, GAL/BDS: data sources */ + int flag; /* GPS/QZS: L2 P data flag, BDS: nav type */ + gtime_t toe, toc, ttr; /* Toe,Toc,T_trans */ + /* SV orbit parameters */ + double A, e, i0, OMG0, omg, M0, deln, OMGd, idot; + double crc, crs, cuc, cus, cic, cis; + double toes; /* Toe (s) in week */ + double fit; /* fit interval (h) */ + double f0, f1, f2; /* SV clock parameters (af0,af1,af2) */ + double tgd[4]; /* group delay parameters */ + /* GPS/QZS:tgd[0]=TGD */ + /* GAL :tgd[0]=BGD E5a/E1,tgd[1]=BGD E5b/E1 */ + /* BDS :tgd[0]=BGD1,tgd[1]=BGD2 */ + double isc[4]; /* GPS :isc[0]=ISCL1, isc[1]=ISCL2, isc[2]=ISCL5I, isc[3]=ISCL5Q */ + double Adot, ndot; /* Adot,ndot for CNAV */ } eph_t; @@ -1210,7 +1213,7 @@ typedef struct char local[1024]; /* local file path */ int topts[4]; /* time options {poff,tint,toff,tretry} (s) */ gtime_t tnext; /* next retry time (gpst) */ - thread_t thread; /* download thread */ + pthread_t thread; /* download thread */ } ftp_t; @@ -1283,7 +1286,7 @@ typedef struct stream_t stream[8]; /* streams {rov,base,corr,sol1,sol2,logr,logb,logc} */ stream_t *moni; /* monitor stream */ unsigned int tick; /* start tick */ - thread_t thread; /* server thread */ + pthread_t thread; /* server thread */ int cputime; /* CPU time (ms) for a processing cycle */ int prcout; /* missing observation data count */ lock_t lock; /* lock flag */ @@ -1304,7 +1307,7 @@ typedef struct } msm_h_t; -const double chisqr[100] = {/* chi-sqr(n) (alpha=0.001) */ +const double CHISQR[100] = {/* chi-sqr(n) (alpha=0.001) */ 10.8, 13.8, 16.3, 18.5, 20.5, 22.5, 24.3, 26.1, 27.9, 29.6, 31.3, 32.9, 34.5, 36.1, 37.7, 39.3, 40.8, 42.3, 43.8, 45.3, 46.8, 48.3, 49.7, 51.2, 52.6, 54.1, 55.5, 56.9, 58.3, 59.7, @@ -1317,7 +1320,7 @@ const double chisqr[100] = {/* chi-sqr(n) (alpha=0.001) */ 138, 139, 140, 142, 143, 144, 145, 147, 148, 149}; -const double lam_carr[MAXFREQ] = {/* carrier wave length (m) */ +const double LAM_CARR[MAXFREQ] = {/* carrier wave length (m) */ SPEED_OF_LIGHT / FREQ1, SPEED_OF_LIGHT / FREQ2, SPEED_OF_LIGHT / FREQ5, SPEED_OF_LIGHT / FREQ6, SPEED_OF_LIGHT / FREQ7, SPEED_OF_LIGHT / FREQ8, SPEED_OF_LIGHT / FREQ9}; diff --git a/src/algorithms/libs/rtklib/rtklib_conversions.cc b/src/algorithms/libs/rtklib/rtklib_conversions.cc index 7953509a2..6008fdfd4 100644 --- a/src/algorithms/libs/rtklib/rtklib_conversions.cc +++ b/src/algorithms/libs/rtklib/rtklib_conversions.cc @@ -49,9 +49,15 @@ obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro break; } double CN0_dB_Hz_est = gnss_synchro.CN0_dB_hz; - if (CN0_dB_Hz_est > 63.75) CN0_dB_Hz_est = 63.75; - if (CN0_dB_Hz_est < 0.0) CN0_dB_Hz_est = 0.0; - unsigned char CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + if (CN0_dB_Hz_est > 63.75) + { + CN0_dB_Hz_est = 63.75; + } + if (CN0_dB_Hz_est < 0.0) + { + CN0_dB_Hz_est = 0.0; + } + auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); rtklib_obs.SNR[band] = CN0_dB_Hz; //Galileo is the third satellite system for RTKLIB, so, add the required offset to discriminate Galileo ephemeris switch (gnss_synchro.System) @@ -65,10 +71,25 @@ obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro case 'R': rtklib_obs.sat = gnss_synchro.PRN + NSATGPS; break; + case 'C': + rtklib_obs.sat = gnss_synchro.PRN + NSATGPS + NSATGLO + NSATGAL + NSATQZS; + break; default: rtklib_obs.sat = gnss_synchro.PRN; } + + // Mote that BeiDou week numbers do not need adjustment for foreseeable future. Consider change + // to more elegant solution + // if(gnss_synchro.System == 'C') + // { + // rtklib_obs.time = bdt2gpst(bdt2time(week, gnss_synchro.RX_time)); + // } + // else + // { + // rtklib_obs.time = gpst2time(adjgpsweek(week), gnss_synchro.RX_time); + // } + // rtklib_obs.time = gpst2time(adjgpsweek(week), gnss_synchro.RX_time); rtklib_obs.rcv = 1; return rtklib_obs; @@ -116,7 +137,7 @@ geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glona eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph) { eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0 }; + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; //Galileo is the third satellite system for RTKLIB, so, add the required offset to discriminate Galileo ephemeris rtklib_sat.sat = gal_eph.i_satellite_PRN + NSATGPS + NSATGLO; rtklib_sat.A = gal_eph.A_1 * gal_eph.A_1; @@ -152,7 +173,7 @@ eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph) /* adjustment for week handover */ double tow, toc; tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week); - toc = time2gpst(rtklib_sat.toc, NULL); + toc = time2gpst(rtklib_sat.toc, nullptr); if (rtklib_sat.toes < tow - 302400.0) { rtklib_sat.week++; @@ -174,7 +195,7 @@ eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph) eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph) { eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0 }; + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; rtklib_sat.sat = gps_eph.i_satellite_PRN; rtklib_sat.A = gps_eph.d_sqrt_A * gps_eph.d_sqrt_A; rtklib_sat.M0 = gps_eph.d_M_0; @@ -209,7 +230,7 @@ eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph) /* adjustment for week handover */ double tow, toc; tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week); - toc = time2gpst(rtklib_sat.toc, NULL); + toc = time2gpst(rtklib_sat.toc, nullptr); if (rtklib_sat.toes < tow - 302400.0) { rtklib_sat.week++; @@ -227,11 +248,74 @@ eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph) return rtklib_sat; } +eph_t eph_to_rtklib(const Beidou_Dnav_Ephemeris& bei_eph) +{ + eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; + rtklib_sat.sat = bei_eph.i_satellite_PRN + NSATGPS + NSATGLO + NSATGAL + NSATQZS; + rtklib_sat.A = bei_eph.d_sqrt_A * bei_eph.d_sqrt_A; + rtklib_sat.M0 = bei_eph.d_M_0; + rtklib_sat.deln = bei_eph.d_Delta_n; + rtklib_sat.OMG0 = bei_eph.d_OMEGA0; + rtklib_sat.OMGd = bei_eph.d_OMEGA_DOT; + rtklib_sat.omg = bei_eph.d_OMEGA; + rtklib_sat.i0 = bei_eph.d_i_0; + rtklib_sat.idot = bei_eph.d_IDOT; + rtklib_sat.e = bei_eph.d_eccentricity; + rtklib_sat.Adot = 0; //only in CNAV; + rtklib_sat.ndot = 0; //only in CNAV; + + rtklib_sat.code = bei_eph.i_sig_type; /*B1I data*/ + rtklib_sat.flag = bei_eph.i_nav_type; /*MEO/IGSO satellite*/ + rtklib_sat.iode = static_cast(bei_eph.d_AODE); /* AODE */ + rtklib_sat.iodc = static_cast(bei_eph.d_AODC); /* AODC */ + + rtklib_sat.week = bei_eph.i_BEIDOU_week; /* week of tow */ + rtklib_sat.cic = bei_eph.d_Cic; + rtklib_sat.cis = bei_eph.d_Cis; + rtklib_sat.cuc = bei_eph.d_Cuc; + rtklib_sat.cus = bei_eph.d_Cus; + rtklib_sat.crc = bei_eph.d_Crc; + rtklib_sat.crs = bei_eph.d_Crs; + rtklib_sat.f0 = bei_eph.d_A_f0; + rtklib_sat.f1 = bei_eph.d_A_f1; + rtklib_sat.f2 = bei_eph.d_A_f2; + rtklib_sat.tgd[0] = bei_eph.d_TGD1; + rtklib_sat.tgd[1] = bei_eph.d_TGD2; + rtklib_sat.tgd[2] = 0.0; + rtklib_sat.tgd[3] = 0.0; + rtklib_sat.toes = bei_eph.d_Toe; + rtklib_sat.toe = bdt2gpst(bdt2time(rtklib_sat.week, bei_eph.d_Toe)); + rtklib_sat.toc = bdt2gpst(bdt2time(rtklib_sat.week, bei_eph.d_Toc)); + rtklib_sat.ttr = bdt2gpst(bdt2time(rtklib_sat.week, bei_eph.d_TOW)); + /* adjustment for week handover */ + double tow, toc, toe; + tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week); + toc = time2gpst(rtklib_sat.toc, nullptr); + toe = time2gpst(rtklib_sat.toe, nullptr); + + if (rtklib_sat.toes < tow - 302400.0) + { + rtklib_sat.week++; + tow -= 604800.0; + } + else if (rtklib_sat.toes > tow + 302400.0) + { + rtklib_sat.week--; + tow += 604800.0; + } + rtklib_sat.toe = gpst2time(rtklib_sat.week, toe); + rtklib_sat.toc = gpst2time(rtklib_sat.week, toc); + rtklib_sat.ttr = gpst2time(rtklib_sat.week, tow); + + return rtklib_sat; +} + eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph) { eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0 }; + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; rtklib_sat.sat = gps_cnav_eph.i_satellite_PRN; const double A_REF = 26559710.0; // See IS-GPS-200H, pp. 170 rtklib_sat.A = A_REF + gps_cnav_eph.d_DELTA_A; @@ -274,7 +358,7 @@ eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph) /* adjustment for week handover */ double tow, toc; tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week); - toc = time2gpst(rtklib_sat.toc, NULL); + toc = time2gpst(rtklib_sat.toc, nullptr); if (rtklib_sat.toes < tow - 302400.0) { rtklib_sat.week++; @@ -291,3 +375,61 @@ eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph) return rtklib_sat; } + +alm_t alm_to_rtklib(const Gps_Almanac& gps_alm) +{ + alm_t rtklib_alm; + + rtklib_alm = {0, 0, 0, 0, {0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + rtklib_alm.sat = gps_alm.i_satellite_PRN; + rtklib_alm.svh = gps_alm.i_SV_health; + rtklib_alm.svconf = gps_alm.i_AS_status; + rtklib_alm.week = gps_alm.i_WNa; + gtime_t toa; + toa.time = gps_alm.i_Toa; + toa.sec = 0.0; + rtklib_alm.toa = toa; + rtklib_alm.A = gps_alm.d_sqrt_A * gps_alm.d_sqrt_A; + rtklib_alm.e = gps_alm.d_e_eccentricity; + rtklib_alm.i0 = (gps_alm.d_Delta_i + 0.3) * PI; + rtklib_alm.OMG0 = gps_alm.d_OMEGA0 * PI; + rtklib_alm.OMGd = gps_alm.d_OMEGA_DOT * PI; + rtklib_alm.omg = gps_alm.d_OMEGA * PI; + rtklib_alm.M0 = gps_alm.d_M_0 * PI; + rtklib_alm.f0 = gps_alm.d_A_f0; + rtklib_alm.f1 = gps_alm.d_A_f1; + rtklib_alm.toas = gps_alm.i_Toa; + + return rtklib_alm; +} + + +alm_t alm_to_rtklib(const Galileo_Almanac& gal_alm) +{ + alm_t rtklib_alm; + + rtklib_alm = {0, 0, 0, 0, {0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + rtklib_alm.sat = gal_alm.i_satellite_PRN + NSATGPS + NSATGLO; + rtklib_alm.svh = gal_alm.E1B_HS; + rtklib_alm.svconf = gal_alm.E1B_HS; + rtklib_alm.week = gal_alm.i_WNa; + gtime_t toa; + toa.time = gal_alm.i_Toa; + toa.sec = 0.0; + rtklib_alm.toa = toa; + rtklib_alm.A = 5440.588203494 + gal_alm.d_Delta_sqrt_A; + rtklib_alm.A = rtklib_alm.A * rtklib_alm.A; + rtklib_alm.e = gal_alm.d_e_eccentricity; + rtklib_alm.i0 = (gal_alm.d_Delta_i + 56.0 / 180.0) * PI; + rtklib_alm.OMG0 = gal_alm.d_OMEGA0 * PI; + rtklib_alm.OMGd = gal_alm.d_OMEGA_DOT * PI; + rtklib_alm.omg = gal_alm.d_OMEGA * PI; + rtklib_alm.M0 = gal_alm.d_M_0 * PI; + rtklib_alm.f0 = gal_alm.d_A_f0; + rtklib_alm.f1 = gal_alm.d_A_f1; + rtklib_alm.toas = gal_alm.i_Toa; + + return rtklib_alm; +} diff --git a/src/algorithms/libs/rtklib/rtklib_conversions.h b/src/algorithms/libs/rtklib/rtklib_conversions.h index 11f4208d1..de2b7baaf 100644 --- a/src/algorithms/libs/rtklib/rtklib_conversions.h +++ b/src/algorithms/libs/rtklib/rtklib_conversions.h @@ -31,17 +31,25 @@ #ifndef GNSS_SDR_RTKLIB_CONVERSIONS_H_ #define GNSS_SDR_RTKLIB_CONVERSIONS_H_ -#include "rtklib.h" -#include "gnss_synchro.h" +#include "beidou_dnav_ephemeris.h" +#include "galileo_almanac.h" #include "galileo_ephemeris.h" -#include "gps_ephemeris.h" -#include "gps_cnav_ephemeris.h" #include "glonass_gnav_ephemeris.h" #include "glonass_gnav_utc_model.h" +#include "gnss_synchro.h" +#include "gps_almanac.h" +#include "gps_cnav_ephemeris.h" +#include "gps_ephemeris.h" +#include "rtklib.h" eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph); eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph); eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph); +eph_t eph_to_rtklib(const Beidou_Dnav_Ephemeris& bei_eph); + +alm_t alm_to_rtklib(const Gps_Almanac& gps_alm); +alm_t alm_to_rtklib(const Galileo_Almanac& gal_alm); + /*! * \brief Transforms a Glonass_Gnav_Ephemeris to its RTKLIB counterpart * \param glonass_gnav_eph GLONASS GNAV Ephemeris structure diff --git a/src/algorithms/libs/rtklib/rtklib_ephemeris.cc b/src/algorithms/libs/rtklib/rtklib_ephemeris.cc index eff182fbd..bd72b7f9f 100644 --- a/src/algorithms/libs/rtklib/rtklib_ephemeris.cc +++ b/src/algorithms/libs/rtklib/rtklib_ephemeris.cc @@ -51,9 +51,9 @@ *----------------------------------------------------------------------------*/ #include "rtklib_ephemeris.h" +#include "rtklib_preceph.h" #include "rtklib_rtkcmn.h" #include "rtklib_sbas.h" -#include "rtklib_preceph.h" /* constants ------------------------------------------------------*/ @@ -99,8 +99,14 @@ double var_uraeph(int ura) double var_urassr(int ura) { double std_; - if (ura <= 0) return std::pow(DEFURASSR, 2.0); - if (ura >= 63) return std::pow(5.4665, 2.0); + if (ura <= 0) + { + return std::pow(DEFURASSR, 2.0); + } + if (ura >= 63) + { + return std::pow(5.4665, 2.0); + } std_ = (std::pow((ura >> 3) & 7, 2.0) * (1.0 + (ura & 7) / 4.0) - 1.0) * 1e-3; return std::pow(std_, 2.0); } @@ -129,7 +135,7 @@ void alm2pos(gtime_t time, const alm_t *alm, double *rs, double *dts) rs[0] = rs[1] = rs[2] = *dts = 0.0; return; } - mu = satsys(alm->sat, NULL) == SYS_GAL ? MU_GAL : MU_GPS; + mu = satsys(alm->sat, nullptr) == SYS_GAL ? MU_GAL : MU_GPS; M = alm->M0 + sqrt(mu / (alm->A * alm->A * alm->A)) * tk; for (n = 0, E = M, Ek = 0.0; fabs(E - Ek) > RTOL_KEPLER && n < MAX_ITER_KEPLER; n++) @@ -323,13 +329,25 @@ void glorbit(double t, double *x, const double *acc) int i; deq(x, k1, acc); - for (i = 0; i < 6; i++) w[i] = x[i] + k1[i] * t / 2.0; + for (i = 0; i < 6; i++) + { + w[i] = x[i] + k1[i] * t / 2.0; + } deq(w, k2, acc); - for (i = 0; i < 6; i++) w[i] = x[i] + k2[i] * t / 2.0; + for (i = 0; i < 6; i++) + { + w[i] = x[i] + k2[i] * t / 2.0; + } deq(w, k3, acc); - for (i = 0; i < 6; i++) w[i] = x[i] + k3[i] * t; + for (i = 0; i < 6; i++) + { + w[i] = x[i] + k3[i] * t; + } deq(w, k4, acc); - for (i = 0; i < 6; i++) x[i] += (k1[i] + 2.0 * k2[i] + 2.0 * k3[i] + k4[i]) * t / 6.0; + for (i = 0; i < 6; i++) + { + x[i] += (k1[i] + 2.0 * k2[i] + 2.0 * k3[i] + k4[i]) * t / 6.0; + } } @@ -386,10 +404,16 @@ void geph2pos(gtime_t time, const geph_t *geph, double *rs, double *dts, } for (tt = t < 0.0 ? -TSTEP : TSTEP; fabs(t) > 1e-9; t -= tt) { - if (fabs(t) < TSTEP) tt = t; + if (fabs(t) < TSTEP) + { + tt = t; + } glorbit(tt, x, geph->acc); } - for (i = 0; i < 3; i++) rs[i] = x[i]; + for (i = 0; i < 3; i++) + { + rs[i] = x[i]; + } *var = std::pow(ERREPH_GLO, 2.0); } @@ -457,7 +481,7 @@ eph_t *seleph(gtime_t time, int sat, int iode, const nav_t *nav) trace(4, "seleph : time=%s sat=%2d iode=%d\n", time_str(time, 3), sat, iode); - switch (satsys(sat, NULL)) + switch (satsys(sat, nullptr)) { case SYS_QZS: tmax = MAXDTOE_QZS + 1.0; @@ -476,10 +500,22 @@ eph_t *seleph(gtime_t time, int sat, int iode, const nav_t *nav) for (i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; - if (iode >= 0 && nav->eph[i].iode != iode) continue; - if ((t = fabs(timediff(nav->eph[i].toe, time))) > tmax) continue; - if (iode >= 0) return nav->eph + i; + if (nav->eph[i].sat != sat) + { + continue; + } + if (iode >= 0 && nav->eph[i].iode != iode) + { + continue; + } + if ((t = fabs(timediff(nav->eph[i].toe, time))) > tmax) + { + continue; + } + if (iode >= 0) + { + return nav->eph + i; + } if (t <= tmin) { j = i; @@ -490,7 +526,7 @@ eph_t *seleph(gtime_t time, int sat, int iode, const nav_t *nav) { trace(3, "no broadcast ephemeris: %s sat=%2d iode=%3d\n", time_str(time, 0), sat, iode); - return NULL; + return nullptr; } return nav->eph + j; } @@ -506,10 +542,22 @@ geph_t *selgeph(gtime_t time, int sat, int iode, const nav_t *nav) for (i = 0; i < nav->ng; i++) { - if (nav->geph[i].sat != sat) continue; - if (iode >= 0 && nav->geph[i].iode != iode) continue; - if ((t = fabs(timediff(nav->geph[i].toe, time))) > tmax) continue; - if (iode >= 0) return nav->geph + i; + if (nav->geph[i].sat != sat) + { + continue; + } + if (iode >= 0 && nav->geph[i].iode != iode) + { + continue; + } + if ((t = fabs(timediff(nav->geph[i].toe, time))) > tmax) + { + continue; + } + if (iode >= 0) + { + return nav->geph + i; + } if (t <= tmin) { j = i; @@ -520,7 +568,7 @@ geph_t *selgeph(gtime_t time, int sat, int iode, const nav_t *nav) { trace(3, "no glonass ephemeris : %s sat=%2d iode=%2d\n", time_str(time, 0), sat, iode); - return NULL; + return nullptr; } return nav->geph + j; } @@ -536,8 +584,14 @@ seph_t *selseph(gtime_t time, int sat, const nav_t *nav) for (i = 0; i < nav->ns; i++) { - if (nav->seph[i].sat != sat) continue; - if ((t = fabs(timediff(nav->seph[i].t0, time))) > tmax) continue; + if (nav->seph[i].sat != sat) + { + continue; + } + if ((t = fabs(timediff(nav->seph[i].t0, time))) > tmax) + { + continue; + } if (t <= tmin) { j = i; @@ -547,7 +601,7 @@ seph_t *selseph(gtime_t time, int sat, const nav_t *nav) if (j < 0) { trace(3, "no sbas ephemeris : %s sat=%2d\n", time_str(time, 0), sat); - return NULL; + return nullptr; } return nav->seph + j; } @@ -564,25 +618,36 @@ int ephclk(gtime_t time, gtime_t teph, int sat, const nav_t *nav, trace(4, "ephclk : time=%s sat=%2d\n", time_str(time, 3), sat); - sys = satsys(sat, NULL); + sys = satsys(sat, nullptr); if (sys == SYS_GPS || sys == SYS_GAL || sys == SYS_QZS || sys == SYS_BDS) { - if (!(eph = seleph(teph, sat, -1, nav))) return 0; + if (!(eph = seleph(teph, sat, -1, nav))) + { + return 0; + } *dts = eph2clk(time, eph); } else if (sys == SYS_GLO) { - if (!(geph = selgeph(teph, sat, -1, nav))) return 0; + if (!(geph = selgeph(teph, sat, -1, nav))) + { + return 0; + } *dts = geph2clk(time, geph); } else if (sys == SYS_SBS) { - if (!(seph = selseph(teph, sat, nav))) return 0; + if (!(seph = selseph(teph, sat, nav))) + { + return 0; + } *dts = seph2clk(time, seph); } else - return 0; + { + return 0; + } return 1; } @@ -600,13 +665,16 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, trace(4, "ephpos : time=%s sat=%2d iode=%d\n", time_str(time, 3), sat, iode); - sys = satsys(sat, NULL); + sys = satsys(sat, nullptr); *svh = -1; if (sys == SYS_GPS || sys == SYS_GAL || sys == SYS_QZS || sys == SYS_BDS) { - if (!(eph = seleph(teph, sat, iode, nav))) return 0; + if (!(eph = seleph(teph, sat, iode, nav))) + { + return 0; + } eph2pos(time, eph, rs, dts, var); time = timeadd(time, tt); @@ -615,7 +683,10 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, } else if (sys == SYS_GLO) { - if (!(geph = selgeph(teph, sat, iode, nav))) return 0; + if (!(geph = selgeph(teph, sat, iode, nav))) + { + return 0; + } geph2pos(time, geph, rs, dts, var); time = timeadd(time, tt); geph2pos(time, geph, rst, dtst, var); @@ -623,7 +694,10 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, } else if (sys == SYS_SBS) { - if (!(seph = selseph(teph, sat, nav))) return 0; + if (!(seph = selseph(teph, sat, nav))) + { + return 0; + } seph2pos(time, seph, rs, dts, var); time = timeadd(time, tt); @@ -631,10 +705,15 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, *svh = seph->svh; } else - return 0; + { + return 0; + } /* satellite velocity and clock drift by differential approx */ - for (i = 0; i < 3; i++) rs[i + 3] = (rst[i] - rs[i]) / tt; + for (i = 0; i < 3; i++) + { + rs[i + 3] = (rst[i] - rs[i]) / tt; + } dts[1] = (dtst[0] - dts[0]) / tt; return 1; @@ -654,7 +733,10 @@ int satpos_sbas(gtime_t time, gtime_t teph, int sat, const nav_t *nav, for (i = 0; i < nav->sbssat.nsat; i++) { sbs = nav->sbssat.sat + i; - if (sbs->sat == sat) break; + if (sbs->sat == sat) + { + break; + } } if (i >= nav->sbssat.nsat) { @@ -664,10 +746,16 @@ int satpos_sbas(gtime_t time, gtime_t teph, int sat, const nav_t *nav, return 0; } /* satellite position and clock by broadcast ephemeris */ - if (!ephpos(time, teph, sat, nav, sbs->lcorr.iode, rs, dts, var, svh)) return 0; + if (!ephpos(time, teph, sat, nav, sbs->lcorr.iode, rs, dts, var, svh)) + { + return 0; + } /* sbas satellite correction (long term and fast) */ - if (sbssatcorr(time, sat, nav, rs, dts, var)) return 1; + if (sbssatcorr(time, sat, nav, rs, dts, var)) + { + return 1; + } *svh = -1; return 0; } @@ -716,10 +804,19 @@ int satpos_ssr(gtime_t time, gtime_t teph, int sat, const nav_t *nav, *svh = -1; return 0; } - if (ssr->udi[0] >= 1.0) t1 -= ssr->udi[0] / 2.0; - if (ssr->udi[1] >= 1.0) t2 -= ssr->udi[0] / 2.0; + if (ssr->udi[0] >= 1.0) + { + t1 -= ssr->udi[0] / 2.0; + } + if (ssr->udi[1] >= 1.0) + { + t2 -= ssr->udi[0] / 2.0; + } - for (i = 0; i < 3; i++) deph[i] = ssr->deph[i] + ssr->ddeph[i] * t1; + for (i = 0; i < 3; i++) + { + deph[i] = ssr->deph[i] + ssr->ddeph[i] * t1; + } dclk = ssr->dclk[0] + ssr->dclk[1] * t2 + ssr->dclk[2] * t2 * t2; /* ssr highrate clock correction (ref [4]) */ @@ -735,13 +832,19 @@ int satpos_ssr(gtime_t time, gtime_t teph, int sat, const nav_t *nav, return 0; } /* satellite position and clock by broadcast ephemeris */ - if (!ephpos(time, teph, sat, nav, ssr->iode, rs, dts, var, svh)) return 0; + if (!ephpos(time, teph, sat, nav, ssr->iode, rs, dts, var, svh)) + { + return 0; + } /* satellite clock for gps, galileo and qzss */ - sys = satsys(sat, NULL); + sys = satsys(sat, nullptr); if (sys == SYS_GPS || sys == SYS_GAL || sys == SYS_QZS || sys == SYS_BDS) { - if (!(eph = seleph(teph, sat, ssr->iode, nav))) return 0; + if (!(eph = seleph(teph, sat, ssr->iode, nav))) + { + return 0; + } /* satellite clock by clock parameters */ tk = timediff(time, eph->toc); @@ -752,7 +855,10 @@ int satpos_ssr(gtime_t time, gtime_t teph, int sat, const nav_t *nav, dts[0] -= 2.0 * dot(rs, rs + 3, 3) / SPEED_OF_LIGHT / SPEED_OF_LIGHT; } /* radial-along-cross directions in ecef */ - if (!normv3(rs + 3, ea)) return 0; + if (!normv3(rs + 3, ea)) + { + return 0; + } cross3(rs, rs + 3, rc); if (!normv3(rc, ec)) { @@ -819,9 +925,13 @@ int satpos(gtime_t time, gtime_t teph, int sat, int ephopt, return satpos_ssr(time, teph, sat, nav, 1, rs, dts, var, svh); case EPHOPT_PREC: if (!peph2pos(time, sat, nav, 1, rs, dts, var)) - break; + { + break; + } else - return 1; + { + return 1; + } //TODO: enable lex //case EPHOPT_LEX : // if (!lexeph2pos(time, sat, nav, rs, dts, var)) break; else return 1; @@ -866,14 +976,25 @@ void satposs(gtime_t teph, const obsd_t *obs, int n, const nav_t *nav, for (i = 0; i < n && i < MAXOBS; i++) { - for (j = 0; j < 6; j++) rs[j + i * 6] = 0.0; - for (j = 0; j < 2; j++) dts[j + i * 2] = 0.0; + for (j = 0; j < 6; j++) + { + rs[j + i * 6] = 0.0; + } + for (j = 0; j < 2; j++) + { + dts[j + i * 2] = 0.0; + } var[i] = 0.0; svh[i] = 0; /* search any pseudorange */ for (j = 0, pr = 0.0; j < NFREQ; j++) - if ((pr = obs[i].P[j]) != 0.0) break; + { + if ((pr = obs[i].P[j]) != 0.0) + { + break; + } + } if (j >= NFREQ) { @@ -901,7 +1022,10 @@ void satposs(gtime_t teph, const obsd_t *obs, int n, const nav_t *nav, /* if no precise clock available, use broadcast clock instead */ if (dts[i * 2] == 0.0) { - if (!ephclk(time[i], teph, obs[i].sat, nav, dts + i * 2)) continue; + if (!ephclk(time[i], teph, obs[i].sat, nav, dts + i * 2)) + { + continue; + } dts[1 + i * 2] = 0.0; *var = std::pow(STD_BRDCCLK, 2.0); } diff --git a/src/algorithms/libs/rtklib/rtklib_ionex.cc b/src/algorithms/libs/rtklib/rtklib_ionex.cc index 7790943fa..8ba2bb950 100644 --- a/src/algorithms/libs/rtklib/rtklib_ionex.cc +++ b/src/algorithms/libs/rtklib/rtklib_ionex.cc @@ -59,14 +59,24 @@ #include "rtklib_ionex.h" #include "rtklib_rtkcmn.h" +#include /* get index -----------------------------------------------------------------*/ int getindex(double value, const double *range) { - if (range[2] == 0.0) return 0; - if (range[1] > 0.0 && (value < range[0] || range[1] < value)) return -1; - if (range[1] < 0.0 && (value < range[1] || range[0] < value)) return -1; - return (int)floor((value - range[0]) / range[2] + 0.5); + if (range[2] == 0.0) + { + return 0; + } + if (range[1] > 0.0 && (value < range[0] || range[1] < value)) + { + return -1; + } + if (range[1] < 0.0 && (value < range[1] || range[0] < value)) + { + return -1; + } + return static_cast(floor((value - range[0]) / range[2] + 0.5)); } @@ -80,7 +90,10 @@ int nitem(const double *range) /* data index (i:lat,j:lon,k:hgt) --------------------------------------------*/ int dataindex(int i, int j, int k, const int *ndata) { - if (i < 0 || ndata[0] <= i || j < 0 || ndata[1] <= j || k < 0 || ndata[2] <= k) return -1; + if (i < 0 || ndata[0] <= i || j < 0 || ndata[1] <= j || k < 0 || ndata[2] <= k) + { + return -1; + } return i + ndata[0] * (j + ndata[1] * k); } @@ -98,18 +111,21 @@ tec_t *addtec(const double *lats, const double *lons, const double *hgts, ndata[0] = nitem(lats); ndata[1] = nitem(lons); ndata[2] = nitem(hgts); - if (ndata[0] <= 1 || ndata[1] <= 1 || ndata[2] <= 0) return NULL; + if (ndata[0] <= 1 || ndata[1] <= 1 || ndata[2] <= 0) + { + return nullptr; + } if (nav->nt >= nav->ntmax) { nav->ntmax += 256; - if (!(nav_tec = (tec_t *)realloc(nav->tec, sizeof(tec_t) * nav->ntmax))) + if (!(nav_tec = static_cast(realloc(nav->tec, sizeof(tec_t) * nav->ntmax)))) { trace(1, "readionex malloc error ntmax=%d\n", nav->ntmax); free(nav->tec); - nav->tec = NULL; + nav->tec = nullptr; nav->nt = nav->ntmax = 0; - return NULL; + return nullptr; } nav->tec = nav_tec; } @@ -125,10 +141,10 @@ tec_t *addtec(const double *lats, const double *lons, const double *hgts, } n = ndata[0] * ndata[1] * ndata[2]; - if (!(p->data = (double *)malloc(sizeof(double) * n)) || - !(p->rms = (float *)malloc(sizeof(float) * n))) + if (!(p->data = static_cast(malloc(sizeof(double) * n))) || + !(p->rms = static_cast(malloc(sizeof(float) * n)))) { - return NULL; + return nullptr; } for (i = 0; i < n; i++) { @@ -148,11 +164,17 @@ void readionexdcb(FILE *fp, double *dcb, double *rms) trace(3, "readionexdcb:\n"); - for (i = 0; i < MAXSAT; i++) dcb[i] = rms[i] = 0.0; + for (i = 0; i < MAXSAT; i++) + { + dcb[i] = rms[i] = 0.0; + } while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60) continue; + if (strlen(buff) < 60) + { + continue; + } label = buff + 60; if (strstr(label, "PRN / BIAS / RMS") == label) @@ -169,7 +191,9 @@ void readionexdcb(FILE *fp, double *dcb, double *rms) rms[sat - 1] = str2num(buff, 16, 10); } else if (strstr(label, "END OF AUX DATA") == label) - break; + { + break; + } } } @@ -185,12 +209,18 @@ double readionexh(FILE *fp, double *lats, double *lons, double *hgts, while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60) continue; + if (strlen(buff) < 60) + { + continue; + } label = buff + 60; if (strstr(label, "IONEX VERSION / TYPE") == label) { - if (buff[20] == 'I') ver = str2num(buff, 0, 8); + if (buff[20] == 'I') + { + ver = str2num(buff, 0, 8); + } } else if (strstr(label, "BASE RADIUS") == label) { @@ -236,7 +266,7 @@ double readionexh(FILE *fp, double *lats, double *lons, double *hgts, int readionexb(FILE *fp, const double *lats, const double *lons, const double *hgts, double rb, double nexp, nav_t *nav) { - tec_t *p = NULL; + tec_t *p = nullptr; gtime_t time = {0, 0}; double lat, lon[3], hgt, x; int i, j, k, n, m, index, type = 0; @@ -246,26 +276,32 @@ int readionexb(FILE *fp, const double *lats, const double *lons, while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60) continue; + if (strlen(buff) < 60) + { + continue; + } if (strstr(label, "START OF TEC MAP") == label) { - if ((p = addtec(lats, lons, hgts, rb, nav))) type = 1; + if ((p = addtec(lats, lons, hgts, rb, nav))) + { + type = 1; + } } else if (strstr(label, "END OF TEC MAP") == label) { type = 0; - p = NULL; + p = nullptr; } else if (strstr(label, "START OF RMS MAP") == label) { type = 2; - p = NULL; + p = nullptr; } else if (strstr(label, "END OF RMS MAP") == label) { type = 0; - p = NULL; + p = nullptr; } else if (strstr(label, "EPOCH OF CURRENT MAP") == label) { @@ -278,13 +314,18 @@ int readionexb(FILE *fp, const double *lats, const double *lons, { for (i = nav->nt - 1; i >= 0; i--) { - if (fabs(timediff(time, nav->tec[i].time)) >= 1.0) continue; + if (fabs(timediff(time, nav->tec[i].time)) >= 1.0) + { + continue; + } p = nav->tec + i; break; } } else if (p) - p->time = time; + { + p->time = time; + } } else if (strstr(label, "LAT/LON1/LON2/DLON/H") == label && p) { @@ -300,17 +341,30 @@ int readionexb(FILE *fp, const double *lats, const double *lons, for (m = 0; m < n; m++) { - if (m % 16 == 0 && !fgets(buff, sizeof(buff), fp)) break; + if (m % 16 == 0 && !fgets(buff, sizeof(buff), fp)) + { + break; + } j = getindex(lon[0] + lon[2] * m, p->lons); - if ((index = dataindex(i, j, k, p->ndata)) < 0) continue; + if ((index = dataindex(i, j, k, p->ndata)) < 0) + { + continue; + } - if ((x = str2num(buff, m % 16 * 5, 5)) == 9999.0) continue; + if ((x = str2num(buff, m % 16 * 5, 5)) == 9999.0) + { + continue; + } if (type == 1) - p->data[index] = x * std::pow(10.0, nexp); + { + p->data[index] = x * std::pow(10.0, nexp); + } else - p->rms[index] = (float)(x * std::pow(10.0, nexp)); + { + p->rms[index] = static_cast(x * std::pow(10.0, nexp)); + } } } } @@ -379,14 +433,17 @@ void readtec(const char *file, nav_t *nav, int opt) if (!opt) { free(nav->tec); - nav->tec = NULL; + nav->tec = nullptr; nav->nt = nav->ntmax = 0; } for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return; } } @@ -395,29 +452,34 @@ void readtec(const char *file, nav_t *nav, int opt) for (i = 0; i < n; i++) { - if (!(fp = fopen(efiles[i], "r"))) + if (!(fp = fopen(efiles[i], "re"))) { trace(2, "ionex file open error %s\n", efiles[i]); continue; } - else + + /* read ionex header */ + if (readionexh(fp, lats, lons, hgts, &rb, &nexp, dcb, rms) <= 0.0) { - /* read ionex header */ - if (readionexh(fp, lats, lons, hgts, &rb, &nexp, dcb, rms) <= 0.0) - { - trace(2, "ionex file format error %s\n", efiles[i]); - fclose(fp); - continue; - } - /* read ionex body */ - readionexb(fp, lats, lons, hgts, rb, nexp, nav); + trace(2, "ionex file format error %s\n", efiles[i]); + fclose(fp); + continue; } + + /* read ionex body */ + readionexb(fp, lats, lons, hgts, rb, nexp, nav); fclose(fp); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } /* combine tec grid data */ - if (nav->nt > 0) combtec(nav); + if (nav->nt > 0) + { + combtec(nav); + } /* P1-P2 dcb */ for (i = 0; i < MAXSAT; i++) @@ -437,26 +499,36 @@ int interptec(const tec_t *tec, int k, const double *posp, double *value, trace(3, "interptec: k=%d posp=%.2f %.2f\n", k, posp[0] * R2D, posp[1] * R2D); *value = *rms = 0.0; - if (tec->lats[2] == 0.0 || tec->lons[2] == 0.0) return 0; + if (tec->lats[2] == 0.0 || tec->lons[2] == 0.0) + { + return 0; + } dlat = posp[0] * R2D - tec->lats[0]; dlon = posp[1] * R2D - tec->lons[0]; if (tec->lons[2] > 0.0) - dlon -= floor(dlon / 360) * 360.0; /* 0 <= dlon<360 */ + { + dlon -= floor(dlon / 360) * 360.0; /* 0 <= dlon<360 */ + } else - dlon += floor(-dlon / 360) * 360.0; /* -360lats[2]; b = dlon / tec->lons[2]; - i = (int)floor(a); + i = static_cast(floor(a)); a -= i; - j = (int)floor(b); + j = static_cast(floor(b)); b -= j; /* get gridded tec data */ for (n = 0; n < 4; n++) { - if ((index = dataindex(i + (n % 2), j + (n < 2 ? 0 : 1), k, tec->ndata)) < 0) continue; + if ((index = dataindex(i + (n % 2), j + (n < 2 ? 0 : 1), k, tec->ndata)) < 0) + { + continue; + } d[n] = tec->data[index]; r[n] = tec->rms[index]; } @@ -491,13 +563,18 @@ int interptec(const tec_t *tec, int k, const double *posp, double *value, { i = 0; for (n = 0; n < 4; n++) - if (d[n] > 0.0) - { - i++; - *value += d[n]; - *rms += r[n]; - } - if (i == 0) return 0; + { + if (d[n] > 0.0) + { + i++; + *value += d[n]; + *rms += r[n]; + } + } + if (i == 0) + { + return 0; + } *value /= i; *rms /= i; } @@ -537,7 +614,10 @@ int iondelay(gtime_t time, const tec_t *tec, const double *pos, posp[1] += 2.0 * PI * timediff(time, tec->time) / 86400.0; } /* interpolate tec grid data */ - if (!interptec(tec, i, posp, &vtec, &rms)) return 0; + if (!interptec(tec, i, posp, &vtec, &rms)) + { + return 0; + } *delay += fact * fs * vtec; *var += fact * fact * fs * fs * rms * rms; @@ -580,7 +660,10 @@ int iontec(gtime_t time, const nav_t *nav, const double *pos, } for (i = 0; i < nav->nt; i++) { - if (timediff(nav->tec[i].time, time) > 0.0) break; + if (timediff(nav->tec[i].time, time) > 0.0) + { + break; + } } if (i == 0 || i >= nav->nt) { diff --git a/src/algorithms/libs/rtklib/rtklib_lambda.cc b/src/algorithms/libs/rtklib/rtklib_lambda.cc index 3130b0e21..8aaba735f 100644 --- a/src/algorithms/libs/rtklib/rtklib_lambda.cc +++ b/src/algorithms/libs/rtklib/rtklib_lambda.cc @@ -52,6 +52,7 @@ #include "rtklib_lambda.h" #include "rtklib_rtkcmn.h" +#include /* LD factorization (Q=L'*diag(D)*L) -----------------------------------------*/ int LD(int n, const double *Q, double *L, double *D) @@ -68,13 +69,27 @@ int LD(int n, const double *Q, double *L, double *D) break; } a = sqrt(D[i]); - for (j = 0; j <= i; j++) L[i + j * n] = A[i + j * n] / a; + for (j = 0; j <= i; j++) + { + L[i + j * n] = A[i + j * n] / a; + } for (j = 0; j <= i - 1; j++) - for (k = 0; k <= j; k++) A[j + k * n] -= L[i + k * n] * L[i + j * n]; - for (j = 0; j <= i; j++) L[i + j * n] /= L[i + i * n]; + { + for (k = 0; k <= j; k++) + { + A[j + k * n] -= L[i + k * n] * L[i + j * n]; + } + } + for (j = 0; j <= i; j++) + { + L[i + j * n] /= L[i + i * n]; + } } free(A); - if (info) fprintf(stderr, "%s : LD factorization error\n", __FILE__); + if (info) + { + fprintf(stderr, "%s : LD factorization error\n", __FILE__); + } return info; } @@ -84,10 +99,16 @@ void gauss(int n, double *L, double *Z, int i, int j) { int k, mu; - if ((mu = (int)ROUND_LAMBDA(L[i + j * n])) != 0) + if ((mu = static_cast ROUND_LAMBDA(L[i + j * n])) != 0) { - for (k = i; k < n; k++) L[k + n * j] -= (double)mu * L[k + i * n]; - for (k = 0; k < n; k++) Z[k + n * j] -= (double)mu * Z[k + i * n]; + for (k = i; k < n; k++) + { + L[k + n * j] -= static_cast(mu) * L[k + i * n]; + } + for (k = 0; k < n; k++) + { + Z[k + n * j] -= static_cast(mu) * Z[k + i * n]; + } } } @@ -110,8 +131,14 @@ void perm(int n, double *L, double *D, int j, double del, double *Z) L[j + 1 + k * n] = eta * a0 + lam * a1; } L[j + 1 + j * n] = lam; - for (k = j + 2; k < n; k++) SWAP_LAMBDA(L[k + j * n], L[k + (j + 1) * n]); - for (k = 0; k < n; k++) SWAP_LAMBDA(Z[k + j * n], Z[k + (j + 1) * n]); + for (k = j + 2; k < n; k++) + { + SWAP_LAMBDA(L[k + j * n], L[k + (j + 1) * n]); + } + for (k = 0; k < n; k++) + { + SWAP_LAMBDA(Z[k + j * n], Z[k + (j + 1) * n]); + } } @@ -126,7 +153,12 @@ void reduction(int n, double *L, double *D, double *Z) while (j >= 0) { if (j <= k) - for (i = j + 1; i < n; i++) gauss(n, L, Z, i, j); + { + for (i = j + 1; i < n; i++) + { + gauss(n, L, Z, i, j); + } + } del = D[j] + L[j + 1 + j * n] * L[j + 1 + j * n] * D[j + 1]; if (del + 1E-6 < D[j + 1]) { /* compared considering numerical error */ @@ -135,7 +167,9 @@ void reduction(int n, double *L, double *D, double *Z) j = n - 2; } else - j--; + { + j--; + } } } @@ -163,7 +197,9 @@ int search(int n, int m, const double *L, const double *D, { dist[--k] = newdist; for (i = 0; i <= k; i++) - S[k + i * n] = S[k + 1 + i * n] + (z[k + 1] - zb[k + 1]) * L[k + 1 + i * n]; + { + S[k + i * n] = S[k + 1 + i * n] + (z[k + 1] - zb[k + 1]) * L[k + 1 + i * n]; + } zb[k] = zs[k] + S[k + k * n]; z[k] = ROUND_LAMBDA(zb[k]); y = zb[k] - z[k]; @@ -173,18 +209,32 @@ int search(int n, int m, const double *L, const double *D, { if (nn < m) { - if (nn == 0 || newdist > s[imax]) imax = nn; - for (i = 0; i < n; i++) zn[i + nn * n] = z[i]; + if (nn == 0 || newdist > s[imax]) + { + imax = nn; + } + for (i = 0; i < n; i++) + { + zn[i + nn * n] = z[i]; + } s[nn++] = newdist; } else { if (newdist < s[imax]) { - for (i = 0; i < n; i++) zn[i + imax * n] = z[i]; + for (i = 0; i < n; i++) + { + zn[i + imax * n] = z[i]; + } s[imax] = newdist; for (i = imax = 0; i < m; i++) - if (s[imax] < s[i]) imax = i; + { + if (s[imax] < s[i]) + { + imax = i; + } + } } maxdist = s[imax]; } @@ -196,23 +246,29 @@ int search(int n, int m, const double *L, const double *D, else { if (k == n - 1) - break; - else { - k++; - z[k] += step[k]; - y = zb[k] - z[k]; - step[k] = -step[k] - SGN_LAMBDA(step[k]); + break; } + + k++; + z[k] += step[k]; + y = zb[k] - z[k]; + step[k] = -step[k] - SGN_LAMBDA(step[k]); } } for (i = 0; i < m - 1; i++) { /* sort by s */ for (j = i + 1; j < m; j++) { - if (s[i] < s[j]) continue; + if (s[i] < s[j]) + { + continue; + } SWAP_LAMBDA(s[i], s[j]); - for (k = 0; k < n; k++) SWAP_LAMBDA(zn[k + i * n], zn[k + j * n]); + for (k = 0; k < n; k++) + { + SWAP_LAMBDA(zn[k + i * n], zn[k + j * n]); + } } } free(S); @@ -248,7 +304,10 @@ int lambda(int n, int m, const double *a, const double *Q, double *F, int info; double *L, *D, *Z, *z, *E; - if (n <= 0 || m <= 0) return -1; + if (n <= 0 || m <= 0) + { + return -1; + } L = zeros(n, n); D = mat(n, 1); Z = eye(n); @@ -289,16 +348,21 @@ int lambda_reduction(int n, const double *Q, double *Z) double *L, *D; int i, j, info; - if (n <= 0) return -1; + if (n <= 0) + { + return -1; + } L = zeros(n, n); D = mat(n, 1); for (i = 0; i < n; i++) - for (j = 0; j < n; j++) - { - Z[i + j * n] = i == j ? 1.0 : 0.0; - } + { + for (j = 0; j < n; j++) + { + Z[i + j * n] = i == j ? 1.0 : 0.0; + } + } /* LD factorization */ if ((info = LD(n, Q, L, D))) { @@ -331,7 +395,10 @@ int lambda_search(int n, int m, const double *a, const double *Q, double *L, *D; int info; - if (n <= 0 || m <= 0) return -1; + if (n <= 0 || m <= 0) + { + return -1; + } L = zeros(n, n); D = mat(n, 1); diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index 31b60c8e6..19cb48d46 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -54,6 +54,7 @@ #include "rtklib_ephemeris.h" #include "rtklib_ionex.h" #include "rtklib_sbas.h" +#include /* pseudorange measurement error variance ------------------------------------*/ double varerr(const prcopt_t *opt, double el, int sys) @@ -61,7 +62,10 @@ double varerr(const prcopt_t *opt, double el, int sys) double fact, varr; fact = sys == SYS_GLO ? EFACT_GLO : (sys == SYS_SBS ? EFACT_SBS : EFACT_GPS); varr = std::pow(opt->err[0], 2.0) * (std::pow(opt->err[1], 2.0) + std::pow(opt->err[2], 2.0) / sin(el)); - if (opt->ionoopt == IONOOPT_IFLC) varr *= std::pow(2, 3.0); /* iono-free */ + if (opt->ionoopt == IONOOPT_IFLC) + { + varr *= std::pow(2, 3.0); /* iono-free */ + } return std::pow(fact, 2.0) * varr; } @@ -72,7 +76,10 @@ double gettgd(int sat, const nav_t *nav) int i; for (i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].tgd[0]; } return 0.0; @@ -83,7 +90,10 @@ double getiscl1(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[0]; } return 0.0; @@ -93,7 +103,10 @@ double getiscl2(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[1]; } return 0.0; @@ -103,7 +116,10 @@ double getiscl5i(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[2]; } return 0.0; @@ -113,7 +129,10 @@ double getiscl5q(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[3]; } return 0.0; @@ -130,15 +149,15 @@ double prange(const obsd_t *obs, const nav_t *nav, const double *azel, double P1_P2 = 0.0; double P1_C1 = 0.0; double P2_C2 = 0.0; - //Intersignal corrections (m). See GPS IS-200 CNAV message - double ISCl1 = 0.0; + // Intersignal corrections (m). See GPS IS-200 CNAV message + //double ISCl1 = 0.0; double ISCl2 = 0.0; double ISCl5i = 0.0; - double ISCl5q = 0.0; + //double ISCl5q = 0.0; double gamma_ = 0.0; int i = 0; int j = 1; - int sys = satsys(obs->sat, NULL); + int sys = satsys(obs->sat, nullptr); *var = 0.0; if (sys == SYS_NONE) @@ -209,10 +228,10 @@ double prange(const obsd_t *obs, const nav_t *nav, const double *azel, if (sys == SYS_GPS) { - ISCl1 = getiscl1(obs->sat, nav); + // ISCl1 = getiscl1(obs->sat, nav); ISCl2 = getiscl2(obs->sat, nav); ISCl5i = getiscl5i(obs->sat, nav); - ISCl5q = getiscl5q(obs->sat, nav); + // ISCl5q = getiscl5q(obs->sat, nav); } //CHECK IF IT IS STILL NEEDED @@ -243,10 +262,10 @@ double prange(const obsd_t *obs, const nav_t *nav, const double *azel, return 0.0; } - else if (obs->code[i] != CODE_NONE and obs->code[j] == CODE_NONE) + if (obs->code[i] != CODE_NONE and obs->code[j] == CODE_NONE) { P1 += P1_C1; /* C1->P1 */ - PC = P1 + P1_P2; + PC = P1 - P1_P2; } else if (obs->code[i] == CODE_NONE and obs->code[j] != CODE_NONE) { @@ -406,7 +425,10 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, trace(3, "resprng : n=%d\n", n); - for (i = 0; i < 3; i++) rr[i] = x[i]; + for (i = 0; i < 3; i++) + { + rr[i] = x[i]; + } dtr = x[3]; ecef2pos(rr, pos); @@ -416,7 +438,10 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, vsat[i] = 0; azel[i * 2] = azel[1 + i * 2] = resp[i] = 0.0; - if (!(sys = satsys(obs[i].sat, NULL))) continue; + if (!(sys = satsys(obs[i].sat, nullptr))) + { + continue; + } /* reject duplicated observation data */ if (i < n - 1 && i < MAXOBS - 1 && obs[i].sat == obs[i + 1].sat) @@ -463,7 +488,7 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, /* GPS-L1 -> L1/B1 */ if ((lam_L1 = nav->lam[obs[i].sat - 1][0]) > 0.0) { - dion *= std::pow(lam_L1 / lam_carr[0], 2.0); + dion *= std::pow(lam_L1 / LAM_CARR[0], 2.0); } /* tropospheric corrections */ if (!tropcorr(obs[i].time, nav, pos, azel + i * 2, @@ -476,7 +501,10 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, v[nv] = P - (r + dtr - SPEED_OF_LIGHT * dts[i * 2] + dion + dtrp); /* design matrix */ - for (j = 0; j < NX; j++) H[j + nv * NX] = j < 3 ? -e[j] : (j == 3 ? 1.0 : 0.0); + for (j = 0; j < NX; j++) + { + H[j + nv * NX] = j < 3 ? -e[j] : (j == 3 ? 1.0 : 0.0); + } /* time system and receiver bias offset correction */ if (sys == SYS_GLO) @@ -498,7 +526,9 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, mask[3] = 1; } else - mask[0] = 1; + { + mask[0] = 1; + } vsat[i] = 1; resp[i] = v[nv]; @@ -513,9 +543,15 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, /* constraint to avoid rank-deficient */ for (i = 0; i < 4; i++) { - if (mask[i]) continue; + if (mask[i]) + { + continue; + } v[nv] = 0.0; - for (j = 0; j < NX; j++) H[j + nv * NX] = j == i + 3 ? 1.0 : 0.0; + for (j = 0; j < NX; j++) + { + H[j + nv * NX] = j == i + 3 ? 1.0 : 0.0; + } var[nv++] = 0.01; } return nv; @@ -535,15 +571,18 @@ int valsol(const double *azel, const int *vsat, int n, /* chi-square validation of residuals */ vv = dot(v, v, nv); - if (nv > nx && vv > chisqr[nv - nx - 1]) + if (nv > nx && vv > CHISQR[nv - nx - 1]) { - sprintf(msg, "chi-square error nv=%d vv=%.1f cs=%.1f", nv, vv, chisqr[nv - nx - 1]); + sprintf(msg, "chi-square error nv=%d vv=%.1f cs=%.1f", nv, vv, CHISQR[nv - nx - 1]); return 0; } /* large gdop check */ for (i = ns = 0; i < n; i++) { - if (!vsat[i]) continue; + if (!vsat[i]) + { + continue; + } azels[ns * 2] = azel[i * 2]; azels[1 + ns * 2] = azel[1 + i * 2]; ns++; @@ -573,7 +612,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, H = mat(NX, n + 4); var = mat(n + 4, 1); - for (i = 0; i < 3; i++) x[i] = sol->rr[i]; + for (i = 0; i < 3; i++) + { + x[i] = sol->rr[i]; + } for (i = 0; i < MAXITR; i++) { @@ -590,7 +632,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, { sig = sqrt(var[j]); v[j] /= sig; - for (k = 0; k < NX; k++) H[k + j * NX] /= sig; + for (k = 0; k < NX; k++) + { + H[k + j * NX] /= sig; + } } /* least square estimation */ if ((info = lsq(H, v, NX, nv, dx, Q))) @@ -598,7 +643,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, sprintf(msg, "lsq error info=%d", info); break; } - for (j = 0; j < NX; j++) x[j] += dx[j]; + for (j = 0; j < NX; j++) + { + x[j] += dx[j]; + } if (norm_rtk(dx, NX) < 1e-4) { @@ -608,12 +656,18 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, sol->dtr[1] = x[4] / SPEED_OF_LIGHT; /* glo-gps time offset (s) */ sol->dtr[2] = x[5] / SPEED_OF_LIGHT; /* gal-gps time offset (s) */ sol->dtr[3] = x[6] / SPEED_OF_LIGHT; /* bds-gps time offset (s) */ - for (j = 0; j < 6; j++) sol->rr[j] = j < 3 ? x[j] : 0.0; - for (j = 0; j < 3; j++) sol->qr[j] = (float)Q[j + j * NX]; - sol->qr[3] = (float)Q[1]; /* cov xy */ - sol->qr[4] = (float)Q[2 + NX]; /* cov yz */ - sol->qr[5] = (float)Q[2]; /* cov zx */ - sol->ns = (unsigned char)ns; + for (j = 0; j < 6; j++) + { + sol->rr[j] = j < 3 ? x[j] : 0.0; + } + for (j = 0; j < 3; j++) + { + sol->qr[j] = static_cast(Q[j + j * NX]); + } + sol->qr[3] = static_cast(Q[1]); /* cov xy */ + sol->qr[4] = static_cast(Q[2 + NX]); /* cov yz */ + sol->qr[5] = static_cast(Q[2]); /* cov zx */ + sol->ns = static_cast(ns); sol->age = sol->ratio = 0.0; /* validate solution */ @@ -628,7 +682,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, return stat; } } - if (i >= MAXITR) sprintf(msg, "iteration divergent i=%d", i); + if (i >= MAXITR) + { + sprintf(msg, "iteration divergent i=%d", i); + } free(v); free(H); @@ -652,7 +709,10 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, trace(3, "raim_fde: %s n=%2d\n", time_str(obs[0].time, 0), n); - if (!(obs_e = (obsd_t *)malloc(sizeof(obsd_t) * n))) return 0; + if (!(obs_e = static_cast(malloc(sizeof(obsd_t) * n)))) + { + return 0; + } rs_e = mat(6, n); dts_e = mat(2, n); vare_e = mat(1, n); @@ -666,7 +726,10 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, /* satellite exclution */ for (j = k = 0; j < n; j++) { - if (j == i) continue; + if (j == i) + { + continue; + } obs_e[k] = obs[j]; matcpy(rs_e + 6 * k, rs + 6 * j, 6, 1); matcpy(dts_e + 2 * k, dts + 2 * j, 2, 1); @@ -682,7 +745,10 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, } for (j = nvsat = 0, rms_e = 0.0; j < n - 1; j++) { - if (!vsat_e[j]) continue; + if (!vsat_e[j]) + { + continue; + } rms_e += std::pow(resp_e[j], 2.0); nvsat++; } @@ -696,12 +762,18 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, trace(3, "raim_fde: exsat=%2d rms=%8.3f\n", obs[i].sat, rms_e); - if (rms_e > rms) continue; + if (rms_e > rms) + { + continue; + } /* save result */ for (j = k = 0; j < n; j++) { - if (j == i) continue; + if (j == i) + { + continue; + } matcpy(azel + 2 * j, azel_e + 2 * k, 2, 1); vsat[j] = vsat_e[k]; resp[j] = resp_e[k++]; @@ -739,6 +811,7 @@ int resdop(const obsd_t *obs, int n, const double *rs, const double *dts, { double lam, rate, pos[3], E[9], a[3], e[3], vs[3], cosel; int i, j, nv = 0; + int band = 0; trace(3, "resdop : n=%d\n", n); @@ -747,9 +820,21 @@ int resdop(const obsd_t *obs, int n, const double *rs, const double *dts, for (i = 0; i < n && i < MAXOBS; i++) { - lam = nav->lam[obs[i].sat - 1][0]; + if (obs[i].code[0] != CODE_NONE) + { + band = 0; + } + if (obs[i].code[1] != CODE_NONE) + { + band = 1; + } + if (obs[i].code[2] != CODE_NONE) + { + band = 2; + } + lam = nav->lam[obs[i].sat - 1][band]; - if (obs[i].D[0] == 0.0 || lam == 0.0 || !vsat[i] || norm_rtk(rs + 3 + i * 6, 3) <= 0.0) + if (obs[i].D[band] == 0.0 || lam == 0.0 || !vsat[i] || norm_rtk(rs + 3 + i * 6, 3) <= 0.0) { continue; } @@ -761,16 +846,22 @@ int resdop(const obsd_t *obs, int n, const double *rs, const double *dts, matmul("TN", 3, 1, 3, 1.0, E, a, 0.0, e); /* satellite velocity relative to receiver in ecef */ - for (j = 0; j < 3; j++) vs[j] = rs[j + 3 + i * 6] - x[j]; + for (j = 0; j < 3; j++) + { + vs[j] = rs[j + 3 + i * 6] - x[j]; + } /* range rate with earth rotation correction */ rate = dot(vs, e, 3) + DEFAULT_OMEGA_EARTH_DOT / SPEED_OF_LIGHT * (rs[4 + i * 6] * rr[0] + rs[1 + i * 6] * x[0] - rs[3 + i * 6] * rr[1] - rs[i * 6] * x[1]); /* doppler residual */ - v[nv] = -lam * obs[i].D[0] - (rate + x[3] - SPEED_OF_LIGHT * dts[1 + i * 2]); + v[nv] = -lam * obs[i].D[band] - (rate + x[3] - SPEED_OF_LIGHT * dts[1 + i * 2]); /* design matrix */ - for (j = 0; j < 4; j++) H[j + nv * 4] = j < 3 ? -e[j] : 1.0; + for (j = 0; j < 4; j++) + { + H[j + nv * 4] = j < 3 ? -e[j] : 1.0; + } nv++; } @@ -799,13 +890,22 @@ void estvel(const obsd_t *obs, int n, const double *rs, const double *dts, break; } /* least square estimation */ - if (lsq(H, v, 4, nv, dx, Q)) break; + if (lsq(H, v, 4, nv, dx, Q)) + { + break; + } - for (j = 0; j < 4; j++) x[j] += dx[j]; + for (j = 0; j < 4; j++) + { + x[j] += dx[j]; + } if (norm_rtk(dx, 4) < 1e-6) { - for (i = 0; i < 3; i++) sol->rr[i + 3] = x[i]; + for (i = 0; i < 3; i++) + { + sol->rr[i + 3] = x[i]; + } break; } } @@ -877,11 +977,17 @@ int pntpos(const obsd_t *obs, int n, const nav_t *nav, stat = raim_fde(obs, n, rs, dts, var, svh, nav, &opt_, sol, azel_, vsat, resp, msg); } /* estimate receiver velocity with doppler */ - if (stat) estvel(obs, n, rs, dts, nav, &opt_, sol, azel_, vsat); + if (stat) + { + estvel(obs, n, rs, dts, nav, &opt_, sol, azel_, vsat); + } if (azel) { - for (i = 0; i < n * 2; i++) azel[i] = azel_[i]; + for (i = 0; i < n * 2; i++) + { + azel[i] = azel_[i]; + } } if (ssat) { @@ -897,7 +1003,10 @@ int pntpos(const obsd_t *obs, int n, const nav_t *nav, ssat[obs[i].sat - 1].azel[0] = azel_[i * 2]; ssat[obs[i].sat - 1].azel[1] = azel_[1 + i * 2]; ssat[obs[i].sat - 1].snr[0] = obs[i].SNR[0]; - if (!vsat[i]) continue; + if (!vsat[i]) + { + continue; + } ssat[obs[i].sat - 1].vs = 1; ssat[obs[i].sat - 1].resp[0] = resp[i]; } diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.cc b/src/algorithms/libs/rtklib/rtklib_ppp.cc index b60d627c9..83329ca48 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.cc +++ b/src/algorithms/libs/rtklib/rtklib_ppp.cc @@ -51,12 +51,13 @@ *----------------------------------------------------------------------------*/ #include "rtklib_ppp.h" -#include "rtklib_rtkcmn.h" -#include "rtklib_sbas.h" #include "rtklib_ephemeris.h" #include "rtklib_ionex.h" -#include "rtklib_tides.h" #include "rtklib_lambda.h" +#include "rtklib_rtkcmn.h" +#include "rtklib_sbas.h" +#include "rtklib_tides.h" +#include /* wave length of LC (m) -----------------------------------------------------*/ double lam_LC(int i, int j, int k) @@ -116,8 +117,14 @@ double p_gamma(double a, double x, double log_gamma_a) double y, w; int i; - if (x == 0.0) return 0.0; - if (x >= a + 1.0) return 1.0 - q_gamma(a, x, log_gamma_a); + if (x == 0.0) + { + return 0.0; + } + if (x >= a + 1.0) + { + return 1.0 - q_gamma(a, x, log_gamma_a); + } y = w = exp(a * log(x) - x - log_gamma_a) / a; @@ -125,7 +132,10 @@ double p_gamma(double a, double x, double log_gamma_a) { w *= x / (a + i); y += w; - if (fabs(w) < 1E-15) break; + if (fabs(w) < 1E-15) + { + break; + } } return y; } @@ -136,7 +146,10 @@ double q_gamma(double a, double x, double log_gamma_a) double y, w, la = 1.0, lb = x + 1.0 - a, lc; int i; - if (x < a + 1.0) return 1.0 - p_gamma(a, x, log_gamma_a); + if (x < a + 1.0) + { + return 1.0 - p_gamma(a, x, log_gamma_a); + } w = exp(-x + a * log(x) - log_gamma_a); y = w / lb; for (i = 2; i < 100; i++) @@ -146,7 +159,10 @@ double q_gamma(double a, double x, double log_gamma_a) lb = lc; w *= (i - 1 - a) / i; y += w / la / lb; - if (fabs(w / la / lb) < 1E-15) break; + if (fabs(w / la / lb) < 1E-15) + { + break; + } } return y; } @@ -185,9 +201,15 @@ void average_LC(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav __attribu { sat = obs[i].sat; - if (azel[1 + 2 * i] < rtk->opt.elmin) continue; + if (azel[1 + 2 * i] < rtk->opt.elmin) + { + continue; + } - if (satsys(sat, NULL) != SYS_GPS) continue; + if (satsys(sat, nullptr) != SYS_GPS) + { + continue; + } /* triple-freq carrier and code LC (m) */ LC1 = L_LC(1, -1, 0, obs[i].L) - P_LC(1, 1, 0, obs[i].P); @@ -211,7 +233,10 @@ void average_LC(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav __attribu amb->LC[0] = amb->LC[1] = amb->LC[2] = 0.0; amb->LCv[0] = amb->LCv[1] = amb->LCv[2] = 0.0; amb->fixcnt = 0; - for (j = 0; j < MAXSAT; j++) amb->flags[j] = 0; + for (j = 0; j < MAXSAT; j++) + { + amb->flags[j] = 0; + } } /* averaging */ if (LC1) @@ -245,7 +270,10 @@ int fix_amb_WL(rtk_t *rtk, const nav_t *nav, int sat1, int sat2, int *NW) amb1 = rtk->ambc + sat1 - 1; amb2 = rtk->ambc + sat2 - 1; - if (!amb1->n[0] || !amb2->n[0]) return 0; + if (!amb1->n[0] || !amb2->n[0]) + { + return 0; + } /* wide-lane ambiguity */ #ifndef REV_WL_FCB @@ -284,15 +312,27 @@ int is_depend(int sat1, int sat2, int *flgs, int *max_flg) else if (flgs[sat1 - 1] > flgs[sat2 - 1]) { for (i = 0; i < MAXSAT; i++) - if (flgs[i] == flgs[sat2 - 1]) flgs[i] = flgs[sat1 - 1]; + { + if (flgs[i] == flgs[sat2 - 1]) + { + flgs[i] = flgs[sat1 - 1]; + } + } } else if (flgs[sat1 - 1] < flgs[sat2 - 1]) { for (i = 0; i < MAXSAT; i++) - if (flgs[i] == flgs[sat1 - 1]) flgs[i] = flgs[sat2 - 1]; + { + if (flgs[i] == flgs[sat1 - 1]) + { + flgs[i] = flgs[sat2 - 1]; + } + } } else - return 0; /* linear depenent */ + { + return 0; /* linear depenent */ + } return 1; } @@ -304,18 +344,26 @@ int sel_amb(int *sat1, int *sat2, double *N, double *var, int n) /* sort by variance */ for (i = 0; i < n; i++) - for (j = 1; j < n - i; j++) - { - if (var[j] >= var[j - 1]) continue; - SWAP_I(sat1[j], sat1[j - 1]); - SWAP_I(sat2[j], sat2[j - 1]); - SWAP_D(N[j], N[j - 1]); - SWAP_D(var[j], var[j - 1]); - } + { + for (j = 1; j < n - i; j++) + { + if (var[j] >= var[j - 1]) + { + continue; + } + SWAP_I(sat1[j], sat1[j - 1]); + SWAP_I(sat2[j], sat2[j - 1]); + SWAP_D(N[j], N[j - 1]); + SWAP_D(var[j], var[j - 1]); + } + } /* select linearly independent satellite pair */ for (i = j = 0; i < n; i++) { - if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) continue; + if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) + { + continue; + } sat1[j] = sat1[i]; sat2[j] = sat2[i]; N[j] = N[i]; @@ -332,7 +380,10 @@ int fix_sol(rtk_t *rtk, const int *sat1, const int *sat2, double *v, *H, *R; int i, j, k, info; - if (n <= 0) return 0; + if (n <= 0) + { + return 0; + } v = zeros(n, 1); H = zeros(rtk->nx, n); @@ -385,8 +436,8 @@ int fix_amb_ROUND(rtk_t *rtk, int *sat1, int *sat2, const int *NW, int n) double C1, C2, B1, v1, BC, v, vc, *NC, *var, lam_NL = lam_LC(1, 1, 0), lam1, lam2; int i, j, k, m = 0, N1, stat; - lam1 = lam_carr[0]; - lam2 = lam_carr[1]; + lam1 = LAM_CARR[0]; + lam2 = LAM_CARR[1]; C1 = std::pow(lam2, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); C2 = -std::pow(lam1, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); @@ -419,7 +470,10 @@ int fix_amb_ROUND(rtk_t *rtk, int *sat1, int *sat2, const int *NW, int n) /* check residuals */ v = rtk->ssat[sat1[i] - 1].resc[0] - rtk->ssat[sat2[i] - 1].resc[0]; vc = v + (BC - (rtk->x[j] - rtk->x[k])); - if (fabs(vc) > THRES_RES) continue; + if (fabs(vc) > THRES_RES) + { + continue; + } sat1[m] = sat1[i]; sat2[m] = sat2[i]; @@ -444,8 +498,8 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) double C1, C2, *B1, *N1, *NC, *D, *E, *Q, s[2], lam_NL = lam_LC(1, 1, 0), lam1, lam2; int i, j, k, m = 0, info, stat, flgs[MAXSAT] = {0}, max_flg = 0; - lam1 = lam_carr[0]; - lam2 = lam_carr[1]; + lam1 = LAM_CARR[0]; + lam2 = LAM_CARR[1]; C1 = std::pow(lam2, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); C2 = -std::pow(lam1, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); @@ -460,7 +514,10 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) for (i = 0; i < n; i++) { /* check linear independency */ - if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) continue; + if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) + { + continue; + } j = IB_PPP(sat1[i], &rtk->opt); k = IB_PPP(sat2[i], &rtk->opt); @@ -470,7 +527,10 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) N1[m] = ROUND_PPP(B1[m]); /* validation of narrow-lane ambiguity */ - if (fabs(N1[m] - B1[m]) > rtk->opt.thresar[2]) continue; + if (fabs(N1[m] - B1[m]) > rtk->opt.thresar[2]) + { + continue; + } /* narrow-lane ambiguity transformation matrix */ D[j + m * rtk->nx] = 1.0 / lam_NL; @@ -518,7 +578,7 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) return 0; } - rtk->sol.ratio = (float)(MIN_PPP(s[1] / s[0], 999.9)); + rtk->sol.ratio = static_cast(MIN_PPP(s[1] / s[0], 999.9)); /* varidation by ratio-test */ if (rtk->opt.thresar[0] > 0.0 && rtk->sol.ratio < rtk->opt.thresar[0]) @@ -561,7 +621,10 @@ int pppamb(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav, double elmask; int i, j, m = 0, stat = 0, *NW, *sat1, *sat2; - if (n <= 0 || rtk->opt.ionoopt != IONOOPT_IFLC || rtk->opt.nf < 2) return 0; + if (n <= 0 || rtk->opt.ionoopt != IONOOPT_IFLC || rtk->opt.nf < 2) + { + return 0; + } trace(3, "pppamb: time=%s n=%d\n", time_str(obs[0].time, 0), n); @@ -576,20 +639,28 @@ int pppamb(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav, /* fix wide-lane ambiguity */ for (i = 0; i < n - 1; i++) - for (j = i + 1; j < n; j++) - { - if (!rtk->ssat[obs[i].sat - 1].vsat[0] || - !rtk->ssat[obs[j].sat - 1].vsat[0] || - azel[1 + i * 2] < elmask || azel[1 + j * 2] < elmask) continue; + { + for (j = i + 1; j < n; j++) + { + if (!rtk->ssat[obs[i].sat - 1].vsat[0] || + !rtk->ssat[obs[j].sat - 1].vsat[0] || + azel[1 + i * 2] < elmask || azel[1 + j * 2] < elmask) + { + continue; + } #if 0 /* test already fixed */ if (rtk->ambc[obs[i].sat-1].flags[obs[j].sat-1] && rtk->ambc[obs[j].sat-1].flags[obs[i].sat-1]) continue; #endif - sat1[m] = obs[i].sat; - sat2[m] = obs[j].sat; - if (fix_amb_WL(rtk, nav, sat1[m], sat2[m], NW + m)) m++; - } + sat1[m] = obs[i].sat; + sat2[m] = obs[j].sat; + if (fix_amb_WL(rtk, nav, sat1[m], sat2[m], NW + m)) + { + m++; + } + } + } /* fix narrow-lane ambiguity */ if (rtk->opt.modear == ARMODE_PPPAR) { @@ -614,7 +685,10 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) int i, j, week, nfreq = 1; char id[32]; - if (level <= 0 || !fp) return; + if (level <= 0 || !fp) + { + return; + } trace(3, "pppoutsolstat:\n"); @@ -653,13 +727,19 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) fprintf(fp, "$TRPG,%d,%.3f,%d,%d,%.5f,%.5f,%.5f,%.5f\n", week, tow, rtk->sol.stat, 1, rtk->x[i + 1], rtk->x[i + 2], 0.0, 0.0); } - if (rtk->sol.stat == SOLQ_NONE || level <= 1) return; + if (rtk->sol.stat == SOLQ_NONE || level <= 1) + { + return; + } /* residuals and status */ for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); for (j = 0; j < nfreq; j++) { @@ -673,277 +753,6 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) } -/* solar/lunar tides (ref [2] 7) ---------------------------------------------*/ -void tide_pl(const double *eu, const double *rp, double GMp, - const double *pos, double *dr) -{ - const double H3 = 0.292, L3 = 0.015; - double r, ep[3], latp, lonp, p, K2, K3, a, H2, L2, dp, du, cosp, sinl, cosl; - int i; - - trace(4, "tide_pl : pos=%.3f %.3f\n", pos[0] * R2D, pos[1] * R2D); - - if ((r = norm_rtk(rp, 3)) <= 0.0) return; - - for (i = 0; i < 3; i++) ep[i] = rp[i] / r; - - K2 = GMp / GME * std::pow(RE_WGS84, 2.0) * std::pow(RE_WGS84, 2.0) / (r * r * r); - K3 = K2 * RE_WGS84 / r; - latp = asin(ep[2]); - lonp = atan2(ep[1], ep[0]); - cosp = cos(latp); - sinl = sin(pos[0]); - cosl = cos(pos[0]); - - /* step1 in phase (degree 2) */ - p = (3.0 * sinl * sinl - 1.0) / 2.0; - H2 = 0.6078 - 0.0006 * p; - L2 = 0.0847 + 0.0002 * p; - a = dot(ep, eu, 3); - dp = K2 * 3.0 * L2 * a; - du = K2 * (H2 * (1.5 * a * a - 0.5) - 3.0 * L2 * a * a); - - /* step1 in phase (degree 3) */ - dp += K3 * L3 * (7.5 * a * a - 1.5); - du += K3 * (H3 * (2.5 * a * a * a - 1.5 * a) - L3 * (7.5 * a * a - 1.5) * a); - - /* step1 out-of-phase (only radial) */ - du += 3.0 / 4.0 * 0.0025 * K2 * sin(2.0 * latp) * sin(2.0 * pos[0]) * sin(pos[1] - lonp); - du += 3.0 / 4.0 * 0.0022 * K2 * cosp * cosp * cosl * cosl * sin(2.0 * (pos[1] - lonp)); - - dr[0] = dp * ep[0] + du * eu[0]; - dr[1] = dp * ep[1] + du * eu[1]; - dr[2] = dp * ep[2] + du * eu[2]; - - trace(5, "tide_pl : dr=%.3f %.3f %.3f\n", dr[0], dr[1], dr[2]); -} - - -/* displacement by solid earth tide (ref [2] 7) ------------------------------*/ -void tide_solid(const double *rsun, const double *rmoon, - const double *pos, const double *E, double gmst, int opt, - double *dr) -{ - double dr1[3], dr2[3], eu[3], du, dn, sinl, sin2l; - - trace(3, "tide_solid: pos=%.3f %.3f opt=%d\n", pos[0] * R2D, pos[1] * R2D, opt); - - /* step1: time domain */ - eu[0] = E[2]; - eu[1] = E[5]; - eu[2] = E[8]; - tide_pl(eu, rsun, GMS, pos, dr1); - tide_pl(eu, rmoon, GMM, pos, dr2); - - /* step2: frequency domain, only K1 radial */ - sin2l = sin(2.0 * pos[0]); - du = -0.012 * sin2l * sin(gmst + pos[1]); - - dr[0] = dr1[0] + dr2[0] + du * E[2]; - dr[1] = dr1[1] + dr2[1] + du * E[5]; - dr[2] = dr1[2] + dr2[2] + du * E[8]; - - /* eliminate permanent deformation */ - if (opt & 8) - { - sinl = sin(pos[0]); - du = 0.1196 * (1.5 * sinl * sinl - 0.5); - dn = 0.0247 * sin2l; - dr[0] += du * E[2] + dn * E[1]; - dr[1] += du * E[5] + dn * E[4]; - dr[2] += du * E[8] + dn * E[7]; - } - trace(5, "tide_solid: dr=%.3f %.3f %.3f\n", dr[0], dr[1], dr[2]); -} - - -/* displacement by ocean tide loading (ref [2] 7) ----------------------------*/ -void tide_oload(gtime_t tut, const double *odisp, double *denu) -{ - const double args[][5] = { - {1.40519E-4, 2.0, -2.0, 0.0, 0.00}, /* M2 */ - {1.45444E-4, 0.0, 0.0, 0.0, 0.00}, /* S2 */ - {1.37880E-4, 2.0, -3.0, 1.0, 0.00}, /* N2 */ - {1.45842E-4, 2.0, 0.0, 0.0, 0.00}, /* K2 */ - {0.72921E-4, 1.0, 0.0, 0.0, 0.25}, /* K1 */ - {0.67598E-4, 1.0, -2.0, 0.0, -0.25}, /* O1 */ - {0.72523E-4, -1.0, 0.0, 0.0, -0.25}, /* P1 */ - {0.64959E-4, 1.0, -3.0, 1.0, -0.25}, /* Q1 */ - {0.53234E-5, 0.0, 2.0, 0.0, 0.00}, /* Mf */ - {0.26392E-5, 0.0, 1.0, -1.0, 0.00}, /* Mm */ - {0.03982E-5, 2.0, 0.0, 0.0, 0.00} /* Ssa */ - }; - const double ep1975[] = {1975, 1, 1, 0, 0, 0}; - double ep[6], fday, days, t, t2, t3, a[5], ang, dp[3] = {0}; - int i, j; - - trace(3, "tide_oload:\n"); - - /* angular argument: see subroutine arg.f for reference [1] */ - time2epoch(tut, ep); - fday = ep[3] * 3600.0 + ep[4] * 60.0 + ep[5]; - ep[3] = ep[4] = ep[5] = 0.0; - days = timediff(epoch2time(ep), epoch2time(ep1975)) / 86400.0; - t = (27392.500528 + 1.000000035 * days) / 36525.0; - t2 = t * t; - t3 = t2 * t; - - a[0] = fday; - a[1] = (279.69668 + 36000.768930485 * t + 3.03E-4 * t2) * D2R; /* H0 */ - a[2] = (270.434358 + 481267.88314137 * t - 0.001133 * t2 + 1.9E-6 * t3) * D2R; /* S0 */ - a[3] = (334.329653 + 4069.0340329577 * t - 0.010325 * t2 - 1.2E-5 * t3) * D2R; /* P0 */ - a[4] = 2.0 * PI; - - /* displacements by 11 constituents */ - for (i = 0; i < 11; i++) - { - ang = 0.0; - for (j = 0; j < 5; j++) ang += a[j] * args[i][j]; - for (j = 0; j < 3; j++) dp[j] += odisp[j + i * 6] * cos(ang - odisp[j + 3 + i * 6] * D2R); - } - denu[0] = -dp[1]; - denu[1] = -dp[2]; - denu[2] = dp[0]; - - trace(5, "tide_oload: denu=%.3f %.3f %.3f\n", denu[0], denu[1], denu[2]); -} - - -/* iers mean pole (ref [7] eq.7.25) ------------------------------------------*/ -void iers_mean_pole(gtime_t tut, double *xp_bar, double *yp_bar) -{ - const double ep2000[] = {2000, 1, 1, 0, 0, 0}; - double y, y2, y3; - - y = timediff(tut, epoch2time(ep2000)) / 86400.0 / 365.25; - - if (y < 3653.0 / 365.25) - { /* until 2010.0 */ - y2 = y * y; - y3 = y2 * y; - *xp_bar = 55.974 + 1.8243 * y + 0.18413 * y2 + 0.007024 * y3; /* (mas) */ - *yp_bar = 346.346 + 1.7896 * y - 0.10729 * y2 - 0.000908 * y3; - } - else - { /* after 2010.0 */ - *xp_bar = 23.513 + 7.6141 * y; /* (mas) */ - *yp_bar = 358.891 - 0.6287 * y; - } -} - - -/* displacement by pole tide (ref [7] eq.7.26) --------------------------------*/ -void tide_pole(gtime_t tut, const double *pos, const double *erpv, - double *denu) -{ - double xp_bar, yp_bar, m1, m2, cosl, sinl; - - trace(3, "tide_pole: pos=%.3f %.3f\n", pos[0] * R2D, pos[1] * R2D); - - /* iers mean pole (mas) */ - iers_mean_pole(tut, &xp_bar, &yp_bar); - - /* ref [7] eq.7.24 */ - m1 = erpv[0] / AS2R - xp_bar * 1E-3; /* (as) */ - m2 = -erpv[1] / AS2R + yp_bar * 1E-3; - - /* sin(2*theta) = sin(2*phi), cos(2*theta)=-cos(2*phi) */ - cosl = cos(pos[1]); - sinl = sin(pos[1]); - denu[0] = 9E-3 * sin(pos[0]) * (m1 * sinl - m2 * cosl); /* de= Slambda (m) */ - denu[1] = -9E-3 * cos(2.0 * pos[0]) * (m1 * cosl + m2 * sinl); /* dn=-Stheta (m) */ - denu[2] = -33E-3 * sin(2.0 * pos[0]) * (m1 * cosl + m2 * sinl); /* du= Sr (m) */ - - trace(5, "tide_pole : denu=%.3f %.3f %.3f\n", denu[0], denu[1], denu[2]); -} - - -/* tidal displacement ---------------------------------------------------------- - * displacements by earth tides - * args : gtime_t tutc I time in utc - * double *rr I site position (ecef) (m) - * int opt I options (or of the followings) - * 1: solid earth tide - * 2: ocean tide loading - * 4: pole tide - * 8: elimate permanent deformation - * double *erp I earth rotation parameters (NULL: not used) - * double *odisp I ocean loading parameters (NULL: not used) - * odisp[0+i*6]: consituent i amplitude radial(m) - * odisp[1+i*6]: consituent i amplitude west (m) - * odisp[2+i*6]: consituent i amplitude south (m) - * odisp[3+i*6]: consituent i phase radial (deg) - * odisp[4+i*6]: consituent i phase west (deg) - * odisp[5+i*6]: consituent i phase south (deg) - * (i=0:M2,1:S2,2:N2,3:K2,4:K1,5:O1,6:P1,7:Q1, - * 8:Mf,9:Mm,10:Ssa) - * double *dr O displacement by earth tides (ecef) (m) - * return : none - * notes : see ref [1], [2] chap 7 - * see ref [4] 5.2.1, 5.2.2, 5.2.3 - * ver.2.4.0 does not use ocean loading and pole tide corrections - *-----------------------------------------------------------------------------*/ -void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, - const double *odisp, double *dr) -{ - gtime_t tut; - double pos[2], E[9], drt[3], denu[3], rs[3], rm[3], gmst, erpv[5] = {0}; - int i; -#ifdef IERS_MODEL - double ep[6], fhr; - int year, mon, day; -#endif - - trace(3, "tidedisp: tutc=%s\n", time_str(tutc, 0)); - - if (erp) geterp(erp, tutc, erpv); - - tut = timeadd(tutc, erpv[2]); - - dr[0] = dr[1] = dr[2] = 0.0; - - if (norm_rtk(rr, 3) <= 0.0) return; - - pos[0] = asin(rr[2] / norm_rtk(rr, 3)); - pos[1] = atan2(rr[1], rr[0]); - xyz2enu(pos, E); - - if (opt & 1) - { /* solid earth tides */ - - /* sun and moon position in ecef */ - sunmoonpos(tutc, erpv, rs, rm, &gmst); - -#ifdef IERS_MODEL - time2epoch(tutc, ep); - year = (int)ep[0]; - mon = (int)ep[1]; - day = (int)ep[2]; - fhr = ep[3] + ep[4] / 60.0 + ep[5] / 3600.0; - - /* call DEHANTTIDEINEL */ - dehanttideinel_((double *)rr, &year, &mon, &day, &fhr, rs, rm, drt); -#else - tide_solid(rs, rm, pos, E, gmst, opt, drt); -#endif - for (i = 0; i < 3; i++) dr[i] += drt[i]; - } - if ((opt & 2) && odisp) - { /* ocean tide loading */ - tide_oload(tut, odisp, denu); - matmul("TN", 3, 1, 3, 1.0, E, denu, 0.0, drt); - for (i = 0; i < 3; i++) dr[i] += drt[i]; - } - if ((opt & 4) && erp) - { /* pole tide */ - tide_pole(tut, pos, erpv, denu); - matmul("TN", 3, 1, 3, 1.0, E, denu, 0.0, drt); - for (i = 0; i < 3; i++) dr[i] += drt[i]; - } - trace(5, "tidedisp: dr=%.3f %.3f %.3f\n", dr[0], dr[1], dr[2]); -} - - /* exclude meas of eclipsing satellite (block IIA) ---------------------------*/ void testeclipse(const obsd_t *obs, int n, const nav_t *nav, double *rs) { @@ -954,17 +763,26 @@ void testeclipse(const obsd_t *obs, int n, const nav_t *nav, double *rs) trace(3, "testeclipse:\n"); /* unit vector of sun direction (ecef) */ - sunmoonpos(gpst2utc(obs[0].time), erpv, rsun, NULL, NULL); - if (normv3(rsun, esun) == 0) trace(1, "Error computing the norm"); + sunmoonpos(gpst2utc(obs[0].time), erpv, rsun, nullptr, nullptr); + if (normv3(rsun, esun) == 0) + { + trace(1, "Error computing the norm"); + } for (i = 0; i < n; i++) { type = nav->pcvs[obs[i].sat - 1].type; - if ((r = norm_rtk(rs + i * 6, 3)) <= 0.0) continue; + if ((r = norm_rtk(rs + i * 6, 3)) <= 0.0) + { + continue; + } #if 1 /* only block IIA */ - if (*type && !strstr(type, "BLOCK IIA")) continue; + if (*type && !strstr(type, "BLOCK IIA")) + { + continue; + } #endif /* sun-earth-satellite angle */ cosa = dot(rs + i * 6, esun, 3) / r; @@ -972,12 +790,18 @@ void testeclipse(const obsd_t *obs, int n, const nav_t *nav, double *rs) ang = acos(cosa); /* test eclipse */ - if (ang < PI / 2.0 || r * sin(ang) > RE_WGS84) continue; + if (ang < PI / 2.0 || r * sin(ang) > RE_WGS84) + { + continue; + } trace(2, "eclipsing sat excluded %s sat=%2d\n", time_str(obs[0].time, 0), obs[i].sat); - for (j = 0; j < 3; j++) rs[j + i * 6] = 0.0; + for (j = 0; j < 3; j++) + { + rs[j + i * 6] = 0.0; + } } } @@ -1016,9 +840,15 @@ double varerr(int sat __attribute__((unused)), int sys, double el, int type, con } else { /* normal error model */ - if (type == 1) fact *= opt->eratio[0]; + if (type == 1) + { + fact *= opt->eratio[0]; + } fact *= sys == SYS_GLO ? EFACT_GLO : (sys == SYS_SBS ? EFACT_SBS : EFACT_GPS); - if (opt->ionoopt == IONOOPT_IFLC) fact *= 3.0; + if (opt->ionoopt == IONOOPT_IFLC) + { + fact *= 3.0; + } a = fact * opt->err[1]; b = fact * opt->err[2]; } @@ -1050,9 +880,15 @@ int ifmeas(const obsd_t *obs, const nav_t *nav, const double *azel, trace(4, "ifmeas :\n"); /* L1-L2 for GPS/GLO/QZS, L1-L5 for GAL/SBS */ - if (NFREQ >= 3 && (satsys(obs->sat, NULL) & (SYS_GAL | SYS_SBS))) j = 2; + if (NFREQ >= 3 && (satsys(obs->sat, nullptr) & (SYS_GAL | SYS_SBS))) + { + j = 2; + } - if (NFREQ < 2 || lam[i] == 0.0 || lam[j] == 0.0) return 0; + if (NFREQ < 2 || lam[i] == 0.0 || lam[j] == 0.0) + { + return 0; + } /* test snr mask */ if (testsnr(0, i, azel[1], obs->SNR[i] * 0.25, &opt->snrmask) || @@ -1074,29 +910,47 @@ int ifmeas(const obsd_t *obs, const nav_t *nav, const double *azel, { P1_C1 = nav->lexeph[obs->sat - 1].isc[0] * SPEED_OF_LIGHT; /* ISC_L1C/A */ } - if (L1 == 0.0 || L2 == 0.0 || P1 == 0.0 || P2 == 0.0) return 0; + if (L1 == 0.0 || L2 == 0.0 || P1 == 0.0 || P2 == 0.0) + { + return 0; + } /* iono-free phase with windup correction */ meas[0] = c1 * L1 + c2 * L2 - (c1 * lam[i] + c2 * lam[j]) * phw; /* iono-free code with dcb correction */ - if (obs->code[i] == CODE_L1C) P1 += P1_C1; /* C1->P1 */ - if (obs->code[j] == CODE_L2C) P2 += P2_C2; /* C2->P2 */ + if (obs->code[i] == CODE_L1C) + { + P1 += P1_C1; /* C1->P1 */ + } + if (obs->code[j] == CODE_L2C) + { + P2 += P2_C2; /* C2->P2 */ + } meas[1] = c1 * P1 + c2 * P2; var[1] = std::pow(ERR_CBIAS, 2.0); - if (opt->sateph == EPHOPT_SBAS) meas[1] -= P1_C1; /* sbas clock based C1 */ + if (opt->sateph == EPHOPT_SBAS) + { + meas[1] -= P1_C1; /* sbas clock based C1 */ + } /* gps-glonass h/w bias correction for code */ - if (opt->exterr.ena[3] && satsys(obs->sat, NULL) == SYS_GLO) + if (opt->exterr.ena[3] && satsys(obs->sat, nullptr) == SYS_GLO) { meas[1] += c1 * opt->exterr.gpsglob[0] + c2 * opt->exterr.gpsglob[1]; } /* antenna phase center variation correction */ for (k = 0; k < 2; k++) { - if (dants) meas[k] -= c1 * dants[i] + c2 * dants[j]; - if (dantr) meas[k] -= c1 * dantr[i] + c2 * dantr[j]; + if (dants) + { + meas[k] -= c1 * dants[i] + c2 * dants[j]; + } + if (dantr) + { + meas[k] -= c1 * dantr[i] + c2 * dantr[j]; + } } return 1; } @@ -1108,7 +962,10 @@ double gettgd_ppp(int sat, const nav_t *nav) int i; for (i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].tgd[0]; } return 0.0; @@ -1173,9 +1030,15 @@ int corrmeas(const obsd_t *obs, const nav_t *nav, const double *pos, { return ifmeas(obs, nav, azel, opt, dantr, dants, phw, meas, var); } - if (lam[0] == 0.0 || obs->L[0] == 0.0 || obs->P[0] == 0.0) return 0; + if (lam[0] == 0.0 || obs->L[0] == 0.0 || obs->P[0] == 0.0) + { + return 0; + } - if (testsnr(0, 0, azel[1], obs->SNR[0] * 0.25, &opt->snrmask)) return 0; + if (testsnr(0, 0, azel[1], obs->SNR[0] * 0.25, &opt->snrmask)) + { + return 0; + } L1 = obs->L[0] * lam[0]; P1 = obs->P[0]; @@ -1184,12 +1047,15 @@ int corrmeas(const obsd_t *obs, const nav_t *nav, const double *pos, gamma = std::pow(lam[1] / lam[0], 2.0); /* f1^2/f2^2 */ P1_P2 = nav->cbias[obs->sat - 1][0]; P1_C1 = nav->cbias[obs->sat - 1][1]; - if (P1_P2 == 0.0 && (satsys(obs->sat, NULL) & (SYS_GPS | SYS_GAL | SYS_QZS))) + if (P1_P2 == 0.0 && (satsys(obs->sat, nullptr) & (SYS_GPS | SYS_GAL | SYS_QZS))) { P1_P2 = (1.0 - gamma) * gettgd_ppp(obs->sat, nav); } - if (obs->code[0] == CODE_L1C) P1 += P1_C1; /* C1->P1 */ - PC = P1 - P1_P2 / (1.0 - gamma); /* P1->PC */ + if (obs->code[0] == CODE_L1C) + { + P1 += P1_C1; /* C1->P1 */ + } + PC = P1 - P1_P2 / (1.0 - gamma); /* P1->PC */ /* slant ionospheric delay L1 (m) */ if (!corr_ion(obs->time, nav, obs->sat, pos, azel, opt->ionoopt, &ion, &vari, brk)) @@ -1208,8 +1074,14 @@ int corrmeas(const obsd_t *obs, const nav_t *nav, const double *pos, /* antenna phase center variation correction */ for (i = 0; i < 2; i++) { - if (dants) meas[i] -= dants[0]; - if (dantr) meas[i] -= dantr[0]; + if (dants) + { + meas[i] -= dants[0]; + } + if (dantr) + { + meas[i] -= dantr[0]; + } } return 1; } @@ -1220,7 +1092,10 @@ double gfmeas(const obsd_t *obs, const nav_t *nav) { const double *lam = nav->lam[obs->sat - 1]; - if (lam[0] == 0.0 || lam[1] == 0.0 || obs->L[0] == 0.0 || obs->L[1] == 0.0) return 0.0; + if (lam[0] == 0.0 || lam[1] == 0.0 || obs->L[0] == 0.0 || obs->L[1] == 0.0) + { + return 0.0; + } return lam[0] * obs->L[0] - lam[1] * obs->L[1]; } @@ -1236,16 +1111,25 @@ void udpos_ppp(rtk_t *rtk) /* fixed mode */ if (rtk->opt.mode == PMODE_PPP_FIXED) { - for (i = 0; i < 3; i++) initx(rtk, rtk->opt.ru[i], 1E-8, i); + for (i = 0; i < 3; i++) + { + initx(rtk, rtk->opt.ru[i], 1E-8, i); + } return; } /* initialize position for first epoch */ if (norm_rtk(rtk->x, 3) <= 0.0) { - for (i = 0; i < 3; i++) initx(rtk, rtk->sol.rr[i], VAR_POS_PPP, i); + for (i = 0; i < 3; i++) + { + initx(rtk, rtk->sol.rr[i], VAR_POS_PPP, i); + } } /* static ppp mode */ - if (rtk->opt.mode == PMODE_PPP_STATIC) return; + if (rtk->opt.mode == PMODE_PPP_STATIC) + { + return; + } /* kinmatic mode without dynamics */ for (i = 0; i < 3; i++) @@ -1297,7 +1181,10 @@ void udtrop_ppp(rtk_t *rtk) if (rtk->opt.tropopt >= TROPOPT_ESTG) { - for (j = 0; j < 2; j++) initx(rtk, 1E-6, VAR_GRA_PPP, ++i); + for (j = 0; j < 2; j++) + { + initx(rtk, 1E-6, VAR_GRA_PPP, ++i); + } } } else @@ -1323,14 +1210,19 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int n) trace(3, "detslp_ll: n=%d\n", n); for (i = 0; i < n && i < MAXOBS; i++) - for (j = 0; j < rtk->opt.nf; j++) - { - if (obs[i].L[j] == 0.0 || !(obs[i].LLI[j] & 3)) continue; + { + for (j = 0; j < rtk->opt.nf; j++) + { + if (obs[i].L[j] == 0.0 || !(obs[i].LLI[j] & 3)) + { + continue; + } - trace(3, "detslp_ll: slip detected sat=%2d f=%d\n", obs[i].sat, j + 1); + trace(3, "detslp_ll: slip detected sat=%2d f=%d\n", obs[i].sat, j + 1); - rtk->ssat[obs[i].sat - 1].slip[j] = 1; - } + rtk->ssat[obs[i].sat - 1].slip[j] = 1; + } + } } @@ -1344,7 +1236,10 @@ void detslp_gf(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < n && i < MAXOBS; i++) { - if ((g1 = gfmeas(obs + i, nav)) == 0.0) continue; + if ((g1 = gfmeas(obs + i, nav)) == 0.0) + { + continue; + } g0 = rtk->ssat[obs[i].sat - 1].gf; rtk->ssat[obs[i].sat - 1].gf = g1; @@ -1356,7 +1251,10 @@ void detslp_gf(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) trace(3, "detslip_gf: slip detected sat=%2d gf=%8.3f->%8.3f\n", obs[i].sat, g0, g1); - for (j = 0; j < rtk->opt.nf; j++) rtk->ssat[obs[i].sat - 1].slip[j] |= 1; + for (j = 0; j < rtk->opt.nf; j++) + { + rtk->ssat[obs[i].sat - 1].slip[j] |= 1; + } } } } @@ -1371,10 +1269,12 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) trace(3, "udbias : n=%d\n", n); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < rtk->opt.nf; j++) - { - rtk->ssat[i].slip[j] = 0; - } + { + for (j = 0; j < rtk->opt.nf; j++) + { + rtk->ssat[i].slip[j] = 0; + } + } /* detect cycle slip by LLI */ detslp_ll(rtk, obs, n); @@ -1384,7 +1284,7 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) /* reset phase-bias if expire obs outage counter */ for (i = 0; i < MAXSAT; i++) { - if (++rtk->ssat[i].outc[0] > (unsigned int)rtk->opt.maxout) + if (++rtk->ssat[i].outc[0] > static_cast(rtk->opt.maxout)) { initx(rtk, 0.0, 0.0, IB_PPP(i + 1, &rtk->opt)); } @@ -1395,8 +1295,11 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) { sat = obs[i].sat; j = IB_PPP(sat, &rtk->opt); - if (!corrmeas(obs + i, nav, pos, rtk->ssat[sat - 1].azel, &rtk->opt, NULL, NULL, - 0.0, meas, var, &brk)) continue; + if (!corrmeas(obs + i, nav, pos, rtk->ssat[sat - 1].azel, &rtk->opt, nullptr, nullptr, + 0.0, meas, var, &brk)) + { + continue; + } if (brk) { @@ -1405,7 +1308,10 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) } bias[i] = meas[0] - meas[1]; if (rtk->x[j] == 0.0 || - rtk->ssat[sat - 1].slip[0] || rtk->ssat[sat - 1].slip[1]) continue; + rtk->ssat[sat - 1].slip[0] || rtk->ssat[sat - 1].slip[1]) + { + continue; + } offset += bias[i] - rtk->x[j]; k++; } @@ -1415,7 +1321,10 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < MAXSAT; i++) { j = IB_PPP(i + 1, &rtk->opt); - if (rtk->x[j] != 0.0) rtk->x[j] += offset / k; + if (rtk->x[j] != 0.0) + { + rtk->x[j] += offset / k; + } } trace(2, "phase-code jump corrected: %s n=%2d dt=%12.9fs\n", time_str(rtk->sol.time, 0), k, offset / k / SPEED_OF_LIGHT); @@ -1428,9 +1337,15 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) rtk->P[j + j * rtk->nx] += std::pow(rtk->opt.prn[0], 2.0) * fabs(rtk->tt); if (rtk->x[j] != 0.0 && - !rtk->ssat[sat - 1].slip[0] && !rtk->ssat[sat - 1].slip[1]) continue; + !rtk->ssat[sat - 1].slip[0] && !rtk->ssat[sat - 1].slip[1]) + { + continue; + } - if (bias[i] == 0.0) continue; + if (bias[i] == 0.0) + { + continue; + } /* reinitialize phase-bias if detecting cycle slip */ initx(rtk, bias[i], VAR_BIAS, IB_PPP(sat, &rtk->opt)); @@ -1473,7 +1388,10 @@ void satantpcv(const double *rs, const double *rr, const pcv_t *pcv, ru[i] = rr[i] - rs[i]; rz[i] = -rs[i]; } - if (!normv3(ru, eu) || !normv3(rz, ez)) return; + if (!normv3(ru, eu) || !normv3(rz, ez)) + { + return; + } cosa = dot(eu, ez, 3); cosa = cosa < -1.0 ? -1.0 : (cosa > 1.0 ? 1.0 : cosa); @@ -1526,9 +1444,15 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do trace(3, "res_ppp : n=%d nx=%d\n", n, nx); - for (i = 0; i < MAXSAT; i++) rtk->ssat[i].vsat[0] = 0; + for (i = 0; i < MAXSAT; i++) + { + rtk->ssat[i].vsat[0] = 0; + } - for (i = 0; i < 3; i++) rr[i] = x[i]; + for (i = 0; i < 3; i++) + { + rr[i] = x[i]; + } /* earth tides correction */ if (opt->tidecorr) @@ -1537,21 +1461,33 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do tidedisp(gpst2utc(obs[0].time), rr, tideopt, &nav->erp, opt->odisp[0], disp); - for (i = 0; i < 3; i++) rr[i] += disp[i]; + for (i = 0; i < 3; i++) + { + rr[i] += disp[i]; + } } ecef2pos(rr, pos); for (i = 0; i < n && i < MAXOBS; i++) { sat = obs[i].sat; - if (!(sys = satsys(sat, NULL)) || !rtk->ssat[sat - 1].vs) continue; + if (!(sys = satsys(sat, nullptr)) || !rtk->ssat[sat - 1].vs) + { + continue; + } /* geometric distance/azimuth/elevation angle */ if ((r = geodist(rs + i * 6, rr, e)) <= 0.0 || - satazel(pos, e, azel + i * 2) < opt->elmin) continue; + satazel(pos, e, azel + i * 2) < opt->elmin) + { + continue; + } /* excluded satellite? */ - if (satexclude(obs[i].sat, svh[i], opt)) continue; + if (satexclude(obs[i].sat, svh[i], opt)) + { + continue; + } /* tropospheric delay correction */ if (opt->tropopt == TROPOPT_SAAS) @@ -1600,13 +1536,22 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do for (j = 0; j < 2; j++) { /* for phase and code */ - if (meas[j] == 0.0) continue; + if (meas[j] == 0.0) + { + continue; + } - for (k = 0; k < nx; k++) H[k + nx * nv] = 0.0; + for (k = 0; k < nx; k++) + { + H[k + nx * nv] = 0.0; + } v[nv] = meas[j] - r; - for (k = 0; k < 3; k++) H[k + nx * nv] = -e[k]; + for (k = 0; k < 3; k++) + { + H[k + nx * nv] = -e[k]; + } if (sys != SYS_GLO) { @@ -1633,9 +1578,13 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do var[nv] = varerr(obs[i].sat, sys, azel[1 + i * 2], j, opt) + varm[j] + vare[i] + vart; if (j == 0) - rtk->ssat[sat - 1].resc[0] = v[nv]; + { + rtk->ssat[sat - 1].resc[0] = v[nv]; + } else - rtk->ssat[sat - 1].resp[0] = v[nv]; + { + rtk->ssat[sat - 1].resp[0] = v[nv]; + } /* test innovation */ #if 0 @@ -1650,15 +1599,20 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do rtk->ssat[sat - 1].rejc[0]++; continue; } - if (j == 0) rtk->ssat[sat - 1].vsat[0] = 1; + if (j == 0) + { + rtk->ssat[sat - 1].vsat[0] = 1; + } nv++; } } for (i = 0; i < nv; i++) - for (j = 0; j < nv; j++) - { - R[i + j * nv] = i == j ? var[i] : 0.0; - } + { + for (j = 0; j < nv; j++) + { + R[i + j * nv] = i == j ? var[i] : 0.0; + } + } trace(5, "x=\n"); tracemat(5, x, 1, nx, 8, 3); trace(5, "v=\n"); @@ -1692,7 +1646,10 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) var = mat(1, n); azel = zeros(2, n); - for (i = 0; i < MAXSAT; i++) rtk->ssat[i].fix[0] = 0; + for (i = 0; i < MAXSAT; i++) + { + rtk->ssat[i].fix[0] = 0; + } /* temporal update of states */ udstate_ppp(rtk, obs, n, nav); @@ -1719,7 +1676,10 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < rtk->opt.niter; i++) { /* phase and code residuals */ - if ((nv = res_ppp(i, obs, n, rs, dts, var, svh, nav, xp, rtk, v, H, R, azel)) <= 0) break; + if ((nv = res_ppp(i, obs, n, rs, dts, var, svh, nav, xp, rtk, v, H, R, azel)) <= 0) + { + break; + } /* measurement update */ matcpy(Pp, rtk->P, rtk->nx, rtk->nx); @@ -1746,13 +1706,19 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) /* ambiguity resolution in ppp */ if (opt->modear == ARMODE_PPPAR || opt->modear == ARMODE_PPPAR_ILS) { - if (pppamb(rtk, obs, n, nav, azel)) stat = SOLQ_FIX; + if (pppamb(rtk, obs, n, nav, azel)) + { + stat = SOLQ_FIX; + } } /* update solution status */ rtk->sol.ns = 0; for (i = 0; i < n && i < MAXOBS; i++) { - if (!rtk->ssat[obs[i].sat - 1].vsat[0]) continue; + if (!rtk->ssat[obs[i].sat - 1].vsat[0]) + { + continue; + } rtk->ssat[obs[i].sat - 1].lock[0]++; rtk->ssat[obs[i].sat - 1].outc[0] = 0; rtk->ssat[obs[i].sat - 1].fix[0] = 4; @@ -1763,11 +1729,11 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < 3; i++) { rtk->sol.rr[i] = rtk->x[i]; - rtk->sol.qr[i] = (float)rtk->P[i + i * rtk->nx]; + rtk->sol.qr[i] = static_cast(rtk->P[i + i * rtk->nx]); } - rtk->sol.qr[3] = (float)rtk->P[1]; - rtk->sol.qr[4] = (float)rtk->P[2 + rtk->nx]; - rtk->sol.qr[5] = (float)rtk->P[2]; + rtk->sol.qr[3] = static_cast(rtk->P[1]); + rtk->sol.qr[4] = static_cast(rtk->P[2 + rtk->nx]); + rtk->sol.qr[5] = static_cast(rtk->P[2]); rtk->sol.dtr[0] = rtk->x[IC_PPP(0, opt)]; rtk->sol.dtr[1] = rtk->x[IC_PPP(1, opt)] - rtk->x[IC_PPP(0, opt)]; for (i = 0; i < n && i < MAXOBS; i++) @@ -1776,7 +1742,10 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) } for (i = 0; i < MAXSAT; i++) { - if (rtk->ssat[i].slip[0] & 3) rtk->ssat[i].slipc[0]++; + if (rtk->ssat[i].slip[0] & 3) + { + rtk->ssat[i].slipc[0]++; + } } } free(rs); diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.h b/src/algorithms/libs/rtklib/rtklib_ppp.h index 8d90c3b3e..cd8449e1a 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.h +++ b/src/algorithms/libs/rtklib/rtklib_ppp.h @@ -129,21 +129,6 @@ int pppamb(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav, const double /* functions originally included in RTKLIB/src/ppp.c v2.4.2 */ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp); -void tide_pl(const double *eu, const double *rp, double GMp, const double *pos, double *dr); - -void tide_solid(const double *rsun, const double *rmoon, - const double *pos, const double *E, double gmst, int opt, - double *dr); - -void tide_oload(gtime_t tut, const double *odisp, double *denu); - -void iers_mean_pole(gtime_t tut, double *xp_bar, double *yp_bar); - -void tide_pole(gtime_t tut, const double *pos, const double *erpv, double *denu); - -void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, - const double *odisp, double *dr); - void testeclipse(const obsd_t *obs, int n, const nav_t *nav, double *rs); double varerr(int sat, int sys, double el, int type, const prcopt_t *opt); diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 293d86543..61217a8ae 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -62,16 +62,35 @@ #include "rtklib_preceph.h" #include "rtklib_rtkcmn.h" +#include /* satellite code to satellite system ----------------------------------------*/ int code2sys(char code) { - if (code == 'G' || code == ' ') return SYS_GPS; - if (code == 'R') return SYS_GLO; - if (code == 'E') return SYS_GAL; /* extension to sp3-c */ - if (code == 'J') return SYS_QZS; /* extension to sp3-c */ - if (code == 'C') return SYS_BDS; /* extension to sp3-c */ - if (code == 'L') return SYS_LEO; /* extension to sp3-c */ + if (code == 'G' || code == ' ') + { + return SYS_GPS; + } + if (code == 'R') + { + return SYS_GLO; + } + if (code == 'E') + { + return SYS_GAL; /* extension to sp3-c */ + } + if (code == 'J') + { + return SYS_QZS; /* extension to sp3-c */ + } + if (code == 'C') + { + return SYS_BDS; /* extension to sp3-c */ + } + if (code == 'L') + { + return SYS_LEO; /* extension to sp3-c */ + } return SYS_NONE; } @@ -87,24 +106,33 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, for (i = 0; i < 22; i++) { - if (!fgets(buff, sizeof(buff), fp)) break; + if (!fgets(buff, sizeof(buff), fp)) + { + break; + } if (i == 0) { *type = buff[2]; - if (str2time(buff, 3, 28, time)) return 0; + if (str2time(buff, 3, 28, time)) + { + return 0; + } } else if (2 <= i && i <= 6) { if (i == 2) { - ns = (int)str2num(buff, 4, 2); + ns = static_cast(str2num(buff, 4, 2)); } for (j = 0; j < 17 && k < ns; j++) { sys = code2sys(buff[9 + 3 * j]); - prn = (int)str2num(buff, 10 + 3 * j, 2); - if (k < MAXSAT) sats[k++] = satno(sys, prn); + prn = static_cast(str2num(buff, 10 + 3 * j, 2)); + if (k < MAXSAT) + { + sats[k++] = satno(sys, prn); + } } } else if (i == 12) @@ -130,11 +158,11 @@ int addpeph(nav_t *nav, peph_t *peph) if (nav->ne >= nav->nemax) { nav->nemax += 256; - if (!(nav_peph = (peph_t *)realloc(nav->peph, sizeof(peph_t) * nav->nemax))) + if (!(nav_peph = static_cast(realloc(nav->peph, sizeof(peph_t) * nav->nemax)))) { trace(1, "readsp3b malloc error n=%d\n", nav->nemax); free(nav->peph); - nav->peph = NULL; + nav->peph = nullptr; nav->ne = nav->nemax = 0; return 0; } @@ -146,7 +174,7 @@ int addpeph(nav_t *nav, peph_t *peph) /* read sp3 body -------------------------------------------------------------*/ -void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, double *bfact, +void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, const double *bfact, char *tsys, int index, int opt, nav_t *nav) { peph_t peph; @@ -159,14 +187,20 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do while (fgets(buff, sizeof(buff), fp)) { - if (!strncmp(buff, "EOF", 3)) break; + if (!strncmp(buff, "EOF", 3)) + { + break; + } if (buff[0] != '*' || str2time(buff, 3, 28, &time)) { trace(2, "sp3 invalid epoch %31.31s\n", buff); continue; } - if (!strcmp(tsys, "UTC")) time = utc2gpst(time); /* utc->gpst */ + if (!strcmp(tsys, "UTC")) + { + time = utc2gpst(time); /* utc->gpst */ + } peph.time = time; peph.index = index; @@ -187,16 +221,26 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do } for (i = pred_o = pred_c = v = 0; i < n && fgets(buff, sizeof(buff), fp); i++) { - if (strlen(buff) < 4 || (buff[0] != 'P' && buff[0] != 'V')) continue; + if (strlen(buff) < 4 || (buff[0] != 'P' && buff[0] != 'V')) + { + continue; + } sys = buff[1] == ' ' ? SYS_GPS : code2sys(buff[1]); - prn = (int)str2num(buff, 2, 2); + prn = static_cast(str2num(buff, 2, 2)); if (sys == SYS_SBS) - prn += 100; + { + prn += 100; + } else if (sys == SYS_QZS) - prn += 192; /* extension to sp3-c */ + { + prn += 192; /* extension to sp3-c */ + } - if (!(sat = satno(sys, prn))) continue; + if (!(sat = satno(sys, prn))) + { + continue; + } if (buff[0] == 'P') { @@ -206,10 +250,22 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do for (j = 0; j < 4; j++) { /* read option for predicted value */ - if (j < 3 && (opt & 1) && pred_o) continue; - if (j < 3 && (opt & 2) && !pred_o) continue; - if (j == 3 && (opt & 1) && pred_c) continue; - if (j == 3 && (opt & 2) && !pred_c) continue; + if (j < 3 && (opt & 1) && pred_o) + { + continue; + } + if (j < 3 && (opt & 2) && !pred_o) + { + continue; + } + if (j == 3 && (opt & 1) && pred_c) + { + continue; + } + if (j == 3 && (opt & 2) && !pred_c) + { + continue; + } val = str2num(buff, 4 + j * 14, 14); std = str2num(buff, 61 + j * 3, j < 3 ? 2 : 3); @@ -223,7 +279,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do } if ((base = bfact[j < 3 ? 0 : 1]) > 0.0 && std > 0.0) { - peph.std[sat - 1][j] = (float)(std::pow(base, std) * (j < 3 ? 1e-3 : 1e-12)); + peph.std[sat - 1][j] = static_cast(std::pow(base, std) * (j < 3 ? 1e-3 : 1e-12)); } } else if (v) @@ -234,14 +290,17 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do } if ((base = bfact[j < 3 ? 0 : 1]) > 0.0 && std > 0.0) { - peph.vst[sat - 1][j] = (float)(std::pow(base, std) * (j < 3 ? 1e-7 : 1e-16)); + peph.vst[sat - 1][j] = static_cast(std::pow(base, std) * (j < 3 ? 1e-7 : 1e-16)); } } } } if (v) { - if (!addpeph(nav, &peph)) return; + if (!addpeph(nav, &peph)) + { + return; + } } } } @@ -250,7 +309,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do /* compare precise ephemeris -------------------------------------------------*/ int cmppeph(const void *p1, const void *p2) { - peph_t *q1 = (peph_t *)p1, *q2 = (peph_t *)p2; + auto *q1 = (peph_t *)p1, *q2 = (peph_t *)p2; double tt = timediff(q1->time, q2->time); return tt < -1e-9 ? -1 : (tt > 1e-9 ? 1 : q1->index - q2->index); } @@ -265,7 +324,10 @@ void combpeph(nav_t *nav, int opt) qsort(nav->peph, nav->ne, sizeof(peph_t), cmppeph); - if (opt & 4) return; + if (opt & 4) + { + return; + } for (i = 0, j = 1; j < nav->ne; j++) { @@ -273,15 +335,32 @@ void combpeph(nav_t *nav, int opt) { for (k = 0; k < MAXSAT; k++) { - if (norm_rtk(nav->peph[j].pos[k], 4) <= 0.0) continue; - for (m = 0; m < 4; m++) nav->peph[i].pos[k][m] = nav->peph[j].pos[k][m]; - for (m = 0; m < 4; m++) nav->peph[i].std[k][m] = nav->peph[j].std[k][m]; - for (m = 0; m < 4; m++) nav->peph[i].vel[k][m] = nav->peph[j].vel[k][m]; - for (m = 0; m < 4; m++) nav->peph[i].vst[k][m] = nav->peph[j].vst[k][m]; + if (norm_rtk(nav->peph[j].pos[k], 4) <= 0.0) + { + continue; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].pos[k][m] = nav->peph[j].pos[k][m]; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].std[k][m] = nav->peph[j].std[k][m]; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].vel[k][m] = nav->peph[j].vel[k][m]; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].vst[k][m] = nav->peph[j].vst[k][m]; + } } } else if (++i < j) - nav->peph[i] = nav->peph[j]; + { + nav->peph[i] = nav->peph[j]; + } } nav->ne = i + 1; @@ -315,9 +394,12 @@ void readsp3(const char *file, nav_t *nav, int opt) for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return; } } @@ -326,12 +408,18 @@ void readsp3(const char *file, nav_t *nav, int opt) for (i = j = 0; i < n; i++) { - if (!(ext = strrchr(efiles[i], '.'))) continue; + if (!(ext = strrchr(efiles[i], '.'))) + { + continue; + } if (!strstr(ext + 1, "sp3") && !strstr(ext + 1, ".SP3") && - !strstr(ext + 1, "eph") && !strstr(ext + 1, ".EPH")) continue; + !strstr(ext + 1, "eph") && !strstr(ext + 1, ".EPH")) + { + continue; + } - if (!(fp = fopen(efiles[i], "r"))) + if (!(fp = fopen(efiles[i], "re"))) { trace(2, "sp3 file open error %s\n", efiles[i]); continue; @@ -344,10 +432,16 @@ void readsp3(const char *file, nav_t *nav, int opt) fclose(fp); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } /* combine precise ephemeris */ - if (nav->ne > 0) combpeph(nav, opt); + if (nav->ne > 0) + { + combpeph(nav, opt); + } } @@ -361,13 +455,16 @@ void readsp3(const char *file, nav_t *nav, int opt) *-----------------------------------------------------------------------------*/ int readsap(const char *file, gtime_t time, nav_t *nav) { - pcvs_t pcvs = {0, 0, (pcv_t *){0}}; + pcvs_t pcvs = {0, 0, (pcv_t *){nullptr}}; pcv_t pcv0 = {0, {}, {}, {0, 0}, {0, 0}, {{}, {}}, {{}, {}}}, *pcv; int i; trace(3, "readsap : file=%s time=%s\n", file, time_str(time, 0)); - if (!readpcv(file, &pcvs)) return 0; + if (!readpcv(file, &pcvs)) + { + return 0; + } for (i = 0; i < MAXSAT; i++) { @@ -389,7 +486,7 @@ int readdcbf(const char *file, nav_t *nav, const sta_t *sta) trace(3, "readdcbf: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "dcb parameters file open error: %s\n", file); return 0; @@ -397,21 +494,36 @@ int readdcbf(const char *file, nav_t *nav, const sta_t *sta) while (fgets(buff, sizeof(buff), fp)) { if (strstr(buff, "DIFFERENTIAL (P1-P2) CODE BIASES")) - type = 1; + { + type = 1; + } else if (strstr(buff, "DIFFERENTIAL (P1-C1) CODE BIASES")) - type = 2; + { + type = 2; + } else if (strstr(buff, "DIFFERENTIAL (P2-C2) CODE BIASES")) - type = 3; + { + type = 3; + } - if (!type || sscanf(buff, "%s %s", str1, str2) < 1) continue; + if (!type || sscanf(buff, "%s %s", str1, str2) < 1) + { + continue; + } - if ((cbias = str2num(buff, 26, 9)) == 0.0) continue; + if ((cbias = str2num(buff, 26, 9)) == 0.0) + { + continue; + } if (sta && (!strcmp(str1, "G") || !strcmp(str1, "R"))) { /* receiver dcb */ for (i = 0; i < MAXRCV; i++) { - if (!strcmp(sta[i].name, str2)) break; + if (!strcmp(sta[i].name, str2)) + { + break; + } } if (i < MAXRCV) { @@ -447,15 +559,20 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta) trace(3, "readdcb : file=%s\n", file); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < 3; j++) - { - nav->cbias[i][j] = 0.0; - } + { + for (j = 0; j < 3; j++) + { + nav->cbias[i][j] = 0.0; + } + } for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return 0; } } @@ -465,7 +582,10 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta) { readdcbf(efiles[i], nav, sta); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } return 1; } @@ -490,7 +610,7 @@ int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat, if (nav->nf >= nav->nfmax) { nav->nfmax = nav->nfmax <= 0 ? 2048 : nav->nfmax * 2; - if (!(nav_fcb = (fcbd_t *)realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax))) + if (!(nav_fcb = static_cast(realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax)))) { free(nav->fcb); nav->nf = nav->nfmax = 0; @@ -499,10 +619,12 @@ int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat, nav->fcb = nav_fcb; } for (i = 0; i < MAXSAT; i++) - for (j = 0; j < 3; j++) - { - nav->fcb[nav->nf].bias[i][j] = nav->fcb[nav->nf].std[i][j] = 0.0; - } + { + for (j = 0; j < 3; j++) + { + nav->fcb[nav->nf].bias[i][j] = nav->fcb[nav->nf].std[i][j] = 0.0; + } + } for (i = 0; i < 3; i++) { nav->fcb[nav->nf].bias[sat - 1][i] = bias[i]; @@ -525,21 +647,30 @@ int readfcbf(const char *file, nav_t *nav) trace(3, "readfcbf: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "fcb parameters file open error: %s\n", file); return 0; } while (fgets(buff, sizeof(buff), fp)) { - if ((p = strchr(buff, '#'))) *p = '\0'; + if ((p = strchr(buff, '#'))) + { + *p = '\0'; + } if (sscanf(buff, "%lf/%lf/%lf %lf:%lf:%lf %lf/%lf/%lf %lf:%lf:%lf %s" "%lf %lf %lf %lf %lf %lf", ep1, ep1 + 1, ep1 + 2, ep1 + 3, ep1 + 4, ep1 + 5, ep2, ep2 + 1, ep2 + 2, ep2 + 3, ep2 + 4, ep2 + 5, str, bias, std, bias + 1, std + 1, - bias + 2, std + 2) < 17) continue; - if (!(sat = satid2no(str))) continue; + bias + 2, std + 2) < 17) + { + continue; + } + if (!(sat = satid2no(str))) + { + continue; + } ts = epoch2time(ep1); te = epoch2time(ep2); if (!addfcb(nav, ts, te, sat, bias, std)) @@ -556,7 +687,7 @@ int readfcbf(const char *file, nav_t *nav) /* compare satellite fcb -----------------------------------------------------*/ int cmpfcb(const void *p1, const void *p2) { - fcbd_t *q1 = (fcbd_t *)p1, *q2 = (fcbd_t *)p2; + auto *q1 = (fcbd_t *)p1, *q2 = (fcbd_t *)p2; double tt = timediff(q1->ts, q2->ts); return tt < -1e-3 ? -1 : (tt > 1e-3 ? 1 : 0); } @@ -578,9 +709,12 @@ int readfcb(const char *file, nav_t *nav) for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return 0; } } @@ -590,7 +724,10 @@ int readfcb(const char *file, nav_t *nav) { readfcbf(efiles[i], nav); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } if (nav->nf > 1) { @@ -639,18 +776,26 @@ int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs, { k = (i + j) / 2; if (timediff(nav->peph[k].time, time) < 0.0) - i = k + 1; + { + i = k + 1; + } else - j = k; + { + j = k; + } } index = i <= 0 ? 0 : i - 1; /* polynomial interpolation for orbit */ i = index - (NMAX + 1) / 2; if (i < 0) - i = 0; + { + i = 0; + } else if (i + NMAX >= nav->ne) - i = nav->ne - NMAX - 1; + { + i = nav->ne - NMAX - 1; + } for (j = 0; j <= NMAX; j++) { @@ -682,14 +827,21 @@ int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs, } if (vare) { - for (i = 0; i < 3; i++) s[i] = nav->peph[index].std[sat - 1][i]; + for (i = 0; i < 3; i++) + { + s[i] = nav->peph[index].std[sat - 1][i]; + } std = norm_rtk(s, 3); /* extrapolation error for orbit */ if (t[0] > 0.0) - std += EXTERR_EPH * std::pow(t[0], 2.0) / 2.0; + { + std += EXTERR_EPH * std::pow(t[0], 2.0) / 2.0; + } else if (t[NMAX] < 0.0) - std += EXTERR_EPH * std::pow(t[NMAX], 2.0) / 2.0; + { + std += EXTERR_EPH * std::pow(t[NMAX], 2.0) / 2.0; + } *vare = std::pow(std, 2.0); } /* linear interpolation for clock */ @@ -722,7 +874,10 @@ int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs, { dts[0] = 0.0; } - if (varc) *varc = std::pow(std, 2.0); + if (varc) + { + *varc = std::pow(std, 2.0); + } return 1; } @@ -748,9 +903,13 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts, { k = (i + j) / 2; if (timediff(nav->pclk[k].time, time) < 0.0) - i = k + 1; + { + i = k + 1; + } else - j = k; + { + j = k; + } } index = i <= 0 ? 0 : i - 1; @@ -762,12 +921,18 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts, if (t[0] <= 0.0) { - if ((dts[0] = c[0]) == 0.0) return 0; + if ((dts[0] = c[0]) == 0.0) + { + return 0; + } std = nav->pclk[index].std[sat - 1][0] * SPEED_OF_LIGHT - EXTERR_CLK * t[0]; } else if (t[1] >= 0.0) { - if ((dts[0] = c[1]) == 0.0) return 0; + if ((dts[0] = c[1]) == 0.0) + { + return 0; + } std = nav->pclk[index + 1].std[sat - 1][0] * SPEED_OF_LIGHT + EXTERR_CLK * t[1]; } else if (c[0] != 0.0 && c[1] != 0.0) @@ -781,7 +946,10 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts, trace(3, "prec clock outage %s sat=%2d\n", time_str(time, 0), sat); return 0; } - if (varc) *varc = std::pow(std, 2.0); + if (varc) + { + *varc = std::pow(std, 2.0); + } return 1; } @@ -809,20 +977,41 @@ void satantoff(gtime_t time, const double *rs, int sat, const nav_t *nav, trace(4, "satantoff: time=%s sat=%2d\n", time_str(time, 3), sat); /* sun position in ecef */ - sunmoonpos(gpst2utc(time), erpv, rsun, NULL, &gmst); + sunmoonpos(gpst2utc(time), erpv, rsun, nullptr, &gmst); /* unit vectors of satellite fixed coordinates */ - for (i = 0; i < 3; i++) r[i] = -rs[i]; - if (!normv3(r, ez)) return; - for (i = 0; i < 3; i++) r[i] = rsun[i] - rs[i]; - if (!normv3(r, es)) return; + for (i = 0; i < 3; i++) + { + r[i] = -rs[i]; + } + if (!normv3(r, ez)) + { + return; + } + for (i = 0; i < 3; i++) + { + r[i] = rsun[i] - rs[i]; + } + if (!normv3(r, es)) + { + return; + } cross3(ez, es, r); - if (!normv3(r, ey)) return; + if (!normv3(r, ey)) + { + return; + } cross3(ey, ez, ex); - if (NFREQ >= 3 && (satsys(sat, NULL) & (SYS_GAL | SYS_SBS))) k = 2; + if (NFREQ >= 3 && (satsys(sat, nullptr) & (SYS_GAL | SYS_SBS))) + { + k = 2; + } - if (NFREQ < 2 || lam[j] == 0.0 || lam[k] == 0.0) return; + if (NFREQ < 2 || lam[j] == 0.0 || lam[k] == 0.0) + { + return; + } gamma = std::pow(lam[k], 2.0) / std::pow(lam[j], 2.0); C1 = gamma / (gamma - 1.0); @@ -864,15 +1053,24 @@ int peph2pos(gtime_t time, int sat, const nav_t *nav, int opt, trace(4, "peph2pos: time=%s sat=%2d opt=%d\n", time_str(time, 3), sat, opt); - if (sat <= 0 || MAXSAT < sat) return 0; + if (sat <= 0 || MAXSAT < sat) + { + return 0; + } /* satellite position and clock bias */ if (!pephpos(time, sat, nav, rss, dtss, &vare, &varc) || - !pephclk(time, sat, nav, dtss, &varc)) return 0; + !pephclk(time, sat, nav, dtss, &varc)) + { + return 0; + } time = timeadd(time, tt); - if (!pephpos(time, sat, nav, rst, dtst, NULL, NULL) || - !pephclk(time, sat, nav, dtst, NULL)) return 0; + if (!pephpos(time, sat, nav, rst, dtst, nullptr, nullptr) || + !pephclk(time, sat, nav, dtst, nullptr)) + { + return 0; + } /* satellite antenna offset correction */ if (opt) @@ -894,7 +1092,10 @@ int peph2pos(gtime_t time, int sat, const nav_t *nav, int opt, { /* no precise clock */ dts[0] = dts[1] = 0.0; } - if (var) *var = vare + varc; + if (var) + { + *var = vare + varc; + } return 1; } diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.h b/src/algorithms/libs/rtklib/rtklib_preceph.h index 24b0b610c..1186b6a88 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.h +++ b/src/algorithms/libs/rtklib/rtklib_preceph.h @@ -75,7 +75,7 @@ int code2sys(char code); int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, double *bfact, char *tsys); int addpeph(nav_t *nav, peph_t *peph); -void readsp3b(FILE *fp, char type, int *sats, int ns, double *bfact, +void readsp3b(FILE *fp, char type, int *sats, int ns, const double *bfact, char *tsys, int index, int opt, nav_t *nav); int cmppeph(const void *p1, const void *p2); void combpeph(nav_t *nav, int opt); diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm.cc b/src/algorithms/libs/rtklib/rtklib_rtcm.cc index e122ebead..53c34663d 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm.cc @@ -88,34 +88,45 @@ int init_rtcm(rtcm_t *rtcm) rtcm->sta.pos[i] = rtcm->sta.del[i] = 0.0; } rtcm->sta.hgt = 0.0; - rtcm->dgps = NULL; + rtcm->dgps = nullptr; for (i = 0; i < MAXSAT; i++) { rtcm->ssr[i] = ssr0; } rtcm->msg[0] = rtcm->msgtype[0] = rtcm->opt[0] = '\0'; - for (i = 0; i < 6; i++) rtcm->msmtype[i][0] = '\0'; + for (i = 0; i < 6; i++) + { + rtcm->msmtype[i][0] = '\0'; + } rtcm->obsflag = rtcm->ephsat = 0; for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ + NEXOBS; j++) - { - rtcm->cp[i][j] = 0.0; - rtcm->lock[i][j] = rtcm->loss[i][j] = 0; - rtcm->lltime[i][j] = time0; - } + { + for (j = 0; j < NFREQ + NEXOBS; j++) + { + rtcm->cp[i][j] = 0.0; + rtcm->lock[i][j] = rtcm->loss[i][j] = 0; + rtcm->lltime[i][j] = time0; + } + } rtcm->nbyte = rtcm->nbit = rtcm->len = 0; rtcm->word = 0; - for (i = 0; i < 100; i++) rtcm->nmsg2[i] = 0; - for (i = 0; i < 300; i++) rtcm->nmsg3[i] = 0; + for (i = 0; i < 100; i++) + { + rtcm->nmsg2[i] = 0; + } + for (i = 0; i < 300; i++) + { + rtcm->nmsg3[i] = 0; + } - rtcm->obs.data = NULL; - rtcm->nav.eph = NULL; - rtcm->nav.geph = NULL; + rtcm->obs.data = nullptr; + rtcm->nav.eph = nullptr; + rtcm->nav.geph = nullptr; /* reallocate memory for observation and ephemris buffer */ - if (!(rtcm->obs.data = (obsd_t *)malloc(sizeof(obsd_t) * MAXOBS)) || - !(rtcm->nav.eph = (eph_t *)malloc(sizeof(eph_t) * MAXSAT)) || - !(rtcm->nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO))) + if (!(rtcm->obs.data = static_cast(malloc(sizeof(obsd_t) * MAXOBS))) || + !(rtcm->nav.eph = static_cast(malloc(sizeof(eph_t) * MAXSAT))) || + !(rtcm->nav.geph = static_cast(malloc(sizeof(geph_t) * MAXPRNGLO)))) { free_rtcm(rtcm); return 0; @@ -123,9 +134,18 @@ int init_rtcm(rtcm_t *rtcm) rtcm->obs.n = 0; rtcm->nav.n = MAXSAT; rtcm->nav.ng = MAXPRNGLO; - for (i = 0; i < MAXOBS; i++) rtcm->obs.data[i] = data0; - for (i = 0; i < MAXSAT; i++) rtcm->nav.eph[i] = eph0; - for (i = 0; i < MAXPRNGLO; i++) rtcm->nav.geph[i] = geph0; + for (i = 0; i < MAXOBS; i++) + { + rtcm->obs.data[i] = data0; + } + for (i = 0; i < MAXSAT; i++) + { + rtcm->nav.eph[i] = eph0; + } + for (i = 0; i < MAXPRNGLO; i++) + { + rtcm->nav.geph[i] = geph0; + } return 1; } @@ -141,13 +161,13 @@ void free_rtcm(rtcm_t *rtcm) /* free memory for observation and ephemeris buffer */ free(rtcm->obs.data); - rtcm->obs.data = NULL; + rtcm->obs.data = nullptr; rtcm->obs.n = 0; free(rtcm->nav.eph); - rtcm->nav.eph = NULL; + rtcm->nav.eph = nullptr; rtcm->nav.n = 0; free(rtcm->nav.geph); - rtcm->nav.geph = NULL; + rtcm->nav.geph = nullptr; rtcm->nav.ng = 0; } @@ -173,7 +193,10 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data) trace(5, "input_rtcm2: data=%02x\n", data); - if ((data & 0xC0) != 0x40) return 0; /* ignore if upper 2bit != 01 */ + if ((data & 0xC0) != 0x40) + { + return 0; /* ignore if upper 2bit != 01 */ + } for (i = 0; i < 6; i++, data >>= 1) { /* decode 6-of-8 form */ @@ -182,20 +205,31 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data) /* synchronize frame */ if (rtcm->nbyte == 0) { - preamb = (unsigned char)(rtcm->word >> 22); - if (rtcm->word & 0x40000000) preamb ^= 0xFF; /* decode preamble */ - if (preamb != RTCM2PREAMB) continue; + preamb = static_cast(rtcm->word >> 22); + if (rtcm->word & 0x40000000) + { + preamb ^= 0xFF; /* decode preamble */ + } + if (preamb != RTCM2PREAMB) + { + continue; + } /* check parity */ - if (!decode_word(rtcm->word, rtcm->buff)) continue; + if (!decode_word(rtcm->word, rtcm->buff)) + { + continue; + } rtcm->nbyte = 3; rtcm->nbit = 0; continue; } if (++rtcm->nbit < 30) - continue; - else - rtcm->nbit = 0; + { + continue; + } + + rtcm->nbit = 0; /* check parity */ if (!decode_word(rtcm->word, rtcm->buff + rtcm->nbyte)) @@ -206,8 +240,14 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data) continue; } rtcm->nbyte += 3; - if (rtcm->nbyte == 6) rtcm->len = (rtcm->buff[5] >> 3) * 3 + 6; - if (rtcm->nbyte < rtcm->len) continue; + if (rtcm->nbyte == 6) + { + rtcm->len = (rtcm->buff[5] >> 3) * 3 + 6; + } + if (rtcm->nbyte < rtcm->len) + { + continue; + } rtcm->nbyte = 0; rtcm->word &= 0x3; @@ -290,7 +330,10 @@ int input_rtcm3(rtcm_t *rtcm, unsigned char data) /* synchronize frame */ if (rtcm->nbyte == 0) { - if (data != RTCM3PREAMB) return 0; + if (data != RTCM3PREAMB) + { + return 0; + } rtcm->buff[rtcm->nbyte++] = data; return 0; } @@ -300,7 +343,10 @@ int input_rtcm3(rtcm_t *rtcm, unsigned char data) { rtcm->len = getbitu(rtcm->buff, 14, 10) + 3; /* length without parity */ } - if (rtcm->nbyte < 3 || rtcm->nbyte < rtcm->len + 3) return 0; + if (rtcm->nbyte < 3 || rtcm->nbyte < rtcm->len + 3) + { + return 0; + } rtcm->nbyte = 0; /* check parity */ @@ -329,8 +375,14 @@ int input_rtcm2f(rtcm_t *rtcm, FILE *fp) for (i = 0; i < 4096; i++) { - if ((data = fgetc(fp)) == EOF) return -2; - if ((ret = input_rtcm2(rtcm, (unsigned char)data))) return ret; + if ((data = fgetc(fp)) == EOF) + { + return -2; + } + if ((ret = input_rtcm2(rtcm, static_cast(data)))) + { + return ret; + } } return 0; /* return at every 4k bytes */ } @@ -351,8 +403,14 @@ int input_rtcm3f(rtcm_t *rtcm, FILE *fp) for (i = 0; i < 4096; i++) { - if ((data = fgetc(fp)) == EOF) return -2; - if ((ret = input_rtcm3(rtcm, (unsigned char)data))) return ret; + if ((data = fgetc(fp)) == EOF) + { + return -2; + } + if ((ret = input_rtcm3(rtcm, static_cast(data)))) + { + return ret; + } } return 0; /* return at every 4k bytes */ } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc index c7af88ccd..24528c762 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc @@ -63,14 +63,21 @@ void adjhour(rtcm_t *rtcm, double zcnt) int week; /* if no time, get cpu time */ - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } tow = time2gpst(rtcm->time, &week); hour = floor(tow / 3600.0); sec = tow - hour * 3600.0; if (zcnt < sec - 1800.0) - zcnt += 3600.0; + { + zcnt += 3600.0; + } else if (zcnt > sec + 1800.0) - zcnt -= 3600.0; + { + zcnt -= 3600.0; + } rtcm->time = gpst2time(week, hour * 3600 + zcnt); } @@ -82,9 +89,15 @@ int obsindex(obs_t *obs, gtime_t time, int sat) for (i = 0; i < obs->n; i++) { - if (obs->data[i].sat == sat) return i; /* field already exists */ + if (obs->data[i].sat == sat) + { + return i; /* field already exists */ + } + } + if (i >= MAXOBS) + { + return -1; /* overflow */ } - if (i >= MAXOBS) return -1; /* overflow */ /* add new field */ obs->data[i].time = time; @@ -122,7 +135,10 @@ int decode_type1(rtcm_t *rtcm) i += 8; iod = getbits(rtcm->buff, i, 8); i += 8; - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } if (prc == 0x80000000 || rrc == 0xFFFF8000) { trace(2, "rtcm2 1 prc/rrc indicates satellite problem: prn=%d\n", prn); @@ -290,7 +306,10 @@ int decode_type17(rtcm_t *rtcm) trace(2, "rtcm2 17 length error: len=%d\n", rtcm->len); return -1; } - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } sat = satno(SYS_GPS, prn); eph.sat = sat; eph.week = adjgpsweek(week); @@ -346,14 +365,20 @@ int decode_type18(rtcm_t *rtcm) i += 5; cp = getbits(rtcm->buff, i, 32); i += 32; - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } if (!(sat = satno(sys ? SYS_GLO : SYS_GPS, prn))) { trace(2, "rtcm2 18 satellite number error: sys=%d prn=%d\n", sys, prn); continue; } time = timeadd(rtcm->time, usec * 1E-6); - if (sys) time = utc2gpst(time); /* convert glonass time to gpst */ + if (sys) + { + time = utc2gpst(time); /* convert glonass time to gpst */ + } tt = timediff(rtcm->obs.data[0].time, time); if (rtcm->obsflag || fabs(tt) > 1E-9) @@ -414,14 +439,20 @@ int decode_type19(rtcm_t *rtcm) i += 5 + 8; pr = getbitu(rtcm->buff, i, 32); i += 32; - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } if (!(sat = satno(sys ? SYS_GLO : SYS_GPS, prn))) { trace(2, "rtcm2 19 satellite number error: sys=%d prn=%d\n", sys, prn); continue; } time = timeadd(rtcm->time, usec * 1E-6); - if (sys) time = utc2gpst(time); /* convert glonass time to gpst */ + if (sys) + { + time = utc2gpst(time); /* convert glonass time to gpst */ + } tt = timediff(rtcm->obs.data[0].time, time); if (rtcm->obsflag || fabs(tt) > 1E-9) @@ -479,7 +510,10 @@ int decode_type22(rtcm_t *rtcm) del[1][2] = getbits(rtcm->buff, i, 8) / 1600.0; } rtcm->sta.deltype = 1; /* xyz */ - for (j = 0; j < 3; j++) rtcm->sta.del[j] = del[0][j]; + for (j = 0; j < 3; j++) + { + rtcm->sta.del[j] = del[0][j]; + } rtcm->sta.hgt = hgt; return 5; } @@ -640,9 +674,13 @@ int decode_rtcm2(rtcm_t *rtcm) if (ret >= 0) { if (1 <= type && type <= 99) - rtcm->nmsg2[type]++; + { + rtcm->nmsg2[type]++; + } else - rtcm->nmsg2[0]++; + { + rtcm->nmsg2[0]++; + } } return ret; } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc index babc88f5f..46dbedb4d 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc @@ -54,6 +54,7 @@ #include "rtklib_rtcm3.h" #include "rtklib_rtkcmn.h" +#include /* msm signal id table -------------------------------------------------------*/ @@ -114,12 +115,19 @@ void adjweek(rtcm_t *rtcm, double tow) int week; /* if no time, get cpu time */ - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } tow_p = time2gpst(rtcm->time, &week); if (tow < tow_p - 302400.0) - tow += 604800.0; + { + tow += 604800.0; + } else if (tow > tow_p + 302400.0) - tow -= 604800.0; + { + tow -= 604800.0; + } rtcm->time = gpst2time(week, tow); } @@ -129,7 +137,10 @@ int adjbdtweek(int week) { int w; (void)time2bdt(gpst2bdt(utc2gpst(timeget())), &w); - if (w < 1) w = 1; /* use 2006/1/1 if time is earlier than 2006/1/1 */ + if (w < 1) + { + w = 1; /* use 2006/1/1 if time is earlier than 2006/1/1 */ + } return week + (w - week + 512) / 1024 * 1024; } @@ -141,15 +152,22 @@ void adjday_glot(rtcm_t *rtcm, double tod) double tow, tod_p; int week; - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } time = timeadd(gpst2utc(rtcm->time), 10800.0); /* glonass time */ tow = time2gpst(time, &week); tod_p = fmod(tow, 86400.0); tow -= tod_p; if (tod < tod_p - 43200.0) - tod += 86400.0; + { + tod += 86400.0; + } else if (tod > tod_p + 43200.0) - tod -= 86400.0; + { + tod -= 86400.0; + } time = gpst2time(week, tow + tod); rtcm->time = utc2gpst(timeadd(time, -10800.0)); } @@ -159,11 +177,17 @@ void adjday_glot(rtcm_t *rtcm, double tod) double adjcp(rtcm_t *rtcm, int sat, int freq, double cp) { if (rtcm->cp[sat - 1][freq] == 0.0) - ; + { + ; + } else if (cp < rtcm->cp[sat - 1][freq] - 750.0) - cp += 1500.0; + { + cp += 1500.0; + } else if (cp > rtcm->cp[sat - 1][freq] + 750.0) - cp -= 1500.0; + { + cp -= 1500.0; + } rtcm->cp[sat - 1][freq] = cp; return cp; } @@ -173,7 +197,7 @@ double adjcp(rtcm_t *rtcm, int sat, int freq, double cp) int lossoflock(rtcm_t *rtcm, int sat, int freq, int lock) { int lli = (!lock && !rtcm->lock[sat - 1][freq]) || lock < rtcm->lock[sat - 1][freq]; - rtcm->lock[sat - 1][freq] = (unsigned short)lock; + rtcm->lock[sat - 1][freq] = static_cast(lock); return lli; } @@ -181,7 +205,7 @@ int lossoflock(rtcm_t *rtcm, int sat, int freq, int lock) /* s/n ratio -----------------------------------------------------------------*/ unsigned char snratio(double snr) { - return (unsigned char)(snr <= 0.0 || 255.5 <= snr ? 0.0 : snr * 4.0 + 0.5); + return static_cast(snr <= 0.0 || 255.5 <= snr ? 0.0 : snr * 4.0 + 0.5); } @@ -192,9 +216,15 @@ int obsindex3(obs_t *obs, gtime_t time, int sat) for (i = 0; i < obs->n; i++) { - if (obs->data[i].sat == sat) return i; /* field already exists */ + if (obs->data[i].sat == sat) + { + return i; /* field already exists */ + } + } + if (i >= MAXOBS) + { + return -1; /* overflow */ } - if (i >= MAXOBS) return -1; /* overflow */ /* add new field */ obs->data[i].time = time; @@ -219,7 +249,10 @@ int test_staid(rtcm_t *rtcm, int staid) /* test station id option */ if ((p = strstr(rtcm->opt, "-STA=")) && sscanf(p, "-STA=%d", &id) == 1) { - if (staid != id) return 0; + if (staid != id) + { + return 0; + } } /* save station id */ if (rtcm->staid == 0 || rtcm->obsflag) @@ -265,7 +298,10 @@ int decode_head1001(rtcm_t *rtcm, int *sync) return -1; } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } adjweek(rtcm, tow); @@ -286,7 +322,10 @@ int decode_head1001(rtcm_t *rtcm, int *sync) int decode_type1001(rtcm_t *rtcm) { int sync; - if (decode_head1001(rtcm, &sync) < 0) return -1; + if (decode_head1001(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -298,7 +337,10 @@ int decode_type1002(rtcm_t *rtcm) double pr1, cnr1, tt, cp1; int i = 24 + 64, j, index, nsat, sync, prn, code, sat, ppr1, lock1, amb, sys; - if ((nsat = decode_head1001(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1001(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 74 <= rtcm->len * 8; j++) { @@ -335,13 +377,16 @@ int decode_type1002(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GPS; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { rtcm->obs.data[index].P[0] = pr1; - cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / lam_carr[0]); - rtcm->obs.data[index].L[0] = pr1 / lam_carr[0] + cp1; + cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / LAM_CARR[0]); + rtcm->obs.data[index].L[0] = pr1 / LAM_CARR[0] + cp1; } rtcm->obs.data[index].LLI[0] = lossoflock(rtcm, sat, 0, lock1); rtcm->obs.data[index].SNR[0] = snratio(cnr1 * 0.25); @@ -355,7 +400,10 @@ int decode_type1002(rtcm_t *rtcm) int decode_type1003(rtcm_t *rtcm) { int sync; - if (decode_head1001(rtcm, &sync) < 0) return -1; + if (decode_head1001(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -369,7 +417,10 @@ int decode_type1004(rtcm_t *rtcm) int i = 24 + 64, j, index, nsat, sync, prn, sat, code1, code2, pr21, ppr1, ppr2; int lock1, lock2, amb, sys; - if ((nsat = decode_head1001(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1001(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 125 <= rtcm->len * 8; j++) { @@ -416,26 +467,29 @@ int decode_type1004(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GPS; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { rtcm->obs.data[index].P[0] = pr1; - cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / lam_carr[0]); - rtcm->obs.data[index].L[0] = pr1 / lam_carr[0] + cp1; + cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / LAM_CARR[0]); + rtcm->obs.data[index].L[0] = pr1 / LAM_CARR[0] + cp1; } rtcm->obs.data[index].LLI[0] = lossoflock(rtcm, sat, 0, lock1); rtcm->obs.data[index].SNR[0] = snratio(cnr1 * 0.25); rtcm->obs.data[index].code[0] = code1 ? CODE_L1P : CODE_L1C; - if (pr21 != (int)0xFFFFE000) + if (pr21 != static_cast(0xFFFFE000)) { rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02; } - if (ppr2 != (int)0xFFF80000) + if (ppr2 != static_cast(0xFFF80000)) { - cp2 = adjcp(rtcm, sat, 1, ppr2 * 0.0005 / lam_carr[1]); - rtcm->obs.data[index].L[1] = pr1 / lam_carr[1] + cp2; + cp2 = adjcp(rtcm, sat, 1, ppr2 * 0.0005 / LAM_CARR[1]); + rtcm->obs.data[index].L[1] = pr1 / LAM_CARR[1] + cp2; } rtcm->obs.data[index].LLI[1] = lossoflock(rtcm, sat, 1, lock2); rtcm->obs.data[index].SNR[1] = snratio(cnr2 * 0.25); @@ -449,7 +503,7 @@ int decode_type1004(rtcm_t *rtcm) /* get signed 38bit field ----------------------------------------------------*/ double getbits_38(const unsigned char *buff, int pos) { - return (double)getbits(buff, pos, 32) * 64.0 + getbitu(buff, pos + 32, 6); + return static_cast(getbits(buff, pos, 32)) * 64.0 + getbitu(buff, pos + 32, 6); } @@ -480,13 +534,19 @@ int decode_type1005(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - for (j = 0; j < 3; j++) re[j] = rr[j] * 0.0001; + for (j = 0; j < 3; j++) + { + re[j] = rr[j] * 0.0001; + } ecef2pos(re, pos); sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f", staid, pos[0] * R2D, pos[1] * R2D, pos[2]); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } rtcm->sta.deltype = 0; /* xyz */ for (j = 0; j < 3; j++) @@ -529,13 +589,19 @@ int decode_type1006(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - for (j = 0; j < 3; j++) re[j] = rr[j] * 0.0001; + for (j = 0; j < 3; j++) + { + re[j] = rr[j] * 0.0001; + } ecef2pos(re, pos); sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f anth=%.3f", staid, pos[0] * R2D, pos[1] * R2D, pos[2], anth); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } rtcm->sta.deltype = 1; /* xyz */ for (j = 0; j < 3; j++) @@ -564,7 +630,7 @@ int decode_type1007(rtcm_t *rtcm) i += 12 + 8; for (j = 0; j < n && j < 31; j++) { - des[j] = (char)getbitu(rtcm->buff, i, 8); + des[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } setup = getbitu(rtcm->buff, i, 8); @@ -580,7 +646,10 @@ int decode_type1007(rtcm_t *rtcm) sprintf(msg, " staid=%4d", staid); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } strncpy(rtcm->sta.antdes, des, n); rtcm->sta.antdes[n] = '\0'; @@ -606,14 +675,14 @@ int decode_type1008(rtcm_t *rtcm) i += 12 + 8; for (j = 0; j < n && j < 31; j++) { - des[j] = (char)getbitu(rtcm->buff, i, 8); + des[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } setup = getbitu(rtcm->buff, i, 8); i += 8 + 8; for (j = 0; j < m && j < 31; j++) { - sno[j] = (char)getbitu(rtcm->buff, i, 8); + sno[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } } @@ -628,7 +697,10 @@ int decode_type1008(rtcm_t *rtcm) sprintf(msg, " staid=%4d", staid); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } strncpy(rtcm->sta.antdes, des, n); rtcm->sta.antdes[n] = '\0'; @@ -665,7 +737,10 @@ int decode_head1009(rtcm_t *rtcm, int *sync) return -1; } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } adjday_glot(rtcm, tod); @@ -686,7 +761,10 @@ int decode_head1009(rtcm_t *rtcm, int *sync) int decode_type1009(rtcm_t *rtcm) { int sync; - if (decode_head1009(rtcm, &sync) < 0) return -1; + if (decode_head1009(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -698,7 +776,10 @@ int decode_type1010(rtcm_t *rtcm) double pr1, cnr1, tt, cp1, lam1; int i = 24 + 61, j, index, nsat, sync, prn, sat, code, freq, ppr1, lock1, amb, sys = SYS_GLO; - if ((nsat = decode_head1009(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1009(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 79 <= rtcm->len * 8; j++) { @@ -728,9 +809,12 @@ int decode_type1010(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GLO; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { rtcm->obs.data[index].P[0] = pr1; lam1 = SPEED_OF_LIGHT / (FREQ1_GLO + DFRQ1_GLO * (freq - 7)); @@ -749,7 +833,10 @@ int decode_type1010(rtcm_t *rtcm) int decode_type1011(rtcm_t *rtcm) { int sync; - if (decode_head1009(rtcm, &sync) < 0) return -1; + if (decode_head1009(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -762,7 +849,10 @@ int decode_type1012(rtcm_t *rtcm) int i = 24 + 61, j, index, nsat, sync, prn, sat, freq, code1, code2, pr21, ppr1, ppr2; int lock1, lock2, amb, sys = SYS_GLO; - if ((nsat = decode_head1009(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1009(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 130 <= rtcm->len * 8; j++) { @@ -802,9 +892,12 @@ int decode_type1012(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GLO; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { lam1 = SPEED_OF_LIGHT / (FREQ1_GLO + DFRQ1_GLO * (freq - 7)); rtcm->obs.data[index].P[0] = pr1; @@ -815,11 +908,11 @@ int decode_type1012(rtcm_t *rtcm) rtcm->obs.data[index].SNR[0] = snratio(cnr1 * 0.25); rtcm->obs.data[index].code[0] = code1 ? CODE_L1P : CODE_L1C; - if (pr21 != (int)0xFFFFE000) + if (pr21 != static_cast(0xFFFFE000)) { rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02; } - if (ppr2 != (int)0xFFF80000) + if (ppr2 != static_cast(0xFFF80000)) { lam2 = SPEED_OF_LIGHT / (FREQ2_GLO + DFRQ2_GLO * (freq - 7)); cp2 = adjcp(rtcm, sat, 1, ppr2 * 0.0005 / lam2); @@ -944,7 +1037,10 @@ int decode_type1019(rtcm_t *rtcm) eph.A = sqrtA * sqrtA; if (!strstr(rtcm->opt, "-EPHALL")) { - if (eph.iode == rtcm->nav.eph[sat - 1].iode) return 0; /* unchanged */ + if (eph.iode == rtcm->nav.eph[sat - 1].iode) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1020,27 +1116,41 @@ int decode_type1020(rtcm_t *rtcm) geph.sat = sat; geph.svh = bn; geph.iode = tb & 0x7F; - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } tow = time2gpst(gpst2utc(rtcm->time), &week); tod = fmod(tow, 86400.0); tow -= tod; tof = tk_h * 3600.0 + tk_m * 60.0 + tk_s - 10800.0; /* lt->utc */ if (tof < tod - 43200.0) - tof += 86400.0; + { + tof += 86400.0; + } else if (tof > tod + 43200.0) - tof -= 86400.0; + { + tof -= 86400.0; + } geph.tof = utc2gpst(gpst2time(week, tow + tof)); toe = tb * 900.0 - 10800.0; /* lt->utc */ if (toe < tod - 43200.0) - toe += 86400.0; + { + toe += 86400.0; + } else if (toe > tod + 43200.0) - toe -= 86400.0; + { + toe -= 86400.0; + } geph.toe = utc2gpst(gpst2time(week, tow + toe)); /* utc->gpst */ if (!strstr(rtcm->opt, "-EPHALL")) { if (fabs(timediff(geph.toe, rtcm->nav.geph[prn - 1].toe)) < 1.0 && - geph.svh == rtcm->nav.geph[prn - 1].svh) return 0; /* unchanged */ + geph.svh == rtcm->nav.geph[prn - 1].svh) + { + return 0; /* unchanged */ + } } rtcm->nav.geph[prn - 1] = geph; rtcm->ephsat = sat; @@ -1189,32 +1299,32 @@ int decode_type1033(rtcm_t *rtcm) i += 12 + 8; for (j = 0; j < n && j < 31; j++) { - des[j] = (char)getbitu(rtcm->buff, i, 8); + des[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } setup = getbitu(rtcm->buff, i, 8); i += 8 + 8; for (j = 0; j < m && j < 31; j++) { - sno[j] = (char)getbitu(rtcm->buff, i, 8); + sno[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } i += 8; for (j = 0; j < n1 && j < 31; j++) { - rec[j] = (char)getbitu(rtcm->buff, i, 8); + rec[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } i += 8; for (j = 0; j < n2 && j < 31; j++) { - ver[j] = (char)getbitu(rtcm->buff, i, 8); + ver[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } i += 8; for (j = 0; j < n3 && j < 31; j++) { - rsn[j] = (char)getbitu(rtcm->buff, i, 8); + rsn[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } } @@ -1229,7 +1339,10 @@ int decode_type1033(rtcm_t *rtcm) sprintf(msg, " staid=%4d", staid); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } strncpy(rtcm->sta.antdes, des, n); rtcm->sta.antdes[n] = '\0'; @@ -1385,7 +1498,10 @@ int decode_type1044(rtcm_t *rtcm) if (!strstr(rtcm->opt, "-EPHALL")) { if (eph.iode == rtcm->nav.eph[sat - 1].iode && - eph.iodc == rtcm->nav.eph[sat - 1].iodc) return 0; /* unchanged */ + eph.iodc == rtcm->nav.eph[sat - 1].iodc) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1489,7 +1605,10 @@ int decode_type1045(rtcm_t *rtcm) eph.code = 2; /* data source = f/nav e5a */ if (!strstr(rtcm->opt, "-EPHALL")) { - if (eph.iode == rtcm->nav.eph[sat - 1].iode) return 0; /* unchanged */ + if (eph.iode == rtcm->nav.eph[sat - 1].iode) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1593,7 +1712,10 @@ int decode_type1046(rtcm_t *rtcm) eph.code = 2; /* data source = f/nav e5a */ if (!strstr(rtcm->opt, "-EPHALL")) { - if (eph.iode == rtcm->nav.eph[sat - 1].iode) return 0; /* unchanged */ + if (eph.iode == rtcm->nav.eph[sat - 1].iode) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1703,7 +1825,10 @@ int decode_type1047(rtcm_t *rtcm) { if (timediff(eph.toe, rtcm->nav.eph[sat - 1].toe) == 0.0 && eph.iode == rtcm->nav.eph[sat - 1].iode && - eph.iodc == rtcm->nav.eph[sat - 1].iodc) return 0; /* unchanged */ + eph.iodc == rtcm->nav.eph[sat - 1].iodc) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1808,7 +1933,10 @@ int decode_type63(rtcm_t *rtcm) { if (timediff(eph.toe, rtcm->nav.eph[sat - 1].toe) == 0.0 && eph.iode == rtcm->nav.eph[sat - 1].iode && - eph.iodc == rtcm->nav.eph[sat - 1].iodc) return 0; /* unchanged */ + eph.iodc == rtcm->nav.eph[sat - 1].iodc) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1827,7 +1955,10 @@ int decode_ssr1_head(rtcm_t *rtcm, int sys, int *sync, int *iod, #ifndef SSR_QZSS_DRAFT_V05 ns = sys == SYS_QZS ? 4 : 6; #endif - if (i + (sys == SYS_GLO ? 53 : 50 + ns) > rtcm->len * 8) return -1; + if (i + (sys == SYS_GLO ? 53 : 50 + ns) > rtcm->len * 8) + { + return -1; + } if (sys == SYS_GLO) { @@ -1855,7 +1986,7 @@ int decode_ssr1_head(rtcm_t *rtcm, int sys, int *sync, int *iod, i += 4; /* solution id */ nsat = getbitu(rtcm->buff, i, ns); i += ns; - *udint = ssrudint[udi]; + *udint = SSRUDINT[udi]; trace(4, "decode_ssr1_head: time=%s sys=%d nsat=%d sync=%d iod=%d provid=%d solid=%d\n", time_str(rtcm->time, 2), sys, nsat, *sync, *iod, provid, solid); @@ -1882,7 +2013,10 @@ int decode_ssr2_head(rtcm_t *rtcm, int sys, int *sync, int *iod, #ifndef SSR_QZSS_DRAFT_V05 ns = sys == SYS_QZS ? 4 : 6; #endif - if (i + (sys == SYS_GLO ? 52 : 49 + ns) > rtcm->len * 8) return -1; + if (i + (sys == SYS_GLO ? 52 : 49 + ns) > rtcm->len * 8) + { + return -1; + } if (sys == SYS_GLO) { @@ -1908,7 +2042,7 @@ int decode_ssr2_head(rtcm_t *rtcm, int sys, int *sync, int *iod, i += 4; /* solution id */ nsat = getbitu(rtcm->buff, i, ns); i += ns; - *udint = ssrudint[udi]; + *udint = SSRUDINT[udi]; trace(4, "decode_ssr2_head: time=%s sys=%d nsat=%d sync=%d iod=%d provid=%d solid=%d\n", time_str(rtcm->time, 2), sys, nsat, *sync, *iod, provid, solid); @@ -1935,7 +2069,10 @@ int decode_ssr7_head(rtcm_t *rtcm, int sys, int *sync, int *iod, #ifndef SSR_QZSS_DRAFT_V05 ns = sys == SYS_QZS ? 4 : 6; #endif - if (i + (sys == SYS_GLO ? 54 : 51 + ns) > rtcm->len * 8) return -1; + if (i + (sys == SYS_GLO ? 54 : 51 + ns) > rtcm->len * 8) + { + return -1; + } if (sys == SYS_GLO) { @@ -1965,7 +2102,7 @@ int decode_ssr7_head(rtcm_t *rtcm, int sys, int *sync, int *iod, i += 1; /* MW consistency indicator */ nsat = getbitu(rtcm->buff, i, ns); i += ns; - *udint = ssrudint[udi]; + *udint = SSRUDINT[udi]; trace(4, "decode_ssr7_head: time=%s sys=%d nsat=%d sync=%d iod=%d provid=%d solid=%d\n", time_str(rtcm->time, 2), sys, nsat, *sync, *iod, provid, solid); @@ -2170,37 +2307,37 @@ int decode_ssr3(rtcm_t *rtcm, int sys) case SYS_GPS: np = 6; offp = 0; - codes = codes_gps; + codes = CODES_GPS; ncode = 17; break; case SYS_GLO: np = 5; offp = 0; - codes = codes_glo; + codes = CODES_GLO; ncode = 4; break; case SYS_GAL: np = 6; offp = 0; - codes = codes_gal; + codes = CODES_GAL; ncode = 19; break; case SYS_QZS: np = 4; offp = 192; - codes = codes_qzs; + codes = CODES_QZS; ncode = 13; break; case SYS_BDS: np = 6; offp = 1; - codes = codes_bds; + codes = CODES_BDS; ncode = 9; break; case SYS_SBS: np = 6; offp = 120; - codes = codes_sbs; + codes = CODES_SBS; ncode = 4; break; default: @@ -2213,7 +2350,10 @@ int decode_ssr3(rtcm_t *rtcm, int sys) nbias = getbitu(rtcm->buff, i, 5); i += 5; - for (k = 0; k < MAXCODE; k++) cbias[k] = 0.0; + for (k = 0; k < MAXCODE; k++) + { + cbias[k] = 0.0; + } for (k = 0; k < nbias && i + 19 <= rtcm->len * 8; k++) { mode = getbitu(rtcm->buff, i, 5); @@ -2222,7 +2362,7 @@ int decode_ssr3(rtcm_t *rtcm, int sys) i += 14; if (mode <= ncode) { - cbias[codes[mode] - 1] = (float)bias; + cbias[codes[mode] - 1] = static_cast(bias); } else { @@ -2240,7 +2380,7 @@ int decode_ssr3(rtcm_t *rtcm, int sys) for (k = 0; k < MAXCODE; k++) { - rtcm->ssr[sat - 1].cbias[k] = (float)cbias[k]; + rtcm->ssr[sat - 1].cbias[k] = static_cast(cbias[k]); } rtcm->ssr[sat - 1].update = 1; } @@ -2502,31 +2642,31 @@ int decode_ssr7(rtcm_t *rtcm, int sys) case SYS_GPS: np = 6; offp = 0; - codes = codes_gps; + codes = CODES_GPS; ncode = 17; break; case SYS_GLO: np = 5; offp = 0; - codes = codes_glo; + codes = CODES_GLO; ncode = 4; break; case SYS_GAL: np = 6; offp = 0; - codes = codes_gal; + codes = CODES_GAL; ncode = 19; break; case SYS_QZS: np = 4; offp = 192; - codes = codes_qzs; + codes = CODES_QZS; ncode = 13; break; case SYS_BDS: np = 6; offp = 1; - codes = codes_bds; + codes = CODES_BDS; ncode = 9; break; default: @@ -2543,7 +2683,10 @@ int decode_ssr7(rtcm_t *rtcm, int sys) yaw_rate = getbits(rtcm->buff, i, 8); i += 8; - for (k = 0; k < MAXCODE; k++) pbias[k] = stdpb[k] = 0.0; + for (k = 0; k < MAXCODE; k++) + { + pbias[k] = stdpb[k] = 0.0; + } for (k = 0; k < nbias && i + 49 <= rtcm->len * 8; k++) { mode = getbitu(rtcm->buff, i, 5); @@ -2579,7 +2722,7 @@ int decode_ssr7(rtcm_t *rtcm, int sys) for (k = 0; k < MAXCODE; k++) { rtcm->ssr[sat - 1].pbias[k] = pbias[k]; - rtcm->ssr[sat - 1].stdpb[k] = (float)stdpb[k]; + rtcm->ssr[sat - 1].stdpb[k] = static_cast(stdpb[k]); } } return 20; @@ -2595,7 +2738,10 @@ void sigindex(int sys, const unsigned char *code, const int *freq, int n, /* test code priority */ for (i = 0; i < n; i++) { - if (!code[i]) continue; + if (!code[i]) + { + continue; + } if (freq[i] > NFREQ) { /* save as extended signal if freq > NFREQ */ @@ -2608,20 +2754,29 @@ void sigindex(int sys, const unsigned char *code, const int *freq, int n, /* select highest priority signal */ if (pri > pri_h[freq[i] - 1]) { - if (index[freq[i] - 1]) ex[index[freq[i] - 1] - 1] = 1; + if (index[freq[i] - 1]) + { + ex[index[freq[i] - 1] - 1] = 1; + } pri_h[freq[i] - 1] = pri; index[freq[i] - 1] = i + 1; } else - ex[i] = 1; + { + ex[i] = 1; + } } /* signal index in obs data */ for (i = nex = 0; i < n; i++) { if (ex[i] == 0) - ind[i] = freq[i] - 1; + { + ind[i] = freq[i] - 1; + } else if (nex < NEXOBS) - ind[i] = NFREQ + nex++; + { + ind[i] = NFREQ + nex++; + } else { /* no space in obs data */ trace(2, "rtcm msm: no space in obs data sys=%d code=%d\n", sys, code[i]); @@ -2643,7 +2798,7 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, const char *sig[32]; double tt, wl; unsigned char code[32]; - char *msm_type = (char *)"", *q = NULL; + char *msm_type = (char *)"", *q = nullptr; int i, j, k, type, prn, sat, fn, index = 0, freq[32], ind[32]; type = getbitu(rtcm->buff, 24, 12); @@ -2703,17 +2858,27 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, if (sys == SYS_BDS) { if (freq[i] == 5) - freq[i] = 2; /* B2 */ + { + freq[i] = 2; /* B2 */ + } else if (freq[i] == 4) - freq[i] = 3; /* B3 */ + { + freq[i] = 3; /* B3 */ + } } if (code[i] != CODE_NONE) { - if (q) q += sprintf(q, "L%s%s", sig[i], i < h->nsig - 1 ? ", " : ""); + if (q) + { + q += sprintf(q, "L%s%s", sig[i], i < h->nsig - 1 ? ", " : ""); + } } else { - if (q) q += sprintf(q, "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : ""); + if (q) + { + q += sprintf(q, "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : ""); + } trace(2, "rtcm3 %d: unknown signal id=%2d\n", type, h->sigs[i]); } @@ -2727,9 +2892,13 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, { prn = h->sats[i]; if (sys == SYS_QZS) - prn += MINPRNQZS - 1; + { + prn += MINPRNQZS - 1; + } else if (sys == SYS_SBS) - prn += MINPRNSBS - 1; + { + prn += MINPRNSBS - 1; + } if ((sat = satno(sys, prn))) { @@ -2746,7 +2915,10 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, } for (k = 0; k < h->nsig; k++) { - if (!h->cellmask[k + i * h->nsig]) continue; + if (!h->cellmask[k + i * h->nsig]) + { + continue; + } if (sat && index >= 0 && ind[k] >= 0) { @@ -2773,11 +2945,11 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, /* doppler (hz) */ if (rr && rrf && rrf[j] > -1E12 && wl > 0.0) { - rtcm->obs.data[index].D[ind[k]] = (float)(-(rr[i] + rrf[j]) / wl); + rtcm->obs.data[index].D[ind[k]] = static_cast(-(rr[i] + rrf[j]) / wl); } rtcm->obs.data[index].LLI[ind[k]] = lossoflock(rtcm, sat, ind[k], lock[j]) + (half[j] ? 3 : 0); - rtcm->obs.data[index].SNR[ind[k]] = (unsigned char)(cnr[j] * 4.0); + rtcm->obs.data[index].SNR[ind[k]] = static_cast(cnr[j] * 4.0); rtcm->obs.data[index].code[ind[k]] = code[k]; } j++; @@ -2842,13 +3014,19 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, { mask = getbitu(rtcm->buff, i, 1); i += 1; - if (mask) h->sats[h->nsat++] = j; + if (mask) + { + h->sats[h->nsat++] = j; + } } for (j = 1; j <= 32; j++) { mask = getbitu(rtcm->buff, i, 1); i += 1; - if (mask) h->sigs[h->nsig++] = j; + if (mask) + { + h->sigs[h->nsig++] = j; + } } } else @@ -2857,7 +3035,10 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, return -1; } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } if (h->nsat * h->nsig > 64) { @@ -2875,7 +3056,10 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, { h->cellmask[j] = getbitu(rtcm->buff, i, 1); i += 1; - if (h->cellmask[j]) ncell++; + if (h->cellmask[j]) + { + ncell++; + } } *hsize = i; @@ -2897,7 +3081,10 @@ int decode_msm0(rtcm_t *rtcm, int sys) { msm_h_t h = {0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}, {0}}; int i, sync, iod; - if (decode_msm_head(rtcm, sys, &sync, &iod, &h, &i) < 0) return -1; + if (decode_msm_head(rtcm, sys, &sync, &iod, &h, &i) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -2913,7 +3100,10 @@ int decode_msm4(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 18 + ncell * 48 > rtcm->len * 8) { @@ -2921,34 +3111,52 @@ int decode_msm4(rtcm_t *rtcm, int sys) ncell, rtcm->len); return -1; } - for (j = 0; j < h.nsat; j++) r[j] = 0.0; - for (j = 0; j < ncell; j++) pr[j] = cp[j] = -1E16; + for (j = 0; j < h.nsat; j++) + { + r[j] = 0.0; + } + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 15); i += 15; - if (prv != -16384) pr[j] = prv * TWO_N24 * RANGE_MS; + if (prv != -16384) + { + pr[j] = prv * TWO_N24 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 22); i += 22; - if (cpv != -2097152) cp[j] = cpv * TWO_N29 * RANGE_MS; + if (cpv != -2097152) + { + cp[j] = cpv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -2966,7 +3174,7 @@ int decode_msm4(rtcm_t *rtcm, int sys) i += 6; } /* save obs data in msm message */ - save_msm_obs(rtcm, sys, &h, r, pr, cp, NULL, NULL, cnr, lock, NULL, half); + save_msm_obs(rtcm, sys, &h, r, pr, cp, nullptr, nullptr, cnr, lock, nullptr, half); rtcm->obsflag = !sync; return sync ? 0 : 1; @@ -2984,7 +3192,10 @@ int decode_msm5(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 36 + ncell * 63 > rtcm->len * 8) { @@ -2997,14 +3208,20 @@ int decode_msm5(rtcm_t *rtcm, int sys) r[j] = rr[j] = 0.0; ex[j] = 15; } - for (j = 0; j < ncell; j++) pr[j] = cp[j] = rrf[j] = -1E16; + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = rrf[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* extended info */ @@ -3015,26 +3232,38 @@ int decode_msm5(rtcm_t *rtcm, int sys) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* phaserangerate */ rate = getbits(rtcm->buff, i, 14); i += 14; - if (rate != -8192) rr[j] = rate * 1.0; + if (rate != -8192) + { + rr[j] = rate * 1.0; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 15); i += 15; - if (prv != -16384) pr[j] = prv * TWO_N24 * RANGE_MS; + if (prv != -16384) + { + pr[j] = prv * TWO_N24 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 22); i += 22; - if (cpv != -2097152) cp[j] = cpv * TWO_N29 * RANGE_MS; + if (cpv != -2097152) + { + cp[j] = cpv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -3055,7 +3284,10 @@ int decode_msm5(rtcm_t *rtcm, int sys) { /* phaserangerate */ rrv = getbits(rtcm->buff, i, 15); i += 15; - if (rrv != -16384) rrf[j] = rrv * 0.0001; + if (rrv != -16384) + { + rrf[j] = rrv * 0.0001; + } } /* save obs data in msm message */ save_msm_obs(rtcm, sys, &h, r, pr, cp, rr, rrf, cnr, lock, ex, half); @@ -3075,7 +3307,10 @@ int decode_msm6(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 18 + ncell * 65 > rtcm->len * 8) { @@ -3083,34 +3318,52 @@ int decode_msm6(rtcm_t *rtcm, int sys) ncell, rtcm->len); return -1; } - for (j = 0; j < h.nsat; j++) r[j] = 0.0; - for (j = 0; j < ncell; j++) pr[j] = cp[j] = -1E16; + for (j = 0; j < h.nsat; j++) + { + r[j] = 0.0; + } + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 20); i += 20; - if (prv != -524288) pr[j] = prv * TWO_N29 * RANGE_MS; + if (prv != -524288) + { + pr[j] = prv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 24); i += 24; - if (cpv != -8388608) cp[j] = cpv * TWO_N31 * RANGE_MS; + if (cpv != -8388608) + { + cp[j] = cpv * TWO_N31 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -3128,7 +3381,7 @@ int decode_msm6(rtcm_t *rtcm, int sys) i += 10; } /* save obs data in msm message */ - save_msm_obs(rtcm, sys, &h, r, pr, cp, NULL, NULL, cnr, lock, NULL, half); + save_msm_obs(rtcm, sys, &h, r, pr, cp, nullptr, nullptr, cnr, lock, nullptr, half); rtcm->obsflag = !sync; return sync ? 0 : 1; @@ -3146,7 +3399,10 @@ int decode_msm7(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 36 + ncell * 80 > rtcm->len * 8) { @@ -3159,14 +3415,20 @@ int decode_msm7(rtcm_t *rtcm, int sys) r[j] = rr[j] = 0.0; ex[j] = 15; } - for (j = 0; j < ncell; j++) pr[j] = cp[j] = rrf[j] = -1E16; + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = rrf[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* extended info */ @@ -3177,26 +3439,38 @@ int decode_msm7(rtcm_t *rtcm, int sys) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* phaserangerate */ rate = getbits(rtcm->buff, i, 14); i += 14; - if (rate != -8192) rr[j] = rate * 1.0; + if (rate != -8192) + { + rr[j] = rate * 1.0; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 20); i += 20; - if (prv != -524288) pr[j] = prv * TWO_N29 * RANGE_MS; + if (prv != -524288) + { + pr[j] = prv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 24); i += 24; - if (cpv != -8388608) cp[j] = cpv * TWO_N31 * RANGE_MS; + if (cpv != -8388608) + { + cp[j] = cpv * TWO_N31 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -3217,7 +3491,10 @@ int decode_msm7(rtcm_t *rtcm, int sys) { /* phaserangerate */ rrv = getbits(rtcm->buff, i, 15); i += 15; - if (rrv != -16384) rrf[j] = rrv * 0.0001; + if (rrv != -16384) + { + rrf[j] = rrv * 0.0001; + } } /* save obs data in msm message */ save_msm_obs(rtcm, sys, &h, r, pr, cp, rr, rrf, cnr, lock, ex, half); @@ -3623,11 +3900,17 @@ int decode_rtcm3(rtcm_t *rtcm) { type -= 1000; if (1 <= type && type <= 299) - rtcm->nmsg3[type]++; /* 1001-1299 */ + { + rtcm->nmsg3[type]++; /* 1001-1299 */ + } else if (1000 <= type && type <= 1099) - rtcm->nmsg3[type - 700]++; /* 2000-2099 */ + { + rtcm->nmsg3[type - 700]++; /* 2000-2099 */ + } else - rtcm->nmsg3[0]++; + { + rtcm->nmsg3[0]++; + } } return ret; } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.h b/src/algorithms/libs/rtklib/rtklib_rtcm3.h index b907f223d..847bae424 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.h +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.h @@ -64,38 +64,38 @@ const double RANGE_MS = SPEED_OF_LIGHT * 0.001; /* range in 1 ms */ /* ssr update intervals ------------------------------------------------------*/ -const double ssrudint[16] = { +const double SSRUDINT[16] = { 1, 2, 5, 10, 15, 30, 60, 120, 240, 300, 600, 900, 1800, 3600, 7200, 10800}; /* ssr 3 and 7 signal and tracking mode ids ----------------------------------*/ -const int codes_gps[] = { +const int CODES_GPS[] = { CODE_L1C, CODE_L1P, CODE_L1W, CODE_L1Y, CODE_L1M, CODE_L2C, CODE_L2D, CODE_L2S, CODE_L2L, CODE_L2X, CODE_L2P, CODE_L2W, CODE_L2Y, CODE_L2M, CODE_L5I, CODE_L5Q, CODE_L5X}; -const int codes_glo[] = { +const int CODES_GLO[] = { CODE_L1C, CODE_L1P, CODE_L2C, CODE_L2P}; -const int codes_gal[] = { +const int CODES_GAL[] = { CODE_L1A, CODE_L1B, CODE_L1C, CODE_L1X, CODE_L1Z, CODE_L5I, CODE_L5Q, CODE_L5X, CODE_L7I, CODE_L7Q, CODE_L7X, CODE_L8I, CODE_L8Q, CODE_L8X, CODE_L6A, CODE_L6B, CODE_L6C, CODE_L6X, CODE_L6Z}; -const int codes_qzs[] = { +const int CODES_QZS[] = { CODE_L1C, CODE_L1S, CODE_L1L, CODE_L2S, CODE_L2L, CODE_L2X, CODE_L5I, CODE_L5Q, CODE_L5X, CODE_L6S, CODE_L6L, CODE_L6X, CODE_L1X}; -const int codes_bds[] = { +const int CODES_BDS[] = { CODE_L1I, CODE_L1Q, CODE_L1X, CODE_L7I, CODE_L7Q, CODE_L7X, CODE_L6I, CODE_L6Q, CODE_L6X}; -const int codes_sbs[] = { +const int CODES_SBS[] = { CODE_L1C, CODE_L5I, CODE_L5Q, CODE_L5X}; diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 20f939dd4..35c7b3939 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -52,16 +52,19 @@ #include "rtklib_rtkcmn.h" //#include +#include #include #include -#include +#include +#include #include +#include #include -const double gpst0[] = {1980, 1, 6, 0, 0, 0}; /* gps time reference */ -const double gst0[] = {1999, 8, 22, 0, 0, 0}; /* galileo system time reference */ -const double bdt0[] = {2006, 1, 1, 0, 0, 0}; /* beidou time reference */ +const double GPST0[] = {1980, 1, 6, 0, 0, 0}; /* gps time reference */ +const double GST0[] = {1999, 8, 22, 0, 0, 0}; /* galileo system time reference */ +const double BDT0[] = {2006, 1, 1, 0, 0, 0}; /* beidou time reference */ static double timeoffset_ = 0.0; @@ -87,38 +90,6 @@ double leaps[MAXLEAPS + 1][7] = {/* leap seconds (y,m,d,h,m,s,utc-gpst) */ {}}; -const prcopt_t prcopt_default = { /* defaults processing options */ - PMODE_SINGLE, 0, 2, SYS_GPS, /* mode, soltype, nf, navsys */ - 15.0 * D2R, {{}, {{}, {}}}, /* elmin, snrmask */ - 0, 1, 1, 1, /* sateph, modear, glomodear, bdsmodear */ - 5, 0, 10, 1, /* maxout, minlock, minfix, armaxiter */ - 0, 0, 0, 0, /* estion, esttrop, dynamics, tidecorr */ - 1, 0, 0, 0, 0, /* niter, codesmooth, intpref, sbascorr, sbassatsel */ - 0, 0, /* rovpos, refpos */ - {100.0, 100.0, 100.0}, /* eratio[] */ - {100.0, 0.003, 0.003, 0.0, 1.0}, /* err[] */ - {30.0, 0.03, 0.3}, /* std[] */ - {1e-4, 1e-3, 1e-4, 1e-1, 1e-2, 0.0}, /* prn[] */ - 5E-12, /* sclkstab */ - {3.0, 0.9999, 0.25, 0.1, 0.05, 0, 0, 0}, /* thresar */ - 0.0, 0.0, 0.05, /* elmaskar, almaskhold, thresslip */ - 30.0, 30.0, 30.0, /* maxtdif, maxinno, maxgdop */ - {}, {}, {}, /* baseline, ru, rb */ - {"", ""}, /* anttype */ - {}, {}, {}, /* antdel, pcv, exsats */ - 0, 0, 0, {"", ""}, {}, 0, {{}, {}}, {{}, {{}, {}}, {{}, {}}, {}, {}}, 0, {}}; - - -const solopt_t solopt_default = { - /* defaults solution output options */ - SOLF_LLH, TIMES_GPST, 1, 3, /* posf, times, timef, timeu */ - 0, 1, 0, 0, 0, 0, /* degf, outhead, outopt, datum, height, geoid */ - 0, 0, 0, /* solstatic, sstat, trace */ - {0.0, 0.0}, /* nmeaintv */ - " ", "", 0 /* separator/program name */ -}; - - const char *formatstrs[32] = {/* stream format strings */ "RTCM 2", /* 0 */ "RTCM 3", /* 1 */ @@ -141,7 +112,7 @@ const char *formatstrs[32] = {/* stream format strings */ "RINEX CLK", /* 18 */ "SBAS", /* 19 */ "NMEA 0183", /* 20 */ - NULL}; + nullptr}; char obscodes[][3] = { @@ -180,10 +151,10 @@ char codepris[7][MAXFREQ][16] = { }; -fatalfunc_t *fatalfunc = NULL; /* fatal callback function */ +fatalfunc_t *fatalfunc = nullptr; /* fatal callback function */ /* crc tables generated by util/gencrc ---------------------------------------*/ -const unsigned short tbl_CRC16[] = { +const uint16_t TBL_CR_C16[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, @@ -218,7 +189,7 @@ const unsigned short tbl_CRC16[] = { 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0}; -const unsigned int tbl_CRC24Q[] = { +const unsigned int TBL_CR_C24_Q[] = { 0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17, 0xA18139, 0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E, 0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E, @@ -253,11 +224,12 @@ const unsigned int tbl_CRC24Q[] = { 0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538}; -extern "C" { -void dgemm_(char *, char *, int *, int *, int *, double *, double *, int *, double *, int *, double *, double *, int *); -extern void dgetrf_(int *, int *, double *, int *, int *, int *); -extern void dgetri_(int *, double *, int *, int *, double *, int *, int *); -extern void dgetrs_(char *, int *, int *, double *, int *, int *, double *, int *, int *); +extern "C" +{ + void dgemm_(char *, char *, int *, int *, int *, double *, double *, int *, double *, int *, double *, double *, int *); + extern void dgetrf_(int *, int *, double *, int *, int *, int *); + extern void dgetri_(int *, double *, int *, int *, double *, int *, int *); + extern void dgetrs_(char *, int *, int *, double *, int *, int *, double *, int *, int *); } @@ -291,33 +263,60 @@ void fatalerr(const char *format, ...) *-----------------------------------------------------------------------------*/ int satno(int sys, int prn) { - if (prn <= 0) return 0; + if (prn <= 0) + { + return 0; + } switch (sys) { case SYS_GPS: - if (prn < MINPRNGPS || MAXPRNGPS < prn) return 0; + if (prn < MINPRNGPS || MAXPRNGPS < prn) + { + return 0; + } return prn - MINPRNGPS + 1; case SYS_GLO: - if (prn < MINPRNGLO || MAXPRNGLO < prn) return 0; + if (prn < MINPRNGLO || MAXPRNGLO < prn) + { + return 0; + } return NSATGPS + prn - MINPRNGLO + 1; case SYS_GAL: - if (prn < MINPRNGAL || MAXPRNGAL < prn) return 0; + if (prn < MINPRNGAL || MAXPRNGAL < prn) + { + return 0; + } return NSATGPS + NSATGLO + prn - MINPRNGAL + 1; case SYS_QZS: - if (prn < MINPRNQZS || MAXPRNQZS < prn) return 0; + if (prn < MINPRNQZS || MAXPRNQZS < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + prn - MINPRNQZS + 1; case SYS_BDS: - if (prn < MINPRNBDS || MAXPRNBDS < prn) return 0; + if (prn < MINPRNBDS || MAXPRNBDS < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + prn - MINPRNBDS + 1; case SYS_IRN: - if (prn < MINPRNIRN || MAXPRNIRN < prn) return 0; + if (prn < MINPRNIRN || MAXPRNIRN < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + prn - MINPRNIRN + 1; case SYS_LEO: - if (prn < MINPRNLEO || MAXPRNLEO < prn) return 0; + if (prn < MINPRNLEO || MAXPRNLEO < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + NSATIRN + prn - MINPRNLEO + 1; case SYS_SBS: - if (prn < MINPRNSBS || MAXPRNSBS < prn) return 0; + if (prn < MINPRNSBS || MAXPRNSBS < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + NSATIRN + NSATLEO + prn - MINPRNSBS + 1; } @@ -335,7 +334,9 @@ int satsys(int sat, int *prn) { int sys = SYS_NONE; if (sat <= 0 || MAXSAT < sat) - sat = 0; + { + sat = 0; + } else if (sat <= NSATGPS) { sys = SYS_GPS; @@ -377,8 +378,13 @@ int satsys(int sat, int *prn) sat += MINPRNSBS - 1; } else - sat = 0; - if (prn) *prn = sat; + { + sat = 0; + } + if (prn) + { + *prn = sat; + } return sys; } @@ -397,16 +403,27 @@ int satid2no(const char *id) if (sscanf(id, "%d", &prn) == 1) { if (MINPRNGPS <= prn && prn <= MAXPRNGPS) - sys = SYS_GPS; + { + sys = SYS_GPS; + } else if (MINPRNSBS <= prn && prn <= MAXPRNSBS) - sys = SYS_SBS; + { + sys = SYS_SBS; + } else if (MINPRNQZS <= prn && prn <= MAXPRNQZS) - sys = SYS_QZS; + { + sys = SYS_QZS; + } else - return 0; + { + return 0; + } return satno(sys, prn); } - if (sscanf(id, "%c%d", &code, &prn) < 2) return 0; + if (sscanf(id, "%c%d", &code, &prn) < 2) + { + return 0; + } switch (code) { @@ -498,7 +515,7 @@ void satno2id(int sat, char *id) *-----------------------------------------------------------------------------*/ int satexclude(int sat, int svh, const prcopt_t *opt) { - int sys = satsys(sat, NULL); + int sys = satsys(sat, nullptr); if (svh < 0) { @@ -513,14 +530,20 @@ int satexclude(int sat, int svh, const prcopt_t *opt) trace(3, "excluded satellite: sat=%3d svh=%02X\n", sat, svh); return 1; /* excluded satellite */ } - if (opt->exsats[sat - 1] == 2) return 0; /* included satellite */ + if (opt->exsats[sat - 1] == 2) + { + return 0; /* included satellite */ + } if (!(sys & opt->navsys)) { trace(3, "unselected sat sys: sat=%3d svh=%02X\n", sat, svh); return 1; /* unselected sat sys */ } } - if (sys == SYS_QZS) svh &= 0xFE; /* mask QZSS LEX health */ + if (sys == SYS_QZS) + { + svh &= 0xFE; /* mask QZSS LEX health */ + } if (svh) { trace(3, "unhealthy satellite: sat=%3d svh=%02X\n", sat, svh); @@ -545,17 +568,26 @@ int testsnr(int base, int freq, double el, double snr, double minsnr, a; int i; - if (!mask->ena[base] || freq < 0 || freq >= NFREQ) return 0; + if (!mask->ena[base] || freq < 0 || freq >= NFREQ) + { + return 0; + } a = (el * R2D + 5.0) / 10.0; - i = (int)floor(a); + i = static_cast(floor(a)); a -= i; if (i < 1) - minsnr = mask->mask[freq][0]; + { + minsnr = mask->mask[freq][0]; + } else if (i > 8) - minsnr = mask->mask[freq][8]; + { + minsnr = mask->mask[freq][8]; + } else - minsnr = (1.0 - a) * mask->mask[freq][i - 1] + a * mask->mask[freq][i]; + { + minsnr = (1.0 - a) * mask->mask[freq][i - 1] + a * mask->mask[freq][i]; + } return snr < minsnr; } @@ -572,12 +604,21 @@ int testsnr(int base, int freq, double el, double snr, unsigned char obs2code(const char *obs, int *freq) { int i; - if (freq) *freq = 0; + if (freq) + { + *freq = 0; + } for (i = 1; *obscodes[i]; i++) { - if (strcmp(obscodes[i], obs)) continue; - if (freq) *freq = obsfreqs[i]; - return (unsigned char)i; + if (strcmp(obscodes[i], obs) != 0) + { + continue; + } + if (freq) + { + *freq = obsfreqs[i]; + } + return static_cast(i); } return CODE_NONE; } @@ -594,9 +635,18 @@ unsigned char obs2code(const char *obs, int *freq) *-----------------------------------------------------------------------------*/ char *code2obs(unsigned char code, int *freq) { - if (freq) *freq = 0; - if (code <= CODE_NONE || MAXCODE < code) return (char *)""; - if (freq) *freq = obsfreqs[code]; + if (freq) + { + *freq = 0; + } + if (code <= CODE_NONE || MAXCODE < code) + { + return (char *)""; + } + if (freq) + { + *freq = obsfreqs[code]; + } return obscodes[code]; } @@ -613,16 +663,40 @@ void setcodepri(int sys, int freq, const char *pri) { trace(3, "setcodepri : sys=%d freq=%d pri=%s\n", sys, freq, pri); - if (freq <= 0 || MAXFREQ < freq) return; + if (freq <= 0 || MAXFREQ < freq) + { + return; + } if (strlen(pri) < 17) { - if (sys & SYS_GPS) strcpy(codepris[0][freq - 1], pri); - if (sys & SYS_GLO) strcpy(codepris[1][freq - 1], pri); - if (sys & SYS_GAL) strcpy(codepris[2][freq - 1], pri); - if (sys & SYS_QZS) strcpy(codepris[3][freq - 1], pri); - if (sys & SYS_SBS) strcpy(codepris[4][freq - 1], pri); - if (sys & SYS_BDS) strcpy(codepris[5][freq - 1], pri); - if (sys & SYS_IRN) strcpy(codepris[6][freq - 1], pri); + if (sys & SYS_GPS) + { + strcpy(codepris[0][freq - 1], pri); + } + if (sys & SYS_GLO) + { + strcpy(codepris[1][freq - 1], pri); + } + if (sys & SYS_GAL) + { + strcpy(codepris[2][freq - 1], pri); + } + if (sys & SYS_QZS) + { + strcpy(codepris[3][freq - 1], pri); + } + if (sys & SYS_SBS) + { + strcpy(codepris[4][freq - 1], pri); + } + if (sys & SYS_BDS) + { + strcpy(codepris[5][freq - 1], pri); + } + if (sys & SYS_IRN) + { + strcpy(codepris[6][freq - 1], pri); + } } else { @@ -682,11 +756,14 @@ int getcodepri(int sys, unsigned char code, const char *opt) /* parse code options */ for (p = opt; p && (p = strchr(p, '-')); p++) { - if (sscanf(p, optstr, str) < 1 || str[0] != obs[0]) continue; + if (sscanf(p, optstr, str) < 1 || str[0] != obs[0]) + { + continue; + } return str[1] == obs[1] ? 15 : 0; } /* search code priority */ - return (p = strchr(codepris[i][j - 1], obs[1])) ? 14 - (int)(p - codepris[i][j - 1]) : 0; + return (p = strchr(codepris[i][j - 1], obs[1])) ? 14 - static_cast(p - codepris[i][j - 1]) : 0; } @@ -701,7 +778,10 @@ unsigned int getbitu(const unsigned char *buff, int pos, int len) { unsigned int bits = 0; int i; - for (i = pos; i < pos + len; i++) bits = (bits << 1) + ((buff[i / 8] >> (7 - i % 8)) & 1u); + for (i = pos; i < pos + len; i++) + { + bits = (bits << 1) + ((buff[i / 8] >> (7 - i % 8)) & 1u); + } return bits; } @@ -709,8 +789,11 @@ unsigned int getbitu(const unsigned char *buff, int pos, int len) int getbits(const unsigned char *buff, int pos, int len) { unsigned int bits = getbitu(buff, pos, len); - if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) return (int)bits; - return (int)(bits | (~0u << len)); /* extend sign */ + if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) + { + return static_cast(bits); + } + return static_cast(bits | (~0u << len)); /* extend sign */ } @@ -726,13 +809,20 @@ void setbitu(unsigned char *buff, int pos, int len, unsigned int data) { unsigned int mask = 1u << (len - 1); int i; - if (len <= 0 || 32 < len) return; + if (len <= 0 || 32 < len) + { + return; + } for (i = pos; i < pos + len; i++, mask >>= 1) { if (data & mask) - buff[i / 8] |= 1u << (7 - i % 8); + { + buff[i / 8] |= 1u << (7 - i % 8); + } else - buff[i / 8] &= ~(1u << (7 - i % 8)); + { + buff[i / 8] &= ~(1u << (7 - i % 8)); + } } } @@ -740,10 +830,14 @@ void setbitu(unsigned char *buff, int pos, int len, unsigned int data) void setbits(unsigned char *buff, int pos, int len, int data) { if (data < 0) - data |= 1 << (len - 1); + { + data |= 1 << (len - 1); + } else - data &= ~(1 << (len - 1)); /* set sign bit */ - setbitu(buff, pos, len, (unsigned int)data); + { + data &= ~(1 << (len - 1)); /* set sign bit */ + } + setbitu(buff, pos, len, static_cast(data)); } @@ -767,9 +861,13 @@ unsigned int rtk_crc32(const unsigned char *buff, int len) for (j = 0; j < 8; j++) { if (crc & 1) - crc = (crc >> 1) ^ POLYCRC32; + { + crc = (crc >> 1) ^ POLYCRC32; + } else - crc >>= 1; + { + crc >>= 1; + } } } return crc; @@ -790,7 +888,10 @@ unsigned int rtk_crc24q(const unsigned char *buff, int len) trace(4, "rtk_crc24q: len=%d\n", len); - for (i = 0; i < len; i++) crc = ((crc << 8) & 0xFFFFFF) ^ tbl_CRC24Q[(crc >> 16) ^ buff[i]]; + for (i = 0; i < len; i++) + { + crc = ((crc << 8) & 0xFFFFFF) ^ TBL_CR_C24_Q[(crc >> 16) ^ buff[i]]; + } return crc; } @@ -802,16 +903,16 @@ unsigned int rtk_crc24q(const unsigned char *buff, int len) * return : crc-16 parity * notes : see reference [10] A.3. *-----------------------------------------------------------------------------*/ -unsigned short rtk_crc16(const unsigned char *buff, int len) +uint16_t rtk_crc16(const unsigned char *buff, int len) { - unsigned short crc = 0; + uint16_t crc = 0; int i; trace(4, "rtk_crc16: len=%d\n", len); for (i = 0; i < len; i++) { - crc = (crc << 8) ^ tbl_CRC16[((crc >> 8) ^ buff[i]) & 0xFF]; + crc = (crc << 8) ^ TBL_CR_C16[((crc >> 8) ^ buff[i]) & 0xFF]; } return crc; } @@ -835,16 +936,28 @@ int decode_word(unsigned int word, unsigned char *data) trace(5, "decodeword: word=%08x\n", word); - if (word & 0x40000000) word ^= 0x3FFFFFC0; + if (word & 0x40000000) + { + word ^= 0x3FFFFFC0; + } for (i = 0; i < 6; i++) { parity <<= 1; - for (w = (word & hamming[i]) >> 6; w; w >>= 1) parity ^= w & 1; + for (w = (word & hamming[i]) >> 6; w; w >>= 1) + { + parity ^= w & 1; + } + } + if (parity != (word & 0x3F)) + { + return 0; } - if (parity != (word & 0x3F)) return 0; - for (i = 0; i < 3; i++) data[i] = (unsigned char)(word >> (22 - i * 8)); + for (i = 0; i < 3; i++) + { + data[i] = static_cast(word >> (22 - i * 8)); + } return 1; } @@ -858,8 +971,11 @@ double *mat(int n, int m) { double *p; - if (n <= 0 || m <= 0) return NULL; - if (!(p = (double *)malloc(sizeof(double) * n * m))) + if (n <= 0 || m <= 0) + { + return nullptr; + } + if (!(p = static_cast(malloc(sizeof(double) * n * m)))) { fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m); } @@ -876,8 +992,11 @@ int *imat(int n, int m) { int *p; - if (n <= 0 || m <= 0) return NULL; - if (!(p = (int *)malloc(sizeof(int) * n * m))) + if (n <= 0 || m <= 0) + { + return nullptr; + } + if (!(p = static_cast(malloc(sizeof(int) * n * m)))) { fatalerr("integer matrix memory allocation error: n=%d,m=%d\n", n, m); } @@ -898,8 +1017,11 @@ double *zeros(int n, int m) if ((p = mat(n, m))) for (n = n * m - 1; n >= 0; n--) p[n] = 0.0; #else - if (n <= 0 || m <= 0) return NULL; - if (!(p = (double *)calloc(sizeof(double), n * m))) + if (n <= 0 || m <= 0) + { + return nullptr; + } + if (!(p = static_cast(calloc(sizeof(double), n * m)))) { fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m); } @@ -919,7 +1041,12 @@ double *eye(int n) int i; if ((p = zeros(n, n))) - for (i = 0; i < n; i++) p[i + i * n] = 1.0; + { + for (i = 0; i < n; i++) + { + p[i + i * n] = 1.0; + } + } return p; } @@ -934,7 +1061,10 @@ double dot(const double *a, const double *b, int n) { double c = 0.0; - while (--n >= 0) c += a[n] * b[n]; + while (--n >= 0) + { + c += a[n] * b[n]; + } return c; } @@ -974,7 +1104,10 @@ void cross3(const double *a, const double *b, double *c) int normv3(const double *a, double *b) { double r; - if ((r = norm_rtk(a, 3)) <= 0.0) return 0; + if ((r = norm_rtk(a, 3)) <= 0.0) + { + return 0; + } b[0] = a[0] / r; b[1] = a[1] / r; b[2] = a[2] / r; @@ -1012,7 +1145,7 @@ void matmul(const char *tr, int n, int k, int m, double alpha, { int lda = tr[0] == 'T' ? m : n, ldb = tr[1] == 'T' ? k : m; - dgemm_((char *)tr, (char *)tr + 1, &n, &k, &m, &alpha, (double *)A, &lda, (double *)B, + dgemm_(const_cast(tr), const_cast(tr) + 1, &n, &k, &m, &alpha, const_cast(A), &lda, const_cast(B), &ldb, &beta, C, &n); } @@ -1030,7 +1163,10 @@ int matinv(double *A, int n) work = mat(lwork, 1); dgetrf_(&n, &n, A, &n, ipiv, &info); - if (!info) dgetri_(&n, A, &n, ipiv, work, &lwork, &info); + if (!info) + { + dgetri_(&n, A, &n, ipiv, work, &lwork, &info); + } free(ipiv); free(work); return info; @@ -1057,7 +1193,10 @@ int solve(const char *tr, const double *A, const double *Y, int n, matcpy(B, A, n, n); matcpy(X, Y, n, m); dgetrf_(&n, &n, B, &n, ipiv, &info); - if (!info) dgetrs_((char *)tr, &n, &m, B, &n, ipiv, X, &n, &info); + if (!info) + { + dgetrs_(const_cast(tr), &n, &m, B, &n, ipiv, X, &n, &info); + } free(ipiv); free(B); return info; @@ -1083,11 +1222,17 @@ int lsq(const double *A, const double *y, int n, int m, double *x, double *Ay; int info; - if (m < n) return -1; + if (m < n) + { + return -1; + } Ay = mat(n, 1); - matmul("NN", n, 1, m, 1.0, A, y, 0.0, Ay); /* Ay=A*y */ - matmul("NT", n, n, m, 1.0, A, A, 0.0, Q); /* Q=A*A' */ - if (!(info = matinv(Q, n))) matmul("NN", n, 1, n, 1.0, Q, Ay, 0.0, x); /* x=Q^-1*Ay */ + matmul("NN", n, 1, m, 1.0, A, y, 0.0, Ay); /* Ay=A*y */ + matmul("NT", n, n, m, 1.0, A, A, 0.0, Q); /* Q=A*A' */ + if (!(info = matinv(Q, n))) + { + matmul("NN", n, 1, n, 1.0, Q, Ay, 0.0, x); /* x=Q^-1*Ay */ + } free(Ay); return info; } @@ -1144,7 +1289,12 @@ int filter(double *x, double *P, const double *H, const double *v, ix = imat(n, 1); for (i = k = 0; i < n; i++) - if (x[i] != 0.0 && P[i + i * n] > 0.0) ix[k++] = i; + { + if (x[i] != 0.0 && P[i + i * n] > 0.0) + { + ix[k++] = i; + } + } x_ = mat(k, 1); xp_ = mat(k, 1); P_ = mat(k, k); @@ -1153,14 +1303,23 @@ int filter(double *x, double *P, const double *H, const double *v, for (i = 0; i < k; i++) { x_[i] = x[ix[i]]; - for (j = 0; j < k; j++) P_[i + j * k] = P[ix[i] + ix[j] * n]; - for (j = 0; j < m; j++) H_[i + j * k] = H[ix[i] + j * n]; + for (j = 0; j < k; j++) + { + P_[i + j * k] = P[ix[i] + ix[j] * n]; + } + for (j = 0; j < m; j++) + { + H_[i + j * k] = H[ix[i] + j * n]; + } } info = filter_(x_, P_, H_, v, R, k, m, xp_, Pp_); for (i = 0; i < k; i++) { x[ix[i]] = xp_[i]; - for (j = 0; j < k; j++) P[ix[i] + ix[j] * n] = Pp_[i + j * k]; + for (j = 0; j < k; j++) + { + P[ix[i] + ix[j] * n] = Pp_[i + j * k]; + } } free(ix); free(x_); @@ -1198,7 +1357,10 @@ int smoother(const double *xf, const double *Qf, const double *xb, matcpy(invQb, Qb, n, n); if (!matinv(invQf, n) && !matinv(invQb, n)) { - for (i = 0; i < n * n; i++) Qs[i] = invQf[i] + invQb[i]; + for (i = 0; i < n * n; i++) + { + Qs[i] = invQf[i] + invQb[i]; + } if (!(info = matinv(Qs, n))) { matmul("NN", n, 1, n, 1.0, invQf, xf, 0.0, xx); @@ -1228,7 +1390,10 @@ void matfprint(const double A[], int n, int m, int p, int q, FILE *fp) for (i = 0; i < n; i++) { - for (j = 0; j < m; j++) fprintf(fp, " %*.*f", p, q, A[i + j * n]); + for (j = 0; j < m; j++) + { + fprintf(fp, " %*.*f", p, q, A[i + j * n]); + } fprintf(fp, "\n"); } } @@ -1268,7 +1433,10 @@ double str2num(const char *s, int i, int n) double value; char str[256], *p = str; - if (i < 0 || (int)strlen(s) < i || (int)sizeof(str) - 1 < n) return 0.0; + if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < n) + { + return 0.0; + } for (s += i; *s && --n >= 0; s++) { *p++ = *s == 'd' || *s == 'D' ? 'E' : *s; @@ -1290,15 +1458,23 @@ int str2time(const char *s, int i, int n, gtime_t *t) double ep[6]; char str[256], *p = str; - if (i < 0 || (int)strlen(s) < i || (int)sizeof(str) - 1 < i) return -1; + if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < i) + { + return -1; + } for (s += i; *s && --n >= 0;) { *p++ = *s++; } *p = '\0'; if (sscanf(str, "%lf %lf %lf %lf %lf %lf", ep, ep + 1, ep + 2, ep + 3, ep + 4, ep + 5) < 6) - return -1; - if (ep[0] < 100.0) ep[0] += ep[0] < 80.0 ? 2000.0 : 1900.0; + { + return -1; + } + if (ep[0] < 100.0) + { + ep[0] += ep[0] < 80.0 ? 2000.0 : 1900.0; + } *t = epoch2time(ep); return 0; } @@ -1314,14 +1490,17 @@ gtime_t epoch2time(const double *ep) { const int doy[] = {1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; gtime_t time = {0, 0}; - int days, sec, year = (int)ep[0], mon = (int)ep[1], day = (int)ep[2]; + int days, sec, year = static_cast(ep[0]), mon = static_cast(ep[1]), day = static_cast(ep[2]); - if (year < 1970 || 2099 < year || mon < 1 || 12 < mon) return time; + if (year < 1970 || 2099 < year || mon < 1 || 12 < mon) + { + return time; + } /* leap year if year%4==0 in 1901-2099 */ days = (year - 1970) * 365 + (year - 1969) / 4 + doy[mon - 1] + day - 2 + (year % 4 == 0 && mon >= 3 ? 1 : 0); - sec = (int)floor(ep[5]); - time.time = (time_t)days * 86400 + (int)ep[3] * 3600 + (int)ep[4] * 60 + sec; + sec = static_cast(floor(ep[5])); + time.time = static_cast(days) * 86400 + static_cast(ep[3]) * 3600 + static_cast(ep[4]) * 60 + sec; time.sec = ep[5] - sec; return time; } @@ -1342,14 +1521,18 @@ void time2epoch(gtime_t t, double *ep) int days, sec, mon, day; /* leap year if year%4==0 in 1901-2099 */ - days = (int)(t.time / 86400); - sec = (int)(t.time - (time_t)days * 86400); + days = static_cast(t.time / 86400); + sec = static_cast(t.time - static_cast(days) * 86400); for (day = days % 1461, mon = 0; mon < 48; mon++) { if (day >= mday[mon]) - day -= mday[mon]; + { + day -= mday[mon]; + } else - break; + { + break; + } } ep[0] = 1970 + days / 1461 * 4 + mon / 12; ep[1] = mon % 12 + 1; @@ -1368,11 +1551,14 @@ void time2epoch(gtime_t t, double *ep) *-----------------------------------------------------------------------------*/ gtime_t gpst2time(int week, double sec) { - gtime_t t = epoch2time(gpst0); + gtime_t t = epoch2time(GPST0); - if (sec < -1e9 || 1e9 < sec) sec = 0.0; - t.time += (time_t)86400 * 7 * week + (int)sec; - t.sec = sec - (int)sec; + if (sec < -1e9 || 1e9 < sec) + { + sec = 0.0; + } + t.time += static_cast(86400) * 7 * week + static_cast(sec); + t.sec = sec - static_cast(sec); return t; } @@ -1385,11 +1571,14 @@ gtime_t gpst2time(int week, double sec) *-----------------------------------------------------------------------------*/ double time2gpst(gtime_t t, int *week) { - gtime_t t0 = epoch2time(gpst0); + gtime_t t0 = epoch2time(GPST0); time_t sec = t.time - t0.time; int w = static_cast(sec / 604800); - if (week) *week = w; + if (week) + { + *week = w; + } return (static_cast(sec - static_cast(w * 604800)) + t.sec); } @@ -1402,11 +1591,14 @@ double time2gpst(gtime_t t, int *week) *-----------------------------------------------------------------------------*/ gtime_t gst2time(int week, double sec) { - gtime_t t = epoch2time(gst0); + gtime_t t = epoch2time(GST0); - if (sec < -1e9 || 1e9 < sec) sec = 0.0; - t.time += (time_t)86400 * 7 * week + (int)sec; - t.sec = sec - (int)sec; + if (sec < -1e9 || 1e9 < sec) + { + sec = 0.0; + } + t.time += static_cast(86400) * 7 * week + static_cast(sec); + t.sec = sec - static_cast(sec); return t; } @@ -1419,12 +1611,15 @@ gtime_t gst2time(int week, double sec) *-----------------------------------------------------------------------------*/ double time2gst(gtime_t t, int *week) { - gtime_t t0 = epoch2time(gst0); + gtime_t t0 = epoch2time(GST0); time_t sec = t.time - t0.time; - int w = (int)(sec / (86400 * 7)); + int w = static_cast(sec / (86400 * 7)); - if (week) *week = w; - return (double)(sec - (double)w * 86400 * 7) + t.sec; + if (week) + { + *week = w; + } + return (sec - static_cast(w) * 86400 * 7) + t.sec; } @@ -1436,11 +1631,14 @@ double time2gst(gtime_t t, int *week) *-----------------------------------------------------------------------------*/ gtime_t bdt2time(int week, double sec) { - gtime_t t = epoch2time(bdt0); + gtime_t t = epoch2time(BDT0); - if (sec < -1e9 || 1e9 < sec) sec = 0.0; - t.time += (time_t)86400 * 7 * week + (int)sec; - t.sec = sec - (int)sec; + if (sec < -1e9 || 1e9 < sec) + { + sec = 0.0; + } + t.time += static_cast(86400) * 7 * week + static_cast(sec); + t.sec = sec - static_cast(sec); return t; } @@ -1453,12 +1651,15 @@ gtime_t bdt2time(int week, double sec) *-----------------------------------------------------------------------------*/ double time2bdt(gtime_t t, int *week) { - gtime_t t0 = epoch2time(bdt0); + gtime_t t0 = epoch2time(BDT0); time_t sec = t.time - t0.time; - int w = (int)(sec / (86400 * 7)); + int w = static_cast(sec / (86400 * 7)); - if (week) *week = w; - return (double)(sec - (double)w * 86400 * 7) + t.sec; + if (week) + { + *week = w; + } + return (sec - static_cast(w) * 86400 * 7) + t.sec; } @@ -1474,7 +1675,7 @@ gtime_t timeadd(gtime_t t, double sec) t.sec += sec; tt = floor(t.sec); - t.time += (int)tt; + t.time += static_cast(tt); t.sec -= tt; return t; } @@ -1500,10 +1701,12 @@ gtime_t timeget(void) { gtime_t time; double ep[6] = {}; - struct timeval tv; + struct timeval tv + { + }; struct tm *tt; - if (!gettimeofday(&tv, NULL) && (tt = gmtime(&tv.tv_sec))) + if (!gettimeofday(&tv, nullptr) && (tt = gmtime(&tv.tv_sec))) { ep[0] = tt->tm_year + 1900; ep[1] = tt->tm_mon + 1; @@ -1544,10 +1747,19 @@ int read_leaps_text(FILE *fp) while (fgets(buff, sizeof(buff), fp) && n < MAXLEAPS) { - if ((p = strchr(buff, '#'))) *p = '\0'; + if ((p = strchr(buff, '#'))) + { + *p = '\0'; + } if (sscanf(buff, "%d %d %d %d %d %d %d", ep, ep + 1, ep + 2, ep + 3, ep + 4, ep + 5, - &ls) < 7) continue; - for (i = 0; i < 6; i++) leaps[n][i] = ep[i]; + &ls) < 7) + { + continue; + } + for (i = 0; i < 6; i++) + { + leaps[n][i] = ep[i]; + } leaps[n++][6] = ls; } return n; @@ -1568,21 +1780,37 @@ int read_leaps_usno(FILE *fp) while (fgets(buff, sizeof(buff), fp) && n < MAXLEAPS) { if (sscanf(buff, "%d %s %d =JD %lf TAI-UTC= %lf", &y, month, &d, &jd, - &tai_utc) < 5) continue; - if (y < 1980) continue; + &tai_utc) < 5) + { + continue; + } + if (y < 1980) + { + continue; + } for (m = 1; m <= 12; m++) - if (!strcmp(months[m - 1], month)) break; - if (m >= 13) continue; + { + if (!strcmp(months[m - 1], month)) + { + break; + } + } + if (m >= 13) + { + continue; + } ls[n][0] = y; ls[n][1] = m; ls[n][2] = d; - ls[n++][6] = (char)(19.0 - tai_utc); + ls[n++][6] = static_cast(19.0 - tai_utc); } for (i = 0; i < n; i++) - for (j = 0; j < 7; j++) - { - leaps[i][j] = ls[n - i - 1][j]; - } + { + for (j = 0; j < 7; j++) + { + leaps[i][j] = ls[n - i - 1][j]; + } + } return n; } @@ -1603,7 +1831,10 @@ int read_leaps(const char *file) FILE *fp; int i, n; - if (!(fp = fopen(file, "r"))) return 0; + if (!(fp = fopen(file, "re"))) + { + return 0; + } /* read leap seconds table by text or usno */ if (!(n = read_leaps_text(fp)) && !(n = read_leaps_usno(fp))) @@ -1611,7 +1842,10 @@ int read_leaps(const char *file) fclose(fp); return 0; } - for (i = 0; i < 7; i++) leaps[n][i] = 0.0; + for (i = 0; i < 7; i++) + { + leaps[n][i] = 0.0; + } fclose(fp); return 1; } @@ -1631,7 +1865,10 @@ gtime_t gpst2utc(gtime_t t) for (i = 0; leaps[i][0] > 0; i++) { tu = timeadd(t, leaps[i][6]); - if (timediff(tu, epoch2time(leaps[i])) >= 0.0) return tu; + if (timediff(tu, epoch2time(leaps[i])) >= 0.0) + { + return tu; + } } return t; } @@ -1649,7 +1886,10 @@ gtime_t utc2gpst(gtime_t t) for (i = 0; leaps[i][0] > 0; i++) { - if (timediff(t, epoch2time(leaps[i])) >= 0.0) return timeadd(t, -leaps[i][6]); + if (timediff(t, epoch2time(leaps[i])) >= 0.0) + { + return timeadd(t, -leaps[i][6]); + } } return t; } @@ -1729,9 +1969,13 @@ void time2str(gtime_t t, char *s, int n) double ep[6]; if (n < 0) - n = 0; + { + n = 0; + } else if (n > 12) - n = 12; + { + n = 12; + } if (1.0 - t.sec < 0.5 / pow(10.0, n)) { t.time++; @@ -1783,7 +2027,10 @@ int adjgpsweek(int week) { int w; (void)time2gpst(utc2gpst(timeget()), &w); - if (w < 1560) w = 1560; /* use 2009/12/1 if time is earlier than 2009/12/1 */ + if (w < 1560) + { + w = 1560; /* use 2009/12/1 if time is earlier than 2009/12/1 */ + } return week + (w - week + 512) / 1024 * 1024; } @@ -1804,11 +2051,9 @@ unsigned int tickget(void) { return tp.tv_sec * 1000u + tp.tv_nsec / 1000000u; } - else - { - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000u + tv.tv_usec / 1000u; - } + gettimeofday(&tv, nullptr); + return tv.tv_sec * 1000u + tv.tv_usec / 1000u; + #else gettimeofday(&tv, NULL); return tv.tv_sec * 1000u + tv.tv_usec / 1000u; @@ -1824,10 +2069,13 @@ unsigned int tickget(void) void sleepms(int ms) { struct timespec ts = {0, 0}; - if (ms <= 0) return; - ts.tv_sec = (time_t)(ms / 1000); - ts.tv_nsec = (long)(ms % 1000 * 1000000); - nanosleep(&ts, NULL); + if (ms <= 0) + { + return; + } + ts.tv_sec = static_cast(ms / 1000); + ts.tv_nsec = static_cast(ms % 1000 * 1000000); + nanosleep(&ts, nullptr); } @@ -2026,11 +2274,17 @@ void ast_args(double t, double *f) double tt[4]; int i, j; - for (tt[0] = t, i = 1; i < 4; i++) tt[i] = tt[i - 1] * t; + for (tt[0] = t, i = 1; i < 4; i++) + { + tt[i] = tt[i - 1] * t; + } for (i = 0; i < 5; i++) { f[i] = fc[i][0] * 3600.0; - for (j = 0; j < 4; j++) f[i] += fc[i][j + 1] * tt[j]; + for (j = 0; j < 4; j++) + { + f[i] += fc[i][j + 1] * tt[j]; + } f[i] = fmod(f[i] * AS2R, 2.0 * PI); } } @@ -2154,7 +2408,10 @@ void nut_iau1980(double t, const double *f, double *dpsi, double *deps) for (i = 0; i < 106; i++) { ang = 0.0; - for (j = 0; j < 5; j++) ang += nut[i][j] * f[j]; + for (j = 0; j < 5; j++) + { + ang += nut[i][j] * f[j]; + } *dpsi += (nut[i][6] + nut[i][7] * t) * sin(ang); *deps += (nut[i][8] + nut[i][9] * t) * cos(ang); } @@ -2188,8 +2445,14 @@ void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst) if (fabs(timediff(tutc, tutc_)) < 0.01) { /* read cache */ - for (i = 0; i < 9; i++) U[i] = U_[i]; - if (gmst) *gmst = gmst_; + for (i = 0; i < 9; i++) + { + U[i] = U_[i]; + } + if (gmst) + { + *gmst = gmst_; + } return; } tutc_ = tutc; @@ -2236,8 +2499,14 @@ void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst) matmul("NN", 3, 3, 3, 1.0, N, P, 0.0, NP); matmul("NN", 3, 3, 3, 1.0, R, NP, 0.0, U_); /* U=W*Rz(gast)*N*P */ - for (i = 0; i < 9; i++) U[i] = U_[i]; - if (gmst) *gmst = gmst_; + for (i = 0; i < 9; i++) + { + U[i] = U_[i]; + } + if (gmst) + { + *gmst = gmst_; + } trace(5, "gmst=%.12f gast=%.12f\n", gmst_, gast); trace(5, "P=\n"); @@ -2256,8 +2525,11 @@ int decodef(char *p, int n, double *v) { int i; - for (i = 0; i < n; i++) v[i] = 0.0; - for (i = 0, p = strtok(p, " "); p && i < n; p = strtok(NULL, " ")) + for (i = 0; i < n; i++) + { + v[i] = 0.0; + } + for (i = 0, p = strtok(p, " "); p && i < n; p = strtok(nullptr, " ")) { v[i++] = atof(p) * 1e-3; } @@ -2273,11 +2545,11 @@ void addpcv(const pcv_t *pcv, pcvs_t *pcvs) if (pcvs->nmax <= pcvs->n) { pcvs->nmax += 256; - if (!(pcvs_pcv = (pcv_t *)realloc(pcvs->pcv, sizeof(pcv_t) * pcvs->nmax))) + if (!(pcvs_pcv = static_cast(realloc(pcvs->pcv, sizeof(pcv_t) * pcvs->nmax)))) { trace(1, "addpcv: memory allocation error\n"); free(pcvs->pcv); - pcvs->pcv = NULL; + pcvs->pcv = nullptr; pcvs->n = pcvs->nmax = 0; return; } @@ -2297,16 +2569,22 @@ int readngspcv(const char *file, pcvs_t *pcvs) int n = 0; char buff[256]; - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "ngs pcv file open error: %s\n", file); return 0; } while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) >= 62 && buff[61] == '|') continue; + if (strlen(buff) >= 62 && buff[61] == '|') + { + continue; + } - if (buff[0] != ' ') n = 0; /* start line */ + if (buff[0] != ' ') + { + n = 0; /* start line */ + } if (++n == 1) { pcv = pcv0; @@ -2315,25 +2593,36 @@ int readngspcv(const char *file, pcvs_t *pcvs) } else if (n == 2) { - if (decodef(buff, 3, neu) < 3) continue; + if (decodef(buff, 3, neu) < 3) + { + continue; + } pcv.off[0][0] = neu[1]; pcv.off[0][1] = neu[0]; pcv.off[0][2] = neu[2]; } else if (n == 3) - decodef(buff, 10, pcv.var[0]); + { + decodef(buff, 10, pcv.var[0]); + } else if (n == 4) - decodef(buff, 9, pcv.var[0] + 10); + { + decodef(buff, 9, pcv.var[0] + 10); + } else if (n == 5) { - if (decodef(buff, 3, neu) < 3) continue; - ; + if (decodef(buff, 3, neu) < 3) + { + continue; + }; pcv.off[1][0] = neu[1]; pcv.off[1][1] = neu[0]; pcv.off[1][2] = neu[2]; } else if (n == 6) - decodef(buff, 10, pcv.var[1]); + { + decodef(buff, 10, pcv.var[1]); + } else if (n == 7) { decodef(buff, 9, pcv.var[1] + 10); @@ -2358,14 +2647,17 @@ int readantex(const char *file, pcvs_t *pcvs) trace(3, "readantex: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "antex pcv file open error: %s\n", file); return 0; } while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60 || strstr(buff + 60, "COMMENT")) continue; + if (strlen(buff) < 60 || strstr(buff + 60, "COMMENT")) + { + continue; + } if (strstr(buff + 60, "START OF ANTENNA")) { @@ -2377,7 +2669,10 @@ int readantex(const char *file, pcvs_t *pcvs) addpcv(&pcv, pcvs); state = 0; } - if (!state) continue; + if (!state) + { + continue; + } if (strstr(buff + 60, "TYPE / SERIAL NO")) { @@ -2392,18 +2687,35 @@ int readantex(const char *file, pcvs_t *pcvs) } else if (strstr(buff + 60, "VALID FROM")) { - if (!str2time(buff, 0, 43, &pcv.ts)) continue; + if (!str2time(buff, 0, 43, &pcv.ts)) + { + continue; + } } else if (strstr(buff + 60, "VALID UNTIL")) { - if (!str2time(buff, 0, 43, &pcv.te)) continue; + if (!str2time(buff, 0, 43, &pcv.te)) + { + continue; + } } else if (strstr(buff + 60, "START OF FREQUENCY")) { - if (sscanf(buff + 4, "%d", &f) < 1) continue; + if (sscanf(buff + 4, "%d", &f) < 1) + { + continue; + } for (i = 0; i < NFREQ; i++) - if (freqs[i] == f) break; - if (i < NFREQ) freq = i + 1; + { + if (freqs[i] == f) + { + break; + } + } + if (i < NFREQ) + { + freq = i + 1; + } } else if (strstr(buff + 60, "END OF FREQUENCY")) { @@ -2411,17 +2723,32 @@ int readantex(const char *file, pcvs_t *pcvs) } else if (strstr(buff + 60, "NORTH / EAST / UP")) { - if (freq < 1 || NFREQ < freq) continue; - if (decodef(buff, 3, neu) < 3) continue; + if (freq < 1 || NFREQ < freq) + { + continue; + } + if (decodef(buff, 3, neu) < 3) + { + continue; + } pcv.off[freq - 1][0] = neu[pcv.sat ? 0 : 1]; /* x or e */ pcv.off[freq - 1][1] = neu[pcv.sat ? 1 : 0]; /* y or n */ pcv.off[freq - 1][2] = neu[2]; /* z or u */ } else if (strstr(buff, "NOAZI")) { - if (freq < 1 || NFREQ < freq) continue; - if ((i = decodef(buff + 8, 19, pcv.var[freq - 1])) <= 0) continue; - for (; i < 19; i++) pcv.var[freq - 1][i] = pcv.var[freq - 1][i - 1]; + if (freq < 1 || NFREQ < freq) + { + continue; + } + if ((i = decodef(buff + 8, 19, pcv.var[freq - 1])) <= 0) + { + continue; + } + for (; i < 19; i++) + { + pcv.var[freq - 1][i] = pcv.var[freq - 1][i - 1]; + } } } fclose(fp); @@ -2494,42 +2821,70 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time, for (i = 0; i < pcvs->n; i++) { pcv = pcvs->pcv + i; - if (pcv->sat != sat) continue; - if (pcv->ts.time != 0 && timediff(pcv->ts, time) > 0.0) continue; - if (pcv->te.time != 0 && timediff(pcv->te, time) < 0.0) continue; + if (pcv->sat != sat) + { + continue; + } + if (pcv->ts.time != 0 && timediff(pcv->ts, time) > 0.0) + { + continue; + } + if (pcv->te.time != 0 && timediff(pcv->te, time) < 0.0) + { + continue; + } return pcv; } } else { if (strlen(type) < MAXANT + 1) - strcpy(buff, type); + { + strcpy(buff, type); + } else { trace(1, "type array is too long"); } - for (p = strtok(buff, " "); p && n < 2; p = strtok(NULL, " ")) types[n++] = p; - if (n <= 0) return NULL; + for (p = strtok(buff, " "); p && n < 2; p = strtok(nullptr, " ")) + { + types[n++] = p; + } + if (n <= 0) + { + return nullptr; + } /* search receiver antenna with radome at first */ for (i = 0; i < pcvs->n; i++) { pcv = pcvs->pcv + i; for (j = 0; j < n; j++) - if (!strstr(pcv->type, types[j])) break; - if (j >= n) return pcv; + { + if (!strstr(pcv->type, types[j])) + { + break; + } + } + if (j >= n) + { + return pcv; + } } /* search receiver antenna without radome */ for (i = 0; i < pcvs->n; i++) { pcv = pcvs->pcv + i; - if (strstr(pcv->type, types[0]) != pcv->type) continue; + if (strstr(pcv->type, types[0]) != pcv->type) + { + continue; + } trace(2, "pcv without radome is used type=%s\n", type); return pcv; } } - return NULL; + return nullptr; } @@ -2552,25 +2907,38 @@ void readpos(const char *file, const char *rcv, double *pos) trace(3, "readpos: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { fprintf(stderr, "reference position file open error : %s\n", file); return; } while (np < 2048 && fgets(buff, sizeof(buff), fp)) { - if (buff[0] == '%' || buff[0] == '#') continue; + if (buff[0] == '%' || buff[0] == '#') + { + continue; + } if (sscanf(buff, "%lf %lf %lf %s", &poss[np][0], &poss[np][1], &poss[np][2], - str) < 4) continue; - strncpy(stas[np], str, 15); + str) < 4) + { + continue; + } + // strncpy(stas[np], str, 15); This line triggers a warning. Replaced by: + memcpy(stas[np], str, 15 * sizeof(stas[np][0])); stas[np++][15] = '\0'; } fclose(fp); - len = (int)strlen(rcv); + len = static_cast(strlen(rcv)); for (i = 0; i < np; i++) { - if (strncmp(stas[i], rcv, len)) continue; - for (j = 0; j < 3; j++) pos[j] = poss[i][j]; + if (strncmp(stas[i], rcv, len) != 0) + { + continue; + } + for (j = 0; j < 3; j++) + { + pos[j] = poss[i][j]; + } pos[0] *= D2R; pos[1] *= D2R; return; @@ -2588,11 +2956,23 @@ int readblqrecord(FILE *fp, double *odisp) while (fgets(buff, sizeof(buff), fp)) { - if (!strncmp(buff, "$$", 2)) continue; + if (!strncmp(buff, "$$", 2)) + { + continue; + } if (sscanf(buff, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", - v, v + 1, v + 2, v + 3, v + 4, v + 5, v + 6, v + 7, v + 8, v + 9, v + 10) < 11) continue; - for (i = 0; i < 11; i++) odisp[n + i * 6] = v[i]; - if (++n == 6) return 1; + v, v + 1, v + 2, v + 3, v + 4, v + 5, v + 6, v + 7, v + 8, v + 9, v + 10) < 11) + { + continue; + } + for (i = 0; i < 11; i++) + { + odisp[n + i * 6] = v[i]; + } + if (++n == 6) + { + return 1; + } } return 0; } @@ -2612,22 +2992,35 @@ int readblq(const char *file, const char *sta, double *odisp) /* station name to upper case */ sscanf(sta, "%16s", staname); - for (p = staname; (*p = (char)toupper((int)(*p))); p++) - ; + for (p = staname; (*p = static_cast(toupper(static_cast(*p)))); p++) + { + ; + } - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "blq file open error: file=%s\n", file); return 0; } while (fgets(buff, sizeof(buff), fp)) { - if (!strncmp(buff, "$$", 2) || strlen(buff) < 2) continue; + if (!strncmp(buff, "$$", 2) || strlen(buff) < 2) + { + continue; + } - if (sscanf(buff + 2, "%16s", name) < 1) continue; - for (p = name; (*p = (char)toupper((int)(*p))); p++) - ; - if (strcmp(name, staname)) continue; + if (sscanf(buff + 2, "%16s", name) < 1) + { + continue; + } + for (p = name; (*p = static_cast(toupper(static_cast(*p)))); p++) + { + ; + } + if (strcmp(name, staname) != 0) + { + continue; + } /* read blq record */ if (readblqrecord(fp, odisp)) @@ -2657,7 +3050,7 @@ int readerp(const char *file, erp_t *erp) trace(3, "readerp: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "erp file open error: file=%s\n", file); return 0; @@ -2672,11 +3065,11 @@ int readerp(const char *file, erp_t *erp) if (erp->n >= erp->nmax) { erp->nmax = erp->nmax <= 0 ? 128 : erp->nmax * 2; - erp_data = (erpd_t *)realloc(erp->data, sizeof(erpd_t) * erp->nmax); + erp_data = static_cast(realloc(erp->data, sizeof(erpd_t) * erp->nmax)); if (!erp_data) { free(erp->data); - erp->data = NULL; + erp->data = nullptr; erp->n = erp->nmax = 0; fclose(fp); return 0; @@ -2711,7 +3104,10 @@ int geterp(const erp_t *erp, gtime_t time, double *erpv) trace(4, "geterp:\n"); - if (erp->n <= 0) return 0; + if (erp->n <= 0) + { + return 0; + } mjd = 51544.5 + (timediff(gpst2utc(time), epoch2time(ep))) / 86400.0; @@ -2737,9 +3133,13 @@ int geterp(const erp_t *erp, gtime_t time, double *erpv) { i = (j + k) / 2; if (mjd < erp->data[i].mjd) - k = i; + { + k = i; + } else - j = i; + { + j = i; + } } if (erp->data[j].mjd == erp->data[j + 1].mjd) { @@ -2759,8 +3159,8 @@ int geterp(const erp_t *erp, gtime_t time, double *erpv) /* compare ephemeris ---------------------------------------------------------*/ int cmpeph(const void *p1, const void *p2) { - eph_t *q1 = (eph_t *)p1, *q2 = (eph_t *)p2; - return q1->ttr.time != q2->ttr.time ? (int)(q1->ttr.time - q2->ttr.time) : (q1->toe.time != q2->toe.time ? (int)(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); + auto *q1 = (eph_t *)p1, *q2 = (eph_t *)p2; + return q1->ttr.time != q2->ttr.time ? static_cast(q1->ttr.time - q2->ttr.time) : (q1->toe.time != q2->toe.time ? static_cast(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); } @@ -2772,7 +3172,10 @@ void uniqeph(nav_t *nav) trace(3, "uniqeph: n=%d\n", nav->n); - if (nav->n <= 0) return; + if (nav->n <= 0) + { + return; + } qsort(nav->eph, nav->n, sizeof(eph_t), cmpeph); @@ -2786,11 +3189,11 @@ void uniqeph(nav_t *nav) } nav->n = j + 1; - if (!(nav_eph = (eph_t *)realloc(nav->eph, sizeof(eph_t) * nav->n))) + if (!(nav_eph = static_cast(realloc(nav->eph, sizeof(eph_t) * nav->n)))) { trace(1, "uniqeph malloc error n=%d\n", nav->n); free(nav->eph); - nav->eph = NULL; + nav->eph = nullptr; nav->n = nav->nmax = 0; return; } @@ -2804,8 +3207,8 @@ void uniqeph(nav_t *nav) /* compare glonass ephemeris -------------------------------------------------*/ int cmpgeph(const void *p1, const void *p2) { - geph_t *q1 = (geph_t *)p1, *q2 = (geph_t *)p2; - return q1->tof.time != q2->tof.time ? (int)(q1->tof.time - q2->tof.time) : (q1->toe.time != q2->toe.time ? (int)(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); + auto *q1 = (geph_t *)p1, *q2 = (geph_t *)p2; + return q1->tof.time != q2->tof.time ? static_cast(q1->tof.time - q2->tof.time) : (q1->toe.time != q2->toe.time ? static_cast(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); } @@ -2817,7 +3220,10 @@ void uniqgeph(nav_t *nav) trace(3, "uniqgeph: ng=%d\n", nav->ng); - if (nav->ng <= 0) return; + if (nav->ng <= 0) + { + return; + } qsort(nav->geph, nav->ng, sizeof(geph_t), cmpgeph); @@ -2832,11 +3238,11 @@ void uniqgeph(nav_t *nav) } nav->ng = j + 1; - if (!(nav_geph = (geph_t *)realloc(nav->geph, sizeof(geph_t) * nav->ng))) + if (!(nav_geph = static_cast(realloc(nav->geph, sizeof(geph_t) * nav->ng)))) { trace(1, "uniqgeph malloc error ng=%d\n", nav->ng); free(nav->geph); - nav->geph = NULL; + nav->geph = nullptr; nav->ng = nav->ngmax = 0; return; } @@ -2850,8 +3256,8 @@ void uniqgeph(nav_t *nav) /* compare sbas ephemeris ----------------------------------------------------*/ int cmpseph(const void *p1, const void *p2) { - seph_t *q1 = (seph_t *)p1, *q2 = (seph_t *)p2; - return q1->tof.time != q2->tof.time ? (int)(q1->tof.time - q2->tof.time) : (q1->t0.time != q2->t0.time ? (int)(q1->t0.time - q2->t0.time) : q1->sat - q2->sat); + auto *q1 = (seph_t *)p1, *q2 = (seph_t *)p2; + return q1->tof.time != q2->tof.time ? static_cast(q1->tof.time - q2->tof.time) : (q1->t0.time != q2->t0.time ? static_cast(q1->t0.time - q2->t0.time) : q1->sat - q2->sat); } @@ -2863,7 +3269,10 @@ void uniqseph(nav_t *nav) trace(3, "uniqseph: ns=%d\n", nav->ns); - if (nav->ns <= 0) return; + if (nav->ns <= 0) + { + return; + } qsort(nav->seph, nav->ns, sizeof(seph_t), cmpseph); @@ -2877,11 +3286,11 @@ void uniqseph(nav_t *nav) } nav->ns = j + 1; - if (!(nav_seph = (seph_t *)realloc(nav->seph, sizeof(seph_t) * nav->ns))) + if (!(nav_seph = static_cast(realloc(nav->seph, sizeof(seph_t) * nav->ns)))) { trace(1, "uniqseph malloc error ns=%d\n", nav->ns); free(nav->seph); - nav->seph = NULL; + nav->seph = nullptr; nav->ns = nav->nsmax = 0; return; } @@ -2910,21 +3319,29 @@ void uniqnav(nav_t *nav) /* update carrier wave length */ for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - nav->lam[i][j] = satwavelen(i + 1, j, nav); - } + { + for (j = 0; j < NFREQ; j++) + { + nav->lam[i][j] = satwavelen(i + 1, j, nav); + } + } } /* compare observation data -------------------------------------------------*/ int cmpobs(const void *p1, const void *p2) { - obsd_t *q1 = (obsd_t *)p1, *q2 = (obsd_t *)p2; + auto *q1 = (obsd_t *)p1, *q2 = (obsd_t *)p2; double tt = timediff(q1->time, q2->time); - if (fabs(tt) > DTTOL) return tt < 0 ? -1 : 1; - if (q1->rcv != q2->rcv) return (int)q1->rcv - (int)q2->rcv; - return (int)q1->sat - (int)q2->sat; + if (fabs(tt) > DTTOL) + { + return tt < 0 ? -1 : 1; + } + if (q1->rcv != q2->rcv) + { + return static_cast(q1->rcv) - static_cast(q2->rcv); + } + return static_cast(q1->sat) - static_cast(q2->sat); } @@ -2939,7 +3356,10 @@ int sortobs(obs_t *obs) trace(3, "sortobs: nobs=%d\n", obs->n); - if (obs->n <= 0) return 0; + if (obs->n <= 0) + { + return 0; + } qsort(obs->data, obs->n, sizeof(obsd_t), cmpobs); @@ -2959,7 +3379,10 @@ int sortobs(obs_t *obs) { for (j = i + 1; j < obs->n; j++) { - if (timediff(obs->data[j].time, obs->data[i].time) > DTTOL) break; + if (timediff(obs->data[j].time, obs->data[i].time) > DTTOL) + { + break; + } } } return n; @@ -2976,7 +3399,7 @@ int sortobs(obs_t *obs) *-----------------------------------------------------------------------------*/ int screent(gtime_t time, gtime_t ts, gtime_t te, double tint) { - return (tint <= 0.0 || fmod(time2gpst(time, NULL) + DTTOL, tint) <= DTTOL * 2.0) && + return (tint <= 0.0 || fmod(time2gpst(time, nullptr) + DTTOL, tint) <= DTTOL * 2.0) && (ts.time == 0 || timediff(time, ts) >= -DTTOL) && (te.time == 0 || timediff(time, te) < DTTOL); } @@ -2995,19 +3418,28 @@ int readnav(const char *file, nav_t *nav) 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; geph_t geph0 = {0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {}, {}, {}, 0.0, 0.0, 0.0}; char buff[4096], *p; - long toe_time, tof_time, toc_time, ttr_time; + int32_t toe_time, tof_time, toc_time, ttr_time; int i, sat, prn; trace(3, "loadnav: file=%s\n", file); - if (!(fp = fopen(file, "r"))) return 0; + if (!(fp = fopen(file, "re"))) + { + return 0; + } while (fgets(buff, sizeof(buff), fp)) { if (!strncmp(buff, "IONUTC", 6)) { - for (i = 0; i < 8; i++) nav->ion_gps[i] = 0.0; - for (i = 0; i < 4; i++) nav->utc_gps[i] = 0.0; + for (i = 0; i < 8; i++) + { + nav->ion_gps[i] = 0.0; + } + for (i = 0; i < 4; i++) + { + nav->utc_gps[i] = 0.0; + } nav->leaps = 0; sscanf(buff, "IONUTC,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d", &nav->ion_gps[0], &nav->ion_gps[1], &nav->ion_gps[2], &nav->ion_gps[3], @@ -3017,17 +3449,24 @@ int readnav(const char *file, nav_t *nav) continue; } if ((p = strchr(buff, ','))) - *p = '\0'; + { + *p = '\0'; + } else - continue; - if (!(sat = satid2no(buff))) continue; + { + continue; + } + if (!(sat = satid2no(buff))) + { + continue; + } if (satsys(sat, &prn) == SYS_GLO) { nav->geph[prn - 1] = geph0; nav->geph[prn - 1].sat = sat; toe_time = tof_time = 0; sscanf(p + 1, - "%d,%d,%d,%d,%d,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," + "%d,%d,%d,%d,%d,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," "%lf,%lf,%lf,%lf", &nav->geph[prn - 1].iode, &nav->geph[prn - 1].frq, &nav->geph[prn - 1].svh, &nav->geph[prn - 1].sva, &nav->geph[prn - 1].age, @@ -3045,7 +3484,7 @@ int readnav(const char *file, nav_t *nav) nav->eph[sat - 1].sat = sat; toe_time = toc_time = ttr_time = 0; sscanf(p + 1, - "%d,%d,%d,%d,%ld,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," + "%d,%d,%d,%d,%d,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d,%d", &nav->eph[sat - 1].iode, &nav->eph[sat - 1].iodc, &nav->eph[sat - 1].sva, &nav->eph[sat - 1].svh, @@ -3076,19 +3515,25 @@ int savenav(const char *file, const nav_t *nav) trace(3, "savenav: file=%s\n", file); - if (!(fp = fopen(file, "w"))) return 0; + if (!(fp = fopen(file, "we"))) + { + return 0; + } for (i = 0; i < MAXSAT; i++) { - if (nav->eph[i].ttr.time == 0) continue; + if (nav->eph[i].ttr.time == 0) + { + continue; + } satno2id(nav->eph[i].sat, id); fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%d,%d\n", id, nav->eph[i].iode, nav->eph[i].iodc, nav->eph[i].sva, - nav->eph[i].svh, (int)nav->eph[i].toe.time, - (int)nav->eph[i].toc.time, (int)nav->eph[i].ttr.time, + nav->eph[i].svh, static_cast(nav->eph[i].toe.time), + static_cast(nav->eph[i].toc.time), static_cast(nav->eph[i].ttr.time), nav->eph[i].A, nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0, nav->eph[i].omg, nav->eph[i].M0, nav->eph[i].deln, nav->eph[i].OMGd, nav->eph[i].idot, nav->eph[i].crc, nav->eph[i].crs, nav->eph[i].cuc, @@ -3098,14 +3543,17 @@ int savenav(const char *file, const nav_t *nav) } for (i = 0; i < MAXPRNGLO; i++) { - if (nav->geph[i].tof.time == 0) continue; + if (nav->geph[i].tof.time == 0) + { + continue; + } satno2id(nav->geph[i].sat, id); fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n", id, nav->geph[i].iode, nav->geph[i].frq, nav->geph[i].svh, - nav->geph[i].sva, nav->geph[i].age, (int)nav->geph[i].toe.time, - (int)nav->geph[i].tof.time, + nav->geph[i].sva, nav->geph[i].age, static_cast(nav->geph[i].toe.time), + static_cast(nav->geph[i].tof.time), nav->geph[i].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2], nav->geph[i].vel[0], nav->geph[i].vel[1], nav->geph[i].vel[2], nav->geph[i].acc[0], nav->geph[i].acc[1], nav->geph[i].acc[2], @@ -3132,7 +3580,7 @@ int savenav(const char *file, const nav_t *nav) void freeobs(obs_t *obs) { free(obs->data); - obs->data = NULL; + obs->data = nullptr; obs->n = obs->nmax = 0; } @@ -3152,49 +3600,49 @@ void freenav(nav_t *nav, int opt) if (opt & 0x01) { free(nav->eph); - nav->eph = NULL; + nav->eph = nullptr; nav->n = nav->nmax = 0; } if (opt & 0x02) { free(nav->geph); - nav->geph = NULL; + nav->geph = nullptr; nav->ng = nav->ngmax = 0; } if (opt & 0x04) { free(nav->seph); - nav->seph = NULL; + nav->seph = nullptr; nav->ns = nav->nsmax = 0; } if (opt & 0x08) { free(nav->peph); - nav->peph = NULL; + nav->peph = nullptr; nav->ne = nav->nemax = 0; } if (opt & 0x10) { free(nav->pclk); - nav->pclk = NULL; + nav->pclk = nullptr; nav->nc = nav->ncmax = 0; } if (opt & 0x20) { free(nav->alm); - nav->alm = NULL; + nav->alm = nullptr; nav->na = nav->namax = 0; } if (opt & 0x40) { free(nav->tec); - nav->tec = NULL; + nav->tec = nullptr; nav->nt = nav->ntmax = 0; } if (opt & 0x80) { free(nav->fcb); - nav->fcb = NULL; + nav->fcb = nullptr; nav->nf = nav->nfmax = 0; } } @@ -3203,7 +3651,7 @@ void freenav(nav_t *nav, int opt) /* debug trace functions -----------------------------------------------------*/ //#ifdef TRACE // -FILE *fp_trace = NULL; /* file pointer of trace */ +FILE *fp_trace = nullptr; /* file pointer of trace */ char file_trace[1024]; /* trace file */ static int level_trace = 0; /* level of trace */ unsigned int tick_trace = 0; /* tick time at traceopen (ms) */ @@ -3217,8 +3665,8 @@ void traceswap(void) rtk_lock(&lock_trace); - if ((int)(time2gpst(time, NULL) / INT_SWAP_TRAC) == - (int)(time2gpst(time_trace, NULL) / INT_SWAP_TRAC)) + if (static_cast(time2gpst(time, nullptr) / INT_SWAP_TRAC) == + static_cast(time2gpst(time_trace, nullptr) / INT_SWAP_TRAC)) { rtk_unlock(&lock_trace); return; @@ -3230,9 +3678,12 @@ void traceswap(void) rtk_unlock(&lock_trace); return; } - if (fp_trace) fclose(fp_trace); + if (fp_trace) + { + fclose(fp_trace); + } - if (!(fp_trace = fopen(path, "w"))) + if (!(fp_trace = fopen(path, "we"))) { fp_trace = stderr; } @@ -3246,11 +3697,18 @@ void traceopen(const char *file) char path[1024]; reppath(file, path, time, "", ""); - if (!*path || !(fp_trace = fopen(path, "w"))) fp_trace = stderr; + if (!*path || !(fp_trace = fopen(path, "we"))) + { + fp_trace = stderr; + } if (strlen(file) < 1025) - strcpy(file_trace, file); + { + strcpy(file_trace, file); + } else - trace(1, "file array is too long"); + { + trace(1, "file array is too long"); + } tick_trace = tickget(); time_trace = time; initlock(&lock_trace); @@ -3259,8 +3717,11 @@ void traceopen(const char *file) void traceclose(void) { - if (fp_trace && fp_trace != stderr) fclose(fp_trace); - fp_trace = NULL; + if (fp_trace && fp_trace != stderr) + { + fclose(fp_trace); + } + fp_trace = nullptr; file_trace[0] = '\0'; } @@ -3287,7 +3748,10 @@ void tracelevel(int level) void tracet(int level, const char *format, ...) { va_list ap; - if (!fp_trace || level > level_trace) return; + if (!fp_trace || level > level_trace) + { + return; + } traceswap(); fprintf(fp_trace, "%d %9.3f: ", level, (tickget() - tick_trace) / 1000.0); va_start(ap, format); @@ -3464,35 +3928,55 @@ void createdir(const char *path) //tracet(3, "createdir: path=%s\n", path); if (strlen(path) < 1025) - strcpy(buff, path); + { + strcpy(buff, path); + } else - trace(1, "path is too long"); - if (!(p = strrchr(buff, FILEPATHSEP))) return; + { + trace(1, "path is too long"); + } + if (!(p = strrchr(buff, FILEPATHSEP))) + { + return; + } *p = '\0'; - if (mkdir(buff, 0777) != 0) trace(1, "Error creating folder"); + if (mkdir(buff, 0777) != 0) + { + trace(1, "Error creating folder"); + } } /* replace string ------------------------------------------------------------*/ int repstr(char *str, const char *pat, const char *rep) { - int len = (int)strlen(pat); + int len = static_cast(strlen(pat)); char buff[1024], *p, *q, *r; for (p = str, r = buff; *p; p = q + len) { - if (!(q = strstr(p, pat))) break; + if (!(q = strstr(p, pat))) + { + break; + } strncpy(r, p, q - p); r += q - p; r += sprintf(r, "%s", rep); } - if (p <= str) return 0; + if (p <= str) + { + return 0; + } if (strlen(p) < 1025) - strcpy(r, p); + { + strcpy(r, p); + } else - trace(1, "pat array is too long"); + { + trace(1, "pat array is too long"); + } strcpy(str, buff); return 1; } @@ -3535,20 +4019,29 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, strcpy(rpath, path); - if (!strstr(rpath, "%")) return 0; - if (*rov) stat |= repstr(rpath, "%r", rov); - if (*base) stat |= repstr(rpath, "%b", base); + if (!strstr(rpath, "%")) + { + return 0; + } + if (*rov) + { + stat |= repstr(rpath, "%r", rov); + } + if (*base) + { + stat |= repstr(rpath, "%b", base); + } if (time.time != 0) { time2epoch(time, ep); ep0[0] = ep[0]; - dow = (int)floor(time2gpst(time, &week) / 86400.0); - doy = (int)floor(timediff(time, epoch2time(ep0)) / 86400.0) + 1; - sprintf(rep, "%02d", ((int)ep[3] / 3) * 3); + dow = static_cast(floor(time2gpst(time, &week) / 86400.0)); + doy = static_cast(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1; + sprintf(rep, "%02d", (static_cast(ep[3]) / 3) * 3); stat |= repstr(rpath, "%ha", rep); - sprintf(rep, "%02d", ((int)ep[3] / 6) * 6); + sprintf(rep, "%02d", (static_cast(ep[3]) / 6) * 6); stat |= repstr(rpath, "%hb", rep); - sprintf(rep, "%02d", ((int)ep[3] / 12) * 12); + sprintf(rep, "%02d", (static_cast(ep[3]) / 12) * 12); stat |= repstr(rpath, "%hc", rep); sprintf(rep, "%04.0f", ep[0]); stat |= repstr(rpath, "%Y", rep); @@ -3570,9 +4063,9 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, stat |= repstr(rpath, "%W", rep); sprintf(rep, "%d", dow); stat |= repstr(rpath, "%D", rep); - sprintf(rep, "%c", 'a' + (int)ep[3]); + sprintf(rep, "%c", 'a' + static_cast(ep[3])); stat |= repstr(rpath, "%H", rep); - sprintf(rep, "%02d", ((int)ep[4] / 15) * 15); + sprintf(rep, "%02d", (static_cast(ep[4]) / 15) * 15); stat |= repstr(rpath, "%t", rep); } else if (strstr(rpath, "%ha") || strstr(rpath, "%hb") || strstr(rpath, "%hc") || @@ -3610,12 +4103,19 @@ int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, trace(3, "reppaths: path =%s nmax=%d rov=%s base=%s\n", path, nmax, rov, base); - if (ts.time == 0 || te.time == 0 || timediff(ts, te) > 0.0) return 0; + if (ts.time == 0 || te.time == 0 || timediff(ts, te) > 0.0) + { + return 0; + } if (strstr(path, "%S") || strstr(path, "%M") || strstr(path, "%t")) - tint = 900.0; + { + tint = 900.0; + } else if (strstr(path, "%h") || strstr(path, "%H")) - tint = 3600.0; + { + tint = 3600.0; + } tow = time2gpst(ts, &week); time = gpst2time(week, floor(tow / tint) * tint); @@ -3623,10 +4123,16 @@ int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, while (timediff(time, te) <= 0.0 && n < nmax) { reppath(path, rpath[n], time, rov, base); - if (n == 0 || strcmp(rpath[n], rpath[n - 1])) n++; + if (n == 0 || strcmp(rpath[n], rpath[n - 1]) != 0) + { + n++; + } time = timeadd(time, tint); } - for (i = 0; i < n; i++) trace(3, "reppaths: rpath=%s\n", rpath[i]); + for (i = 0; i < n; i++) + { + trace(3, "reppaths: rpath=%s\n", rpath[i]); + } return n; } @@ -3642,7 +4148,7 @@ double satwavelen(int sat, int frq, const nav_t *nav) { const double freq_glo[] = {FREQ1_GLO, FREQ2_GLO}; const double dfrq_glo[] = {DFRQ1_GLO, DFRQ2_GLO}; - int i, sys = satsys(sat, NULL); + int i, sys = satsys(sat, nullptr); if (sys == SYS_GLO) { @@ -3650,7 +4156,10 @@ double satwavelen(int sat, int frq, const nav_t *nav) { for (i = 0; i < nav->ng; i++) { - if (nav->geph[i].sat != sat) continue; + if (nav->geph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT / (freq_glo[frq] + dfrq_glo[frq] * nav->geph[i].frq); } } @@ -3662,28 +4171,48 @@ double satwavelen(int sat, int frq, const nav_t *nav) else if (sys == SYS_BDS) { if (frq == 0) - return SPEED_OF_LIGHT / FREQ1_BDS; /* B1 */ - else if (frq == 1) - return SPEED_OF_LIGHT / FREQ2_BDS; /* B2 */ - else if (frq == 2) - return SPEED_OF_LIGHT / FREQ3_BDS; /* B3 */ + { + return SPEED_OF_LIGHT / FREQ1_BDS; /* B1 */ + } + if (frq == 1) + { + return SPEED_OF_LIGHT / FREQ2_BDS; /* B2 */ + } + if (frq == 2) + { + return SPEED_OF_LIGHT / FREQ3_BDS; /* B3 */ + } } else { if (frq == 0) - return SPEED_OF_LIGHT / FREQ1; /* L1/E1 */ - else if (frq == 1) - return SPEED_OF_LIGHT / FREQ2; /* L2 */ - else if (frq == 2) - return SPEED_OF_LIGHT / FREQ5; /* L5/E5a */ - else if (frq == 3) - return SPEED_OF_LIGHT / FREQ6; /* L6/LEX */ - else if (frq == 4) - return SPEED_OF_LIGHT / FREQ7; /* E5b */ - else if (frq == 5) - return SPEED_OF_LIGHT / FREQ8; /* E5a+b */ + { + return SPEED_OF_LIGHT / FREQ1; /* L1/E1 */ + } + if (frq == 1) + { + return SPEED_OF_LIGHT / FREQ2; /* L2 */ + } + if (frq == 2) + { + return SPEED_OF_LIGHT / FREQ5; /* L5/E5a */ + } + if (frq == 3) + { + return SPEED_OF_LIGHT / FREQ6; /* L6/LEX */ + } + if (frq == 4) + { + return SPEED_OF_LIGHT / FREQ7; /* E5b */ + } + if (frq == 5) + { + return SPEED_OF_LIGHT / FREQ8; /* E5a+b */ + } else if (frq == 6) - return SPEED_OF_LIGHT / FREQ9; /* S */ + { + return SPEED_OF_LIGHT / FREQ9; /* S */ + } } return 0.0; } @@ -3702,10 +4231,19 @@ double geodist(const double *rs, const double *rr, double *e) double r; int i; - if (norm_rtk(rs, 3) < RE_WGS84) return -1.0; - for (i = 0; i < 3; i++) e[i] = rs[i] - rr[i]; + if (norm_rtk(rs, 3) < RE_WGS84) + { + return -1.0; + } + for (i = 0; i < 3; i++) + { + e[i] = rs[i] - rr[i]; + } r = norm_rtk(e, 3); - for (i = 0; i < 3; i++) e[i] /= r; + for (i = 0; i < 3; i++) + { + e[i] /= r; + } return r + DEFAULT_OMEGA_EARTH_DOT * (rs[0] * rr[1] - rs[1] * rr[0]) / SPEED_OF_LIGHT; } @@ -3726,7 +4264,10 @@ double satazel(const double *pos, const double *e, double *azel) { ecef2enu(pos, e, enu); az = dot(enu, enu, 2) < 1e-12 ? 0.0 : atan2(enu[0], enu[1]); - if (az < 0.0) az += 2 * PI; + if (az < 0.0) + { + az += 2 * PI; + } el = asin(enu[2]); } if (azel) @@ -3752,10 +4293,16 @@ void dops(int ns, const double *azel, double elmin, double *dop) double H[4 * MAXSAT], Q[16], cosel, sinel; int i, n; - for (i = 0; i < 4; i++) dop[i] = 0.0; + for (i = 0; i < 4; i++) + { + dop[i] = 0.0; + } for (i = n = 0; i < ns && i < MAXSAT; i++) { - if (azel[1 + i * 2] < elmin || azel[1 + i * 2] <= 0.0) continue; + if (azel[1 + i * 2] < elmin || azel[1 + i * 2] <= 0.0) + { + continue; + } cosel = cos(azel[1 + i * 2]); sinel = sin(azel[1 + i * 2]); H[4 * n] = cosel * sin(azel[i * 2]); @@ -3763,7 +4310,10 @@ void dops(int ns, const double *azel, double elmin, double *dop) H[2 + 4 * n] = sinel; H[3 + 4 * n++] = 1.0; } - if (n < 4) return; + if (n < 4) + { + return; + } matmul("NT", 4, 4, n, 1.0, H, H, 0.0, Q); if (!matinv(Q, 4)) @@ -3793,8 +4343,14 @@ double ionmodel(gtime_t t, const double *ion, const double *pos, double tt, f, psi, phi, lam, amp, per, x; int week; - if (pos[2] < -1e3 || azel[1] <= 0) return 0.0; - if (norm_rtk(ion, 8) <= 0.0) ion = ion_default; + if (pos[2] < -1e3 || azel[1] <= 0) + { + return 0.0; + } + if (norm_rtk(ion, 8) <= 0.0) + { + ion = ion_default; + } /* earth centered angle (semi-circle) */ psi = 0.0137 / (azel[1] / PI + 0.11) - 0.022; @@ -3802,9 +4358,13 @@ double ionmodel(gtime_t t, const double *ion, const double *pos, /* subionospheric latitude/longitude (semi-circle) */ phi = pos[0] / PI + psi * cos(azel[0]); if (phi > 0.416) - phi = 0.416; + { + phi = 0.416; + } else if (phi < -0.416) - phi = -0.416; + { + phi = -0.416; + } lam = pos[1] / PI + psi * sin(azel[0]) / cos(phi * PI); /* geomagnetic latitude (semi-circle) */ @@ -3836,7 +4396,10 @@ double ionmodel(gtime_t t, const double *ion, const double *pos, *-----------------------------------------------------------------------------*/ double ionmapf(const double *pos, const double *azel) { - if (pos[2] >= HION) return 1.0; + if (pos[2] >= HION) + { + return 1.0; + } return 1.0 / cos(asin((RE_WGS84 + pos[2]) / (RE_WGS84 + HION) * sin(PI / 2.0 - azel[1]))); } @@ -3891,7 +4454,10 @@ double tropmodel(gtime_t time __attribute__((unused)), const double *pos, const const double temp0 = 15.0; /* temparature at sea level */ double hgt, pres, temp, e, z, trph, trpw; - if (pos[2] < -100.0 || 1e4 < pos[2] || azel[1] <= 0) return 0.0; + if (pos[2] < -100.0 || 1e4 < pos[2] || azel[1] <= 0) + { + return 0.0; + } /* standard atmosphere */ hgt = pos[2] < 0.0 ? 0.0 : pos[2]; @@ -3911,11 +4477,15 @@ double tropmodel(gtime_t time __attribute__((unused)), const double *pos, const double interpc(const double coef[], double lat) { - int i = (int)(lat / 15.0); + int i = static_cast(lat / 15.0); if (i < 1) - return coef[0]; - else if (i > 4) - return coef[4]; + { + return coef[0]; + } + if (i > 4) + { + return coef[4]; + } return coef[i - 1] * (1.0 - lat / 15.0 + i) + coef[i] * (lat / 15.0 - i); } @@ -3951,7 +4521,10 @@ double nmf(gtime_t time, const double pos[], const double azel[], if (el <= 0.0) { - if (mapfw) *mapfw = 0.0; + if (mapfw) + { + *mapfw = 0.0; + } return 0.0; } /* year from doy 28, added half a year for southern latitudes */ @@ -3968,7 +4541,10 @@ double nmf(gtime_t time, const double pos[], const double azel[], /* ellipsoidal height is used instead of height above sea level */ dm = (1.0 / sin(el) - mapf(el, aht[0], aht[1], aht[2])) * hgt / 1e3; - if (mapfw) *mapfw = mapf(el, aw[0], aw[1], aw[2]); + if (mapfw) + { + *mapfw = mapf(el, aw[0], aw[1], aw[2]); + } return mapf(el, ah[0], ah[1], ah[2]) + dm; } @@ -3999,7 +4575,10 @@ double tropmapf(gtime_t time, const double pos[], const double azel[], if (pos[2] < -1000.0 || pos[2] > 20000.0) { - if (mapfw) *mapfw = 0.0; + if (mapfw) + { + *mapfw = 0.0; + } return 0.0; } #ifdef IERS_MODEL @@ -4024,11 +4603,15 @@ double tropmapf(gtime_t time, const double pos[], const double azel[], double interpvar(double ang, const double *var) { double a = ang / 5.0; /* ang=0-90 */ - int i = (int)a; + int i = static_cast(a); if (i < 0) - return var[0]; - else if (i >= 18) - return var[18]; + { + return var[0]; + } + if (i >= 18) + { + return var[18]; + } return var[i] * (1.0 - a + i) + var[i + 1] * (a - i); } @@ -4056,7 +4639,10 @@ void antmodel(const pcv_t *pcv, const double *del, const double *azel, for (i = 0; i < NFREQ; i++) { - for (j = 0; j < 3; j++) off[j] = pcv->off[i][j] + del[j]; + for (j = 0; j < 3; j++) + { + off[j] = pcv->off[i][j] + del[j]; + } dant[i] = -dot(off, e, 3) + (opt ? interpvar(90.0 - azel[1] * R2D, pcv->var[i]) : 0.0); } @@ -4160,15 +4746,24 @@ void sunmoonpos(gtime_t tutc, const double *erpv, double *rsun, tut = timeadd(tutc, erpv[2]); /* utc -> ut1 */ /* sun and moon position in eci */ - sunmoonpos_eci(tut, rsun ? rs : NULL, rmoon ? rm : NULL); + sunmoonpos_eci(tut, rsun ? rs : nullptr, rmoon ? rm : nullptr); /* eci to ecef transformation matrix */ eci2ecef(tutc, erpv, U, &gmst_); /* sun and moon position in ecef */ - if (rsun) matmul("NN", 3, 1, 3, 1.0, U, rs, 0.0, rsun); - if (rmoon) matmul("NN", 3, 1, 3, 1.0, U, rm, 0.0, rmoon); - if (gmst) *gmst = gmst_; + if (rsun) + { + matmul("NN", 3, 1, 3, 1.0, U, rs, 0.0, rsun); + } + if (rmoon) + { + matmul("NN", 3, 1, 3, 1.0, U, rm, 0.0, rmoon); + } + if (gmst) + { + *gmst = gmst_; + } } @@ -4193,20 +4788,35 @@ void csmooth(obs_t *obs, int ns) r = p->rcv; for (j = 0; j < NFREQ; j++) { - if (s <= 0 || MAXSAT < s || r <= 0 || 2 < r) continue; - if (p->P[j] == 0.0 || p->L[j] == 0.0) continue; - if (p->LLI[j]) n[r - 1][s - 1][j] = 0; + if (s <= 0 || MAXSAT < s || r <= 0 || 2 < r) + { + continue; + } + if (p->P[j] == 0.0 || p->L[j] == 0.0) + { + continue; + } + if (p->LLI[j]) + { + n[r - 1][s - 1][j] = 0; + } if (n[r - 1][s - 1][j] == 0) - Ps[r - 1][s - 1][j] = p->P[j]; + { + Ps[r - 1][s - 1][j] = p->P[j]; + } else { - dcp = lam_carr[j] * (p->L[j] - Lp[r - 1][s - 1][j]); + dcp = LAM_CARR[j] * (p->L[j] - Lp[r - 1][s - 1][j]); Ps[r - 1][s - 1][j] = p->P[j] / ns + (Ps[r - 1][s - 1][j] + dcp) * (ns - 1) / ns; } if (++n[r - 1][s - 1][j] < ns) - p->P[j] = 0.0; + { + p->P[j] = 0.0; + } else - p->P[j] = Ps[r - 1][s - 1][j]; + { + p->P[j] = Ps[r - 1][s - 1][j]; + } Lp[r - 1][s - 1][j] = p->L[j]; } } @@ -4229,10 +4839,17 @@ int rtk_uncompress(const char *file, char *uncfile) trace(3, "rtk_uncompress: file=%s\n", file); if (strlen(file) < 1025) - strcpy(tmpfile, file); + { + strcpy(tmpfile, file); + } else - trace(1, "file array is too long"); - if (!(p = strrchr(tmpfile, '.'))) return 0; + { + trace(1, "file array is too long"); + } + if (!(p = strrchr(tmpfile, '.'))) + { + return 0; + } /* uncompress by gzip */ if (!strcmp(p, ".z") || !strcmp(p, ".Z") || @@ -4241,14 +4858,20 @@ int rtk_uncompress(const char *file, char *uncfile) { strcpy(uncfile, tmpfile); uncfile[p - tmpfile] = '\0'; - sprintf(cmd, "gzip -f -d -c \"%s\" > \"%s\"", tmpfile, uncfile); + sprintf(cmd, R"(gzip -f -d -c "%s" > "%s")", tmpfile, uncfile); if (execcmd(cmd)) { - if (remove(uncfile) != 0) trace(1, "Error removing file"); + if (remove(uncfile) != 0) + { + trace(1, "Error removing file"); + } return -1; } - if (strlen(uncfile) < 1025) strcpy(tmpfile, uncfile); + if (strlen(uncfile) < 1025) + { + strcpy(tmpfile, uncfile); + } stat = 1; } /* extract tar file */ @@ -4264,15 +4887,40 @@ int rtk_uncompress(const char *file, char *uncfile) dir = fname; fname = p + 1; } - sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile); + // sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile); + // NOTE: This sprintf triggers a format overflow warning. Replaced by: + std::ostringstream temp; + std::string s_aux1(dir); + std::string s_aux2(tmpfile); + temp << "tar -C " << s_aux1 << " -xf " << s_aux2; + std::string s_aux = temp.str(); + int n = s_aux.length(); + if (n < 2048) + { + for (int i = 0; i < n; i++) + { + cmd[i] = s_aux[i]; + } + } + if (execcmd(cmd)) { if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } return -1; } if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } stat = 1; } /* extract hatanaka-compressed file by cnx2rnx */ @@ -4280,17 +4928,30 @@ int rtk_uncompress(const char *file, char *uncfile) { strcpy(uncfile, tmpfile); uncfile[p - tmpfile + 3] = *(p + 3) == 'D' ? 'O' : 'o'; - sprintf(cmd, "crx2rnx < \"%s\" > \"%s\"", tmpfile, uncfile); + sprintf(cmd, R"(crx2rnx < "%s" > "%s")", tmpfile, uncfile); if (execcmd(cmd)) { - if (remove(uncfile) != 0) trace(1, "Error removing file"); + if (remove(uncfile) != 0) + { + trace(1, "Error removing file"); + } if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } return -1; } if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } stat = 1; } trace(3, "rtk_uncompress: stat=%d\n", stat); @@ -4321,23 +4982,42 @@ int expath(const char *path, char *paths[], int nmax) //if ((p=strrchr(path,'/')) || (p=strrchr(path,'\\'))) { // file=p+1; strncpy(dir,path,p-path+1); dir[p-path+1]='\0'; //} - if (!(dp = opendir(*dir ? dir : "."))) return 0; + if (!(dp = opendir(*dir ? dir : "."))) + { + return 0; + } while ((d = readdir(dp))) { - if (*(d->d_name) == '.') continue; + if (*(d->d_name) == '.') + { + continue; + } sprintf(s1, "^%s$", d->d_name); sprintf(s2, "^%s$", file); - for (p = s1; *p; p++) *p = (char)tolower((int)*p); - for (p = s2; *p; p++) *p = (char)tolower((int)*p); + for (p = s1; *p; p++) + { + *p = static_cast(tolower(static_cast(*p))); + } + for (p = s2; *p; p++) + { + *p = static_cast(tolower(static_cast(*p))); + } - for (p = s1, q = strtok_r(s2, "*", &r); q; q = strtok_r(NULL, "*", &r)) + for (p = s1, q = strtok_r(s2, "*", &r); q; q = strtok_r(nullptr, "*", &r)) { if ((p = strstr(p, q))) - p += strlen(q); + { + p += strlen(q); + } else - break; + { + break; + } + } + if (p && n < nmax) + { + sprintf(paths[n++], "%s%s", dir, d->d_name); } - if (p && n < nmax) sprintf(paths[n++], "%s%s", dir, d->d_name); } closedir(dp); /* sort paths in alphabetical order */ @@ -4348,7 +5028,9 @@ int expath(const char *path, char *paths[], int nmax) if (strcmp(paths[i], paths[j]) > 0) { if (strlen(paths[i]) < 1025) - strcpy(tmp, paths[i]); + { + strcpy(tmp, paths[i]); + } else { trace(1, "Path is too long"); @@ -4358,7 +5040,10 @@ int expath(const char *path, char *paths[], int nmax) } } } - for (i = 0; i < n; i++) trace(3, "expath : file=%s\n", paths[i]); + for (i = 0; i < n; i++) + { + trace(3, "expath : file=%s\n", paths[i]); + } return n; } @@ -4373,19 +5058,40 @@ void windupcorr(gtime_t time, const double *rs, const double *rr, double *phw) trace(4, "windupcorr: time=%s\n", time_str(time, 0)); /* sun position in ecef */ - sunmoonpos(gpst2utc(time), erpv, rsun, NULL, NULL); + sunmoonpos(gpst2utc(time), erpv, rsun, nullptr, nullptr); /* unit vector satellite to receiver */ - for (i = 0; i < 3; i++) r[i] = rr[i] - rs[i]; - if (!normv3(r, ek)) return; + for (i = 0; i < 3; i++) + { + r[i] = rr[i] - rs[i]; + } + if (!normv3(r, ek)) + { + return; + } /* unit vectors of satellite antenna */ - for (i = 0; i < 3; i++) r[i] = -rs[i]; - if (!normv3(r, ezs)) return; - for (i = 0; i < 3; i++) r[i] = rsun[i] - rs[i]; - if (!normv3(r, ess)) return; + for (i = 0; i < 3; i++) + { + r[i] = -rs[i]; + } + if (!normv3(r, ezs)) + { + return; + } + for (i = 0; i < 3; i++) + { + r[i] = rsun[i] - rs[i]; + } + if (!normv3(r, ess)) + { + return; + } cross3(ezs, ess, r); - if (!normv3(r, eys)) return; + if (!normv3(r, eys)) + { + return; + } cross3(eys, ezs, exs); /* unit vectors of receiver antenna */ @@ -4408,12 +5114,19 @@ void windupcorr(gtime_t time, const double *rs, const double *rr, double *phw) } cosp = dot(ds, dr, 3) / norm_rtk(ds, 3) / norm_rtk(dr, 3); if (cosp < -1.0) - cosp = -1.0; + { + cosp = -1.0; + } else if (cosp > 1.0) - cosp = 1.0; + { + cosp = 1.0; + } ph = acos(cosp) / 2.0 / PI; cross3(ds, dr, drs); - if (dot(ek, drs, 3) < 0.0) ph = -ph; + if (dot(ek, drs, 3) < 0.0) + { + ph = -ph; + } *phw = ph + floor(*phw - ph + 0.5); /* in cycle */ } diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h index f58e95193..8fbde5a88 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h @@ -79,7 +79,7 @@ #define GNSS_SDR_RTKLIB_RTKCMN_H_ #include "rtklib.h" -#include +//#include /* coordinate rotation matrix ------------------------------------------------*/ #define Rx(t, X) \ diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index 872e186c2..e59327680 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -52,11 +52,13 @@ *----------------------------------------------------------------------------*/ #include "rtklib_rtkpos.h" -#include "rtklib_pntpos.h" #include "rtklib_ephemeris.h" +#include "rtklib_lambda.h" +#include "rtklib_pntpos.h" #include "rtklib_ppp.h" #include "rtklib_tides.h" -#include "rtklib_lambda.h" +#include +#include static int resamb_WLNL(rtk_t *rtk __attribute((unused)), const obsd_t *obs __attribute((unused)), const int *sat __attribute((unused)), const int *iu __attribute((unused)), const int *ir __attribute((unused)), int ns __attribute__((unused)), const nav_t *nav __attribute((unused)), @@ -67,7 +69,7 @@ static int resamb_TCAR(rtk_t *rtk __attribute((unused)), const obsd_t *obs __att /* global variables ----------------------------------------------------------*/ static int statlevel = 0; /* rtk status output level (0:off) */ -static FILE *fp_stat = NULL; /* rtk status file pointer */ +static FILE *fp_stat = nullptr; /* rtk status file pointer */ static char file_stat[1024] = ""; /* rtk status file original path */ static gtime_t time_stat = {0, 0}; /* rtk status file time */ @@ -147,19 +149,26 @@ int rtkopenstat(const char *file, int level) trace(3, "rtkopenstat: file=%s level=%d\n", file, level); - if (level <= 0) return 0; + if (level <= 0) + { + return 0; + } reppath(file, path, time, "", ""); - if (!(fp_stat = fopen(path, "w"))) + if (!(fp_stat = fopen(path, "we"))) { trace(1, "rtkopenstat: file open error path=%s\n", path); return 0; } if (strlen(file) < 1025) - strcpy(file_stat, file); + { + strcpy(file_stat, file); + } else - trace(1, "File name is too long"); + { + trace(1, "File name is too long"); + } time_stat = time; statlevel = level; return 1; @@ -175,8 +184,11 @@ void rtkclosestat(void) { trace(3, "rtkclosestat:\n"); - if (fp_stat) fclose(fp_stat); - fp_stat = NULL; + if (fp_stat) + { + fclose(fp_stat); + } + fp_stat = nullptr; file_stat[0] = '\0'; statlevel = 0; } @@ -190,7 +202,10 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) int i, j, week, est, nfreq, nf = NF_RTK(&rtk->opt); char id[32]; - if (statlevel <= 0 || !fp_stat) return; + if (statlevel <= 0 || !fp_stat) + { + return; + } trace(3, "outsolstat:\n"); @@ -204,7 +219,10 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) /* receiver position */ if (est) { - for (i = 0; i < 3; i++) xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + for (i = 0; i < 3; i++) + { + xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + } fprintf(fp_stat, "$POS,%d,%.3f,%d,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f\n", week, tow, rtk->sol.stat, rtk->x[0], rtk->x[1], rtk->x[2], xa[0], xa[1], xa[2]); } @@ -220,8 +238,14 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) ecef2pos(rtk->sol.rr, pos); ecef2enu(pos, rtk->x + 3, vel); ecef2enu(pos, rtk->x + 6, acc); - if (rtk->na >= 6) ecef2enu(pos, rtk->xa + 3, vela); - if (rtk->na >= 9) ecef2enu(pos, rtk->xa + 6, acca); + if (rtk->na >= 6) + { + ecef2enu(pos, rtk->xa + 3, vela); + } + if (rtk->na >= 9) + { + ecef2enu(pos, rtk->xa + 6, acca); + } fprintf(fp_stat, "$VELACC,%d,%.3f,%d,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f\n", week, tow, rtk->sol.stat, vel[0], vel[1], vel[2], acc[0], acc[1], acc[2], vela[0], vela[1], vela[2], acca[0], acca[1], acca[2]); @@ -245,7 +269,10 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); j = II_RTK(i + 1, &rtk->opt); xa[0] = j < rtk->na ? rtk->xa[j] : 0.0; @@ -275,13 +302,19 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) i + 1, rtk->x[j], xa[0]); } } - if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) return; + if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) + { + return; + } /* residuals and status */ for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); for (j = 0; j < nfreq; j++) { @@ -301,8 +334,8 @@ void swapsolstat(void) gtime_t time = utc2gpst(timeget()); char path[1024]; - if ((int)(time2gpst(time, NULL) / INT_SWAP_STAT) == - (int)(time2gpst(time_stat, NULL) / INT_SWAP_STAT)) + if (static_cast(time2gpst(time, nullptr) / INT_SWAP_STAT) == + static_cast(time2gpst(time_stat, nullptr) / INT_SWAP_STAT)) { return; } @@ -312,9 +345,12 @@ void swapsolstat(void) { return; } - if (fp_stat) fclose(fp_stat); + if (fp_stat) + { + fclose(fp_stat); + } - if (!(fp_stat = fopen(path, "w"))) + if (!(fp_stat = fopen(path, "we"))) { trace(2, "swapsolstat: file open error path=%s\n", path); return; @@ -331,7 +367,10 @@ void outsolstat(rtk_t *rtk) int i, j, week, est, nfreq, nf = NF_RTK(&rtk->opt); char id[32]; - if (statlevel <= 0 || !fp_stat) return; + if (statlevel <= 0 || !fp_stat) + { + return; + } trace(3, "outsolstat:\n"); @@ -345,7 +384,10 @@ void outsolstat(rtk_t *rtk) /* receiver position */ if (est) { - for (i = 0; i < 3; i++) xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + for (i = 0; i < 3; i++) + { + xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + } fprintf(fp_stat, "$POS,%d,%.3f,%d,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f\n", week, tow, rtk->sol.stat, rtk->x[0], rtk->x[1], rtk->x[2], xa[0], xa[1], xa[2]); } @@ -361,8 +403,14 @@ void outsolstat(rtk_t *rtk) ecef2pos(rtk->sol.rr, pos); ecef2enu(pos, rtk->x + 3, vel); ecef2enu(pos, rtk->x + 6, acc); - if (rtk->na >= 6) ecef2enu(pos, rtk->xa + 3, vela); - if (rtk->na >= 9) ecef2enu(pos, rtk->xa + 6, acca); + if (rtk->na >= 6) + { + ecef2enu(pos, rtk->xa + 3, vela); + } + if (rtk->na >= 9) + { + ecef2enu(pos, rtk->xa + 6, acca); + } fprintf(fp_stat, "$VELACC,%d,%.3f,%d,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f\n", week, tow, rtk->sol.stat, vel[0], vel[1], vel[2], acc[0], acc[1], acc[2], vela[0], vela[1], vela[2], acca[0], acca[1], acca[2]); @@ -386,7 +434,10 @@ void outsolstat(rtk_t *rtk) for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); j = II_RTK(i + 1, &rtk->opt); xa[0] = j < rtk->na ? rtk->xa[j] : 0.0; @@ -416,13 +467,19 @@ void outsolstat(rtk_t *rtk) i + 1, rtk->x[j], xa[0]); } } - if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) return; + if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) + { + return; + } /* residuals and status */ for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); for (j = 0; j < nfreq; j++) { @@ -509,8 +566,14 @@ double varerr(int sat __attribute((unused)), int sys, double el, double bl, doub } else { /* normal error model */ - if (f >= nf) fact = opt->eratio[f - nf]; - if (fact <= 0.0) fact = opt->eratio[0]; + if (f >= nf) + { + fact = opt->eratio[f - nf]; + } + if (fact <= 0.0) + { + fact = opt->eratio[0]; + } fact *= sys == SYS_GLO ? EFACT_GLO : (sys == SYS_SBS ? EFACT_SBS : EFACT_GPS); a = fact * opt->err[1]; b = fact * opt->err[2]; @@ -523,7 +586,10 @@ double varerr(int sat __attribute((unused)), int sys, double el, double bl, doub double baseline(const double *ru, const double *rb, double *dr) { int i; - for (i = 0; i < 3; i++) dr[i] = ru[i] - rb[i]; + for (i = 0; i < 3; i++) + { + dr[i] = ru[i] - rb[i]; + } return norm_rtk(dr, 3); } @@ -541,7 +607,7 @@ void initx_rtk(rtk_t *rtk, double xi, double var, int i) /* select common satellites between rover and reference station --------------*/ -int selsat(const obsd_t *obs, double *azel, int nu, int nr, +int selsat(const obsd_t *obs, const double *azel, int nu, int nr, const prcopt_t *opt, int *sat, int *iu, int *ir) { int i, j, k = 0; @@ -551,9 +617,13 @@ int selsat(const obsd_t *obs, double *azel, int nu, int nr, for (i = 0, j = nu; i < nu && j < nu + nr; i++, j++) { if (obs[i].sat < obs[j].sat) - j--; + { + j--; + } else if (obs[i].sat > obs[j].sat) - i--; + { + i--; + } else if (azel[1 + j * 2] >= opt->elmin) { /* elevation at base station */ sat[k] = obs[i].sat; @@ -577,26 +647,44 @@ void udpos(rtk_t *rtk, double tt) /* fixed mode */ if (rtk->opt.mode == PMODE_FIXED) { - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->opt.ru[i], 1E-8, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->opt.ru[i], 1E-8, i); + } return; } /* initialize position for first epoch */ if (norm_rtk(rtk->x, 3) <= 0.0) { - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + } if (rtk->opt.dynamics) { - for (i = 3; i < 6; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); - for (i = 6; i < 9; i++) initx_rtk(rtk, 1E-6, VAR_ACC, i); + for (i = 3; i < 6; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); + } + for (i = 6; i < 9; i++) + { + initx_rtk(rtk, 1E-6, VAR_ACC, i); + } } } /* static mode */ - if (rtk->opt.mode == PMODE_STATIC) return; + if (rtk->opt.mode == PMODE_STATIC) + { + return; + } /* kinmatic mode without dynamics */ if (!rtk->opt.dynamics) { - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + } return; } /* check variance of estimated position */ @@ -609,9 +697,18 @@ void udpos(rtk_t *rtk, double tt) if (var > VAR_POS) { /* reset position with large variance */ - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); - for (i = 3; i < 6; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); - for (i = 6; i < 9; i++) initx_rtk(rtk, 1E-6, VAR_ACC, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + } + for (i = 3; i < 6; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); + } + for (i = 6; i < 9; i++) + { + initx_rtk(rtk, 1E-6, VAR_ACC, i); + } trace(2, "reset rtk position due to large variance: var=%.3f\n", var); return; } @@ -636,10 +733,12 @@ void udpos(rtk_t *rtk, double tt) ecef2pos(rtk->x, pos); covecef(pos, Q, Qv); for (i = 0; i < 3; i++) - for (j = 0; j < 3; j++) - { - rtk->P[i + 6 + (j + 6) * rtk->nx] += Qv[i + j * 3]; - } + { + for (j = 0; j < 3; j++) + { + rtk->P[i + 6 + (j + 6) * rtk->nx] += Qv[i + j * 3]; + } + } free(F); free(FP); free(xp); @@ -659,7 +758,9 @@ void udion(rtk_t *rtk, double tt, double bl, const int *sat, int ns) j = II_RTK(i, &rtk->opt); if (rtk->x[j] != 0.0 && rtk->ssat[i - 1].outc[0] > GAP_RESION && rtk->ssat[i - 1].outc[1] > GAP_RESION) - rtk->x[j] = 0.0; + { + rtk->x[j] = 0.0; + } } for (i = 0; i < ns; i++) { @@ -697,7 +798,10 @@ void udtrop(rtk_t *rtk, double tt, double bl __attribute((unused))) if (rtk->opt.tropopt >= TROPOPT_ESTG) { - for (k = 0; k < 2; k++) initx_rtk(rtk, 1e-6, VAR_GRA, ++j); + for (k = 0; k < 2; k++) + { + initx_rtk(rtk, 1e-6, VAR_GRA, ++j); + } } } else @@ -754,13 +858,20 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int i, int rcv) for (f = 0; f < rtk->opt.nf; f++) { - if (obs[i].L[f] == 0.0) continue; + if (obs[i].L[f] == 0.0) + { + continue; + } /* restore previous LLI */ if (rcv == 1) - LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 0, 2); /* rover */ + { + LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 0, 2); /* rover */ + } else - LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 2, 2); /* base */ + { + LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 2, 2); /* base */ + } /* detect slip by cycle slip flag in LLI */ if (rtk->tt >= 0.0) @@ -790,12 +901,16 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int i, int rcv) } /* save current LLI */ if (rcv == 1) - setbitu(&rtk->ssat[sat - 1].slip[f], 0, 2, obs[i].LLI[f]); + { + setbitu(&rtk->ssat[sat - 1].slip[f], 0, 2, obs[i].LLI[f]); + } else - setbitu(&rtk->ssat[sat - 1].slip[f], 2, 2, obs[i].LLI[f]); + { + setbitu(&rtk->ssat[sat - 1].slip[f], 2, 2, obs[i].LLI[f]); + } /* save slip and half-cycle valid flag */ - rtk->ssat[sat - 1].slip[f] |= (unsigned char)slip; + rtk->ssat[sat - 1].slip[f] |= static_cast(slip); rtk->ssat[sat - 1].half[f] = (obs[i].LLI[f] & 2) ? 0 : 1; } } @@ -810,7 +925,10 @@ void detslp_gf_L1L2(rtk_t *rtk, const obsd_t *obs, int i, int j, trace(3, "detslp_gf_L1L2: i=%d j=%d\n", i, j); - if (rtk->opt.nf <= 1 || (g1 = gfobs_L1L2(obs, i, j, nav->lam[sat - 1])) == 0.0) return; + if (rtk->opt.nf <= 1 || (g1 = gfobs_L1L2(obs, i, j, nav->lam[sat - 1])) == 0.0) + { + return; + } g0 = rtk->ssat[sat - 1].gf; rtk->ssat[sat - 1].gf = g1; @@ -834,7 +952,10 @@ void detslp_gf_L1L5(rtk_t *rtk, const obsd_t *obs, int i, int j, trace(3, "detslp_gf_L1L5: i=%d j=%d\n", i, j); - if (rtk->opt.nf <= 2 || (g1 = gfobs_L1L5(obs, i, j, nav->lam[sat - 1])) == 0.0) return; + if (rtk->opt.nf <= 2 || (g1 = gfobs_L1L5(obs, i, j, nav->lam[sat - 1])) == 0.0) + { + return; + } g0 = rtk->ssat[sat - 1].gf2; rtk->ssat[sat - 1].gf2 = g1; @@ -899,7 +1020,10 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, for (i = 0; i < ns; i++) { /* detect cycle slip by LLI */ - for (f = 0; f < rtk->opt.nf; f++) rtk->ssat[sat[i] - 1].slip[f] &= 0xFC; + for (f = 0; f < rtk->opt.nf; f++) + { + rtk->ssat[sat[i] - 1].slip[f] &= 0xFC; + } detslp_ll(rtk, obs, iu[i], 1); detslp_ll(rtk, obs, ir[i], 2); @@ -923,7 +1047,7 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, /* reset phase-bias if instantaneous AR or expire obs outage counter */ for (i = 1; i <= MAXSAT; i++) { - reset = ++rtk->ssat[i - 1].outc[f] > (unsigned int)rtk->opt.maxout; + reset = ++rtk->ssat[i - 1].outc[f] > static_cast(rtk->opt.maxout); if (rtk->opt.modear == ARMODE_INST && rtk->x[IB_RTK(i, f, &rtk->opt)] != 0.0) { @@ -946,8 +1070,14 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, j = IB_RTK(sat[i], f, &rtk->opt); rtk->P[j + j * rtk->nx] += rtk->opt.prn[0] * rtk->opt.prn[0] * tt; slip = rtk->ssat[sat[i] - 1].slip[f]; - if (rtk->opt.ionoopt == IONOOPT_IFLC) slip |= rtk->ssat[sat[i] - 1].slip[1]; - if (rtk->opt.modear == ARMODE_INST || !(slip & 1)) continue; + if (rtk->opt.ionoopt == IONOOPT_IFLC) + { + slip |= rtk->ssat[sat[i] - 1].slip[1]; + } + if (rtk->opt.modear == ARMODE_INST || !(slip & 1)) + { + continue; + } rtk->x[j] = 0.0; rtk->ssat[sat[i] - 1].lock[f] = -rtk->opt.minlock; } @@ -961,7 +1091,10 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, cp = sdobs(obs, iu[i], ir[i], f); /* cycle */ pr = sdobs(obs, iu[i], ir[i], f + NFREQ); lami = nav->lam[sat[i] - 1][f]; - if (cp == 0.0 || pr == 0.0 || lami <= 0.0) continue; + if (cp == 0.0 || pr == 0.0 || lami <= 0.0) + { + continue; + } bias[i] = cp - pr / lami; } @@ -973,7 +1106,10 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, pr2 = sdobs(obs, iu[i], ir[i], NFREQ + 1); lam1 = nav->lam[sat[i] - 1][0]; lam2 = nav->lam[sat[i] - 1][1]; - if (cp1 == 0.0 || cp2 == 0.0 || pr1 == 0.0 || pr2 == 0.0 || lam1 <= 0.0 || lam2 <= 0.0) continue; + if (cp1 == 0.0 || cp2 == 0.0 || pr1 == 0.0 || pr2 == 0.0 || lam1 <= 0.0 || lam2 <= 0.0) + { + continue; + } C1 = std::pow(lam2, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); C2 = -std::pow(lam1, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); @@ -990,13 +1126,19 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, { for (i = 1; i <= MAXSAT; i++) { - if (rtk->x[IB_RTK(i, f, &rtk->opt)] != 0.0) rtk->x[IB_RTK(i, f, &rtk->opt)] += offset / j; + if (rtk->x[IB_RTK(i, f, &rtk->opt)] != 0.0) + { + rtk->x[IB_RTK(i, f, &rtk->opt)] += offset / j; + } } } /* set initial states of phase-bias */ for (i = 0; i < ns; i++) { - if (bias[i] == 0.0 || rtk->x[IB_RTK(sat[i], f, &rtk->opt)] != 0.0) continue; + if (bias[i] == 0.0 || rtk->x[IB_RTK(sat[i], f, &rtk->opt)] != 0.0) + { + continue; + } initx_rtk(rtk, bias[i], std::pow(rtk->opt.std[0], 2.0), IB_RTK(sat[i], f, &rtk->opt)); } free(bias); @@ -1050,10 +1192,16 @@ void zdres_sat(int base, double r, const obsd_t *obs, const nav_t *nav, if (opt->ionoopt == IONOOPT_IFLC) { /* iono-free linear combination */ - if (lam[0] == 0.0 || lam[1] == 0.0) return; + if (lam[0] == 0.0 || lam[1] == 0.0) + { + return; + } if (testsnr(base, 0, azel[1], obs->SNR[0] * 0.25, &opt->snrmask) || - testsnr(base, 1, azel[1], obs->SNR[1] * 0.25, &opt->snrmask)) return; + testsnr(base, 1, azel[1], obs->SNR[1] * 0.25, &opt->snrmask)) + { + return; + } f1 = SPEED_OF_LIGHT / lam[0]; f2 = SPEED_OF_LIGHT / lam[1]; @@ -1074,7 +1222,10 @@ void zdres_sat(int base, double r, const obsd_t *obs, const nav_t *nav, { for (i = 0; i < nf; i++) { - if (lam[i] == 0.0) continue; + if (lam[i] == 0.0) + { + continue; + } /* check snr mask */ if (testsnr(base, i, azel[1], obs->SNR[i] * 0.25, &opt->snrmask)) @@ -1082,8 +1233,14 @@ void zdres_sat(int base, double r, const obsd_t *obs, const nav_t *nav, continue; } /* residuals = observable - pseudorange */ - if (obs->L[i] != 0.0) y[i] = obs->L[i] * lam[i] - r - dant[i]; - if (obs->P[i] != 0.0) y[i + nf] = obs->P[i] - r - dant[i]; + if (obs->L[i] != 0.0) + { + y[i] = obs->L[i] * lam[i] - r - dant[i]; + } + if (obs->P[i] != 0.0) + { + y[i + nf] = obs->P[i] - r - dant[i]; + } } } } @@ -1101,36 +1258,57 @@ int zdres(int base, const obsd_t *obs, int n, const double *rs, trace(3, "zdres : n=%d\n", n); - for (i = 0; i < n * nf * 2; i++) y[i] = 0.0; + for (i = 0; i < n * nf * 2; i++) + { + y[i] = 0.0; + } - if (norm_rtk(rr, 3) <= 0.0) return 0; /* no receiver position */ + if (norm_rtk(rr, 3) <= 0.0) + { + return 0; /* no receiver position */ + } - for (i = 0; i < 3; i++) rr_[i] = rr[i]; + for (i = 0; i < 3; i++) + { + rr_[i] = rr[i]; + } /* earth tide correction */ if (opt->tidecorr) { tidedisp(gpst2utc(obs[0].time), rr_, opt->tidecorr, &nav->erp, opt->odisp[base], disp); - for (i = 0; i < 3; i++) rr_[i] += disp[i]; + for (i = 0; i < 3; i++) + { + rr_[i] += disp[i]; + } } ecef2pos(rr_, pos); for (i = 0; i < n; i++) { /* compute geometric-range and azimuth/elevation angle */ - if ((r = geodist(rs + i * 6, rr_, e + i * 3)) <= 0.0) continue; - if (satazel(pos, e + i * 3, azel + i * 2) < opt->elmin) continue; + if ((r = geodist(rs + i * 6, rr_, e + i * 3)) <= 0.0) + { + continue; + } + if (satazel(pos, e + i * 3, azel + i * 2) < opt->elmin) + { + continue; + } /* excluded satellite? */ - if (satexclude(obs[i].sat, svh[i], opt)) continue; + if (satexclude(obs[i].sat, svh[i], opt)) + { + continue; + } /* satellite clock-bias */ r += -SPEED_OF_LIGHT * dts[i * 2]; /* troposphere delay model (hydrostatic) */ zhd = tropmodel(obs[0].time, pos, zazel, 0.0); - r += tropmapf(obs[i].time, pos, azel + i * 2, NULL) * zhd; + r += tropmapf(obs[i].time, pos, azel + i * 2, nullptr) * zhd; /* receiver antenna phase center correction */ antmodel(opt->pcvr + index, opt->antdel[index], azel + i * 2, opt->posopt[1], @@ -1155,7 +1333,7 @@ int zdres(int base, const obsd_t *obs, int n, const double *rs, /* test valid observation data -----------------------------------------------*/ -int validobs(int i, int j, int f, int nf, double *y) +int validobs(int i, int j, int f, int nf, const double *y) { /* if no phase observable, psudorange is also unusable */ return y[f + i * nf * 2] != 0.0 && y[f + j * nf * 2] != 0.0 && @@ -1171,14 +1349,19 @@ void ddcov(const int *nb, int n, const double *Ri, const double *Rj, trace(3, "ddcov : n=%d\n", n); - for (i = 0; i < nv * nv; i++) R[i] = 0.0; + for (i = 0; i < nv * nv; i++) + { + R[i] = 0.0; + } for (b = 0; b < n; k += nb[b++]) { for (i = 0; i < nb[b]; i++) - for (j = 0; j < nb[b]; j++) - { - R[k + i + (k + j) * nv] = Ri[k + i] + (i == j ? Rj[k + i] : 0.0); - } + { + for (j = 0; j < nb[b]; j++) + { + R[k + i + (k + j) * nv] = Ri[k + i] + (i == j ? Rj[k + i] : 0.0); + } + } } trace(5, "R=\n"); tracemat(5, R, nv, nv, 8, 6); @@ -1196,7 +1379,10 @@ int constbl(rtk_t *rtk, const double *x, const double *P, double *v, trace(3, "constbl : \n"); /* no constraint */ - if (rtk->opt.baseline[0] <= 0.0) return 0; + if (rtk->opt.baseline[0] <= 0.0) + { + return 0; + } /* time-adjusted baseline vector and length */ for (i = 0; i < 3; i++) @@ -1225,7 +1411,10 @@ int constbl(rtk_t *rtk, const double *x, const double *P, double *v, v[index] = rtk->opt.baseline[0] - bb; if (H) { - for (i = 0; i < 3; i++) H[i + index * rtk->nx] = b[i] / bb; + for (i = 0; i < 3; i++) + { + H[i + index * rtk->nx] = b[i] / bb; + } } Ri[index] = 0.0; Rj[index] = std::pow(rtk->opt.baseline[1], 2.0); @@ -1258,7 +1447,9 @@ double prectrop(gtime_t time, const double *pos, int r, dtdx[2] = grad_e * x[i]; } else - dtdx[1] = dtdx[2] = 0.0; + { + dtdx[1] = dtdx[2] = 0.0; + } dtdx[0] = m_w; return m_w * x[i]; } @@ -1270,7 +1461,10 @@ double gloicbcorr(int sat1 __attribute((unused)), int sat2 __attribute((unused)) { double dfreq; - if (f >= NFREQGLO || f >= opt->nf || !opt->exterr.ena[2]) return 0.0; + if (f >= NFREQGLO || f >= opt->nf || !opt->exterr.ena[2]) + { + return 0.0; + } dfreq = (SPEED_OF_LIGHT / lam1 - SPEED_OF_LIGHT / lam2) / (f == 0 ? DFRQ1_GLO : DFRQ2_GLO); @@ -1302,13 +1496,13 @@ int test_sys(int sys, int m) /* double-differenced phase/code residuals -----------------------------------*/ int ddres(rtk_t *rtk, const nav_t *nav, double dt, const double *x, - const double *P, const int *sat, double *y, double *e, + const double *P, const int *sat, double *y, const double *e, double *azel, const int *iu, const int *ir, int ns, double *v, double *H, double *R, int *vflg) { prcopt_t *opt = &rtk->opt; double bl, dr[3], posu[3], posr[3], didxi = 0.0, didxj = 0.0, *im; - double *tropr, *tropu, *dtdxr, *dtdxu, *Ri, *Rj, lami, lamj, fi, fj, df, *Hi = NULL; + double *tropr, *tropu, *dtdxr, *dtdxu, *Ri, *Rj, lami, lamj, fi, fj, df, *Hi = nullptr; int i, j, k, m, f, ff, nv = 0, nb[NFREQ * 4 * 2 + 2] = {0}, b = 0, sysi, sysj, nf = NF_RTK(opt); trace(3, "ddres : dt=%.1f nx=%d ns=%d\n", dt, rtk->nx, ns); @@ -1326,10 +1520,12 @@ int ddres(rtk_t *rtk, const nav_t *nav, double dt, const double *x, dtdxr = mat(ns, 3); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - rtk->ssat[i].resp[j] = rtk->ssat[i].resc[j] = 0.0; - } + { + for (j = 0; j < NFREQ; j++) + { + rtk->ssat[i].resp[j] = rtk->ssat[i].resc[j] = 0.0; + } + } /* compute factors of ionospheric and tropospheric delay */ for (i = 0; i < ns; i++) { @@ -1343,145 +1539,186 @@ int ddres(rtk_t *rtk, const nav_t *nav, double dt, const double *x, tropr[i] = prectrop(rtk->sol.time, posr, 1, azel + ir[i] * 2, opt, x, dtdxr + i * 3); } } - for (m = 0; m < 4; m++) /* m=0:gps/qzs/sbs, 1:glo, 2:gal, 3:bds */ + for (m = 0; m < 4; m++) + { /* m=0:gps/qzs/sbs, 1:glo, 2:gal, 3:bds */ - for (f = opt->mode > PMODE_DGPS ? 0 : nf; f < nf * 2; f++) - { - /* search reference satellite with highest elevation */ - for (i = -1, j = 0; j < ns; j++) - { - sysi = rtk->ssat[sat[j] - 1].sys; - if (!test_sys(sysi, m)) continue; - if (!validobs(iu[j], ir[j], f, nf, y)) continue; - if (i < 0 || azel[1 + iu[j] * 2] >= azel[1 + iu[i] * 2]) i = j; - } - if (i < 0) continue; + for (f = opt->mode > PMODE_DGPS ? 0 : nf; f < nf * 2; f++) + { + /* search reference satellite with highest elevation */ + for (i = -1, j = 0; j < ns; j++) + { + sysi = rtk->ssat[sat[j] - 1].sys; + if (!test_sys(sysi, m)) + { + continue; + } + if (!validobs(iu[j], ir[j], f, nf, y)) + { + continue; + } + if (i < 0 || azel[1 + iu[j] * 2] >= azel[1 + iu[i] * 2]) + { + i = j; + } + } + if (i < 0) + { + continue; + } - /* make double difference */ - for (j = 0; j < ns; j++) - { - if (i == j) continue; - sysi = rtk->ssat[sat[i] - 1].sys; - sysj = rtk->ssat[sat[j] - 1].sys; - if (!test_sys(sysj, m)) continue; - if (!validobs(iu[j], ir[j], f, nf, y)) continue; + /* make double difference */ + for (j = 0; j < ns; j++) + { + if (i == j) + { + continue; + } + sysi = rtk->ssat[sat[i] - 1].sys; + sysj = rtk->ssat[sat[j] - 1].sys; + if (!test_sys(sysj, m)) + { + continue; + } + if (!validobs(iu[j], ir[j], f, nf, y)) + { + continue; + } - ff = f % nf; - lami = nav->lam[sat[i] - 1][ff]; - lamj = nav->lam[sat[j] - 1][ff]; - if (lami <= 0.0 || lamj <= 0.0) continue; - if (H) - { - Hi = H + nv * rtk->nx; - for (k = 0; k < rtk->nx; k++) Hi[k] = 0.0; - } - /* double-differenced residual */ - v[nv] = (y[f + iu[i] * nf * 2] - y[f + ir[i] * nf * 2]) - - (y[f + iu[j] * nf * 2] - y[f + ir[j] * nf * 2]); + ff = f % nf; + lami = nav->lam[sat[i] - 1][ff]; + lamj = nav->lam[sat[j] - 1][ff]; + if (lami <= 0.0 || lamj <= 0.0) + { + continue; + } + if (H) + { + Hi = H + nv * rtk->nx; + for (k = 0; k < rtk->nx; k++) + { + Hi[k] = 0.0; + } + } + /* double-differenced residual */ + v[nv] = (y[f + iu[i] * nf * 2] - y[f + ir[i] * nf * 2]) - + (y[f + iu[j] * nf * 2] - y[f + ir[j] * nf * 2]); - /* partial derivatives by rover position */ - if (H) - { - for (k = 0; k < 3; k++) - { - Hi[k] = -e[k + iu[i] * 3] + e[k + iu[j] * 3]; - } - } - /* double-differenced ionospheric delay term */ - if (opt->ionoopt == IONOOPT_EST) - { - fi = lami / lam_carr[0]; - fj = lamj / lam_carr[0]; - didxi = (f < nf ? -1.0 : 1.0) * fi * fi * im[i]; - didxj = (f < nf ? -1.0 : 1.0) * fj * fj * im[j]; - v[nv] -= didxi * x[II_RTK(sat[i], opt)] - didxj * x[II_RTK(sat[j], opt)]; - if (H) - { - Hi[II_RTK(sat[i], opt)] = didxi; - Hi[II_RTK(sat[j], opt)] = -didxj; - } - } - /* double-differenced tropospheric delay term */ - if (opt->tropopt == TROPOPT_EST || opt->tropopt == TROPOPT_ESTG) - { - v[nv] -= (tropu[i] - tropu[j]) - (tropr[i] - tropr[j]); - for (k = 0; k < (opt->tropopt < TROPOPT_ESTG ? 1 : 3); k++) - { - if (!H) continue; - Hi[IT_RTK(0, opt) + k] = (dtdxu[k + i * 3] - dtdxu[k + j * 3]); - Hi[IT_RTK(1, opt) + k] = -(dtdxr[k + i * 3] - dtdxr[k + j * 3]); - } - } - /* double-differenced phase-bias term */ - if (f < nf) - { - if (opt->ionoopt != IONOOPT_IFLC) - { - v[nv] -= lami * x[IB_RTK(sat[i], f, opt)] - lamj * x[IB_RTK(sat[j], f, opt)]; - if (H) - { - Hi[IB_RTK(sat[i], f, opt)] = lami; - Hi[IB_RTK(sat[j], f, opt)] = -lamj; - } - } - else - { - v[nv] -= x[IB_RTK(sat[i], f, opt)] - x[IB_RTK(sat[j], f, opt)]; - if (H) - { - Hi[IB_RTK(sat[i], f, opt)] = 1.0; - Hi[IB_RTK(sat[j], f, opt)] = -1.0; - } - } - } - /* glonass receiver h/w bias term */ - if (rtk->opt.glomodear == 2 && sysi == SYS_GLO && sysj == SYS_GLO && ff < NFREQGLO) - { - df = (SPEED_OF_LIGHT / lami - SPEED_OF_LIGHT / lamj) / 1E6; /* freq-difference (MHz) */ - v[nv] -= df * x[IL_RTK(ff, opt)]; - if (H) Hi[IL_RTK(ff, opt)] = df; - } - /* glonass interchannel bias correction */ - else if (sysi == SYS_GLO && sysj == SYS_GLO) - { - v[nv] -= gloicbcorr(sat[i], sat[j], &rtk->opt, lami, lamj, f); - } - if (f < nf) - rtk->ssat[sat[j] - 1].resc[f] = v[nv]; - else - rtk->ssat[sat[j] - 1].resp[f - nf] = v[nv]; + /* partial derivatives by rover position */ + if (H) + { + for (k = 0; k < 3; k++) + { + Hi[k] = -e[k + iu[i] * 3] + e[k + iu[j] * 3]; + } + } + /* double-differenced ionospheric delay term */ + if (opt->ionoopt == IONOOPT_EST) + { + fi = lami / LAM_CARR[0]; + fj = lamj / LAM_CARR[0]; + didxi = (f < nf ? -1.0 : 1.0) * fi * fi * im[i]; + didxj = (f < nf ? -1.0 : 1.0) * fj * fj * im[j]; + v[nv] -= didxi * x[II_RTK(sat[i], opt)] - didxj * x[II_RTK(sat[j], opt)]; + if (H) + { + Hi[II_RTK(sat[i], opt)] = didxi; + Hi[II_RTK(sat[j], opt)] = -didxj; + } + } + /* double-differenced tropospheric delay term */ + if (opt->tropopt == TROPOPT_EST || opt->tropopt == TROPOPT_ESTG) + { + v[nv] -= (tropu[i] - tropu[j]) - (tropr[i] - tropr[j]); + for (k = 0; k < (opt->tropopt < TROPOPT_ESTG ? 1 : 3); k++) + { + if (!H) + { + continue; + } + Hi[IT_RTK(0, opt) + k] = (dtdxu[k + i * 3] - dtdxu[k + j * 3]); + Hi[IT_RTK(1, opt) + k] = -(dtdxr[k + i * 3] - dtdxr[k + j * 3]); + } + } + /* double-differenced phase-bias term */ + if (f < nf) + { + if (opt->ionoopt != IONOOPT_IFLC) + { + v[nv] -= lami * x[IB_RTK(sat[i], f, opt)] - lamj * x[IB_RTK(sat[j], f, opt)]; + if (H) + { + Hi[IB_RTK(sat[i], f, opt)] = lami; + Hi[IB_RTK(sat[j], f, opt)] = -lamj; + } + } + else + { + v[nv] -= x[IB_RTK(sat[i], f, opt)] - x[IB_RTK(sat[j], f, opt)]; + if (H) + { + Hi[IB_RTK(sat[i], f, opt)] = 1.0; + Hi[IB_RTK(sat[j], f, opt)] = -1.0; + } + } + } + /* glonass receiver h/w bias term */ + if (rtk->opt.glomodear == 2 && sysi == SYS_GLO && sysj == SYS_GLO && ff < NFREQGLO) + { + df = (SPEED_OF_LIGHT / lami - SPEED_OF_LIGHT / lamj) / 1E6; /* freq-difference (MHz) */ + v[nv] -= df * x[IL_RTK(ff, opt)]; + if (H) + { + Hi[IL_RTK(ff, opt)] = df; + } + } + /* glonass interchannel bias correction */ + else if (sysi == SYS_GLO && sysj == SYS_GLO) + { + v[nv] -= gloicbcorr(sat[i], sat[j], &rtk->opt, lami, lamj, f); + } + if (f < nf) + { + rtk->ssat[sat[j] - 1].resc[f] = v[nv]; + } + else + { + rtk->ssat[sat[j] - 1].resp[f - nf] = v[nv]; + } - /* test innovation */ - if (opt->maxinno > 0.0 && fabs(v[nv]) > opt->maxinno) - { - if (f < nf) - { - rtk->ssat[sat[i] - 1].rejc[f]++; - rtk->ssat[sat[j] - 1].rejc[f]++; - } - errmsg(rtk, "outlier rejected (sat=%3d-%3d %s%d v=%.3f)\n", - sat[i], sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv]); - continue; - } - /* single-differenced measurement error variances */ - Ri[nv] = varerr(sat[i], sysi, azel[1 + iu[i] * 2], bl, dt, f, opt); - Rj[nv] = varerr(sat[j], sysj, azel[1 + iu[j] * 2], bl, dt, f, opt); + /* test innovation */ + if (opt->maxinno > 0.0 && fabs(v[nv]) > opt->maxinno) + { + if (f < nf) + { + rtk->ssat[sat[i] - 1].rejc[f]++; + rtk->ssat[sat[j] - 1].rejc[f]++; + } + errmsg(rtk, "outlier rejected (sat=%3d-%3d %s%d v=%.3f)\n", + sat[i], sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv]); + continue; + } + /* single-differenced measurement error variances */ + Ri[nv] = varerr(sat[i], sysi, azel[1 + iu[i] * 2], bl, dt, f, opt); + Rj[nv] = varerr(sat[j], sysj, azel[1 + iu[j] * 2], bl, dt, f, opt); - /* set valid data flags */ - if (opt->mode > PMODE_DGPS) - { - if (f < nf) rtk->ssat[sat[i] - 1].vsat[f] = rtk->ssat[sat[j] - 1].vsat[f] = 1; - } - else - { - rtk->ssat[sat[i] - 1].vsat[f - nf] = rtk->ssat[sat[j] - 1].vsat[f - nf] = 1; - } - trace(4, "sat=%3d-%3d %s%d v=%13.3f R=%8.6f %8.6f\n", sat[i], - sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv], Ri[nv], Rj[nv]); + /* set valid data flags */ + if (opt->mode > PMODE_DGPS) + { + if (f < nf) + { + rtk->ssat[sat[i] - 1].vsat[f] = rtk->ssat[sat[j] - 1].vsat[f] = 1; + } + } + else + { + rtk->ssat[sat[i] - 1].vsat[f - nf] = rtk->ssat[sat[j] - 1].vsat[f - nf] = 1; + } + trace(4, "sat=%3d-%3d %s%d v=%13.3f R=%8.6f %8.6f\n", sat[i], + sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv], Ri[nv], Rj[nv]); - vflg[nv++] = (sat[i] << 16) | (sat[j] << 8) | ((f < nf ? 0 : 1) << 4) | (f % nf); - nb[b]++; - } + vflg[nv++] = (sat[i] << 16) | (sat[j] << 8) | ((f < nf ? 0 : 1) << 4) | (f % nf); + nb[b]++; + } #if 0 /* residuals referenced to reference satellite (2.4.2 p11) */ /* restore single-differenced residuals assuming sum equal zero */ if (f opt->maxtdiff * 2.0 || ttb == tt) return tt; + if (fabs(ttb) > opt->maxtdiff * 2.0 || ttb == tt) + { + return tt; + } satposs(time, obsb, nb, nav, opt->sateph, rs, dts, var, svh); @@ -1567,14 +1811,26 @@ double intpres(gtime_t time, const obsd_t *obs, int n, const nav_t *nav, for (i = 0; i < n; i++) { for (j = 0; j < nb; j++) - if (obsb[j].sat == obs[i].sat) break; - if (j >= nb) continue; + { + if (obsb[j].sat == obs[i].sat) + { + break; + } + } + if (j >= nb) + { + continue; + } for (k = 0, p = y + i * nf * 2, q = yb + j * nf * 2; k < nf * 2; k++, p++, q++) { if (*p == 0.0 || *q == 0.0) - *p = 0.0; + { + *p = 0.0; + } else - *p = (ttb * (*p) - tt * (*q)) / (ttb - tt); + { + *p = (ttb * (*p) - tt * (*q)) / (ttb - tt); + } } } return fabs(ttb) > fabs(tt) ? ttb : tt; @@ -1589,11 +1845,16 @@ int ddmat(rtk_t *rtk, double *D) trace(3, "ddmat :\n"); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - rtk->ssat[i].fix[j] = 0; - } - for (i = 0; i < na; i++) D[i + i * nx] = 1.0; + { + for (j = 0; j < NFREQ; j++) + { + rtk->ssat[i].fix[j] = 0; + } + } + for (i = 0; i < na; i++) + { + D[i + i * nx] = 1.0; + } for (m = 0; m < 4; m++) { /* m=0:gps/qzs/sbs, 1:glo, 2:gal, 3:bds */ @@ -1616,8 +1877,7 @@ int ddmat(rtk_t *rtk, double *D) rtk->ssat[i - k].fix[f] = 2; /* fix */ break; } - else - rtk->ssat[i - k].fix[f] = 1; + rtk->ssat[i - k].fix[f] = 1; } for (j = k; j < k + MAXSAT; j++) { @@ -1636,7 +1896,9 @@ int ddmat(rtk_t *rtk, double *D) rtk->ssat[j - k].fix[f] = 2; /* fix */ } else - rtk->ssat[j - k].fix[f] = 1; + { + rtk->ssat[j - k].fix[f] = 1; + } } } } @@ -1654,29 +1916,40 @@ void restamb(rtk_t *rtk, const double *bias, int nb __attribute((unused)), doubl trace(3, "restamb :\n"); - for (i = 0; i < rtk->nx; i++) xa[i] = rtk->x[i]; - for (i = 0; i < rtk->na; i++) xa[i] = rtk->xa[i]; + for (i = 0; i < rtk->nx; i++) + { + xa[i] = rtk->x[i]; + } + for (i = 0; i < rtk->na; i++) + { + xa[i] = rtk->xa[i]; + } for (m = 0; m < 4; m++) - for (f = 0; f < nf; f++) - { - for (n = i = 0; i < MAXSAT; i++) - { - if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2) - { - continue; - } - index[n++] = IB_RTK(i + 1, f, &rtk->opt); - } - if (n < 2) continue; + { + for (f = 0; f < nf; f++) + { + for (n = i = 0; i < MAXSAT; i++) + { + if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2) + { + continue; + } + index[n++] = IB_RTK(i + 1, f, &rtk->opt); + } + if (n < 2) + { + continue; + } - xa[index[0]] = rtk->x[index[0]]; + xa[index[0]] = rtk->x[index[0]]; - for (i = 1; i < n; i++) - { - xa[index[i]] = xa[index[0]] - bias[nv++]; - } - } + for (i = 1; i < n; i++) + { + xa[index[i]] = xa[index[0]] - bias[nv++]; + } + } + } } @@ -1692,32 +1965,37 @@ void holdamb(rtk_t *rtk, const double *xa) H = zeros(nb, rtk->nx); for (m = 0; m < 4; m++) - for (f = 0; f < nf; f++) - { - for (n = i = 0; i < MAXSAT; i++) - { - if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2 || - rtk->ssat[i].azel[1] < rtk->opt.elmaskhold) - { - continue; - } - index[n++] = IB_RTK(i + 1, f, &rtk->opt); - rtk->ssat[i].fix[f] = 3; /* hold */ - } - /* constraint to fixed ambiguity */ - for (i = 1; i < n; i++) - { - v[nv] = (xa[index[0]] - xa[index[i]]) - (rtk->x[index[0]] - rtk->x[index[i]]); + { + for (f = 0; f < nf; f++) + { + for (n = i = 0; i < MAXSAT; i++) + { + if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2 || + rtk->ssat[i].azel[1] < rtk->opt.elmaskhold) + { + continue; + } + index[n++] = IB_RTK(i + 1, f, &rtk->opt); + rtk->ssat[i].fix[f] = 3; /* hold */ + } + /* constraint to fixed ambiguity */ + for (i = 1; i < n; i++) + { + v[nv] = (xa[index[0]] - xa[index[i]]) - (rtk->x[index[0]] - rtk->x[index[i]]); - H[index[0] + nv * rtk->nx] = 1.0; - H[index[i] + nv * rtk->nx] = -1.0; - nv++; - } - } + H[index[0] + nv * rtk->nx] = 1.0; + H[index[i] + nv * rtk->nx] = -1.0; + nv++; + } + } + } if (nv > 0) { R = zeros(nv, nv); - for (i = 0; i < nv; i++) R[i + i * nv] = VAR_HOLDAMB; + for (i = 0; i < nv; i++) + { + R[i + i * nv] = VAR_HOLDAMB; + } /* update states with constraints */ if ((info = filter(rtk->x, rtk->P, H, v, R, rtk->nx, nv))) @@ -1772,9 +2050,19 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) /* phase-bias covariance (Qb) and real-parameters to bias covariance (Qab) */ for (i = 0; i < nb; i++) - for (j = 0; j < nb; j++) Qb[i + j * nb] = Qy[na + i + (na + j) * ny]; + { + for (j = 0; j < nb; j++) + { + Qb[i + j * nb] = Qy[na + i + (na + j) * ny]; + } + } for (i = 0; i < na; i++) - for (j = 0; j < nb; j++) Qab[i + j * na] = Qy[i + (na + j) * ny]; + { + for (j = 0; j < nb; j++) + { + Qab[i + j * na] = Qy[i + (na + j) * ny]; + } + } trace(4, "N(0)="); tracemat(4, y + na, 1, nb, 10, 3); @@ -1787,8 +2075,11 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) trace(4, "N(2)="); tracemat(4, b + nb, 1, nb, 10, 3); - rtk->sol.ratio = s[0] > 0 ? (float)(s[1] / s[0]) : 0.0f; - if (rtk->sol.ratio > 999.9) rtk->sol.ratio = 999.9f; + rtk->sol.ratio = s[0] > 0 ? static_cast(s[1] / s[0]) : 0.0f; + if (rtk->sol.ratio > 999.9) + { + rtk->sol.ratio = 999.9f; + } /* validation by popular ratio-test */ if (s[0] <= 0.0 || s[1] / s[0] >= opt->thresar[0]) @@ -1797,7 +2088,10 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) for (i = 0; i < na; i++) { rtk->xa[i] = rtk->x[i]; - for (j = 0; j < na; j++) rtk->Pa[i + j * na] = rtk->P[i + j * nx]; + for (j = 0; j < na; j++) + { + rtk->Pa[i + j * na] = rtk->P[i + j * nx]; + } } for (i = 0; i < nb; i++) { @@ -1820,7 +2114,9 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) restamb(rtk, bias, nb, xa); } else - nb = 0; + { + nb = 0; + } } else { /* validation failed */ @@ -1864,7 +2160,10 @@ int valpos(rtk_t *rtk, const double *v, const double *R, const int *vflg, /* post-fit residual test */ for (i = 0; i < nv; i++) { - if (v[i] * v[i] <= fact * R[i + i * nv]) continue; + if (v[i] * v[i] <= fact * R[i + i * nv]) + { + continue; + } sat1 = (vflg[i] >> 16) & 0xFF; sat2 = (vflg[i] >> 8) & 0xFF; type = (vflg[i] >> 4) & 0xF; @@ -1921,8 +2220,11 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, for (i = 0; i < MAXSAT; i++) { - rtk->ssat[i].sys = satsys(i + 1, NULL); - for (j = 0; j < NFREQ; j++) rtk->ssat[i].vsat[j] = rtk->ssat[i].snr[j] = 0; + rtk->ssat[i].sys = satsys(i + 1, nullptr); + for (j = 0; j < NFREQ; j++) + { + rtk->ssat[i].vsat[j] = rtk->ssat[i].snr[j] = 0; + } } /* satellite positions/clocks */ satposs(time, obs, n, nav, opt->sateph, rs, dts, var, svh); @@ -2009,7 +2311,7 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, if (stat != SOLQ_NONE && zdres(0, obs, nu, rs, dts, svh, nav, xp, opt, 0, y, e, azel)) { /* post-fit residuals for float solution */ - nv = ddres(rtk, nav, dt, xp, Pp, sat, y, e, azel, iu, ir, ns, v, NULL, R, vflg); + nv = ddres(rtk, nav, dt, xp, Pp, sat, y, e, azel, iu, ir, ns, v, nullptr, R, vflg); /* validation of float solution */ if (valpos(rtk, v, R, vflg, nv, 4.0)) @@ -2021,18 +2323,31 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, /* update ambiguity control struct */ rtk->sol.ns = 0; for (i = 0; i < ns; i++) - for (f = 0; f < nf; f++) - { - if (!rtk->ssat[sat[i] - 1].vsat[f]) continue; - rtk->ssat[sat[i] - 1].lock[f]++; - rtk->ssat[sat[i] - 1].outc[f] = 0; - if (f == 0) rtk->sol.ns++; /* valid satellite count by L1 */ - } + { + for (f = 0; f < nf; f++) + { + if (!rtk->ssat[sat[i] - 1].vsat[f]) + { + continue; + } + rtk->ssat[sat[i] - 1].lock[f]++; + rtk->ssat[sat[i] - 1].outc[f] = 0; + if (f == 0) + { + rtk->sol.ns++; /* valid satellite count by L1 */ + } + } + } /* lack of valid satellites */ - if (rtk->sol.ns < 4) stat = SOLQ_NONE; + if (rtk->sol.ns < 4) + { + stat = SOLQ_NONE; + } } else - stat = SOLQ_NONE; + { + stat = SOLQ_NONE; + } } /* resolve integer ambiguity by WL-NL */ if (stat != SOLQ_NONE && rtk->opt.modear == ARMODE_WLNL) @@ -2056,7 +2371,7 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, if (zdres(0, obs, nu, rs, dts, svh, nav, xa, opt, 0, y, e, azel)) { /* post-fit reisiduals for fixed solution */ - nv = ddres(rtk, nav, dt, xa, NULL, sat, y, e, azel, iu, ir, ns, v, NULL, R, vflg); + nv = ddres(rtk, nav, dt, xa, nullptr, sat, y, e, azel, iu, ir, ns, v, nullptr, R, vflg); /* validation of fixed solution */ if (valpos(rtk, v, R, vflg, nv, 4.0)) @@ -2078,43 +2393,58 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, for (i = 0; i < 3; i++) { rtk->sol.rr[i] = rtk->xa[i]; - rtk->sol.qr[i] = (float)rtk->Pa[i + i * rtk->na]; + rtk->sol.qr[i] = static_cast(rtk->Pa[i + i * rtk->na]); } - rtk->sol.qr[3] = (float)rtk->Pa[1]; - rtk->sol.qr[4] = (float)rtk->Pa[1 + 2 * rtk->na]; - rtk->sol.qr[5] = (float)rtk->Pa[2]; + rtk->sol.qr[3] = static_cast(rtk->Pa[1]); + rtk->sol.qr[4] = static_cast(rtk->Pa[1 + 2 * rtk->na]); + rtk->sol.qr[5] = static_cast(rtk->Pa[2]); } else { for (i = 0; i < 3; i++) { rtk->sol.rr[i] = rtk->x[i]; - rtk->sol.qr[i] = (float)rtk->P[i + i * rtk->nx]; + rtk->sol.qr[i] = static_cast(rtk->P[i + i * rtk->nx]); } - rtk->sol.qr[3] = (float)rtk->P[1]; - rtk->sol.qr[4] = (float)rtk->P[1 + 2 * rtk->nx]; - rtk->sol.qr[5] = (float)rtk->P[2]; + rtk->sol.qr[3] = static_cast(rtk->P[1]); + rtk->sol.qr[4] = static_cast(rtk->P[1 + 2 * rtk->nx]); + rtk->sol.qr[5] = static_cast(rtk->P[2]); rtk->nfix = 0; } for (i = 0; i < n; i++) - for (j = 0; j < nf; j++) - { - if (obs[i].L[j] == 0.0) continue; - rtk->ssat[obs[i].sat - 1].pt[obs[i].rcv - 1][j] = obs[i].time; - rtk->ssat[obs[i].sat - 1].ph[obs[i].rcv - 1][j] = obs[i].L[j]; - } + { + for (j = 0; j < nf; j++) + { + if (obs[i].L[j] == 0.0) + { + continue; + } + rtk->ssat[obs[i].sat - 1].pt[obs[i].rcv - 1][j] = obs[i].time; + rtk->ssat[obs[i].sat - 1].ph[obs[i].rcv - 1][j] = obs[i].L[j]; + } + } for (i = 0; i < ns; i++) - for (j = 0; j < nf; j++) - { - /* output snr of rover receiver */ - rtk->ssat[sat[i] - 1].snr[j] = obs[iu[i]].SNR[j]; - } + { + for (j = 0; j < nf; j++) + { + /* output snr of rover receiver */ + rtk->ssat[sat[i] - 1].snr[j] = obs[iu[i]].SNR[j]; + } + } for (i = 0; i < MAXSAT; i++) - for (j = 0; j < nf; j++) - { - if (rtk->ssat[i].fix[j] == 2 && stat != SOLQ_FIX) rtk->ssat[i].fix[j] = 1; - if (rtk->ssat[i].slip[j] & 1) rtk->ssat[i].slipc[j]++; - } + { + for (j = 0; j < nf; j++) + { + if (rtk->ssat[i].fix[j] == 2 && stat != SOLQ_FIX) + { + rtk->ssat[i].fix[j] = 1; + } + if (rtk->ssat[i].slip[j] & 1) + { + rtk->ssat[i].slipc[j]++; + } + } + } free(rs); free(dts); free(var); @@ -2129,7 +2459,10 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, free(R); free(bias); - if (stat != SOLQ_NONE) rtk->sol.stat = stat; + if (stat != SOLQ_NONE) + { + rtk->sol.stat = stat; + } return stat != SOLQ_NONE; } @@ -2145,13 +2478,16 @@ void rtkinit(rtk_t *rtk, const prcopt_t *opt) { sol_t sol0 = {{0, 0}, {}, {}, {}, '0', '0', '0', 0.0, 0.0, 0.0}; ambc_t ambc0 = {{{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {}, {}, {}, 0, {}}; - ssat_t ssat0 = {0, 0, {0.0}, {0.0}, {0.0}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {}, {}, {}, {}, 0.0, 0.0, 0.0, 0.0, {{0, 0}, {0, 0}}, {{}, {}}}; + ssat_t ssat0 = {0, 0, {0.0}, {0.0}, {0.0}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {}, {}, {}, {}, 0.0, 0.0, 0.0, 0.0, {{{0, 0}}, {{0, 0}}}, {{}, {}}}; int i; trace(3, "rtkinit :\n"); rtk->sol = sol0; - for (i = 0; i < 6; i++) rtk->rb[i] = 0.0; + for (i = 0; i < 6; i++) + { + rtk->rb[i] = 0.0; + } rtk->nx = opt->mode <= PMODE_FIXED ? NX_RTK(opt) : pppnx(opt); rtk->na = opt->mode <= PMODE_FIXED ? NR_RTK(opt) : pppnx(opt); rtk->tt = 0.0; @@ -2165,7 +2501,10 @@ void rtkinit(rtk_t *rtk, const prcopt_t *opt) rtk->ambc[i] = ambc0; rtk->ssat[i] = ssat0; } - for (i = 0; i < MAXERRMSG; i++) rtk->errbuf[i] = 0; + for (i = 0; i < MAXERRMSG; i++) + { + rtk->errbuf[i] = 0; + } rtk->opt = *opt; } @@ -2181,13 +2520,13 @@ void rtkfree(rtk_t *rtk) rtk->nx = rtk->na = 0; free(rtk->x); - rtk->x = NULL; + rtk->x = nullptr; free(rtk->P); - rtk->P = NULL; + rtk->P = nullptr; free(rtk->xa); - rtk->xa = NULL; + rtk->xa = nullptr; free(rtk->Pa); - rtk->Pa = NULL; + rtk->Pa = nullptr; } @@ -2266,18 +2605,25 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) if (opt->refpos <= POSOPT_RINEX && opt->mode != PMODE_SINGLE && opt->mode != PMODE_MOVEB) { - for (i = 0; i < 6; i++) rtk->rb[i] = i < 3 ? opt->rb[i] : 0.0; + for (i = 0; i < 6; i++) + { + rtk->rb[i] = i < 3 ? opt->rb[i] : 0.0; + } } /* count rover/base station observations */ for (nu = 0; nu < n && obs[nu].rcv == 1; nu++) - ; + { + ; + } for (nr = 0; nu + nr < n && obs[nu + nr].rcv == 2; nr++) - ; + { + ; + } time = rtk->sol.time; /* previous epoch */ /* rover position by single point positioning */ - if (!pntpos(obs, nu, nav, &rtk->opt, &rtk->sol, NULL, rtk->ssat, msg)) + if (!pntpos(obs, nu, nav, &rtk->opt, &rtk->sol, nullptr, rtk->ssat, msg)) { errmsg(rtk, "point pos error (%s)\n", msg); if (!rtk->opt.dynamics) @@ -2286,7 +2632,10 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) return 0; } } - if (time.time != 0) rtk->tt = timediff(rtk->sol.time, time); + if (time.time != 0) + { + rtk->tt = timediff(rtk->sol.time, time); + } /* single point positioning */ if (opt->mode == PMODE_SINGLE) @@ -2317,28 +2666,34 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) { /* moving baseline */ /* estimate position/velocity of base station */ - if (!pntpos(obs + nu, nr, nav, &rtk->opt, &solb, NULL, NULL, msg)) + if (!pntpos(obs + nu, nr, nav, &rtk->opt, &solb, nullptr, nullptr, msg)) { errmsg(rtk, "base station position error (%s)\n", msg); return 0; } - rtk->sol.age = (float)timediff(rtk->sol.time, solb.time); + rtk->sol.age = static_cast(timediff(rtk->sol.time, solb.time)); - if (fabs(rtk->sol.age) > TTOL_MOVEB) + if (std::fabs(rtk->sol.age) > TTOL_MOVEB) { errmsg(rtk, "time sync error for moving-base (age=%.1f)\n", rtk->sol.age); return 0; } - for (i = 0; i < 6; i++) rtk->rb[i] = solb.rr[i]; + for (i = 0; i < 6; i++) + { + rtk->rb[i] = solb.rr[i]; + } /* time-synchronized position of base station */ - for (i = 0; i < 3; i++) rtk->rb[i] += rtk->rb[i + 3] * rtk->sol.age; + for (i = 0; i < 3; i++) + { + rtk->rb[i] += rtk->rb[i + 3] * rtk->sol.age; + } } else { - rtk->sol.age = (float)timediff(obs[0].time, obs[nu].time); + rtk->sol.age = static_cast(timediff(obs[0].time, obs[nu].time)); - if (fabs(rtk->sol.age) > opt->maxtdiff) + if (std::fabs(rtk->sol.age) > opt->maxtdiff) { errmsg(rtk, "age of differential error (age=%.1f)\n", rtk->sol.age); outsolstat(rtk); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.h b/src/algorithms/libs/rtklib/rtklib_rtkpos.h index 81234a634..3cac6b4d0 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.h +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.h @@ -108,7 +108,7 @@ double baseline(const double *ru, const double *rb, double *dr); void initx_rtk(rtk_t *rtk, double xi, double var, int i); -int selsat(const obsd_t *obs, double *azel, int nu, int nr, +int selsat(const obsd_t *obs, const double *azel, int nu, int nr, const prcopt_t *opt, int *sat, int *iu, int *ir); void udpos(rtk_t *rtk, double tt); @@ -144,7 +144,7 @@ int zdres(int base, const obsd_t *obs, int n, const double *rs, const double *rr, const prcopt_t *opt, int index, double *y, double *e, double *azel); -int validobs(int i, int j, int f, int nf, double *y); +int validobs(int i, int j, int f, int nf, const double *y); void ddcov(const int *nb, int n, const double *Ri, const double *Rj, int nv, double *R); @@ -162,7 +162,7 @@ double gloicbcorr(int sat1, int sat2, const prcopt_t *opt, double lam1, int test_sys(int sys, int m); int ddres(rtk_t *rtk, const nav_t *nav, double dt, const double *x, - const double *P, const int *sat, double *y, double *e, + const double *P, const int *sat, double *y, const double *e, double *azel, const int *iu, const int *ir, int ns, double *v, double *H, double *R, int *vflg); diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index 6f27b9ca6..8b2e00833 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -1,12 +1,13 @@ #include "rtklib_rtksvr.h" +#include "rtklib_preceph.h" +#include "rtklib_rtcm.h" #include "rtklib_rtkcmn.h" #include "rtklib_rtkpos.h" -#include "rtklib_solution.h" #include "rtklib_sbas.h" -#include "rtklib_preceph.h" +#include "rtklib_solution.h" #include "rtklib_stream.h" -#include "rtklib_rtcm.h" +#include /* write solution header to output stream ------------------------------------*/ void writesolhead(stream_t *stream, const solopt_t *solopt) @@ -34,7 +35,7 @@ void saveoutbuf(rtksvr_t *svr, unsigned char *buff, int n, int index) /* write solution to output stream -------------------------------------------*/ void writesol(rtksvr_t *svr, int index) { - solopt_t solopt = solopt_default; + solopt_t solopt = SOLOPT_DEFAULT; unsigned char buff[1024]; int i, n; @@ -77,10 +78,12 @@ void updatenav(nav_t *nav) { int i, j; for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - nav->lam[i][j] = satwavelen(i + 1, j, nav); - } + { + for (j = 0; j < NFREQ; j++) + { + nav->lam[i][j] = satwavelen(i + 1, j, nav); + } + } } @@ -95,14 +98,23 @@ void updatefcn(rtksvr_t *svr) for (j = 0, frq = -999; j < 3; j++) { - if (svr->raw[j].nav.geph[i].sat != sat) continue; + if (svr->raw[j].nav.geph[i].sat != sat) + { + continue; + } frq = svr->raw[j].nav.geph[i].frq; } - if (frq < -7 || frq > 6) continue; + if (frq < -7 || frq > 6) + { + continue; + } for (j = 0; j < 3; j++) { - if (svr->raw[j].nav.geph[i].sat == sat) continue; + if (svr->raw[j].nav.geph[i].sat == sat) + { + continue; + } svr->raw[j].nav.geph[i].sat = sat; svr->raw[j].nav.geph[i].frq = frq; } @@ -129,7 +141,10 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, for (i = 0; i < obs->n; i++) { if (svr->rtk.opt.exsats[obs->data[i].sat - 1] == 1 || - !(satsys(obs->data[i].sat, NULL) & svr->rtk.opt.navsys)) continue; + !(satsys(obs->data[i].sat, nullptr) & svr->rtk.opt.navsys)) + { + continue; + } svr->obs[index][iobs].data[n] = obs->data[i]; svr->obs[index][iobs].data[n++].rcv = index + 1; } @@ -188,7 +203,10 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, } else { - for (i = 0; i < MAXSBSMSG - 1; i++) svr->sbsmsg[i] = svr->sbsmsg[i + 1]; + for (i = 0; i < MAXSBSMSG - 1; i++) + { + svr->sbsmsg[i] = svr->sbsmsg[i + 1]; + } svr->sbsmsg[i] = *sbsmsg; } sbsupdatecorr(sbsmsg, &svr->nav); @@ -199,12 +217,30 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* ion/utc parameters */ if (svr->navsel == index || svr->navsel >= 3) { - for (i = 0; i < 8; i++) svr->nav.ion_gps[i] = nav->ion_gps[i]; - for (i = 0; i < 4; i++) svr->nav.utc_gps[i] = nav->utc_gps[i]; - for (i = 0; i < 4; i++) svr->nav.ion_gal[i] = nav->ion_gal[i]; - for (i = 0; i < 4; i++) svr->nav.utc_gal[i] = nav->utc_gal[i]; - for (i = 0; i < 8; i++) svr->nav.ion_qzs[i] = nav->ion_qzs[i]; - for (i = 0; i < 4; i++) svr->nav.utc_qzs[i] = nav->utc_qzs[i]; + for (i = 0; i < 8; i++) + { + svr->nav.ion_gps[i] = nav->ion_gps[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.utc_gps[i] = nav->utc_gps[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.ion_gal[i] = nav->ion_gal[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.utc_gal[i] = nav->utc_gal[i]; + } + for (i = 0; i < 8; i++) + { + svr->nav.ion_qzs[i] = nav->ion_qzs[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.utc_qzs[i] = nav->utc_qzs[i]; + } svr->nav.leaps = nav->leaps; } svr->nmsg[index][2]++; @@ -247,7 +283,10 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* ssr message */ for (i = 0; i < MAXSAT; i++) { - if (!svr->rtcm[index].ssr[i].update) continue; + if (!svr->rtcm[index].ssr[i].update) + { + continue; + } svr->rtcm[index].ssr[i].update = 0; iode = svr->rtcm[index].ssr[i].iode; @@ -291,7 +330,7 @@ int decoderaw(rtksvr_t *svr, int index) { obs_t *obs; nav_t *nav; - sbsmsg_t *sbsmsg = NULL; + sbsmsg_t *sbsmsg = nullptr; int i, ret = 0, sat, fobs = 0; tracet(4, "decoderaw: index=%d\n", index); @@ -332,15 +371,22 @@ int decoderaw(rtksvr_t *svr, int index) } #endif /* update rtk server */ - if (ret > 0) updatesvr(svr, ret, obs, nav, sat, sbsmsg, index, fobs); + if (ret > 0) + { + updatesvr(svr, ret, obs, nav, sat, sbsmsg, index, fobs); + } /* observation data received */ if (ret == 1) { if (fobs < MAXOBSBUF) - fobs++; + { + fobs++; + } else - svr->prcout++; + { + svr->prcout++; + } } } svr->nb[index] = 0; @@ -359,7 +405,9 @@ void decodefile(rtksvr_t *svr, int index) // Allocate space for GLONASS frequency channels depending on availability for (i = 0; i < MAXPRNGLO + 1; i++) - glo_fcn[i] = '0'; + { + glo_fcn[i] = '0'; + } pcv_t pcvt0[MAXSAT] = {{0, {'0'}, {'0'}, {0, 0.0}, {0, 0.0}, {{0.0}, {0.0}}, {{0.0}, {0.0}}}}; sbsfcorr_t sbsfcorr0 = {{0, 0.0}, 0.0, 0.0, 0.0, 0, 0, 0}; sbslcorr_t sbslcorr0 = {{0, 0.0}, 0, {0.0}, {0.0}, 0.0, 0.0}; @@ -373,9 +421,9 @@ void decodefile(rtksvr_t *svr, int index) trop_t trop0[MAXSTA] = {{{0, 0.0}, {0.0}, {0.0}}}; pppcorr_t pppcorr0 = {0, {{0}, {0}}, {{0.0}, {0.0}}, {0}, {0}, {0}, {0}, {stec0}, {trop0}}; - nav_t nav = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - {0, 0, (erpd_t *){0}}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, - {0.0}, {0.0}, {0.0}, {0.0}, 0, {{0.0}, {0.0}}, {{0.0}, {0.0}}, {{0.0}, {0.0}, {0.0}}, + nav_t nav = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + {0, 0, (erpd_t *){nullptr}}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, + {0.0}, {0.0}, {0.0}, {0.0}, 0, {{0.0}, {0.0}}, {{0.0}, {0.0}}, {{{0.0}}, {{0.0}}, {{0.0}}}, {0.0}, {0.0}, {*glo_fcn}, {*pcvt0}, sbssat0, {*sbsion0}, {*dgps0}, {*ssr0}, {*lexeph0}, {{0, 0.0}, 0.0, {0.0}, {{0.0}, {0.0}}}, pppcorr0}; @@ -393,7 +441,7 @@ void decodefile(rtksvr_t *svr, int index) rtksvrunlock(svr); return; } - strncpy(file, (char *)svr->buff[index], nb - 2); + strncpy(file, reinterpret_cast(svr->buff[index]), nb - 2); file[nb - 2] = '\0'; svr->nb[index] = 0; @@ -412,7 +460,10 @@ void decodefile(rtksvr_t *svr, int index) /* update precise ephemeris */ rtksvrlock(svr); - if (svr->nav.peph) free(svr->nav.peph); + if (svr->nav.peph) + { + free(svr->nav.peph); + } svr->nav.ne = svr->nav.nemax = nav.ne; svr->nav.peph = nav.peph; svr->ftime[index] = utc2gpst(timeget()); @@ -424,7 +475,7 @@ void decodefile(rtksvr_t *svr, int index) { /* precise clock */ /* read rinex clock */ // Disabled!! - if (1 /*readrnxc(file, &nav)<=0 */) + if (true /*readrnxc(file, &nav)<=0 */) { tracet(1, "rinex clock file read error: %s\n", file); return; @@ -432,7 +483,10 @@ void decodefile(rtksvr_t *svr, int index) /* update precise clock */ rtksvrlock(svr); - if (svr->nav.pclk) free(svr->nav.pclk); + if (svr->nav.pclk) + { + free(svr->nav.pclk); + } svr->nav.nc = svr->nav.ncmax = nav.nc; svr->nav.pclk = nav.pclk; svr->ftime[index] = utc2gpst(timeget()); @@ -446,7 +500,7 @@ void decodefile(rtksvr_t *svr, int index) /* rtk server thread ---------------------------------------------------------*/ void *rtksvrthread(void *arg) { - rtksvr_t *svr = (rtksvr_t *)arg; + auto *svr = static_cast(arg); obs_t obs; obsd_t data[MAXOBS * 2]; double tt; @@ -471,7 +525,7 @@ void *rtksvrthread(void *arg) q = svr->buff[i] + svr->buffsize; /* read receiver raw/rtcm data from input stream */ - if ((n = strread(svr->stream + i, p, q - p)) <= 0) + if ((n = strread(svr->stream + i, p, static_cast(q[0]) - static_cast(p[0]))) <= 0) { continue; } @@ -518,14 +572,14 @@ void *rtksvrthread(void *arg) if (svr->rtk.sol.stat != SOLQ_NONE) { /* adjust current time */ - tt = (int)(tickget() - tick) / 1000.0 + DTTOL; + tt = static_cast(tickget() - tick) / 1000.0 + DTTOL; timeset(gpst2utc(timeadd(svr->rtk.sol.time, tt))); /* write solution */ writesol(svr, i); } /* if cpu overload, inclement obs outage counter and break */ - if ((int)(tickget() - tick) >= svr->cycle) + if (static_cast(tickget() - tick) >= svr->cycle) { svr->prcout += fobs[0] - i - 1; #if 0 /* omitted v.2.4.1 */ @@ -539,7 +593,7 @@ void *rtksvrthread(void *arg) writesol(svr, 0); } /* send nmea request to base/nrtk input stream */ - if (svr->nmeacycle > 0 && (int)(tick - ticknmea) >= svr->nmeacycle) + if (svr->nmeacycle > 0 && static_cast(tick - ticknmea) >= svr->nmeacycle) { if (svr->stream[1].state == 1) { @@ -554,19 +608,25 @@ void *rtksvrthread(void *arg) } ticknmea = tick; } - if ((cputime = (int)(tickget() - tick)) > 0) svr->cputime = cputime; + if ((cputime = static_cast(tickget() - tick)) > 0) + { + svr->cputime = cputime; + } /* sleep until next cycle */ sleepms(svr->cycle - cputime); } - for (i = 0; i < MAXSTRRTK; i++) strclose(svr->stream + i); + for (i = 0; i < MAXSTRRTK; i++) + { + strclose(svr->stream + i); + } for (i = 0; i < 3; i++) { svr->nb[i] = svr->npb[i] = 0; free(svr->buff[i]); - svr->buff[i] = NULL; + svr->buff[i] = nullptr; free(svr->pbuf[i]); - svr->pbuf[i] = NULL; + svr->pbuf[i] = nullptr; //free_raw (svr->raw +i); free_rtcm(svr->rtcm + i); } @@ -574,9 +634,9 @@ void *rtksvrthread(void *arg) { svr->nsb[i] = 0; free(svr->sbuf[i]); - svr->sbuf[i] = NULL; + svr->sbuf[i] = nullptr; } - return 0; + return nullptr; } @@ -601,57 +661,112 @@ int rtksvrinit(rtksvr_t *svr) tracet(3, "rtksvrinit:\n"); svr->state = svr->cycle = svr->nmeacycle = svr->nmeareq = 0; - for (i = 0; i < 3; i++) svr->nmeapos[i] = 0.0; - svr->buffsize = 0; - for (i = 0; i < 3; i++) svr->format[i] = 0; - for (i = 0; i < 2; i++) svr->solopt[i] = solopt_default; - svr->navsel = svr->nsbs = svr->nsol = 0; - rtkinit(&svr->rtk, &prcopt_default); - for (i = 0; i < 3; i++) svr->nb[i] = 0; - for (i = 0; i < 2; i++) svr->nsb[i] = 0; - for (i = 0; i < 3; i++) svr->npb[i] = 0; - for (i = 0; i < 3; i++) svr->buff[i] = NULL; - for (i = 0; i < 2; i++) svr->sbuf[i] = NULL; - for (i = 0; i < 3; i++) svr->pbuf[i] = NULL; - for (i = 0; i < MAXSOLBUF; i++) svr->solbuf[i] = sol0; for (i = 0; i < 3; i++) - for (j = 0; j < 10; j++) svr->nmsg[i][j] = 0; - for (i = 0; i < 3; i++) svr->ftime[i] = time0; - for (i = 0; i < 3; i++) svr->files[i][0] = '\0'; - svr->moni = NULL; + { + svr->nmeapos[i] = 0.0; + } + svr->buffsize = 0; + for (i = 0; i < 3; i++) + { + svr->format[i] = 0; + } + for (i = 0; i < 2; i++) + { + svr->solopt[i] = SOLOPT_DEFAULT; + } + svr->navsel = svr->nsbs = svr->nsol = 0; + rtkinit(&svr->rtk, &PRCOPT_DEFAULT); + for (i = 0; i < 3; i++) + { + svr->nb[i] = 0; + } + for (i = 0; i < 2; i++) + { + svr->nsb[i] = 0; + } + for (i = 0; i < 3; i++) + { + svr->npb[i] = 0; + } + for (i = 0; i < 3; i++) + { + svr->buff[i] = nullptr; + } + for (i = 0; i < 2; i++) + { + svr->sbuf[i] = nullptr; + } + for (i = 0; i < 3; i++) + { + svr->pbuf[i] = nullptr; + } + for (i = 0; i < MAXSOLBUF; i++) + { + svr->solbuf[i] = sol0; + } + for (i = 0; i < 3; i++) + { + for (j = 0; j < 10; j++) + { + svr->nmsg[i][j] = 0; + } + } + for (i = 0; i < 3; i++) + { + svr->ftime[i] = time0; + } + for (i = 0; i < 3; i++) + { + svr->files[i][0] = '\0'; + } + svr->moni = nullptr; svr->tick = 0; - svr->thread = 0; + svr->thread = 0; // NOLINT svr->cputime = svr->prcout = 0; - if (!(svr->nav.eph = (eph_t *)malloc(sizeof(eph_t) * MAXSAT * 2)) || - !(svr->nav.geph = (geph_t *)malloc(sizeof(geph_t) * NSATGLO * 2)) || - !(svr->nav.seph = (seph_t *)malloc(sizeof(seph_t) * NSATSBS * 2))) + if (!(svr->nav.eph = static_cast(malloc(sizeof(eph_t) * MAXSAT * 2))) || + !(svr->nav.geph = static_cast(malloc(sizeof(geph_t) * NSATGLO * 2))) || + !(svr->nav.seph = static_cast(malloc(sizeof(seph_t) * NSATSBS * 2)))) { tracet(1, "rtksvrinit: malloc error\n"); return 0; } - for (i = 0; i < MAXSAT * 2; i++) svr->nav.eph[i] = eph0; - for (i = 0; i < NSATGLO * 2; i++) svr->nav.geph[i] = geph0; - for (i = 0; i < NSATSBS * 2; i++) svr->nav.seph[i] = seph0; + for (i = 0; i < MAXSAT * 2; i++) + { + svr->nav.eph[i] = eph0; + } + for (i = 0; i < NSATGLO * 2; i++) + { + svr->nav.geph[i] = geph0; + } + for (i = 0; i < NSATSBS * 2; i++) + { + svr->nav.seph[i] = seph0; + } svr->nav.n = MAXSAT * 2; svr->nav.ng = NSATGLO * 2; svr->nav.ns = NSATSBS * 2; for (i = 0; i < 3; i++) - for (j = 0; j < MAXOBSBUF; j++) - { - if (!(svr->obs[i][j].data = (obsd_t *)malloc(sizeof(obsd_t) * MAXOBS))) - { - tracet(1, "rtksvrinit: malloc error\n"); - return 0; - } - } + { + for (j = 0; j < MAXOBSBUF; j++) + { + if (!(svr->obs[i][j].data = static_cast(malloc(sizeof(obsd_t) * MAXOBS)))) + { + tracet(1, "rtksvrinit: malloc error\n"); + return 0; + } + } + } for (i = 0; i < 3; i++) { memset(svr->raw + i, 0, sizeof(raw_t)); memset(svr->rtcm + i, 0, sizeof(rtcm_t)); } - for (i = 0; i < MAXSTRRTK; i++) strinit(svr->stream + i); + for (i = 0; i < MAXSTRRTK; i++) + { + strinit(svr->stream + i); + } initlock(&svr->lock); @@ -672,10 +787,12 @@ void rtksvrfree(rtksvr_t *svr) free(svr->nav.geph); free(svr->nav.seph); for (i = 0; i < 3; i++) - for (j = 0; j < MAXOBSBUF; j++) - { - free(svr->obs[i][j].data); - } + { + for (j = 0; j < MAXOBSBUF; j++) + { + free(svr->obs[i][j].data); + } + } } @@ -730,7 +847,7 @@ void rtksvrunlock(rtksvr_t *svr) { rtk_unlock(&svr->lock); } * return : status (1:ok 0:error) *-----------------------------------------------------------------------------*/ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, - char **paths, int *formats, int navsel, char **cmds, + char **paths, const int *formats, int navsel, char **cmds, char **rcvopts, int nmeacycle, int nmeareq, const double *nmeapos, prcopt_t *prcopt, solopt_t *solopt, stream_t *moni) @@ -741,15 +858,24 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, tracet(3, "rtksvrstart: cycle=%d buffsize=%d navsel=%d nmeacycle=%d nmeareq=%d\n", cycle, buffsize, navsel, nmeacycle, nmeareq); - if (svr->state) return 0; + if (svr->state) + { + return 0; + } strinitcom(); svr->cycle = cycle > 1 ? cycle : 1; svr->nmeacycle = nmeacycle > 1000 ? nmeacycle : 1000; svr->nmeareq = nmeareq; - for (i = 0; i < 3; i++) svr->nmeapos[i] = nmeapos[i]; + for (i = 0; i < 3; i++) + { + svr->nmeapos[i] = nmeapos[i]; + } svr->buffsize = buffsize > 4096 ? buffsize : 4096; - for (i = 0; i < 3; i++) svr->format[i] = formats[i]; + for (i = 0; i < 3; i++) + { + svr->format[i] = formats[i]; + } svr->navsel = navsel; svr->nsbs = 0; svr->nsol = 0; @@ -760,29 +886,41 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, for (i = 0; i < 3; i++) { /* input/log streams */ svr->nb[i] = svr->npb[i] = 0; - if (!(svr->buff[i] = (unsigned char *)malloc(buffsize)) || - !(svr->pbuf[i] = (unsigned char *)malloc(buffsize))) + if (!(svr->buff[i] = static_cast(malloc(buffsize))) || + !(svr->pbuf[i] = static_cast(malloc(buffsize)))) { tracet(1, "rtksvrstart: malloc error\n"); return 0; } - for (j = 0; j < 10; j++) svr->nmsg[i][j] = 0; - for (j = 0; j < MAXOBSBUF; j++) svr->obs[i][j].n = 0; + for (j = 0; j < 10; j++) + { + svr->nmsg[i][j] = 0; + } + for (j = 0; j < MAXOBSBUF; j++) + { + svr->obs[i][j].n = 0; + } /* initialize receiver raw and rtcm control */ //init_raw (svr->raw +i); init_rtcm(svr->rtcm + i); /* set receiver and rtcm option */ - if (strlen(rcvopts[i]) < 256) strcpy(svr->raw[i].opt, rcvopts[i]); - if (strlen(rcvopts[i]) < 256) strcpy(svr->rtcm[i].opt, rcvopts[i]); + if (strlen(rcvopts[i]) < 256) + { + strcpy(svr->raw[i].opt, rcvopts[i]); + } + if (strlen(rcvopts[i]) < 256) + { + strcpy(svr->rtcm[i].opt, rcvopts[i]); + } /* connect dgps corrections */ svr->rtcm[i].dgps = svr->nav.dgps; } for (i = 0; i < 2; i++) { /* output peek buffer */ - if (!(svr->sbuf[i] = (unsigned char *)malloc(buffsize))) + if (!(svr->sbuf[i] = static_cast(malloc(buffsize)))) { tracet(1, "rtksvrstart: malloc error\n"); return 0; @@ -799,9 +937,18 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, svr->rtk.rb[i] = i < 3 ? prcopt->rb[i] : 0.0; } /* update navigation data */ - for (i = 0; i < MAXSAT * 2; i++) svr->nav.eph[i].ttr = time0; - for (i = 0; i < NSATGLO * 2; i++) svr->nav.geph[i].tof = time0; - for (i = 0; i < NSATSBS * 2; i++) svr->nav.seph[i].tof = time0; + for (i = 0; i < MAXSAT * 2; i++) + { + svr->nav.eph[i].ttr = time0; + } + for (i = 0; i < NSATGLO * 2; i++) + { + svr->nav.geph[i].tof = time0; + } + for (i = 0; i < NSATSBS * 2; i++) + { + svr->nav.seph[i].tof = time0; + } updatenav(&svr->nav); /* set monitor stream */ @@ -811,10 +958,16 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, for (i = 0; i < 8; i++) { rw = i < 3 ? STR_MODE_R : STR_MODE_W; - if (strs[i] != STR_FILE) rw |= STR_MODE_W; + if (strs[i] != STR_FILE) + { + rw |= STR_MODE_W; + } if (!stropen(svr->stream + i, strs[i], rw, paths[i])) { - for (i--; i >= 0; i--) strclose(svr->stream + i); + for (i--; i >= 0; i--) + { + strclose(svr->stream + i); + } return 0; } /* set initial time for rtcm and raw */ @@ -832,7 +985,10 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, /* write start commands to input streams */ for (i = 0; i < 3; i++) { - if (cmds[i]) strsendcmd(svr->stream + i, cmds[i]); + if (cmds[i]) + { + strsendcmd(svr->stream + i, cmds[i]); + } } /* write solution header to solution streams */ for (i = 3; i < 5; i++) @@ -840,9 +996,12 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, writesolhead(svr->stream + i, svr->solopt + i - 3); } /* create rtk server thread */ - if (pthread_create(&svr->thread, NULL, rtksvrthread, svr)) + if (pthread_create(&svr->thread, nullptr, rtksvrthread, svr)) { - for (i = 0; i < MAXSTRRTK; i++) strclose(svr->stream + i); + for (i = 0; i < MAXSTRRTK; i++) + { + strclose(svr->stream + i); + } return 0; } return 1; @@ -868,7 +1027,10 @@ void rtksvrstop(rtksvr_t *svr, char **cmds) rtksvrlock(svr); for (i = 0; i < 3; i++) { - if (cmds[i]) strsendcmd(svr->stream + i, cmds[i]); + if (cmds[i]) + { + strsendcmd(svr->stream + i, cmds[i]); + } } rtksvrunlock(svr); @@ -876,7 +1038,7 @@ void rtksvrstop(rtksvr_t *svr, char **cmds) svr->state = 0; /* free rtk server thread */ - pthread_join(svr->thread, NULL); + pthread_join(svr->thread, nullptr); } @@ -896,7 +1058,10 @@ int rtksvropenstr(rtksvr_t *svr, int index, int str, const char *path, { tracet(3, "rtksvropenstr: index=%d str=%d path=%s\n", index, str, path); - if (index < 3 || index > 7 || !svr->state) return 0; + if (index < 3 || index > 7 || !svr->state) + { + return 0; + } rtksvrlock(svr); @@ -935,7 +1100,10 @@ void rtksvrclosestr(rtksvr_t *svr, int index) { tracet(3, "rtksvrclosestr: index=%d\n", index); - if (index < 3 || index > 7 || !svr->state) return; + if (index < 3 || index > 7 || !svr->state) + { + return; + } rtksvrlock(svr); @@ -965,7 +1133,10 @@ int rtksvrostat(rtksvr_t *svr, int rcv, gtime_t *time, int *sat, tracet(4, "rtksvrostat: rcv=%d\n", rcv); - if (!svr->state) return 0; + if (!svr->state) + { + return 0; + } rtksvrlock(svr); ns = svr->obs[rcv][0].n; if (ns > 0) @@ -979,7 +1150,7 @@ int rtksvrostat(rtksvr_t *svr, int rcv, gtime_t *time, int *sat, el[i] = svr->rtk.ssat[sat[i] - 1].azel[1]; for (j = 0; j < NFREQ; j++) { - snr[i][j] = (int)(svr->obs[rcv][0].data[i].SNR[j] * 0.25); + snr[i][j] = static_cast(svr->obs[rcv][0].data[i].SNR[j] * 0.25); } if (svr->rtk.sol.stat == SOLQ_NONE || svr->rtk.sol.stat == SOLQ_SINGLE) { @@ -1013,7 +1184,10 @@ void rtksvrsstat(rtksvr_t *svr, int *sstat, char *msg) for (i = 0; i < MAXSTRRTK; i++) { sstat[i] = strstat(svr->stream + i, s); - if (*s) p += sprintf(p, "(%d) %s ", i + 1, s); + if (*s) + { + p += sprintf(p, "(%d) %s ", i + 1, s); + } } rtksvrunlock(svr); } diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.h b/src/algorithms/libs/rtklib/rtklib_rtksvr.h index 0e6eb65e7..9d84b13c9 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.h +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.h @@ -57,7 +57,7 @@ #include "rtklib.h" -const solopt_t solopt_default = { +const solopt_t SOLOPT_DEFAULT = { /* defaults solution output options */ SOLF_LLH, TIMES_GPST, 1, 3, /* posf, times, timef, timeu */ 0, 1, 0, 0, 0, 0, /* degf, outhead, outopt, datum, height, geoid */ @@ -66,7 +66,7 @@ const solopt_t solopt_default = { " ", "", 0 /* separator/program name */ }; -const prcopt_t prcopt_default = { /* defaults processing options */ +const prcopt_t PRCOPT_DEFAULT = { /* defaults processing options */ PMODE_SINGLE, 0, 2, SYS_GPS, /* mode, soltype, nf, navsys */ 15.0 * D2R, {{}, {{}, {}}}, /* elmin, snrmask */ 0, 1, 1, 1, /* sateph, modear, glomodear, bdsmodear */ @@ -116,7 +116,7 @@ void rtksvrlock(rtksvr_t *svr); void rtksvrunlock(rtksvr_t *svr); int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, - char **paths, int *formats, int navsel, char **cmds, + char **paths, const int *formats, int navsel, char **cmds, char **rcvopts, int nmeacycle, int nmeareq, const double *nmeapos, prcopt_t *prcopt, solopt_t *solopt, stream_t *moni); diff --git a/src/algorithms/libs/rtklib/rtklib_sbas.cc b/src/algorithms/libs/rtklib/rtklib_sbas.cc index 3bd809d10..943b271f0 100644 --- a/src/algorithms/libs/rtklib/rtklib_sbas.cc +++ b/src/algorithms/libs/rtklib/rtklib_sbas.cc @@ -61,12 +61,18 @@ #include "rtklib_sbas.h" #include "rtklib_rtkcmn.h" +#include /* extract field from line ---------------------------------------------------*/ char *getfield(char *p, int pos) { for (pos--; pos > 0; pos--, p++) - if (!(p = strchr(p, ','))) return NULL; + { + if (!(p = strchr(p, ','))) + { + return nullptr; + } + } return p; } @@ -113,21 +119,37 @@ int decode_sbstype1(const sbsmsg_t *msg, sbssat_t *sbssat) if (getbitu(msg->msg, 13 + i, 1)) { if (i <= 37) - sat = satno(SYS_GPS, i); /* 0- 37: gps */ + { + sat = satno(SYS_GPS, i); /* 0- 37: gps */ + } else if (i <= 61) - sat = satno(SYS_GLO, i - 37); /* 38- 61: glonass */ + { + sat = satno(SYS_GLO, i - 37); /* 38- 61: glonass */ + } else if (i <= 119) - sat = 0; /* 62-119: future gnss */ + { + sat = 0; /* 62-119: future gnss */ + } else if (i <= 138) - sat = satno(SYS_SBS, i); /* 120-138: geo/waas */ + { + sat = satno(SYS_SBS, i); /* 120-138: geo/waas */ + } else if (i <= 182) - sat = 0; /* 139-182: reserved */ + { + sat = 0; /* 139-182: reserved */ + } else if (i <= 192) - sat = satno(SYS_SBS, i + 10); /* 183-192: qzss ref [2] */ + { + sat = satno(SYS_SBS, i + 10); /* 183-192: qzss ref [2] */ + } else if (i <= 202) - sat = satno(SYS_QZS, i); /* 193-202: qzss ref [2] */ + { + sat = satno(SYS_QZS, i); /* 193-202: qzss ref [2] */ + } else - sat = 0; /* 203- : reserved */ + { + sat = 0; /* 203- : reserved */ + } sbssat->sat[n++].sat = sat; } } @@ -148,14 +170,20 @@ int decode_sbstype2(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype2:\n"); - if (sbssat->iodp != (int)getbitu(msg->msg, 16, 2)) return 0; + if (sbssat->iodp != static_cast(getbitu(msg->msg, 16, 2))) + { + return 0; + } type = getbitu(msg->msg, 8, 6); iodf = getbitu(msg->msg, 14, 2); for (i = 0; i < 13; i++) { - if ((j = 13 * ((type == 0 ? 2 : type) - 2) + i) >= sbssat->nsat) break; + if ((j = 13 * ((type == 0 ? 2 : type) - 2) + i) >= sbssat->nsat) + { + break; + } udre = getbitu(msg->msg, 174 + 4 * i, 4); t0 = sbssat->sat[j].fcorr.t0; prc = sbssat->sat[j].fcorr.prc; @@ -193,7 +221,10 @@ int decode_sbstype6(const sbsmsg_t *msg, sbssat_t *sbssat) } for (i = 0; i < sbssat->nsat && i < MAXSAT; i++) { - if (sbssat->sat[i].fcorr.iodf != iodf[i / 28]) continue; + if (sbssat->sat[i].fcorr.iodf != iodf[i / 28]) + { + continue; + } udre = getbitu(msg->msg, 22 + i * 4, 4); sbssat->sat[i].fcorr.udre = udre + 1; } @@ -209,7 +240,10 @@ int decode_sbstype7(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype7\n"); - if (sbssat->iodp != (int)getbitu(msg->msg, 18, 2)) return 0; + if (sbssat->iodp != static_cast(getbitu(msg->msg, 18, 2))) + { + return 0; + } sbssat->tlat = getbitu(msg->msg, 14, 4); @@ -234,11 +268,15 @@ int decode_sbstype9(const sbsmsg_t *msg, nav_t *nav) trace(2, "invalid prn in sbas type 9: prn=%3d\n", msg->prn); return 0; } - t = (int)getbitu(msg->msg, 22, 13) * 16 - (int)msg->tow % 86400; + t = static_cast(getbitu(msg->msg, 22, 13)) * 16 - msg->tow % 86400; if (t <= -43200) - t += 86400; + { + t += 86400; + } else if (t > 43200) - t -= 86400; + { + t -= 86400; + } seph.sat = sat; seph.t0 = gpst2time(msg->week, msg->tow + t); seph.tof = gpst2time(msg->week, msg->tow); @@ -281,25 +319,33 @@ int decode_sbstype18(const sbsmsg_t *msg, sbsion_t *sbsion) if (0 <= band && band <= 8) { - p = igpband1[band]; + p = IGPBAND1[band]; m = 8; } else if (9 <= band && band <= 10) { - p = igpband2[band - 9]; + p = IGPBAND2[band - 9]; m = 5; } else - return 0; + { + return 0; + } - sbsion[band].iodi = (short)getbitu(msg->msg, 22, 2); + sbsion[band].iodi = static_cast(getbitu(msg->msg, 22, 2)); for (i = 1, n = 0; i <= 201; i++) { - if (!getbitu(msg->msg, 23 + i, 1)) continue; + if (!getbitu(msg->msg, 23 + i, 1)) + { + continue; + } for (j = 0; j < m; j++) { - if (i < p[j].bits || p[j].bite < i) continue; + if (i < p[j].bits || p[j].bite < i) + { + continue; + } sbsion[band].igp[n].lat = band <= 8 ? p[j].y[i - p[j].bits] : p[j].x; sbsion[band].igp[n++].lon = band <= 8 ? p[j].x : p[j].y[i - p[j].bits]; break; @@ -319,7 +365,10 @@ int decode_longcorr0(const sbsmsg_t *msg, int p, sbssat_t *sbssat) trace(4, "decode_longcorr0:\n"); - if (n == 0 || n > MAXSAT) return 0; + if (n == 0 || n > MAXSAT) + { + return 0; + } sbssat->sat[n - 1].lcorr.iode = getbitu(msg->msg, p + 6, 8); @@ -344,7 +393,10 @@ int decode_longcorr1(const sbsmsg_t *msg, int p, sbssat_t *sbssat) trace(4, "decode_longcorr1:\n"); - if (n == 0 || n > MAXSAT) return 0; + if (n == 0 || n > MAXSAT) + { + return 0; + } sbssat->sat[n - 1].lcorr.iode = getbitu(msg->msg, p + 6, 8); @@ -355,11 +407,15 @@ int decode_longcorr1(const sbsmsg_t *msg, int p, sbssat_t *sbssat) } sbssat->sat[n - 1].lcorr.daf0 = getbits(msg->msg, p + 47, 11) * TWO_N31; sbssat->sat[n - 1].lcorr.daf1 = getbits(msg->msg, p + 82, 8) * TWO_N39; - t = (int)getbitu(msg->msg, p + 90, 13) * 16 - (int)msg->tow % 86400; + t = static_cast(getbitu(msg->msg, p + 90, 13)) * 16 - msg->tow % 86400; if (t <= -43200) - t += 86400; + { + t += 86400; + } else if (t > 43200) - t -= 86400; + { + t -= 86400; + } sbssat->sat[n - 1].lcorr.t0 = gpst2time(msg->week, msg->tow + t); trace(5, "decode_longcorr1: sat=%2d\n", sbssat->sat[n - 1].sat); @@ -374,13 +430,13 @@ int decode_longcorrh(const sbsmsg_t *msg, int p, sbssat_t *sbssat) if (getbitu(msg->msg, p, 1) == 0) { /* vel code=0 */ - if (sbssat->iodp == (int)getbitu(msg->msg, p + 103, 2)) + if (sbssat->iodp == static_cast(getbitu(msg->msg, p + 103, 2))) { return decode_longcorr0(msg, p + 1, sbssat) && decode_longcorr0(msg, p + 52, sbssat); } } - else if (sbssat->iodp == (int)getbitu(msg->msg, p + 104, 2)) + else if (sbssat->iodp == static_cast(getbitu(msg->msg, p + 104, 2))) { return decode_longcorr1(msg, p + 1, sbssat); } @@ -395,14 +451,20 @@ int decode_sbstype24(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype24:\n"); - if (sbssat->iodp != (int)getbitu(msg->msg, 110, 2)) return 0; /* check IODP */ + if (sbssat->iodp != static_cast(getbitu(msg->msg, 110, 2))) + { + return 0; /* check IODP */ + } blk = getbitu(msg->msg, 112, 2); iodf = getbitu(msg->msg, 114, 2); for (i = 0; i < 6; i++) { - if ((j = 13 * blk + i) >= sbssat->nsat) break; + if ((j = 13 * blk + i) >= sbssat->nsat) + { + break; + } udre = getbitu(msg->msg, 86 + 4 * i, 4); sbssat->sat[j].fcorr.t0 = gpst2time(msg->week, msg->tow); @@ -430,13 +492,19 @@ int decode_sbstype26(const sbsmsg_t *msg, sbsion_t *sbsion) trace(4, "decode_sbstype26:\n"); - if (band > MAXBAND || sbsion[band].iodi != (int)getbitu(msg->msg, 217, 2)) return 0; + if (band > MAXBAND || sbsion[band].iodi != static_cast(getbitu(msg->msg, 217, 2))) + { + return 0; + } block = getbitu(msg->msg, 18, 4); for (i = 0; i < 15; i++) { - if ((j = block * 15 + i) >= sbsion[band].nigp) continue; + if ((j = block * 15 + i) >= sbsion[band].nigp) + { + continue; + } give = getbitu(msg->msg, 22 + i * 13 + 9, 4); delay = getbitu(msg->msg, 22 + i * 13, 9); @@ -469,7 +537,10 @@ int sbsupdatecorr(const sbsmsg_t *msg, nav_t *nav) trace(3, "sbsupdatecorr: type=%d\n", type); - if (msg->week == 0) return -1; + if (msg->week == 0) + { + return -1; + } switch (type) { @@ -529,7 +600,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, trace(3, "readmsgs: file=%s sel=%d\n", file, sel); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "sbas message file open error: %s\n", file); return; @@ -550,36 +621,71 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, } else if (!strncmp(buff, "#RAWWAASFRAMEA", 14)) { /* NovAtel OEM4/V */ - if (!(p = getfield(buff, 6))) continue; - if (sscanf(p, "%d,%lf", &week, &tow) < 2) continue; - if (!(p = strchr(++p, ';'))) continue; - if (sscanf(++p, "%d,%d", &ch, &prn) < 2) continue; - if (!(p = getfield(p, 4))) continue; + if (!(p = getfield(buff, 6))) + { + continue; + } + if (sscanf(p, "%d,%lf", &week, &tow) < 2) + { + continue; + } + if (!(p = strchr(++p, ';'))) + { + continue; + } + if (sscanf(++p, "%d,%d", &ch, &prn) < 2) + { + continue; + } + if (!(p = getfield(p, 4))) + { + continue; + } } else if (!strncmp(buff, "$FRMA", 5)) { /* NovAtel OEM3 */ - if (!(p = getfield(buff, 2))) continue; - if (sscanf(p, "%d,%lf,%d", &week, &tow, &prn) < 3) continue; - if (!(p = getfield(p, 6))) continue; - if (week < WEEKOFFSET) week += WEEKOFFSET; + if (!(p = getfield(buff, 2))) + { + continue; + } + if (sscanf(p, "%d,%lf,%d", &week, &tow, &prn) < 3) + { + continue; + } + if (!(p = getfield(p, 6))) + { + continue; + } + if (week < WEEKOFFSET) + { + week += WEEKOFFSET; + } } else - continue; + { + continue; + } - if (sel != 0 && sel != prn) continue; + if (sel != 0 && sel != prn) + { + continue; + } time = gpst2time(week, tow); - if (!screent(time, ts, te, 0.0)) continue; + if (!screent(time, ts, te, 0.0)) + { + continue; + } if (sbs->n >= sbs->nmax) { sbs->nmax = sbs->nmax == 0 ? 1024 : sbs->nmax * 2; - if (!(sbs_msgs = (sbsmsg_t *)realloc(sbs->msgs, sbs->nmax * sizeof(sbsmsg_t)))) + if (!(sbs_msgs = static_cast(realloc(sbs->msgs, sbs->nmax * sizeof(sbsmsg_t))))) { trace(1, "readsbsmsg malloc error: nmax=%d\n", sbs->nmax); free(sbs->msgs); - sbs->msgs = NULL; + sbs->msgs = nullptr; sbs->n = sbs->nmax = 0; fclose(fp); return; @@ -587,12 +693,18 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, sbs->msgs = sbs_msgs; } sbs->msgs[sbs->n].week = week; - sbs->msgs[sbs->n].tow = (int)(tow + 0.5); + sbs->msgs[sbs->n].tow = static_cast(tow + 0.5); sbs->msgs[sbs->n].prn = prn; - for (i = 0; i < 29; i++) sbs->msgs[sbs->n].msg[i] = 0; + for (i = 0; i < 29; i++) + { + sbs->msgs[sbs->n].msg[i] = 0; + } for (i = 0; *(p - 1) && *p && i < 29; p += 2, i++) { - if (sscanf(p, "%2X", &b) == 1) sbs->msgs[sbs->n].msg[i] = (unsigned char)b; + if (sscanf(p, "%2X", &b) == 1) + { + sbs->msgs[sbs->n].msg[i] = static_cast(b); + } } sbs->msgs[sbs->n++].msg[28] &= 0xC0; } @@ -603,7 +715,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, /* compare sbas messages -----------------------------------------------------*/ int cmpmsgs(const void *p1, const void *p2) { - sbsmsg_t *q1 = (sbsmsg_t *)p1, *q2 = (sbsmsg_t *)p2; + auto *q1 = (sbsmsg_t *)p1, *q2 = (sbsmsg_t *)p2; return q1->week != q2->week ? q1->week - q2->week : (q1->tow < q2->tow ? -1 : (q1->tow > q2->tow ? 1 : q1->prn - q2->prn)); } @@ -633,9 +745,12 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te, for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return 0; } } @@ -644,13 +759,22 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te, for (i = 0; i < n; i++) { - if (!(ext = strrchr(efiles[i], '.'))) continue; - if (strcmp(ext, ".sbs") && strcmp(ext, ".SBS") && - strcmp(ext, ".ems") && strcmp(ext, ".EMS")) continue; + if (!(ext = strrchr(efiles[i], '.'))) + { + continue; + } + if (strcmp(ext, ".sbs") != 0 && strcmp(ext, ".SBS") != 0 && + strcmp(ext, ".ems") != 0 && strcmp(ext, ".EMS") != 0) + { + continue; + } readmsgs(efiles[i], sel, ts, te, sbs); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } /* sort messages */ if (sbs->n > 0) @@ -684,7 +808,10 @@ void sbsoutmsg(FILE *fp, sbsmsg_t *sbsmsg) trace(4, "sbsoutmsg:\n"); fprintf(fp, "%4d %6d %3d %2d : ", sbsmsg->week, sbsmsg->tow, sbsmsg->prn, type); - for (i = 0; i < 29; i++) fprintf(fp, "%02X", sbsmsg->msg[i]); + for (i = 0; i < 29; i++) + { + fprintf(fp, "%02X", sbsmsg->msg[i]); + } fprintf(fp, "\n"); } @@ -699,59 +826,87 @@ void searchigp(gtime_t time __attribute__((unused)), const double *pos, const sb trace(4, "searchigp: pos=%.3f %.3f\n", pos[0] * R2D, pos[1] * R2D); - if (lon >= 180.0) lon -= 360.0; + if (lon >= 180.0) + { + lon -= 360.0; + } if (-55.0 <= lat && lat < 55.0) { - latp[0] = (int)floor(lat / 5.0) * 5; + latp[0] = static_cast(floor(lat / 5.0)) * 5; latp[1] = latp[0] + 5; - lonp[0] = lonp[1] = (int)floor(lon / 5.0) * 5; + lonp[0] = lonp[1] = static_cast(floor(lon / 5.0)) * 5; lonp[2] = lonp[3] = lonp[0] + 5; *x = (lon - lonp[0]) / 5.0; *y = (lat - latp[0]) / 5.0; } else { - latp[0] = (int)floor((lat - 5.0) / 10.0) * 10 + 5; + latp[0] = static_cast(floor((lat - 5.0) / 10.0)) * 10 + 5; latp[1] = latp[0] + 10; - lonp[0] = lonp[1] = (int)floor(lon / 10.0) * 10; + lonp[0] = lonp[1] = static_cast(floor(lon / 10.0)) * 10; lonp[2] = lonp[3] = lonp[0] + 10; *x = (lon - lonp[0]) / 10.0; *y = (lat - latp[0]) / 10.0; if (75.0 <= lat && lat < 85.0) { - lonp[1] = (int)floor(lon / 90.0) * 90; + lonp[1] = static_cast(floor(lon / 90.0)) * 90; lonp[3] = lonp[1] + 90; } else if (-85.0 <= lat && lat < -75.0) { - lonp[0] = (int)floor((lon - 50.0) / 90.0) * 90 + 40; + lonp[0] = static_cast(floor((lon - 50.0) / 90.0)) * 90 + 40; lonp[2] = lonp[0] + 90; } else if (lat >= 85.0) { - for (i = 0; i < 4; i++) lonp[i] = (int)floor(lon / 90.0) * 90; + for (i = 0; i < 4; i++) + { + lonp[i] = static_cast(floor(lon / 90.0)) * 90; + } } else if (lat < -85.0) { - for (i = 0; i < 4; i++) lonp[i] = (int)floor((lon - 50.0) / 90.0) * 90 + 40; + for (i = 0; i < 4; i++) + { + lonp[i] = static_cast(floor((lon - 50.0) / 90.0)) * 90 + 40; + } } } for (i = 0; i < 4; i++) - if (lonp[i] == 180) lonp[i] = -180; + { + if (lonp[i] == 180) + { + lonp[i] = -180; + } + } for (i = 0; i <= MAXBAND; i++) { for (p = ion[i].igp; p < ion[i].igp + ion[i].nigp; p++) { - if (p->t0.time == 0) continue; + if (p->t0.time == 0) + { + continue; + } if (p->lat == latp[0] && p->lon == lonp[0] && p->give > 0) - igp[0] = p; + { + igp[0] = p; + } else if (p->lat == latp[1] && p->lon == lonp[1] && p->give > 0) - igp[1] = p; + { + igp[1] = p; + } else if (p->lat == latp[0] && p->lon == lonp[2] && p->give > 0) - igp[2] = p; + { + igp[2] = p; + } else if (p->lat == latp[1] && p->lon == lonp[3] && p->give > 0) - igp[3] = p; - if (igp[0] && igp[1] && igp[2] && igp[3]) return; + { + igp[3] = p; + } + if (igp[0] && igp[1] && igp[2] && igp[3]) + { + return; + } } } } @@ -782,7 +937,10 @@ int sbsioncorr(gtime_t time, const nav_t *nav, const double *pos, azel[0] * R2D, azel[1] * R2D); *delay = *var = 0.0; - if (pos[2] < -100.0 || azel[1] <= 0) return 1; + if (pos[2] < -100.0 || azel[1] <= 0) + { + return 1; + } /* ipp (ionospheric pierce point) position */ fp = ionppp(pos, azel, re, hion, posp); @@ -802,28 +960,42 @@ int sbsioncorr(gtime_t time, const nav_t *nav, const double *pos, { w[1] = y; w[2] = x; - if ((w[0] = 1.0 - w[1] - w[2]) < 0.0) err = 1; + if ((w[0] = 1.0 - w[1] - w[2]) < 0.0) + { + err = 1; + } } else if (igp[0] && igp[2] && igp[3]) { w[0] = 1.0 - x; w[3] = y; - if ((w[2] = 1.0 - w[0] - w[3]) < 0.0) err = 1; + if ((w[2] = 1.0 - w[0] - w[3]) < 0.0) + { + err = 1; + } } else if (igp[0] && igp[1] && igp[3]) { w[0] = 1.0 - y; w[3] = x; - if ((w[1] = 1.0 - w[0] - w[3]) < 0.0) err = 1; + if ((w[1] = 1.0 - w[0] - w[3]) < 0.0) + { + err = 1; + } } else if (igp[1] && igp[2] && igp[3]) { w[1] = 1.0 - x; w[2] = 1.0 - y; - if ((w[3] = 1.0 - w[1] - w[2]) < 0.0) err = 1; + if ((w[3] = 1.0 - w[1] - w[2]) < 0.0) + { + err = 1; + } } else - err = 1; + { + err = 1; + } if (err) { @@ -833,7 +1005,10 @@ int sbsioncorr(gtime_t time, const nav_t *nav, const double *pos, } for (i = 0; i < 4; i++) { - if (!igp[i]) continue; + if (!igp[i]) + { + continue; + } t = timediff(time, igp[i]->t0); *delay += w[i] * igp[i]->delay; *var += w[i] * varicorr(igp[i]->give) * 9e-8 * fabs(t); @@ -859,14 +1034,27 @@ void getmet(double lat, double *met) double a; lat = fabs(lat); if (lat <= 15.0) - for (i = 0; i < 10; i++) met[i] = metprm[0][i]; + { + for (i = 0; i < 10; i++) + { + met[i] = metprm[0][i]; + } + } else if (lat >= 75.0) - for (i = 0; i < 10; i++) met[i] = metprm[4][i]; + { + for (i = 0; i < 10; i++) + { + met[i] = metprm[4][i]; + } + } else { - j = (int)(lat / 15.0); + j = static_cast(lat / 15.0); a = (lat - j * 15.0) / 15.0; - for (i = 0; i < 10; i++) met[i] = (1.0 - a) * metprm[j - 1][i] + a * metprm[j][i]; + for (i = 0; i < 10; i++) + { + met[i] = (1.0 - a) * metprm[j - 1][i] + a * metprm[j][i]; + } } } @@ -900,12 +1088,18 @@ double sbstropcorr(gtime_t time, const double *pos, const double *azel, { getmet(pos[0] * R2D, met); c = cos(2.0 * PI * (time2doy(time) - (pos[0] >= 0.0 ? 28.0 : 211.0)) / 365.25); - for (i = 0; i < 5; i++) met[i] -= met[i + 5] * c; + for (i = 0; i < 5; i++) + { + met[i] -= met[i + 5] * c; + } zh = 1e-6 * k1 * rd * met[0] / gm; zw = 1e-6 * k2 * rd / (gm * (met[4] + 1.0) - met[3] * rd) * met[2] / met[1]; zh *= pow(1.0 - met[3] * h / met[1], g / (rd * met[3])); zw *= pow(1.0 - met[3] * h / met[1], (met[4] + 1.0) * g / (rd * met[3]) - 1.0); - for (i = 0; i < 3; i++) pos_[i] = pos[i]; + for (i = 0; i < 3; i++) + { + pos_[i] = pos[i]; + } } m = 1.001 / sqrt(0.002001 + sinel * sinel); *var = 0.12 * 0.12 * m * m; @@ -925,7 +1119,10 @@ int sbslongcorr(gtime_t time, int sat, const sbssat_t *sbssat, for (p = sbssat->sat; p < sbssat->sat + sbssat->nsat; p++) { - if (p->sat != sat || p->lcorr.t0.time == 0) continue; + if (p->sat != sat || p->lcorr.t0.time == 0) + { + continue; + } t = timediff(time, p->lcorr.t0); if (fabs(t) > MAXSBSAGEL) { @@ -933,7 +1130,10 @@ int sbslongcorr(gtime_t time, int sat, const sbssat_t *sbssat, time_str(time, 0), sat, t); return 0; } - for (i = 0; i < 3; i++) drs[i] = p->lcorr.dpos[i] + p->lcorr.dvel[i] * t; + for (i = 0; i < 3; i++) + { + drs[i] = p->lcorr.dpos[i] + p->lcorr.dvel[i] * t; + } *ddts = p->lcorr.daf0 + p->lcorr.daf1 * t; trace(5, "sbslongcorr: sat=%2d drs=%7.2f%7.2f%7.2f ddts=%7.2f\n", @@ -942,7 +1142,10 @@ int sbslongcorr(gtime_t time, int sat, const sbssat_t *sbssat, return 1; } /* if sbas satellite without correction, no correction applied */ - if (satsys(sat, NULL) == SYS_SBS) return 1; + if (satsys(sat, nullptr) == SYS_SBS) + { + return 1; + } trace(2, "no sbas long-term correction: %s sat=%2d\n", time_str(time, 0), sat); return 0; @@ -960,12 +1163,21 @@ int sbsfastcorr(gtime_t time, int sat, const sbssat_t *sbssat, for (p = sbssat->sat; p < sbssat->sat + sbssat->nsat; p++) { - if (p->sat != sat) continue; - if (p->fcorr.t0.time == 0) break; + if (p->sat != sat) + { + continue; + } + if (p->fcorr.t0.time == 0) + { + break; + } t = timediff(time, p->fcorr.t0) + sbssat->tlat; /* expire age of correction or UDRE==14 (not monitored) */ - if (fabs(t) > MAXSBSAGEF || p->fcorr.udre >= 15) continue; + if (fabs(t) > MAXSBSAGEF || p->fcorr.udre >= 15) + { + continue; + } *prc = p->fcorr.prc; #ifdef RRCENA if (p->fcorr.ai > 0 && fabs(t) <= 8.0 * p->fcorr.dt) @@ -1019,7 +1231,10 @@ int sbssatcorr(gtime_t time, int sat, const nav_t *nav, double *rs, { return 0; } - for (i = 0; i < 3; i++) rs[i] += drs[i]; + for (i = 0; i < 3; i++) + { + rs[i] += drs[i]; + } dts[0] += dclk + prc / SPEED_OF_LIGHT; @@ -1047,17 +1262,25 @@ int sbsdecodemsg(gtime_t time, int prn, const unsigned int *words, trace(5, "sbsdecodemsg: prn=%d\n", prn); - if (time.time == 0) return 0; + if (time.time == 0) + { + return 0; + } tow = time2gpst(time, &sbsmsg->week); - sbsmsg->tow = (int)(tow + DTTOL); + sbsmsg->tow = static_cast(tow + DTTOL); sbsmsg->prn = prn; for (i = 0; i < 7; i++) - for (j = 0; j < 4; j++) - { - sbsmsg->msg[i * 4 + j] = (unsigned char)(words[i] >> ((3 - j) * 8)); - } - sbsmsg->msg[28] = (unsigned char)(words[7] >> 18) & 0xC0; - for (i = 28; i > 0; i--) f[i] = (sbsmsg->msg[i] >> 6) + (sbsmsg->msg[i - 1] << 2); + { + for (j = 0; j < 4; j++) + { + sbsmsg->msg[i * 4 + j] = static_cast(words[i] >> ((3 - j) * 8)); + } + } + sbsmsg->msg[28] = static_cast(words[7] >> 18) & 0xC0; + for (i = 28; i > 0; i--) + { + f[i] = (sbsmsg->msg[i] >> 6) + (sbsmsg->msg[i - 1] << 2); + } f[0] = sbsmsg->msg[0] >> 6; return rtk_crc24q(f, 29) == (words[7] & 0xFFFFFF); /* check crc */ diff --git a/src/algorithms/libs/rtklib/rtklib_sbas.h b/src/algorithms/libs/rtklib/rtklib_sbas.h index 1ff7bf6ad..801df1202 100644 --- a/src/algorithms/libs/rtklib/rtklib_sbas.h +++ b/src/algorithms/libs/rtklib/rtklib_sbas.h @@ -70,50 +70,50 @@ const int WEEKOFFSET = 1024; /* gps week offset for NovAtel OEM-3 */ /* sbas igp definition -------------------------------------------------------*/ static const short - x1[] = {-75, -65, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, + X1[] = {-75, -65, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 65, 75, 85}, - x2[] = {-55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, + X2[] = {-55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55}, - x3[] = {-75, -65, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, + X3[] = {-75, -65, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 65, 75}, - x4[] = {-85, -75, -65, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, + X4[] = {-85, -75, -65, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 65, 75}, - x5[] = {-180, -175, -170, -165, -160, -155, -150, -145, -140, -135, -130, -125, -120, -115, + X5[] = {-180, -175, -170, -165, -160, -155, -150, -145, -140, -135, -130, -125, -120, -115, -110, -105, -100, -95, -90, -85, -80, -75, -70, -65, -60, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175}, - x6[] = {-180, -170, -160, -150, -140, -130, -120, -110, -100, -90, -80, -70, -60, -50, + X6[] = {-180, -170, -160, -150, -140, -130, -120, -110, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170}, - x7[] = {-180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120, 150}, - x8[] = {-170, -140, -110, -80, -50, -20, 10, 40, 70, 100, 130, 160}; + X7[] = {-180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120, 150}, + X8[] = {-170, -140, -110, -80, -50, -20, 10, 40, 70, 100, 130, 160}; -const sbsigpband_t igpband1[9][8] = {/* band 0-8 */ - {{-180, x1, 1, 28}, {-175, x2, 29, 51}, {-170, x3, 52, 78}, {-165, x2, 79, 101}, - {-160, x3, 102, 128}, {-155, x2, 129, 151}, {-150, x3, 152, 178}, {-145, x2, 179, 201}}, - {{-140, x4, 1, 28}, {-135, x2, 29, 51}, {-130, x3, 52, 78}, {-125, x2, 79, 101}, - {-120, x3, 102, 128}, {-115, x2, 129, 151}, {-110, x3, 152, 178}, {-105, x2, 179, 201}}, - {{-100, x3, 1, 27}, {-95, x2, 28, 50}, {-90, x1, 51, 78}, {-85, x2, 79, 101}, - {-80, x3, 102, 128}, {-75, x2, 129, 151}, {-70, x3, 152, 178}, {-65, x2, 179, 201}}, - {{-60, x3, 1, 27}, {-55, x2, 28, 50}, {-50, x4, 51, 78}, {-45, x2, 79, 101}, - {-40, x3, 102, 128}, {-35, x2, 129, 151}, {-30, x3, 152, 178}, {-25, x2, 179, 201}}, - {{-20, x3, 1, 27}, {-15, x2, 28, 50}, {-10, x3, 51, 77}, {-5, x2, 78, 100}, - {0, x1, 101, 128}, {5, x2, 129, 151}, {10, x3, 152, 178}, {15, x2, 179, 201}}, - {{20, x3, 1, 27}, {25, x2, 28, 50}, {30, x3, 51, 77}, {35, x2, 78, 100}, - {40, x4, 101, 128}, {45, x2, 129, 151}, {50, x3, 152, 178}, {55, x2, 179, 201}}, - {{60, x3, 1, 27}, {65, x2, 28, 50}, {70, x3, 51, 77}, {75, x2, 78, 100}, - {80, x3, 101, 127}, {85, x2, 128, 150}, {90, x1, 151, 178}, {95, x2, 179, 201}}, - {{100, x3, 1, 27}, {105, x2, 28, 50}, {110, x3, 51, 77}, {115, x2, 78, 100}, - {120, x3, 101, 127}, {125, x2, 128, 150}, {130, x4, 151, 178}, {135, x2, 179, 201}}, - {{140, x3, 1, 27}, {145, x2, 28, 50}, {150, x3, 51, 77}, {155, x2, 78, 100}, - {160, x3, 101, 127}, {165, x2, 128, 150}, {170, x3, 151, 177}, {175, x2, 178, 200}}}; -const sbsigpband_t igpband2[2][5] = {/* band 9-10 */ - {{60, x5, 1, 72}, {65, x6, 73, 108}, {70, x6, 109, 144}, {75, x6, 145, 180}, - {85, x7, 181, 192}}, - {{-60, x5, 1, 72}, {-65, x6, 73, 108}, {-70, x6, 109, 144}, {-75, x6, 145, 180}, - {-85, x8, 181, 192}}}; +const sbsigpband_t IGPBAND1[9][8] = {/* band 0-8 */ + {{-180, X1, 1, 28}, {-175, X2, 29, 51}, {-170, X3, 52, 78}, {-165, X2, 79, 101}, + {-160, X3, 102, 128}, {-155, X2, 129, 151}, {-150, X3, 152, 178}, {-145, X2, 179, 201}}, + {{-140, X4, 1, 28}, {-135, X2, 29, 51}, {-130, X3, 52, 78}, {-125, X2, 79, 101}, + {-120, X3, 102, 128}, {-115, X2, 129, 151}, {-110, X3, 152, 178}, {-105, X2, 179, 201}}, + {{-100, X3, 1, 27}, {-95, X2, 28, 50}, {-90, X1, 51, 78}, {-85, X2, 79, 101}, + {-80, X3, 102, 128}, {-75, X2, 129, 151}, {-70, X3, 152, 178}, {-65, X2, 179, 201}}, + {{-60, X3, 1, 27}, {-55, X2, 28, 50}, {-50, X4, 51, 78}, {-45, X2, 79, 101}, + {-40, X3, 102, 128}, {-35, X2, 129, 151}, {-30, X3, 152, 178}, {-25, X2, 179, 201}}, + {{-20, X3, 1, 27}, {-15, X2, 28, 50}, {-10, X3, 51, 77}, {-5, X2, 78, 100}, + {0, X1, 101, 128}, {5, X2, 129, 151}, {10, X3, 152, 178}, {15, X2, 179, 201}}, + {{20, X3, 1, 27}, {25, X2, 28, 50}, {30, X3, 51, 77}, {35, X2, 78, 100}, + {40, X4, 101, 128}, {45, X2, 129, 151}, {50, X3, 152, 178}, {55, X2, 179, 201}}, + {{60, X3, 1, 27}, {65, X2, 28, 50}, {70, X3, 51, 77}, {75, X2, 78, 100}, + {80, X3, 101, 127}, {85, X2, 128, 150}, {90, X1, 151, 178}, {95, X2, 179, 201}}, + {{100, X3, 1, 27}, {105, X2, 28, 50}, {110, X3, 51, 77}, {115, X2, 78, 100}, + {120, X3, 101, 127}, {125, X2, 128, 150}, {130, X4, 151, 178}, {135, X2, 179, 201}}, + {{140, X3, 1, 27}, {145, X2, 28, 50}, {150, X3, 51, 77}, {155, X2, 78, 100}, + {160, X3, 101, 127}, {165, X2, 128, 150}, {170, X3, 151, 177}, {175, X2, 178, 200}}}; +const sbsigpband_t IGPBAND2[2][5] = {/* band 9-10 */ + {{60, X5, 1, 72}, {65, X6, 73, 108}, {70, X6, 109, 144}, {75, X6, 145, 180}, + {85, X7, 181, 192}}, + {{-60, X5, 1, 72}, {-65, X6, 73, 108}, {-70, X6, 109, 144}, {-75, X6, 145, 180}, + {-85, X8, 181, 192}}}; char *getfield(char *p, int pos); diff --git a/src/algorithms/libs/rtklib/rtklib_solution.cc b/src/algorithms/libs/rtklib/rtklib_solution.cc index f559e9f4d..ab7c6a72e 100644 --- a/src/algorithms/libs/rtklib/rtklib_solution.cc +++ b/src/algorithms/libs/rtklib/rtklib_solution.cc @@ -51,10 +51,11 @@ * *----------------------------------------------------------------------------*/ -#include #include "rtklib_solution.h" #include "rtklib_rtkcmn.h" #include "rtklib_rtksvr.h" +#include +#include /* constants and macros ------------------------------------------------------*/ @@ -63,11 +64,10 @@ #define SQRT_SOL(x) ((x) < 0.0 ? 0.0 : sqrt(x)) const int MAXFIELD = 64; /* max number of fields in a record */ -const int MAXNMEA = 256; /* max length of nmea sentence */ const double KNOT2M = 0.514444444; /* m/knot */ -static const int solq_nmea[] = {/* nmea quality flags to rtklib sol quality */ +static const int SOLQ_NMEA[] = {/* nmea quality flags to rtklib sol quality */ /* nmea 0183 v.2.3 quality flags: */ /* 0=invalid, 1=gps fix (sps), 2=dgps fix, 3=pps fix, 4=rtk, 5=float rtk */ /* 6=estimated (dead reckoning), 7=manual input, 8=simulation */ @@ -79,9 +79,13 @@ static const int solq_nmea[] = {/* nmea quality flags to rtklib sol quality */ const char *opt2sep(const solopt_t *opt) { if (!*opt->sep) - return " "; - else if (!strcmp(opt->sep, "\\t")) - return "\t"; + { + return " "; + } + if (!strcmp(opt->sep, "\\t")) + { + return "\t"; + } return opt->sep; } @@ -89,14 +93,23 @@ const char *opt2sep(const solopt_t *opt) /* separate fields -----------------------------------------------------------*/ int tonum(char *buff, const char *sep, double *v) { - int n, len = (int)strlen(sep); + int n, len = static_cast(strlen(sep)); char *p, *q; for (p = buff, n = 0; n < MAXFIELD; p = q + len) { - if ((q = strstr(p, sep))) *q = '\0'; - if (*p) v[n++] = atof(p); - if (!q) break; + if ((q = strstr(p, sep))) + { + *q = '\0'; + } + if (*p) + { + v[n++] = atof(p); + } + if (!q) + { + break; + } } return n; } @@ -141,12 +154,12 @@ void soltocov(const sol_t *sol, double *P) /* covariance to solution ----------------------------------------------------*/ void covtosol(const double *P, sol_t *sol) { - sol->qr[0] = (float)P[0]; /* xx or ee */ - sol->qr[1] = (float)P[4]; /* yy or nn */ - sol->qr[2] = (float)P[8]; /* zz or uu */ - sol->qr[3] = (float)P[1]; /* xy or en */ - sol->qr[4] = (float)P[5]; /* yz or nu */ - sol->qr[5] = (float)P[2]; /* zx or ue */ + sol->qr[0] = static_cast(P[0]); /* xx or ee */ + sol->qr[1] = static_cast(P[4]); /* yy or nn */ + sol->qr[2] = static_cast(P[8]); /* zz or uu */ + sol->qr[3] = static_cast(P[1]); /* xy or en */ + sol->qr[4] = static_cast(P[5]); /* yz or nu */ + sol->qr[5] = static_cast(P[2]); /* zx or ue */ } @@ -301,13 +314,19 @@ int decode_nmeagga(char **val, int n, sol_t *sol) time = utc2gpst(epoch2time(ep)); tt = timediff(time, sol->time); if (tt < -43200.0) - sol->time = timeadd(time, 86400.0); + { + sol->time = timeadd(time, 86400.0); + } else if (tt > 43200.0) - sol->time = timeadd(time, -86400.0); + { + sol->time = timeadd(time, -86400.0); + } else - sol->time = time; + { + sol->time = time; + } pos2ecef(pos, sol->rr); - sol->stat = 0 <= solq && solq <= 8 ? solq_nmea[solq] : SOLQ_NONE; + sol->stat = 0 <= solq && solq <= 8 ? SOLQ_NMEA[solq] : SOLQ_NONE; sol->ns = nrcv; sol->type = 0; /* position type = xyz */ @@ -323,7 +342,7 @@ int decode_nmeagga(char **val, int n, sol_t *sol) /* decode nmea ---------------------------------------------------------------*/ int decode_nmea(char *buff, sol_t *sol) { - char *p, *q, *val[MAXFIELD] = {0}; + char *p, *q, *val[MAXFIELD] = {nullptr}; int n = 0; trace(4, "decode_nmea: buff=%s\n", buff); @@ -337,14 +356,16 @@ int decode_nmea(char *buff, sol_t *sol) *q = '\0'; } else - break; + { + break; + } } /* decode nmea sentence */ if (!strcmp(val[0], "$GPRMC")) { return decode_nmearmc(val + 1, n - 1, sol); } - else if (!strcmp(val[0], "$GPGGA")) + if (!strcmp(val[0], "$GPGGA")) { return decode_nmeagga(val + 1, n - 1, sol); } @@ -362,10 +383,14 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) trace(4, "decode_soltime:\n"); if (!strcmp(opt->sep, "\\t")) - strcpy(s, "\t"); + { + strcpy(s, "\t"); + } else if (*opt->sep) - strcpy(s, opt->sep); - len = (int)strlen(s); + { + strcpy(s, opt->sep); + } + len = static_cast(strlen(s)); /* yyyy/mm/dd hh:mm:ss or yyyy mm dd hh:mm:ss */ if (sscanf(buff, "%lf/%lf/%lf %lf:%lf:%lf", v, v + 1, v + 2, v + 3, v + 4, v + 5) >= 6) @@ -383,34 +408,55 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) { *time = utc2gpst(timeadd(*time, -9 * 3600.0)); } - if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return NULL; - for (p++; isdigit((int)*p) || *p == '.';) p++; + if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) + { + return nullptr; + } + for (p++; isdigit(static_cast(*p)) || *p == '.';) + { + p++; + } return p + len; } if (opt->posf == SOLF_GSIF) { if (sscanf(buff, "%lf %lf %lf %lf:%lf:%lf", v, v + 1, v + 2, v + 3, v + 4, v + 5) < 6) { - return NULL; + return nullptr; } *time = timeadd(epoch2time(v), -12.0 * 3600.0); - if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return NULL; - for (p++; isdigit((int)*p) || *p == '.';) p++; + if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) + { + return nullptr; + } + for (p++; isdigit(static_cast(*p)) || *p == '.';) + { + p++; + } return p + len; } /* wwww ssss */ for (p = buff, n = 0; n < 2; p = q + len) { - if ((q = strstr(p, s))) *q = '\0'; - if (*p) v[n++] = atof(p); - if (!q) break; + if ((q = strstr(p, s))) + { + *q = '\0'; + } + if (*p) + { + v[n++] = atof(p); + } + if (!q) + { + break; + } } if (n >= 2 && 0.0 <= v[0] && v[0] <= 3000.0 && 0.0 <= v[1] && v[1] < 604800.0) { - *time = gpst2time((int)v[0], v[1]); + *time = gpst2time(static_cast(v[0]), v[1]); return p; } - return NULL; + return nullptr; } @@ -423,14 +469,23 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol) trace(4, "decode_solxyz:\n"); - if ((n = tonum(buff, sep, val)) < 3) return 0; + if ((n = tonum(buff, sep, val)) < 3) + { + return 0; + } for (j = 0; j < 3; j++) { sol->rr[j] = val[i++]; /* xyz */ } - if (i < n) sol->stat = (unsigned char)val[i++]; - if (i < n) sol->ns = (unsigned char)val[i++]; + if (i < n) + { + sol->stat = static_cast(val[i++]); + } + if (i < n) + { + sol->ns = static_cast(val[i++]); + } if (i + 3 < n) { P[0] = val[i] * val[i]; @@ -450,12 +505,21 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol) } covtosol(P, sol); } - if (i < n) sol->age = (float)val[i++]; - if (i < n) sol->ratio = (float)val[i]; + if (i < n) + { + sol->age = static_cast(val[i++]); + } + if (i < n) + { + sol->ratio = static_cast(val[i]); + } sol->type = 0; /* position type = xyz */ - if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; + if (MAXSOLQ < sol->stat) + { + sol->stat = SOLQ_NONE; + } return 1; } @@ -473,22 +537,34 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol) if (!opt->degf) { - if (n < 3) return 0; + if (n < 3) + { + return 0; + } pos[0] = val[i++] * D2R; /* lat/lon/hgt (ddd.ddd) */ pos[1] = val[i++] * D2R; pos[2] = val[i++]; } else { - if (n < 7) return 0; + if (n < 7) + { + return 0; + } pos[0] = dms2deg(val) * D2R; /* lat/lon/hgt (ddd mm ss) */ pos[1] = dms2deg(val + 3) * D2R; pos[2] = val[6]; i += 7; } pos2ecef(pos, sol->rr); - if (i < n) sol->stat = (unsigned char)val[i++]; - if (i < n) sol->ns = (unsigned char)val[i++]; + if (i < n) + { + sol->stat = static_cast(val[i++]); + } + if (i < n) + { + sol->ns = static_cast(val[i++]); + } if (i + 3 < n) { Q[4] = val[i] * val[i]; @@ -509,12 +585,21 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol) covecef(pos, Q, P); covtosol(P, sol); } - if (i < n) sol->age = (float)val[i++]; - if (i < n) sol->ratio = (float)val[i]; + if (i < n) + { + sol->age = static_cast(val[i++]); + } + if (i < n) + { + sol->ratio = static_cast(val[i]); + } sol->type = 0; /* position type = xyz */ - if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; + if (MAXSOLQ < sol->stat) + { + sol->stat = SOLQ_NONE; + } return 1; } @@ -528,14 +613,23 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) trace(4, "decode_solenu:\n"); - if ((n = tonum(buff, sep, val)) < 3) return 0; + if ((n = tonum(buff, sep, val)) < 3) + { + return 0; + } for (j = 0; j < 3; j++) { sol->rr[j] = val[i++]; /* enu */ } - if (i < n) sol->stat = (unsigned char)val[i++]; - if (i < n) sol->ns = (unsigned char)val[i++]; + if (i < n) + { + sol->stat = static_cast(val[i++]); + } + if (i < n) + { + sol->ns = static_cast(val[i++]); + } if (i + 3 < n) { Q[0] = val[i] * val[i]; @@ -555,12 +649,21 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) } covtosol(Q, sol); } - if (i < n) sol->age = (float)val[i++]; - if (i < n) sol->ratio = (float)val[i]; + if (i < n) + { + sol->age = static_cast(val[i++]); + } + if (i < n) + { + sol->ratio = static_cast(val[i]); + } sol->type = 1; /* position type = enu */ - if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; + if (MAXSOLQ < sol->stat) + { + sol->stat = SOLQ_NONE; + } return 1; } @@ -573,7 +676,10 @@ int decode_solgsi(char *buff, const solopt_t *opt __attribute((unused)), sol_t * trace(4, "decode_solgsi:\n"); - if (tonum(buff, " ", val) < 3) return 0; + if (tonum(buff, " ", val) < 3) + { + return 0; + } for (j = 0; j < 3; j++) { @@ -624,11 +730,17 @@ void decode_refpos(char *buff, const solopt_t *opt, double *rb) trace(3, "decode_refpos: buff=%s\n", buff); - if ((n = tonum(buff, sep, val)) < 3) return; + if ((n = tonum(buff, sep, val)) < 3) + { + return; + } if (opt->posf == SOLF_XYZ) { /* xyz */ - for (i = 0; i < 3; i++) rb[i] = val[i]; + for (i = 0; i < 3; i++) + { + rb[i] = val[i]; + } } else if (opt->degf == 0) { /* lat/lon/hgt (ddd.ddd) */ @@ -656,21 +768,36 @@ int decode_sol(char *buff, const solopt_t *opt, sol_t *sol, double *rb) if (!strncmp(buff, COMMENTH, 1)) { /* reference position */ - if (!strstr(buff, "ref pos") && !strstr(buff, "slave pos")) return 0; - if (!(p = strchr(buff, ':'))) return 0; + if (!strstr(buff, "ref pos") && !strstr(buff, "slave pos")) + { + return 0; + } + if (!(p = strchr(buff, ':'))) + { + return 0; + } decode_refpos(p + 1, opt, rb); return 0; } if (!strncmp(buff, "$GP", 3)) { /* decode nmea */ - if (!decode_nmea(buff, sol)) return 0; + if (!decode_nmea(buff, sol)) + { + return 0; + } /* for time update only */ - if (opt->posf != SOLF_NMEA && !strncmp(buff, "$GPRMC", 6)) return 2; + if (opt->posf != SOLF_NMEA && !strncmp(buff, "$GPRMC", 6)) + { + return 2; + } } else { /* decode position record */ - if (!decode_solpos(buff, opt, sol)) return 0; + if (!decode_solpos(buff, opt, sol)) + { + return 0; + } } return 1; } @@ -683,14 +810,23 @@ void decode_solopt(char *buff, solopt_t *opt) trace(4, "decode_solhead: buff=%s\n", buff); - if (strncmp(buff, COMMENTH, 1) && strncmp(buff, "+", 1)) return; + if (strncmp(buff, COMMENTH, 1) != 0 && strncmp(buff, "+", 1) != 0) + { + return; + } if (strstr(buff, "GPST")) - opt->times = TIMES_GPST; + { + opt->times = TIMES_GPST; + } else if (strstr(buff, "UTC")) - opt->times = TIMES_UTC; + { + opt->times = TIMES_UTC; + } else if (strstr(buff, "JST")) - opt->times = TIMES_JST; + { + opt->times = TIMES_JST; + } if ((p = strstr(buff, "x-ecef(m)"))) { @@ -771,19 +907,22 @@ int inputsol(unsigned char data, gtime_t ts, gtime_t te, double tint, solbuf->nb = 0; } solbuf->buff[solbuf->nb++] = data; - if (data != '\n' && solbuf->nb < MAXSOLMSG) return 0; /* sync trailer */ + if (data != '\n' && solbuf->nb < MAXSOLMSG) + { + return 0; /* sync trailer */ + } solbuf->buff[solbuf->nb] = '\0'; solbuf->nb = 0; /* check disconnect message */ - if (!strcmp((char *)solbuf->buff, MSG_DISCONN)) + if (!strcmp(reinterpret_cast(solbuf->buff), MSG_DISCONN)) { trace(3, "disconnect received\n"); return -1; } /* decode solution */ - if ((stat = decode_sol((char *)solbuf->buff, opt, &sol, solbuf->rb)) > 0) + if ((stat = decode_sol(reinterpret_cast(solbuf->buff), opt, &sol, solbuf->rb)) > 0) { solbuf->time = sol.time; /* update current time */ } @@ -807,7 +946,7 @@ int readsoldata(FILE *fp, gtime_t ts, gtime_t te, double tint, int qflag, while ((c = fgetc(fp)) != EOF) { /* input solution */ - inputsol((unsigned char)c, ts, te, tint, qflag, opt, solbuf); + inputsol(static_cast(c), ts, te, tint, qflag, opt, solbuf); } return solbuf->n > 0; } @@ -816,7 +955,7 @@ int readsoldata(FILE *fp, gtime_t ts, gtime_t te, double tint, int qflag, /* compare solution data -----------------------------------------------------*/ int cmpsol(const void *p1, const void *p2) { - sol_t *q1 = (sol_t *)p1, *q2 = (sol_t *)p2; + auto *q1 = (sol_t *)p1, *q2 = (sol_t *)p2; double tt = timediff(q1->time, q2->time); return tt < -0.0 ? -1 : (tt > 0.0 ? 1 : 0); } @@ -829,13 +968,16 @@ int sort_solbuf(solbuf_t *solbuf) trace(4, "sort_solbuf: n=%d\n", solbuf->n); - if (solbuf->n <= 0) return 0; + if (solbuf->n <= 0) + { + return 0; + } - if (!(solbuf_data = (sol_t *)realloc(solbuf->data, sizeof(sol_t) * solbuf->n))) + if (!(solbuf_data = static_cast(realloc(solbuf->data, sizeof(sol_t) * solbuf->n)))) { trace(1, "sort_solbuf: memory allocation error\n"); free(solbuf->data); - solbuf->data = NULL; + solbuf->data = nullptr; solbuf->n = solbuf->nmax = 0; return 0; } @@ -863,7 +1005,7 @@ int readsolt(char *files[], int nfile, gtime_t ts, gtime_t te, double tint, int qflag, solbuf_t *solbuf) { FILE *fp; - solopt_t opt = solopt_default; + solopt_t opt = SOLOPT_DEFAULT; int i; trace(3, "readsolt: nfile=%d\n", nfile); @@ -872,7 +1014,7 @@ int readsolt(char *files[], int nfile, gtime_t ts, gtime_t te, for (i = 0; i < nfile; i++) { - if (!(fp = fopen(files[i], "rb"))) + if (!(fp = fopen(files[i], "rbe"))) { trace(1, "readsolt: file open error %s\n", files[i]); continue; @@ -916,15 +1058,26 @@ int addsol(solbuf_t *solbuf, const sol_t *sol) if (solbuf->cyclic) { /* ring buffer */ - if (solbuf->nmax <= 1) return 0; + if (solbuf->nmax <= 1) + { + return 0; + } solbuf->data[solbuf->end] = *sol; - if (++solbuf->end >= solbuf->nmax) solbuf->end = 0; + if (++solbuf->end >= solbuf->nmax) + { + solbuf->end = 0; + } if (solbuf->start == solbuf->end) { - if (++solbuf->start >= solbuf->nmax) solbuf->start = 0; + if (++solbuf->start >= solbuf->nmax) + { + solbuf->start = 0; + } } else - solbuf->n++; + { + solbuf->n++; + } return 1; } @@ -932,11 +1085,11 @@ int addsol(solbuf_t *solbuf, const sol_t *sol) if (solbuf->n >= solbuf->nmax) { solbuf->nmax = solbuf->nmax == 0 ? 8192 : solbuf->nmax * 2; - if (!(solbuf_data = (sol_t *)realloc(solbuf->data, sizeof(sol_t) * solbuf->nmax))) + if (!(solbuf_data = static_cast(realloc(solbuf->data, sizeof(sol_t) * solbuf->nmax)))) { trace(1, "addsol: memory allocation error\n"); free(solbuf->data); - solbuf->data = NULL; + solbuf->data = nullptr; solbuf->n = solbuf->nmax = 0; return 0; } @@ -957,7 +1110,10 @@ sol_t *getsol(solbuf_t *solbuf, int index) { trace(4, "getsol: index=%d\n", index); - if (index < 0 || solbuf->n <= index) return NULL; + if (index < 0 || solbuf->n <= index) + { + return nullptr; + } if ((index = solbuf->start + index) >= solbuf->nmax) { index -= solbuf->nmax; @@ -982,11 +1138,14 @@ void initsolbuf(solbuf_t *solbuf, int cyclic, int nmax) solbuf->n = solbuf->nmax = solbuf->start = solbuf->end = 0; solbuf->cyclic = cyclic; solbuf->time = time0; - solbuf->data = NULL; + solbuf->data = nullptr; if (cyclic) { - if (nmax <= 2) nmax = 2; - if (!(solbuf->data = (sol_t *)malloc(sizeof(sol_t) * nmax))) + if (nmax <= 2) + { + nmax = 2; + } + if (!(solbuf->data = static_cast(malloc(sizeof(sol_t) * nmax)))) { trace(1, "initsolbuf: memory allocation error\n"); return; @@ -1007,7 +1166,7 @@ void freesolbuf(solbuf_t *solbuf) free(solbuf->data); solbuf->n = solbuf->nmax = solbuf->start = solbuf->end = 0; - solbuf->data = NULL; + solbuf->data = nullptr; } @@ -1017,14 +1176,14 @@ void freesolstatbuf(solstatbuf_t *solstatbuf) solstatbuf->n = solstatbuf->nmax = 0; free(solstatbuf->data); - solstatbuf->data = NULL; + solstatbuf->data = nullptr; } /* compare solution status ---------------------------------------------------*/ int cmpsolstat(const void *p1, const void *p2) { - solstat_t *q1 = (solstat_t *)p1, *q2 = (solstat_t *)p2; + auto *q1 = (solstat_t *)p1, *q2 = (solstat_t *)p2; double tt = timediff(q1->time, q2->time); return tt < -0.0 ? -1 : (tt > 0.0 ? 1 : 0); } @@ -1037,13 +1196,16 @@ int sort_solstat(solstatbuf_t *statbuf) trace(4, "sort_solstat: n=%d\n", statbuf->n); - if (statbuf->n <= 0) return 0; + if (statbuf->n <= 0) + { + return 0; + } - if (!(statbuf_data = (solstat_t *)realloc(statbuf->data, sizeof(solstat_t) * statbuf->n))) + if (!(statbuf_data = static_cast(realloc(statbuf->data, sizeof(solstat_t) * statbuf->n)))) { trace(1, "sort_solstat: memory allocation error\n"); free(statbuf->data); - statbuf->data = NULL; + statbuf->data = nullptr; statbuf->n = statbuf->nmax = 0; return 0; } @@ -1064,10 +1226,18 @@ int decode_solstat(char *buff, solstat_t *stat) trace(4, "decode_solstat: buff=%s\n", buff); - if (strstr(buff, "$SAT") != buff) return 0; + if (strstr(buff, "$SAT") != buff) + { + return 0; + } for (p = buff; *p; p++) - if (*p == ',') *p = ' '; + { + if (*p == ',') + { + *p = ' '; + } + } n = sscanf(buff, "$SAT%d%lf%s%d%lf%lf%lf%lf%d%d%d%d%d%d%d%d", &week, &tow, id, &frq, &az, &el, &resp, &resc, &vsat, &snr, &fix, &slip, @@ -1085,18 +1255,18 @@ int decode_solstat(char *buff, solstat_t *stat) } *stat = stat0; stat->time = gpst2time(week, tow); - stat->sat = (unsigned char)sat; - stat->frq = (unsigned char)frq; - stat->az = (float)(az * D2R); - stat->el = (float)(el * D2R); - stat->resp = (float)resp; - stat->resc = (float)resc; - stat->flag = (unsigned char)((vsat << 5) + (slip << 3) + fix); - stat->snr = (unsigned char)(snr * 4.0 + 0.5); - stat->lock = (unsigned short)lock; - stat->outc = (unsigned short)outc; - stat->slipc = (unsigned short)slipc; - stat->rejc = (unsigned short)rejc; + stat->sat = static_cast(sat); + stat->frq = static_cast(frq); + stat->az = static_cast(az * D2R); + stat->el = static_cast(el * D2R); + stat->resp = static_cast(resp); + stat->resc = static_cast(resc); + stat->flag = static_cast((vsat << 5) + (slip << 3) + fix); + stat->snr = static_cast(snr * 4.0 + 0.5); + stat->lock = static_cast(lock); + stat->outc = static_cast(outc); + stat->slipc = static_cast(slipc); + stat->rejc = static_cast(rejc); return 1; } @@ -1111,12 +1281,12 @@ void addsolstat(solstatbuf_t *statbuf, const solstat_t *stat) if (statbuf->n >= statbuf->nmax) { statbuf->nmax = statbuf->nmax == 0 ? 8192 : statbuf->nmax * 2; - if (!(statbuf_data = (solstat_t *)realloc(statbuf->data, sizeof(solstat_t) * - statbuf->nmax))) + if (!(statbuf_data = static_cast(realloc(statbuf->data, sizeof(solstat_t) * + statbuf->nmax)))) { trace(1, "addsolstat: memory allocation error\n"); free(statbuf->data); - statbuf->data = NULL; + statbuf->data = nullptr; statbuf->n = statbuf->nmax = 0; return; } @@ -1138,7 +1308,10 @@ int readsolstatdata(FILE *fp, gtime_t ts, gtime_t te, double tint, while (fgets(buff, sizeof(buff), fp)) { /* decode solution status */ - if (!decode_solstat(buff, &stat)) continue; + if (!decode_solstat(buff, &stat)) + { + continue; + } /* add solution to solution buffer */ if (screent(stat.time, ts, te, tint)) @@ -1170,12 +1343,12 @@ int readsolstatt(char *files[], int nfile, gtime_t ts, gtime_t te, trace(3, "readsolstatt: nfile=%d\n", nfile); statbuf->n = statbuf->nmax = 0; - statbuf->data = NULL; + statbuf->data = nullptr; for (i = 0; i < nfile; i++) { sprintf(path, "%s.stat", files[i]); - if (!(fp = fopen(path, "r"))) + if (!(fp = fopen(path, "re"))) { trace(1, "readsolstatt: file open error %s\n", path); continue; @@ -1206,7 +1379,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol, const solopt_t *opt) { const char *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outecef:\n"); @@ -1215,7 +1388,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol, sol->ns, sep, SQRT_SOL(sol->qr[0]), sep, SQRT_SOL(sol->qr[1]), sep, SQRT_SOL(sol->qr[2]), sep, sqvar(sol->qr[3]), sep, sqvar(sol->qr[4]), sep, sqvar(sol->qr[5]), sep, sol->age, sep, sol->ratio); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1225,7 +1398,7 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol, { double pos[3], dms1[3], dms2[3], P[9], Q[9]; const char *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outpos :\n"); @@ -1245,12 +1418,14 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol, dms2[2]); } else - p += sprintf(p, "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D); + { + p += sprintf(p, "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D); + } p += sprintf(p, "%s%10.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", sep, pos[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[2]), sep, sqvar(Q[5]), sep, sol->age, sep, sol->ratio); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1261,11 +1436,14 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol, double pos[3], rr[3], enu[3], P[9], Q[9]; int i; const char *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outenu :\n"); - for (i = 0; i < 3; i++) rr[i] = sol->rr[i] - rb[i]; + for (i = 0; i < 3; i++) + { + rr[i] = sol->rr[i] - rb[i]; + } ecef2pos(rb, pos); soltocov(sol, P); covenu(pos, P, Q); @@ -1274,7 +1452,7 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol, s, sep, enu[0], sep, enu[1], sep, enu[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[5]), sep, sqvar(Q[2]), sep, sol->age, sep, sol->ratio); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1284,16 +1462,19 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) static double dirp = 0.0; gtime_t time; double ep[6], pos[3], enuv[3], dms1[3], dms2[3], vel, dir, amag = 0.0; - char *p = (char *)buff, *q, sum, *emag = (char *)"E"; + char *p = reinterpret_cast(buff), *q, sum, *emag = (char *)"E"; trace(3, "outnmea_rmc:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPRMC,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } time = gpst2utc(sol->time); if (time.sec >= 0.995) @@ -1308,21 +1489,29 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) if (vel >= 1.0) { dir = atan2(enuv[0], enuv[1]) * R2D; - if (dir < 0.0) dir += 360.0; + if (dir < 0.0) + { + dir += 360.0; + } dirp = dir; } else - dir = dirp; + { + dir = dirp; + } deg2dms(fabs(pos[0]) * R2D, dms1); deg2dms(fabs(pos[1]) * R2D, dms2); p += sprintf(p, "$GPRMC,%02.0f%02.0f%05.2f,A,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%4.2f,%4.2f,%02.0f%02.0f%02d,%.1f,%s,%s", ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S", dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", vel / KNOT2M, dir, - ep[2], ep[1], (int)ep[0] % 100, amag, emag, + ep[2], ep[1], static_cast(ep[0]) % 100, amag, emag, sol->stat == SOLQ_DGPS || sol->stat == SOLQ_FLOAT || sol->stat == SOLQ_FIX ? "D" : "A"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1332,20 +1521,31 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) gtime_t time; double h, ep[6], pos[3], dms1[3], dms2[3], dop = 1.0; int solq; - char *p = (char *)buff, *q, sum; + char *p = reinterpret_cast(buff), *q, sum; trace(3, "outnmea_gga:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGGA,,,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } for (solq = 0; solq < 8; solq++) - if (solq_nmea[solq] == sol->stat) break; - if (solq >= 8) solq = 0; + { + if (SOLQ_NMEA[solq] == sol->stat) + { + break; + } + } + if (solq >= 8) + { + solq = 0; + } time = gpst2utc(sol->time); if (time.sec >= 0.995) { @@ -1361,9 +1561,12 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S", dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", solq, sol->ns, dop, pos[2] - h, h, sol->age); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1373,26 +1576,41 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, { double azel[MAXSAT * 2], dop[4]; int i, sat, sys, nsat, prn[MAXSAT]; - char *p = (char *)buff, *q, *s, sum; + char *p = reinterpret_cast(buff), *q, *s, sum; trace(3, "outnmea_gsa:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGSA,A,1,,,,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } /* GPGSA: gps/sbas */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) { - if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) continue; + if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) + { + continue; + } sys = satsys(sat, prn + nsat); - if (sys != SYS_GPS && sys != SYS_SBS) continue; - if (sys == SYS_SBS) prn[nsat] += 33 - MINPRNSBS; - for (i = 0; i < 2; i++) azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + if (sys != SYS_GPS && sys != SYS_SBS) + { + continue; + } + if (sys == SYS_SBS) + { + prn[nsat] += 33 - MINPRNSBS; + } + for (i = 0; i < 2; i++) + { + azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + } nsat++; } if (nsat > 0) @@ -1402,21 +1620,37 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, for (i = 0; i < 12; i++) { if (i < nsat) - p += sprintf(p, ",%02d", prn[i]); + { + p += sprintf(p, ",%02d", prn[i]); + } else - p += sprintf(p, ","); + { + p += sprintf(p, ","); + } } dops(nsat, azel, 0.0, dop); p += sprintf(p, ",%3.1f,%3.1f,%3.1f,1", dop[1], dop[2], dop[3]); - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GLGSA: glonass */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) { - if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) continue; - if (satsys(sat, prn + nsat) != SYS_GLO) continue; - for (i = 0; i < 2; i++) azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) + { + continue; + } + if (satsys(sat, prn + nsat) != SYS_GLO) + { + continue; + } + for (i = 0; i < 2; i++) + { + azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + } nsat++; } if (nsat > 0) @@ -1426,21 +1660,37 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, for (i = 0; i < 12; i++) { if (i < nsat) - p += sprintf(p, ",%02d", prn[i] + 64); + { + p += sprintf(p, ",%02d", prn[i] + 64); + } else - p += sprintf(p, ","); + { + p += sprintf(p, ","); + } } dops(nsat, azel, 0.0, dop); p += sprintf(p, ",%3.1f,%3.1f,%3.1f,2", dop[1], dop[2], dop[3]); - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GAGSA: galileo */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) { - if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) continue; - if (satsys(sat, prn + nsat) != SYS_GAL) continue; - for (i = 0; i < 2; i++) azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) + { + continue; + } + if (satsys(sat, prn + nsat) != SYS_GAL) + { + continue; + } + for (i = 0; i < 2; i++) + { + azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + } nsat++; } if (nsat > 0) @@ -1450,16 +1700,23 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, for (i = 0; i < 12; i++) { if (i < nsat) - p += sprintf(p, ",%02d", prn[i]); + { + p += sprintf(p, ",%02d", prn[i]); + } else - p += sprintf(p, ","); + { + p += sprintf(p, ","); + } } dops(nsat, azel, 0.0, dop); p += sprintf(p, ",%3.1f,%3.1f,%3.1f,3", dop[1], dop[2], dop[3]); - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1469,23 +1726,32 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, { double az, el, snr; int i, j, k, n, sat, prn, sys, nmsg, sats[MAXSAT]; - char *p = (char *)buff, *q, *s, sum; + char *p = reinterpret_cast(buff), *q, *s, sum; trace(3, "outnmea_gsv:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } /* GPGSV: gps/sbas */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) { sys = satsys(sat, &prn); - if (sys != SYS_GPS && sys != SYS_SBS) continue; - if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) sats[n++] = sat; + if (sys != SYS_GPS && sys != SYS_SBS) + { + continue; + } + if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) + { + sats[n++] = sat; + } } nmsg = n <= 0 ? 0 : (n - 1) / 4 + 1; @@ -1498,25 +1764,42 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, { if (k < n) { - if (satsys(sats[k], &prn) == SYS_SBS) prn += 33 - MINPRNSBS; + if (satsys(sats[k], &prn) == SYS_SBS) + { + prn += 33 - MINPRNSBS; + } az = ssat[sats[k] - 1].azel[0] * R2D; - if (az < 0.0) az += 360.0; + if (az < 0.0) + { + az += 360.0; + } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else - p += sprintf(p, ",,,,"); + { + p += sprintf(p, ",,,,"); + } + } + p += sprintf(p, ",1"); /* L1C/A */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ } - p += sprintf(p, ",1"); /* L1C/A */ - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GLGSV: glonass */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) { - if (satsys(sat, &prn) != SYS_GLO) continue; - if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) sats[n++] = sat; + if (satsys(sat, &prn) != SYS_GLO) + { + continue; + } + if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) + { + sats[n++] = sat; + } } nmsg = n <= 0 ? 0 : (n - 1) / 4 + 1; @@ -1532,23 +1815,37 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, satsys(sats[k], &prn); prn += 64; /* 65-99 */ az = ssat[sats[k] - 1].azel[0] * R2D; - if (az < 0.0) az += 360.0; + if (az < 0.0) + { + az += 360.0; + } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else - p += sprintf(p, ",,,,"); + { + p += sprintf(p, ",,,,"); + } + } + p += sprintf(p, ",1"); /* L1C/A */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ } - p += sprintf(p, ",1"); /* L1C/A */ - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GAGSV: galileo */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) { - if (satsys(sat, &prn) != SYS_GAL) continue; - if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) sats[n++] = sat; + if (satsys(sat, &prn) != SYS_GAL) + { + continue; + } + if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) + { + sats[n++] = sat; + } } nmsg = n <= 0 ? 0 : (n - 1) / 4 + 1; @@ -1563,19 +1860,27 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, { satsys(sats[k], &prn); /* 1-36 */ az = ssat[sats[k] - 1].azel[0] * R2D; - if (az < 0.0) az += 360.0; + if (az < 0.0) + { + az += 360.0; + } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else - p += sprintf(p, ",,,,"); + { + p += sprintf(p, ",,,,"); + } + } + p += sprintf(p, ",7"); /* L1BC */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ } - p += sprintf(p, ",7"); /* L1BC */ - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1602,7 +1907,7 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) const char *s8[] = {"off", "continuous", "instantaneous", "fix and hold", ""}; const char *s9[] = {"off", "on", "auto calib", "external calib", ""}; int i; - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outprcopts:\n"); @@ -1633,7 +1938,10 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) p += sprintf(p, "%s navi sys :", COMMENTH); for (i = 0; sys[i]; i++) { - if (opt->navsys & sys[i]) p += sprintf(p, " %s", s7[i]); + if (opt->navsys & sys[i]) + { + p += sprintf(p, " %s", s7[i]); + } } p += sprintf(p, "\n"); } @@ -1656,12 +1964,15 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) } for (i = 0; i < 2; i++) { - if (opt->mode == PMODE_SINGLE || (i >= 1 && opt->mode > PMODE_FIXED)) continue; + if (opt->mode == PMODE_SINGLE || (i >= 1 && opt->mode > PMODE_FIXED)) + { + continue; + } p += sprintf(p, "%s antenna%d : %-21s (%7.4f %7.4f %7.4f)\n", COMMENTH, i + 1, opt->anttype[i], opt->antdel[i][0], opt->antdel[i][1], opt->antdel[i][2]); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1675,22 +1986,31 @@ int outsolheads(unsigned char *buff, const solopt_t *opt) { const char *s1[] = {"WGS84", "Tokyo"}, *s2[] = {"ellipsoidal", "geodetic"}; const char *s3[] = {"GPST", "UTC ", "JST "}, *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); int timeu = opt->timeu < 0 ? 0 : (opt->timeu > 20 ? 20 : opt->timeu); trace(3, "outsolheads:\n"); - if (opt->posf == SOLF_NMEA) return 0; + if (opt->posf == SOLF_NMEA) + { + return 0; + } if (opt->outhead) { p += sprintf(p, "%s (", COMMENTH); if (opt->posf == SOLF_XYZ) - p += sprintf(p, "x/y/z-ecef=WGS84"); + { + p += sprintf(p, "x/y/z-ecef=WGS84"); + } else if (opt->posf == SOLF_ENU) - p += sprintf(p, "e/n/u-baseline=WGS84"); + { + p += sprintf(p, "e/n/u-baseline=WGS84"); + } else - p += sprintf(p, "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]); + { + p += sprintf(p, "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]); + } p += sprintf(p, ",Q=1:fix,2:float,3:sbas,4:dgps,5:single,6:ppp,ns=# of satellites)\n"); } p += sprintf(p, "%s %-*s%s", COMMENTH, (opt->timef ? 16 : 8) + timeu + 1, s3[opt->times], sep); @@ -1726,7 +2046,7 @@ int outsolheads(unsigned char *buff, const solopt_t *opt) "Q", sep, "ns", sep, "sde(m)", sep, "sdn(m)", sep, "sdu(m)", sep, "sden(m)", sep, "sdnu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio"); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1752,8 +2072,14 @@ int outsols(unsigned char *buff, const sol_t *sol, const double *rb, if (opt->posf == SOLF_NMEA) { - if (opt->nmeaintv[0] < 0.0) return 0; - if (!screent(sol->time, ts, ts, opt->nmeaintv[0])) return 0; + if (opt->nmeaintv[0] < 0.0) + { + return 0; + } + if (!screent(sol->time, ts, ts, opt->nmeaintv[0])) + { + return 0; + } } if (sol->stat <= SOLQ_NONE || (opt->posf == SOLF_ENU && norm_rtk(rb, 3) <= 0.0)) { @@ -1762,11 +2088,19 @@ int outsols(unsigned char *buff, const sol_t *sol, const double *rb, timeu = opt->timeu < 0 ? 0 : (opt->timeu > 20 ? 20 : opt->timeu); time = sol->time; - if (opt->times >= TIMES_UTC) time = gpst2utc(time); - if (opt->times == TIMES_JST) time = timeadd(time, 9 * 3600.0); + if (opt->times >= TIMES_UTC) + { + time = gpst2utc(time); + } + if (opt->times == TIMES_JST) + { + time = timeadd(time, 9 * 3600.0); + } if (opt->timef) - time2str(time, s, timeu); + { + time2str(time, s, timeu); + } else { gpst = time2gpst(time, &week); @@ -1816,8 +2150,14 @@ int outsolexs(unsigned char *buff, const sol_t *sol, const ssat_t *ssat, if (opt->posf == SOLF_NMEA) { - if (opt->nmeaintv[1] < 0.0) return 0; - if (!screent(sol->time, ts, ts, opt->nmeaintv[1])) return 0; + if (opt->nmeaintv[1] < 0.0) + { + return 0; + } + if (!screent(sol->time, ts, ts, opt->nmeaintv[1])) + { + return 0; + } } if (opt->posf == SOLF_NMEA) { diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 6dafde2ac..48a1564e6 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -50,20 +50,22 @@ * *----------------------------------------------------------------------------*/ -#include -#include -#include -#include +#include "rtklib_stream.h" +#include "rtklib_rtkcmn.h" +#include "rtklib_solution.h" +#include +#include +#include +#include #include -#include +#include +#include +#include +#include #include #include -#include #include -#include -#include -#include -#include +#include /* global options ------------------------------------------------------------*/ @@ -89,47 +91,76 @@ serial_t *openserial(const char *path, int mode, char *msg) const speed_t bs[] = { B300, B600, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400}; - struct termios ios; + struct termios ios + { + }; int rw = 0; tracet(3, "openserial: path=%s mode=%d\n", path, mode); - if (!(serial = (serial_t *)malloc(sizeof(serial_t)))) return NULL; + if (!(serial = static_cast(malloc(sizeof(serial_t))))) + { + return nullptr; + } - if ((p = strchr((char *)path, ':'))) + if ((p = strchr(const_cast(path), ':'))) { strncpy(port, path, p - path); port[p - path] = '\0'; sscanf(p, ":%d:%d:%c:%d:%s", &brate, &bsize, &parity, &stopb, fctr); } else if (strlen(path) < 128) - strcpy(port, path); + { + strcpy(port, path); + } for (i = 0; i < 10; i++) - if (br[i] == brate) break; + { + if (br[i] == brate) + { + break; + } + } if (i >= 11) { sprintf(msg, "bitrate error (%d)", brate); tracet(1, "openserial: %s path=%s\n", msg, path); free(serial); - return NULL; + return nullptr; } - parity = (char)toupper((int)parity); + parity = static_cast(toupper(static_cast(parity))); - sprintf(dev, "/dev/%s", port); + // sprintf(dev, "/dev/%s", port); This line triggers a warning. Replaced by: + std::string s_aux = "/dev/" + std::string(port); + s_aux.resize(128, '\0'); + int n = s_aux.length(); + for (int i = 0; i < n; i++) + { + dev[i] = s_aux[i]; + } + if (n == 0) + { + dev[0] = '\0'; + } if ((mode & STR_MODE_R) && (mode & STR_MODE_W)) - rw = O_RDWR; + { + rw = O_RDWR; + } else if (mode & STR_MODE_R) - rw = O_RDONLY; + { + rw = O_RDONLY; + } else if (mode & STR_MODE_W) - rw = O_WRONLY; + { + rw = O_WRONLY; + } if ((serial->dev = open(dev, rw | O_NOCTTY | O_NONBLOCK)) < 0) { sprintf(msg, "device open error (%d)", errno); tracet(1, "openserial: %s dev=%s\n", msg, dev); free(serial); - return NULL; + return nullptr; } tcgetattr(serial->dev, &ios); ios.c_iflag = 0; @@ -152,7 +183,10 @@ serial_t *openserial(const char *path, int mode, char *msg) /* close serial --------------------------------------------------------------*/ void closeserial(serial_t *serial) { - if (!serial) return; + if (!serial) + { + return; + } tracet(3, "closeserial: dev=%d\n", serial->dev); close(serial->dev); free(serial); @@ -163,9 +197,15 @@ void closeserial(serial_t *serial) int readserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribute__((unused))) { int nr; - if (!serial) return 0; + if (!serial) + { + return 0; + } tracet(4, "readserial: dev=%d n=%d\n", serial->dev, n); - if ((nr = read(serial->dev, buff, n)) < 0) return 0; + if ((nr = read(serial->dev, buff, n)) < 0) + { + return 0; + } tracet(5, "readserial: exit dev=%d nr=%d\n", serial->dev, nr); return nr; } @@ -175,9 +215,15 @@ int readserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribu int writeserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribute__((unused))) { int ns; - if (!serial) return 0; + if (!serial) + { + return 0; + } tracet(3, "writeserial: dev=%d n=%d\n", serial->dev, n); - if ((ns = write(serial->dev, buff, n)) < 0) return 0; + if ((ns = write(serial->dev, buff, n)) < 0) + { + return 0; + } tracet(5, "writeserial: exit dev=%d ns=%d\n", serial->dev, ns); return ns; } @@ -218,9 +264,13 @@ int openfile_(file_t *file, gtime_t time, char *msg) createdir(file->openpath); } if (file->mode & STR_MODE_R) - rw = (char *)"rb"; + { + rw = (char *)"rb"; + } else - rw = (char *)"wb"; + { + rw = (char *)"wb"; + } if (!(file->fp = fopen(file->openpath, rw))) { @@ -271,10 +321,13 @@ int openfile_(file_t *file, gtime_t time, char *msg) } else if (file->mode & STR_MODE_W) { /* remove time-tag */ - if ((fp = fopen(tagpath, "rb"))) + if ((fp = fopen(tagpath, "rbe"))) { fclose(fp); - if (remove(tagpath) != 0) trace(1, "Error removing file"); + if (remove(tagpath) != 0) + { + trace(1, "Error removing file"); + } } } return 1; @@ -285,11 +338,23 @@ int openfile_(file_t *file, gtime_t time, char *msg) void closefile_(file_t *file) { tracet(3, "closefile_: path=%s\n", file->path); - if (file->fp) fclose(file->fp); - if (file->fp_tag) fclose(file->fp_tag); - if (file->fp_tmp) fclose(file->fp_tmp); - if (file->fp_tag_tmp) fclose(file->fp_tag_tmp); - file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = NULL; + if (file->fp) + { + fclose(file->fp); + } + if (file->fp_tag) + { + fclose(file->fp_tag); + } + if (file->fp_tmp) + { + fclose(file->fp_tmp); + } + if (file->fp_tag_tmp) + { + fclose(file->fp_tag_tmp); + } + file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; } @@ -304,28 +369,54 @@ file_t *openfile(const char *path, int mode, char *msg) tracet(3, "openfile: path=%s mode=%d\n", path, mode); - if (!(mode & (STR_MODE_R | STR_MODE_W))) return NULL; + if (!(mode & (STR_MODE_R | STR_MODE_W))) + { + return nullptr; + } /* file options */ - for (p = (char *)path; (p = strstr(p, "::")); p += 2) + for (p = const_cast(path); (p = strstr(p, "::")); p += 2) { /* file options */ if (*(p + 2) == 'T') - timetag = 1; + { + timetag = 1; + } else if (*(p + 2) == '+') - sscanf(p + 2, "+%lf", &start); + { + sscanf(p + 2, "+%lf", &start); + } else if (*(p + 2) == 'x') - sscanf(p + 2, "x%lf", &speed); + { + sscanf(p + 2, "x%lf", &speed); + } else if (*(p + 2) == 'S') - sscanf(p + 2, "S=%lf", &swapintv); + { + sscanf(p + 2, "S=%lf", &swapintv); + } + } + if (start <= 0.0) + { + start = 0.0; + } + if (swapintv <= 0.0) + { + swapintv = 0.0; } - if (start <= 0.0) start = 0.0; - if (swapintv <= 0.0) swapintv = 0.0; - if (!(file = (file_t *)malloc(sizeof(file_t)))) return NULL; + if (!(file = static_cast(malloc(sizeof(file_t))))) + { + return nullptr; + } - file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = NULL; - if (strlen(path) < MAXSTRPATH) strcpy(file->path, path); - if ((p = strstr(file->path, "::"))) *p = '\0'; + file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; + if (strlen(path) < MAXSTRPATH) + { + strcpy(file->path, path); + } + if ((p = strstr(file->path, "::"))) + { + *p = '\0'; + } file->openpath[0] = '\0'; file->mode = mode; file->timetag = timetag; @@ -344,7 +435,7 @@ file_t *openfile(const char *path, int mode, char *msg) if (!openfile_(file, time, msg)) { free(file); - return NULL; + return nullptr; } return file; } @@ -353,7 +444,10 @@ file_t *openfile(const char *path, int mode, char *msg) /* close file ----------------------------------------------------------------*/ void closefile(file_t *file) { - if (!file) return; + if (!file) + { + return; + } tracet(3, "closefile: fp=%d\n", file->fp); closefile_(file); free(file); @@ -368,7 +462,10 @@ void swapfile(file_t *file, gtime_t time, char *msg) tracet(3, "swapfile: fp=%d time=%s\n", file->fp, time_str(time, 0)); /* return if old swap file open */ - if (file->fp_tmp || file->fp_tag_tmp) return; + if (file->fp_tmp || file->fp_tag_tmp) + { + return; + } /* check path of new swap file */ reppath(file->path, openpath, time, "", ""); @@ -391,9 +488,15 @@ void swapfile(file_t *file, gtime_t time, char *msg) void swapclose(file_t *file) { tracet(3, "swapclose: fp_tmp=%d\n", file->fp_tmp); - if (file->fp_tmp) fclose(file->fp_tmp); - if (file->fp_tag_tmp) fclose(file->fp_tag_tmp); - file->fp_tmp = file->fp_tag_tmp = NULL; + if (file->fp_tmp) + { + fclose(file->fp_tmp); + } + if (file->fp_tag_tmp) + { + fclose(file->fp_tag_tmp); + } + file->fp_tmp = file->fp_tag_tmp = nullptr; } @@ -413,7 +516,10 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) int nr = 0; size_t fpos; - if (!file) return 0; + if (!file) + { + return 0; + } tracet(4, "readfile: fp=%d nmax=%d\n", file->fp, nmax); if (file->fp == stdin) @@ -421,48 +527,69 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) /* input from stdin */ FD_ZERO(&rs); FD_SET(0, &rs); - if (!select(1, &rs, NULL, NULL, &tv)) return 0; - if ((nr = read(0, buff, nmax)) < 0) return 0; + if (!select(1, &rs, nullptr, nullptr, &tv)) + { + return 0; + } + if ((nr = read(0, buff, nmax)) < 0) + { + return 0; + } return nr; } if (file->fp_tag) { if (file->repmode) { /* slave */ - t = (unsigned int)(tick_master + file->offset); + t = (tick_master + file->offset); } else { /* master */ - t = (unsigned int)((tickget() - file->tick) * file->speed + file->start * 1000.0); + t = static_cast((tickget() - file->tick) * file->speed + file->start * 1000.0); } for (;;) { /* seek file position */ if (fread(&tick, sizeof(tick), 1, file->fp_tag) < 1 || fread(&fpos, sizeof(fpos), 1, file->fp_tag) < 1) { - if (fseek(file->fp, 0, SEEK_END) != 0) trace(1, "fseek error"); + if (fseek(file->fp, 0, SEEK_END) != 0) + { + trace(1, "fseek error"); + } sprintf(msg, "end"); break; } if (file->repmode || file->speed > 0.0) { - if ((int)(tick - t) < 1) continue; + if (static_cast(tick - t) < 1) + { + continue; + } } - if (!file->repmode) tick_master = tick; - - sprintf(msg, "T%+.1fs", (int)tick < 0 ? 0.0 : (int)tick / 1000.0); - - if ((int)(fpos - file->fpos) >= nmax) + if (!file->repmode) { - if (fseek(file->fp, fpos, SEEK_SET) != 0) trace(1, "Error fseek"); + tick_master = tick; + } + + sprintf(msg, "T%+.1fs", static_cast(tick) < 0 ? 0.0 : static_cast(tick) / 1000.0); + + if (static_cast(fpos - file->fpos) >= nmax) + { + if (fseek(file->fp, fpos, SEEK_SET) != 0) + { + trace(1, "Error fseek"); + } file->fpos = fpos; return 0; } - nmax = (int)(fpos - file->fpos); + nmax = static_cast(fpos - file->fpos); if (file->repmode || file->speed > 0.0) { - if (fseek(file->fp_tag, -(long)(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) trace(1, "Error fseek"); + if (fseek(file->fp_tag, -static_cast(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) + { + trace(1, "Error fseek"); + } } break; } @@ -471,10 +598,13 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) { nr = fread(buff, 1, nmax, file->fp); file->fpos += nr; - if (nr <= 0) sprintf(msg, "end"); + if (nr <= 0) + { + sprintf(msg, "end"); + } } tracet(5, "readfile: fp=%d nr=%d fpos=%d\n", file->fp, nr, file->fpos); - return (int)nr; + return nr; } @@ -487,7 +617,10 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg) double tow1, tow2, intv; size_t fpos, fpos_tmp; - if (!file) return 0; + if (!file) + { + return 0; + } tracet(3, "writefile: fp=%d n=%d\n", file->fp, n); wtime = utc2gpst(timeget()); /* write time in gpst */ @@ -511,7 +644,10 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg) swapclose(file); } } - if (!file->fp) return 0; + if (!file->fp) + { + return 0; + } ns = fwrite(buff, 1, n, file->fp); fpos = ftell(file->fp); @@ -540,17 +676,20 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg) } tracet(5, "writefile: fp=%d ns=%d tick=%5d fpos=%d\n", file->fp, ns, tick, fpos); - return (int)ns; + return static_cast(ns); } /* sync files by time-tag ----------------------------------------------------*/ void syncfile(file_t *file1, file_t *file2) { - if (!file1->fp_tag || !file2->fp_tag) return; + if (!file1->fp_tag || !file2->fp_tag) + { + return; + } file1->repmode = 0; file2->repmode = 1; - file2->offset = (int)(file1->tick_f - file2->tick_f); + file2->offset = static_cast(file1->tick_f - file2->tick_f); } @@ -562,25 +701,52 @@ void decodetcppath(const char *path, char *addr, char *port, char *user, tracet(4, "decodetcpepath: path=%s\n", path); - if (port) *port = '\0'; - if (user) *user = '\0'; - if (passwd) *passwd = '\0'; - if (mntpnt) *mntpnt = '\0'; - if (str) *str = '\0'; + if (port) + { + *port = '\0'; + } + if (user) + { + *user = '\0'; + } + if (passwd) + { + *passwd = '\0'; + } + if (mntpnt) + { + *mntpnt = '\0'; + } + if (str) + { + *str = '\0'; + } - if (strlen(path) < MAXSTRPATH) strcpy(buff, path); + if (strlen(path) < MAXSTRPATH) + { + strcpy(buff, path); + } - if (!(p = strrchr(buff, '@'))) p = buff; + if (!(p = strrchr(buff, '@'))) + { + p = buff; + } if ((p = strchr(p, '/'))) { if ((q = strchr(p + 1, ':'))) { *q = '\0'; - if (str) strcpy(str, q + 1); + if (str) + { + strcpy(str, q + 1); + } } *p = '\0'; - if (mntpnt) strcpy(mntpnt, p + 1); + if (mntpnt) + { + strcpy(mntpnt, p + 1); + } } if ((p = strrchr(buff, '@'))) { @@ -588,19 +754,33 @@ void decodetcppath(const char *path, char *addr, char *port, char *user, if ((q = strchr(buff, ':'))) { *q = '\0'; - if (passwd) strcpy(passwd, q + 1); + if (passwd) + { + strcpy(passwd, q + 1); + } + } + if (user) + { + strcpy(user, buff); } - if (user) strcpy(user, buff); } else - p = buff; + { + p = buff; + } if ((q = strchr(p, ':'))) { *q = '\0'; - if (port) strcpy(port, q + 1); + if (port) + { + strcpy(port, q + 1); + } + } + if (addr) + { + strcpy(addr, p); } - if (addr) strcpy(addr, p); } @@ -616,21 +796,21 @@ int setsock(socket_t sock, char *msg) tracet(3, "setsock: sock=%d\n", sock); - if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)) == -1 || - setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(tv)) == -1) + if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&tv), sizeof(tv)) == -1 || + setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast(&tv), sizeof(tv)) == -1) { sprintf(msg, "sockopt error: notimeo"); tracet(1, "setsock: setsockopt error 1 sock=%d err=%d\n", sock, errsock()); closesocket(sock); return 0; } - if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *)&bs, sizeof(bs)) == -1 || - setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char *)&bs, sizeof(bs)) == -1) + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&bs), sizeof(bs)) == -1 || + setsockopt(sock, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&bs), sizeof(bs)) == -1) { tracet(1, "setsock: setsockopt error 2 sock=%d err=%d bs=%d\n", sock, errsock(), bs); sprintf(msg, "sockopt error: bufsiz"); } - if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&mode, sizeof(mode)) == -1) + if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&mode), sizeof(mode)) == -1) { tracet(1, "setsock: setsockopt error 3 sock=%d err=%d\n", sock, errsock()); sprintf(msg, "sockopt error: nodelay"); @@ -646,7 +826,10 @@ socket_t accept_nb(socket_t sock, struct sockaddr *addr, socklen_t *len) fd_set rs; FD_ZERO(&rs); FD_SET(sock, &rs); - if (!select(sock + 1, &rs, NULL, NULL, &tv)) return 0; + if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) + { + return 0; + } return accept(sock, addr, len); } @@ -659,15 +842,24 @@ int connect_nb(socket_t sock, struct sockaddr *addr, socklen_t len) int err, flag; flag = fcntl(sock, F_GETFL, 0); - if (fcntl(sock, F_SETFL, flag | O_NONBLOCK) == -1) trace(1, "fcntl error"); + if (fcntl(sock, F_SETFL, flag | O_NONBLOCK) == -1) + { + trace(1, "fcntl error"); + } if (connect(sock, addr, len) == -1) { err = errsock(); - if (err != EISCONN && err != EINPROGRESS && err != EALREADY) return -1; + if (err != EISCONN && err != EINPROGRESS && err != EALREADY) + { + return -1; + } FD_ZERO(&rs); FD_SET(sock, &rs); ws = rs; - if (select(sock + 1, &rs, &ws, NULL, &tv) == 0) return 0; + if (select(sock + 1, &rs, &ws, nullptr, &tv) == 0) + { + return 0; + } } return 1; } @@ -680,8 +872,11 @@ int recv_nb(socket_t sock, unsigned char *buff, int n) fd_set rs; FD_ZERO(&rs); FD_SET(sock, &rs); - if (!select(sock + 1, &rs, NULL, NULL, &tv)) return 0; - return recv(sock, (char *)buff, n, 0); + if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) + { + return 0; + } + return recv(sock, reinterpret_cast(buff), n, 0); } @@ -692,8 +887,11 @@ int send_nb(socket_t sock, unsigned char *buff, int n) fd_set ws; FD_ZERO(&ws); FD_SET(sock, &ws); - if (!select(sock + 1, NULL, &ws, NULL, &tv)) return 0; - return send(sock, (char *)buff, n, 0); + if (!select(sock + 1, nullptr, &ws, nullptr, &tv)) + { + return 0; + } + return send(sock, reinterpret_cast(buff), n, 0); } @@ -708,7 +906,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) tracet(3, "gentcp: type=%d\n", type); /* generate socket */ - if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == (socket_t)-1) + if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { sprintf(msg, "socket error (%d)", errsock()); tracet(1, "gentcp: socket error err=%d\n", errsock()); @@ -732,7 +930,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) setsockopt(tcp->sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt)); #endif - if (bind(tcp->sock, (struct sockaddr *)&tcp->addr, sizeof(tcp->addr)) == -1) + if (bind(tcp->sock, reinterpret_cast(&tcp->addr), sizeof(tcp->addr)) == -1) { sprintf(msg, "bind error (%d) : %d", errsock(), tcp->port); tracet(1, "gentcp: bind error port=%d err=%d\n", tcp->port, errsock()); @@ -779,23 +977,26 @@ tcpsvr_t *opentcpsvr(const char *path, char *msg) { tcpsvr_t *tcpsvr, tcpsvr0; // = {{0}}; char port[256] = ""; - tcpsvr0 = {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}, {0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}}; + tcpsvr0 = {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}, {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}}}; tracet(3, "opentcpsvr: path=%s\n", path); - if (!(tcpsvr = (tcpsvr_t *)malloc(sizeof(tcpsvr_t)))) return NULL; + if (!(tcpsvr = static_cast(malloc(sizeof(tcpsvr_t))))) + { + return nullptr; + } *tcpsvr = tcpsvr0; - decodetcppath(path, tcpsvr->svr.saddr, port, NULL, NULL, NULL, NULL); + decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpsvr->svr.port) < 1) { sprintf(msg, "port error: %s", port); tracet(1, "opentcpsvr: port error port=%s\n", port); free(tcpsvr); - return NULL; + return nullptr; } if (!gentcp(&tcpsvr->svr, 0, msg)) { free(tcpsvr); - return NULL; + return nullptr; } tcpsvr->svr.tcon = 0; return tcpsvr; @@ -809,7 +1010,10 @@ void closetcpsvr(tcpsvr_t *tcpsvr) tracet(3, "closetcpsvr:\n"); for (i = 0; i < MAXCLI; i++) { - if (tcpsvr->cli[i].state) closesocket(tcpsvr->cli[i].sock); + if (tcpsvr->cli[i].state) + { + closesocket(tcpsvr->cli[i].sock); + } } closesocket(tcpsvr->svr.sock); free(tcpsvr); @@ -824,14 +1028,23 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) tracet(3, "updatetcpsvr: state=%d\n", tcpsvr->svr.state); - if (tcpsvr->svr.state == 0) return; + if (tcpsvr->svr.state == 0) + { + return; + } for (i = 0; i < MAXCLI; i++) { - if (tcpsvr->cli[i].state) continue; + if (tcpsvr->cli[i].state) + { + continue; + } for (j = i + 1; j < MAXCLI; j++) { - if (!tcpsvr->cli[j].state) continue; + if (!tcpsvr->cli[j].state) + { + continue; + } tcpsvr->cli[i] = tcpsvr->cli[j]; tcpsvr->cli[j].state = 0; break; @@ -839,7 +1052,10 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) } for (i = 0; i < MAXCLI; i++) { - if (!tcpsvr->cli[i].state) continue; + if (!tcpsvr->cli[i].state) + { + continue; + } strcpy(saddr, tcpsvr->cli[i].saddr); n++; } @@ -851,16 +1067,22 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) } tcpsvr->svr.state = 2; if (n == 1) - sprintf(msg, "%s", saddr); + { + sprintf(msg, "%s", saddr); + } else - sprintf(msg, "%d clients", n); + { + sprintf(msg, "%d clients", n); + } } /* accept client connection --------------------------------------------------*/ int accsock(tcpsvr_t *tcpsvr, char *msg) { - struct sockaddr_in addr; + struct sockaddr_in addr + { + }; socket_t sock; socklen_t len = sizeof(addr); int i, err; @@ -868,10 +1090,18 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) tracet(3, "accsock: sock=%d\n", tcpsvr->svr.sock); for (i = 0; i < MAXCLI; i++) - if (tcpsvr->cli[i].state == 0) break; - if (i >= MAXCLI) return 0; /* too many client */ + { + if (tcpsvr->cli[i].state == 0) + { + break; + } + } + if (i >= MAXCLI) + { + return 0; /* too many client */ + } - if ((sock = accept_nb(tcpsvr->svr.sock, (struct sockaddr *)&addr, &len)) == (socket_t)-1) + if ((sock = accept_nb(tcpsvr->svr.sock, reinterpret_cast(&addr), &len)) == -1) { err = errsock(); sprintf(msg, "accept error (%d)", err); @@ -880,12 +1110,21 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) tcpsvr->svr.state = 0; return 0; } - if (sock == 0) return 0; + if (sock == 0) + { + return 0; + } tcpsvr->cli[i].sock = sock; - if (!setsock(tcpsvr->cli[i].sock, msg)) return 0; + if (!setsock(tcpsvr->cli[i].sock, msg)) + { + return 0; + } memcpy(&tcpsvr->cli[i].addr, &addr, sizeof(addr)); - if (strlen(inet_ntoa(addr.sin_addr)) < 256) strcpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr)); + if (strlen(inet_ntoa(addr.sin_addr)) < 256) + { + strcpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr)); + } sprintf(msg, "%s", tcpsvr->cli[i].saddr); tracet(2, "accsock: connected sock=%d addr=%s\n", tcpsvr->cli[i].sock, tcpsvr->cli[i].saddr); tcpsvr->cli[i].state = 2; @@ -898,9 +1137,14 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) int waittcpsvr(tcpsvr_t *tcpsvr, char *msg) { tracet(4, "waittcpsvr: sock=%d state=%d\n", tcpsvr->svr.sock, tcpsvr->svr.state); - if (tcpsvr->svr.state <= 0) return 0; + if (tcpsvr->svr.state <= 0) + { + return 0; + } while (accsock(tcpsvr, msg)) - ; + { + ; + } updatetcpsvr(tcpsvr, msg); return tcpsvr->svr.state == 2; } @@ -913,7 +1157,10 @@ int readtcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) tracet(4, "readtcpsvr: state=%d n=%d\n", tcpsvr->svr.state, n); - if (!waittcpsvr(tcpsvr, msg) || tcpsvr->cli[0].state != 2) return 0; + if (!waittcpsvr(tcpsvr, msg) || tcpsvr->cli[0].state != 2) + { + return 0; + } if ((nr = recv_nb(tcpsvr->cli[0].sock, buff, n)) == -1) { @@ -924,7 +1171,10 @@ int readtcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) updatetcpsvr(tcpsvr, msg); return 0; } - if (nr > 0) tcpsvr->cli[0].tact = tickget(); + if (nr > 0) + { + tcpsvr->cli[0].tact = tickget(); + } tracet(5, "readtcpsvr: exit sock=%d nr=%d\n", tcpsvr->cli[0].sock, nr); return nr; } @@ -937,11 +1187,17 @@ int writetcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) tracet(3, "writetcpsvr: state=%d n=%d\n", tcpsvr->svr.state, n); - if (!waittcpsvr(tcpsvr, msg)) return 0; + if (!waittcpsvr(tcpsvr, msg)) + { + return 0; + } for (i = 0; i < MAXCLI; i++) { - if (tcpsvr->cli[i].state != 2) continue; + if (tcpsvr->cli[i].state != 2) + { + continue; + } if ((ns = send_nb(tcpsvr->cli[i].sock, buff, n)) == -1) { @@ -952,7 +1208,10 @@ int writetcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) updatetcpsvr(tcpsvr, msg); return 0; } - if (ns > 0) tcpsvr->cli[i].tact = tickget(); + if (ns > 0) + { + tcpsvr->cli[i].tact = tickget(); + } tracet(5, "writetcpsvr: send i=%d ns=%d\n", i, ns); } return ns; @@ -975,12 +1234,12 @@ int consock(tcpcli_t *tcpcli, char *msg) /* wait re-connect */ if (tcpcli->svr.tcon < 0 || (tcpcli->svr.tcon > 0 && - (int)(tickget() - tcpcli->svr.tdis) < tcpcli->svr.tcon)) + static_cast(tickget() - tcpcli->svr.tdis) < tcpcli->svr.tcon)) { return 0; } /* non-block connect */ - if ((stat = connect_nb(tcpcli->svr.sock, (struct sockaddr *)&tcpcli->svr.addr, + if ((stat = connect_nb(tcpcli->svr.sock, reinterpret_cast(&tcpcli->svr.addr), sizeof(tcpcli->svr.addr))) == -1) { err = errsock(); @@ -1012,15 +1271,18 @@ tcpcli_t *opentcpcli(const char *path, char *msg) tracet(3, "opentcpcli: path=%s\n", path); - if (!(tcpcli = (tcpcli_t *)malloc(sizeof(tcpcli_t)))) return NULL; + if (!(tcpcli = static_cast(malloc(sizeof(tcpcli_t))))) + { + return nullptr; + } *tcpcli = tcpcli0; - decodetcppath(path, tcpcli->svr.saddr, port, NULL, NULL, NULL, NULL); + decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpcli->svr.port) < 1) { sprintf(msg, "port error: %s", port); tracet(1, "opentcp: port error port=%s\n", port); free(tcpcli); - return NULL; + return nullptr; } tcpcli->svr.tcon = 0; tcpcli->toinact = toinact; @@ -1043,20 +1305,29 @@ int waittcpcli(tcpcli_t *tcpcli, char *msg) { tracet(4, "waittcpcli: sock=%d state=%d\n", tcpcli->svr.sock, tcpcli->svr.state); - if (tcpcli->svr.state < 0) return 0; + if (tcpcli->svr.state < 0) + { + return 0; + } if (tcpcli->svr.state == 0) { /* close */ - if (!gentcp(&tcpcli->svr, 1, msg)) return 0; + if (!gentcp(&tcpcli->svr, 1, msg)) + { + return 0; + } } if (tcpcli->svr.state == 1) { /* wait */ - if (!consock(tcpcli, msg)) return 0; + if (!consock(tcpcli, msg)) + { + return 0; + } } if (tcpcli->svr.state == 2) { /* connect */ if (tcpcli->toinact > 0 && - (int)(tickget() - tcpcli->svr.tact) > tcpcli->toinact) + static_cast(tickget() - tcpcli->svr.tact) > tcpcli->toinact) { sprintf(msg, "timeout"); tracet(2, "waittcpcli: inactive timeout sock=%d\n", tcpcli->svr.sock); @@ -1075,7 +1346,10 @@ int readtcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) tracet(4, "readtcpcli: sock=%d state=%d n=%d\n", tcpcli->svr.sock, tcpcli->svr.state, n); - if (!waittcpcli(tcpcli, msg)) return 0; + if (!waittcpcli(tcpcli, msg)) + { + return 0; + } if ((nr = recv_nb(tcpcli->svr.sock, buff, n)) == -1) { @@ -1085,7 +1359,10 @@ int readtcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) discontcp(&tcpcli->svr, tcpcli->tirecon); return 0; } - if (nr > 0) tcpcli->svr.tact = tickget(); + if (nr > 0) + { + tcpcli->svr.tact = tickget(); + } tracet(5, "readtcpcli: exit sock=%d nr=%d\n", tcpcli->svr.sock, nr); return nr; } @@ -1098,7 +1375,10 @@ int writetcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) tracet(3, "writetcpcli: sock=%d state=%d n=%d\n", tcpcli->svr.sock, tcpcli->svr.state, n); - if (!waittcpcli(tcpcli, msg)) return 0; + if (!waittcpcli(tcpcli, msg)) + { + return 0; + } if ((ns = send_nb(tcpcli->svr.sock, buff, n)) == -1) { @@ -1108,7 +1388,10 @@ int writetcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) discontcp(&tcpcli->svr, tcpcli->tirecon); return 0; } - if (ns > 0) tcpcli->svr.tact = tickget(); + if (ns > 0) + { + tcpcli->svr.tact = tickget(); + } tracet(5, "writetcpcli: exit sock=%d ns=%d\n", tcpcli->svr.sock, ns); return ns; } @@ -1135,11 +1418,17 @@ int encbase64(char *str, const unsigned char *byte, int n) for (k = b = 0; k < 6; k++, i++) { b <<= 1; - if (i / 8 < n) b |= (byte[i / 8] >> (7 - i % 8)) & 0x1; + if (i / 8 < n) + { + b |= (byte[i / 8] >> (7 - i % 8)) & 0x1; + } } str[j++] = table[b]; } - while (j & 0x3) str[j++] = '='; + while (j & 0x3) + { + str[j++] = '='; + } str[j] = '\0'; tracet(5, "encbase64: str=%s\n", str); return j; @@ -1158,7 +1447,10 @@ int reqntrip_s(ntrip_t *ntrip, char *msg) p += sprintf(p, "STR: %s\r\n", ntrip->str); p += sprintf(p, "\r\n"); - if (writetcpcli(ntrip->tcp, (unsigned char *)buff, p - buff, msg) != p - buff) return 0; + if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) + { + return 0; + } tracet(2, "reqntrip_s: send request state=%d ns=%d\n", ntrip->state, p - buff); tracet(5, "reqntrip_s: n=%d buff=\n%s\n", p - buff, buff); @@ -1186,12 +1478,15 @@ int reqntrip_c(ntrip_t *ntrip, char *msg) { sprintf(user, "%s:%s", ntrip->user, ntrip->passwd); p += sprintf(p, "Authorization: Basic "); - p += encbase64(p, (unsigned char *)user, strlen(user)); + p += encbase64(p, reinterpret_cast(user), strlen(user)); p += sprintf(p, "\r\n"); } p += sprintf(p, "\r\n"); - if (writetcpcli(ntrip->tcp, (unsigned char *)buff, p - buff, msg) != p - buff) return 0; + if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) + { + return 0; + } tracet(2, "reqntrip_c: send request state=%d ns=%d\n", ntrip->state, p - buff); tracet(5, "reqntrip_c: n=%d buff=\n%s\n", p - buff, buff); @@ -1210,21 +1505,31 @@ int rspntrip_s(ntrip_t *ntrip, char *msg) ntrip->buff[ntrip->nb] = '0'; tracet(5, "rspntrip_s: n=%d buff=\n%s\n", ntrip->nb, ntrip->buff); - if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_OK_SVR))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_OK_SVR))) { /* ok */ - q = (char *)ntrip->buff; + q = reinterpret_cast(ntrip->buff); p += strlen(NTRIP_RSP_OK_SVR); ntrip->nb -= p - q; - for (i = 0; i < ntrip->nb; i++) *q++ = *p++; + for (i = 0; i < ntrip->nb; i++) + { + *q++ = *p++; + } ntrip->state = 2; sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb); return 1; } - else if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_ERROR))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_ERROR))) { /* error */ nb = ntrip->nb < MAXSTATMSG ? ntrip->nb : MAXSTATMSG; - strncpy(msg, (char *)ntrip->buff, nb); + // strncpy(msg, (char *)ntrip->buff, nb); This line triggers a warning. Replaced by; + std::string s_aux(reinterpret_cast(ntrip->buff)); + s_aux.resize(nb, '\0'); + for (int i = 0; i < nb; i++) + { + msg[i] = s_aux[i]; + } + msg[nb] = 0; tracet(1, "rspntrip_s: %s nb=%d\n", msg, ntrip->nb); ntrip->nb = 0; @@ -1256,18 +1561,21 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) ntrip->buff[ntrip->nb] = '0'; tracet(5, "rspntrip_c: n=%d buff=\n%s\n", ntrip->nb, ntrip->buff); - if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_OK_CLI))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_OK_CLI))) { /* ok */ - q = (char *)ntrip->buff; + q = reinterpret_cast(ntrip->buff); p += strlen(NTRIP_RSP_OK_CLI); ntrip->nb -= p - q; - for (i = 0; i < ntrip->nb; i++) *q++ = *p++; + for (i = 0; i < ntrip->nb; i++) + { + *q++ = *p++; + } ntrip->state = 2; sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); tracet(2, "rspntrip_c: response ok nb=%d\n", ntrip->nb); return 1; } - if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_SRCTBL))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_SRCTBL))) { /* source table */ if (!*ntrip->mntpnt) { /* source table request */ @@ -1283,12 +1591,16 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) ntrip->state = 0; discontcp(&ntrip->tcp->svr, ntrip->tcp->tirecon); } - else if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_HTTP))) + else if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_HTTP))) { /* http response */ if ((q = strchr(p, '\r'))) - *q = '\0'; + { + *q = '\0'; + } else - ntrip->buff[128] = '\0'; + { + ntrip->buff[128] = '\0'; + } strcpy(msg, p); tracet(1, "rspntrip_s: %s nb=%d\n", msg, ntrip->nb); ntrip->nb = 0; @@ -1318,9 +1630,15 @@ int waitntrip(ntrip_t *ntrip, char *msg) tracet(4, "waitntrip: state=%d nb=%d\n", ntrip->state, ntrip->nb); - if (ntrip->state < 0) return 0; /* error */ + if (ntrip->state < 0) + { + return 0; /* error */ + } - if (ntrip->tcp->svr.state < 2) ntrip->state = 0; /* tcp disconnected */ + if (ntrip->tcp->svr.state < 2) + { + ntrip->state = 0; /* tcp disconnected */ + } if (ntrip->state == 0) { /* send request */ @@ -1332,8 +1650,8 @@ int waitntrip(ntrip_t *ntrip, char *msg) } if (ntrip->state == 1) { /* read response */ - p = (char *)ntrip->buff + ntrip->nb; - if ((n = readtcpcli(ntrip->tcp, (unsigned char *)p, NTRIP_MAXRSP - ntrip->nb - 1, msg)) == 0) + p = reinterpret_cast(ntrip->buff) + ntrip->nb; + if ((n = readtcpcli(ntrip->tcp, reinterpret_cast(p), NTRIP_MAXRSP - ntrip->nb - 1, msg)) == 0) { tracet(5, "waitntrip: readtcp n=%d\n", n); return 0; @@ -1357,14 +1675,20 @@ ntrip_t *openntrip(const char *path, int type, char *msg) tracet(3, "openntrip: path=%s type=%d\n", path, type); - if (!(ntrip = (ntrip_t *)malloc(sizeof(ntrip_t)))) return NULL; + if (!(ntrip = static_cast(malloc(sizeof(ntrip_t))))) + { + return nullptr; + } ntrip->state = 0; ntrip->type = type; /* 0:server, 1:client */ ntrip->nb = 0; ntrip->url[0] = '\0'; ntrip->mntpnt[0] = ntrip->user[0] = ntrip->passwd[0] = ntrip->str[0] = '\0'; - for (i = 0; i < NTRIP_MAXRSP; i++) ntrip->buff[i] = 0; + for (i = 0; i < NTRIP_MAXRSP; i++) + { + ntrip->buff[i] = 0; + } /* decode tcp/ntrip path */ decodetcppath(path, addr, port, ntrip->user, ntrip->passwd, ntrip->mntpnt, @@ -1380,7 +1704,16 @@ ntrip_t *openntrip(const char *path, int type, char *msg) /* ntrip access via proxy server */ if (*proxyaddr) { - sprintf(ntrip->url, "http://%s", tpath); + // sprintf(ntrip->url, "http://%s", tpath); This line triggers a warning. Replaced by: + std::string s_aux = "http://" + std::string(tpath); + int n = s_aux.length(); + if (n < 256) + { + for (int k = 0; k < n; k++) + { + ntrip->url[k] = s_aux[k]; + } + } strcpy(tpath, proxyaddr); } /* open tcp client stream */ @@ -1388,7 +1721,7 @@ ntrip_t *openntrip(const char *path, int type, char *msg) { tracet(1, "openntrip: opentcp error\n"); free(ntrip); - return NULL; + return nullptr; } return ntrip; } @@ -1410,7 +1743,10 @@ int readntrip(ntrip_t *ntrip, unsigned char *buff, int n, char *msg) tracet(4, "readntrip: n=%d\n", n); - if (!waitntrip(ntrip, msg)) return 0; + if (!waitntrip(ntrip, msg)) + { + return 0; + } if (ntrip->nb > 0) { /* read response buffer first */ nb = ntrip->nb <= n ? ntrip->nb : n; @@ -1427,7 +1763,10 @@ int writentrip(ntrip_t *ntrip, unsigned char *buff, int n, char *msg) { tracet(3, "writentrip: n=%d\n", n); - if (!waitntrip(ntrip, msg)) return 0; + if (!waitntrip(ntrip, msg)) + { + return 0; + } return writetcpcli(ntrip->tcp, buff, n, msg); } @@ -1447,8 +1786,14 @@ void decodeftppath(const char *path, char *addr, char *file, char *user, tracet(4, "decodeftpath: path=%s\n", path); - if (user) *user = '\0'; - if (passwd) *passwd = '\0'; + if (user) + { + *user = '\0'; + } + if (passwd) + { + *passwd = '\0'; + } if (topts) { topts[0] = 0; /* time offset in path (s) */ @@ -1456,20 +1801,28 @@ void decodeftppath(const char *path, char *addr, char *file, char *user, topts[2] = 0; /* download time offset (s) */ topts[3] = 0; /* retry interval (s) (0: no retry) */ } - if (strlen(path) < MAXSTRPATH) strcpy(buff, path); + if (strlen(path) < MAXSTRPATH) + { + strcpy(buff, path); + } if ((p = strchr(buff, '/'))) { if ((q = strstr(p + 1, "::"))) { *q = '\0'; - if (topts) sscanf(q + 2, "T=%d, %d, %d, %d", topts, topts + 1, topts + 2, topts + 3); + if (topts) + { + sscanf(q + 2, "T=%d, %d, %d, %d", topts, topts + 1, topts + 2, topts + 3); + } } strcpy(file, p + 1); *p = '\0'; } else - file[0] = '\0'; + { + file[0] = '\0'; + } if ((p = strrchr(buff, '@'))) { @@ -1477,13 +1830,20 @@ void decodeftppath(const char *path, char *addr, char *file, char *user, if ((q = strchr(buff, ':'))) { *q = '\0'; - if (passwd) strcpy(passwd, q + 1); + if (passwd) + { + strcpy(passwd, q + 1); + } + } + if (user) + { + strcpy(user, buff); } - *q = '\0'; - if (user) strcpy(user, buff); } else - p = buff; + { + p = buff; + } strcpy(addr, p); } @@ -1521,7 +1881,7 @@ gtime_t nextdltime(const int *topts, int stat) /* ftp thread ----------------------------------------------------------------*/ void *ftpthread(void *arg) { - ftp_t *ftp = (ftp_t *)arg; + auto *ftp = static_cast(arg); FILE *fp; gtime_t time; char remote[1024], local[1024], tmpfile[1024], errfile[1024], *p; @@ -1535,18 +1895,41 @@ void *ftpthread(void *arg) tracet(1, "no local directory\n"); ftp->error = 11; ftp->state = 3; - return 0; + return nullptr; } /* replace keyword in file path and local path */ time = timeadd(utc2gpst(timeget()), ftp->topts[0]); reppath(ftp->file, remote, time, "", ""); if ((p = strrchr(remote, '/'))) - p++; + { + p++; + } else - p = remote; - sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p); - sprintf(errfile, "%s.err", local); + { + p = remote; + } + // sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p); This line triggers a warning. Replaced by: + std::string s_aux = std::string(localdir) + std::to_string(FILEPATHSEP) + std::string(p); + int n = s_aux.length(); + if (n < 1024) + { + for (int i = 0; i < n; i++) + { + local[i] = s_aux[i]; + } + } + + // sprintf(errfile, "%s.err", local); This line triggers a warning. Replaced by: + std::string s_aux2 = std::string(local) + ".err"; + n = s_aux2.length(); + if (n < 1024) + { + for (int i = 0; i < n; i++) + { + errfile[i] = s_aux2[i]; + } + } /* if local file exist, skip download */ strcpy(tmpfile, local); @@ -1556,13 +1939,13 @@ void *ftpthread(void *arg) { *p = '\0'; } - if ((fp = fopen(tmpfile, "rb"))) + if ((fp = fopen(tmpfile, "rbe"))) { fclose(fp); strcpy(ftp->local, tmpfile); tracet(3, "ftpthread: file exists %s\n", ftp->local); ftp->state = 2; - return 0; + return nullptr; } /* proxy settings for wget (ref [2]) */ if (*proxyaddr) @@ -1574,27 +1957,66 @@ void *ftpthread(void *arg) /* download command (ref [2]) */ if (ftp->proto == 0) { /* ftp */ - sprintf(opt, "--ftp-user=%s --ftp-password=%s --glob=off --passive-ftp %s-t 1 -T %d -O \"%s\"", - ftp->user, ftp->passwd, proxyopt, FTP_TIMEOUT, local); - sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, - remote, errfile); + // sprintf(opt, "--ftp-user=%s --ftp-password=%s --glob=off --passive-ftp %s-t 1 -T %d -O \"%s\"", + // ftp->user, ftp->passwd, proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by: + std::string s_aux = "--ftp-user=" + std::string(ftp->user) + " --ftp-password=" + std::string(ftp->passwd) + + " --glob=off --passive-ftp " + std::string(proxyopt) + "s-t 1 -T " + std::to_string(FTP_TIMEOUT) + + " -O \"" + std::string(local) + "\""; + int k = s_aux.length(); + if (k < 1024) + { + for (int i = 0; i < k; i++) + { + opt[i] = s_aux[i]; + } + } + + // sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, + // remote, errfile); This line triggers a warning. Replaced by: + std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + + "\"ftp://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; + k = s_aux2.length(); + for (int i = 0; (i < k) && (i < 1024); i++) + { + cmd[i] = s_aux2[i]; + } } else { /* http */ - sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local); - sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, - remote, errfile); + // sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by: + std::string s_aux = std::string(proxyopt) + " -t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\""; + int l = s_aux.length(); + for (int i = 0; (i < l) && (i < 1024); i++) + { + opt[i] = s_aux[i]; + } + + // sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, + // remote, errfile); This line triggers a warning. Replaced by: + std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + + "\"http://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; + l = s_aux2.length(); + for (int i = 0; (i < l) && (i < 1024); i++) + { + cmd[i] = s_aux2[i]; + } } /* execute download command */ if ((ret = execcmd(cmd))) { - if (remove(local) != 0) trace(1, "Error removing file"); + if (remove(local) != 0) + { + trace(1, "Error removing file"); + } tracet(1, "execcmd error: cmd=%s ret=%d\n", cmd, ret); ftp->error = ret; ftp->state = 3; - return 0; + return nullptr; + } + if (remove(errfile) != 0) + { + trace(1, "Error removing file"); } - if (remove(errfile) != 0) trace(1, "Error removing file"); /* uncompress downloaded file */ if ((p = strrchr(local, '.')) && @@ -1603,22 +2025,31 @@ void *ftpthread(void *arg) { if (rtk_uncompress(local, tmpfile)) { - if (remove(local) != 0) trace(1, "Error removing file"); - if (strlen(tmpfile) < 1024) strcpy(local, tmpfile); + if (remove(local) != 0) + { + trace(1, "Error removing file"); + } + if (strlen(tmpfile) < 1024) + { + strcpy(local, tmpfile); + } } else { tracet(1, "file uncompact error: %s\n", local); ftp->error = 12; ftp->state = 3; - return 0; + return nullptr; } } - if (strlen(local) < 1024) strcpy(ftp->local, local); + if (strlen(local) < 1024) + { + strcpy(ftp->local, local); + } ftp->state = 2; /* ftp completed */ tracet(3, "ftpthread: complete cmd=%s\n", cmd); - return 0; + return nullptr; } @@ -1631,12 +2062,15 @@ ftp_t *openftp(const char *path, int type, char *msg) msg[0] = '\0'; - if (!(ftp = (ftp_t *)malloc(sizeof(ftp_t)))) return NULL; + if (!(ftp = static_cast(malloc(sizeof(ftp_t))))) + { + return nullptr; + } ftp->state = 0; ftp->proto = type; ftp->error = 0; - ftp->thread = 0; + ftp->thread = 0; // NOLINT ftp->local[0] = '\0'; /* decode ftp path */ @@ -1654,7 +2088,10 @@ void closeftp(ftp_t *ftp) { tracet(3, "closeftp: state=%d\n", ftp->state); - if (ftp->state != 1) free(ftp); + if (ftp->state != 1) + { + free(ftp); + } } @@ -1677,7 +2114,7 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) ftp->state = 1; sprintf(msg, "%s://%s", ftp->proto ? "http" : "ftp", ftp->addr); - if (pthread_create(&ftp->thread, NULL, ftpthread, ftp)) + if (pthread_create(&ftp->thread, nullptr, ftpthread, ftp)) { tracet(1, "readftp: ftp thread create error\n"); ftp->state = 3; @@ -1685,7 +2122,10 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) return 0; } } - if (ftp->state <= 1) return 0; /* ftp/http on going? */ + if (ftp->state <= 1) + { + return 0; /* ftp/http on going? */ + } if (ftp->state == 3) { /* ftp error */ @@ -1698,9 +2138,12 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) } /* return local file path if ftp completed */ p = buff; - q = (unsigned char *)ftp->local; - while (*q && (int)(p - buff) < n) *p++ = *q++; - p += sprintf((char *)p, "\r\n"); + q = reinterpret_cast(ftp->local); + while (*q && static_cast(p - buff) < n) + { + *p++ = *q++; + } + p += sprintf(reinterpret_cast(p), "\r\n"); /* set next download time */ ftp->tnext = nextdltime(ftp->topts, 1); @@ -1708,7 +2151,7 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) strcpy(msg, ""); - return (int)(p - buff); + return static_cast(p - buff); } @@ -1745,7 +2188,7 @@ void strinit(stream_t *stream) stream->inb = stream->inr = stream->outb = stream->outr = 0; stream->tick = stream->tact = stream->inbt = stream->outbt = 0; initlock(&stream->lock); - stream->port = NULL; + stream->port = nullptr; stream->path[0] = '\0'; stream->msg[0] = '\0'; } @@ -1792,12 +2235,15 @@ int stropen(stream_t *stream, int type, int mode, const char *path) stream->type = type; stream->mode = mode; - if (strlen(path) < MAXSTRPATH) strcpy(stream->path, path); + if (strlen(path) < MAXSTRPATH) + { + strcpy(stream->path, path); + } stream->inb = stream->inr = stream->outb = stream->outr = 0; stream->tick = tickget(); stream->inbt = stream->outbt = 0; stream->msg[0] = '\0'; - stream->port = NULL; + stream->port = nullptr; switch (type) { case STR_SERIAL: @@ -1829,7 +2275,7 @@ int stropen(stream_t *stream, int type, int mode, const char *path) return 1; } stream->state = !stream->port ? -1 : 1; - return stream->port != NULL; + return stream->port != nullptr; } @@ -1847,28 +2293,28 @@ void strclose(stream_t *stream) switch (stream->type) { case STR_SERIAL: - closeserial((serial_t *)stream->port); + closeserial(static_cast(stream->port)); break; case STR_FILE: - closefile((file_t *)stream->port); + closefile(static_cast(stream->port)); break; case STR_TCPSVR: - closetcpsvr((tcpsvr_t *)stream->port); + closetcpsvr(static_cast(stream->port)); break; case STR_TCPCLI: - closetcpcli((tcpcli_t *)stream->port); + closetcpcli(static_cast(stream->port)); break; case STR_NTRIPSVR: - closentrip((ntrip_t *)stream->port); + closentrip(static_cast(stream->port)); break; case STR_NTRIPCLI: - closentrip((ntrip_t *)stream->port); + closentrip(static_cast(stream->port)); break; case STR_FTP: - closeftp((ftp_t *)stream->port); + closeftp(static_cast(stream->port)); break; case STR_HTTP: - closeftp((ftp_t *)stream->port); + closeftp(static_cast(stream->port)); break; } } @@ -1882,7 +2328,7 @@ void strclose(stream_t *stream) stream->inr = stream->outr = 0; stream->path[0] = '\0'; stream->msg[0] = '\0'; - stream->port = NULL; + stream->port = nullptr; } @@ -1896,10 +2342,16 @@ void strclose(stream_t *stream) void strsync(stream_t *stream1, stream_t *stream2) { file_t *file1, *file2; - if (stream1->type != STR_FILE || stream2->type != STR_FILE) return; - file1 = (file_t *)stream1->port; - file2 = (file_t *)stream2->port; - if (file1 && file2) syncfile(file1, file2); + if (stream1->type != STR_FILE || stream2->type != STR_FILE) + { + return; + } + file1 = static_cast(stream1->port); + file2 = static_cast(stream2->port); + if (file1 && file2) + { + syncfile(file1, file2); + } } @@ -1929,32 +2381,35 @@ int strread(stream_t *stream, unsigned char *buff, int n) tracet(4, "strread: n=%d\n", n); - if (!(stream->mode & STR_MODE_R) || !stream->port) return 0; + if (!(stream->mode & STR_MODE_R) || !stream->port) + { + return 0; + } strlock(stream); switch (stream->type) { case STR_SERIAL: - nr = readserial((serial_t *)stream->port, buff, n, msg); + nr = readserial(static_cast(stream->port), buff, n, msg); break; case STR_FILE: - nr = readfile((file_t *)stream->port, buff, n, msg); + nr = readfile(static_cast(stream->port), buff, n, msg); break; case STR_TCPSVR: - nr = readtcpsvr((tcpsvr_t *)stream->port, buff, n, msg); + nr = readtcpsvr(static_cast(stream->port), buff, n, msg); break; case STR_TCPCLI: - nr = readtcpcli((tcpcli_t *)stream->port, buff, n, msg); + nr = readtcpcli(static_cast(stream->port), buff, n, msg); break; case STR_NTRIPCLI: - nr = readntrip((ntrip_t *)stream->port, buff, n, msg); + nr = readntrip(static_cast(stream->port), buff, n, msg); break; case STR_FTP: - nr = readftp((ftp_t *)stream->port, buff, n, msg); + nr = readftp(static_cast(stream->port), buff, n, msg); break; case STR_HTTP: - nr = readftp((ftp_t *)stream->port, buff, n, msg); + nr = readftp(static_cast(stream->port), buff, n, msg); break; default: strunlock(stream); @@ -1962,9 +2417,12 @@ int strread(stream_t *stream, unsigned char *buff, int n) } stream->inb += nr; tick = tickget(); - if (nr > 0) stream->tact = tick; + if (nr > 0) + { + stream->tact = tick; + } - if ((int)(tick - stream->tick) >= tirate) + if (static_cast(tick - stream->tick) >= tirate) { stream->inr = (stream->inb - stream->inbt) * 8000 / (tick - stream->tick); stream->tick = tick; @@ -1991,27 +2449,30 @@ int strwrite(stream_t *stream, unsigned char *buff, int n) tracet(3, "strwrite: n=%d\n", n); - if (!(stream->mode & STR_MODE_W) || !stream->port) return 0; + if (!(stream->mode & STR_MODE_W) || !stream->port) + { + return 0; + } strlock(stream); switch (stream->type) { case STR_SERIAL: - ns = writeserial((serial_t *)stream->port, buff, n, msg); + ns = writeserial(static_cast(stream->port), buff, n, msg); break; case STR_FILE: - ns = writefile((file_t *)stream->port, buff, n, msg); + ns = writefile(static_cast(stream->port), buff, n, msg); break; case STR_TCPSVR: - ns = writetcpsvr((tcpsvr_t *)stream->port, buff, n, msg); + ns = writetcpsvr(static_cast(stream->port), buff, n, msg); break; case STR_TCPCLI: - ns = writetcpcli((tcpcli_t *)stream->port, buff, n, msg); + ns = writetcpcli(static_cast(stream->port), buff, n, msg); break; case STR_NTRIPCLI: case STR_NTRIPSVR: - ns = writentrip((ntrip_t *)stream->port, buff, n, msg); + ns = writentrip(static_cast(stream->port), buff, n, msg); break; case STR_FTP: case STR_HTTP: @@ -2021,9 +2482,12 @@ int strwrite(stream_t *stream, unsigned char *buff, int n) } stream->outb += ns; tick = tickget(); - if (ns > 0) stream->tact = tick; + if (ns > 0) + { + stream->tact = tick; + } - if ((int)(tick - stream->tick) > tirate) + if (static_cast(tick - stream->tick) > tirate) { stream->outr = (stream->outb - stream->outbt) * 8000 / (tick - stream->tick); stream->tick = tick; @@ -2049,7 +2513,13 @@ int strstat(stream_t *stream, char *msg) strlock(stream); if (msg) { - strncpy(msg, stream->msg, MAXSTRMSG - 1); + // strncpy(msg, stream->msg, MAXSTRMSG - 1); This line triggers a warning. Replaced by: + std::string aux_s(stream->msg); + aux_s.resize(MAXSTRMSG - 1, '0'); + for (int i = 0; i < MAXSTRMSG - 1; i++) + { + msg[i] = aux_s[i]; + } msg[MAXSTRMSG - 1] = '\0'; } if (!stream->port) @@ -2060,32 +2530,35 @@ int strstat(stream_t *stream, char *msg) switch (stream->type) { case STR_SERIAL: - state = stateserial((serial_t *)stream->port); + state = stateserial(static_cast(stream->port)); break; case STR_FILE: - state = statefile((file_t *)stream->port); + state = statefile(static_cast(stream->port)); break; case STR_TCPSVR: - state = statetcpsvr((tcpsvr_t *)stream->port); + state = statetcpsvr(static_cast(stream->port)); break; case STR_TCPCLI: - state = statetcpcli((tcpcli_t *)stream->port); + state = statetcpcli(static_cast(stream->port)); break; case STR_NTRIPSVR: case STR_NTRIPCLI: - state = statentrip((ntrip_t *)stream->port); + state = statentrip(static_cast(stream->port)); break; case STR_FTP: - state = stateftp((ftp_t *)stream->port); + state = stateftp(static_cast(stream->port)); break; case STR_HTTP: - state = stateftp((ftp_t *)stream->port); + state = stateftp(static_cast(stream->port)); break; default: strunlock(stream); return 0; } - if (state == 2 && (int)(tickget() - stream->tact) <= TINTACT) state = 3; + if (state == 2 && static_cast(tickget() - stream->tact) <= TINTACT) + { + state = 3; + } strunlock(stream); return state; } @@ -2105,10 +2578,22 @@ void strsum(stream_t *stream, int *inb, int *inr, int *outb, int *outr) tracet(4, "strsum:\n"); strlock(stream); - if (inb) *inb = stream->inb; - if (inr) *inr = stream->inr; - if (outb) *outb = stream->outb; - if (outr) *outr = stream->outr; + if (inb) + { + *inb = stream->inb; + } + if (inr) + { + *inr = stream->inr; + } + if (outb) + { + *outb = stream->outb; + } + if (outr) + { + *outr = stream->outr; + } strunlock(stream); } @@ -2154,14 +2639,16 @@ void strsettimeout(stream_t *stream, int toinact, int tirecon) if (stream->type == STR_TCPCLI) { - tcpcli = (tcpcli_t *)stream->port; + tcpcli = static_cast(stream->port); } else if (stream->type == STR_NTRIPCLI || stream->type == STR_NTRIPSVR) { - tcpcli = ((ntrip_t *)stream->port)->tcp; + tcpcli = (static_cast(stream->port))->tcp; } else - return; + { + return; + } tcpcli->toinact = toinact; tcpcli->tirecon = tirecon; @@ -2176,7 +2663,10 @@ void strsettimeout(stream_t *stream, int toinact, int tirecon) void strsetdir(const char *dir) { tracet(3, "strsetdir: dir=%s\n", dir); - if (strlen(dir) < 1024) strcpy(localdir, dir); + if (strlen(dir) < 1024) + { + strcpy(localdir, dir); + } } @@ -2188,7 +2678,10 @@ void strsetdir(const char *dir) void strsetproxy(const char *addr) { tracet(3, "strsetproxy: addr=%s\n", addr); - if (strlen(addr) < 256) strcpy(proxyaddr, addr); + if (strlen(addr) < 256) + { + strcpy(proxyaddr, addr); + } } @@ -2201,7 +2694,7 @@ gtime_t strgettime(stream_t *stream) { file_t *file; if (stream->type == STR_FILE && (stream->mode & STR_MODE_R) && - (file = (file_t *)stream->port)) + (file = static_cast(stream->port))) { return timeadd(file->time, file->start); /* replay start time */ } @@ -2225,7 +2718,10 @@ void strsendnmea(stream_t *stream, const double *pos) sol.stat = SOLQ_SINGLE; sol.time = utc2gpst(timeget()); - for (i = 0; i < 3; i++) sol.rr[i] = pos[i]; + for (i = 0; i < 3; i++) + { + sol.rr[i] = pos[i]; + } n = outnmea_gga(buff, &sol); strwrite(stream, buff, n); } @@ -2242,15 +2738,18 @@ int gen_hex(const char *msg, unsigned char *buff) trace(4, "gen_hex: msg=%s\n", msg); strncpy(mbuff, msg, 1023); - for (p = strtok(mbuff, " "); p && narg < 256; p = strtok(NULL, " ")) + for (p = strtok(mbuff, " "); p && narg < 256; p = strtok(nullptr, " ")) { args[narg++] = p; } for (i = 0; i < narg; i++) { - if (sscanf(args[i], "%x", &byte)) *q++ = (unsigned char)byte; + if (sscanf(args[i], "%x", &byte)) + { + *q++ = static_cast(byte); + } } - return (int)(q - buff); + return static_cast(q - buff); } @@ -2272,8 +2771,13 @@ void strsendcmd(stream_t *str, const char *cmd) for (;;) { for (q = p;; q++) - if (*q == '\r' || *q == '\n' || *q == '\0') break; - n = (int)(q - p); + { + if (*q == '\r' || *q == '\n' || *q == '\0') + { + break; + } + } + n = static_cast(q - p); strncpy(msg, p, n); msg[n] = '\0'; @@ -2285,8 +2789,14 @@ void strsendcmd(stream_t *str, const char *cmd) { /* binary escape */ if (!strncmp(msg + 1, "WAIT", 4)) { /* wait */ - if (sscanf(msg + 5, "%d", &ms) < 1) ms = 100; - if (ms > 3000) ms = 3000; /* max 3 s */ + if (sscanf(msg + 5, "%d", &ms) < 1) + { + ms = 100; + } + if (ms > 3000) + { + ms = 3000; /* max 3 s */ + } sleepms(ms); } @@ -2308,17 +2818,22 @@ void strsendcmd(stream_t *str, const char *cmd) //} else if (!strncmp(msg + 1, "HEX", 3)) { /* general hex message */ - if ((m = gen_hex(msg + 4, buff)) > 0) strwrite(str, buff, m); + if ((m = gen_hex(msg + 4, buff)) > 0) + { + strwrite(str, buff, m); + } } } else { - strwrite(str, (unsigned char *)msg, n); - strwrite(str, (unsigned char *)cmdend, 2); + strwrite(str, reinterpret_cast(msg), n); + strwrite(str, reinterpret_cast(cmdend), 2); } if (*q == '\0') - break; - else - p = q + 1; + { + break; + } + + p = q + 1; } } diff --git a/src/algorithms/libs/rtklib/rtklib_tides.cc b/src/algorithms/libs/rtklib/rtklib_tides.cc index c53d5cd98..eb5355a61 100644 --- a/src/algorithms/libs/rtklib/rtklib_tides.cc +++ b/src/algorithms/libs/rtklib/rtklib_tides.cc @@ -65,9 +65,15 @@ void tide_pl(const double *eu, const double *rp, double GMp, trace(4, "tide_pl : pos=%.3f %.3f\n", pos[0] * R2D, pos[1] * R2D); - if ((r = norm_rtk(rp, 3)) <= 0.0) return; + if ((r = norm_rtk(rp, 3)) <= 0.0) + { + return; + } - for (i = 0; i < 3; i++) ep[i] = rp[i] / r; + for (i = 0; i < 3; i++) + { + ep[i] = rp[i] / r; + } K2 = GMp / GME * std::pow(RE_WGS84, 2.04) * std::pow(RE_WGS84, 2.0) / (r * r * r); K3 = K2 * RE_WGS84 / r; @@ -181,8 +187,14 @@ void tide_oload(gtime_t tut, const double *odisp, double *denu) for (i = 0; i < 11; i++) { ang = 0.0; - for (j = 0; j < 5; j++) ang += a[j] * args[i][j]; - for (j = 0; j < 3; j++) dp[j] += odisp[j + i * 6] * cos(ang - odisp[j + 3 + i * 6] * D2R); + for (j = 0; j < 5; j++) + { + ang += a[j] * args[i][j]; + } + for (j = 0; j < 3; j++) + { + dp[j] += odisp[j + i * 6] * cos(ang - odisp[j + 3 + i * 6] * D2R); + } } denu[0] = -dp[1]; denu[1] = -dp[2]; @@ -279,13 +291,19 @@ void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, trace(3, "tidedisp: tutc=%s\n", time_str(tutc, 0)); - if (erp) geterp(erp, tutc, erpv); + if (erp) + { + geterp(erp, tutc, erpv); + } tut = timeadd(tutc, erpv[2]); dr[0] = dr[1] = dr[2] = 0.0; - if (norm_rtk(rr, 3) <= 0.0) return; + if (norm_rtk(rr, 3) <= 0.0) + { + return; + } pos[0] = asin(rr[2] / norm_rtk(rr, 3)); pos[1] = atan2(rr[1], rr[0]); @@ -309,19 +327,28 @@ void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, #else tide_solid(rs, rm, pos, E, gmst, opt, drt); #endif - for (i = 0; i < 3; i++) dr[i] += drt[i]; + for (i = 0; i < 3; i++) + { + dr[i] += drt[i]; + } } if ((opt & 2) && odisp) { /* ocean tide loading */ tide_oload(tut, odisp, denu); matmul("TN", 3, 1, 3, 1.0, E, denu, 0.0, drt); - for (i = 0; i < 3; i++) dr[i] += drt[i]; + for (i = 0; i < 3; i++) + { + dr[i] += drt[i]; + } } if ((opt & 4) && erp) { /* pole tide */ tide_pole(tut, pos, erpv, denu); matmul("TN", 3, 1, 3, 1.0, E, denu, 0.0, drt); - for (i = 0; i < 3; i++) dr[i] += drt[i]; + for (i = 0; i < 3; i++) + { + dr[i] += drt[i]; + } } trace(5, "tidedisp: dr=%.3f %.3f %.3f\n", dr[0], dr[1], dr[2]); } diff --git a/src/algorithms/libs/short_x2_to_cshort.cc b/src/algorithms/libs/short_x2_to_cshort.cc index 90c842530..90ce99a7e 100644 --- a/src/algorithms/libs/short_x2_to_cshort.cc +++ b/src/algorithms/libs/short_x2_to_cshort.cc @@ -41,8 +41,8 @@ short_x2_to_cshort_sptr make_short_x2_to_cshort() short_x2_to_cshort::short_x2_to_cshort() : sync_block("short_x2_to_cshort", - gr::io_signature::make(2, 2, sizeof(short)), - gr::io_signature::make(1, 1, sizeof(lv_16sc_t))) // lv_8sc_t is a Volk's typedef for std::complex + gr::io_signature::make(2, 2, sizeof(int16_t)), + gr::io_signature::make(1, 1, sizeof(lv_16sc_t))) { const int alignment_multiple = volk_get_alignment() / sizeof(lv_16sc_t); set_alignment(std::max(1, alignment_multiple)); @@ -53,12 +53,12 @@ int short_x2_to_cshort::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const short *in0 = reinterpret_cast(input_items[0]); - const short *in1 = reinterpret_cast(input_items[1]); - lv_16sc_t *out = reinterpret_cast(output_items[0]); + const auto *in0 = reinterpret_cast(input_items[0]); + const auto *in1 = reinterpret_cast(input_items[1]); + auto *out = reinterpret_cast(output_items[0]); // This could be put into a volk kernel - short real_part; - short imag_part; + int16_t real_part; + int16_t imag_part; for (int number = 0; number < noutput_items; number++) { // lv_cmake(r, i) defined at volk/volk_complex.h diff --git a/src/algorithms/libs/short_x2_to_cshort.h b/src/algorithms/libs/short_x2_to_cshort.h index a95ae1214..1591c5412 100644 --- a/src/algorithms/libs/short_x2_to_cshort.h +++ b/src/algorithms/libs/short_x2_to_cshort.h @@ -37,7 +37,7 @@ class short_x2_to_cshort; -typedef boost::shared_ptr short_x2_to_cshort_sptr; +using short_x2_to_cshort_sptr = boost::shared_ptr; short_x2_to_cshort_sptr make_short_x2_to_cshort(); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 017132296..79e64245e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -20,7 +20,7 @@ ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk_gnsssdr) enable_language(CXX) @@ -44,37 +44,37 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # retrieve the compiler's version from it string(REGEX MATCH "clang version [0-9.]+" CLANG_OTHER_VERSION ${_err}) string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_OTHER_VERSION}) - else("${IS_APPLE}" STREQUAL "") + else() set(MIN_VERSION ${GNSSSDR_APPLECLANG_MIN_VERSION}) set(APPLE_STR "Apple ") # retrieve the compiler's version from it string(REGEX MATCH "(clang-[0-9.]+)" CLANG_APPLE_VERSION ${_err}) string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_APPLE_VERSION}) - endif("${IS_APPLE}" STREQUAL "") + endif() if(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}") message(WARNING "\nThe compiler selected to build VOLK-GNSSSDR (${APPLE_STR}Clang version ${CLANG_VERSION} : ${CMAKE_CXX_COMPILER}) is older than that officially supported (${MIN_VERSION} minimum). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.") - endif(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}") - else(${_res} STREQUAL "0") + endif() + else() message(WARNING "\nCannot determine the version of the compiler selected to build VOLK-GNSSSDR (${APPLE_STR}Clang : ${CMAKE_CXX_COMPILER}). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.") - endif(${_res} STREQUAL "0") -endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + endif() +endif() # Enable C++17 support in GCC >= 8.0.0 # Enable C++14 support in 8.0.0 > GCC >= 6.1.1 # Fallback to C++11 when using GCC < 6.1.1 -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") - else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") + else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") + else() set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") - endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") - endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") + endif() + endif() set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html -endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +endif() # Enable C++17 support in Clang >= 6.0.0 # Enable C++14 support in 6.0.0 > Clang >= 3.5.0 or AppleClang >= 600 @@ -84,28 +84,28 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # See https://trac.macports.org/wiki/XcodeVersionInfo for Apple Clang version equivalences if(CLANG_VERSION VERSION_LESS "600") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") - else(CLANG_VERSION VERSION_LESS "600") + else() set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - endif(CLANG_VERSION VERSION_LESS "600") - else(CMAKE_SYSTEM_NAME MATCHES "Darwin") + endif() + else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") - else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") + else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") + else() set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") - endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") - endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") - endif(CMAKE_SYSTEM_NAME MATCHES "Darwin") -endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + endif() + endif() + endif() +endif() -if(NOT (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) +if(NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) if(NOT (CMAKE_VERSION VERSION_LESS "3.1")) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 11) - endif(NOT (CMAKE_VERSION VERSION_LESS "3.1")) -endif(NOT (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + endif() +endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") @@ -113,9 +113,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") if(CMAKE_VERSION VERSION_GREATER "3.0") cmake_policy(SET CMP0042 NEW) if(CMAKE_VERSION VERSION_GREATER "3.9") - cmake_policy(SET CMP0068 NEW) - endif(CMAKE_VERSION VERSION_GREATER "3.9") -endif(CMAKE_VERSION VERSION_GREATER "3.0") + cmake_policy(SET CMP0068 NEW) + endif() +endif() option(ENABLE_STRIP "Create a stripped volk_gnsssdr_profile binary (without shared libraries)" OFF) @@ -129,13 +129,13 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message(STATUS "Build type not specified: defaulting to release.") endif() -VOLK_CHECK_BUILD_TYPE(${CMAKE_BUILD_TYPE}) +volk_check_build_type(${CMAKE_BUILD_TYPE}) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") set(VERSION_INFO_MAJOR_VERSION 0) set(VERSION_INFO_MINOR_VERSION 0) -set(VERSION_INFO_MAINT_VERSION 9.git) +set(VERSION_INFO_MAINT_VERSION 10.git) include(VolkVersion) #setup version info @@ -144,14 +144,14 @@ include(VolkVersion) #setup version info ######################################################################## # Environment setup ######################################################################## -IF(NOT DEFINED BOOST_ROOT AND NOT DEFINED ENV{BOOST_ROOT}) - SET(BOOST_ROOT ${CMAKE_INSTALL_PREFIX}) -ENDIF() +if(NOT DEFINED BOOST_ROOT AND NOT DEFINED ENV{BOOST_ROOT}) + set(BOOST_ROOT ${CMAKE_INSTALL_PREFIX}) +endif() -IF(NOT DEFINED CROSSCOMPILE_MULTILIB) - SET(CROSSCOMPILE_MULTILIB "") -ENDIF() -SET(CROSSCOMPILE_MULTILIB ${CROSSCOMPILE_MULTILIB} CACHE STRING "Define \"true\" if you have and want to use multiple C development libs installed for cross compile") +if(NOT DEFINED CROSSCOMPILE_MULTILIB) + set(CROSSCOMPILE_MULTILIB "") +endif() +set(CROSSCOMPILE_MULTILIB ${CROSSCOMPILE_MULTILIB} CACHE STRING "Define \"true\" if you have and want to use multiple C development libs installed for cross compile") if(MSVC) add_definitions(-D_USE_MATH_DEFINES) #enables math constants on all supported versions of MSVC @@ -160,16 +160,16 @@ if(MSVC) add_compile_options(/wd4752) add_compile_options(/wo4273) add_compile_options(/wo4838) -endif(MSVC) +endif() # allow 'large' files in 32 bit builds if(UNIX) - add_definitions( -D_LARGEFILE_SOURCE - -D_FILE_OFFSET_BITS=64 - -D_LARGE_FILES - -D_FORTIFY_SOURCE=2 - ) -endif(UNIX) + add_definitions(-D_LARGEFILE_SOURCE + -D_FILE_OFFSET_BITS=64 + -D_LARGE_FILES + -D_FORTIFY_SOURCE=2 + ) +endif() ######################################################################## @@ -178,9 +178,9 @@ endif(UNIX) # Python include(VolkPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B -VOLK_PYTHON_CHECK_MODULE("python >= 2.7" sys "sys.version.split()[0] >= '2.7'" PYTHON_MIN_VER_FOUND) -VOLK_PYTHON_CHECK_MODULE("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) -VOLK_PYTHON_CHECK_MODULE("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) +volk_python_check_module("python >= 2.7" sys "sys.version.split()[0] >= '2.7'" PYTHON_MIN_VER_FOUND) +volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) +volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) if(NOT PYTHON_MIN_VER_FOUND) @@ -199,16 +199,16 @@ endif() # Boost if(MSVC) - if (NOT DEFINED BOOST_ALL_DYN_LINK) + if(NOT DEFINED BOOST_ALL_DYN_LINK) set(BOOST_ALL_DYN_LINK TRUE) endif() set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking") if(BOOST_ALL_DYN_LINK) add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc - else(BOOST_ALL_DYN_LINK) + else() unset(BOOST_REQUIRED_COMPONENTS) #empty components list for static link - endif(BOOST_ALL_DYN_LINK) -endif(MSVC) + endif() +endif() include(VolkBoost) @@ -220,9 +220,9 @@ endif() option(ENABLE_ORC "Enable Orc" True) if(ENABLE_ORC) find_package(ORC) -else(ENABLE_ORC) +else() message(STATUS "Disabling use of ORC") -endif(ENABLE_ORC) +endif() ######################################################################## @@ -240,7 +240,7 @@ if(DOXYGEN_FOUND) WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Generating documentation with Doxygen" VERBATIM ) -endif(DOXYGEN_FOUND) +endif() ######################################################################## @@ -255,7 +255,8 @@ set(includedir "\${prefix}/include") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr.pc.in ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr.pc -@ONLY) + @ONLY +) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr.pc @@ -304,17 +305,17 @@ if(APPLE) set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${VOLK_LIBRARY_DIR} CACHE PATH "Library Install Name Destination Directory" FORCE) - endif(NOT CMAKE_INSTALL_NAME_DIR) + endif() if(NOT CMAKE_INSTALL_RPATH) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${VOLK_LIBRARY_DIR} CACHE PATH "Library Install RPath" FORCE) - endif(NOT CMAKE_INSTALL_RPATH) + endif() if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Do Build Using Library Install RPath" FORCE) - endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) -endif(APPLE) + endif() +endif() ######################################################################## @@ -358,7 +359,7 @@ configure_file( if(NOT CMAKE_MODULES_DIR) set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) -endif(NOT CMAKE_MODULES_DIR) +endif() install( FILES @@ -368,10 +369,14 @@ install( COMPONENT "volk_gnsssdr_devel" ) +install(EXPORT VOLK_GNSSSDR-export FILE VolkGnsssdrTargets.cmake + NAMESPACE VolkGnsssdr:: DESTINATION ${CMAKE_MODULES_DIR}/volk_gnsssdr +) + ######################################################################## # Option to enable QA testing, on by default ######################################################################## -OPTION(ENABLE_TESTING "Enable QA testing" ON) +option(ENABLE_TESTING "Enable QA testing" ON) if(ENABLE_TESTING) message(STATUS "QA Testing is enabled.") else() @@ -383,7 +388,7 @@ message(STATUS " Modify using: -DENABLE_TESTING=ON/OFF") ######################################################################## # Option to enable post-build profiling using volk_profile, off by default ######################################################################## -OPTION(ENABLE_PROFILING "Launch system profiler after build" OFF) +option(ENABLE_PROFILING "Launch system profiler after build" OFF) if(ENABLE_PROFILING) set(ENABLE_STATIC_LIBS ON) if(DEFINED VOLK_CONFIGPATH) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in index 8fa50f08d..4d9e579a3 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in @@ -20,7 +20,7 @@ # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all text # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# built into libc) for the transcoding. See https://www.gnu.org/software/libiconv # for the list of possible encodings. # The default value is: UTF-8. @@ -287,7 +287,7 @@ EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -320,7 +320,7 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -679,7 +679,7 @@ LAYOUT_FILE = @PROJECT_SOURCE_DIR@/DoxygenLayout.xml # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. Do not use file names with spaces, bibtex cannot handle them. See @@ -761,7 +761,7 @@ INPUT = @PROJECT_SOURCE_DIR@ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# documentation (see: https://www.gnu.org/software/libiconv) for the list of # possible encodings. # The default value is: UTF-8. @@ -994,7 +994,7 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: @@ -1137,7 +1137,7 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the stylesheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1195,13 +1195,12 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# environment (see: https://developer.apple.com/xcode/), introduced with # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1240,7 +1239,7 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output @@ -1453,7 +1452,7 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side Javascript for the rendering # instead of using prerendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1465,7 +1464,7 @@ USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# https://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1480,11 +1479,11 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdnjs.com/libraries/mathjax/. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = https://cdnjs.com/libraries/mathjax/ # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example @@ -1495,7 +1494,7 @@ MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: https://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1542,7 +1541,7 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer ( doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1555,7 +1554,7 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer ( doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and +# Xapian (see: https://xapian.org/). See the section "External Indexing and # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. @@ -1726,7 +1725,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt index c95967d70..b1afa4ed0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt @@ -22,7 +22,7 @@ ######################################################################## if(MSVC) include_directories(${PROJECT_SOURCE_DIR}/cmake/msvc) -endif(MSVC) +endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR} @@ -37,26 +37,26 @@ include_directories( set(Clang_required_link "") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(Clang_required_link "c++") - endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") -endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(Clang_required_link "c++") + endif() +endif() if(ORC_FOUND) set(orc_lib ${ORC_LIBRARIES}) -elseif(ORC_FOUND) +else() set(orc_lib "") -endif(ORC_FOUND) +endif() # allow 'large' files in 32 bit builds if(UNIX) - add_definitions( -D_LARGEFILE_SOURCE - -D_FILE_OFFSET_BITS=64 - -D_LARGE_FILES - ) -endif(UNIX) + add_definitions(-D_LARGEFILE_SOURCE + -D_FILE_OFFSET_BITS=64 + -D_LARGE_FILES + ) +endif() # MAKE volk_gnsssdr_profile @@ -68,18 +68,18 @@ add_executable(volk_gnsssdr_profile if(ENABLE_STATIC_LIBS) target_link_libraries(volk_gnsssdr_profile volk_gnsssdr_static ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib}) -else(ENABLE_STATIC_LIBS) +else() target_link_libraries(volk_gnsssdr_profile volk_gnsssdr ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib}) add_dependencies(volk_gnsssdr_profile volk_gnsssdr) -endif(ENABLE_STATIC_LIBS) +endif() if(ENABLE_STRIP) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) set_target_properties(volk_gnsssdr_profile - PROPERTIES LINK_FLAGS "-s") - endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) -endif(ENABLE_STRIP) + PROPERTIES LINK_FLAGS "-s") + endif() +endif() install( @@ -92,18 +92,18 @@ install( # MAKE volk_gnsssdr-config-info add_executable(volk_gnsssdr-config-info volk_gnsssdr-config-info.cc ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc) if(ENABLE_STATIC_LIBS) - target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr_static ${Clang_required_link} ${orc_lib}) -else(ENABLE_STATIC_LIBS) - target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${Clang_required_link} ${orc_lib}) - add_dependencies(volk_gnsssdr-config-info volk_gnsssdr) -endif(ENABLE_STATIC_LIBS) + target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr_static ${Clang_required_link} ${orc_lib}) +else() + target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${Clang_required_link} ${orc_lib}) + add_dependencies(volk_gnsssdr-config-info volk_gnsssdr) +endif() if(ENABLE_STRIP) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) set_target_properties(volk_gnsssdr-config-info - PROPERTIES LINK_FLAGS "-s") - endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) -endif(ENABLE_STRIP) + PROPERTIES LINK_FLAGS "-s") + endif() +endif() install( TARGETS volk_gnsssdr-config-info @@ -114,17 +114,14 @@ install( # Launch volk_gnsssdr_profile if requested to do so if(ENABLE_PROFILING) - if(DEFINED VOLK_CONFIGPATH) + if(DEFINED VOLK_CONFIGPATH) set( VOLK_CONFIG_ARG "-p${VOLK_CONFIGPATH}" ) set( VOLK_CONFIG "${VOLK_CONFIGPATH}/volk_gnsssdr_config" ) - endif() - add_custom_command(OUTPUT ${VOLK_CONFIG} + endif() + add_custom_command(OUTPUT ${VOLK_CONFIG} COMMAND volk_gnsssdr_profile "${VOLK_CONFIG_ARG}" DEPENDS volk_gnsssdr_profile COMMENT "Launching profiler, this may take a few minutes..." ) add_custom_target(volk-gnsssdr-profile-run ALL DEPENDS ${VOLK_CONFIG}) endif() - - - diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index 8c9997ef9..c18bb2e3a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -16,22 +16,22 @@ * along with GNSS-SDR. If not, see . */ +#include "volk_gnsssdr_profile.h" #include "kernel_tests.h" // for init_test_list #include "qa_utils.h" // for volk_gnsssdr_test_results_t #include "volk_gnsssdr/volk_gnsssdr_complex.h" // for lv_32fc_t +#include "volk_gnsssdr/volk_gnsssdr_prefs.h" // for volk_gnsssdr_get_config_path #include "volk_gnsssdr_option_helpers.h" // for option_list, option_t -#include "volk_gnsssdr_profile.h" -#include "volk_gnsssdr/volk_gnsssdr_prefs.h" // for volk_gnsssdr_get_config_path -#include // for create_directories, exists -#include // for path, operator<< -#include // for filesystem -#include // for stat -#include // for size_t -#include // for operator<<, basic_ostream -#include // IWYU pragma: keep -#include // for map, map<>::iterator -#include // for pair -#include // for vector, vector<>::const_.. +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem +#include // for size_t +#include // IWYU pragma: keep +#include // for operator<<, basic_ostream +#include // for map, map<>::iterator +#include // for stat +#include // for pair +#include // for vector, vector<>::const_.. namespace fs = boost::filesystem; @@ -250,10 +250,10 @@ void write_results(const std::vector *results, bool const fs::path config_path(path); // Until we can update the config on a kernel by kernel basis // do not overwrite volk_gnsssdr_config when using a regex. - if (!fs::exists(config_path.branch_path())) + if (!fs::exists(config_path.parent_path())) { - std::cout << "Creating " << config_path.branch_path() << " ..." << std::endl; - fs::create_directories(config_path.branch_path()); + std::cout << "Creating " << config_path.parent_path() << " ..." << std::endl; + fs::create_directories(config_path.parent_path()); } std::ofstream config; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindORC.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindORC.cmake index 0341d3f7b..1154d2e7a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindORC.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindORC.cmake @@ -16,52 +16,56 @@ # along with GNSS-SDR. If not, see . -FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_ORC "orc-0.4 > 0.4.22") +find_package(PkgConfig) +pkg_check_modules(PC_ORC "orc-0.4 > 0.4.22") -FIND_PROGRAM(ORCC_EXECUTABLE orcc - HINTS ${PC_ORC_TOOLSDIR} - PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin) +find_program(ORCC_EXECUTABLE orcc + HINTS ${PC_ORC_TOOLSDIR} + PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin +) -FIND_PATH(ORC_INCLUDE_DIR NAMES orc/orc.h - HINTS ${PC_ORC_INCLUDEDIR} - PATHS ${ORC_ROOT}/include/orc-0.4 ${CMAKE_INSTALL_PREFIX}/include/orc-0.4) - - -FIND_PATH(ORC_LIBRARY_DIR NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX} - HINTS ${PC_ORC_LIBDIR} - /usr/local/lib - /usr/lib/x86_64-linux-gnu - /usr/lib/i386-linux-gnu - /usr/lib/arm-linux-gnueabihf - /usr/lib/arm-linux-gnueabi - /usr/lib/aarch64-linux-gnu - /usr/lib/mipsel-linux-gnu - /usr/lib/mips-linux-gnu - /usr/lib/mips64el-linux-gnuabi64 - /usr/lib/powerpc-linux-gnu - /usr/lib/powerpc64-linux-gnu - /usr/lib/powerpc64le-linux-gnu - /usr/lib/hppa-linux-gnu - /usr/lib/s390x-linux-gnu - /usr/lib64 - /usr/lib - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - -FIND_LIBRARY(ORC_LIB orc-0.4 - HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - -LIST(APPEND ORC_LIBRARY - ${ORC_LIB} +find_path(ORC_INCLUDE_DIR NAMES orc/orc.h + HINTS ${PC_ORC_INCLUDEDIR} + PATHS ${ORC_ROOT}/include/orc-0.4 ${CMAKE_INSTALL_PREFIX}/include/orc-0.4 ) -SET(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR}) -SET(ORC_LIBRARIES ${ORC_LIBRARY}) -SET(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR}) +find_path(ORC_LIBRARY_DIR + NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX} + HINTS ${PC_ORC_LIBDIR} + /usr/local/lib + /usr/lib/x86_64-linux-gnu + /usr/lib/i386-linux-gnu + /usr/lib/arm-linux-gnueabihf + /usr/lib/arm-linux-gnueabi + /usr/lib/aarch64-linux-gnu + /usr/lib/mipsel-linux-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/powerpc-linux-gnu + /usr/lib/powerpc64-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/hppa-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/lib64 + /usr/lib + PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} +) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR ORCC_EXECUTABLE) +find_library(ORC_LIB orc-0.4 + HINTS ${PC_ORC_LIBRARY_DIRS} + PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + +list(APPEND ORC_LIBRARY + ${ORC_LIB} +) + + +set(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR}) +set(ORC_LIBRARIES ${ORC_LIBRARY}) +set(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR ORCC_EXECUTABLE) mark_as_advanced(ORC_INCLUDE_DIR ORC_LIBRARY ORCC_EXECUTABLE) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake index b01a99594..a2097046e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake @@ -30,7 +30,7 @@ set(__INCLUDED_VOLK_ADD_TEST TRUE) function(VOLK_GEN_TEST executable_name) include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_TEST "" "" "SOURCES;TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) + cmake_parse_arguments(VOLK_TEST "" "" "SOURCES;TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) add_executable(${executable_name} ${VOLK_TEST_SOURCES}) target_link_libraries(${executable_name} ${VOLK_TEST_TARGET_DEPS}) endfunction() @@ -53,7 +53,7 @@ function(VOLK_ADD_TEST test_name executable_name) #parse the arguments for component names include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_TEST "" "" "TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) + cmake_parse_arguments(VOLK_TEST "" "" "TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) #set the initial environs to use set(environs ${VOLK_TEST_ENVIRONS}) @@ -146,7 +146,7 @@ function(VOLK_ADD_TEST test_name executable_name) #each line sets an environment variable foreach(environ ${environs}) file(APPEND ${sh_file} "export ${environ}\n") - endforeach(environ) + endforeach() set(VOLK_TEST_ARGS "${test_name}") @@ -166,7 +166,7 @@ function(VOLK_ADD_TEST test_name executable_name) COMMAND ${SHELL} ${sh_file} ${TARGET_DIR_LIST} ) - endif(UNIX) + endif() if(WIN32) #In the land of windows, all libraries must be in the PATH. Since @@ -199,7 +199,7 @@ function(VOLK_ADD_TEST test_name executable_name) #each line sets an environment variable foreach(environ ${environs}) file(APPEND ${bat_file} "SET ${environ}\n") - endforeach(environ) + endforeach() set(VOLK_TEST_ARGS "${test_name}") @@ -213,7 +213,7 @@ function(VOLK_ADD_TEST test_name executable_name) add_test(NAME qa_${test_name} COMMAND ${bat_file} ${TARGET_DIR_LIST} ) - endif(WIN32) + endif() -endfunction(VOLK_ADD_TEST) +endfunction() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBoost.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBoost.cmake index 074b7003e..2aea96b2a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBoost.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBoost.cmake @@ -31,21 +31,21 @@ set(BOOST_REQUIRED_COMPONENTS if(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64") list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix -endif(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64") +endif() if(MSVC) set(BOOST_REQUIRED_COMPONENTS ${BOOST_REQUIRED_COMPONENTS} chrono) - if (NOT DEFINED BOOST_ALL_DYN_LINK) + if(NOT DEFINED BOOST_ALL_DYN_LINK) set(BOOST_ALL_DYN_LINK TRUE) endif() set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking") if(BOOST_ALL_DYN_LINK) add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc - else(BOOST_ALL_DYN_LINK) + else() unset(BOOST_REQUIRED_COMPONENTS) #empty components list for static link - endif(BOOST_ALL_DYN_LINK) -endif(MSVC) + endif() +endif() find_package(Boost "1.35" COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) @@ -61,15 +61,17 @@ set(Boost_ADDITIONAL_VERSIONS "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" + "1.70.0" "1.70" "1.71.0" "1.71" "1.72.0" "1.72" "1.73.0" "1.73" "1.74.0" "1.74" + "1.75.0" "1.75" "1.76.0" "1.76" "1.77.0" "1.77" "1.78.0" "1.78" "1.79.0" "1.79" ) # Boost 1.52 disabled, see https://svn.boost.org/trac/boost/ticket/7669 # Similar problems with Boost 1.46 and 1.47. -OPTION(ENABLE_BAD_BOOST "Enable known bad versions of Boost" OFF) +option(ENABLE_BAD_BOOST "Enable known bad versions of Boost" OFF) if(ENABLE_BAD_BOOST) - MESSAGE(STATUS "Enabling use of known bad versions of Boost.") -endif(ENABLE_BAD_BOOST) + message(STATUS "Enabling use of known bad versions of Boost.") +endif() # For any unsuitable Boost version, add the version number below in # the following format: XXYYZZ @@ -78,17 +80,17 @@ endif(ENABLE_BAD_BOOST) # YY is the minor version number ('46' for 1.46) # ZZ is the patcher version number (typically just '00') set(Boost_NOGO_VERSIONS - 104600 104601 104700 105200 - ) + 104600 104601 104700 105200 +) foreach(ver ${Boost_NOGO_VERSIONS}) - if("${Boost_VERSION}" STREQUAL "${ver}") - if(NOT ENABLE_BAD_BOOST) - MESSAGE(STATUS "WARNING: Found a known bad version of Boost (v${Boost_VERSION}). Disabling.") - set(Boost_FOUND FALSE) - else(NOT ENABLE_BAD_BOOST) - MESSAGE(STATUS "WARNING: Found a known bad version of Boost (v${Boost_VERSION}). Continuing anyway.") - set(Boost_FOUND TRUE) - endif(NOT ENABLE_BAD_BOOST) - endif("${Boost_VERSION}" STREQUAL "${ver}") -endforeach(ver) + if("${Boost_VERSION}" STREQUAL "${ver}") + if(NOT ENABLE_BAD_BOOST) + message(STATUS "WARNING: Found a known bad version of Boost (v${Boost_VERSION}). Disabling.") + set(Boost_FOUND FALSE) + else() + message(STATUS "WARNING: Found a known bad version of Boost (v${Boost_VERSION}). Continuing anyway.") + set(Boost_FOUND TRUE) + endif() + endif() +endforeach() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake index 53e47ddbf..6f45f1683 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake @@ -38,6 +38,7 @@ set(__INCLUDED_VOLK_BUILD_TYPES_CMAKE TRUE) list(APPEND AVAIL_BUILDTYPES None Debug Release RelWithDebInfo MinSizeRel DebugParanoid NoOptWithASM O2WithASM O3WithASM + ASAN ) ######################################################################## @@ -52,16 +53,16 @@ list(APPEND AVAIL_BUILDTYPES # the avialable build types. ######################################################################## function(VOLK_CHECK_BUILD_TYPE settype) - STRING(TOUPPER ${settype} _settype) + string(TOUPPER ${settype} _settype) foreach(btype ${AVAIL_BUILDTYPES}) - STRING(TOUPPER ${btype} _btype) + string(TOUPPER ${btype} _btype) if(${_settype} STREQUAL ${_btype}) return() # found it; exit cleanly - endif(${_settype} STREQUAL ${_btype}) - endforeach(btype) + endif() + endforeach() # Build type not found; error out message(FATAL_ERROR "Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}") -endfunction(VOLK_CHECK_BUILD_TYPE) +endfunction() ######################################################################## # For GCC and Clang, we can set a build type: @@ -73,23 +74,23 @@ endfunction(VOLK_CHECK_BUILD_TYPE) # NOTE: This is not defined on Windows systems. ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_DEBUGPARANOID "-Wall -Wextra -g -O0" CACHE STRING + set(CMAKE_CXX_FLAGS_DEBUGPARANOID "-Wall -Wextra -g -O0" CACHE STRING "Flags used by the C++ compiler during DebugParanoid builds." FORCE) - SET(CMAKE_C_FLAGS_DEBUGPARANOID "-Wall -Wextra -g -O0" CACHE STRING + set(CMAKE_C_FLAGS_DEBUGPARANOID "-Wall -Wextra -g -O0" CACHE STRING "Flags used by the C compiler during DebugParanoid builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID + set(CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used for linking binaries during NoOptWithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_DEBUGPARANOID + set(CMAKE_SHARED_LINKER_FLAGS_DEBUGPARANOID "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used by the shared lib linker during NoOptWithASM builds." FORCE) - MARK_AS_ADVANCED( + mark_as_advanced( CMAKE_CXX_FLAGS_DEBUGPARANOID CMAKE_C_FLAGS_DEBUGPARANOID CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID CMAKE_SHARED_LINKER_DEBUGPARANOID) -endif(NOT WIN32) +endif() ######################################################################## @@ -104,23 +105,23 @@ endif(NOT WIN32) # NOTE: This is not defined on Windows systems. ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_NOOPTWITHASM "-save-temps -g -O0" CACHE STRING + set(CMAKE_CXX_FLAGS_NOOPTWITHASM "-save-temps -g -O0" CACHE STRING "Flags used by the C++ compiler during NoOptWithASM builds." FORCE) - SET(CMAKE_C_FLAGS_NOOPTWITHASM "-save-temps -g -O0" CACHE STRING + set(CMAKE_C_FLAGS_NOOPTWITHASM "-save-temps -g -O0" CACHE STRING "Flags used by the C compiler during NoOptWithASM builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM + set(CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used for linking binaries during NoOptWithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM + set(CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used by the shared lib linker during NoOptWithASM builds." FORCE) - MARK_AS_ADVANCED( + mark_as_advanced( CMAKE_CXX_FLAGS_NOOPTWITHASM CMAKE_C_FLAGS_NOOPTWITHASM CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM) -endif(NOT WIN32) +endif() ######################################################################## @@ -136,23 +137,23 @@ endif(NOT WIN32) ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_O2WITHASM "-save-temps -g -O2" CACHE STRING + set(CMAKE_CXX_FLAGS_O2WITHASM "-save-temps -g -O2" CACHE STRING "Flags used by the C++ compiler during O2WithASM builds." FORCE) - SET(CMAKE_C_FLAGS_O2WITHASM "-save-temps -g -O2" CACHE STRING + set(CMAKE_C_FLAGS_O2WITHASM "-save-temps -g -O2" CACHE STRING "Flags used by the C compiler during O2WithASM builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_O2WITHASM + set(CMAKE_EXE_LINKER_FLAGS_O2WITHASM "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used for linking binaries during O2WithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_O2WITHASM + set(CMAKE_SHARED_LINKER_FLAGS_O2WITHASM "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used by the shared lib linker during O2WithASM builds." FORCE) - MARK_AS_ADVANCED( + mark_as_advanced( CMAKE_CXX_FLAGS_O2WITHASM CMAKE_C_FLAGS_O2WITHASM CMAKE_EXE_LINKER_FLAGS_O2WITHASM CMAKE_SHARED_LINKER_FLAGS_O2WITHASM) -endif(NOT WIN32) +endif() ######################################################################## @@ -168,20 +169,42 @@ endif(NOT WIN32) ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_O3WITHASM "-save-temps -g -O3" CACHE STRING + set(CMAKE_CXX_FLAGS_O3WITHASM "-save-temps -g -O3" CACHE STRING "Flags used by the C++ compiler during O3WithASM builds." FORCE) - SET(CMAKE_C_FLAGS_O3WITHASM "-save-temps -g -O3" CACHE STRING + set(CMAKE_C_FLAGS_O3WITHASM "-save-temps -g -O3" CACHE STRING "Flags used by the C compiler during O3WithASM builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_O3WITHASM + set(CMAKE_EXE_LINKER_FLAGS_O3WITHASM "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used for linking binaries during O3WithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_O3WITHASM + set(CMAKE_SHARED_LINKER_FLAGS_O3WITHASM "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING "Flags used by the shared lib linker during O3WithASM builds." FORCE) - MARK_AS_ADVANCED( + mark_as_advanced( CMAKE_CXX_FLAGS_O3WITHASM CMAKE_C_FLAGS_O3WITHASM CMAKE_EXE_LINKER_FLAGS_O3WITHASM CMAKE_SHARED_LINKER_FLAGS_O3WITHASM) -endif(NOT WIN32) +endif() + +######################################################################## +# For GCC and Clang, we can set a build type: +# +# -DCMAKE_BUILD_TYPE=ASAN +# +# This type creates an address sanitized build (-fsanitize=address) +# and defaults to the DebugParanoid linker flags. +# NOTE: This is not defined on Windows systems. +######################################################################## +if(NOT WIN32) + set(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + "Flags used by the C++ compiler during Address Sanitized builds." FORCE) + set(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + "Flags used by the C compiler during Address Sanitized builds." FORCE) + mark_as_advanced( + CMAKE_CXX_FLAGS_ASAN + CMAKE_C_FLAGS_ASAN + CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID + CMAKE_SHARED_LINKER_DEBUGPARANOID) +endif() + diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfig.cmake.in b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfig.cmake.in index 4838f13c0..ef8dce6e6 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfig.cmake.in +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfig.cmake.in @@ -15,33 +15,8 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_VOLK_GNSSSDR volk_gnsssdr) +get_filename_component(VOLK_GNSSSDR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -FIND_PATH( - VOLK_GNSSSDR_INCLUDE_DIRS - NAMES volk_gnsssdr/volk_gnsssdr.h - HINTS $ENV{VOLK_DIR}/include - ${PC_VOLK_INCLUDEDIR} - PATHS /usr/local/include - /usr/include - /opt/local/include - "@CMAKE_INSTALL_PREFIX@/include" -) - -FIND_LIBRARY( - VOLK_GNSSSDR_LIBRARIES - NAMES volk_gnsssdr - HINTS $ENV{VOLK_DIR}/lib - ${PC_VOLK_LIBDIR} - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 - /opt/local/lib - "@CMAKE_INSTALL_PREFIX@/lib" -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(VOLK_GNSSSDR DEFAULT_MSG VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS) -MARK_AS_ADVANCED(VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS) +if(NOT TARGET VolkGnsssdr::volkgnsssdr) + include("${VOLK_GNSSSDR_CMAKE_DIR}/VolkGnsssdrTargets.cmake") +endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfigVersion.cmake.in b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfigVersion.cmake.in index d7694fdb9..7808c7dbe 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfigVersion.cmake.in +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkGnsssdrConfigVersion.cmake.in @@ -27,6 +27,6 @@ if(${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${MAJOR_VERSION}) if(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MAINT_VERSION}) set(PACKAGE_VERSION_EXACT 1) # exact match for API version set(PACKAGE_VERSION_COMPATIBLE 1) # compat for minor/patch version - endif(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MAINT_VERSION}) - endif(${PACKAGE_FIND_VERSION_MINOR} EQUAL ${MINOR_VERSION}) -endif(${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${MAJOR_VERSION}) + endif() + endif() +endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 085a32030..06c51883c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -25,42 +25,39 @@ set(__INCLUDED_VOLK_PYTHON_CMAKE TRUE) # This allows the user to specify a specific interpreter, # or finds the interpreter via the built-in cmake module. ######################################################################## -#this allows the user to override PYTHON_EXECUTABLE -if(PYTHON_EXECUTABLE) +set(VOLK_PYTHON_MIN_VERSION "2.7") +set(VOLK_PYTHON3_MIN_VERSION "3.4") - set(PYTHONINTERP_FOUND TRUE) - -#otherwise if not set, try to automatically find it -else(PYTHON_EXECUTABLE) - - #use the built-in find script - set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6) - find_package(PythonInterp 2) - - #and if that fails use the find program routine - if(NOT PYTHONINTERP_FOUND) - find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7 python3) - if(PYTHON_EXECUTABLE) - set(PYTHONINTERP_FOUND TRUE) - endif(PYTHON_EXECUTABLE) - endif(NOT PYTHONINTERP_FOUND) - -endif(PYTHON_EXECUTABLE) - -#make the path to the executable appear in the cmake gui -set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") - -#make sure we can use -B with python (introduced in 2.6) -if(PYTHON_EXECUTABLE) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -B -c "" - OUTPUT_QUIET ERROR_QUIET - RESULT_VARIABLE PYTHON_HAS_DASH_B_RESULT - ) - if(PYTHON_HAS_DASH_B_RESULT EQUAL 0) - set(PYTHON_DASH_B "-B") +if(CMAKE_VERSION VERSION_LESS 3.12) + if(PYTHON_EXECUTABLE) + message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + else() + message(STATUS "PYTHON_EXECUTABLE not set - using default python2") + message(STATUS "Use -DPYTHON_EXECUTABLE=/path/to/python3 to build for python3.") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) + if(NOT PYTHONINTERP_FOUND) + message(STATUS "python2 not found - using python3") + find_package(PythonInterp ${VOLK_PYTHON3_MIN_VERSION} REQUIRED) + endif() endif() -endif(PYTHON_EXECUTABLE) + find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT) +else() + if(PYTHON_EXECUTABLE) + message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + else() + find_package(Python COMPONENTS Interpreter) + set(PYTHON_VERSION_MAJOR ${Python_VERSION_MAJOR}) + set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) + endif() +endif() + +if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) + set(PYTHON3 TRUE) +endif() + + ######################################################################## # Check for the existence of a python module: @@ -69,37 +66,45 @@ endif(PYTHON_EXECUTABLE) # - cmd an additional command to run # - have the result variable to set ######################################################################## -macro(VOLK_PYTHON_CHECK_MODULE desc mod cmd have) - message(STATUS "") - message(STATUS "Python checking for ${desc}") +macro(VOLK_PYTHON_CHECK_MODULE_RAW desc python_code have) execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c " -######################################### -try: import ${mod} -except: - try: ${mod} - except: exit(-1) -try: assert ${cmd} -except: exit(-1) -#########################################" - RESULT_VARIABLE ${have} + COMMAND ${PYTHON_EXECUTABLE} -c "${python_code}" + OUTPUT_QUIET ERROR_QUIET + RESULT_VARIABLE return_code ) - if(${have} EQUAL 0) + if(return_code EQUAL 0) message(STATUS "Python checking for ${desc} - found") set(${have} TRUE) - else(${have} EQUAL 0) + else() message(STATUS "Python checking for ${desc} - not found") set(${have} FALSE) - endif(${have} EQUAL 0) -endmacro(VOLK_PYTHON_CHECK_MODULE) + endif() +endmacro() + +macro(VOLK_PYTHON_CHECK_MODULE desc mod cmd have) + VOLK_PYTHON_CHECK_MODULE_RAW( + "${desc}" " +######################################### +try: + import ${mod} + assert ${cmd} +except (ImportError, AssertionError): exit(-1) +except: pass +#########################################" + "${have}") +endmacro() ######################################################################## # Sets the python installation directory VOLK_PYTHON_DIR ######################################################################## if(NOT DEFINED VOLK_PYTHON_DIR) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c " -from distutils import sysconfig -print(sysconfig.get_python_lib(plat_specific=True, prefix='')) +import os +import sys +if os.name == 'posix': + print(os.path.join('lib', 'python' + sys.version[:3], 'dist-packages')) +if os.name == 'nt': + print(os.path.join('Lib', 'site-packages')) " OUTPUT_VARIABLE VOLK_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) endif() @@ -116,14 +121,14 @@ unique = hashlib.md5(b'${reldir}${ARGN}').hexdigest()[:5] print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_target(${_target} ALL DEPENDS ${ARGN}) -endfunction(VOLK_UNIQUE_TARGET) +endfunction() ######################################################################## # Install python sources (also builds and installs byte-compiled python) ######################################################################## function(VOLK_PYTHON_INSTALL) include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN}) + cmake_parse_arguments(VOLK_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN}) #################################################################### if(VOLK_PYTHON_INSTALL_FILES) @@ -157,7 +162,7 @@ function(VOLK_PYTHON_INSTALL) get_filename_component(pygen_path ${pygenfile} PATH) file(MAKE_DIRECTORY ${pygen_path}) - endforeach(pyfile) + endforeach() #the command to generate the pyc files add_custom_command( @@ -184,8 +189,8 @@ function(VOLK_PYTHON_INSTALL) #################################################################### file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) - if (CMAKE_CROSSCOMPILING) - set(pyexe_native "/usr/bin/env python") + if(CMAKE_CROSSCOMPILING) + set(pyexe_native "/usr/bin/env python") endif() foreach(pyfile ${VOLK_PYTHON_INSTALL_PROGRAMS}) @@ -200,7 +205,7 @@ function(VOLK_PYTHON_INSTALL) add_custom_command( OUTPUT ${pyexefile} DEPENDS ${pyfile} COMMAND ${PYTHON_EXECUTABLE} -c - "open('${pyexefile}','w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())" + "open('${pyexefile}','w').write(r'\#!${pyexe_native}'+'\\n'+open('${pyfile}').read())" COMMENT "Shebangin ${pyfile_name}" VERBATIM ) @@ -215,13 +220,13 @@ function(VOLK_PYTHON_INSTALL) DESTINATION ${VOLK_PYTHON_INSTALL_DESTINATION} COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT} ) - endforeach(pyfile) + endforeach() endif() - VOLK_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) + volk_unique_target("pygen" ${python_install_gen_targets}) -endfunction(VOLK_PYTHON_INSTALL) +endfunction() ######################################################################## # Write the python helper script that generates byte code files diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage index 48de3376a..6f273a82b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage @@ -1,14 +1,14 @@ -.\" Manpage for volk_gnsssdr-config-info +.\" Manpage for volk_gnsssdr\-config\-info .\" Contact carles.fernandez@cttc.es to correct errors or typos. -.TH volk_gnsssdr_profile 1 "06 Feb 2017" "0.0.9" "volk_gnsssdr-config-info man page" +.TH volk_gnsssdr\-config\-info 1 "12 Dec 2018" "0.0.10" "volk_gnsssdr\-config\-info man page" .SH NAME -\fBvolk_gnsssdr-config-info\fR \- Prints configuration information of libvolk_gnsssdr functions. +\fBvolk_gnsssdr\-config\-info\fR \- Prints configuration information of libvolk_gnsssdr functions. .SH SYNOPSIS -\fBvolk_gnsssdr-config-info\fR [OPTION] +\fBvolk_gnsssdr\-config\-info\fR [OPTION] .SH DESCRIPTION -This program prints configuration information for the Vector-Optimized Library of Kernels of GNSS-SDR (VOLK_GNSSSDR). +This program prints configuration information for the Vector\-Optimized Library of Kernels of GNSS\-SDR (VOLK_GNSSSDR). .SH OPTIONS -\fBvolk_gnsssdr-config-info\fR takes the following options: +\fBvolk_gnsssdr\-config\-info\fR takes the following options: .TP \fB-h\fR [ \fB--help\fR ] Print help message. .TP diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage index 186bcb9c9..99a9ae316 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage @@ -1,6 +1,6 @@ .\" Manpage for volk_gnsssdr_profile .\" Contact carles.fernandez@cttc.es to correct errors or typos. -.TH volk_gnsssdr_profile 1 "06 Feb 2017" "0.0.9" "volk_gnsssdr_profile man page" +.TH volk_gnsssdr_profile 1 "12 Dec 2018" "0.0.10" "volk_gnsssdr_profile man page" .SH NAME \fBvolk_gnsssdr_profile\fR \- Profiler application for libvolk_gnsssdr functions. .SH SYNOPSIS diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/cmake_uninstall.cmake.in b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/cmake_uninstall.cmake.in index a6191a104..d026a667a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/cmake_uninstall.cmake.in +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/cmake_uninstall.cmake.in @@ -25,10 +25,10 @@ string(REGEX REPLACE "\n" ";" files "${files}") foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove \"$ENV{DESTDIR}${file}\" OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval + RESULT_VARIABLE rm_retval ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml index a8bee46a2..6d293da91 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml @@ -6,14 +6,17 @@ -mfloat-abi=softfp + -mfloat-abi=softfp -mfloat-abi=hard + -mfloat-abi=hard -funsafe-math-optimizations + -funsafe-math-optimizations 16 @@ -21,18 +24,22 @@ -mfpu=neon -funsafe-math-optimizations + -mfpu=neon + -funsafe-math-optimizations 16 -funsafe-math-optimizations + -funsafe-math-optimizations 16 -m32 + -m32 @@ -238,4 +245,48 @@ 32 + + + + 7 + 0 + 1 + 16 + + + + 2 + 0x00000001 + 27 + + + + -mavx512f + -mavx512f + /arch:AVX512F + 64 + + + + + + 7 + 0 + 1 + 28 + + + + 2 + 0x00000001 + 27 + + + + -mavx512cd + -mavx512cd + /arch:AVX512CD + 64 + + diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/machines.xml b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/machines.xml index e7c6eaf20..d787a6b14 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/machines.xml +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/machines.xml @@ -51,4 +51,14 @@ generic 32|64| mmx| sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx fma avx2 orc| + + +generic 32|64| mmx| sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx fma avx2 avx512f orc| + + + + +generic 32|64| mmx| sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx fma avx2 avx512f avx512cd orc| + + diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py index 1a1248ad2..f639ae767 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py @@ -25,7 +25,7 @@ import six archs = list() arch_dict = dict() -class arch_class: +class arch_class(object): def __init__(self, flags, checks, **kwargs): for key, cast, failval in ( ('name', str, None), diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py index 9daddda73..229d44a7a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py @@ -53,7 +53,7 @@ def split_into_nested_ifdef_sections(code): header = 'text' in_section_depth = 0 for i, line in enumerate(code.splitlines()): - m = re.match('^(\s*)#(\s*)(\w+)(.*)$', line) + m = re.match(r'^(\s*)#(\s*)(\w+)(.*)$', line) line_is = 'normal' if m: p0, p1, fcn, stuff = m.groups() @@ -118,14 +118,14 @@ def flatten_section_text(sections): ######################################################################## # Extract kernel info from section, represent as an implementation ######################################################################## -class impl_class: +class impl_class(object): def __init__(self, kern_name, header, body): #extract LV_HAVE_* - self.deps = set(map(str.lower, re.findall('LV_HAVE_(\w+)', header))) + self.deps = set(res.lower() for res in re.findall(r'LV_HAVE_(\w+)', header)) #extract function suffix and args body = flatten_section_text(body) try: - fcn_matcher = re.compile('^.*(%s\\w*)\\s*\\((.*)$'%kern_name, re.DOTALL | re.MULTILINE) + fcn_matcher = re.compile(r'^.*(%s\w*)\s*\((.*)$'%kern_name, re.DOTALL | re.MULTILINE) body = body.split('{')[0].rsplit(')', 1)[0] #get the part before the open ){ bracket m = fcn_matcher.match(body) impl_name, the_rest = m.groups() @@ -133,7 +133,7 @@ class impl_class: self.args = list() fcn_args = the_rest.split(',') for fcn_arg in fcn_args: - arg_matcher = re.compile('^\s*(.*\\W)\s*(\w+)\s*$', re.DOTALL | re.MULTILINE) + arg_matcher = re.compile(r'^\s*(.*\W)\s*(\w+)\s*$', re.DOTALL | re.MULTILINE) m = arg_matcher.match(fcn_arg) arg_type, arg_name = m.groups() self.args.append((arg_type, arg_name)) @@ -153,18 +153,18 @@ def extract_lv_haves(code): haves = list() for line in code.splitlines(): if not line.strip().startswith('#'): continue - have_set = set(map(str.lower, re.findall('LV_HAVE_(\w+)', line))) + have_set = set(res.lower() for res in re.findall(r'LV_HAVE_(\w+)', line)) if have_set: haves.append(have_set) return haves ######################################################################## # Represent a processing kernel, parse from file ######################################################################## -class kernel_class: +class kernel_class(object): def __init__(self, kernel_file): self.name = os.path.splitext(os.path.basename(kernel_file))[0] self.pname = self.name.replace('volk_gnsssdr_', 'p_') - code = open(kernel_file, 'r').read() + code = open(kernel_file, 'rb').read().decode("utf-8") code = comment_remover(code) sections = split_into_nested_ifdef_sections(code) self._impls = list() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_machine_defs.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_machine_defs.py index 26e77ec5e..8eb7e5472 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_machine_defs.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_machine_defs.py @@ -26,7 +26,7 @@ from volk_gnsssdr_arch_defs import arch_dict machines = list() machine_dict = dict() -class machine_class: +class machine_class(object): def __init__(self, name, archs): self.name = name self.archs = list() @@ -36,7 +36,7 @@ class machine_class: arch = arch_dict[arch_name] self.archs.append(arch) self.arch_names.append(arch_name) - self.alignment = max(map(lambda a: a.alignment, self.archs)) + self.alignment = max([a.alignment for a in self.archs]) def __repr__(self): return self.name diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_resamplerxnpuppet_16i.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_resamplerxnpuppet_16i.h index 9fb835bd6..1be4896b2 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_resamplerxnpuppet_16i.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_resamplerxnpuppet_16i.h @@ -36,9 +36,9 @@ #define INCLUDED_volk_gnsssdr_16i_resamplerxnpuppet_16i_H #include "volk_gnsssdr/volk_gnsssdr_16i_xn_resampler_16i_xn.h" -#include -#include #include +#include +#include #include #ifdef LV_HAVE_GENERIC @@ -47,7 +47,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_generic(int16_t* resul int code_length_chips = 2046; float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; - unsigned int n; + int n; float rem_code_phase_chips = -0.234; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -77,7 +77,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_a_sse3(int16_t* result float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -106,7 +106,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_u_sse3(int16_t* result float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -136,7 +136,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_u_sse4_1(int16_t* resu float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -166,7 +166,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_a_sse4_1(int16_t* resu float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -196,7 +196,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_u_avx(int16_t* result, float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -226,7 +226,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_a_avx(int16_t* result, float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -256,7 +256,7 @@ static inline void volk_gnsssdr_16i_resamplerxnpuppet_16i_neon(int16_t* result, float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; int16_t** result_aux = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_xn_resampler_16i_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_xn_resampler_16i_xn.h index 6413265b2..2491813bb 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_xn_resampler_16i_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16i_xn_resampler_16i_xn.h @@ -63,12 +63,12 @@ #ifndef INCLUDED_volk_gnsssdr_16i_xn_resampler_16i_xn_H #define INCLUDED_volk_gnsssdr_16i_xn_resampler_16i_xn_H -#include -#include -#include -#include #include #include +#include +#include +#include +#include #ifdef LV_HAVE_GENERIC @@ -77,7 +77,7 @@ static inline void volk_gnsssdr_16i_xn_resampler_16i_xn_generic(int16_t** result { int local_code_chip_index; int current_correlator_tap; - int n; + unsigned int n; for (current_correlator_tap = 0; current_correlator_tap < num_out_vectors; current_correlator_tap++) { for (n = 0; n < num_points; n++) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn.h index b52e032f1..c16812e00 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn.h @@ -69,10 +69,10 @@ #define INCLUDED_volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn_H -#include -#include -#include #include +#include +#include +#include #include //#include @@ -742,9 +742,9 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn_u_sse3(lv_16sc #ifdef LV_HAVE_AVX2 -#include -#include #include +#include +#include static inline void volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn_a_avx2(lv_16sc_t* result, const lv_16sc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const int16_t** in_a, int num_a_vectors, unsigned int num_points) { @@ -896,9 +896,9 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn_a_avx2(lv_16sc #endif /* LV_HAVE_AVX2 */ #ifdef LV_HAVE_AVX2 -#include -#include #include +#include +#include static inline void volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn_u_avx2(lv_16sc_t* result, const lv_16sc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const int16_t** in_a, int num_a_vectors, unsigned int num_points) { diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic.h index ddefa24dc..e28e01225 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic.h @@ -36,8 +36,8 @@ #define INCLUDED_volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_H #include "volk_gnsssdr/volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn.h" -#include #include +#include #include #ifdef LV_HAVE_GENERIC @@ -50,7 +50,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_generic(lv phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -80,7 +80,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_generic_re phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -110,7 +110,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_a_sse3(lv_ phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -141,7 +141,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_a_sse3(lv_ //phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); //lv_32fc_t phase_inc[1]; //phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); -//unsigned int n; +//int n; //int num_a_vectors = 3; //int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); //for(n = 0; n < num_a_vectors; n++) @@ -172,7 +172,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_u_sse3(lv_ phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -203,7 +203,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_a_avx2(lv_ phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -234,7 +234,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_a_avx2(lv_ //phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); //lv_32fc_t phase_inc[1]; //phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); -//unsigned int n; +//int n; //int num_a_vectors = 3; //int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); //for(n = 0; n < num_a_vectors; n++) @@ -265,7 +265,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_u_avx2(lv_ phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -296,7 +296,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_u_avx2(lv_ //phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); //lv_32fc_t phase_inc[1]; //phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); -//unsigned int n; +//int n; //int num_a_vectors = 3; //int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); //for(n = 0; n < num_a_vectors; n++) @@ -327,7 +327,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_u_avx2(lv_ //phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); //lv_32fc_t phase_inc[1]; //phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); -//unsigned int n; +//int n; //int num_a_vectors = 3; //int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); //for(n = 0; n < num_a_vectors; n++) @@ -358,7 +358,7 @@ static inline void volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic_u_avx2(lv_ //phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); //lv_32fc_t phase_inc[1]; //phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); -//unsigned int n; +//int n; //int num_a_vectors = 3; //int16_t** in_a = (int16_t**)volk_gnsssdr_malloc(sizeof(int16_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); //for(n = 0; n < num_a_vectors; n++) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_convert_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_convert_32fc.h index 5e2bf1c0a..57d76874c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_convert_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_convert_32fc.h @@ -179,6 +179,73 @@ static inline void volk_gnsssdr_16ic_convert_32fc_a_axv(lv_32fc_t* outputVector, } #endif /* LV_HAVE_AVX */ +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_convert_32fc_a_avx2(lv_32fc_t* outputVector, const lv_16sc_t* inputVector, unsigned int num_points) +{ + const unsigned int avx_iters = num_points / 8; + unsigned int number = 0; + const int16_t* complexVectorPtr = (int16_t*)inputVector; + float* outputVectorPtr = (float*)outputVector; + __m256 outVal; + __m256i outValInt; + __m128i cplxValue; + + for (number = 0; number < avx_iters; number++) + { + cplxValue = _mm_load_si128((__m128i*)complexVectorPtr); + complexVectorPtr += 8; + + outValInt = _mm256_cvtepi16_epi32(cplxValue); + outVal = _mm256_cvtepi32_ps(outValInt); + _mm256_store_ps((float*)outputVectorPtr, outVal); + + outputVectorPtr += 8; + } + + number = avx_iters * 8; + for (; number < num_points * 2; number++) + { + *outputVectorPtr++ = (float)*complexVectorPtr++; + } +} + +#endif /* LV_HAVE_AVX2 */ + +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_convert_32fc_u_avx2(lv_32fc_t* outputVector, const lv_16sc_t* inputVector, unsigned int num_points) +{ + const unsigned int avx_iters = num_points / 8; + unsigned int number = 0; + const int16_t* complexVectorPtr = (int16_t*)inputVector; + float* outputVectorPtr = (float*)outputVector; + __m256 outVal; + __m256i outValInt; + __m128i cplxValue; + + for (number = 0; number < avx_iters; number++) + { + cplxValue = _mm_loadu_si128((__m128i*)complexVectorPtr); + complexVectorPtr += 8; + + outValInt = _mm256_cvtepi16_epi32(cplxValue); + outVal = _mm256_cvtepi32_ps(outValInt); + _mm256_storeu_ps((float*)outputVectorPtr, outVal); + + outputVectorPtr += 8; + } + + number = avx_iters * 8; + for (; number < num_points * 2; number++) + { + *outputVectorPtr++ = (float)*complexVectorPtr++; + } +} + +#endif /* LV_HAVE_AVX2 */ #ifdef LV_HAVE_NEONV7 #include diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resampler_fast_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resampler_fast_16ic.h index 29dfcd767..634f4f8c3 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resampler_fast_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resampler_fast_16ic.h @@ -61,9 +61,9 @@ #ifndef INCLUDED_volk_gnsssdr_16ic_resampler_fast_16ic_H #define INCLUDED_volk_gnsssdr_16ic_resampler_fast_16ic_H -#include #include #include +#include #ifdef LV_HAVE_GENERIC diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic.h index 8355d1f67..c6e535a42 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic.h @@ -36,9 +36,9 @@ #define INCLUDED_volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic_H #include "volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h" -#include -#include #include +#include +#include #include #ifdef LV_HAVE_GENERIC @@ -47,7 +47,7 @@ static inline void volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic_generic(lv_16sc_ float code_phase_step_chips = 0.1; int code_length_chips = 2046; int num_out_vectors = 3; - unsigned int n; + int n; float* rem_code_phase_chips = (float*)volk_gnsssdr_malloc(sizeof(float) * num_out_vectors, volk_gnsssdr_get_alignment()); lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -76,7 +76,7 @@ static inline void volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic_a_sse2(lv_16sc_t float code_phase_step_chips = 0.1; int code_length_chips = 2046; int num_out_vectors = 3; - unsigned int n; + int n; float* rem_code_phase_chips = (float*)volk_gnsssdr_malloc(sizeof(float) * num_out_vectors, volk_gnsssdr_get_alignment()); lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -105,7 +105,7 @@ static inline void volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic_u_sse2(lv_16sc_t float code_phase_step_chips = 0.1; int code_length_chips = 2046; int num_out_vectors = 3; - unsigned int n; + int n; float* rem_code_phase_chips = (float*)volk_gnsssdr_malloc(sizeof(float) * num_out_vectors, volk_gnsssdr_get_alignment()); lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -134,7 +134,7 @@ static inline void volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic_neon(lv_16sc_t* float code_phase_step_chips = 0.1; int code_length_chips = 2046; int num_out_vectors = 3; - unsigned int n; + int n; float* rem_code_phase_chips = (float*)volk_gnsssdr_malloc(sizeof(float) * num_out_vectors, volk_gnsssdr_get_alignment()); lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerxnpuppet_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerxnpuppet_16ic.h index 3bc7aa0bc..ffac7fece 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerxnpuppet_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_resamplerxnpuppet_16ic.h @@ -36,9 +36,9 @@ #define INCLUDED_volk_gnsssdr_16ic_resamplerxnpuppet_16ic_H #include "volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_16ic_xn.h" -#include -#include #include +#include +#include #include #ifdef LV_HAVE_GENERIC @@ -47,7 +47,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_generic(lv_16sc_t* r int code_length_chips = 2046; float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; - unsigned int n; + int n; float rem_code_phase_chips = -0.234; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -78,7 +78,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_a_sse3(lv_16sc_t* re float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -107,7 +107,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_u_sse3(lv_16sc_t* re float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -137,7 +137,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_u_sse4_1(lv_16sc_t* float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -167,7 +167,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_a_sse4_1(lv_16sc_t* float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -197,7 +197,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_u_avx(lv_16sc_t* res float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -227,7 +227,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_a_avx(lv_16sc_t* res float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -257,7 +257,7 @@ static inline void volk_gnsssdr_16ic_resamplerxnpuppet_16ic_neon(lv_16sc_t* resu float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_16sc_t** result_aux = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h index 8f1c1beb5..757e213d2 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h @@ -36,8 +36,8 @@ #define INCLUDED_volk_gnsssdr_16ic_rotatorpuppet_16ic_H -#include #include "volk_gnsssdr/volk_gnsssdr_16ic_s32fc_x2_rotator_16ic.h" +#include #include diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h index 4834354f5..6d65f80f3 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h @@ -59,9 +59,9 @@ #ifndef INCLUDED_volk_gnsssdr_16ic_x2_dot_prod_16ic_H #define INCLUDED_volk_gnsssdr_16ic_x2_dot_prod_16ic_H +#include #include #include -#include #ifdef LV_HAVE_GENERIC diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic_xn.h index e45b885a9..9d370fb19 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic_xn.h @@ -61,10 +61,10 @@ #define INCLUDED_volk_gnsssdr_16ic_xn_dot_prod_16ic_xn_H +#include +#include #include #include -#include -#include #ifdef LV_HAVE_GENERIC diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic.h index eeec91a59..67bfb1a0b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic.h @@ -36,9 +36,9 @@ #define INCLUDED_volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_H #include "volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic_xn.h" -#include -#include #include +#include +#include #include #ifdef LV_HAVE_GENERIC @@ -46,7 +46,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_generic(lv_16sc_t* { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -70,7 +70,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_generic_sat(lv_16sc { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -94,7 +94,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_a_sse2(lv_16sc_t* r { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -119,7 +119,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_u_sse2(lv_16sc_t* r { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -144,7 +144,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_a_avx2(lv_16sc_t* r { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -169,7 +169,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_u_avx2(lv_16sc_t* r { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -194,7 +194,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_neon(lv_16sc_t* res { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -219,7 +219,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_neon_vma(lv_16sc_t* { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); @@ -243,7 +243,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_neon_optvma(lv_16sc { int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); - unsigned int n; + int n; for (n = 0; n < num_a_vectors; n++) { in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment()); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn.h index 24b2454c4..efc0feb70 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn.h @@ -69,10 +69,10 @@ #define INCLUDED_volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_H -#include -#include -#include #include +#include +#include +#include #include #ifdef LV_HAVE_GENERIC @@ -1490,8 +1490,8 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_neon(lv_16sc_t* #ifdef LV_HAVE_NEONV7 -#include #include +#include static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_neon_vma(lv_16sc_t* result, const lv_16sc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_16sc_t** in_a, int num_a_vectors, unsigned int num_points) { @@ -1687,8 +1687,8 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_neon_vma(lv_16s #ifdef LV_HAVE_NEONV7 -#include #include +#include static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_neon_optvma(lv_16sc_t* result, const lv_16sc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_16sc_t** in_a, int num_a_vectors, unsigned int num_points) { diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic.h index 610d7a884..51536530e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic.h @@ -36,8 +36,8 @@ #define INCLUDED_volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_H #include "volk_gnsssdr/volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn.h" -#include #include +#include #include #ifdef LV_HAVE_GENERIC @@ -50,7 +50,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_generic(lv_ phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -80,7 +80,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_generic_rel phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -110,7 +110,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_a_sse3(lv_1 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -141,7 +141,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_a_sse3_relo phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -172,7 +172,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_u_sse3(lv_1 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -203,7 +203,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_a_avx2(lv_1 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -234,7 +234,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_a_avx2_relo phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -265,7 +265,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_u_avx2(lv_1 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -296,7 +296,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_u_avx2_relo phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -327,7 +327,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_neon(lv_16s phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -358,7 +358,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_neon_vma(lv phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_16ic_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_16ic_xn.h index 8e60443b0..8bf573ea1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_16ic_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_16ic_xn.h @@ -63,10 +63,10 @@ #ifndef INCLUDED_volk_gnsssdr_16ic_xn_resampler_16ic_xn_H #define INCLUDED_volk_gnsssdr_16ic_xn_resampler_16ic_xn_H -#include -#include #include #include +#include +#include #ifdef LV_HAVE_GENERIC @@ -75,8 +75,8 @@ static inline void volk_gnsssdr_16ic_xn_resampler_16ic_xn_generic(lv_16sc_t** re { int local_code_chip_index; int current_correlator_tap; - int n; - for (current_correlator_tap = 0; current_correlator_tap < num_out_vectors; current_correlator_tap++) + unsigned int n; + for (current_correlator_tap = 0U; current_correlator_tap < num_out_vectors; current_correlator_tap++) { for (n = 0; n < num_points; n++) { diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h index 36c5089b6..4d3cc61c1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h @@ -63,9 +63,9 @@ #ifndef INCLUDED_volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_H #define INCLUDED_volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_H -#include #include #include +#include #ifdef LV_HAVE_GENERIC @@ -83,7 +83,7 @@ static inline void volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_generic(lv_16sc_t // resample code for current tap local_code_chip_index = round(code_phase_step_chips * (float)(n) + rem_code_phase_chips[current_vector] - 0.5f); if (local_code_chip_index < 0.0) local_code_chip_index += code_length_chips; - if (local_code_chip_index > (code_length_chips - 1)) local_code_chip_index -= code_length_chips; + if (local_code_chip_index > ((int)code_length_chips - 1)) local_code_chip_index -= code_length_chips; result[current_vector][n] = local_code[local_code_chip_index]; } } @@ -180,7 +180,7 @@ static inline void volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_a_sse2(lv_16sc_t* { local_code_chip_index[0] = (int)(code_phase_step_chips * (float)(number) + rem_code_phase_chips[current_vector]); if (local_code_chip_index[0] < 0.0) local_code_chip_index[0] += code_length_chips - 1; - if (local_code_chip_index[0] > (code_length_chips - 1)) local_code_chip_index[0] -= code_length_chips; + if (local_code_chip_index[0] > ((int)code_length_chips - 1)) local_code_chip_index[0] -= code_length_chips; _result[current_vector][number] = local_code[local_code_chip_index[0]]; } } @@ -276,7 +276,7 @@ static inline void volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_u_sse2(lv_16sc_t* { local_code_chip_index[0] = (int)(code_phase_step_chips * (float)(number) + rem_code_phase_chips[current_vector]); if (local_code_chip_index[0] < 0.0) local_code_chip_index[0] += code_length_chips - 1; - if (local_code_chip_index[0] > (code_length_chips - 1)) local_code_chip_index[0] -= code_length_chips; + if (local_code_chip_index[0] > ((int)code_length_chips - 1)) local_code_chip_index[0] -= code_length_chips; _result[current_vector][number] = local_code[local_code_chip_index[0]]; } } @@ -378,7 +378,7 @@ static inline void volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_neon(lv_16sc_t** { local_code_chip_index[0] = (int)(code_phase_step_chips * (float)(number) + rem_code_phase_chips[current_vector]); if (local_code_chip_index[0] < 0.0) local_code_chip_index[0] += code_length_chips - 1; - if (local_code_chip_index[0] > (code_length_chips - 1)) local_code_chip_index[0] -= code_length_chips; + if (local_code_chip_index[0] > ((int)code_length_chips - 1)) local_code_chip_index[0] -= code_length_chips; _result[current_vector][number] = local_code[local_code_chip_index[0]]; } } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f.h new file mode 100644 index 000000000..d6fbcf756 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f.h @@ -0,0 +1,288 @@ +/*! + * \file volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f.h + * \brief VOLK_GNSSSDR puppet for the multiple 32-bit float vector high dynamics resampler kernel. + * \authors
                  + *
                • Cillian O'Driscoll 2017 cillian.odriscoll at gmail dot com + *
                • Javier Arribas, 2018. javiarribas(at)gmail.com + *
                + * + * VOLK_GNSSSDR puppet for integrating the multiple resampler into the test system + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef INCLUDED_volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_H +#define INCLUDED_volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_H + +#include "volk_gnsssdr/volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn.h" +#include +#include +#include +#include + + +#ifdef LV_HAVE_GENERIC +static inline void volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_generic(float* result, const float* local_code, unsigned int num_points) +{ + int code_length_chips = 2046; + float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); + int num_out_vectors = 3; + float rem_code_phase_chips = -0.8234; + float code_phase_rate_step_chips = 1.0 / powf(2.0, 33.0); + int n; + float shifts_chips[3] = {-0.1, 0.0, 0.1}; + + float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_out_vectors; n++) + { + result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + } + + volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_generic(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); + + memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); + + for (n = 0; n < num_out_vectors; n++) + { + volk_gnsssdr_free(result_aux[n]); + } + volk_gnsssdr_free(result_aux); +} + +#endif /* LV_HAVE_GENERIC */ + + +#ifdef LV_HAVE_SSE3 +static inline void volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_a_sse3(float* result, const float* local_code, unsigned int num_points) +{ + int code_length_chips = 2046; + float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); + int num_out_vectors = 3; + float rem_code_phase_chips = -0.8234; + float code_phase_rate_step_chips = 1.0 / powf(2.0, 33.0); + int n; + float shifts_chips[3] = {-0.1, 0.0, 0.1}; + + float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_out_vectors; n++) + { + result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + } + + volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_a_sse3(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); + + memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); + + for (n = 0; n < num_out_vectors; n++) + { + volk_gnsssdr_free(result_aux[n]); + } + volk_gnsssdr_free(result_aux); +} + +#endif + + +#ifdef LV_HAVE_SSE3 +static inline void volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_u_sse3(float* result, const float* local_code, unsigned int num_points) +{ + int code_length_chips = 2046; + float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); + int num_out_vectors = 3; + float rem_code_phase_chips = -0.8234; + float code_phase_rate_step_chips = 1.0 / powf(2.0, 33.0); + int n; + float shifts_chips[3] = {-0.1, 0.0, 0.1}; + + float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_out_vectors; n++) + { + result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + } + + volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_u_sse3(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); + + memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); + + for (n = 0; n < num_out_vectors; n++) + { + volk_gnsssdr_free(result_aux[n]); + } + volk_gnsssdr_free(result_aux); +} + +#endif + + +#ifdef LV_HAVE_SSE4_1 +static inline void volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_u_sse4_1(float* result, const float* local_code, unsigned int num_points) +{ + int code_length_chips = 2046; + float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); + int num_out_vectors = 3; + float rem_code_phase_chips = -0.8234; + float code_phase_rate_step_chips = 1.0 / powf(2.0, 33.0); + int n; + float shifts_chips[3] = {-0.1, 0.0, 0.1}; + + float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_out_vectors; n++) + { + result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + } + + volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_u_sse4_1(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); + + memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); + + for (n = 0; n < num_out_vectors; n++) + { + volk_gnsssdr_free(result_aux[n]); + } + volk_gnsssdr_free(result_aux); +} + +#endif + + +#ifdef LV_HAVE_SSE4_1 +static inline void volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_a_sse4_1(float* result, const float* local_code, unsigned int num_points) +{ + int code_length_chips = 2046; + float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); + int num_out_vectors = 3; + float rem_code_phase_chips = -0.8234; + float code_phase_rate_step_chips = 1.0 / powf(2.0, 33.0); + int n; + float shifts_chips[3] = {-0.1, 0.0, 0.1}; + + float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_out_vectors; n++) + { + result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + } + + volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_a_sse4_1(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); + + memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); + + for (n = 0; n < num_out_vectors; n++) + { + volk_gnsssdr_free(result_aux[n]); + } + volk_gnsssdr_free(result_aux); +} + +#endif + + +#ifdef LV_HAVE_AVX +static inline void volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_a_avx(float* result, const float* local_code, unsigned int num_points) +{ + int code_length_chips = 2046; + float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); + int num_out_vectors = 3; + float rem_code_phase_chips = -0.8234; + float code_phase_rate_step_chips = 1.0 / powf(2.0, 33.0); + int n; + float shifts_chips[3] = {-0.1, 0.0, 0.1}; + + float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_out_vectors; n++) + { + result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + } + + volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_a_avx(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); + + memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); + + for (n = 0; n < num_out_vectors; n++) + { + volk_gnsssdr_free(result_aux[n]); + } + volk_gnsssdr_free(result_aux); +} +#endif + + +#ifdef LV_HAVE_AVX +static inline void volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f_u_avx(float* result, const float* local_code, unsigned int num_points) +{ + int code_length_chips = 2046; + float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); + int num_out_vectors = 3; + float rem_code_phase_chips = -0.8234; + float code_phase_rate_step_chips = 1.0 / powf(2.0, 33.0); + int n; + float shifts_chips[3] = {-0.1, 0.0, 0.1}; + + float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_out_vectors; n++) + { + result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + } + + volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_u_avx(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); + + memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); + + for (n = 0; n < num_out_vectors; n++) + { + volk_gnsssdr_free(result_aux[n]); + } + volk_gnsssdr_free(result_aux); +} +#endif +// +//#ifdef LV_HAVE_NEONV7 +//static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_neon(float* result, const float* local_code, unsigned int num_points) +//{ +// int code_length_chips = 2046; +// float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); +// int num_out_vectors = 3; +// float rem_code_phase_chips = -0.234; +// int n; +// float shifts_chips[3] = {-0.1, 0.0, 0.1}; +// +// float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); +// for (n = 0; n < num_out_vectors; n++) +// { +// result_aux[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); +// } +// +// volk_gnsssdr_32f_xn_resampler_32f_xn_neon(result_aux, local_code, rem_code_phase_chips, code_phase_step_chips, shifts_chips, code_length_chips, num_out_vectors, num_points); +// +// memcpy((float*)result, (float*)result_aux[0], sizeof(float) * num_points); +// +// for (n = 0; n < num_out_vectors; n++) +// { +// volk_gnsssdr_free(result_aux[n]); +// } +// volk_gnsssdr_free(result_aux); +//} +//#endif + +#endif // INCLUDED_volk_gnsssdr_32f_high_dynamics_resamplerpuppet_32f_H diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_resamplerxnpuppet_32f.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_resamplerxnpuppet_32f.h index 1ee4f64cb..5f979c69e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_resamplerxnpuppet_32f.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_resamplerxnpuppet_32f.h @@ -36,9 +36,9 @@ #define INCLUDED_volk_gnsssdr_32f_resamplerxnpuppet_32f_H #include "volk_gnsssdr/volk_gnsssdr_32f_xn_resampler_32f_xn.h" -#include -#include #include +#include +#include #include @@ -49,7 +49,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_generic(float* result, float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -79,7 +79,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_a_sse3(float* result, float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -108,7 +108,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_u_sse3(float* result, float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -138,7 +138,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_u_sse4_1(float* result float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -167,7 +167,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_a_sse4_1(float* result float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -196,7 +196,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_a_avx(float* result, c float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -225,7 +225,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_u_avx(float* result, c float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -253,7 +253,7 @@ static inline void volk_gnsssdr_32f_resamplerxnpuppet_32f_neon(float* result, co float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; float** result_aux = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_out_vectors, volk_gnsssdr_get_alignment()); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_sincos_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_sincos_32fc.h index 8936901b0..9c7f01227 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_sincos_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_sincos_32fc.h @@ -57,9 +57,9 @@ #ifndef INCLUDED_volk_gnsssdr_32f_sincos_32fc_H #define INCLUDED_volk_gnsssdr_32f_sincos_32fc_H -#include #include #include +#include #ifdef LV_HAVE_SSE4_1 #include diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn.h new file mode 100644 index 000000000..db878c584 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn.h @@ -0,0 +1,707 @@ +/*! + * \file volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn.h + * \brief VOLK_GNSSSDR kernel: Resamples 1 complex 32-bit float vectors using zero hold resample algorithm + * and produces the delayed replicas by copying and rotating the resulting resampled signal. + * \authors
                  + *
                • Cillian O'Driscoll, 2017. cillian.odirscoll(at)gmail.com + *
                • Javier Arribas, 2018. javiarribas(at)gmail.com + *
                + * + * VOLK_GNSSSDR kernel that resamples N 32-bit float vectors using zero hold resample algorithm. + * It is optimized to resample a single GNSS local code signal replica into 1 vector fractional-resampled and fractional-delayed + * and produces the delayed replicas by copying and rotating the resulting resampled signal. + * (i.e. it creates the Early, Prompt, and Late code replicas) + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +/*! + * \page volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn + * + * \b Overview + * + * Resamples a 32-bit floating point vector , providing \p num_out_vectors outputs. + * + * Dispatcher Prototype + * \code + * void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) + * \endcode + * + * \b Inputs + * \li local_code: Vector to be resampled. + * \li rem_code_phase_chips: Remnant code phase [chips]. + * \li code_phase_step_chips: Phase increment per sample [chips/sample]. + * \li code_phase_rate_step_chips: Phase rate increment per sample [chips/sample^2]. + * \li shifts_chips: Vector of floats that defines the spacing (in chips) between the replicas of \p local_code + * \li code_length_chips: Code length in chips. + * \li num_out_vectors Number of output vectors. + * \li num_points: The number of data values to be in the resampled vector. + * + * \b Outputs + * \li result: Pointer to a vector of pointers where the results will be stored. + * + */ + +#ifndef INCLUDED_volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_H +#define INCLUDED_volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_H + +#include +#include +#include +#include +#include /* int64_t */ +#include +#include /* abs */ + + +#ifdef LV_HAVE_GENERIC + +static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_generic(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +{ + int local_code_chip_index; + int current_correlator_tap; + unsigned int n; + //first correlator + for (n = 0; n < num_points; n++) + { + // resample code for first tap + local_code_chip_index = (int)floor(code_phase_step_chips * (float)n + code_phase_rate_step_chips * (float)(n * n) + shifts_chips[0] - rem_code_phase_chips); + // Take into account that in multitap correlators, the shifts can be negative! + if (local_code_chip_index < 0) local_code_chip_index += (int)code_length_chips * (abs(local_code_chip_index) / code_length_chips + 1); + local_code_chip_index = local_code_chip_index % code_length_chips; + result[0][n] = local_code[local_code_chip_index]; + } + + //adjacent correlators + unsigned int shift_samples = 0; + for (current_correlator_tap = 1; current_correlator_tap < num_out_vectors; current_correlator_tap++) + { + shift_samples += (int)round((shifts_chips[current_correlator_tap] - shifts_chips[current_correlator_tap - 1]) / code_phase_step_chips); + memcpy(&result[current_correlator_tap][0], &result[0][shift_samples], (num_points - shift_samples) * sizeof(float)); + memcpy(&result[current_correlator_tap][num_points - shift_samples], &result[0][0], shift_samples * sizeof(float)); + } +} + +#endif /*LV_HAVE_GENERIC*/ + + +#ifdef LV_HAVE_SSE3 +#include +static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_a_sse3(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +{ + float** _result = result; + const unsigned int quarterPoints = num_points / 4; + // int current_correlator_tap; + unsigned int n; + unsigned int k; + int current_correlator_tap; + const __m128 ones = _mm_set1_ps(1.0f); + const __m128 fours = _mm_set1_ps(4.0f); + const __m128 rem_code_phase_chips_reg = _mm_set_ps1(rem_code_phase_chips); + const __m128 code_phase_step_chips_reg = _mm_set_ps1(code_phase_step_chips); + const __m128 code_phase_rate_step_chips_reg = _mm_set_ps1(code_phase_rate_step_chips); + + __VOLK_ATTR_ALIGNED(16) + int local_code_chip_index[4]; + int local_code_chip_index_; + const __m128i zeros = _mm_setzero_si128(); + const __m128 code_length_chips_reg_f = _mm_set_ps1((float)code_length_chips); + const __m128i code_length_chips_reg_i = _mm_set1_epi32((int)code_length_chips); + __m128i local_code_chip_index_reg, aux_i, negatives, i; + __m128 aux, aux2, aux3, indexnn, shifts_chips_reg, fi, igx, j, c, cTrunc, base; + __m128 indexn = _mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f); + + shifts_chips_reg = _mm_set_ps1((float)shifts_chips[0]); + aux2 = _mm_sub_ps(shifts_chips_reg, rem_code_phase_chips_reg); + + for (n = 0; n < quarterPoints; n++) + { + aux = _mm_mul_ps(code_phase_step_chips_reg, indexn); + indexnn = _mm_mul_ps(indexn, indexn); + aux3 = _mm_mul_ps(code_phase_rate_step_chips_reg, indexnn); + aux = _mm_add_ps(aux, aux3); + aux = _mm_add_ps(aux, aux2); + // floor + i = _mm_cvttps_epi32(aux); + fi = _mm_cvtepi32_ps(i); + igx = _mm_cmpgt_ps(fi, aux); + j = _mm_and_ps(igx, ones); + aux = _mm_sub_ps(fi, j); + + // Correct negative shift + c = _mm_div_ps(aux, code_length_chips_reg_f); + aux3 = _mm_add_ps(c, ones); + i = _mm_cvttps_epi32(aux3); + cTrunc = _mm_cvtepi32_ps(i); + base = _mm_mul_ps(cTrunc, code_length_chips_reg_f); + local_code_chip_index_reg = _mm_cvtps_epi32(_mm_sub_ps(aux, base)); + negatives = _mm_cmplt_epi32(local_code_chip_index_reg, zeros); + aux_i = _mm_and_si128(code_length_chips_reg_i, negatives); + local_code_chip_index_reg = _mm_add_epi32(local_code_chip_index_reg, aux_i); + + _mm_store_si128((__m128i*)local_code_chip_index, local_code_chip_index_reg); + + for (k = 0; k < 4; ++k) + { + _result[0][n * 4 + k] = local_code[local_code_chip_index[k]]; + } + indexn = _mm_add_ps(indexn, fours); + } + + for (n = quarterPoints * 4; n < num_points; n++) + { + // resample code for first tap + local_code_chip_index_ = (int)floor(code_phase_step_chips * (float)n + code_phase_rate_step_chips * (float)(n * n) + shifts_chips[0] - rem_code_phase_chips); + // Take into account that in multitap correlators, the shifts can be negative! + if (local_code_chip_index_ < 0) local_code_chip_index_ += (int)code_length_chips * (abs(local_code_chip_index_) / code_length_chips + 1); + local_code_chip_index_ = local_code_chip_index_ % code_length_chips; + _result[0][n] = local_code[local_code_chip_index_]; + } + + // adjacent correlators + unsigned int shift_samples = 0; + for (current_correlator_tap = 1; current_correlator_tap < num_out_vectors; current_correlator_tap++) + { + shift_samples += (int)round((shifts_chips[current_correlator_tap] - shifts_chips[current_correlator_tap - 1]) / code_phase_step_chips); + memcpy(&_result[current_correlator_tap][0], &_result[0][shift_samples], (num_points - shift_samples) * sizeof(float)); + memcpy(&_result[current_correlator_tap][num_points - shift_samples], &_result[0][0], shift_samples * sizeof(float)); + } +} +#endif + + +#ifdef LV_HAVE_SSE3 +#include +static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_u_sse3(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +{ + float** _result = result; + const unsigned int quarterPoints = num_points / 4; + // int current_correlator_tap; + unsigned int n; + unsigned int k; + int current_correlator_tap; + const __m128 ones = _mm_set1_ps(1.0f); + const __m128 fours = _mm_set1_ps(4.0f); + const __m128 rem_code_phase_chips_reg = _mm_set_ps1(rem_code_phase_chips); + const __m128 code_phase_step_chips_reg = _mm_set_ps1(code_phase_step_chips); + const __m128 code_phase_rate_step_chips_reg = _mm_set_ps1(code_phase_rate_step_chips); + + __VOLK_ATTR_ALIGNED(16) + int local_code_chip_index[4]; + int local_code_chip_index_; + const __m128i zeros = _mm_setzero_si128(); + const __m128 code_length_chips_reg_f = _mm_set_ps1((float)code_length_chips); + const __m128i code_length_chips_reg_i = _mm_set1_epi32((int)code_length_chips); + __m128i local_code_chip_index_reg, aux_i, negatives, i; + __m128 aux, aux2, aux3, indexnn, shifts_chips_reg, fi, igx, j, c, cTrunc, base; + __m128 indexn = _mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f); + + shifts_chips_reg = _mm_set_ps1((float)shifts_chips[0]); + aux2 = _mm_sub_ps(shifts_chips_reg, rem_code_phase_chips_reg); + + for (n = 0; n < quarterPoints; n++) + { + aux = _mm_mul_ps(code_phase_step_chips_reg, indexn); + indexnn = _mm_mul_ps(indexn, indexn); + aux3 = _mm_mul_ps(code_phase_rate_step_chips_reg, indexnn); + aux = _mm_add_ps(aux, aux3); + aux = _mm_add_ps(aux, aux2); + // floor + i = _mm_cvttps_epi32(aux); + fi = _mm_cvtepi32_ps(i); + igx = _mm_cmpgt_ps(fi, aux); + j = _mm_and_ps(igx, ones); + aux = _mm_sub_ps(fi, j); + + // Correct negative shift + c = _mm_div_ps(aux, code_length_chips_reg_f); + aux3 = _mm_add_ps(c, ones); + i = _mm_cvttps_epi32(aux3); + cTrunc = _mm_cvtepi32_ps(i); + base = _mm_mul_ps(cTrunc, code_length_chips_reg_f); + local_code_chip_index_reg = _mm_cvtps_epi32(_mm_sub_ps(aux, base)); + negatives = _mm_cmplt_epi32(local_code_chip_index_reg, zeros); + aux_i = _mm_and_si128(code_length_chips_reg_i, negatives); + local_code_chip_index_reg = _mm_add_epi32(local_code_chip_index_reg, aux_i); + + _mm_store_si128((__m128i*)local_code_chip_index, local_code_chip_index_reg); + + for (k = 0; k < 4; ++k) + { + _result[0][n * 4 + k] = local_code[local_code_chip_index[k]]; + } + indexn = _mm_add_ps(indexn, fours); + } + + for (n = quarterPoints * 4; n < num_points; n++) + { + // resample code for first tap + local_code_chip_index_ = (int)floor(code_phase_step_chips * (float)n + code_phase_rate_step_chips * (float)(n * n) + shifts_chips[0] - rem_code_phase_chips); + // Take into account that in multitap correlators, the shifts can be negative! + if (local_code_chip_index_ < 0) local_code_chip_index_ += (int)code_length_chips * (abs(local_code_chip_index_) / code_length_chips + 1); + local_code_chip_index_ = local_code_chip_index_ % code_length_chips; + _result[0][n] = local_code[local_code_chip_index_]; + } + + // adjacent correlators + unsigned int shift_samples = 0; + for (current_correlator_tap = 1; current_correlator_tap < num_out_vectors; current_correlator_tap++) + { + shift_samples += (int)round((shifts_chips[current_correlator_tap] - shifts_chips[current_correlator_tap - 1]) / code_phase_step_chips); + memcpy(&_result[current_correlator_tap][0], &_result[0][shift_samples], (num_points - shift_samples) * sizeof(float)); + memcpy(&_result[current_correlator_tap][num_points - shift_samples], &_result[0][0], shift_samples * sizeof(float)); + } +} + +#endif + + +#ifdef LV_HAVE_SSE4_1 +#include +static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_a_sse4_1(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +{ + float** _result = result; + const unsigned int quarterPoints = num_points / 4; + // int current_correlator_tap; + unsigned int n; + unsigned int k; + int current_correlator_tap; + const __m128 ones = _mm_set1_ps(1.0f); + const __m128 fours = _mm_set1_ps(4.0f); + const __m128 rem_code_phase_chips_reg = _mm_set_ps1(rem_code_phase_chips); + const __m128 code_phase_step_chips_reg = _mm_set_ps1(code_phase_step_chips); + const __m128 code_phase_rate_step_chips_reg = _mm_set_ps1(code_phase_rate_step_chips); + + __VOLK_ATTR_ALIGNED(16) + int local_code_chip_index[4]; + int local_code_chip_index_; + const __m128i zeros = _mm_setzero_si128(); + const __m128 code_length_chips_reg_f = _mm_set_ps1((float)code_length_chips); + const __m128i code_length_chips_reg_i = _mm_set1_epi32((int)code_length_chips); + __m128i local_code_chip_index_reg, aux_i, negatives, i; + __m128 aux, aux2, aux3, indexnn, shifts_chips_reg, c, cTrunc, base; + __m128 indexn = _mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f); + + shifts_chips_reg = _mm_set_ps1((float)shifts_chips[0]); + aux2 = _mm_sub_ps(shifts_chips_reg, rem_code_phase_chips_reg); + + for (n = 0; n < quarterPoints; n++) + { + aux = _mm_mul_ps(code_phase_step_chips_reg, indexn); + indexnn = _mm_mul_ps(indexn, indexn); + aux3 = _mm_mul_ps(code_phase_rate_step_chips_reg, indexnn); + aux = _mm_add_ps(aux, aux3); + aux = _mm_add_ps(aux, aux2); + // floor + aux = _mm_floor_ps(aux); + + // Correct negative shift + c = _mm_div_ps(aux, code_length_chips_reg_f); + aux3 = _mm_add_ps(c, ones); + i = _mm_cvttps_epi32(aux3); + cTrunc = _mm_cvtepi32_ps(i); + base = _mm_mul_ps(cTrunc, code_length_chips_reg_f); + local_code_chip_index_reg = _mm_cvtps_epi32(_mm_sub_ps(aux, base)); + negatives = _mm_cmplt_epi32(local_code_chip_index_reg, zeros); + aux_i = _mm_and_si128(code_length_chips_reg_i, negatives); + local_code_chip_index_reg = _mm_add_epi32(local_code_chip_index_reg, aux_i); + + _mm_store_si128((__m128i*)local_code_chip_index, local_code_chip_index_reg); + + for (k = 0; k < 4; ++k) + { + _result[0][n * 4 + k] = local_code[local_code_chip_index[k]]; + } + indexn = _mm_add_ps(indexn, fours); + } + + for (n = quarterPoints * 4; n < num_points; n++) + { + // resample code for first tap + local_code_chip_index_ = (int)floor(code_phase_step_chips * (float)n + code_phase_rate_step_chips * (float)(n * n) + shifts_chips[0] - rem_code_phase_chips); + // Take into account that in multitap correlators, the shifts can be negative! + if (local_code_chip_index_ < 0) local_code_chip_index_ += (int)code_length_chips * (abs(local_code_chip_index_) / code_length_chips + 1); + local_code_chip_index_ = local_code_chip_index_ % code_length_chips; + _result[0][n] = local_code[local_code_chip_index_]; + } + + // adjacent correlators + unsigned int shift_samples = 0; + for (current_correlator_tap = 1; current_correlator_tap < num_out_vectors; current_correlator_tap++) + { + shift_samples += (int)round((shifts_chips[current_correlator_tap] - shifts_chips[current_correlator_tap - 1]) / code_phase_step_chips); + memcpy(&_result[current_correlator_tap][0], &_result[0][shift_samples], (num_points - shift_samples) * sizeof(float)); + memcpy(&_result[current_correlator_tap][num_points - shift_samples], &_result[0][0], shift_samples * sizeof(float)); + } +} + +#endif + + +#ifdef LV_HAVE_SSE4_1 +#include +static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_u_sse4_1(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +{ + float** _result = result; + const unsigned int quarterPoints = num_points / 4; + // int current_correlator_tap; + unsigned int n; + unsigned int k; + int current_correlator_tap; + const __m128 ones = _mm_set1_ps(1.0f); + const __m128 fours = _mm_set1_ps(4.0f); + const __m128 rem_code_phase_chips_reg = _mm_set_ps1(rem_code_phase_chips); + const __m128 code_phase_step_chips_reg = _mm_set_ps1(code_phase_step_chips); + const __m128 code_phase_rate_step_chips_reg = _mm_set_ps1(code_phase_rate_step_chips); + + __VOLK_ATTR_ALIGNED(16) + int local_code_chip_index[4]; + int local_code_chip_index_; + const __m128i zeros = _mm_setzero_si128(); + const __m128 code_length_chips_reg_f = _mm_set_ps1((float)code_length_chips); + const __m128i code_length_chips_reg_i = _mm_set1_epi32((int)code_length_chips); + __m128i local_code_chip_index_reg, aux_i, negatives, i; + __m128 aux, aux2, aux3, indexnn, shifts_chips_reg, c, cTrunc, base; + __m128 indexn = _mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f); + + shifts_chips_reg = _mm_set_ps1((float)shifts_chips[0]); + aux2 = _mm_sub_ps(shifts_chips_reg, rem_code_phase_chips_reg); + + for (n = 0; n < quarterPoints; n++) + { + aux = _mm_mul_ps(code_phase_step_chips_reg, indexn); + indexnn = _mm_mul_ps(indexn, indexn); + aux3 = _mm_mul_ps(code_phase_rate_step_chips_reg, indexnn); + aux = _mm_add_ps(aux, aux3); + aux = _mm_add_ps(aux, aux2); + // floor + aux = _mm_floor_ps(aux); + + // Correct negative shift + c = _mm_div_ps(aux, code_length_chips_reg_f); + aux3 = _mm_add_ps(c, ones); + i = _mm_cvttps_epi32(aux3); + cTrunc = _mm_cvtepi32_ps(i); + base = _mm_mul_ps(cTrunc, code_length_chips_reg_f); + local_code_chip_index_reg = _mm_cvtps_epi32(_mm_sub_ps(aux, base)); + negatives = _mm_cmplt_epi32(local_code_chip_index_reg, zeros); + aux_i = _mm_and_si128(code_length_chips_reg_i, negatives); + local_code_chip_index_reg = _mm_add_epi32(local_code_chip_index_reg, aux_i); + + _mm_store_si128((__m128i*)local_code_chip_index, local_code_chip_index_reg); + + for (k = 0; k < 4; ++k) + { + _result[0][n * 4 + k] = local_code[local_code_chip_index[k]]; + } + indexn = _mm_add_ps(indexn, fours); + } + + for (n = quarterPoints * 4; n < num_points; n++) + { + // resample code for first tap + local_code_chip_index_ = (int)floor(code_phase_step_chips * (float)n + code_phase_rate_step_chips * (float)(n * n) + shifts_chips[0] - rem_code_phase_chips); + // Take into account that in multitap correlators, the shifts can be negative! + if (local_code_chip_index_ < 0) local_code_chip_index_ += (int)code_length_chips * (abs(local_code_chip_index_) / code_length_chips + 1); + local_code_chip_index_ = local_code_chip_index_ % code_length_chips; + _result[0][n] = local_code[local_code_chip_index_]; + } + + // adjacent correlators + unsigned int shift_samples = 0; + for (current_correlator_tap = 1; current_correlator_tap < num_out_vectors; current_correlator_tap++) + { + shift_samples += (int)round((shifts_chips[current_correlator_tap] - shifts_chips[current_correlator_tap - 1]) / code_phase_step_chips); + memcpy(&_result[current_correlator_tap][0], &_result[0][shift_samples], (num_points - shift_samples) * sizeof(float)); + memcpy(&_result[current_correlator_tap][num_points - shift_samples], &_result[0][0], shift_samples * sizeof(float)); + } +} + +#endif + + +#ifdef LV_HAVE_AVX +#include +static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_a_avx(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +{ + float** _result = result; + const unsigned int avx_iters = num_points / 8; + int current_correlator_tap; + unsigned int n; + unsigned int k; + const __m256 eights = _mm256_set1_ps(8.0f); + const __m256 ones = _mm256_set1_ps(1.0f); + const __m256 rem_code_phase_chips_reg = _mm256_set1_ps(rem_code_phase_chips); + const __m256 code_phase_step_chips_reg = _mm256_set1_ps(code_phase_step_chips); + const __m256 code_phase_rate_step_chips_reg = _mm256_set1_ps(code_phase_rate_step_chips); + + __VOLK_ATTR_ALIGNED(32) + int local_code_chip_index[8]; + int local_code_chip_index_; + + const __m256 zeros = _mm256_setzero_ps(); + const __m256 code_length_chips_reg_f = _mm256_set1_ps((float)code_length_chips); + const __m256 n0 = _mm256_set_ps(7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f); + + __m256i local_code_chip_index_reg, i; + __m256 aux, aux2, aux3, shifts_chips_reg, c, cTrunc, base, negatives, indexn, indexnn; + + shifts_chips_reg = _mm256_set1_ps((float)shifts_chips[0]); + aux2 = _mm256_sub_ps(shifts_chips_reg, rem_code_phase_chips_reg); + indexn = n0; + for (n = 0; n < avx_iters; n++) + { + __VOLK_GNSSSDR_PREFETCH_LOCALITY(&_result[0][8 * n + 7], 1, 0); + __VOLK_GNSSSDR_PREFETCH_LOCALITY(&local_code_chip_index[8], 1, 3); + aux = _mm256_mul_ps(code_phase_step_chips_reg, indexn); + indexnn = _mm256_mul_ps(indexn, indexn); + aux3 = _mm256_mul_ps(code_phase_rate_step_chips_reg, indexnn); + aux = _mm256_add_ps(aux, aux3); + aux = _mm256_add_ps(aux, aux2); + // floor + aux = _mm256_floor_ps(aux); + + // Correct negative shift + c = _mm256_div_ps(aux, code_length_chips_reg_f); + aux3 = _mm256_add_ps(c, ones); + i = _mm256_cvttps_epi32(aux3); + cTrunc = _mm256_cvtepi32_ps(i); + base = _mm256_mul_ps(cTrunc, code_length_chips_reg_f); + local_code_chip_index_reg = _mm256_cvttps_epi32(_mm256_sub_ps(aux, base)); + + c = _mm256_cvtepi32_ps(local_code_chip_index_reg); + negatives = _mm256_cmp_ps(c, zeros, 0x01); + aux3 = _mm256_and_ps(code_length_chips_reg_f, negatives); + aux = _mm256_add_ps(c, aux3); + local_code_chip_index_reg = _mm256_cvttps_epi32(aux); + + _mm256_store_si256((__m256i*)local_code_chip_index, local_code_chip_index_reg); + for (k = 0; k < 8; ++k) + { + _result[0][n * 8 + k] = local_code[local_code_chip_index[k]]; + } + indexn = _mm256_add_ps(indexn, eights); + } + + _mm256_zeroupper(); + + for (n = avx_iters * 8; n < num_points; n++) + { + // resample code for first tap + local_code_chip_index_ = (int)floor(code_phase_step_chips * (float)n + code_phase_rate_step_chips * (float)(n * n) + shifts_chips[0] - rem_code_phase_chips); + // Take into account that in multitap correlators, the shifts can be negative! + if (local_code_chip_index_ < 0) local_code_chip_index_ += (int)code_length_chips * (abs(local_code_chip_index_) / code_length_chips + 1); + local_code_chip_index_ = local_code_chip_index_ % code_length_chips; + _result[0][n] = local_code[local_code_chip_index_]; + } + + // adjacent correlators + unsigned int shift_samples = 0; + for (current_correlator_tap = 1; current_correlator_tap < num_out_vectors; current_correlator_tap++) + { + shift_samples += (int)round((shifts_chips[current_correlator_tap] - shifts_chips[current_correlator_tap - 1]) / code_phase_step_chips); + memcpy(&_result[current_correlator_tap][0], &_result[0][shift_samples], (num_points - shift_samples) * sizeof(float)); + memcpy(&_result[current_correlator_tap][num_points - shift_samples], &_result[0][0], shift_samples * sizeof(float)); + } +} + +#endif + + +#ifdef LV_HAVE_AVX +#include +static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_u_avx(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +{ + float** _result = result; + const unsigned int avx_iters = num_points / 8; + int current_correlator_tap; + unsigned int n; + unsigned int k; + const __m256 eights = _mm256_set1_ps(8.0f); + const __m256 ones = _mm256_set1_ps(1.0f); + const __m256 rem_code_phase_chips_reg = _mm256_set1_ps(rem_code_phase_chips); + const __m256 code_phase_step_chips_reg = _mm256_set1_ps(code_phase_step_chips); + const __m256 code_phase_rate_step_chips_reg = _mm256_set1_ps(code_phase_rate_step_chips); + + __VOLK_ATTR_ALIGNED(32) + int local_code_chip_index[8]; + int local_code_chip_index_; + + const __m256 zeros = _mm256_setzero_ps(); + const __m256 code_length_chips_reg_f = _mm256_set1_ps((float)code_length_chips); + const __m256 n0 = _mm256_set_ps(7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f); + + __m256i local_code_chip_index_reg, i; + __m256 aux, aux2, aux3, shifts_chips_reg, c, cTrunc, base, negatives, indexn, indexnn; + + shifts_chips_reg = _mm256_set1_ps((float)shifts_chips[0]); + aux2 = _mm256_sub_ps(shifts_chips_reg, rem_code_phase_chips_reg); + indexn = n0; + for (n = 0; n < avx_iters; n++) + { + __VOLK_GNSSSDR_PREFETCH_LOCALITY(&_result[0][8 * n + 7], 1, 0); + __VOLK_GNSSSDR_PREFETCH_LOCALITY(&local_code_chip_index[8], 1, 3); + aux = _mm256_mul_ps(code_phase_step_chips_reg, indexn); + indexnn = _mm256_mul_ps(indexn, indexn); + aux3 = _mm256_mul_ps(code_phase_rate_step_chips_reg, indexnn); + aux = _mm256_add_ps(aux, aux3); + aux = _mm256_add_ps(aux, aux2); + // floor + aux = _mm256_floor_ps(aux); + + // Correct negative shift + c = _mm256_div_ps(aux, code_length_chips_reg_f); + aux3 = _mm256_add_ps(c, ones); + i = _mm256_cvttps_epi32(aux3); + cTrunc = _mm256_cvtepi32_ps(i); + base = _mm256_mul_ps(cTrunc, code_length_chips_reg_f); + local_code_chip_index_reg = _mm256_cvttps_epi32(_mm256_sub_ps(aux, base)); + + c = _mm256_cvtepi32_ps(local_code_chip_index_reg); + negatives = _mm256_cmp_ps(c, zeros, 0x01); + aux3 = _mm256_and_ps(code_length_chips_reg_f, negatives); + aux = _mm256_add_ps(c, aux3); + local_code_chip_index_reg = _mm256_cvttps_epi32(aux); + + _mm256_store_si256((__m256i*)local_code_chip_index, local_code_chip_index_reg); + for (k = 0; k < 8; ++k) + { + _result[0][n * 8 + k] = local_code[local_code_chip_index[k]]; + } + indexn = _mm256_add_ps(indexn, eights); + } + + _mm256_zeroupper(); + + for (n = avx_iters * 8; n < num_points; n++) + { + // resample code for first tap + local_code_chip_index_ = (int)floor(code_phase_step_chips * (float)n + code_phase_rate_step_chips * (float)(n * n) + shifts_chips[0] - rem_code_phase_chips); + // Take into account that in multitap correlators, the shifts can be negative! + if (local_code_chip_index_ < 0) local_code_chip_index_ += (int)code_length_chips * (abs(local_code_chip_index_) / code_length_chips + 1); + local_code_chip_index_ = local_code_chip_index_ % code_length_chips; + _result[0][n] = local_code[local_code_chip_index_]; + } + + // adjacent correlators + unsigned int shift_samples = 0; + for (current_correlator_tap = 1; current_correlator_tap < num_out_vectors; current_correlator_tap++) + { + shift_samples += (int)round((shifts_chips[current_correlator_tap] - shifts_chips[current_correlator_tap - 1]) / code_phase_step_chips); + memcpy(&_result[current_correlator_tap][0], &_result[0][shift_samples], (num_points - shift_samples) * sizeof(float)); + memcpy(&_result[current_correlator_tap][num_points - shift_samples], &_result[0][0], shift_samples * sizeof(float)); + } +} + +#endif +// +// +//#ifdef LV_HAVE_NEONV7 +//#include +// +//static inline void volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_neon(float** result, const float* local_code, float rem_code_phase_chips, float code_phase_step_chips, float* shifts_chips, unsigned int code_length_chips, int num_out_vectors, unsigned int num_points) +//{ +// float** _result = result; +// const unsigned int neon_iters = num_points / 4; +// int current_correlator_tap; +// unsigned int n; +// unsigned int k; +// const int32x4_t ones = vdupq_n_s32(1); +// const float32x4_t fours = vdupq_n_f32(4.0f); +// const float32x4_t rem_code_phase_chips_reg = vdupq_n_f32(rem_code_phase_chips); +// const float32x4_t code_phase_step_chips_reg = vdupq_n_f32(code_phase_step_chips); +// +// __VOLK_ATTR_ALIGNED(16) +// int32_t local_code_chip_index[4]; +// int32_t local_code_chip_index_; +// +// const int32x4_t zeros = vdupq_n_s32(0); +// const float32x4_t code_length_chips_reg_f = vdupq_n_f32((float)code_length_chips); +// const int32x4_t code_length_chips_reg_i = vdupq_n_s32((int32_t)code_length_chips); +// int32x4_t local_code_chip_index_reg, aux_i, negatives, i; +// float32x4_t aux, aux2, shifts_chips_reg, fi, c, j, cTrunc, base, indexn, reciprocal; +// __VOLK_ATTR_ALIGNED(16) +// const float vec[4] = {0.0f, 1.0f, 2.0f, 3.0f}; +// uint32x4_t igx; +// reciprocal = vrecpeq_f32(code_length_chips_reg_f); +// reciprocal = vmulq_f32(vrecpsq_f32(code_length_chips_reg_f, reciprocal), reciprocal); +// reciprocal = vmulq_f32(vrecpsq_f32(code_length_chips_reg_f, reciprocal), reciprocal); // this refinement is required! +// float32x4_t n0 = vld1q_f32((float*)vec); +// +// for (current_correlator_tap = 0; current_correlator_tap < num_out_vectors; current_correlator_tap++) +// { +// shifts_chips_reg = vdupq_n_f32((float)shifts_chips[current_correlator_tap]); +// aux2 = vsubq_f32(shifts_chips_reg, rem_code_phase_chips_reg); +// indexn = n0; +// for (n = 0; n < neon_iters; n++) +// { +// __VOLK_GNSSSDR_PREFETCH_LOCALITY(&_result[current_correlator_tap][4 * n + 3], 1, 0); +// __VOLK_GNSSSDR_PREFETCH(&local_code_chip_index[4]); +// aux = vmulq_f32(code_phase_step_chips_reg, indexn); +// aux = vaddq_f32(aux, aux2); +// +// //floor +// i = vcvtq_s32_f32(aux); +// fi = vcvtq_f32_s32(i); +// igx = vcgtq_f32(fi, aux); +// j = vcvtq_f32_s32(vandq_s32(vreinterpretq_s32_u32(igx), ones)); +// aux = vsubq_f32(fi, j); +// +// // fmod +// c = vmulq_f32(aux, reciprocal); +// i = vcvtq_s32_f32(c); +// cTrunc = vcvtq_f32_s32(i); +// base = vmulq_f32(cTrunc, code_length_chips_reg_f); +// aux = vsubq_f32(aux, base); +// local_code_chip_index_reg = vcvtq_s32_f32(aux); +// +// negatives = vreinterpretq_s32_u32(vcltq_s32(local_code_chip_index_reg, zeros)); +// aux_i = vandq_s32(code_length_chips_reg_i, negatives); +// local_code_chip_index_reg = vaddq_s32(local_code_chip_index_reg, aux_i); +// +// vst1q_s32((int32_t*)local_code_chip_index, local_code_chip_index_reg); +// +// for (k = 0; k < 4; ++k) +// { +// _result[current_correlator_tap][n * 4 + k] = local_code[local_code_chip_index[k]]; +// } +// indexn = vaddq_f32(indexn, fours); +// } +// for (n = neon_iters * 4; n < num_points; n++) +// { +// __VOLK_GNSSSDR_PREFETCH_LOCALITY(&_result[current_correlator_tap][n], 1, 0); +// // resample code for current tap +// local_code_chip_index_ = (int)floor(code_phase_step_chips * (float)n + shifts_chips[current_correlator_tap] - rem_code_phase_chips); +// //Take into account that in multitap correlators, the shifts can be negative! +// if (local_code_chip_index_ < 0) local_code_chip_index_ += (int)code_length_chips * (abs(local_code_chip_index_) / code_length_chips + 1); +// local_code_chip_index_ = local_code_chip_index_ % code_length_chips; +// _result[current_correlator_tap][n] = local_code[local_code_chip_index_]; +// } +// } +//} +// +//#endif + +#endif /*INCLUDED_volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn_H*/ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_xn_resampler_32f_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_xn_resampler_32f_xn.h index e28fd610d..50bdd732c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_xn_resampler_32f_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_xn_resampler_32f_xn.h @@ -63,13 +63,13 @@ #ifndef INCLUDED_volk_gnsssdr_32f_xn_resampler_32f_xn_H #define INCLUDED_volk_gnsssdr_32f_xn_resampler_32f_xn_H -#include -#include -#include /* abs */ -#include /* int64_t */ -#include #include #include +#include +#include +#include /* int64_t */ +#include +#include /* abs */ #ifdef LV_HAVE_GENERIC @@ -78,7 +78,7 @@ static inline void volk_gnsssdr_32f_xn_resampler_32f_xn_generic(float** result, { int local_code_chip_index; int current_correlator_tap; - int n; + unsigned int n; for (current_correlator_tap = 0; current_correlator_tap < num_out_vectors; current_correlator_tap++) { for (n = 0; n < num_points; n++) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn.h new file mode 100644 index 000000000..822742daf --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn.h @@ -0,0 +1,122 @@ +/*! + * \file volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn.h + * \brief VOLK_GNSSSDR kernel: multiplies N complex (32-bit float per component) vectors + * by a common vector, phase rotated and accumulates the results in N float complex outputs. + * \authors
                  + *
                • Antonio Ramos 2018. antonio.ramosdet(at)gmail.com + *
                + * + * VOLK_GNSSSDR kernel that multiplies N 32 bits complex vectors by a common vector, which is + * phase-rotated by phase offset and phase increment, and accumulates the results + * in N 32 bits float complex outputs. + * It is optimized to perform the N tap correlation process in GNSS receivers. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +/*! + * \page volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn + * + * \b Overview + * + * Rotates and multiplies the reference complex vector with an arbitrary number of other real vectors, + * accumulates the results and stores them in the output vector. + * The rotation is done at a fixed rate per sample, from an initial \p phase offset. + * This function can be used for Doppler wipe-off and multiple correlator. + * + * Dispatcher Prototype + * \code + * void volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, const lv_32fc_t phase_inc_rate, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points); + * \endcode + * + * \b Inputs + * \li in_common: Pointer to one of the vectors to be rotated, multiplied and accumulated (reference vector). + * \li phase_inc: Phase increment = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)) + * \li phase_inc_rate: Phase increment rate = lv_cmake(cos(phase_step_rate_rad), sin(phase_step_rate_rad)) + * \li phase: Initial phase = lv_cmake(cos(initial_phase_rad), sin(initial_phase_rad)) + * \li in_a: Pointer to an array of pointers to multiple vectors to be multiplied and accumulated. + * \li num_a_vectors: Number of vectors to be multiplied by the reference vector and accumulated. + * \li num_points: Number of complex values to be multiplied together, accumulated and stored into \p result. + * + * \b Outputs + * \li phase: Final phase. + * \li result: Vector of \p num_a_vectors components with the multiple vectors of \p in_a rotated, multiplied by \p in_common and accumulated. + * + */ + +#ifndef INCLUDED_volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn_H +#define INCLUDED_volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn_H + + +#include +#include +#include +#include +#include + +#ifdef LV_HAVE_GENERIC + +static inline void volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn_generic(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, const lv_32fc_t phase_inc_rate, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points) +{ + lv_32fc_t tmp32_1; +#ifdef __cplusplus + lv_32fc_t half_phase_inc_rate = std::sqrt(phase_inc_rate); +#else + lv_32fc_t half_phase_inc_rate = csqrtf(phase_inc_rate); +#endif + lv_32fc_t constant_rotation = phase_inc * half_phase_inc_rate; + lv_32fc_t delta_phase_rate = lv_cmake(1.0f, 0.0f); + int n_vec; + unsigned int n; + for (n_vec = 0; n_vec < num_a_vectors; n_vec++) + { + result[n_vec] = lv_cmake(0.0f, 0.0f); + } + for (n = 0; n < num_points; n++) + { + tmp32_1 = *in_common++ * (*phase); + // Regenerate phase + if (n % 256 == 0) + { +#ifdef __cplusplus + (*phase) /= std::abs((*phase)); + delta_phase_rate /= std::abs(delta_phase_rate); +#else + (*phase) /= hypotf(lv_creal(*phase), lv_cimag(*phase)); + delta_phase_rate /= hypotf(lv_creal(delta_phase_rate), lv_cimag(delta_phase_rate)); +#endif + } + (*phase) *= (constant_rotation * delta_phase_rate); + delta_phase_rate *= phase_inc_rate; + for (n_vec = 0; n_vec < num_a_vectors; n_vec++) + { + result[n_vec] += (tmp32_1 * in_a[n_vec][n]); + } + } +} + +#endif /*LV_HAVE_GENERIC*/ + +#endif /* INCLUDED_volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn_H */ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc.h new file mode 100644 index 000000000..ac71ab47a --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc.h @@ -0,0 +1,163 @@ +/*! + * \file volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h + * \brief Volk puppet for the multiple 16-bit complex dot product kernel. + * \authors
                  + *
                • Carles Fernandez Prades 2016 cfernandez at cttc dot cat + *
                + * + * Volk puppet for integrating the resampler into volk's test system + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef INCLUDED_volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc_H +#define INCLUDED_volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc_H + +#include "volk_gnsssdr/volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn.h" +#include +#include +#include + +#ifdef LV_HAVE_GENERIC + +static inline void volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc_generic(lv_32fc_t* result, const lv_32fc_t* local_code, const float* in, unsigned int num_points) +{ + // phases must be normalized. Phase rotator expects a complex exponential input! + float rem_carrier_phase_in_rad = 0.25; + float phase_step_rad = 0.1; + lv_32fc_t phase[1]; + phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); + lv_32fc_t phase_inc[1]; + phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); + lv_32fc_t phase_inc_rate[1]; + phase_inc_rate[0] = lv_cmake(cos(phase_step_rad * 0.001), sin(phase_step_rad * 0.001)); + int n; + int num_a_vectors = 3; + float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); + for (n = 0; n < num_a_vectors; n++) + { + in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); + memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points); + } + volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn_generic(result, local_code, phase_inc[0], phase_inc_rate[0], phase, (const float**)in_a, num_a_vectors, num_points); + + for (n = 0; n < num_a_vectors; n++) + { + volk_gnsssdr_free(in_a[n]); + } + volk_gnsssdr_free(in_a); +} +#endif // Generic + +// +//#ifdef LV_HAVE_GENERIC +//static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_generic_reload(lv_32fc_t* result, const lv_32fc_t* local_code, const float* in, unsigned int num_points) +//{ +// // phases must be normalized. Phase rotator expects a complex exponential input! +// float rem_carrier_phase_in_rad = 0.25; +// float phase_step_rad = 0.1; +// lv_32fc_t phase[1]; +// phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); +// lv_32fc_t phase_inc[1]; +// phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); +// int n; +// int num_a_vectors = 3; +// float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); +// for (n = 0; n < num_a_vectors; n++) +// { +// in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); +// memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points); +// } +// volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points); +// +// for (n = 0; n < num_a_vectors; n++) +// { +// volk_gnsssdr_free(in_a[n]); +// } +// volk_gnsssdr_free(in_a); +//} +// +//#endif // Generic +// +//#ifdef LV_HAVE_AVX +//static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_u_avx(lv_32fc_t* result, const lv_32fc_t* local_code, const float* in, unsigned int num_points) +//{ +// // phases must be normalized. Phase rotator expects a complex exponential input! +// float rem_carrier_phase_in_rad = 0.25; +// float phase_step_rad = 0.1; +// lv_32fc_t phase[1]; +// phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); +// lv_32fc_t phase_inc[1]; +// phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); +// int n; +// int num_a_vectors = 3; +// float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); +// for (n = 0; n < num_a_vectors; n++) +// { +// in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); +// memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points); +// } +// volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points); +// +// for (n = 0; n < num_a_vectors; n++) +// { +// volk_gnsssdr_free(in_a[n]); +// } +// volk_gnsssdr_free(in_a); +//} +// +//#endif // AVX +// +// +//#ifdef LV_HAVE_AVX +//static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_a_avx(lv_32fc_t* result, const lv_32fc_t* local_code, const float* in, unsigned int num_points) +//{ +// // phases must be normalized. Phase rotator expects a complex exponential input! +// float rem_carrier_phase_in_rad = 0.25; +// float phase_step_rad = 0.1; +// lv_32fc_t phase[1]; +// phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); +// lv_32fc_t phase_inc[1]; +// phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); +// int n; +// int num_a_vectors = 3; +// float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); +// for (n = 0; n < num_a_vectors; n++) +// { +// in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); +// memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points); +// } +// volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points); +// +// for (n = 0; n < num_a_vectors; n++) +// { +// volk_gnsssdr_free(in_a[n]); +// } +// volk_gnsssdr_free(in_a); +//} +// +//#endif // AVX + +#endif // INCLUDED_volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc_H diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h index a87bad93e..c08591deb 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h @@ -69,10 +69,10 @@ #define INCLUDED_volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_H -#include -#include -#include #include +#include +#include +#include #include //#include @@ -165,12 +165,12 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload #endif /*LV_HAVE_GENERIC*/ #ifdef LV_HAVE_AVX -#include #include +#include static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points) { unsigned int number = 0; - unsigned int vec_ind = 0; + int vec_ind = 0; unsigned int i = 0; const unsigned int sixteenthPoints = num_points / 16; @@ -329,12 +329,12 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_ #ifdef LV_HAVE_AVX -#include #include +#include static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points) { unsigned int number = 0; - unsigned int vec_ind = 0; + int vec_ind = 0; unsigned int i = 0; const unsigned int sixteenthPoints = num_points / 16; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h index 69f948d45..0a166d97f 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h @@ -36,8 +36,8 @@ #define INCLUDED_volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_H #include "volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h" -#include #include +#include #include #ifdef LV_HAVE_GENERIC @@ -51,7 +51,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_generic(lv phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -80,7 +80,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_generic_re phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -109,7 +109,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_u_avx(lv_3 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -139,7 +139,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_a_avx(lv_3 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; float** in_a = (float**)volk_gnsssdr_malloc(sizeof(float*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_16ic.h index 85d902d7d..ecfe1fb2e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_16ic.h @@ -56,9 +56,9 @@ #ifndef INCLUDED_volk_gnsssdr_32fc_convert_16ic_H #define INCLUDED_volk_gnsssdr_32fc_convert_16ic_H +#include "volk_gnsssdr/volk_gnsssdr_complex.h" #include #include -#include "volk_gnsssdr/volk_gnsssdr_complex.h" #ifdef LV_HAVE_SSE2 #include diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_8ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_8ic.h index ff4202ca4..634fdd60e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_8ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_convert_8ic.h @@ -56,10 +56,10 @@ #ifndef INCLUDED_volk_gnsssdr_32fc_convert_8ic_H #define INCLUDED_volk_gnsssdr_32fc_convert_8ic_H -#include -#include -#include #include "volk_gnsssdr/volk_gnsssdr_complex.h" +#include +#include +#include #ifdef LV_HAVE_GENERIC diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_resamplerxnpuppet_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_resamplerxnpuppet_32fc.h index 0757c9776..c95091ac0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_resamplerxnpuppet_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_resamplerxnpuppet_32fc.h @@ -36,9 +36,9 @@ #define INCLUDED_volk_gnsssdr_32fc_resamplerxnpuppet_32fc_H #include "volk_gnsssdr/volk_gnsssdr_32fc_xn_resampler_32fc_xn.h" -#include -#include #include +#include +#include #include @@ -49,7 +49,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_generic(lv_32fc_t* r float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -80,7 +80,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_a_sse3(lv_32fc_t* re float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -109,7 +109,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_u_sse3(lv_32fc_t* re float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -139,7 +139,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_u_sse4_1(lv_32fc_t* float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -168,7 +168,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_a_sse4_1(lv_32fc_t* float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -197,7 +197,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_a_avx(lv_32fc_t* res float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -226,7 +226,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_u_avx(lv_32fc_t* res float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -255,7 +255,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_a_avx2(lv_32fc_t* re float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -284,7 +284,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_u_avx2(lv_32fc_t* re float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); @@ -313,7 +313,7 @@ static inline void volk_gnsssdr_32fc_resamplerxnpuppet_32fc_neon(lv_32fc_t* resu float code_phase_step_chips = ((float)(code_length_chips) + 0.1) / ((float)num_points); int num_out_vectors = 3; float rem_code_phase_chips = -0.234; - unsigned int n; + int n; float shifts_chips[3] = {-0.1, 0.0, 0.1}; lv_32fc_t** result_aux = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_out_vectors, volk_gnsssdr_get_alignment()); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn.h index 32c51fa55..5701ae041 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn.h @@ -69,10 +69,10 @@ #define INCLUDED_volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_H -#include -#include -#include #include +#include +#include +#include #include diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc.h index 7eeb01dc7..4d5efcefe 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc.h @@ -36,8 +36,8 @@ #define INCLUDED_volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_H #include "volk_gnsssdr/volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn.h" -#include #include +#include #include #ifdef LV_HAVE_GENERIC @@ -50,7 +50,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_generic(lv_ phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_32fc_t** in_a = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -80,7 +80,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_generic_rel phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_32fc_t** in_a = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -110,7 +110,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_u_sse3(lv_3 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_32fc_t** in_a = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -140,7 +140,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_a_sse3(lv_3 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_32fc_t** in_a = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -170,7 +170,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_u_avx(lv_32 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_32fc_t** in_a = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -200,7 +200,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_a_avx(lv_32 phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_32fc_t** in_a = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) @@ -230,7 +230,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc_neon(lv_32f phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); - unsigned int n; + int n; int num_a_vectors = 3; lv_32fc_t** in_a = (lv_32fc_t**)volk_gnsssdr_malloc(sizeof(lv_32fc_t*) * num_a_vectors, volk_gnsssdr_get_alignment()); for (n = 0; n < num_a_vectors; n++) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_xn_resampler_32fc_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_xn_resampler_32fc_xn.h index 98dba44cf..4335e0722 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_xn_resampler_32fc_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_xn_resampler_32fc_xn.h @@ -63,10 +63,10 @@ #ifndef INCLUDED_volk_gnsssdr_32fc_xn_resampler_32fc_xn_H #define INCLUDED_volk_gnsssdr_32fc_xn_resampler_32fc_xn_H -#include -#include /* abs */ #include #include +#include +#include /* abs */ #ifdef LV_HAVE_GENERIC @@ -75,7 +75,7 @@ static inline void volk_gnsssdr_32fc_xn_resampler_32fc_xn_generic(lv_32fc_t** re { int local_code_chip_index; int current_correlator_tap; - int n; + unsigned int n; for (current_correlator_tap = 0; current_correlator_tap < num_out_vectors; current_correlator_tap++) { for (n = 0; n < num_points; n++) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8ic_x2_dot_prod_8ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8ic_x2_dot_prod_8ic.h index 47d9ccaaf..d123f6225 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8ic_x2_dot_prod_8ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8ic_x2_dot_prod_8ic.h @@ -59,9 +59,9 @@ #ifndef INCLUDED_volk_gnsssdr_8ic_x2_dot_prod_8ic_H #define INCLUDED_volk_gnsssdr_8ic_x2_dot_prod_8ic_H -#include #include #include +#include #ifdef LV_HAVE_GENERIC diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincos_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincos_32fc.h index 50ac028d0..41e59e525 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincos_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincos_32fc.h @@ -62,9 +62,9 @@ #ifndef INCLUDED_volk_gnsssdr_s32f_sincos_32fc_H #define INCLUDED_volk_gnsssdr_s32f_sincos_32fc_H -#include #include #include +#include #ifdef LV_HAVE_SSE2 diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincospuppet_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincospuppet_32fc.h index ac86c52a2..6146d443a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincospuppet_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_s32f_sincospuppet_32fc.h @@ -36,8 +36,8 @@ #define INCLUDED_volk_gnsssdr_s32f_sincospuppet_32fc_H -#include #include "volk_gnsssdr/volk_gnsssdr_s32f_sincos_32fc.h" +#include #include diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index ec4d5ab2c..5211c1cf5 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -22,22 +22,22 @@ # header file detection ######################################################################## include(CheckIncludeFile) -CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H) +check_include_file(cpuid.h HAVE_CPUID_H) if(HAVE_CPUID_H) add_definitions(-DHAVE_CPUID_H) endif() -CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H) +check_include_file(intrin.h HAVE_INTRIN_H) if(HAVE_INTRIN_H) add_definitions(-DHAVE_INTRIN_H) endif() -CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H) +check_include_file(fenv.h HAVE_FENV_H) if(HAVE_FENV_H) add_definitions(-DHAVE_FENV_H) endif() -CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) +check_include_file(dlfcn.h HAVE_DLFCN_H) if(HAVE_DLFCN_H) add_definitions(-DHAVE_DLFCN_H) list(APPEND volk_gnsssdr_libraries ${CMAKE_DL_LIBS}) @@ -62,7 +62,7 @@ endif() ######################################################################## if(COMPILER_NAME MATCHES "GNU") include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-Werror=unused-command-line-argument" HAVE_WERROR_UNUSED_CMD_LINE_ARG) + check_cxx_compiler_flag("-Werror=unused-command-line-argument" HAVE_WERROR_UNUSED_CMD_LINE_ARG) if(HAVE_WERROR_UNUSED_CMD_LINE_ARG) set(VOLK_FLAG_CHECK_FLAGS "-Werror=unused-command-line-argument") endif() @@ -74,20 +74,20 @@ endif() ######################################################################## include(CheckSymbolExists) -CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) - +check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) + if(HAVE_POSIX_MEMALIGN) add_definitions(-DHAVE_POSIX_MEMALIGN) -endif(HAVE_POSIX_MEMALIGN) +endif() if(NOT DEFINED _XOPEN_SOURCE) add_definitions(-D_XOPEN_SOURCE=700) -endif(NOT DEFINED _XOPEN_SOURCE) +endif() ######################################################################## # detect x86 flavor of CPU ######################################################################## -if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64|AMD64)$") +if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64|AMD64)$") message(STATUS "x86* CPU detected") set(CPU_IS_x86 TRUE) endif() @@ -106,7 +106,7 @@ macro(check_arch arch_name) set(flags ${ARGN}) set(have_${arch_name} TRUE) foreach(flag ${flags}) - if (MSVC AND (${flag} STREQUAL "/arch:SSE2" OR ${flag} STREQUAL "/arch:SSE" )) + if(MSVC AND (${flag} STREQUAL "/arch:SSE2" OR ${flag} STREQUAL "/arch:SSE")) # SSE/SSE2 is supported in MSVC since VS 2005 but flag not available when compiling 64-bit so do not check else() include(CheckCXXCompilerFlag) @@ -119,27 +119,27 @@ macro(check_arch arch_name) if(VOLK_FLAG_CHECK_FLAGS) set(CMAKE_REQUIRED_FLAGS ${VOLK_FLAG_CHECK_FLAGS}) endif() - CHECK_CXX_COMPILER_FLAG(${flag} ${have_flag}) + check_cxx_compiler_flag(${flag} ${have_flag}) unset(CMAKE_REQUIRED_FLAGS) - if (NOT ${have_flag}) + if(NOT ${have_flag}) set(have_${arch_name} FALSE) endif() endif() endforeach() - if (have_${arch_name}) + if(have_${arch_name}) list(APPEND available_archs ${arch_name}) endif() -endmacro(check_arch) +endmacro() foreach(line ${arch_flag_lines}) string(REGEX REPLACE "," ";" arch_flags ${line}) check_arch(${arch_flags}) -endforeach(line) +endforeach() macro(OVERRULE_ARCH arch reason) message(STATUS "${reason}, Overruled arch ${arch}") list(REMOVE_ITEM available_archs ${arch}) -endmacro(OVERRULE_ARCH) +endmacro() ######################################################################## # eliminate AVX on if not on x86, or if the compiler does not accept @@ -150,25 +150,25 @@ set(HAVE_XGETBV 0) set(HAVE_AVX_CVTPI32_PS 0) if(CPU_IS_x86) # check to see if the compiler/linker works with xgetb instruction - if (NOT MSVC) + if(NOT MSVC) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "unsigned long long _xgetbv(unsigned int index) { unsigned int eax, edx; __asm__ __volatile__(\"xgetbv\" : \"=a\"(eax), \"=d\"(edx) : \"c\"(index)); return ((unsigned long long)edx << 32) | eax; } int main (void) { (void) _xgetbv(0); return (0); }") - else (NOT MSVC) + else() #MSVC defines an intrinsic file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "#include \n #include \n int main() { int avxSupported = 0; \n#if (_MSC_FULL_VER >= 160040219) \nint cpuInfo[4]; __cpuid(cpuInfo, 1);\nif ((cpuInfo[2] & (1 << 27) || 0) && (cpuInfo[2] & (1 << 28) || 0)) \n{\nunsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);\n avxSupported = (xcrFeatureMask & 0x6) == 6;}\n#endif \n return 1- avxSupported; }") - endif(NOT MSVC) + endif() execute_process(COMMAND ${CMAKE_C_COMPILER} -o ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE avx_compile_result) if(NOT ${avx_compile_result} EQUAL 0) - OVERRULE_ARCH(avx "Compiler or linker missing xgetbv instruction") + overrule_arch(avx "Compiler or linker missing xgetbv instruction") elseif(NOT CROSSCOMPILE_MULTILIB) execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE avx_exe_result) if(NOT ${avx_exe_result} EQUAL 0) - OVERRULE_ARCH(avx "CPU missing xgetbv") + overrule_arch(avx "CPU missing xgetbv") else() set(HAVE_XGETBV 1) endif() @@ -184,7 +184,7 @@ if(CPU_IS_x86) ######################################################################### # check to see if the compiler/linker works with cvtpi32_ps instrinsic when using AVX - if (CMAKE_SIZEOF_VOID_P EQUAL 4) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c "#include \nint main (void) {__m128 __a; __m64 __b; __m128 foo = _mm_cvtpi32_ps(__a, __b); return (0); }") execute_process(COMMAND ${CMAKE_C_COMPILER} -mavx -o ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps @@ -192,13 +192,13 @@ if(CPU_IS_x86) OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE avx_compile_result) if(NOT ${avx_compile_result} EQUAL 0) - OVERRULE_ARCH(avx "Compiler missing cvtpi32_ps instrinsic") + overrule_arch(avx "Compiler missing cvtpi32_ps instrinsic") elseif(NOT CROSSCOMPILE_MULTILIB) execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE avx_exe_result) if(NOT ${avx_exe_result} EQUAL 0) - OVERRULE_ARCH(avx "CPU missing cvtpi32_ps") + overrule_arch(avx "CPU missing cvtpi32_ps") else() set(HAVE_AVX_CVTPI32_PS 1) endif() @@ -207,13 +207,13 @@ if(CPU_IS_x86) endif() file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c) - else(CMAKE_SIZEOF_VOID_P EQUAL 4) - # 64-bit compilations won't need this command so don't overrule AVX - set(HAVE_AVX_CVTPI32_PS 0) - endif(CMAKE_SIZEOF_VOID_P EQUAL 4) + else() + # 64-bit compilations won't need this command so don't overrule AVX + set(HAVE_AVX_CVTPI32_PS 0) + endif() # Disable SSE4a if Clang is less than version 3.2 - if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") # Figure out the version of Clang if(CMAKE_VERSION VERSION_LESS "2.8.10") # Exctract the Clang version from the --version string. @@ -222,14 +222,14 @@ if(CPU_IS_x86) execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE clang_version) string(REGEX MATCH "[0-9].[0-9]" CMAKE_C_COMPILER_VERSION ${clang_version}) - endif(CMAKE_VERSION VERSION_LESS "2.8.10") + endif() if(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") - OVERRULE_ARCH(sse4_a "Clang >= 3.2 required for SSE4a") - endif(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") - endif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + overrule_arch(sse4_a "Clang >= 3.2 required for SSE4a") + endif() + endif() -endif(CPU_IS_x86) +endif() if(${HAVE_XGETBV}) add_definitions(-DHAVE_XGETBV) @@ -244,17 +244,19 @@ endif() ######################################################################## if(NOT CPU_IS_x86) - OVERRULE_ARCH(3dnow "Architecture is not x86 or x86_64") - OVERRULE_ARCH(mmx "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse2 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse3 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(ssse3 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse4_a "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse4_1 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse4_2 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(avx "Architecture is not x86 or x86_64") -endif(NOT CPU_IS_x86) + overrule_arch(3dnow "Architecture is not x86 or x86_64") + overrule_arch(mmx "Architecture is not x86 or x86_64") + overrule_arch(sse "Architecture is not x86 or x86_64") + overrule_arch(sse2 "Architecture is not x86 or x86_64") + overrule_arch(sse3 "Architecture is not x86 or x86_64") + overrule_arch(ssse3 "Architecture is not x86 or x86_64") + overrule_arch(sse4_a "Architecture is not x86 or x86_64") + overrule_arch(sse4_1 "Architecture is not x86 or x86_64") + overrule_arch(sse4_2 "Architecture is not x86 or x86_64") + overrule_arch(avx "Architecture is not x86 or x86_64") + overrule_arch(avx512f "Architecture is not x86 or x86_64") + overrule_arch(avx512cd "Architecture is not x86 or x86_64") +endif() ######################################################################## # Select neon based on ARM ISA version @@ -265,33 +267,33 @@ endif(NOT CPU_IS_x86) include(CheckCSourceCompiles) check_c_source_compiles("#include \nint main(){ uint8_t *dest; uint8x8_t res; vst1_u8(dest, res); }" - neon_compile_result) + neon_compile_result) if(neon_compile_result) check_c_source_compiles("int main(){asm volatile(\"vrev32.8 q0, q0\");}" - have_neonv7_result ) + have_neonv7_result) check_c_source_compiles("int main(){asm volatile(\"sub v1.4s,v1.4s,v1.4s\");}" - have_neonv8_result ) + have_neonv8_result) - if (have_neonv7_result) - OVERRULE_ARCH(neonv8 "CPU is armv7") + if(have_neonv7_result) + overrule_arch(neonv8 "CPU is armv7") endif() - if (have_neonv8_result) - OVERRULE_ARCH(neonv7 "CPU is armv8") + if(have_neonv8_result) + overrule_arch(neonv7 "CPU is armv8") endif() -else(neon_compile_result) - OVERRULE_ARCH(neon "Compiler doesn't support NEON") - OVERRULE_ARCH(neonv7 "Compiler doesn't support NEON") - OVERRULE_ARCH(neonv8 "Compiler doesn't support NEON") -endif(neon_compile_result) +else() + overrule_arch(neon "Compiler doesn't support NEON") + overrule_arch(neonv7 "Compiler doesn't support NEON") + overrule_arch(neonv8 "Compiler doesn't support NEON") +endif() ######################################################################## # implement overruling in the ORC case, # since ORC always passes flag detection ######################################################################## if(NOT ORC_FOUND) - OVERRULE_ARCH(orc "ORC support not found") + overrule_arch(orc "ORC support not found") endif() ######################################################################## @@ -301,16 +303,16 @@ endif() if(NOT CROSSCOMPILE_MULTILIB AND CPU_IS_x86) include(CheckTypeSize) check_type_size("void*[8]" SIZEOF_CPU BUILTIN_TYPES_ONLY) - if (${SIZEOF_CPU} EQUAL 64) - OVERRULE_ARCH(32 "CPU width is 64 bits") + if(${SIZEOF_CPU} EQUAL 64) + overrule_arch(32 "CPU width is 64 bits") endif() - if (${SIZEOF_CPU} EQUAL 32) - OVERRULE_ARCH(64 "CPU width is 32 bits") + if(${SIZEOF_CPU} EQUAL 32) + overrule_arch(64 "CPU width is 32 bits") endif() #MSVC 64 bit does not have MMX, overrule it - if (${SIZEOF_CPU} EQUAL 64 AND MSVC) - OVERRULE_ARCH(mmx "No MMX for Win64") + if(${SIZEOF_CPU} EQUAL 64 AND MSVC) + overrule_arch(mmx "No MMX for Win64") endif() endif() @@ -340,12 +342,12 @@ execute_process( foreach(arch mmx orc 64 32) foreach(machine_name ${available_machines}) string(REPLACE "_${arch}" "" machine_name_no_arch ${machine_name}) - if (${machine_name} STREQUAL ${machine_name_no_arch}) + if(${machine_name} STREQUAL ${machine_name_no_arch}) else() list(REMOVE_ITEM available_machines ${machine_name_no_arch}) endif() - endforeach(machine_name) -endforeach(arch) + endforeach() +endforeach() ######################################################################## # done overrules! print the result @@ -373,7 +375,7 @@ macro(gen_template tmpl output) ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_tmpl_utils.py --input ${tmpl} --output ${output} ${ARGN} ) -endmacro(gen_template) +endmacro() file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/volk_gnsssdr) @@ -399,13 +401,13 @@ if(MSVC) elseif(MSVC11) #Visual Studio 11 set(cmake_c_compiler_version "Microsoft Visual Studio 11.0") elseif(MSVC12) #Visual Studio 12 - SET(cmake_c_compiler_version "Microsoft Visual Studio 12.0") + set(cmake_c_compiler_version "Microsoft Visual Studio 12.0") endif() else() execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE cmake_c_compiler_version) -endif(MSVC) -set(COMPILER_INFO "${CMAKE_C_COMPILER}:::${CMAKE_C_FLAGS_${GRCBTU}} ${CMAKE_C_FLAGS}\n${CMAKE_CXX_COMPILER}:::${CMAKE_CXX_FLAGS_${GRCBTU}} ${CMAKE_CXX_FLAGS}\n" ) +endif() +set(COMPILER_INFO "${CMAKE_C_COMPILER}:::${CMAKE_C_FLAGS_${GRCBTU}} ${CMAKE_C_FLAGS}\n${CMAKE_CXX_COMPILER}:::${CMAKE_CXX_FLAGS_${GRCBTU}} ${CMAKE_CXX_FLAGS}\n") foreach(machine_name ${available_machines}) #generate machine source @@ -419,8 +421,8 @@ foreach(machine_name ${available_machines}) --mode "machine_flags" --machine "${machine_name}" --compiler "${COMPILER_NAME}" OUTPUT_VARIABLE ${machine_name}_flags OUTPUT_STRIP_TRAILING_WHITESPACE ) - MESSAGE(STATUS "BUILD INFO ::: ${machine_name} ::: ${COMPILER_NAME} ::: ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}") - set(COMPILER_INFO "${COMPILER_INFO}${machine_name}:::${COMPILER_NAME}:::${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}\n" ) + message(STATUS "BUILD INFO ::: ${machine_name} ::: ${COMPILER_NAME} ::: ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}") + set(COMPILER_INFO "${COMPILER_INFO}${machine_name}:::${COMPILER_NAME}:::${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}\n") if(${machine_name}_flags AND NOT MSVC) set_source_files_properties(${machine_source} PROPERTIES COMPILE_FLAGS "${${machine_name}_flags}") endif() @@ -428,12 +430,12 @@ foreach(machine_name ${available_machines}) #add to available machine defs string(TOUPPER LV_MACHINE_${machine_name} machine_def) list(APPEND machine_defs ${machine_def}) -endforeach(machine_name) +endforeach() # Convert to a C string to compile and display properly string(STRIP "${cmake_c_compiler_version}" cmake_c_compiler_version) string(STRIP ${COMPILER_INFO} COMPILER_INFO) -MESSAGE(STATUS "Compiler Version: ${cmake_c_compiler_version}") +message(STATUS "Compiler Version: ${cmake_c_compiler_version}") string(REPLACE "\n" " \\n" cmake_c_compiler_version ${cmake_c_compiler_version}) string(REPLACE "\n" " \\n" COMPILER_INFO ${COMPILER_INFO}) @@ -462,7 +464,7 @@ if(${CMAKE_VERSION} VERSION_GREATER "2.8.9") # set up the assembler flags and include the source files foreach(ARCH ${ASM_ARCHS_AVAILABLE}) string(REGEX MATCH "${ARCH}" ASM_ARCH "${available_archs}") - if( ASM_ARCH STREQUAL "neonv7" ) + if(ASM_ARCH STREQUAL "neonv7") message(STATUS "---- Adding ASM files") # we always use ATT syntax message(STATUS "-- Detected neon architecture; enabling ASM") # setup architecture specific assembler flags @@ -474,23 +476,23 @@ if(${CMAKE_VERSION} VERSION_GREATER "2.8.9") foreach(asm_file ${asm_files}) list(APPEND volk_gnsssdr_sources ${asm_file}) message(STATUS "Adding source file: ${asm_file}") - endforeach(asm_file) + endforeach() endif() enable_language(ASM) - set(CMAKE_ASM_FLAGS ${ARCH_ASM_FLAGS}) + set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${ARCH_ASM_FLAGS}") message(STATUS "c flags: ${FULL_C_FLAGS}") message(STATUS "asm flags: ${CMAKE_ASM_FLAGS}") - endforeach(ARCH) + endforeach() -else(${CMAKE_VERSION} VERSION_GREATER "2.8.9") +else() message(STATUS "Not enabling ASM support. CMake >= 2.8.10 required.") foreach(machine_name ${available_machines}) string(REGEX MATCH "neon" NEON_MACHINE ${machine_name}) - if( NEON_MACHINE STREQUAL "neon") + if(NEON_MACHINE STREQUAL "neon") message(FATAL_ERROR "CMake >= 2.8.10 is required for ARM NEON support") endif() endforeach() -endif(${CMAKE_VERSION} VERSION_GREATER "2.8.9") +endif() ######################################################################## # Handle orc support @@ -517,7 +519,7 @@ if(ORC_FOUND) ) list(APPEND volk_gnsssdr_sources ${orcc_gen}) - endforeach(orc_file) + endforeach() else() message(STATUS "Did not find liborc and orcc, disabling orc support...") endif() @@ -567,71 +569,67 @@ if(MSVC) set_source_files_properties(${volk_gnsssdr_sources} PROPERTIES LANGUAGE CXX) endif() -#Use object library for faster overall build in newer versions of cmake -if(CMAKE_VERSION VERSION_GREATER "2.8.7") - #Create a volk_gnsssdr object library (requires cmake >= 2.8.8) - add_library(volk_gnsssdr_obj OBJECT ${volk_gnsssdr_sources}) - - #Add dynamic library - add_library(volk_gnsssdr SHARED $) - target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries} ${Boost_LIBRARIES}) +#Create a volk_gnsssdr object library +add_library(volk_gnsssdr_obj OBJECT ${volk_gnsssdr_sources}) +target_include_directories(volk_gnsssdr_obj + PUBLIC $ + PUBLIC $ + PUBLIC $ + PRIVATE ${PROJECT_SOURCE_DIR}/kernels + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) - #Configure target properties - set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC") - set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${LIBVER}) - set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS") +#Add dynamic library +add_library(volk_gnsssdr SHARED $) +target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries} m) +target_include_directories(volk_gnsssdr + PUBLIC $ + PUBLIC $ + PUBLIC $ + PRIVATE ${PROJECT_SOURCE_DIR}/kernels + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) - #Install locations - install(TARGETS volk_gnsssdr - LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file - RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file +#Configure target properties +set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC") +set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${LIBVER}) +set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS") + +#Install locations +install(TARGETS volk_gnsssdr + EXPORT VOLK_GNSSSDR-export + LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file + ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file + RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file +) + +#Configure static library +if(ENABLE_STATIC_LIBS) + add_library(volk_gnsssdr_static STATIC $) + target_link_libraries(volk_gnsssdr_static ${volk_gnsssdr_libraries} pthread m) + target_include_directories(volk_gnsssdr_static + PUBLIC $ + PUBLIC $ + PUBLIC $ + PRIVATE ${PROJECT_SOURCE_DIR}/kernels + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) - #Configure static library - if(ENABLE_STATIC_LIBS) - add_library(volk_gnsssdr_static STATIC $) - - set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr) - - install(TARGETS volk_gnsssdr_static - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" - ) - endif(ENABLE_STATIC_LIBS) - -#Older cmake versions (slower to build when building dynamic/static libs) -else() - #create the volk_gnsssdr runtime library - add_library(volk_gnsssdr SHARED ${volk_gnsssdr_sources}) - target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries}) - set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${LIBVER}) - set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS") - - install(TARGETS volk_gnsssdr - LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file - RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file + install(TARGETS volk_gnsssdr_static + EXPORT VOLK_GNSSSDR-export + ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" ) - if(ENABLE_STATIC_LIBS) - add_library(volk_gnsssdr_static STATIC ${volk_gnsssdr_sources}) + set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr) +endif() - if(NOT WIN32) - set_target_properties(volk_gnsssdr_static - PROPERTIES OUTPUT_NAME volk_gnsssdr) - endif(NOT WIN32) - - install(TARGETS volk_gnsssdr_static - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file - ) - endif(ENABLE_STATIC_LIBS) - -endif(CMAKE_VERSION VERSION_GREATER "2.8.7") ######################################################################## # Build the QA test application ######################################################################## if(ENABLE_TESTING) - #include Boost headers include_directories(${Boost_INCLUDE_DIRS}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.unittest) @@ -641,17 +639,15 @@ if(ENABLE_TESTING) ) include(VolkAddTest) - VOLK_GEN_TEST("volk_gnsssdr_test_all" + volk_gen_test("volk_gnsssdr_test_all" SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc TARGET_DEPS volk_gnsssdr - ) + ) + foreach(kernel ${h_files}) get_filename_component(kernel ${kernel} NAME) string(REPLACE ".h" "" kernel ${kernel}) - if(NOT ${kernel} MATCHES puppet*) - VOLK_ADD_TEST(${kernel} "volk_gnsssdr_test_all") - endif(NOT ${kernel} MATCHES puppet*) + volk_add_test(${kernel} "volk_gnsssdr_test_all") endforeach() - -endif(ENABLE_TESTING) +endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h index d9fca252a..86b20b5e0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h @@ -29,8 +29,8 @@ #include "qa_utils.h" -#include #include +#include // macros for initializing volk_gnsssdr_test_case_t. Macros are needed to generate @@ -93,11 +93,13 @@ std::vector init_test_list(volk_gnsssdr_test_params_t QA(VOLK_INIT_PUPP(volk_gnsssdr_16i_resamplerxnpuppet_16i, volk_gnsssdr_16i_xn_resampler_16i_xn, test_params)) QA(VOLK_INIT_PUPP(volk_gnsssdr_32fc_resamplerxnpuppet_32fc, volk_gnsssdr_32fc_xn_resampler_32fc_xn, test_params)) QA(VOLK_INIT_PUPP(volk_gnsssdr_32f_resamplerxnpuppet_32f, volk_gnsssdr_32f_xn_resampler_32f_xn, test_params)) + QA(VOLK_INIT_PUPP(volk_gnsssdr_32f_high_dynamics_resamplerxnpuppet_32f, volk_gnsssdr_32f_xn_high_dynamics_resampler_32f_xn, test_params)) QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_x2_dot_prod_16ic_xn, test_params)) QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn, test_params_int16)) QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn, test_params_int16)) QA(VOLK_INIT_PUPP(volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc, volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn, test_params_int1)) QA(VOLK_INIT_PUPP(volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc, volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn, test_params_int1)); + QA(VOLK_INIT_PUPP(volk_gnsssdr_32fc_32f_high_dynamic_rotator_dotprodxnpuppet_32fc, volk_gnsssdr_32fc_32f_high_dynamic_rotator_dot_prod_32fc_xn, test_params_int1)); return test_cases; } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc index cf26c9bea..906028e6d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc @@ -16,9 +16,8 @@ * along with GNSS-SDR. If not, see . */ -#include "volk_gnsssdr/volk_gnsssdr.h" // for volk_gnsssdr_func_desc_t #include "qa_utils.h" - +#include "volk_gnsssdr/volk_gnsssdr.h" // for volk_gnsssdr_func_desc_t #include // for volk_gnsssdr_free, volk_gnsssdr_malloc #include // for assert #include // for system_clock, duration,... @@ -539,7 +538,7 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, vlen = vlen + vlen_twiddle; const float tol_f = tol; - const unsigned int tol_i = static_cast(tol); + const unsigned int tol_i = static_cast(tol); //first let's get a list of available architectures for the test std::vector arch_list = get_arch_list(desc); @@ -565,6 +564,11 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, std::cerr << " - " << name << std::endl; return false; } + catch (std::string s) + { + std::cerr << "Error: " << s << std::endl; + return false; + } //pull the input scalars into their own vector std::vector inputsc; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h index e0a265c92..2a69e5947 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h @@ -23,8 +23,8 @@ #define _DARWIN_C_SOURCE #endif -#include "volk_gnsssdr/volk_gnsssdr_complex.h" // for lv_32fc_t #include "volk_gnsssdr/volk_gnsssdr.h" // for volk_gnsssdr_func_desc_t +#include "volk_gnsssdr/volk_gnsssdr_complex.h" // for lv_32fc_t #include // for bool, false #include // for NULL #include // for map diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc index 4b4ec2a2f..6c23220d1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc @@ -22,9 +22,10 @@ #include "qa_utils.h" // for volk_gnsssdr_test_case_t, volk_gnsssdr_test_results_t #include "volk_gnsssdr/volk_gnsssdr_complex.h" // for lv_32fc_t #include // for bool, false, true -#include // for operator<<, basic_ostream, endl, char... #include // IWYU pragma: keep +#include // for operator<<, basic_ostream, endl, char... #include // for map, map<>::iterator, _Rb_tree_iterator +#include // for stringstream #include // for string, operator<< #include // for pair #include // for vector @@ -38,7 +39,7 @@ int main(int argc, char* argv[]) float def_tol = 1e-6; lv_32fc_t def_scalar = 327.0; int def_iter = 1; - int def_vlen = 131071; + int def_vlen = 8111; bool def_benchmark_mode = true; std::string def_kernel_regex = ""; @@ -48,15 +49,16 @@ int main(int argc, char* argv[]) std::vector results; if (argc > 1) { - const size_t len = std::char_traits::length(argv[1]); - if (len == 0 || len > 2046) + std::stringstream ss; + ss << argv[1]; + if (ss.fail()) { - std::cerr << "Test name is too long." << std::endl; + std::cerr << "Test name not correctly set." << std::endl; return 0; } for (unsigned int ii = 0; ii < test_cases.size(); ++ii) { - if (std::string(argv[1]) == test_cases[ii].name()) + if (ss.str() == test_cases[ii].name()) { volk_gnsssdr_test_case_t test_case = test_cases[ii]; if (run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(), diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_rank_archs.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_rank_archs.h index 335d4a279..06c2cd41e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_rank_archs.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_rank_archs.h @@ -19,8 +19,8 @@ #ifndef GNSS_SDR_VOLK_GNSSSDR_RANK_ARCHS_H #define GNSS_SDR_VOLK_GNSSSDR_RANK_ARCHS_H -#include #include +#include #ifdef __cplusplus extern "C" diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/CMakeLists.txt index 3309080ba..4c35e9c60 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/CMakeLists.txt @@ -35,4 +35,4 @@ VOLK_PYTHON_INSTALL( volk_gnsssdr_modtool DESTINATION ${VOLK_RUNTIME_DIR} COMPONENT "volk_gnsssdr" -) \ No newline at end of file +) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/README b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/README index 3820201c2..f0da0f59d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/README +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/README @@ -76,8 +76,7 @@ This will put the code for the new kernel into Other kernels must be added by hand. See the following webpages for more information about creating VOLK kernels: - http://gnuradio.org/doc/doxygen/volk_gnsssdr_guide.html - http://gnuradio.org/redmine/projects/gnuradio/wiki/Volk + https://www.gnuradio.org/doc/doxygen/volk_guide.html ====================================================================== diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/__init__.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/__init__.py index db03736dd..04e726c70 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/__init__.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/__init__.py @@ -19,5 +19,5 @@ # # -from cfg import volk_gnsssdr_modtool_config -from volk_gnsssdr_modtool_generate import volk_gnsssdr_modtool +from .cfg import volk_gnsssdr_modtool_config +from .volk_gnsssdr_modtool_generate import volk_gnsssdr_modtool diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py index bb2f511d8..26ffc790a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py @@ -21,16 +21,15 @@ from __future__ import print_function -import ConfigParser import sys import os -import exceptions import re +from six.moves import configparser, input -class volk_gnsssdr_modtool_config: +class volk_gnsssdr_modtool_config(object): def key_val_sub(self, num, stuff, section): - return re.sub('\$' + 'k' + str(num), stuff[num][0], (re.sub('\$' + str(num), stuff[num][1], section[1][num]))); + return re.sub(r'\$' + 'k' + str(num), stuff[num][0], (re.sub(r'\$' + str(num), stuff[num][1], section[1][num]))); def verify(self): for i in self.verification: @@ -46,11 +45,11 @@ class volk_gnsssdr_modtool_config: try: val = eval(self.key_val_sub(i, stuff, section)) if val == False: - raise exceptions.ValueError + raise ValueError except ValueError: - raise exceptions.ValueError('Verification function returns False... key:%s, val:%s'%(stuff[i][0], stuff[i][1])) + raise ValueError('Verification function returns False... key:%s, val:%s'%(stuff[i][0], stuff[i][1])) except: - raise exceptions.IOError('bad configuration... key:%s, val:%s'%(stuff[i][0], stuff[i][1])) + raise IOError('bad configuration... key:%s, val:%s'%(stuff[i][0], stuff[i][1])) def __init__(self, cfg=None): @@ -66,7 +65,7 @@ class volk_gnsssdr_modtool_config: self.remapification = [(self.config_name, self.config_defaults_remap)] self.verification = [(self.config_name, self.config_defaults_verify)] default = os.path.join(os.getcwd(), 'volk_gnsssdr_modtool.cfg') - icfg = ConfigParser.RawConfigParser() + icfg = configparser.RawConfigParser() if cfg: icfg.read(cfg) elif os.path.exists(default): @@ -75,7 +74,7 @@ class volk_gnsssdr_modtool_config: print("Initializing config file...") icfg.add_section(self.config_name) for kn in self.config_defaults: - rv = raw_input("%s: "%(kn)) + rv = input("%s: "%(kn)) icfg.set(self.config_name, kn, rv) self.cfg = icfg self.remap() @@ -96,4 +95,3 @@ class volk_gnsssdr_modtool_config: for i in stuff: retval[i[0]] = i[1] return retval - diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool index 898a1f658..ded907fbe 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool @@ -18,10 +18,10 @@ # along with GNSS-SDR. If not, see . # +from __future__ import print_function from volk_gnsssdr_modtool import volk_gnsssdr_modtool, volk_gnsssdr_modtool_config from optparse import OptionParser, OptionGroup -import exceptions import os import sys @@ -57,12 +57,12 @@ if __name__ == '__main__': parser.print_help() elif options.moo: - print " (__) " - print " (oo) " - print " /------\/ " - print " / | || " - print " * /\---/\ " - print " ~~ ~~ " + print(" (__) ") + print(" (oo) ") + print(" /------\/ ") + print(" / | || ") + print(" * /\---/\ ") + print(" ~~ ~~ ") else: my_cfg = volk_gnsssdr_modtool_config(options.config_file); @@ -77,7 +77,7 @@ if __name__ == '__main__': if options.add_kernel: if not options.kernel_name: - raise exceptions.IOError("This action requires the -n option."); + raise IOError("This action requires the -n option."); else: name = options.kernel_name; if options.base_path: @@ -88,7 +88,7 @@ if __name__ == '__main__': if options.remove_kernel: if not options.kernel_name: - raise exceptions.IOError("This action requires the -n option."); + raise IOError("This action requires the -n option."); else: name = options.kernel_name; my_modtool.remove_kernel(name); @@ -105,17 +105,17 @@ if __name__ == '__main__': if options.remote_list: if not options.base_path: - raise exceptions.IOError("This action requires the -b option. Try -l or -k for listing kernels in the base or the module.") + raise IOError("This action requires the -b option. Try -l or -k for listing kernels in the base or the module.") else: base = options.base_path; kernelset = my_modtool.get_current_kernels(base); for i in kernelset: - print i; + print(i); if options.list: kernelset = my_modtool.get_current_kernels(); for i in kernelset: - print i; + print(i); if options.kernels: dest = my_cfg.cfg.get(my_cfg.config_name, 'destination'); @@ -123,4 +123,4 @@ if __name__ == '__main__': base = os.path.join(dest, 'volk_gnsssdr_' + name); kernelset = my_modtool.get_current_kernels(base); for i in kernelset: - print i; + print(i); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py index 3384ecd91..35905ad15 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py @@ -21,25 +21,20 @@ from __future__ import print_function import os -import glob -import sys import re import glob -import shutil -import exceptions -from sets import Set -class volk_gnsssdr_modtool: +class volk_gnsssdr_modtool(object): def __init__(self, cfg): self.volk_gnsssdr = re.compile('volk_gnsssdr'); self.remove_after_underscore = re.compile("_.*"); - self.volk_gnsssdr_run_tests = re.compile('^\s*VOLK_RUN_TESTS.*\n', re.MULTILINE); - self.volk_gnsssdr_profile = re.compile('^\s*(VOLK_PROFILE|VOLK_PUPPET_PROFILE).*\n', re.MULTILINE); + self.volk_gnsssdr_run_tests = re.compile(r'^\s*VOLK_RUN_TESTS.*\n', re.MULTILINE); + self.volk_gnsssdr_profile = re.compile(r'^\s*(VOLK_PROFILE|VOLK_PUPPET_PROFILE).*\n', re.MULTILINE); self.my_dict = cfg; - self.lastline = re.compile('\s*char path\[1024\];.*'); - self.badassert = re.compile('^\s*assert\(toked\[0\] == "volk_gnsssdr_.*\n', re.MULTILINE); + self.lastline = re.compile(r'\s*char path\[1024\];.*'); + self.badassert = re.compile(r'^\s*assert\(toked\[0\] == "volk_gnsssdr_.*\n', re.MULTILINE); self.goodassert = ' assert(toked[0] == "volk_gnsssdr");\n' - self.baderase = re.compile('^\s*toked.erase\(toked.begin\(\)\);.*\n', re.MULTILINE); + self.baderase = re.compile(r'^\s*toked.erase\(toked.begin\(\)\);.*\n', re.MULTILINE); self.gooderase = ' toked.erase(toked.begin());\n toked.erase(toked.begin());\n'; def get_basename(self, base=None): @@ -70,7 +65,7 @@ class volk_gnsssdr_modtool: for line in hdr_files: - subline = re.search(".*\.h.*", os.path.basename(line)) + subline = re.search(r".*\.h.*", os.path.basename(line)) if subline: subsubline = begins.search(subline.group(0)); if subsubline: @@ -86,7 +81,7 @@ class volk_gnsssdr_modtool: for dt in datatypes: if dt in line: #subline = re.search("(?<=volk_gnsssdr_)" + dt + ".*(?=\.h)", line); - subline = re.search(begins.pattern[:-2] + dt + ".*(?=\.h)", line); + subline = re.search(begins.pattern[:-2] + dt + r".*(?=\.h)", line); if subline: functions.append(subline.group(0)); @@ -96,7 +91,7 @@ class volk_gnsssdr_modtool: dest = os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name']) if os.path.exists(dest): - raise exceptions.IOError("Destination %s already exits!"%(dest)); + raise IOError("Destination %s already exits!" % (dest)); if not os.path.exists(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'kernels/volk_gnsssdr_' + self.my_dict['name'])): os.makedirs(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'kernels/volk_gnsssdr_' + self.my_dict['name'])) @@ -108,7 +103,7 @@ class volk_gnsssdr_modtool: for root, dirnames, filenames in os.walk(self.my_dict['base']): for name in filenames: - t_table = map(lambda a: re.search(a, name), current_kernel_names); + t_table = [re.search(a, name) for a in current_kernel_names] t_table = set(t_table); if t_table == set([None]): infile = os.path.join(root, name); @@ -188,18 +183,13 @@ class volk_gnsssdr_modtool: base = os.path.join(self.my_dict['destination'], top[:-1]) ; if not name in self.get_current_kernels(): - - raise exceptions.IOError("Requested kernel %s is not in module %s"%(name,base)); - - + raise IOError("Requested kernel %s is not in module %s" % (name,base)); inpath = os.path.abspath(base); - - kernel = re.compile(name) - search_kernels = Set([kernel]) - profile = re.compile('^\s*VOLK_PROFILE') - puppet = re.compile('^\s*VOLK_PUPPET') + search_kernels = set([kernel]) + profile = re.compile(r'^\s*VOLK_PROFILE') + puppet = re.compile(r'^\s*VOLK_PUPPET') src_dest = os.path.join(inpath, 'apps/', top[:-1] + '_profile.cc'); infile = open(src_dest); otherlines = infile.readlines(); @@ -253,7 +243,7 @@ class volk_gnsssdr_modtool: else: basename = self.get_basename(base); if not name in self.get_current_kernels(base): - raise exceptions.IOError("Requested kernel %s is not in module %s"%(name,base)); + raise IOError("Requested kernel %s is not in module %s" % (name, base)); inpath = os.path.abspath(base); if len(basename) > 0: @@ -265,10 +255,10 @@ class volk_gnsssdr_modtool: self.convert_kernel(oldvolk_gnsssdr, name, base, inpath, top); kernel = re.compile(name) - search_kernels = Set([kernel]) + search_kernels = set([kernel]) - profile = re.compile('^\s*VOLK_PROFILE') - puppet = re.compile('^\s*VOLK_PUPPET') + profile = re.compile(r'^\s*VOLK_PROFILE') + puppet = re.compile(r'^\s*VOLK_PUPPET') infile = open(os.path.join(inpath, 'apps/', oldvolk_gnsssdr.pattern + '_profile.cc')); otherinfile = open(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'apps/volk_gnsssdr_' + self.my_dict['name'] + '_profile.cc')); dest = os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'apps/volk_gnsssdr_' + self.my_dict['name'] + '_profile.cc'); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h index cfde1b241..51f8026fc 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h @@ -19,14 +19,13 @@ #ifndef INCLUDED_VOLK_GNSSSDR_RUNTIME #define INCLUDED_VOLK_GNSSSDR_RUNTIME -#include -#include #include #include +#include #include - -#include +#include #include +#include __VOLK_DECL_BEGIN diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_cpu.tmpl.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_cpu.tmpl.c index 4aba13014..420b5c91d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_cpu.tmpl.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_cpu.tmpl.c @@ -123,6 +123,15 @@ static inline unsigned int get_avx2_enabled(void) #endif } +static inline unsigned int get_avx512_enabled(void) +{ +#if defined(VOLK_CPU_x86) + return __xgetbv() & 0xE6; //check for zmm, xmm and ymm regs +#else + return 0; +#endif +} + //neon detection is linux specific #if defined(__arm__) && defined(__linux__) #include diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_typedefs.tmpl.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_typedefs.tmpl.h index 2d7ac6a30..d55149147 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_typedefs.tmpl.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr_typedefs.tmpl.h @@ -19,8 +19,8 @@ #ifndef INCLUDED_VOLK_GNSSSDR_TYPEDEFS #define INCLUDED_VOLK_GNSSSDR_TYPEDEFS -#include #include +#include // clang-format off %for kern in kernels: diff --git a/src/algorithms/observables/CMakeLists.txt b/src/algorithms/observables/CMakeLists.txt index 64cb2a571..1841d3dfc 100644 --- a/src/algorithms/observables/CMakeLists.txt +++ b/src/algorithms/observables/CMakeLists.txt @@ -17,4 +17,4 @@ # add_subdirectory(adapters) -add_subdirectory(gnuradio_blocks) \ No newline at end of file +add_subdirectory(gnuradio_blocks) diff --git a/src/algorithms/observables/adapters/CMakeLists.txt b/src/algorithms/observables/adapters/CMakeLists.txt index d3cff285a..a75cd92df 100644 --- a/src/algorithms/observables/adapters/CMakeLists.txt +++ b/src/algorithms/observables/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,24 +17,42 @@ # set(OBS_ADAPTER_SOURCES - hybrid_observables.cc + hybrid_observables.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/observables/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} +set(OBS_ADAPTER_HEADERS + hybrid_observables.h ) -file(GLOB OBS_ADAPTER_HEADERS "*.h") -list(SORT OBS_ADAPTER_HEADERS) -add_library(obs_adapters ${OBS_ADAPTER_SOURCES} ${OBS_ADAPTER_HEADERS}) source_group(Headers FILES ${OBS_ADAPTER_HEADERS}) -target_link_libraries(obs_adapters obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES}) + +add_library(obs_adapters ${OBS_ADAPTER_SOURCES} ${OBS_ADAPTER_HEADERS}) + +target_include_directories(obs_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +target_link_libraries(obs_adapters + PUBLIC + obs_gr_blocks + algorithms_libs + PRIVATE + Gflags::gflags + Glog::glog +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(obs_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET obs_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/observables/adapters/hybrid_observables.cc b/src/algorithms/observables/adapters/hybrid_observables.cc index 4313edfee..f92c02b48 100644 --- a/src/algorithms/observables/adapters/hybrid_observables.cc +++ b/src/algorithms/observables/adapters/hybrid_observables.cc @@ -38,21 +38,20 @@ using google::LogMessage; HybridObservables::HybridObservables(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams) : - role_(role), in_streams_(in_streams), out_streams_(out_streams) + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { std::string default_dump_filename = "./observables.dat"; DLOG(INFO) << "role " << role; dump_ = configuration->property(role + ".dump", false); + dump_mat_ = configuration->property(role + ".dump_mat", true); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); - observables_ = hybrid_make_observables_cc(in_streams_, out_streams_, dump_, dump_filename_); + observables_ = hybrid_make_observables_cc(in_streams_, out_streams_, dump_, dump_mat_, dump_filename_); DLOG(INFO) << "Observables block ID (" << observables_->unique_id() << ")"; } -HybridObservables::~HybridObservables() -{} +HybridObservables::~HybridObservables() = default; void HybridObservables::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/observables/adapters/hybrid_observables.h b/src/algorithms/observables/adapters/hybrid_observables.h index 57883374a..35015b837 100644 --- a/src/algorithms/observables/adapters/hybrid_observables.h +++ b/src/algorithms/observables/adapters/hybrid_observables.h @@ -47,7 +47,7 @@ class HybridObservables : public ObservablesInterface { public: HybridObservables(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -83,6 +83,7 @@ public: private: hybrid_observables_cc_sptr observables_; bool dump_; + bool dump_mat_; std::string dump_filename_; std::string role_; unsigned int in_streams_; diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index 276908208..e50fabfd2 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,31 +16,46 @@ # along with GNSS-SDR. If not, see . # -set(OBS_GR_BLOCKS_SOURCES - hybrid_observables_cc.cc +set(OBS_GR_BLOCKS_SOURCES + hybrid_observables_cc.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${ARMADILLO_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${MATIO_INCLUDE_DIRS} +set(OBS_GR_BLOCKS_HEADERS + hybrid_observables_cc.h ) -file(GLOB OBS_GR_BLOCKS_HEADERS "*.h") -list(SORT OBS_GR_BLOCKS_HEADERS) -add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS}) -if(MATIO_FOUND) - add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) -else(MATIO_FOUND) - add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) -endif(MATIO_FOUND) -target_link_libraries(obs_gr_blocks gnss_sp_libs ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) + +add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS}) + +target_include_directories(obs_gr_blocks + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs +) + +target_link_libraries(obs_gr_blocks + PUBLIC + Boost::boost + Gnuradio::blocks + core_system_parameters + PRIVATE + Gflags::gflags + Glog::glog + Boost::filesystem + Matio::matio + algorithms_libs +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(obs_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET obs_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index aa7d49cd7..429931dd0 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -30,63 +30,98 @@ */ #include "hybrid_observables_cc.h" -#include "display.h" #include "GPS_L1_CA.h" -#include +#include "display.h" +#include "gnss_sdr_create_directory.h" +#include #include #include #include #include #include +#include +#include #include #include +#include using google::LogMessage; -hybrid_observables_cc_sptr hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename) +hybrid_observables_cc_sptr hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, bool dump_mat, std::string dump_filename) { - return hybrid_observables_cc_sptr(new hybrid_observables_cc(nchannels_in, nchannels_out, dump, dump_filename)); + return hybrid_observables_cc_sptr(new hybrid_observables_cc(nchannels_in, nchannels_out, dump, dump_mat, std::move(dump_filename))); } -hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, - unsigned int nchannels_out, +hybrid_observables_cc::hybrid_observables_cc(uint32_t nchannels_in, + uint32_t nchannels_out, bool dump, + bool dump_mat, std::string dump_filename) : gr::block("hybrid_observables_cc", gr::io_signature::make(nchannels_in, nchannels_in, sizeof(Gnss_Synchro)), gr::io_signature::make(nchannels_out, nchannels_out, sizeof(Gnss_Synchro))) { d_dump = dump; - d_nchannels = nchannels_out; - d_dump_filename = dump_filename; - T_rx_s = 0.0; - T_rx_step_s = 0.001; // 1 ms - max_delta = 1.5; // 1.5 s - d_latency = 0.5; // 300 ms - valid_channels.resize(d_nchannels, false); - d_num_valid_channels = 0; - d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0), d_nchannels); + d_dump_mat = dump_mat and d_dump; + d_dump_filename = std::move(dump_filename); + d_nchannels_out = nchannels_out; + d_nchannels_in = nchannels_in; + T_rx_clock_step_samples = 0U; + d_gnss_synchro_history = new Gnss_circular_deque(500, d_nchannels_out); // ############# ENABLE DATA FILE LOG ################# if (d_dump) { - if (!d_dump_file.is_open()) + std::string dump_path; + // Get path + if (d_dump_filename.find_last_of('/') != std::string::npos) { - try - { - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Observables dump enabled Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception opening observables dump file " << e.what(); - d_dump = false; - } + std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); + dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); + d_dump_filename = dump_filename_; + } + else + { + dump_path = std::string("."); + } + if (d_dump_filename.empty()) + { + d_dump_filename = "observables.dat"; + } + // remove extension if any + if (d_dump_filename.substr(1).find_last_of('.') != std::string::npos) + { + d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); + } + d_dump_filename.append(".dat"); + d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + // create directory + if (!gnss_sdr_create_directory(dump_path)) + { + std::cerr << "GNSS-SDR cannot create dump file for the Observables block. Wrong permissions?" << std::endl; + d_dump = false; + } + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Observables dump enabled Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception opening observables dump file " << e.what(); + d_dump = false; } } + T_rx_TOW_ms = 0U; + T_rx_TOW_offset_ms = 0U; + T_rx_TOW_set = false; + + // rework + d_Rx_clock_buffer.resize(10); // 10*20 ms = 200 ms of data in buffer + d_Rx_clock_buffer.clear(); // Clear all the elements in the buffer } @@ -104,26 +139,33 @@ hybrid_observables_cc::~hybrid_observables_cc() LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); } } - if (d_dump) + if (d_dump_mat) { - std::cout << "Writing observables .mat files ..."; - save_matfile(); - std::cout << " done." << std::endl; + try + { + save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } } } -int hybrid_observables_cc::save_matfile() +int32_t hybrid_observables_cc::save_matfile() { // READ DUMP FILE + std::string dump_filename = d_dump_filename; std::ifstream::pos_type size; - int number_of_double_vars = 7; - int epoch_size_bytes = sizeof(double) * number_of_double_vars * d_nchannels; + int32_t number_of_double_vars = 7; + int32_t epoch_size_bytes = sizeof(double) * number_of_double_vars * d_nchannels_out; std::ifstream dump_file; + std::cout << "Generating .mat file for " << dump_filename << std::endl; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try { - dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + dump_file.open(dump_filename.c_str(), std::ios::binary | std::ios::ate); } catch (const std::ifstream::failure &e) { @@ -131,26 +173,26 @@ int hybrid_observables_cc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0LL; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - double **RX_time = new double *[d_nchannels]; - double **TOW_at_current_symbol_s = new double *[d_nchannels]; - double **Carrier_Doppler_hz = new double *[d_nchannels]; - double **Carrier_phase_cycles = new double *[d_nchannels]; - double **Pseudorange_m = new double *[d_nchannels]; - double **PRN = new double *[d_nchannels]; - double **Flag_valid_pseudorange = new double *[d_nchannels]; + auto **RX_time = new double *[d_nchannels_out]; + auto **TOW_at_current_symbol_s = new double *[d_nchannels_out]; + auto **Carrier_Doppler_hz = new double *[d_nchannels_out]; + auto **Carrier_phase_cycles = new double *[d_nchannels_out]; + auto **Pseudorange_m = new double *[d_nchannels_out]; + auto **PRN = new double *[d_nchannels_out]; + auto **Flag_valid_pseudorange = new double *[d_nchannels_out]; - for (unsigned int i = 0; i < d_nchannels; i++) + for (uint32_t i = 0; i < d_nchannels_out; i++) { RX_time[i] = new double[num_epoch]; TOW_at_current_symbol_s[i] = new double[num_epoch]; @@ -165,9 +207,9 @@ int hybrid_observables_cc::save_matfile() { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { - for (unsigned int chan = 0; chan < d_nchannels; chan++) + for (uint32_t chan = 0; chan < d_nchannels_out; chan++) { dump_file.read(reinterpret_cast(&RX_time[chan][i]), sizeof(double)); dump_file.read(reinterpret_cast(&TOW_at_current_symbol_s[chan][i]), sizeof(double)); @@ -184,7 +226,7 @@ int hybrid_observables_cc::save_matfile() catch (const std::ifstream::failure &e) { std::cerr << "Problem reading dump file:" << e.what() << std::endl; - for (unsigned int i = 0; i < d_nchannels; i++) + for (uint32_t i = 0; i < d_nchannels_out; i++) { delete[] RX_time[i]; delete[] TOW_at_current_symbol_s[i]; @@ -205,17 +247,17 @@ int hybrid_observables_cc::save_matfile() return 1; } - double *RX_time_aux = new double[d_nchannels * num_epoch]; - double *TOW_at_current_symbol_s_aux = new double[d_nchannels * num_epoch]; - double *Carrier_Doppler_hz_aux = new double[d_nchannels * num_epoch]; - double *Carrier_phase_cycles_aux = new double[d_nchannels * num_epoch]; - double *Pseudorange_m_aux = new double[d_nchannels * num_epoch]; - double *PRN_aux = new double[d_nchannels * num_epoch]; - double *Flag_valid_pseudorange_aux = new double[d_nchannels * num_epoch]; - unsigned int k = 0; - for (long int j = 0; j < num_epoch; j++) + auto *RX_time_aux = new double[d_nchannels_out * num_epoch]; + auto *TOW_at_current_symbol_s_aux = new double[d_nchannels_out * num_epoch]; + auto *Carrier_Doppler_hz_aux = new double[d_nchannels_out * num_epoch]; + auto *Carrier_phase_cycles_aux = new double[d_nchannels_out * num_epoch]; + auto *Pseudorange_m_aux = new double[d_nchannels_out * num_epoch]; + auto *PRN_aux = new double[d_nchannels_out * num_epoch]; + auto *Flag_valid_pseudorange_aux = new double[d_nchannels_out * num_epoch]; + uint32_t k = 0U; + for (int64_t j = 0; j < num_epoch; j++) { - for (unsigned int i = 0; i < d_nchannels; i++) + for (uint32_t i = 0; i < d_nchannels_out; i++) { RX_time_aux[k] = RX_time[i][j]; TOW_at_current_symbol_s_aux[k] = TOW_at_current_symbol_s[i][j]; @@ -237,10 +279,10 @@ int hybrid_observables_cc::save_matfile() filename.erase(filename.end() - 4, filename.end()); } filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { - size_t dims[2] = {static_cast(d_nchannels), static_cast(num_epoch)}; + size_t dims[2] = {static_cast(d_nchannels_out), static_cast(num_epoch)}; matvar = Mat_VarCreate("RX_time", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, RX_time_aux, MAT_F_DONT_COPY_DATA); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -271,7 +313,7 @@ int hybrid_observables_cc::save_matfile() } Mat_Close(matfp); - for (unsigned int i = 0; i < d_nchannels; i++) + for (uint32_t i = 0; i < d_nchannels_out; i++) { delete[] RX_time[i]; delete[] TOW_at_current_symbol_s[i]; @@ -300,153 +342,159 @@ int hybrid_observables_cc::save_matfile() } -bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned int &ch, const double &ti) -{ - if ((ti < d_gnss_synchro_history->front(ch).RX_time) or (ti > d_gnss_synchro_history->back(ch).RX_time)) - { - return false; - } - find_interp_elements(ch, ti); - - //Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1) - - // CARRIER PHASE INTERPOLATION - out.Carrier_phase_rads = d_gnss_synchro_history->at(ch, 0).Carrier_phase_rads + (d_gnss_synchro_history->at(ch, 1).Carrier_phase_rads - d_gnss_synchro_history->at(ch, 0).Carrier_phase_rads) * (ti - d_gnss_synchro_history->at(ch, 0).RX_time) / (d_gnss_synchro_history->at(ch, 1).RX_time - d_gnss_synchro_history->at(ch, 0).RX_time); - - // CARRIER DOPPLER INTERPOLATION - out.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, 0).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, 1).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, 0).Carrier_Doppler_hz) * (ti - d_gnss_synchro_history->at(ch, 0).RX_time) / (d_gnss_synchro_history->at(ch, 1).RX_time - d_gnss_synchro_history->at(ch, 0).RX_time); - - // TOW INTERPOLATION - out.TOW_at_current_symbol_s = d_gnss_synchro_history->at(ch, 0).TOW_at_current_symbol_s + (d_gnss_synchro_history->at(ch, 1).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, 0).TOW_at_current_symbol_s) * (ti - d_gnss_synchro_history->at(ch, 0).RX_time) / (d_gnss_synchro_history->at(ch, 1).RX_time - d_gnss_synchro_history->at(ch, 0).RX_time); - - return true; -} - - double hybrid_observables_cc::compute_T_rx_s(const Gnss_Synchro &a) { - if (a.Flag_valid_word) - { - return ((static_cast(a.Tracking_sample_counter) + a.Code_phase_samples) / static_cast(a.fs)); - } - else - { - return 0.0; - } -} - -void hybrid_observables_cc::find_interp_elements(const unsigned int &ch, const double &ti) -{ - unsigned int closest = 0; - double dif = std::numeric_limits::max(); - double dt = 0.0; - for (unsigned int i = 0; i < d_gnss_synchro_history->size(ch); i++) - { - dt = std::fabs(ti - d_gnss_synchro_history->at(ch, i).RX_time); - if (dt < dif) - { - closest = i; - dif = dt; - } - else - { - break; - } - } - if (ti > d_gnss_synchro_history->at(ch, closest).RX_time) - { - while (closest > 0) - { - d_gnss_synchro_history->pop_front(ch); - closest--; - } - } - else - { - while (closest > 1) - { - d_gnss_synchro_history->pop_front(ch); - closest--; - } - } + return ((static_cast(a.Tracking_sample_counter) + a.Code_phase_samples) / static_cast(a.fs)); } -void hybrid_observables_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) +bool hybrid_observables_cc::interp_trk_obs(Gnss_Synchro &interpolated_obs, const uint32_t &ch, const uint64_t &rx_clock) { - for (unsigned int i = 0; i < d_nchannels; i++) + int32_t nearest_element = -1; + int64_t abs_diff; + int64_t old_abs_diff = std::numeric_limits::max(); + for (uint32_t i = 0; i < d_gnss_synchro_history->size(ch); i++) { - ninput_items_required[i] = 0; - } - ninput_items_required[d_nchannels] = noutput_items; -} - - -void hybrid_observables_cc::clean_history(unsigned int pos) -{ - while (d_gnss_synchro_history->size(pos) > 0) - { - if ((T_rx_s - d_gnss_synchro_history->front(pos).RX_time) > max_delta) + abs_diff = llabs(static_cast(rx_clock) - static_cast(d_gnss_synchro_history->at(ch, i).Tracking_sample_counter)); + if (old_abs_diff > abs_diff) { - d_gnss_synchro_history->pop_front(pos); - } - else - { - return; + old_abs_diff = abs_diff; + nearest_element = static_cast(i); } } -} - -void hybrid_observables_cc::correct_TOW_and_compute_prange(std::vector &data) -{ - std::vector::iterator it; - -/////////////////////// DEBUG ////////////////////////// -// Logs if there is a pseudorange difference between -// signals of the same satellite higher than a threshold -//////////////////////////////////////////////////////// -#ifndef NDEBUG - std::vector::iterator it2; - double thr_ = 250.0 / SPEED_OF_LIGHT; // Maximum pseudorange difference = 250 meters - for (it = data.begin(); it != (data.end() - 1); it++) + if (nearest_element != -1 and nearest_element != static_cast(d_gnss_synchro_history->size(ch))) { - for (it2 = it + 1; it2 != data.end(); it2++) + if ((static_cast(old_abs_diff) / static_cast(d_gnss_synchro_history->at(ch, nearest_element).fs)) < 0.02) { - if (it->PRN == it2->PRN and it->System == it2->System) + int32_t neighbor_element; + if (rx_clock > d_gnss_synchro_history->at(ch, nearest_element).Tracking_sample_counter) { - double tow_dif_ = std::fabs(it->TOW_at_current_symbol_s - it2->TOW_at_current_symbol_s); - if (tow_dif_ > thr_) + neighbor_element = nearest_element + 1; + } + else + { + neighbor_element = nearest_element - 1; + } + if (neighbor_element < static_cast(d_gnss_synchro_history->size(ch)) and neighbor_element >= 0) + { + int32_t t1_idx; + int32_t t2_idx; + if (rx_clock > d_gnss_synchro_history->at(ch, nearest_element).Tracking_sample_counter) { - DLOG(INFO) << "System " << it->System << ". Signals " << it->Signal << " and " << it2->Signal - << ". TOW difference in PRN " << it->PRN - << " = " << tow_dif_ * 1e3 << "[ms]. Equivalent to " << tow_dif_ * SPEED_OF_LIGHT - << " meters in pseudorange"; - std::cout << TEXT_RED << "System " << it->System << ". Signals " << it->Signal << " and " << it2->Signal - << ". TOW difference in PRN " << it->PRN - << " = " << tow_dif_ * 1e3 << "[ms]. Equivalent to " << tow_dif_ * SPEED_OF_LIGHT - << " meters in pseudorange" << TEXT_RESET << std::endl; + //std::cout << "S1= " << d_gnss_synchro_history->at(ch, nearest_element).Tracking_sample_counter + // << " Si=" << rx_clock << " S2=" << d_gnss_synchro_history->at(ch, neighbor_element).Tracking_sample_counter << std::endl; + t1_idx = nearest_element; + t2_idx = neighbor_element; } + else + { + //std::cout << "inv S1= " << d_gnss_synchro_history->at(ch, neighbor_element).Tracking_sample_counter + // << " Si=" << rx_clock << " S2=" << d_gnss_synchro_history->at(ch, nearest_element).Tracking_sample_counter << std::endl; + t1_idx = neighbor_element; + t2_idx = nearest_element; + } + + // 1st: copy the nearest gnss_synchro data for that channel + interpolated_obs = d_gnss_synchro_history->at(ch, nearest_element); + + // 2nd: Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1) + + double T_rx_s = static_cast(rx_clock) / static_cast(interpolated_obs.fs); + + double time_factor = (T_rx_s - d_gnss_synchro_history->at(ch, t1_idx).RX_time) / + (d_gnss_synchro_history->at(ch, t2_idx).RX_time - + d_gnss_synchro_history->at(ch, t1_idx).RX_time); + + // CARRIER PHASE INTERPOLATION + interpolated_obs.Carrier_phase_rads = d_gnss_synchro_history->at(ch, t1_idx).Carrier_phase_rads + (d_gnss_synchro_history->at(ch, t2_idx).Carrier_phase_rads - d_gnss_synchro_history->at(ch, t1_idx).Carrier_phase_rads) * time_factor; + // CARRIER DOPPLER INTERPOLATION + interpolated_obs.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, t1_idx).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, t2_idx).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, t1_idx).Carrier_Doppler_hz) * time_factor; + // TOW INTERPOLATION + interpolated_obs.interp_TOW_ms = static_cast(d_gnss_synchro_history->at(ch, t1_idx).TOW_at_current_symbol_ms) + (static_cast(d_gnss_synchro_history->at(ch, t2_idx).TOW_at_current_symbol_ms) - static_cast(d_gnss_synchro_history->at(ch, t1_idx).TOW_at_current_symbol_ms)) * time_factor; + // + // std::cout << "Rx samplestamp: " << T_rx_s << " Channel " << ch << " interp buff idx " << nearest_element + // << " ,diff: " << old_abs_diff << " samples (" << static_cast(old_abs_diff) / static_cast(d_gnss_synchro_history->at(ch, nearest_element).fs) << " s)\n"; + return true; + } + return false; + } + // std::cout << "ALERT: Channel " << ch << " interp buff idx " << nearest_element + // << " ,diff: " << old_abs_diff << " samples (" << static_cast(old_abs_diff) / static_cast(d_gnss_synchro_history->at(ch, nearest_element).fs) << " s)\n"; + // usleep(1000); + } + return false; +} + + +void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) +{ + for (int32_t n = 0; n < static_cast(d_nchannels_in) - 1; n++) + { + ninput_items_required[n] = 0; + } + // last input channel is the sample counter, triggered each ms + ninput_items_required[d_nchannels_in - 1] = 1; +} + + +void hybrid_observables_cc::update_TOW(std::vector &data) +{ + //1. Set the TOW using the minimum TOW in the observables. + // this will be the receiver time. + //2. If the TOW is set, it must be incremented by the desired receiver time step. + // the time step must match the observables timer block (connected to the las input channel) + std::vector::iterator it; + // if (!T_rx_TOW_set) + // { + //uint32_t TOW_ref = std::numeric_limits::max(); + uint32_t TOW_ref = 0U; + for (it = data.begin(); it != data.end(); it++) + { + if (it->Flag_valid_word) + { + if (it->TOW_at_current_symbol_ms > TOW_ref) + { + TOW_ref = it->TOW_at_current_symbol_ms; + T_rx_TOW_set = true; } } } -#endif - /////////////////////////////////////////////////////////// + T_rx_TOW_ms = TOW_ref; + //} + // else + // { + // T_rx_TOW_ms += T_rx_step_ms; + // //todo: check what happens during the week rollover + // if (T_rx_TOW_ms >= 604800000) + // { + // T_rx_TOW_ms = T_rx_TOW_ms % 604800000; + // } + // } + // std::cout << "T_rx_TOW_ms: " << T_rx_TOW_ms << std::endl; +} - double TOW_ref = std::numeric_limits::lowest(); + +void hybrid_observables_cc::compute_pranges(std::vector &data) +{ + std::vector::iterator it; for (it = data.begin(); it != data.end(); it++) { - if (it->TOW_at_current_symbol_s > TOW_ref) + if (it->Flag_valid_word) { - TOW_ref = it->TOW_at_current_symbol_s; + double traveltime_s = (static_cast(T_rx_TOW_ms) - it->interp_TOW_ms + GPS_STARTOFFSET_MS) / 1000.0; + //todo: check what happens during the week rollover (TOW rollover at 604800000s) + it->RX_time = (static_cast(T_rx_TOW_ms) + GPS_STARTOFFSET_MS) / 1000.0; + it->Pseudorange_m = traveltime_s * SPEED_OF_LIGHT; + it->Flag_valid_pseudorange = true; + // debug code + // std::cout.precision(17); + // std::cout << "[" << it->Channel_ID << "] interp_TOW_ms: " << it->interp_TOW_ms << std::endl; + // std::cout << "[" << it->Channel_ID << "] Diff T_rx_TOW_ms - interp_TOW_ms: " << static_cast(T_rx_TOW_ms) - it->interp_TOW_ms << std::endl; + // std::cout << "[" << it->Channel_ID << "] Pseudorange_m: " << it->Pseudorange_m << std::endl; } } - for (it = data.begin(); it != data.end(); it++) - { - double traveltime_s = TOW_ref - it->TOW_at_current_symbol_s + GPS_STARTOFFSET_ms / 1000.0; - it->RX_time = TOW_ref + GPS_STARTOFFSET_ms / 1000.0; - it->Pseudorange_m = traveltime_s * SPEED_OF_LIGHT; - } + // usleep(1000); } @@ -454,132 +502,88 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const Gnss_Synchro **in = reinterpret_cast(&input_items[0]); - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto **in = reinterpret_cast(&input_items[0]); + auto **out = reinterpret_cast(&output_items[0]); - unsigned int i; - unsigned int returned_elements = 0; - int total_input_items = 0; - for (i = 0; i < d_nchannels; i++) + // Push receiver clock into history buffer (connected to the last of the input channels) + // The clock buffer gives time to the channels to compute the tracking observables + if (ninput_items[d_nchannels_in - 1] > 0) { - total_input_items += ninput_items[i]; + d_Rx_clock_buffer.push_back(in[d_nchannels_in - 1][0].Tracking_sample_counter); + if (T_rx_clock_step_samples == 0) + { + T_rx_clock_step_samples = std::round(static_cast(in[d_nchannels_in - 1][0].fs) * 1e-3); // 1 ms + LOG(INFO) << "Observables clock step samples set to " << T_rx_clock_step_samples; + usleep(1000000); + } + + // Consume one item from the clock channel (last of the input channels) + consume(d_nchannels_in - 1, 1); } - for (int epoch = 0; epoch < ninput_items[d_nchannels]; epoch++) + + // Push the tracking observables into buffers to allow the observable interpolation at the desired Rx clock + for (uint32_t n = 0; n < d_nchannels_out; n++) { - T_rx_s += T_rx_step_s; - - ////////////////////////////////////////////////////////////////////////// - if ((total_input_items == 0) and (d_num_valid_channels == 0)) + // Push the valid tracking Gnss_Synchros to their corresponding deque + for (int32_t m = 0; m < ninput_items[n]; m++) { - consume(d_nchannels, epoch + 1); - return returned_elements; - } - ////////////////////////////////////////////////////////////////////////// - - if (total_input_items > 0 and epoch == 0) - { - for (i = 0; i < d_nchannels; i++) + if (in[n][m].Flag_valid_word) { - if (ninput_items[i] > 0) + if (d_gnss_synchro_history->size(n) > 0) { - // Add the new Gnss_Synchros to their corresponding deque - for (int aux = 0; aux < ninput_items[i]; aux++) + // Check if the last Gnss_Synchro comes from the same satellite as the previous ones + if (d_gnss_synchro_history->front(n).PRN != in[n][m].PRN) { - if (in[i][aux].Flag_valid_word) - { - d_gnss_synchro_history->push_back(i, in[i][aux]); - d_gnss_synchro_history->back(i).RX_time = compute_T_rx_s(in[i][aux]); - // Check if the last Gnss_Synchro comes from the same satellite as the previous ones - if (d_gnss_synchro_history->size(i) > 1) - { - if (d_gnss_synchro_history->front(i).PRN != d_gnss_synchro_history->back(i).PRN) - { - d_gnss_synchro_history->clear(i); - } - } - } + d_gnss_synchro_history->clear(n); } - consume(i, ninput_items[i]); } + d_gnss_synchro_history->push_back(n, in[n][m]); + d_gnss_synchro_history->back(n).RX_time = compute_T_rx_s(in[n][m]); } } - for (i = 0; i < d_nchannels; i++) - { - if (d_gnss_synchro_history->size(i) > 2) - { - valid_channels[i] = true; - } - else - { - valid_channels[i] = false; - } - } - d_num_valid_channels = valid_channels.count(); - // Check if there is any valid channel after reading the new incoming Gnss_Synchro data - if (d_num_valid_channels == 0) - { - consume(d_nchannels, epoch + 1); - return returned_elements; - } - - for (i = 0; i < d_nchannels; i++) //Discard observables with T_rx higher than the threshold - { - if (valid_channels[i]) - { - clean_history(i); - if (d_gnss_synchro_history->size(i) < 2) - { - valid_channels[i] = false; - } - } - } - - // Check if there is any valid channel after computing the time distance between the Gnss_Synchro data and the receiver time - d_num_valid_channels = valid_channels.count(); - double T_rx_s_out = T_rx_s - d_latency; - if ((d_num_valid_channels == 0) or (T_rx_s_out < 0.0)) - { - consume(d_nchannels, epoch + 1); - return returned_elements; - } + consume(n, ninput_items[n]); + } + if (d_Rx_clock_buffer.size() == d_Rx_clock_buffer.capacity()) + { std::vector epoch_data; - for (i = 0; i < d_nchannels; i++) + int32_t n_valid = 0; + for (uint32_t n = 0; n < d_nchannels_out; n++) { - if (valid_channels[i]) + Gnss_Synchro interpolated_gnss_synchro{}; + if (!interp_trk_obs(interpolated_gnss_synchro, n, d_Rx_clock_buffer.front() + T_rx_TOW_offset_ms * T_rx_clock_step_samples)) { - Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history->back(i); - if (interpolate_data(interpolated_gnss_synchro, i, T_rx_s_out)) - { - epoch_data.push_back(interpolated_gnss_synchro); - } - else - { - valid_channels[i] = false; - } - } - } - d_num_valid_channels = valid_channels.count(); - if (d_num_valid_channels == 0) - { - consume(d_nchannels, epoch + 1); - return returned_elements; - } - correct_TOW_and_compute_prange(epoch_data); - std::vector::iterator it = epoch_data.begin(); - for (i = 0; i < d_nchannels; i++) - { - if (valid_channels[i]) - { - out[i][epoch] = (*it); - out[i][epoch].Flag_valid_pseudorange = true; - it++; + // Produce an empty observation + interpolated_gnss_synchro = Gnss_Synchro(); + interpolated_gnss_synchro.Flag_valid_pseudorange = false; + interpolated_gnss_synchro.Flag_valid_word = false; + interpolated_gnss_synchro.Flag_valid_acquisition = false; + interpolated_gnss_synchro.fs = 0; + interpolated_gnss_synchro.Channel_ID = n; } else { - out[i][epoch] = Gnss_Synchro(); - out[i][epoch].Flag_valid_pseudorange = false; + n_valid++; } + epoch_data.push_back(interpolated_gnss_synchro); + } + if (n_valid > 0) + { + update_TOW(epoch_data); + if (T_rx_TOW_ms % 20 != 0) + { + T_rx_TOW_offset_ms = T_rx_TOW_ms % 20; + } + } + + if (n_valid > 0) + { + compute_pranges(epoch_data); + } + + for (uint32_t n = 0; n < d_nchannels_out; n++) + { + out[n][0] = epoch_data.at(n); } if (d_dump) { @@ -587,21 +591,21 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) try { double tmp_double; - for (i = 0; i < d_nchannels; i++) + for (uint32_t i = 0; i < d_nchannels_out; i++) { - tmp_double = out[i][epoch].RX_time; + tmp_double = out[i][0].RX_time; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][epoch].TOW_at_current_symbol_s; + tmp_double = out[i][0].interp_TOW_ms / 1000.0; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][epoch].Carrier_Doppler_hz; + tmp_double = out[i][0].Carrier_Doppler_hz; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][epoch].Carrier_phase_rads / GPS_TWO_PI; + tmp_double = out[i][0].Carrier_phase_rads / GPS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][epoch].Pseudorange_m; + tmp_double = out[i][0].Pseudorange_m; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(out[i][epoch].PRN); + tmp_double = static_cast(out[i][0].PRN); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(out[i][epoch].Flag_valid_pseudorange); + tmp_double = static_cast(out[i][0].Flag_valid_pseudorange); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); } } @@ -611,8 +615,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) d_dump = false; } } - returned_elements++; + return 1; } - consume(d_nchannels, ninput_items[d_nchannels]); - return returned_elements; + return 0; } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index 409327d9c..8a4d4c56e 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -34,10 +34,10 @@ #ifndef GNSS_SDR_HYBRID_OBSERVABLES_CC_H #define GNSS_SDR_HYBRID_OBSERVABLES_CC_H -#include "gnss_synchro.h" #include "gnss_circular_deque.h" -#include +#include "gnss_synchro.h" #include +#include #include #include #include @@ -45,10 +45,10 @@ class hybrid_observables_cc; -typedef boost::shared_ptr hybrid_observables_cc_sptr; +using hybrid_observables_cc_sptr = boost::shared_ptr; hybrid_observables_cc_sptr -hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); +hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, bool dump_mat, std::string dump_filename); /*! * \brief This class implements a block that computes observables @@ -63,25 +63,28 @@ public: private: friend hybrid_observables_cc_sptr - hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); - hybrid_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); - void clean_history(unsigned int pos); + hybrid_make_observables_cc(uint32_t nchannels_in, uint32_t nchannels_out, bool dump, bool dump_mat, std::string dump_filename); + hybrid_observables_cc(uint32_t nchannels_in, uint32_t nchannels_out, bool dump, bool dump_mat, std::string dump_filename); + bool interpolate_data(Gnss_Synchro& out, const uint32_t& ch, const double& ti); + bool interp_trk_obs(Gnss_Synchro& interpolated_obs, const uint32_t& ch, const uint64_t& rx_clock); double compute_T_rx_s(const Gnss_Synchro& a); - bool interpolate_data(Gnss_Synchro& out, const unsigned int& ch, const double& ti); - void find_interp_elements(const unsigned int& ch, const double& ti); - void correct_TOW_and_compute_prange(std::vector& data); - int save_matfile(); + void compute_pranges(std::vector& data); + void update_TOW(std::vector& data); + int32_t save_matfile(); + //time history + boost::circular_buffer d_Rx_clock_buffer; //Tracking observable history Gnss_circular_deque* d_gnss_synchro_history; - boost::dynamic_bitset<> valid_channels; - double T_rx_s; - double T_rx_step_s; - double max_delta; - double d_latency; + uint32_t T_rx_clock_step_samples; + //rx time follow GPST + bool T_rx_TOW_set; + uint32_t T_rx_TOW_ms; + uint32_t T_rx_TOW_offset_ms; bool d_dump; - unsigned int d_nchannels; - unsigned int d_num_valid_channels; + bool d_dump_mat; + uint32_t d_nchannels_in; + uint32_t d_nchannels_out; std::string d_dump_filename; std::ofstream d_dump_file; }; diff --git a/src/algorithms/resampler/CMakeLists.txt b/src/algorithms/resampler/CMakeLists.txt index 64cb2a571..1841d3dfc 100644 --- a/src/algorithms/resampler/CMakeLists.txt +++ b/src/algorithms/resampler/CMakeLists.txt @@ -17,4 +17,4 @@ # add_subdirectory(adapters) -add_subdirectory(gnuradio_blocks) \ No newline at end of file +add_subdirectory(gnuradio_blocks) diff --git a/src/algorithms/resampler/adapters/CMakeLists.txt b/src/algorithms/resampler/adapters/CMakeLists.txt index 886ad5487..18554d352 100644 --- a/src/algorithms/resampler/adapters/CMakeLists.txt +++ b/src/algorithms/resampler/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,29 +16,56 @@ # along with GNSS-SDR. If not, see . # + set(RESAMPLER_ADAPTER_SOURCES - direct_resampler_conditioner.cc - mmse_resampler_conditioner.cc + direct_resampler_conditioner.cc + mmse_resampler_conditioner.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/algorithms/resampler/gnuradio_blocks - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} +set(RESAMPLER_ADAPTER_HEADERS + direct_resampler_conditioner.h + mmse_resampler_conditioner.h ) - -if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) - add_definitions( -DGR_GREATER_38=1 ) -endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) - - -file(GLOB RESAMPLER_ADAPTER_HEADERS "*.h") list(SORT RESAMPLER_ADAPTER_HEADERS) -add_library(resampler_adapters ${RESAMPLER_ADAPTER_SOURCES} ${RESAMPLER_ADAPTER_HEADERS}) +list(SORT RESAMPLER_ADAPTER_SOURCES) + source_group(Headers FILES ${RESAMPLER_ADAPTER_HEADERS}) -target_link_libraries(resampler_adapters resampler_gr_blocks) + +add_library(resampler_adapters + ${RESAMPLER_ADAPTER_SOURCES} + ${RESAMPLER_ADAPTER_HEADERS} +) + +target_link_libraries(resampler_adapters + PUBLIC + Gnuradio::runtime + resampler_gr_blocks + PRIVATE + Gflags::gflags + Glog::glog + Volk::volk +) + +target_include_directories(resampler_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13.4") + target_compile_definitions(resampler_adapters PUBLIC -DGR_GREATER_38=1) +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(resampler_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET resampler_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc b/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc index c9524bca7..a1e6e2e1b 100644 --- a/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc +++ b/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc @@ -30,20 +30,21 @@ */ #include "direct_resampler_conditioner.h" +#include "configuration_interface.h" +#include "direct_resampler_conditioner_cb.h" #include "direct_resampler_conditioner_cc.h" #include "direct_resampler_conditioner_cs.h" -#include "direct_resampler_conditioner_cb.h" -#include "configuration_interface.h" #include #include #include #include +#include #include using google::LogMessage; DirectResamplerConditioner::DirectResamplerConditioner( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream) : role_(role), in_stream_(in_stream), out_stream_(out_stream) { std::string default_item_type = "short"; @@ -64,7 +65,7 @@ DirectResamplerConditioner::DirectResamplerConditioner( DLOG(INFO) << "dump_ is " << dump_; dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); resampler_ = direct_resampler_make_conditioner_cc(sample_freq_in_, sample_freq_out_); @@ -73,7 +74,7 @@ DirectResamplerConditioner::DirectResamplerConditioner( DLOG(INFO) << "Item size " << item_size_; DLOG(INFO) << "resampler(" << resampler_->unique_id() << ")"; } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); resampler_ = direct_resampler_make_conditioner_cs(sample_freq_in_, sample_freq_out_); @@ -82,7 +83,7 @@ DirectResamplerConditioner::DirectResamplerConditioner( DLOG(INFO) << "Item size " << item_size_; DLOG(INFO) << "resampler(" << resampler_->unique_id() << ")"; } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { item_size_ = sizeof(lv_8sc_t); resampler_ = direct_resampler_make_conditioner_cb(sample_freq_in_, sample_freq_out_); @@ -94,7 +95,7 @@ DirectResamplerConditioner::DirectResamplerConditioner( else { LOG(WARNING) << item_type_ << " unrecognized item type for resampler"; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (dump_) { @@ -102,10 +103,18 @@ DirectResamplerConditioner::DirectResamplerConditioner( file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -DirectResamplerConditioner::~DirectResamplerConditioner() {} +DirectResamplerConditioner::~DirectResamplerConditioner() = default; void DirectResamplerConditioner::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/resampler/adapters/direct_resampler_conditioner.h b/src/algorithms/resampler/adapters/direct_resampler_conditioner.h index a874b9268..300ce297f 100644 --- a/src/algorithms/resampler/adapters/direct_resampler_conditioner.h +++ b/src/algorithms/resampler/adapters/direct_resampler_conditioner.h @@ -47,7 +47,7 @@ class DirectResamplerConditioner : public GNSSBlockInterface { public: DirectResamplerConditioner(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream); virtual ~DirectResamplerConditioner(); diff --git a/src/algorithms/resampler/adapters/mmse_resampler_conditioner.cc b/src/algorithms/resampler/adapters/mmse_resampler_conditioner.cc index 382358ce9..bc18beba5 100644 --- a/src/algorithms/resampler/adapters/mmse_resampler_conditioner.cc +++ b/src/algorithms/resampler/adapters/mmse_resampler_conditioner.cc @@ -39,7 +39,7 @@ using google::LogMessage; MmseResamplerConditioner::MmseResamplerConditioner( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream) : role_(role), in_stream_(in_stream), out_stream_(out_stream) { std::string default_item_type = "gr_complex"; @@ -60,9 +60,20 @@ MmseResamplerConditioner::MmseResamplerConditioner( DLOG(INFO) << "dump_ is " << dump_; dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); + + + //create a FIR low pass filter + std::vector taps = gr::filter::firdes::low_pass(1.0, + sample_freq_in_, + sample_freq_out_ / 2.1, + sample_freq_out_ / 5, + gr::filter::firdes::win_type::WIN_HAMMING); + std::cout << "Enabled fractional resampler low pass filter with " << taps.size() << " taps" << std::endl; + fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(1, taps); + #ifdef GR_GREATER_38 resampler_ = gr::filter::mmse_resampler_cc::make(0.0, sample_freq_in_ / sample_freq_out_); #else @@ -84,22 +95,31 @@ MmseResamplerConditioner::MmseResamplerConditioner( file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -MmseResamplerConditioner::~MmseResamplerConditioner() {} +MmseResamplerConditioner::~MmseResamplerConditioner() = default; void MmseResamplerConditioner::connect(gr::top_block_sptr top_block) { if (dump_) { + top_block->connect(fir_filter_ccf_, 0, resampler_, 0); top_block->connect(resampler_, 0, file_sink_, 0); DLOG(INFO) << "connected resampler to file sink"; } else { - DLOG(INFO) << "nothing to connect internally"; + top_block->connect(fir_filter_ccf_, 0, resampler_, 0); } } @@ -108,14 +128,19 @@ void MmseResamplerConditioner::disconnect(gr::top_block_sptr top_block) { if (dump_) { + top_block->disconnect(fir_filter_ccf_, 0, resampler_, 0); top_block->disconnect(resampler_, 0, file_sink_, 0); } + else + { + top_block->disconnect(fir_filter_ccf_, 0, resampler_, 0); + } } gr::basic_block_sptr MmseResamplerConditioner::get_left_block() { - return resampler_; + return fir_filter_ccf_; } diff --git a/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h b/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h index b5c20c846..641975e83 100644 --- a/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h +++ b/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h @@ -35,10 +35,14 @@ #include "gnss_block_interface.h" #ifdef GR_GREATER_38 +#include #include #else +#include #include #endif + +#include #include class ConfigurationInterface; @@ -51,7 +55,7 @@ class MmseResamplerConditioner : public GNSSBlockInterface { public: MmseResamplerConditioner(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream); virtual ~MmseResamplerConditioner(); @@ -91,6 +95,7 @@ private: #else gr::filter::fractional_resampler_cc::sptr resampler_; #endif + gr::filter::fir_filter_ccf::sptr fir_filter_ccf_; gr::block_sptr file_sink_; }; diff --git a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt index 70db5015e..33dd7b6ab 100644 --- a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,22 +17,44 @@ # -set(RESAMPLER_GR_BLOCKS_SOURCES - direct_resampler_conditioner_cc.cc - direct_resampler_conditioner_cs.cc - direct_resampler_conditioner_cb.cc +set(RESAMPLER_GR_BLOCKS_SOURCES + direct_resampler_conditioner_cc.cc + direct_resampler_conditioner_cs.cc + direct_resampler_conditioner_cb.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} +set(RESAMPLER_GR_BLOCKS_HEADERS + direct_resampler_conditioner_cc.h + direct_resampler_conditioner_cs.h + direct_resampler_conditioner_cb.h ) -file(GLOB RESAMPLER_GR_BLOCKS_HEADERS "*.h") list(SORT RESAMPLER_GR_BLOCKS_HEADERS) -add_library(resampler_gr_blocks ${RESAMPLER_GR_BLOCKS_SOURCES} ${RESAMPLER_GR_BLOCKS_HEADERS}) +list(SORT RESAMPLER_GR_BLOCKS_SOURCES) + source_group(Headers FILES ${RESAMPLER_GR_BLOCKS_HEADERS}) -add_dependencies(resampler_gr_blocks glog-${glog_RELEASE}) \ No newline at end of file + +add_library(resampler_gr_blocks + ${RESAMPLER_GR_BLOCKS_SOURCES} + ${RESAMPLER_GR_BLOCKS_HEADERS} +) + +target_link_libraries(resampler_gr_blocks + PUBLIC + Gnuradio::runtime + Volk::volk +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(resampler_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET resampler_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc index e5926468b..99948c3bb 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc @@ -34,11 +34,8 @@ #include "direct_resampler_conditioner_cb.h" #include -#include -using google::LogMessage; - direct_resampler_conditioner_cb_sptr direct_resampler_make_conditioner_cb( double sample_freq_in, double sample_freq_out) { @@ -55,8 +52,7 @@ direct_resampler_conditioner_cb::direct_resampler_conditioner_cb( d_sample_freq_out( sample_freq_out), d_phase(0), - d_lphase(0), - d_history(1) + d_lphase(0) { const double two_32 = 4294967296.0; // Computes the phase step multiplying the resampling ratio by 2^32 = 4294967296 @@ -74,9 +70,7 @@ direct_resampler_conditioner_cb::direct_resampler_conditioner_cb( } -direct_resampler_conditioner_cb::~direct_resampler_conditioner_cb() -{ -} +direct_resampler_conditioner_cb::~direct_resampler_conditioner_cb() = default; void direct_resampler_conditioner_cb::forecast(int noutput_items, @@ -96,8 +90,8 @@ int direct_resampler_conditioner_cb::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const lv_8sc_t *in = reinterpret_cast(input_items[0]); - lv_8sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); int lcv = 0; int count = 0; diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.h b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.h index c6f77232c..ac93ab82b 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.h +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.h @@ -36,8 +36,7 @@ #include class direct_resampler_conditioner_cb; -typedef boost::shared_ptr - direct_resampler_conditioner_cb_sptr; +using direct_resampler_conditioner_cb_sptr = boost::shared_ptr; direct_resampler_conditioner_cb_sptr direct_resampler_make_conditioner_cb(double sample_freq_in, @@ -59,7 +58,6 @@ private: uint32_t d_phase; uint32_t d_lphase; uint32_t d_phase_step; - unsigned int d_history; direct_resampler_conditioner_cb(double sample_freq_in, double sample_freq_out); diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc index ca39ff4a1..b302272ca 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc @@ -34,11 +34,8 @@ #include "direct_resampler_conditioner_cc.h" #include -#include -using google::LogMessage; - direct_resampler_conditioner_cc_sptr direct_resampler_make_conditioner_cc( double sample_freq_in, double sample_freq_out) { @@ -54,8 +51,7 @@ direct_resampler_conditioner_cc::direct_resampler_conditioner_cc( d_sample_freq_in(sample_freq_in), d_sample_freq_out(sample_freq_out), d_phase(0), - d_lphase(0), - d_history(1) + d_lphase(0) { // Computes the phase step multiplying the resampling ratio by 2^32 = 4294967296 const double two_32 = 4294967296.0; @@ -72,9 +68,7 @@ direct_resampler_conditioner_cc::direct_resampler_conditioner_cc( } -direct_resampler_conditioner_cc::~direct_resampler_conditioner_cc() -{ -} +direct_resampler_conditioner_cc::~direct_resampler_conditioner_cc() = default; void direct_resampler_conditioner_cc::forecast(int noutput_items, @@ -93,8 +87,8 @@ int direct_resampler_conditioner_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const gr_complex *in = reinterpret_cast(input_items[0]); - gr_complex *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); int lcv = 0; int count = 0; diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.h b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.h index 7548a700c..945f797ce 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.h +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.h @@ -43,7 +43,7 @@ #include class direct_resampler_conditioner_cc; -typedef boost::shared_ptr direct_resampler_conditioner_cc_sptr; +using direct_resampler_conditioner_cc_sptr = boost::shared_ptr; direct_resampler_conditioner_cc_sptr direct_resampler_make_conditioner_cc(double sample_freq_in, double sample_freq_out); @@ -64,7 +64,6 @@ private: uint32_t d_phase; uint32_t d_lphase; uint32_t d_phase_step; - unsigned int d_history; direct_resampler_conditioner_cc(double sample_freq_in, double sample_freq_out); diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc index 6fc2dcf43..6a4b5a8d3 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc @@ -34,9 +34,7 @@ #include "direct_resampler_conditioner_cs.h" #include -#include -using google::LogMessage; direct_resampler_conditioner_cs_sptr direct_resampler_make_conditioner_cs( double sample_freq_in, double sample_freq_out) @@ -49,12 +47,13 @@ direct_resampler_conditioner_cs_sptr direct_resampler_make_conditioner_cs( direct_resampler_conditioner_cs::direct_resampler_conditioner_cs( double sample_freq_in, - double sample_freq_out) : gr::block("direct_resampler_make_conditioner_cs", gr::io_signature::make(1, 1, sizeof(lv_16sc_t)), gr::io_signature::make(1, 1, sizeof(lv_16sc_t))), + double sample_freq_out) : gr::block("direct_resampler_make_conditioner_cs", + gr::io_signature::make(1, 1, sizeof(lv_16sc_t)), + gr::io_signature::make(1, 1, sizeof(lv_16sc_t))), d_sample_freq_in(sample_freq_in), d_sample_freq_out(sample_freq_out), d_phase(0), - d_lphase(0), - d_history(1) + d_lphase(0) { const double two_32 = 4294967296.0; // Computes the phase step multiplying the resampling ratio by 2^32 = 4294967296 @@ -72,9 +71,7 @@ direct_resampler_conditioner_cs::direct_resampler_conditioner_cs( } -direct_resampler_conditioner_cs::~direct_resampler_conditioner_cs() -{ -} +direct_resampler_conditioner_cs::~direct_resampler_conditioner_cs() = default; void direct_resampler_conditioner_cs::forecast(int noutput_items, @@ -94,8 +91,8 @@ int direct_resampler_conditioner_cs::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const lv_16sc_t *in = reinterpret_cast(input_items[0]); - lv_16sc_t *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); int lcv = 0; int count = 0; diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.h b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.h index b57b1b438..9d904abfb 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.h +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.h @@ -36,8 +36,7 @@ #include class direct_resampler_conditioner_cs; -typedef boost::shared_ptr - direct_resampler_conditioner_cs_sptr; +using direct_resampler_conditioner_cs_sptr = boost::shared_ptr; direct_resampler_conditioner_cs_sptr direct_resampler_make_conditioner_cs(double sample_freq_in, @@ -59,7 +58,6 @@ private: uint32_t d_phase; uint32_t d_lphase; uint32_t d_phase_step; - unsigned int d_history; direct_resampler_conditioner_cs(double sample_freq_in, double sample_freq_out); diff --git a/src/algorithms/signal_generator/adapters/CMakeLists.txt b/src/algorithms/signal_generator/adapters/CMakeLists.txt index 3d141ddb3..fb651871e 100644 --- a/src/algorithms/signal_generator/adapters/CMakeLists.txt +++ b/src/algorithms/signal_generator/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,26 +17,40 @@ # set(SIGNAL_GENERATOR_ADAPTER_SOURCES signal_generator.cc) +set(SIGNAL_GENERATOR_ADAPTER_HEADERS signal_generator.h) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_generator/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} -) - -file(GLOB SIGNAL_GENERATOR_ADAPTER_HEADERS "*.h") -list(SORT SIGNAL_GENERATOR_ADAPTER_HEADERS) -add_library(signal_generator_adapters ${SIGNAL_GENERATOR_ADAPTER_SOURCES} ${SIGNAL_GENERATOR_ADAPTER_HEADERS}) source_group(Headers FILES ${SIGNAL_GENERATOR_ADAPTER_HEADERS}) -target_link_libraries(signal_generator_adapters gnss_sp_libs - signal_generator_blocks - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} + +add_library(signal_generator_adapters + ${SIGNAL_GENERATOR_ADAPTER_SOURCES} + ${SIGNAL_GENERATOR_ADAPTER_HEADERS} +) + +target_link_libraries(signal_generator_adapters + PUBLIC + Gnuradio::blocks + signal_generator_gr_blocks + PRIVATE + Gflags::gflags + Glog::glog + algorithms_libs +) + +target_include_directories(signal_generator_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(signal_generator_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET signal_generator_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ ) diff --git a/src/algorithms/signal_generator/adapters/signal_generator.cc b/src/algorithms/signal_generator/adapters/signal_generator.cc index 781738b4c..8a4d5ab8e 100644 --- a/src/algorithms/signal_generator/adapters/signal_generator.cc +++ b/src/algorithms/signal_generator/adapters/signal_generator.cc @@ -31,19 +31,22 @@ #include "signal_generator.h" -#include "configuration_interface.h" -#include "Galileo_E1.h" -#include "GPS_L1_CA.h" -#include "Galileo_E5a.h" +#include "Beidou_B1I.h" #include "GLONASS_L1_L2_CA.h" +#include "GPS_L1_CA.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "configuration_interface.h" #include +#include +#include using google::LogMessage; SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, - unsigned int out_stream, boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, unsigned int in_stream, + unsigned int out_stream, boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) { std::string default_item_type = "gr_complex"; std::string default_dump_file = "./data/gen_source.dat"; @@ -87,11 +90,11 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, { if (signal1[0].at(0) == '5') { - vector_length = round(static_cast(fs_in) / (Galileo_E5a_CODE_CHIP_RATE_HZ / Galileo_E5a_CODE_LENGTH_CHIPS)); + vector_length = round(static_cast(fs_in) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS)); } else { - vector_length = round(static_cast(fs_in) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS)) * Galileo_E1_C_SECONDARY_CODE_LENGTH; + vector_length = round(static_cast(fs_in) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)) * GALILEO_E1_C_SECONDARY_CODE_LENGTH; } } else if (std::find(system.begin(), system.end(), "G") != system.end()) @@ -102,15 +105,21 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, { if (signal1[0].at(0) == '1') { - vector_length = round((float)fs_in / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); + vector_length = round(static_cast(fs_in) / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); } else { - vector_length = round((float)fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + vector_length = round(static_cast(fs_in) / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); } } - if (item_type_.compare("gr_complex") == 0) + else if (std::find(system.begin(), system.end(), "B") != system.end()) + { + vector_length = round(static_cast(fs_in) / (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS)); + } + + + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); DLOG(INFO) << "Item size " << item_size_; @@ -126,7 +135,7 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, else { LOG(WARNING) << item_type_ << " unrecognized item type for resampler"; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (dump_) @@ -138,17 +147,23 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, { DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -SignalGenerator::~SignalGenerator() -{ -} +SignalGenerator::~SignalGenerator() = default; void SignalGenerator::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->connect(gen_source_, 0, vector_to_stream_, 0); DLOG(INFO) << "connected gen_source to vector_to_stream"; @@ -164,7 +179,7 @@ void SignalGenerator::connect(gr::top_block_sptr top_block) void SignalGenerator::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { top_block->disconnect(gen_source_, 0, vector_to_stream_, 0); if (dump_) diff --git a/src/algorithms/signal_generator/adapters/signal_generator.h b/src/algorithms/signal_generator/adapters/signal_generator.h index 52a2a0f82..e32c431b8 100644 --- a/src/algorithms/signal_generator/adapters/signal_generator.h +++ b/src/algorithms/signal_generator/adapters/signal_generator.h @@ -36,9 +36,9 @@ #include "gnss_block_interface.h" #include "signal_generator_c.h" #include +#include #include #include -#include #include #include @@ -52,7 +52,7 @@ class SignalGenerator : public GNSSBlockInterface { public: SignalGenerator(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue); virtual ~SignalGenerator(); diff --git a/src/algorithms/signal_generator/gnuradio_blocks/CMakeLists.txt b/src/algorithms/signal_generator/gnuradio_blocks/CMakeLists.txt index 55e2e9bd6..99e7debab 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/signal_generator/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,31 +17,40 @@ # set(SIGNAL_GENERATOR_BLOCK_SOURCES signal_generator_c.cc) +set(SIGNAL_GENERATOR_BLOCK_HEADERS signal_generator_c.h) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} -) - -file(GLOB SIGNAL_GENERATOR_BLOCK_HEADERS "*.h") -list(SORT SIGNAL_GENERATOR_BLOCK_HEADERS) -add_library(signal_generator_blocks ${SIGNAL_GENERATOR_BLOCK_SOURCES} ${SIGNAL_GENERATOR_BLOCK_HEADERS}) source_group(Headers FILES ${SIGNAL_GENERATOR_BLOCK_HEADERS}) -target_link_libraries(signal_generator_blocks gnss_system_parameters gnss_sp_libs - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_FFT_LIBRARIES} - ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} + +add_library(signal_generator_gr_blocks + ${SIGNAL_GENERATOR_BLOCK_SOURCES} + ${SIGNAL_GENERATOR_BLOCK_HEADERS} ) -if(VOLK_GNSSSDR_FOUND) - # add_dependencies(signal_generator_blocks glog-${glog_RELEASE}) -else(VOLK_GNSSSDR_FOUND) - add_dependencies(signal_generator_blocks volk_gnsssdr_module) -endif() \ No newline at end of file +target_link_libraries(signal_generator_gr_blocks + PUBLIC + Boost::boost + Gnuradio::runtime + core_system_parameters + PRIVATE + Volkgnsssdr::volkgnsssdr + algorithms_libs +) + +target_include_directories(signal_generator_gr_blocks + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(signal_generator_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET signal_generator_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc index 824b5d76a..37c3ca36f 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc @@ -29,17 +29,18 @@ */ #include "signal_generator_c.h" -#include "gps_sdr_signal_processing.h" -#include "glonass_l1_signal_processing.h" -#include "galileo_e1_signal_processing.h" -#include "galileo_e5_signal_processing.h" +#include "GLONASS_L1_L2_CA.h" +#include "GPS_L1_CA.h" #include "Galileo_E1.h" #include "Galileo_E5a.h" -#include "GPS_L1_CA.h" -#include "GLONASS_L1_L2_CA.h" +#include "galileo_e1_signal_processing.h" +#include "galileo_e5_signal_processing.h" +#include "glonass_l1_signal_processing.h" +#include "gps_sdr_signal_processing.h" #include #include #include +#include /* @@ -52,7 +53,7 @@ signal_make_generator_c(std::vector signal1, std::vector &delay_chips, const std::vector &delay_sec, bool data_flag, bool noise_flag, unsigned int fs_in, unsigned int vector_length, float BW_BB) { - return gnuradio::get_initial_sptr(new signal_generator_c(signal1, system, PRN, CN0_dB, doppler_Hz, delay_chips, delay_sec, + return gnuradio::get_initial_sptr(new signal_generator_c(std::move(signal1), std::move(system), PRN, CN0_dB, doppler_Hz, delay_chips, delay_sec, data_flag, noise_flag, fs_in, vector_length, BW_BB)); } @@ -63,22 +64,22 @@ signal_make_generator_c(std::vector signal1, std::vector signal1, std::vector system, const std::vector &PRN, - const std::vector &CN0_dB, - const std::vector &doppler_Hz, - const std::vector &delay_chips, - const std::vector &delay_sec, + std::vector CN0_dB, + std::vector doppler_Hz, + std::vector delay_chips, + std::vector delay_sec, bool data_flag, bool noise_flag, unsigned int fs_in, unsigned int vector_length, float BW_BB) : gr::block("signal_gen_cc", gr::io_signature::make(0, 0, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex) * vector_length)), - signal_(signal1), - system_(system), + signal_(std::move(signal1)), + system_(std::move(system)), PRN_(PRN), - CN0_dB_(CN0_dB), - doppler_Hz_(doppler_Hz), - delay_chips_(delay_chips), - delay_sec_(delay_sec), + CN0_dB_(std::move(CN0_dB)), + doppler_Hz_(std::move(doppler_Hz)), + delay_chips_(std::move(delay_chips)), + delay_sec_(std::move(delay_sec)), data_flag_(data_flag), noise_flag_(noise_flag), fs_in_(fs_in), @@ -104,41 +105,41 @@ void signal_generator_c::init() { start_phase_rad_.push_back(0); current_data_bit_int_.push_back(1); - current_data_bits_.push_back(gr_complex(1, 0)); + current_data_bits_.emplace_back(1, 0); ms_counter_.push_back(0); - data_modulation_.push_back((Galileo_E5a_I_SECONDARY_CODE.at(0) == '0' ? 1 : -1)); - pilot_modulation_.push_back((Galileo_E5a_Q_SECONDARY_CODE[PRN_[sat]].at(0) == '0' ? 1 : -1)); + data_modulation_.push_back((GALILEO_E5A_I_SECONDARY_CODE.at(0) == '0' ? 1 : -1)); + pilot_modulation_.push_back((GALILEO_E5A_Q_SECONDARY_CODE[PRN_[sat]].at(0) == '0' ? 1 : -1)); if (system_[sat] == "G") { samples_per_code_.push_back(round(static_cast(fs_in_) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - num_of_codes_per_vector_.push_back(galileo_signal ? 4 * static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH) : 1); + num_of_codes_per_vector_.push_back(galileo_signal ? 4 * static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH) : 1); data_bit_duration_ms_.push_back(1e3 / GPS_CA_TELEMETRY_RATE_BITS_SECOND); } else if (system_[sat] == "R") { samples_per_code_.push_back(round(static_cast(fs_in_) / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS))); - num_of_codes_per_vector_.push_back(galileo_signal ? 4 * static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH) : 1); + num_of_codes_per_vector_.push_back(galileo_signal ? 4 * static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH) : 1); data_bit_duration_ms_.push_back(1e3 / GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND); } else if (system_[sat] == "E") { if (signal_[sat].at(0) == '5') { - int codelen = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); - samples_per_code_.push_back(round(static_cast(fs_in_) / (Galileo_E5a_CODE_CHIP_RATE_HZ / codelen))); + int codelen = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); + samples_per_code_.push_back(round(static_cast(fs_in_) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / codelen))); num_of_codes_per_vector_.push_back(1); - data_bit_duration_ms_.push_back(1e3 / Galileo_E5a_SYMBOL_RATE_BPS); + data_bit_duration_ms_.push_back(1e3 / GALILEO_E5A_SYMBOL_RATE_BPS); } else { - samples_per_code_.push_back(round(static_cast(fs_in_) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + samples_per_code_.push_back(round(static_cast(fs_in_) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - num_of_codes_per_vector_.push_back(static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH)); - data_bit_duration_ms_.push_back(1e3 / Galileo_E1_B_SYMBOL_RATE_BPS); + num_of_codes_per_vector_.push_back(static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH)); + data_bit_duration_ms_.push_back(1e3 / GALILEO_E1_B_SYMBOL_RATE_BPS); } } } @@ -211,7 +212,7 @@ void signal_generator_c::generate_codes() strcpy(signal, "5X"); galileo_e5_a_code_gen_complex_sampled(sampled_code_data_[sat], signal, PRN_[sat], fs_in_, - static_cast(Galileo_E5a_CODE_LENGTH_CHIPS) - delay_chips_[sat]); + static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS) - delay_chips_[sat]); //noise if (noise_flag_) { @@ -229,7 +230,7 @@ void signal_generator_c::generate_codes() strcpy(signal, "1B"); galileo_e1_code_gen_complex_sampled(code, signal, cboc, PRN_[sat], fs_in_, - static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) - delay_chips_[sat]); + static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) - delay_chips_[sat]); // Obtain the desired CN0 assuming that Pn = 1. if (noise_flag_) @@ -253,7 +254,7 @@ void signal_generator_c::generate_codes() strcpy(signal, "1C"); galileo_e1_code_gen_complex_sampled(sampled_code_pilot_[sat], signal, cboc, PRN_[sat], fs_in_, - static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) - delay_chips_[sat], true); + static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) - delay_chips_[sat], true); // Obtain the desired CN0 assuming that Pn = 1. if (noise_flag_) @@ -288,7 +289,7 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)), gr_vector_const_void_star &input_items __attribute__((unused)), gr_vector_void_star &output_items) { - gr_complex *out = reinterpret_cast(output_items[0]); + auto *out = reinterpret_cast(output_items[0]); work_counter_++; @@ -379,7 +380,7 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)), if (signal_[sat].at(0) == '5') { // EACH WORK outputs 1 modulated primary code - int codelen = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); + int codelen = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); unsigned int delay_samples = (delay_chips_[sat] % codelen) * samples_per_code_[sat] / codelen; for (k = 0; k < delay_samples; k++) { @@ -394,10 +395,10 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)), // New random data bit current_data_bit_int_[sat] = (uniform_dist(e1) % 2) == 0 ? 1 : -1; } - data_modulation_[sat] = current_data_bit_int_[sat] * (Galileo_E5a_I_SECONDARY_CODE.at((ms_counter_[sat] + delay_sec_[sat]) % 20) == '0' ? 1 : -1); - pilot_modulation_[sat] = (Galileo_E5a_Q_SECONDARY_CODE[PRN_[sat] - 1].at((ms_counter_[sat] + delay_sec_[sat]) % 100) == '0' ? 1 : -1); + data_modulation_[sat] = current_data_bit_int_[sat] * (GALILEO_E5A_I_SECONDARY_CODE.at((ms_counter_[sat] + delay_sec_[sat]) % 20) == '0' ? 1 : -1); + pilot_modulation_[sat] = (GALILEO_E5A_Q_SECONDARY_CODE[PRN_[sat] - 1].at((ms_counter_[sat] + delay_sec_[sat]) % 100) == '0' ? 1 : -1); - ms_counter_[sat] = ms_counter_[sat] + static_cast(round(1e3 * GALILEO_E5a_CODE_PERIOD)); + ms_counter_[sat] = ms_counter_[sat] + static_cast(round(1e3 * GALILEO_E5A_CODE_PERIOD)); for (k = delay_samples; k < samples_per_code_[sat]; k++) { @@ -409,7 +410,7 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)), } else { - unsigned int delay_samples = (delay_chips_[sat] % static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)) * samples_per_code_[sat] / Galileo_E1_B_CODE_LENGTH_CHIPS; + unsigned int delay_samples = (delay_chips_[sat] % static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * samples_per_code_[sat] / GALILEO_E1_B_CODE_LENGTH_CHIPS; for (i = 0; i < num_of_codes_per_vector_[sat]; i++) { @@ -431,7 +432,7 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)), out_idx++; } - ms_counter_[sat] = (ms_counter_[sat] + static_cast(round(1e3 * Galileo_E1_CODE_PERIOD))) % data_bit_duration_ms_[sat]; + ms_counter_[sat] = (ms_counter_[sat] + static_cast(round(1e3 * GALILEO_E1_CODE_PERIOD))) % data_bit_duration_ms_[sat]; } } } diff --git a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h index ddcc0f1fb..2201a849c 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h @@ -33,11 +33,10 @@ #include "gnss_signal.h" #include -//#include #include +#include #include #include -#include class signal_generator_c; @@ -52,7 +51,7 @@ class signal_generator_c; * * As a convention, the _sptr suffix indicates a boost::shared_ptr */ -typedef boost::shared_ptr signal_generator_c_sptr; +using signal_generator_c_sptr = boost::shared_ptr; /*! * \brief Return a shared_ptr to a new instance of gen_source. @@ -87,8 +86,8 @@ private: unsigned int fs_in, unsigned int vector_length, float BW_BB); signal_generator_c(std::vector signal1, std::vector system, const std::vector &PRN, - const std::vector &CN0_dB, const std::vector &doppler_Hz, - const std::vector &delay_chips, const std::vector &delay_sec, bool data_flag, bool noise_flag, + std::vector CN0_dB, std::vector doppler_Hz, + std::vector delay_chips, std::vector delay_sec, bool data_flag, bool noise_flag, unsigned int fs_in, unsigned int vector_length, float BW_BB); void init(); diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index c2fa1de07..5374a6fbf 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,58 +16,60 @@ # along with GNSS-SDR. If not, see . # -file(GLOB SIGNAL_SOURCE_ADAPTER_HEADERS "*.h") -list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS) # Optional drivers +if(ENABLE_RAW_UDP AND PCAP_FOUND) + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} custom_udp_signal_source.cc) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} custom_udp_signal_source.h) +endif() + + if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) - find_package(iio REQUIRED) - if(NOT IIO_FOUND) - message(STATUS "gnuradio-iio not found, its installation is required.") - message(STATUS "Please build and install the following projects:") - message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") - message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") - message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") - message(FATAL_ERROR "gnuradio-iio is required for building gnss-sdr with this option enabled.") - endif(NOT IIO_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) -endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + if(NOT GRIIO_FOUND) + message(STATUS "gnuradio-iio not found, its installation is required.") + message(STATUS "Please build and install the following projects:") + message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") + message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") + message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") + message(FATAL_ERROR "gnuradio-iio is required for building gnss-sdr with this option enabled.") + endif() +endif() + if(ENABLE_AD9361) - find_package(libiio REQUIRED) - if(NOT LIBIIO_FOUND) - message(STATUS "libiio not found, its installation is required.") - message(STATUS "Please build and install the following projects:") - message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") - message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") - message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") - message(FATAL_ERROR "libiio is required for building gnss-sdr with this option enabled.") - endif(NOT LIBIIO_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${LIBIIO_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${LIBIIO_INCLUDE_DIRS}) -endif(ENABLE_AD9361) + if(NOT LIBIIO_FOUND) + message(STATUS "libiio not found, its installation is required.") + message(STATUS "Please build and install the following projects:") + message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") + message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") + message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") + message(FATAL_ERROR "libiio is required for building gnss-sdr with this option enabled.") + endif() +endif() if(ENABLE_PLUTOSDR) ############################################## # ADALM-PLUTO (Analog Devices Inc.) ############################################## - if(IIO_FOUND) + if(GRIIO_FOUND) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} plutosdr_signal_source.cc) - endif(IIO_FOUND) -endif(ENABLE_PLUTOSDR) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} plutosdr_signal_source.h) + endif() +endif() if(ENABLE_FMCOMMS2) ############################################### # FMCOMMS2 based SDR Hardware ############################################### - if(IIO_FOUND) + if(GRIIO_FOUND) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc) - endif(IIO_FOUND) -endif(ENABLE_FMCOMMS2) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} fmcomms2_signal_source.h) + endif() +endif() + if(ENABLE_AD9361) ############################################### @@ -75,59 +77,43 @@ if(ENABLE_AD9361) ############################################### if(LIBIIO_FOUND) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} ad9361_fpga_signal_source.cc) - endif(LIBIIO_FOUND) -endif(ENABLE_AD9361) - + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} ad9361_fpga_signal_source.h) + endif() +endif() if(ENABLE_GN3S) - ############################################## - # GN3S (USB dongle) - ############################################## - find_package(GrGN3S REQUIRED) - if(NOT GR_GN3S_FOUND) - message(" gr-gn3s not found, install it from https://github.com/gnss-sdr/gr-gn3s ") - message(FATAL_ERROR "gr-gn3s required for building gnss-sdr with this option enabled") - endif(NOT GR_GN3S_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GR_GN3S_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${GR_GN3S_INCLUDE_DIRS}) - set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gn3s_signal_source.cc) -endif(ENABLE_GN3S) + ############################################## + # GN3S (USB dongle) + ############################################## + if(NOT GRGN3S_FOUND) + message(" gr-gn3s not found, install it from https://github.com/gnss-sdr/gr-gn3s ") + message(FATAL_ERROR "gr-gn3s required for building gnss-sdr with this option enabled") + endif() + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gn3s_signal_source.cc) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} gn3s_signal_source.h) +endif() -if(ENABLE_FLEXIBAND) - ############################################## - # TELEORBIT FLEXIBAND FRONTEND ADAPTER - ############################################## - find_package(Teleorbit REQUIRED) - if(NOT TELEORBIT_FOUND) - message(FATAL_ERROR "Teleorbit Flexiband GNU Radio driver required to build gnss-sdr with the optional FLEXIBAND adapter") - endif(NOT TELEORBIT_FOUND) - - # Set up variables - set(FLEXIBAND_DRIVER_INCLUDE_DIRS - ${OPT_DRIVER_INCLUDE_DIRS} - ${TELEORBIT_INCLUDE_DIR}/teleorbit - ) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${TELEORBIT_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${FLEXIBAND_DRIVER_INCLUDE_DIRS}) - set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} flexiband_signal_source.cc) -endif(ENABLE_FLEXIBAND) +if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND) + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} flexiband_signal_source.cc) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} flexiband_signal_source.h) +endif() if(ENABLE_ARRAY) - ############################################## - # DBFCTTC GNSS EXPERIMENTAL ARRAY PROTOTYPE - ############################################## - find_package(GrDbfcttc REQUIRED) - if(NOT GR_DBFCTTC_FOUND) - message(" gr-dbfcttc not found, install it from https://github.com/gnss-sdr/gr-dbfcttc ") - message(FATAL_ERROR "gr-dbfcttc required for building gnss-sdr with this option enabled") - endif(NOT GR_DBFCTTC_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GR_DBFCTTC_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${GR_DBFCTTC_INCLUDE_DIRS}) - set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} raw_array_signal_source.cc) -endif(ENABLE_ARRAY) + ############################################## + # DBFCTTC GNSS EXPERIMENTAL ARRAY PROTOTYPE + ############################################## + if(NOT GRDBFCTTC_FOUND) + message(" gr-dbfcttc not found, install it from https://github.com/gnss-sdr/gr-dbfcttc ") + message(FATAL_ERROR "gr-dbfcttc required for building gnss-sdr with this option enabled") + endif() + set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GR_DBFCTTC_LIBRARIES}) + set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${GR_DBFCTTC_INCLUDE_DIRS}) + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} raw_array_signal_source.cc) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} raw_array_signal_source.h) +endif() if(ENABLE_OSMOSDR) @@ -137,71 +123,145 @@ if(ENABLE_OSMOSDR) if(NOT GROSMOSDR_FOUND) if(ENABLE_PACKAGING) list(REMOVE_ITEM SIGNAL_SOURCE_ADAPTER_HEADERS ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters/osmosdr_signal_source.h) - endif(ENABLE_PACKAGING) - else(NOT GROSMOSDR_FOUND) - # set OSMO include dirs - set(OSMO_DRIVER_INCLUDE_DIRS - ${OPT_DRIVER_INCLUDE_DIRS} - ${GROSMOSDR_INCLUDE_DIR}/osmosdr - ) + endif() + else() set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} osmosdr_signal_source.cc) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GROSMOSDR_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${OSMO_DRIVER_INCLUDE_DIRS}) - endif(NOT GROSMOSDR_FOUND) -endif(ENABLE_OSMOSDR) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} osmosdr_signal_source.h) + endif() +endif() + if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} uhd_signal_source.cc) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${UHD_LIBRARIES} ${GNURADIO_UHD_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${UHD_INCLUDE_DIRS}) -else(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) - list(REMOVE_ITEM SIGNAL_SOURCE_ADAPTER_HEADERS ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters/uhd_signal_source.h) -endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} uhd_signal_source.h) +endif() -set(SIGNAL_SOURCE_ADAPTER_SOURCES file_signal_source.cc - gen_signal_source.cc - nsr_file_signal_source.cc - spir_file_signal_source.cc - spir_gss6450_file_signal_source.cc - rtl_tcp_signal_source.cc - labsat_signal_source.cc - ${OPT_DRIVER_SOURCES} +set(SIGNAL_SOURCE_ADAPTER_SOURCES + file_signal_source.cc + gen_signal_source.cc + nsr_file_signal_source.cc + spir_file_signal_source.cc + spir_gss6450_file_signal_source.cc + rtl_tcp_signal_source.cc + labsat_signal_source.cc + ${OPT_DRIVER_SOURCES} +) + +set(SIGNAL_SOURCE_ADAPTER_HEADERS + file_signal_source.h + gen_signal_source.h + nsr_file_signal_source.h + spir_file_signal_source.h + spir_gss6450_file_signal_source.h + rtl_tcp_signal_source.h + labsat_signal_source.h + ${OPT_DRIVER_HEADERS} ) if(PC_GNURADIO_RUNTIME_VERSION VERSION_GREATER 3.7.3) - set(SIGNAL_SOURCE_ADAPTER_SOURCES ${SIGNAL_SOURCE_ADAPTER_SOURCES} - two_bit_cpx_file_signal_source.cc - two_bit_packed_file_signal_source.cc ) -endif(PC_GNURADIO_RUNTIME_VERSION VERSION_GREATER 3.7.3) + set(SIGNAL_SOURCE_ADAPTER_SOURCES ${SIGNAL_SOURCE_ADAPTER_SOURCES} + two_bit_cpx_file_signal_source.cc + two_bit_packed_file_signal_source.cc) + set(SIGNAL_SOURCE_ADAPTER_HEADERS ${SIGNAL_SOURCE_ADAPTER_HEADERS} + two_bit_cpx_file_signal_source.h + two_bit_packed_file_signal_source.h) +endif() -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${OPT_DRIVER_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/gnuradio_blocks - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} -) +list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS) +list(SORT SIGNAL_SOURCE_ADAPTER_SOURCES) -if(ARCH_64BITS) - add_definitions(-DARCH_64BITS=1) -endif(ARCH_64BITS) - -add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}") - -add_library(signal_source_adapters ${SIGNAL_SOURCE_ADAPTER_SOURCES} ${SIGNAL_SOURCE_ADAPTER_HEADERS}) source_group(Headers FILES ${SIGNAL_SOURCE_ADAPTER_HEADERS}) -target_link_libraries(signal_source_adapters signal_source_gr_blocks - ${Boost_LIBRARIES} - ${GNURADIO_PMT_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${OPT_LIBRARIES} - gnss_sp_libs + +add_library(signal_source_adapters + ${SIGNAL_SOURCE_ADAPTER_SOURCES} + ${SIGNAL_SOURCE_ADAPTER_HEADERS} +) + +target_include_directories(signal_source_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +target_link_libraries(signal_source_adapters + PUBLIC + Boost::boost + Gnuradio::runtime + Gnuradio::blocks + signal_source_gr_blocks + signal_source_libs + PRIVATE + gnss_sdr_flags + core_system_parameters + Gflags::gflags + Glog::glog + Volk::volk +) + +if(ENABLE_RAW_UDP AND PCAP_FOUND) + target_link_libraries(signal_source_adapters + PRIVATE + Pcap::pcap + ) +endif() + +if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) + target_link_libraries(signal_source_adapters + PUBLIC + Gnuradio::uhd + PRIVATE + Uhd::uhd + ) +endif() + +if(ENABLE_OSMOSDR AND GROSMOSDR_FOUND) + target_link_libraries(signal_source_adapters + PUBLIC + Gnuradio::osmosdr + ) +endif() + +if(ENABLE_AD9361 AND LIBIIO_FOUND) + target_link_libraries(signal_source_adapters + PRIVATE + Iio::iio + ) +endif() + +if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND) + target_link_libraries(signal_source_adapters + PRIVATE + Gnuradio::teleorbit + ) +endif() + +if(ENABLE_GN3S AND GRGN3S_FOUND) + target_link_libraries(signal_source_adapters + PRIVATE + Gnuradio::gn3s + ) +endif() + +if(ENABLE_ARRAY AND GRDBFCTTC_FOUND) + target_link_libraries(signal_source_adapters + PRIVATE + Gnuradio::dbfcttc + ) +endif() + +target_compile_definitions(signal_source_adapters + PRIVATE -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(signal_source_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET signal_source_adapters APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ ) diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index 4c95cf547..0a09cc789 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -31,12 +31,14 @@ */ #include "ad9361_fpga_signal_source.h" -#include "configuration_interface.h" -#include "ad9361_manager.h" #include "GPS_L1_CA.h" #include "GPS_L2C.h" +#include "ad9361_manager.h" +#include "configuration_interface.h" #include +#include #include // for cout, endl +#include #ifdef __APPLE__ #include @@ -45,8 +47,8 @@ #endif Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, - boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, unsigned int in_stream, unsigned int out_stream, + boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) { std::string default_item_type = "gr_complex"; std::string default_dump_file = "./data/signal_source.dat"; @@ -105,11 +107,19 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface* configura } // turn switch to A/D position - std::string default_device_name = "/dev/uio13"; + std::string default_device_name = "/dev/uio1"; std::string device_name = configuration->property(role + ".devicename", default_device_name); - int switch_position = configuration->property(role + ".switch_position", 0); - switch_fpga = std::make_shared(device_name); + int32_t switch_position = configuration->property(role + ".switch_position", 0); + switch_fpga = std::make_shared(device_name); switch_fpga->set_switch_position(switch_position); + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } @@ -122,7 +132,14 @@ Ad9361FpgaSignalSource::~Ad9361FpgaSignalSource() if (enable_dds_lo_) { - ad9361_disable_lo_local(); + try + { + ad9361_disable_lo_local(); + } + catch (const std::exception& e) + { + LOG(WARNING) << "Problem closing the Ad9361FpgaSignalSource: " << e.what(); + } } // std::cout<<"* AD9361 Destroying context\n"; @@ -132,12 +149,18 @@ Ad9361FpgaSignalSource::~Ad9361FpgaSignalSource() void Ad9361FpgaSignalSource::connect(gr::top_block_sptr top_block) { + if (top_block) + { /* top_block is not null */ + }; DLOG(INFO) << "AD9361 FPGA source nothing to connect"; } void Ad9361FpgaSignalSource::disconnect(gr::top_block_sptr top_block) { + if (top_block) + { /* top_block is not null */ + }; DLOG(INFO) << "AD9361 FPGA source nothing to disconnect"; } diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h index 5fee04b1a..9277c4c2b 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h @@ -32,10 +32,11 @@ #ifndef GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H_ #define GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H_ -#include "gnss_block_interface.h" #include "fpga_switch.h" +#include "gnss_block_interface.h" #include #include +#include #include class ConfigurationInterface; @@ -44,7 +45,7 @@ class Ad9361FpgaSignalSource : public GNSSBlockInterface { public: Ad9361FpgaSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue); ~Ad9361FpgaSignalSource(); @@ -76,11 +77,11 @@ private: std::string role_; // Front-end settings - std::string uri_; // device direction - unsigned long freq_; // frequency of local oscillator - unsigned long sample_rate_; - unsigned long bandwidth_; - unsigned long buffer_size_; // reception buffer + std::string uri_; // device direction + uint64_t freq_; // frequency of local oscillator + uint64_t sample_rate_; + uint64_t bandwidth_; + uint64_t buffer_size_; // reception buffer bool rx1_en_; bool rx2_en_; bool quadrature_; @@ -96,14 +97,14 @@ private: // DDS configuration for LO generation for external mixer bool enable_dds_lo_; - unsigned long freq_rf_tx_hz_; - unsigned long freq_dds_tx_hz_; + uint64_t freq_rf_tx_hz_; + uint64_t freq_dds_tx_hz_; double scale_dds_dbfs_; double phase_dds_deg_; double tx_attenuation_db_; - unsigned int in_stream_; - unsigned int out_stream_; + uint32_t in_stream_; + uint32_t out_stream_; std::string item_type_; size_t item_size_; @@ -113,7 +114,7 @@ private: boost::shared_ptr queue_; - std::shared_ptr switch_fpga; + std::shared_ptr switch_fpga; }; #endif /*GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H_*/ diff --git a/src/algorithms/signal_source/adapters/custom_udp_signal_source.cc b/src/algorithms/signal_source/adapters/custom_udp_signal_source.cc new file mode 100644 index 000000000..2b4714bca --- /dev/null +++ b/src/algorithms/signal_source/adapters/custom_udp_signal_source.cc @@ -0,0 +1,174 @@ +/*! + * \file udp_signal_source.cc + * + * \brief Receives ip frames containing samples in UDP frame encapsulation + * using a high performance packet capture library (libpcap) + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "custom_udp_signal_source.h" +#include "GPS_L1_CA.h" +#include "configuration_interface.h" +#include +#include +#include +#include + + +using google::LogMessage; + + +CustomUDPSignalSource::CustomUDPSignalSource(ConfigurationInterface* configuration, + const std::string& role, unsigned int in_stream, unsigned int out_stream, + boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) +{ + // DUMP PARAMETERS + std::string empty = ""; + std::string default_dump_file = "./data/signal_source.dat"; + std::string default_item_type = "gr_complex"; + dump_ = configuration->property(role + ".dump", false); + dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); + + // network PARAMETERS + std::string default_capture_device = "eth0"; + std::string default_address = "127.0.0.1"; + int default_port = 1234; + std::string address = configuration->property(role + ".origin_address", default_address); + std::string capture_device = configuration->property(role + ".capture_device", default_capture_device); + int port = configuration->property(role + ".port", default_port); + int payload_bytes = configuration->property(role + ".payload_bytes", 1024); + + RF_channels_ = configuration->property(role + ".RF_channels", 1); + channels_in_udp_ = configuration->property(role + ".channels_in_udp", 1); + IQ_swap_ = configuration->property(role + ".IQ_swap", false); + + std::string default_sample_type = "cbyte"; + std::string sample_type = configuration->property(role + ".sample_type", default_sample_type); + item_type_ = configuration->property(role + ".item_type", default_item_type); + // output item size is always gr_complex + item_size_ = sizeof(gr_complex); + + udp_gnss_rx_source_ = Gr_Complex_Ip_Packet_Source::make(capture_device, + address, + port, + payload_bytes, + channels_in_udp_, + sample_type, + item_size_, + IQ_swap_); + + if (channels_in_udp_ >= RF_channels_) + { + for (int n = 0; n < channels_in_udp_; n++) + { + null_sinks_.push_back(gr::blocks::null_sink::make(sizeof(gr_complex))); + } + } + else + { + std::cout << "Configuration error: RF_channels 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } +} + + +CustomUDPSignalSource::~CustomUDPSignalSource() = default; + + +void CustomUDPSignalSource::connect(gr::top_block_sptr top_block) +{ + // connect null sinks to unused streams + for (int n = 0; n < channels_in_udp_; n++) + { + top_block->connect(udp_gnss_rx_source_, n, null_sinks_.at(n), 0); + } + DLOG(INFO) << "connected udp_source to null_sinks to enable the use of spare channels" << std::endl; + + if (dump_) + { + for (int n = 0; n < channels_in_udp_; n++) + { + top_block->connect(udp_gnss_rx_source_, n, file_sink_.at(n), 0); + DLOG(INFO) << "connected source to file sink"; + } + } +} + + +void CustomUDPSignalSource::disconnect(gr::top_block_sptr top_block) +{ + // disconnect null sinks to unused streams + for (int n = 0; n < channels_in_udp_; n++) + { + top_block->disconnect(udp_gnss_rx_source_, n, null_sinks_.at(n), 0); + } + if (dump_) + { + for (int n = 0; n < channels_in_udp_; n++) + { + top_block->disconnect(udp_gnss_rx_source_, n, file_sink_.at(n), 0); + DLOG(INFO) << "disconnected source to file sink"; + } + } + DLOG(INFO) << "disconnected udp_source" << std::endl; +} + + +gr::basic_block_sptr CustomUDPSignalSource::get_left_block() +{ + LOG(WARNING) << "Left block of a signal source should not be retrieved"; + return gr::block_sptr(); +} + + +gr::basic_block_sptr CustomUDPSignalSource::get_right_block() +{ + return udp_gnss_rx_source_; +} + + +gr::basic_block_sptr CustomUDPSignalSource::get_right_block(__attribute__((unused)) int RF_channel) +{ + return udp_gnss_rx_source_; +} diff --git a/src/algorithms/signal_source/adapters/custom_udp_signal_source.h b/src/algorithms/signal_source/adapters/custom_udp_signal_source.h new file mode 100644 index 000000000..18cc21c9e --- /dev/null +++ b/src/algorithms/signal_source/adapters/custom_udp_signal_source.h @@ -0,0 +1,105 @@ +/*! + * \file udp_signal_source.h + * + * \brief Receives ip frames containing samples in UDP frame encapsulation + * using a high performance packet capture library (libpcap) + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_CUSTOM_UDP_SIGNAL_SOURCE_H +#define GNSS_SDR_CUSTOM_UDP_SIGNAL_SOURCE_H + +#include "gnss_block_interface.h" +#include "gr_complex_ip_packet_source.h" +#include +#include +#include +#include +#include +#include +#include + + +class ConfigurationInterface; + +/*! + * \brief This class reads from UDP packets, which streams interleaved + * I/Q samples over a network. + */ +class CustomUDPSignalSource : public GNSSBlockInterface +{ +public: + CustomUDPSignalSource(ConfigurationInterface* configuration, + const std::string& role, unsigned int in_stream, + unsigned int out_stream, boost::shared_ptr queue); + + virtual ~CustomUDPSignalSource(); + + inline std::string role() override + { + return role_; + } + + /*! + * \brief Returns "UDP_Signal_Source" + */ + inline std::string implementation() override + { + return "Custom_UDP_Signal_Source"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + gr::basic_block_sptr get_right_block(int RF_channel) override; + +private: + std::string role_; + + bool IQ_swap_; + int RF_channels_; + int channels_in_udp_; + unsigned int in_stream_; + unsigned int out_stream_; + + std::string item_type_; + size_t item_size_; + bool dump_; + std::string dump_filename_; + std::vector> null_sinks_; + Gr_Complex_Ip_Packet_Source::sptr udp_gnss_rx_source_; + std::vector> file_sink_; + boost::shared_ptr queue_; +}; + +#endif /*GNSS_SDR_CUSTOM_UDP_SIGNAL_SOURCE_H */ diff --git a/src/algorithms/signal_source/adapters/file_signal_source.cc b/src/algorithms/signal_source/adapters/file_signal_source.cc index 188d5ff16..d7856ee57 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/file_signal_source.cc @@ -35,18 +35,19 @@ #include "gnss_sdr_flags.h" #include "gnss_sdr_valve.h" #include -#include // for std::cerr +#include #include #include -#include +#include // for std::cerr +#include using google::LogMessage; FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams, - boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) + const std::string& role, unsigned int in_streams, unsigned int out_streams, + boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(std::move(queue)) { std::string default_filename = "./example_capture.dat"; std::string default_item_type = "short"; @@ -59,8 +60,14 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source; - if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); @@ -70,32 +77,32 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, double seconds_to_skip = configuration->property(role + ".seconds_to_skip", default_seconds_to_skip); header_size = configuration->property(role + ".header_size", 0); - long samples_to_skip = 0; + int64_t samples_to_skip = 0; bool is_complex = false; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); } - else if (item_type_.compare("float") == 0) + else if (item_type_ == "float") { item_size_ = sizeof(float); } - else if (item_type_.compare("short") == 0) + else if (item_type_ == "short") { item_size_ = sizeof(int16_t); } - else if (item_type_.compare("ishort") == 0) + else if (item_type_ == "ishort") { item_size_ = sizeof(int16_t); is_complex = true; } - else if (item_type_.compare("byte") == 0) + else if (item_type_ == "byte") { item_size_ = sizeof(int8_t); } - else if (item_type_.compare("ibyte") == 0) + else if (item_type_ == "ibyte") { item_size_ = sizeof(int8_t); is_complex = true; @@ -112,7 +119,7 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, if (seconds_to_skip > 0) { - samples_to_skip = static_cast(seconds_to_skip * sampling_frequency_); + samples_to_skip = static_cast(seconds_to_skip * sampling_frequency_); if (is_complex) { @@ -135,7 +142,7 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, } catch (const std::exception& e) { - if (filename_.compare(default_filename) == 0) + if (filename_ == default_filename) { std::cerr << "The configuration file has not been found." @@ -200,8 +207,8 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, if (size > 0) { - long bytes_to_skip = samples_to_skip * item_size_; - long bytes_to_process = static_cast(size) - bytes_to_skip; + int64_t bytes_to_skip = samples_to_skip * item_size_; + int64_t bytes_to_process = static_cast(size) - bytes_to_skip; samples_ = floor(static_cast(bytes_to_process) / static_cast(item_size()) - ceil(0.002 * static_cast(sampling_frequency_))); //process all the samples available in the file excluding at least the last 1 ms } } @@ -240,12 +247,18 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, DLOG(INFO) << "Repeat " << repeat_; DLOG(INFO) << "Dump " << dump_; DLOG(INFO) << "Dump filename " << dump_filename_; + if (in_streams_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -FileSignalSource::~FileSignalSource() -{ -} +FileSignalSource::~FileSignalSource() = default; void FileSignalSource::connect(gr::top_block_sptr top_block) @@ -363,15 +376,9 @@ gr::basic_block_sptr FileSignalSource::get_right_block() { return valve_; } - else + if (enable_throttle_control_ == true) { - if (enable_throttle_control_ == true) - { - return throttle_; - } - else - { - return file_source_; - } + return throttle_; } + return file_source_; } diff --git a/src/algorithms/signal_source/adapters/file_signal_source.h b/src/algorithms/signal_source/adapters/file_signal_source.h index 97fda6ddf..bfded2ce8 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.h +++ b/src/algorithms/signal_source/adapters/file_signal_source.h @@ -36,11 +36,12 @@ #define GNSS_SDR_FILE_SIGNAL_SOURCE_H_ #include "gnss_block_interface.h" -#include #include +#include #include #include #include +#include #include class ConfigurationInterface; @@ -52,7 +53,7 @@ class ConfigurationInterface; class FileSignalSource : public GNSSBlockInterface { public: - FileSignalSource(ConfigurationInterface* configuration, std::string role, + FileSignalSource(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, boost::shared_ptr queue); @@ -96,27 +97,27 @@ public: return repeat_; } - inline long sampling_frequency() const + inline int64_t sampling_frequency() const { return sampling_frequency_; } - inline long samples() const + inline uint64_t samples() const { return samples_; } private: - unsigned long long samples_; - long sampling_frequency_; + uint64_t samples_; + int64_t sampling_frequency_; std::string filename_; std::string item_type_; bool repeat_; bool dump_; std::string dump_filename_; std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; + uint32_t in_streams_; + uint32_t out_streams_; gr::blocks::file_source::sptr file_source_; boost::shared_ptr valve_; gr::blocks::file_sink::sptr sink_; diff --git a/src/algorithms/signal_source/adapters/flexiband_signal_source.cc b/src/algorithms/signal_source/adapters/flexiband_signal_source.cc index 83ee0faee..216fa084c 100644 --- a/src/algorithms/signal_source/adapters/flexiband_signal_source.cc +++ b/src/algorithms/signal_source/adapters/flexiband_signal_source.cc @@ -1,6 +1,8 @@ /*! - * \file raw_array_signal_source.cc - * \brief CTTC Experimental GNSS 8 channels array signal source + * \file flexiband_signal_source.cc + * \brief ignal Source adapter for the Teleorbit Flexiband front-end device. + * This adapter requires a Flexiband GNU Radio driver + * installed (not included with GNSS-SDR) * \author Javier Arribas, jarribas(at)cttc.es * * ------------------------------------------------------------------------- @@ -30,16 +32,22 @@ #include "flexiband_signal_source.h" #include "configuration_interface.h" +#include #include #include -#include #include - +#include using google::LogMessage; FlexibandSignalSource::FlexibandSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, + unsigned int in_stream, + unsigned int out_stream, + gr::msg_queue::sptr queue) : role_(role), + in_stream_(in_stream), + out_stream_(out_stream), + queue_(std::move(queue)) { std::string default_item_type = "byte"; item_type_ = configuration->property(role + ".item_type", default_item_type); @@ -60,7 +68,7 @@ FlexibandSignalSource::FlexibandSignalSource(ConfigurationInterface* configurati RF_channels_ = configuration->property(role + ".RF_channels", 1); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); flexiband_source_ = gr::teleorbit::frontend::make(firmware_filename_.c_str(), gain1_, gain2_, gain3_, AGC_, usb_packet_buffer_size_, signal_file.c_str(), flag_read_file); @@ -85,12 +93,18 @@ FlexibandSignalSource::FlexibandSignalSource(ConfigurationInterface* configurati LOG(WARNING) << item_type_ << " unrecognized item type for flexiband_source_"; item_size_ = sizeof(gr_complex); } + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -FlexibandSignalSource::~FlexibandSignalSource() -{ -} +FlexibandSignalSource::~FlexibandSignalSource() = default; void FlexibandSignalSource::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/signal_source/adapters/flexiband_signal_source.h b/src/algorithms/signal_source/adapters/flexiband_signal_source.h index dbf7e567e..40030af6c 100644 --- a/src/algorithms/signal_source/adapters/flexiband_signal_source.h +++ b/src/algorithms/signal_source/adapters/flexiband_signal_source.h @@ -1,7 +1,8 @@ /*! - * \file raw_array_signal_source.h - * \brief Signal Source adapter for the Teleorbit Flexiband front-end device. - * This adapter requires a Flexiband GNURadio driver installed (not included with GNSS-SDR) + * \file flexiband_signal_source.h + * \brief ignal Source adapter for the Teleorbit Flexiband front-end device. + * This adapter requires a Flexiband GNU Radio driver + * installed (not included with GNSS-SDR) * \author Javier Arribas, jarribas(at)cttc.es * * ------------------------------------------------------------------------- @@ -30,15 +31,15 @@ */ -#ifndef FLEXIBAND_SIGNAL_SOURCE_H_ -#define FLEXIBAND_SIGNAL_SOURCE_H_ +#ifndef GNSS_SDR_FLEXIBAND_SIGNAL_SOURCE_H_ +#define GNSS_SDR_FLEXIBAND_SIGNAL_SOURCE_H_ #include "gnss_block_interface.h" +#include +#include +#include #include #include -#include -#include -#include #include #include @@ -53,7 +54,7 @@ class FlexibandSignalSource : public GNSSBlockInterface { public: FlexibandSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue); virtual ~FlexibandSignalSource(); @@ -108,4 +109,4 @@ private: boost::shared_ptr queue_; }; -#endif /*FLEXIBAND_SIGNAL_SOURCE_H_*/ +#endif // GNSS_SDR_FLEXIBAND_SIGNAL_SOURCE_H_ diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc index fbbb8a972..8f3f5fa82 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc @@ -1,6 +1,6 @@ /*! - * \filei fmcomms2_signal_source.cc - * \brief signal source for sdr hardware from analog devices based on + * \file fmcomms2_signal_source.cc + * \brief Signal source for SDR hardware from Analog Devices based on * fmcomms2 evaluation board. * \author Rodrigo Muñoz, 2017, rmunozl(at)inacap.cl * @@ -30,20 +30,22 @@ */ #include "fmcomms2_signal_source.h" -#include "configuration_interface.h" -#include "gnss_sdr_valve.h" -#include "ad9361_manager.h" #include "GPS_L1_CA.h" #include "GPS_L2C.h" +#include "ad9361_manager.h" +#include "configuration_interface.h" +#include "gnss_sdr_valve.h" #include +#include #include +#include using google::LogMessage; Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, - boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, unsigned int in_stream, unsigned int out_stream, + boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) { std::string default_item_type = "gr_complex"; std::string default_dump_file = "./data/signal_source.dat"; @@ -70,7 +72,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - //AD9361 Local Oscillator generation for dual band operation + // AD9361 Local Oscillator generation for dual band operation enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false); freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000); freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000); @@ -84,7 +86,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration std::cout << "LO frequency : " << freq_ << " Hz" << std::endl; std::cout << "sample rate: " << sample_rate_ << " Hz" << std::endl; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { if (RF_channels_ == 1) { @@ -104,7 +106,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration rf_port_select_.c_str(), filter_file_.c_str(), filter_auto_); - //configure LO + // configure LO if (enable_dds_lo_ == true) { std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n"; @@ -135,7 +137,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration gain_mode_rx2_.c_str(), rf_gain_rx2_, rf_port_select_.c_str(), filter_file_.c_str(), filter_auto_); - //configure LO + // configure LO if (enable_dds_lo_ == true) { std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n"; @@ -179,7 +181,14 @@ Fmcomms2SignalSource::~Fmcomms2SignalSource() { if (enable_dds_lo_ == true) { - ad9361_disable_lo_remote(uri_); + try + { + ad9361_disable_lo_remote(uri_); + } + catch (const std::exception& e) + { + LOG(WARNING) << "Exception thrown in Fmcomms2SignalSource destructor: " << e.what(); + } } } diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h index 050e50402..820ce1a14 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h @@ -35,9 +35,9 @@ #include "gnss_block_interface.h" #include -#include #include #include +#include #include class ConfigurationInterface; @@ -46,7 +46,7 @@ class Fmcomms2SignalSource : public GNSSBlockInterface { public: Fmcomms2SignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue); virtual ~Fmcomms2SignalSource(); diff --git a/src/algorithms/signal_source/adapters/gen_signal_source.cc b/src/algorithms/signal_source/adapters/gen_signal_source.cc index 1900fdf04..69c1151c1 100644 --- a/src/algorithms/signal_source/adapters/gen_signal_source.cc +++ b/src/algorithms/signal_source/adapters/gen_signal_source.cc @@ -33,10 +33,11 @@ #include "gen_signal_source.h" #include #include +#include #include #include -#include #include +#include using google::LogMessage; @@ -44,8 +45,8 @@ using google::LogMessage; GenSignalSource::GenSignalSource(GNSSBlockInterface *signal_generator, GNSSBlockInterface *filter, std::string role, boost::shared_ptr queue) : signal_generator_(signal_generator), filter_(filter), - role_(role), - queue_(queue) + role_(std::move(role)), + queue_(std::move(queue)) { connected_ = false; } diff --git a/src/algorithms/signal_source/adapters/gn3s_signal_source.cc b/src/algorithms/signal_source/adapters/gn3s_signal_source.cc index 8867fca8a..ebf984c18 100644 --- a/src/algorithms/signal_source/adapters/gn3s_signal_source.cc +++ b/src/algorithms/signal_source/adapters/gn3s_signal_source.cc @@ -30,9 +30,9 @@ #include "gn3s_signal_source.h" #include "configuration_interface.h" +#include #include #include -#include #include diff --git a/src/algorithms/signal_source/adapters/gn3s_signal_source.h b/src/algorithms/signal_source/adapters/gn3s_signal_source.h index 42fd6e581..8fb7637f5 100644 --- a/src/algorithms/signal_source/adapters/gn3s_signal_source.h +++ b/src/algorithms/signal_source/adapters/gn3s_signal_source.h @@ -33,9 +33,9 @@ #define GNSS_SDR_GN3S_SIGNAL_SOURCE_H_ #include "gnss_block_interface.h" +#include #include #include -#include #include diff --git a/src/algorithms/signal_source/adapters/labsat_signal_source.cc b/src/algorithms/signal_source/adapters/labsat_signal_source.cc index 69f7f393e..cf1278d9d 100644 --- a/src/algorithms/signal_source/adapters/labsat_signal_source.cc +++ b/src/algorithms/signal_source/adapters/labsat_signal_source.cc @@ -32,12 +32,14 @@ #include "configuration_interface.h" #include "labsat23_source.h" #include +#include +#include using google::LogMessage; LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) { std::string default_item_type = "gr_complex"; std::string default_dump_file = "./data/source.bin"; @@ -51,7 +53,7 @@ LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration, samples_ = configuration->property(role + ".samples", 0); filename_ = configuration->property(role + ".filename", default_filename); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); labsat23_source_ = labsat23_make_source(filename_.c_str(), channel_selector); @@ -61,7 +63,7 @@ LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration, else { LOG(WARNING) << item_type_ << " unrecognized item type for LabSat source"; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (dump_) { @@ -72,12 +74,18 @@ LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration, { DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -LabsatSignalSource::~LabsatSignalSource() -{ -} +LabsatSignalSource::~LabsatSignalSource() = default; void LabsatSignalSource::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/signal_source/adapters/labsat_signal_source.h b/src/algorithms/signal_source/adapters/labsat_signal_source.h index ef11713e3..bf8f990ef 100644 --- a/src/algorithms/signal_source/adapters/labsat_signal_source.h +++ b/src/algorithms/signal_source/adapters/labsat_signal_source.h @@ -33,9 +33,9 @@ #define GNSS_SDR_LABSAT_SIGNAL_SOURCE_H_ #include "gnss_block_interface.h" +#include #include #include -#include #include class ConfigurationInterface; @@ -47,7 +47,7 @@ class LabsatSignalSource : public GNSSBlockInterface { public: LabsatSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue); virtual ~LabsatSignalSource(); @@ -81,7 +81,7 @@ private: unsigned int out_stream_; std::string item_type_; size_t item_size_; - long samples_; + uint64_t samples_; std::string filename_; bool dump_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc index bcf24343b..2ceeca528 100644 --- a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc @@ -39,14 +39,15 @@ #include #include #include +#include using google::LogMessage; NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams, - boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) + const std::string& role, unsigned int in_streams, unsigned int out_streams, + boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(std::move(queue)) { std::string default_filename = "../data/my_capture.dat"; std::string default_item_type = "byte"; @@ -57,8 +58,14 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration, filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source; - if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); @@ -66,7 +73,7 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration, dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); - if (item_type_.compare("byte") == 0) + if (item_type_ == "byte") { item_size_ = sizeof(char); } @@ -166,12 +173,18 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration, DLOG(INFO) << "Repeat " << repeat_; DLOG(INFO) << "Dump " << dump_; DLOG(INFO) << "Dump filename " << dump_filename_; + if (in_streams_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -NsrFileSignalSource::~NsrFileSignalSource() -{ -} +NsrFileSignalSource::~NsrFileSignalSource() = default; void NsrFileSignalSource::connect(gr::top_block_sptr top_block) @@ -302,15 +315,9 @@ gr::basic_block_sptr NsrFileSignalSource::get_right_block() { return valve_; } - else + if (enable_throttle_control_ == true) { - if (enable_throttle_control_ == true) - { - return throttle_; - } - else - { - return unpack_byte_; - } + return throttle_; } + return unpack_byte_; } diff --git a/src/algorithms/signal_source/adapters/nsr_file_signal_source.h b/src/algorithms/signal_source/adapters/nsr_file_signal_source.h index c1e0f6bb4..a2b3ee547 100644 --- a/src/algorithms/signal_source/adapters/nsr_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/nsr_file_signal_source.h @@ -37,8 +37,8 @@ #include "gnss_block_interface.h" #include "unpack_byte_2bit_samples.h" -#include #include +#include #include #include #include @@ -53,7 +53,7 @@ class ConfigurationInterface; class NsrFileSignalSource : public GNSSBlockInterface { public: - NsrFileSignalSource(ConfigurationInterface* configuration, std::string role, + NsrFileSignalSource(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, boost::shared_ptr queue); @@ -96,27 +96,27 @@ public: return repeat_; } - inline long sampling_frequency() const + inline int64_t sampling_frequency() const { return sampling_frequency_; } - inline long samples() const + inline uint64_t samples() const { return samples_; } private: - unsigned long long samples_; - long sampling_frequency_; + uint64_t samples_; + int64_t sampling_frequency_; std::string filename_; std::string item_type_; bool repeat_; bool dump_; std::string dump_filename_; std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; + uint32_t in_streams_; + uint32_t out_streams_; gr::blocks::file_source::sptr file_source_; unpack_byte_2bit_samples_sptr unpack_byte_; boost::shared_ptr valve_; diff --git a/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc index 57b32fbaa..80f52a290 100644 --- a/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc @@ -30,21 +30,22 @@ */ #include "osmosdr_signal_source.h" +#include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_valve.h" -#include "GPS_L1_CA.h" #include #include #include #include +#include using google::LogMessage; OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, - boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, unsigned int in_stream, unsigned int out_stream, + boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) { // DUMP PARAMETERS std::string empty = ""; @@ -66,11 +67,11 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration, osmosdr_args_ = configuration->property(role + ".osmosdr_args", std::string()); antenna_ = configuration->property(role + ".antenna", empty); - if (item_type_.compare("short") == 0) + if (item_type_ == "short") { - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } - else if (item_type_.compare("gr_complex") == 0) + else if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); // 1. Make the driver instance @@ -130,7 +131,7 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration, else { LOG(WARNING) << item_type_ << " unrecognized item type. Using short."; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (samples_ != 0) @@ -146,12 +147,18 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration, file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -OsmosdrSignalSource::~OsmosdrSignalSource() -{ -} +OsmosdrSignalSource::~OsmosdrSignalSource() = default; void OsmosdrSignalSource::driver_instance() diff --git a/src/algorithms/signal_source/adapters/osmosdr_signal_source.h b/src/algorithms/signal_source/adapters/osmosdr_signal_source.h index ac50d53ca..15f38b2a3 100644 --- a/src/algorithms/signal_source/adapters/osmosdr_signal_source.h +++ b/src/algorithms/signal_source/adapters/osmosdr_signal_source.h @@ -35,8 +35,9 @@ #include "gnss_block_interface.h" #include -#include #include +#include +#include #include #include #include @@ -52,7 +53,7 @@ class OsmosdrSignalSource : public GNSSBlockInterface { public: OsmosdrSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue); virtual ~OsmosdrSignalSource(); @@ -98,7 +99,7 @@ private: std::string item_type_; size_t item_size_; - long samples_; + int64_t samples_; bool dump_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc index f77241ded..5c4c71dd9 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc @@ -29,19 +29,20 @@ */ #include "plutosdr_signal_source.h" +#include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_valve.h" -#include "GPS_L1_CA.h" #include #include +#include using google::LogMessage; PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, - boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, unsigned int in_stream, unsigned int out_stream, + boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) { std::string default_item_type = "gr_complex"; std::string default_dump_file = "./data/signal_source.dat"; @@ -63,7 +64,7 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - if (item_type_.compare("gr_complex") != 0) + if (item_type_ != "gr_complex") { std::cout << "Configuration error: item_type must be gr_complex" << std::endl; LOG(FATAL) << "Configuration error: item_type must be gr_complex!"; @@ -94,12 +95,18 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -PlutosdrSignalSource::~PlutosdrSignalSource() -{ -} +PlutosdrSignalSource::~PlutosdrSignalSource() = default; void PlutosdrSignalSource::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.h b/src/algorithms/signal_source/adapters/plutosdr_signal_source.h index 9b27220a1..4cedb3787 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.h +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.h @@ -34,9 +34,9 @@ #include "gnss_block_interface.h" #include -#include #include #include +#include #include @@ -48,7 +48,7 @@ class PlutosdrSignalSource : public GNSSBlockInterface { public: PlutosdrSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue); virtual ~PlutosdrSignalSource(); diff --git a/src/algorithms/signal_source/adapters/raw_array_signal_source.cc b/src/algorithms/signal_source/adapters/raw_array_signal_source.cc index 04f4c8011..589af32c5 100644 --- a/src/algorithms/signal_source/adapters/raw_array_signal_source.cc +++ b/src/algorithms/signal_source/adapters/raw_array_signal_source.cc @@ -30,10 +30,10 @@ #include "raw_array_signal_source.h" #include "configuration_interface.h" -#include +#include #include #include -#include +#include using google::LogMessage; @@ -66,7 +66,7 @@ RawArraySignalSource::RawArraySignalSource(ConfigurationInterface* configuration int sampling_freq_; sampling_freq_ = configuration->property(role + ".sampling_freq", 5000000); - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); raw_array_source_ = gr::dbfcttc::raw_array::make(eth_device_.c_str(), channels_, snapshots_per_frame_, inter_frame_delay_, sampling_freq_); @@ -97,9 +97,7 @@ RawArraySignalSource::RawArraySignalSource(ConfigurationInterface* configuration } -RawArraySignalSource::~RawArraySignalSource() -{ -} +RawArraySignalSource::~RawArraySignalSource() = default; void RawArraySignalSource::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/signal_source/adapters/raw_array_signal_source.h b/src/algorithms/signal_source/adapters/raw_array_signal_source.h index a00be1821..321895cef 100644 --- a/src/algorithms/signal_source/adapters/raw_array_signal_source.h +++ b/src/algorithms/signal_source/adapters/raw_array_signal_source.h @@ -29,13 +29,13 @@ */ -#ifndef RAW_ARRAY_SIGNAL_SOURCE_H_ -#define RAW_ARRAY_SIGNAL_SOURCE_H_ +#ifndef GNSS_SDR_RAW_ARRAY_SIGNAL_SOURCE_H_ +#define GNSS_SDR_RAW_ARRAY_SIGNAL_SOURCE_H_ #include "gnss_block_interface.h" +#include #include #include -#include #include class ConfigurationInterface; @@ -90,4 +90,4 @@ private: boost::shared_ptr queue_; }; -#endif /*RAW_ARRAY_SIGNAL_SOURCE_H_*/ +#endif /*GNSS_SDR_RAW_ARRAY_SIGNAL_SOURCE_H_*/ diff --git a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc index a0f9880fd..fd9fc9751 100644 --- a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc +++ b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc @@ -31,20 +31,27 @@ */ #include "rtl_tcp_signal_source.h" +#include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_valve.h" -#include "GPS_L1_CA.h" #include #include +#include #include +#include using google::LogMessage; RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, - boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, + unsigned int in_stream, + unsigned int out_stream, + boost::shared_ptr queue) : role_(role), + in_stream_(in_stream), + out_stream_(out_stream), + queue_(std::move(queue)) { // DUMP PARAMETERS std::string empty = ""; @@ -57,7 +64,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, // rtl_tcp PARAMETERS std::string default_address = "127.0.0.1"; - short default_port = 1234; + int16_t default_port = 1234; AGC_enabled_ = configuration->property(role + ".AGC_enabled", true); freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ); gain_ = configuration->property(role + ".gain", 40.0); @@ -69,11 +76,11 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, port_ = configuration->property(role + ".port", default_port); flip_iq_ = configuration->property(role + ".flip_iq", false); - if (item_type_.compare("short") == 0) + if (item_type_ == "short") { - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } - else if (item_type_.compare("gr_complex") == 0) + else if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); // 1. Make the gr block @@ -112,10 +119,10 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, else { LOG(WARNING) << item_type_ << " unrecognized item type. Using short."; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } - if (samples_ != 0) + if (samples_ != 0ULL) { DLOG(INFO) << "Send STOP signal after " << samples_ << " samples"; valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_); @@ -128,12 +135,18 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; } + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -RtlTcpSignalSource::~RtlTcpSignalSource() -{ -} +RtlTcpSignalSource::~RtlTcpSignalSource() = default; void RtlTcpSignalSource::MakeBlock() @@ -154,7 +167,7 @@ void RtlTcpSignalSource::MakeBlock() void RtlTcpSignalSource::connect(gr::top_block_sptr top_block) { - if (samples_) + if (samples_ != 0ULL) { top_block->connect(signal_source_, 0, valve_, 0); DLOG(INFO) << "connected rtl tcp source to valve"; @@ -174,7 +187,7 @@ void RtlTcpSignalSource::connect(gr::top_block_sptr top_block) void RtlTcpSignalSource::disconnect(gr::top_block_sptr top_block) { - if (samples_) + if (samples_ != 0ULL) { top_block->disconnect(signal_source_, 0, valve_, 0); if (dump_) @@ -198,12 +211,9 @@ gr::basic_block_sptr RtlTcpSignalSource::get_left_block() gr::basic_block_sptr RtlTcpSignalSource::get_right_block() { - if (samples_ != 0) + if (samples_ != 0ULL) { return valve_; } - else - { - return signal_source_; - } + return signal_source_; } diff --git a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h index a1966c3ad..74f2b02d5 100644 --- a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h +++ b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h @@ -32,13 +32,13 @@ #ifndef GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H #define GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H -#include "rtl_tcp_signal_source_c.h" #include "gnss_block_interface.h" +#include "rtl_tcp_signal_source_c.h" #include -#include -#include #include +#include #include +#include #include #include @@ -54,8 +54,10 @@ class RtlTcpSignalSource : public GNSSBlockInterface { public: RtlTcpSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, - unsigned int out_stream, boost::shared_ptr queue); + const std::string& role, + unsigned int in_stream, + unsigned int out_stream, + boost::shared_ptr queue); virtual ~RtlTcpSignalSource(); @@ -88,7 +90,7 @@ private: // rtl_tcp settings std::string address_; - short port_; + int16_t port_; bool AGC_enabled_; double sample_rate_; bool flip_iq_; @@ -103,7 +105,7 @@ private: std::string item_type_; size_t item_size_; - long samples_; + uint64_t samples_; bool dump_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc index d49ce9aca..58675e527 100644 --- a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc @@ -38,14 +38,15 @@ #include #include #include +#include using google::LogMessage; SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams, - boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) + const std::string& role, unsigned int in_streams, unsigned int out_streams, + boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(std::move(queue)) { std::string default_filename = "../data/my_capture.dat"; std::string default_item_type = "int"; @@ -56,8 +57,14 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source; - if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); @@ -65,7 +72,7 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); - if (item_type_.compare("int") == 0) + if (item_type_ == "int") { item_size_ = sizeof(int); } @@ -165,12 +172,18 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration DLOG(INFO) << "Repeat " << repeat_; DLOG(INFO) << "Dump " << dump_; DLOG(INFO) << "Dump filename " << dump_filename_; + if (in_streams_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -SpirFileSignalSource::~SpirFileSignalSource() -{ -} +SpirFileSignalSource::~SpirFileSignalSource() = default; void SpirFileSignalSource::connect(gr::top_block_sptr top_block) @@ -301,15 +314,9 @@ gr::basic_block_sptr SpirFileSignalSource::get_right_block() { return valve_; } - else + if (enable_throttle_control_ == true) { - if (enable_throttle_control_ == true) - { - return throttle_; - } - else - { - return unpack_intspir_; - } + return throttle_; } + return unpack_intspir_; } diff --git a/src/algorithms/signal_source/adapters/spir_file_signal_source.h b/src/algorithms/signal_source/adapters/spir_file_signal_source.h index 70a7eb659..ad76ce23b 100644 --- a/src/algorithms/signal_source/adapters/spir_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/spir_file_signal_source.h @@ -34,11 +34,12 @@ #include "gnss_block_interface.h" #include "unpack_intspir_1bit_samples.h" -#include #include +#include #include #include #include +#include #include class ConfigurationInterface; @@ -50,7 +51,7 @@ class ConfigurationInterface; class SpirFileSignalSource : public GNSSBlockInterface { public: - SpirFileSignalSource(ConfigurationInterface* configuration, std::string role, + SpirFileSignalSource(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, boost::shared_ptr queue); @@ -93,19 +94,19 @@ public: return repeat_; } - inline long sampling_frequency() const + inline int64_t sampling_frequency() const { return sampling_frequency_; } - inline long samples() const + inline uint64_t samples() const { return samples_; } private: - unsigned long long samples_; - long sampling_frequency_; + uint64_t samples_; + int64_t sampling_frequency_; std::string filename_; std::string item_type_; bool repeat_; diff --git a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc index 24d97369b..5b9534129 100644 --- a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc @@ -36,20 +36,21 @@ #include #include #include +#include using google::LogMessage; SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams, gr::msg_queue::sptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) + const std::string& role, uint32_t in_streams, uint32_t out_streams, gr::msg_queue::sptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(std::move(queue)) { std::string default_filename = "../data/my_capture.dat"; std::string default_dump_filename = "../data/my_capture_dump.dat"; item_type_ = "int"; samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0.0); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); filename_ = configuration->property(role + ".filename", default_filename); repeat_ = configuration->property(role + ".repeat", false); dump_ = configuration->property(role + ".dump", false); @@ -59,8 +60,8 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* adc_bits_ = configuration->property(role + ".adc_bits", 4); n_channels_ = configuration->property(role + ".total_channels", 1); sel_ch_ = configuration->property(role + ".sel_ch", 1); - item_size_ = sizeof(int); - long bytes_seek = configuration->property(role + ".bytes_to_skip", 65536); + item_size_ = sizeof(int32_t); + int64_t bytes_seek = configuration->property(role + ".bytes_to_skip", 65536); double sample_size_byte = static_cast(adc_bits_) / 4.0; if (sel_ch_ > n_channels_) @@ -69,17 +70,22 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* } if (n_channels_ > 1) { - for (unsigned int i = 0; i < (n_channels_ - 1); i++) + for (uint32_t i = 0; i < n_channels_; i++) { - null_sinks_.push_back(gr::blocks::null_sink::make(item_size_)); + null_sinks_.push_back(gr::blocks::null_sink::make(sizeof(gr_complex))); + unpack_spir_vec_.push_back(make_unpack_spir_gss6450_samples(adc_bits_)); + if (endian_swap_) + { + endian_vec_.push_back(gr::blocks::endian_swap::make(item_size_)); + } } - DLOG(INFO) << "NUMBER OF NULL SINKS = " << null_sinks_.size(); } try { file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_); file_source_->seek(bytes_seek / item_size_, SEEK_SET); - unpack_spir_ = make_unpack_spir_gss6450_samples(adc_bits_); + + deint_ = gr::blocks::deinterleave::make(item_size_); } catch (const std::exception& e) @@ -133,8 +139,8 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* if (size > 0) { - samples_ = static_cast(floor(static_cast(static_cast(size) - static_cast(bytes_seek)) / (sample_size_byte * static_cast(n_channels_)))); - samples_ = samples_ - static_cast(ceil(0.002 * sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms + samples_ = static_cast(floor(static_cast(static_cast(size) - static_cast(bytes_seek)) / (sample_size_byte * static_cast(n_channels_)))); + samples_ = samples_ - static_cast(ceil(0.002 * sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms } } @@ -143,22 +149,20 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* LOG(INFO) << "Total number samples to be processed= " << samples_ << " GNSS signal duration= " << signal_duration_s << " [s]"; std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl; - valve_ = gnss_sdr_make_valve(sizeof(gr_complex), samples_, queue_); - DLOG(INFO) << "valve(" << valve_->unique_id() << ")"; + for (uint32_t i = 0; i < (n_channels_); i++) + { + valve_vec_.push_back(gnss_sdr_make_valve(sizeof(gr_complex), samples_, queue_)); + if (dump_) + { + std::string tmp_str = dump_filename_ + "_ch" + std::to_string(i); + sink_vec_.push_back(gr::blocks::file_sink::make(sizeof(gr_complex), tmp_str.c_str())); + } + if (enable_throttle_control_) + { + throttle_vec_.push_back(gr::blocks::throttle::make(sizeof(gr_complex), sampling_frequency_)); + } + } - if (dump_) - { - sink_ = gr::blocks::file_sink::make(sizeof(gr_complex), dump_filename_.c_str()); - DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")"; - } - if (enable_throttle_control_) - { - throttle_ = gr::blocks::throttle::make(sizeof(gr_complex), sampling_frequency_); - } - if (endian_swap_) - { - endian_ = gr::blocks::endian_swap::make(item_size_); - } DLOG(INFO) << "File source filename " << filename_; DLOG(INFO) << "Samples " << samples_; DLOG(INFO) << "Sampling frequency " << sampling_frequency_; @@ -167,12 +171,18 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* DLOG(INFO) << "Repeat " << repeat_; DLOG(INFO) << "Dump " << dump_; DLOG(INFO) << "Dump filename " << dump_filename_; + if (in_streams_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -SpirGSS6450FileSignalSource::~SpirGSS6450FileSignalSource() -{ -} +SpirGSS6450FileSignalSource::~SpirGSS6450FileSignalSource() = default; void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block) @@ -180,39 +190,55 @@ void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block) if (samples_ > 0) { top_block->connect(file_source_, 0, deint_, 0); + if (endian_swap_) { - top_block->connect(deint_, sel_ch_ - 1, endian_, 0); - top_block->connect(endian_, 0, unpack_spir_, 0); + top_block->connect(deint_, sel_ch_ - 1, endian_vec_.at(sel_ch_ - 1), 0); + top_block->connect(endian_vec_.at(sel_ch_ - 1), 0, unpack_spir_vec_.at(sel_ch_ - 1), 0); } else { - top_block->connect(deint_, sel_ch_ - 1, unpack_spir_, 0); + top_block->connect(deint_, sel_ch_ - 1, unpack_spir_vec_.at(sel_ch_ - 1), 0); } + if (n_channels_ > 1) { - unsigned int aux = 0; - for (unsigned int i = 0; i < n_channels_; i++) + uint32_t aux = 0; + for (uint32_t i = 0; i < n_channels_; i++) { if (i != (sel_ch_ - 1)) { - top_block->connect(deint_, i, null_sinks_.at(aux), 0); + if (endian_swap_) + { + top_block->connect(deint_, i, endian_vec_.at(i), 0); + top_block->connect(endian_vec_.at(i), 0, unpack_spir_vec_.at(i), 0); + } + else + { + top_block->connect(deint_, i, unpack_spir_vec_.at(i), 0); + } + aux++; } } } - if (enable_throttle_control_) + for (uint32_t i = 0; i < n_channels_; i++) { - top_block->connect(unpack_spir_, 0, throttle_, 0); - top_block->connect(throttle_, 0, valve_, 0); - } - else - { - top_block->connect(unpack_spir_, 0, valve_, 0); - } - if (dump_) - { - top_block->connect(valve_, 0, sink_, 0); + if (enable_throttle_control_) + { + top_block->connect(unpack_spir_vec_.at(i), 0, throttle_vec_.at(i), 0); + top_block->connect(throttle_vec_.at(i), 0, valve_vec_.at(i), 0); + } + else + { + top_block->connect(unpack_spir_vec_.at(i), 0, valve_vec_.at(i), 0); + } + if (dump_) + { + top_block->connect(valve_vec_.at(i), 0, sink_vec_.at(i), 0); + } + + top_block->connect(valve_vec_.at(i), 0, null_sinks_.at(i), 0); } } else @@ -229,37 +255,52 @@ void SpirGSS6450FileSignalSource::disconnect(gr::top_block_sptr top_block) top_block->disconnect(file_source_, 0, deint_, 0); if (endian_swap_) { - top_block->disconnect(deint_, sel_ch_ - 1, endian_, 0); - top_block->disconnect(endian_, 0, unpack_spir_, 0); + top_block->disconnect(deint_, sel_ch_ - 1, endian_vec_.at(sel_ch_ - 1), 0); + top_block->disconnect(endian_vec_.at(sel_ch_ - 1), 0, unpack_spir_vec_.at(sel_ch_ - 1), 0); } else { - top_block->disconnect(deint_, sel_ch_ - 1, unpack_spir_, 0); + top_block->disconnect(deint_, sel_ch_ - 1, unpack_spir_vec_.at(sel_ch_ - 1), 0); } if (n_channels_ > 1) { - unsigned int aux = 0; - for (unsigned int i = 0; i < n_channels_; i++) + uint32_t aux = 0; + for (uint32_t i = 0; i < n_channels_; i++) { if (i != (sel_ch_ - 1)) { - top_block->disconnect(deint_, i, null_sinks_.at(aux), 0); + if (endian_swap_) + { + top_block->disconnect(deint_, i, endian_vec_.at(i), 0); + top_block->disconnect(endian_vec_.at(i), 0, unpack_spir_vec_.at(i), 0); + } + else + { + top_block->disconnect(deint_, i, unpack_spir_vec_.at(i), 0); + } + aux++; } } } - if (enable_throttle_control_) + + for (uint32_t i = 0; i < (n_channels_); i++) { - top_block->disconnect(unpack_spir_, 0, throttle_, 0); - top_block->disconnect(throttle_, 0, valve_, 0); - } - else - { - top_block->disconnect(unpack_spir_, 0, valve_, 0); - } - if (dump_) - { - top_block->disconnect(valve_, 0, sink_, 0); + if (enable_throttle_control_) + { + top_block->disconnect(unpack_spir_vec_.at(i), 0, throttle_vec_.at(i), 0); + top_block->disconnect(throttle_vec_.at(i), 0, valve_vec_.at(i), 0); + } + else + { + top_block->disconnect(unpack_spir_vec_.at(i), 0, valve_vec_.at(i), 0); + } + if (dump_) + { + top_block->disconnect(valve_vec_.at(i), 0, sink_vec_.at(i), 0); + } + + top_block->disconnect(valve_vec_.at(i), 0, null_sinks_.at(i), 0); } } else @@ -275,22 +316,12 @@ gr::basic_block_sptr SpirGSS6450FileSignalSource::get_left_block() return gr::blocks::file_source::sptr(); } +gr::basic_block_sptr SpirGSS6450FileSignalSource::get_right_block(int RF_channel) +{ + return valve_vec_.at(RF_channel); +} gr::basic_block_sptr SpirGSS6450FileSignalSource::get_right_block() { - if (samples_ > 0) - { - return valve_; - } - else - { - if (enable_throttle_control_) - { - return throttle_; - } - else - { - return unpack_spir_; - } - } + return valve_vec_.at(0); } diff --git a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h index 606bbd313..0757c24af 100644 --- a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h @@ -35,14 +35,15 @@ #include "gnss_block_interface.h" #include "gnss_sdr_valve.h" #include "unpack_spir_gss6450_samples.h" -#include -#include -#include #include -#include #include +#include +#include +#include +#include #include #include +#include #include #include @@ -56,8 +57,8 @@ class ConfigurationInterface; class SpirGSS6450FileSignalSource : public GNSSBlockInterface { public: - SpirGSS6450FileSignalSource(ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams, gr::msg_queue::sptr queue); + SpirGSS6450FileSignalSource(ConfigurationInterface* configuration, const std::string& role, + uint32_t in_streams, uint32_t out_streams, gr::msg_queue::sptr queue); virtual ~SpirGSS6450FileSignalSource(); inline std::string role() override @@ -78,6 +79,7 @@ public: void connect(gr::top_block_sptr top_block) override; void disconnect(gr::top_block_sptr top_block) override; gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block(int RF_channel) override; gr::basic_block_sptr get_right_block() override; inline std::string filename() const @@ -95,19 +97,19 @@ public: return repeat_; } - inline long sampling_frequency() const + inline int64_t sampling_frequency() const { return sampling_frequency_; } - inline long samples() const + inline uint64_t samples() const { return samples_; } private: - unsigned long long samples_; - double sampling_frequency_; + uint64_t samples_; + int64_t sampling_frequency_; std::string filename_; bool repeat_; bool dump_; //Enables dumping the gr_complex sample output @@ -116,19 +118,19 @@ private: std::string dump_filename_; std::string role_; std::string item_type_; - unsigned int in_streams_; - unsigned int out_streams_; - unsigned int adc_bits_; - unsigned int n_channels_; - unsigned int sel_ch_; + uint32_t in_streams_; + uint32_t out_streams_; + uint32_t adc_bits_; + uint32_t n_channels_; + uint32_t sel_ch_; gr::blocks::file_source::sptr file_source_; gr::blocks::deinterleave::sptr deint_; - gr::blocks::endian_swap::sptr endian_; + std::vector endian_vec_; std::vector null_sinks_; - unpack_spir_gss6450_samples_sptr unpack_spir_; - boost::shared_ptr valve_; - gr::blocks::file_sink::sptr sink_; - gr::blocks::throttle::sptr throttle_; + std::vector unpack_spir_vec_; + std::vector> valve_vec_; + std::vector sink_vec_; + std::vector throttle_vec_; gr::msg_queue::sptr queue_; size_t item_size_; }; diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc index d6d10e59e..b1e578b1b 100644 --- a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc @@ -38,14 +38,20 @@ #include #include #include +#include using google::LogMessage; TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams, - boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, + boost::shared_ptr queue) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams), + queue_(std::move(queue)) { std::string default_filename = "../data/my_capture.dat"; std::string default_item_type = "byte"; @@ -56,8 +62,14 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source; - if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); @@ -65,7 +77,7 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); - if (item_type_.compare("byte") == 0) + if (item_type_ == "byte") { item_size_ = sizeof(char); } @@ -166,12 +178,18 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con DLOG(INFO) << "Repeat " << repeat_; DLOG(INFO) << "Dump " << dump_; DLOG(INFO) << "Dump filename " << dump_filename_; + if (in_streams_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -TwoBitCpxFileSignalSource::~TwoBitCpxFileSignalSource() -{ -} +TwoBitCpxFileSignalSource::~TwoBitCpxFileSignalSource() = default; void TwoBitCpxFileSignalSource::connect(gr::top_block_sptr top_block) @@ -306,15 +324,9 @@ gr::basic_block_sptr TwoBitCpxFileSignalSource::get_right_block() { return valve_; } - else + if (enable_throttle_control_ == true) { - if (enable_throttle_control_ == true) - { - return throttle_; - } - else - { - return unpack_byte_; - } + return throttle_; } + return unpack_byte_; } diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h index c0f58687e..a66a87965 100644 --- a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h @@ -36,12 +36,13 @@ #include "gnss_block_interface.h" #include "unpack_byte_2bit_cpx_samples.h" -#include #include +#include +#include #include #include #include -#include +#include #include @@ -54,8 +55,10 @@ class ConfigurationInterface; class TwoBitCpxFileSignalSource : public GNSSBlockInterface { public: - TwoBitCpxFileSignalSource(ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams, + TwoBitCpxFileSignalSource(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue); virtual ~TwoBitCpxFileSignalSource(); @@ -97,19 +100,19 @@ public: return repeat_; } - inline long sampling_frequency() const + inline int64_t sampling_frequency() const { return sampling_frequency_; } - inline long samples() const + inline uint64_t samples() const { return samples_; } private: - unsigned long long samples_; - long sampling_frequency_; + uint64_t samples_; + int64_t sampling_frequency_; std::string filename_; std::string item_type_; bool repeat_; diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index 5dbc6a5a5..00a50257e 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -40,14 +40,20 @@ #include #include #include +#include using google::LogMessage; TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams, - boost::shared_ptr queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, + boost::shared_ptr queue) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams), + queue_(std::move(queue)) { std::string default_filename = "../data/my_capture.dat"; std::string default_item_type = "byte"; @@ -55,13 +61,19 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac std::string default_sample_type = "real"; double default_seconds_to_skip = 0.0; - samples_ = configuration->property(role + ".samples", 0L); + samples_ = configuration->property(role + ".samples", 0); sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source; - if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); big_endian_items_ = configuration->property(role + ".big_endian_items", true); @@ -72,19 +84,19 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); double seconds_to_skip = configuration->property(role + ".seconds_to_skip", default_seconds_to_skip); - long bytes_to_skip = 0; + int64_t bytes_to_skip = 0; - if (item_type_.compare("byte") == 0) + if (item_type_ == "byte") { item_size_ = sizeof(char); } - else if (item_type_.compare("short") == 0) + else if (item_type_ == "short") { // If we have shorts stored in little endian format, might as // well read them in as bytes. if (big_endian_items_) { - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } else { @@ -97,16 +109,16 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac item_size_ = sizeof(char); } - if (sample_type_.compare("real") == 0) + if (sample_type_ == "real") { is_complex_ = false; } - else if (sample_type_.compare("iq") == 0) + else if (sample_type_ == "iq") { is_complex_ = true; reverse_interleaving_ = false; } - else if (sample_type_.compare("qi") == 0) + else if (sample_type_ == "qi") { is_complex_ = true; reverse_interleaving_ = true; @@ -122,7 +134,7 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac if (seconds_to_skip > 0) { - bytes_to_skip = static_cast( + bytes_to_skip = static_cast( seconds_to_skip * sampling_frequency_ / 4); if (is_complex_) { @@ -230,12 +242,18 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac DLOG(INFO) << "Repeat " << repeat_; DLOG(INFO) << "Dump " << dump_; DLOG(INFO) << "Dump filename " << dump_filename_; + if (in_streams_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -TwoBitPackedFileSignalSource::~TwoBitPackedFileSignalSource() -{ -} +TwoBitPackedFileSignalSource::~TwoBitPackedFileSignalSource() = default; void TwoBitPackedFileSignalSource::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h index 2a1db00bc..1e98d737b 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h @@ -37,12 +37,13 @@ #include "gnss_block_interface.h" #include "unpack_2bit_samples.h" -#include #include +#include +#include #include #include #include -#include +#include #include @@ -55,7 +56,7 @@ class ConfigurationInterface; class TwoBitPackedFileSignalSource : public GNSSBlockInterface { public: - TwoBitPackedFileSignalSource(ConfigurationInterface* configuration, std::string role, + TwoBitPackedFileSignalSource(ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, boost::shared_ptr queue); @@ -98,12 +99,12 @@ public: return repeat_; } - inline long sampling_frequency() const + inline int64_t sampling_frequency() const { return sampling_frequency_; } - inline long samples() const + inline uint64_t samples() const { return samples_; } @@ -129,8 +130,8 @@ public: } private: - unsigned long long samples_; - long sampling_frequency_; + uint64_t samples_; + int64_t sampling_frequency_; std::string filename_; std::string item_type_; bool repeat_; diff --git a/src/algorithms/signal_source/adapters/uhd_signal_source.cc b/src/algorithms/signal_source/adapters/uhd_signal_source.cc index f0c9fcb12..1f551fa5d 100644 --- a/src/algorithms/signal_source/adapters/uhd_signal_source.cc +++ b/src/algorithms/signal_source/adapters/uhd_signal_source.cc @@ -29,21 +29,22 @@ */ #include "uhd_signal_source.h" +#include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_valve.h" -#include "GPS_L1_CA.h" #include -#include #include +#include #include #include +#include using google::LogMessage; UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, - boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) + const std::string& role, unsigned int in_stream, unsigned int out_stream, + boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue)) { // DUMP PARAMETERS std::string empty = ""; @@ -57,13 +58,13 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, // available transports on the system (ethernet, usb...). // To narrow down the discovery process to a particular device, // specify a transport key/value pair specific to your device. - if (empty.compare(device_address_) != 0) // if not empty + if (empty != device_address_) // if not empty { dev_addr["addr"] = device_address_; } //filter the device by serial number if required (useful for USB devices) std::string device_serial = configuration->property(role + ".device_serial", empty); - if (empty.compare(device_serial) != 0) // if not empty + if (empty != device_serial) // if not empty { dev_addr["serial"] = device_serial; } @@ -91,14 +92,14 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, for (int i = 0; i < RF_channels_; i++) { // Single RF channel UHD operation (backward compatible config file format) - samples_.push_back(configuration->property(role + ".samples" + boost::lexical_cast(i), 0)); - dump_.push_back(configuration->property(role + ".dump" + boost::lexical_cast(i), false)); - dump_filename_.push_back(configuration->property(role + ".dump_filename" + boost::lexical_cast(i), default_dump_file)); + samples_.push_back(configuration->property(role + ".samples" + std::to_string(i), 0)); + dump_.push_back(configuration->property(role + ".dump" + std::to_string(i), false)); + dump_filename_.push_back(configuration->property(role + ".dump_filename" + std::to_string(i), default_dump_file)); - freq_.push_back(configuration->property(role + ".freq" + boost::lexical_cast(i), GPS_L1_FREQ_HZ)); - gain_.push_back(configuration->property(role + ".gain" + boost::lexical_cast(i), 50.0)); + freq_.push_back(configuration->property(role + ".freq" + std::to_string(i), GPS_L1_FREQ_HZ)); + gain_.push_back(configuration->property(role + ".gain" + std::to_string(i), 50.0)); - IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz" + boost::lexical_cast(i), sample_rate_ / 2)); + IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz" + std::to_string(i), sample_rate_ / 2)); } } // 1. Make the uhd driver instance @@ -111,17 +112,17 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, // fc32: Complex floating point (32-bit floats) range [-1.0, +1.0]. // sc16: Complex signed integer (16-bit integers) range [-32768, +32767]. // sc8: Complex signed integer (8-bit integers) range [-128, 127]. - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { item_size_ = sizeof(lv_8sc_t); uhd_stream_args_ = uhd::stream_args_t("sc8"); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); uhd_stream_args_ = uhd::stream_args_t("sc16"); } - else if (item_type_.compare("gr_complex") == 0) + else if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); uhd_stream_args_ = uhd::stream_args_t("fc32"); @@ -214,7 +215,7 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, for (int i = 0; i < RF_channels_; i++) { - if (samples_.at(i) != 0) + if (samples_.at(i) != 0ULL) { LOG(INFO) << "RF_channel " << i << " Send STOP signal after " << samples_.at(i) << " samples"; valve_.push_back(gnss_sdr_make_valve(item_size_, samples_.at(i), queue_)); @@ -228,19 +229,25 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, DLOG(INFO) << "file_sink(" << file_sink_.at(i)->unique_id() << ")"; } } + if (in_stream_ > 0) + { + LOG(ERROR) << "A signal source does not have an input stream"; + } + if (out_stream_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -UhdSignalSource::~UhdSignalSource() -{ -} +UhdSignalSource::~UhdSignalSource() = default; void UhdSignalSource::connect(gr::top_block_sptr top_block) { for (int i = 0; i < RF_channels_; i++) { - if (samples_.at(i) != 0) + if (samples_.at(i) != 0ULL) { top_block->connect(uhd_source_, i, valve_.at(i), 0); DLOG(INFO) << "connected usrp source to valve RF Channel " << i; @@ -266,7 +273,7 @@ void UhdSignalSource::disconnect(gr::top_block_sptr top_block) { for (int i = 0; i < RF_channels_; i++) { - if (samples_.at(i) != 0) + if (samples_.at(i) != 0ULL) { top_block->disconnect(uhd_source_, i, valve_.at(i), 0); LOG(INFO) << "UHD source disconnected"; @@ -303,12 +310,9 @@ gr::basic_block_sptr UhdSignalSource::get_right_block() gr::basic_block_sptr UhdSignalSource::get_right_block(int RF_channel) { //TODO: There is a incoherence here: Multichannel UHD is a single block with multiple outputs, but if the sample limit is enabled, the output is a multiple block! - if (samples_.at(RF_channel) != 0) + if (samples_.at(RF_channel) != 0ULL) { return valve_.at(RF_channel); } - else - { - return uhd_source_; - } + return uhd_source_; } diff --git a/src/algorithms/signal_source/adapters/uhd_signal_source.h b/src/algorithms/signal_source/adapters/uhd_signal_source.h index bfe13ddb1..50d233c2e 100644 --- a/src/algorithms/signal_source/adapters/uhd_signal_source.h +++ b/src/algorithms/signal_source/adapters/uhd_signal_source.h @@ -33,10 +33,11 @@ #include "gnss_block_interface.h" #include -#include -#include #include +#include #include +#include +#include #include #include @@ -50,7 +51,7 @@ class UhdSignalSource : public GNSSBlockInterface { public: UhdSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, + const std::string& role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue); virtual ~UhdSignalSource(); @@ -99,7 +100,7 @@ private: std::vector freq_; std::vector gain_; std::vector IF_bandwidth_hz_; - std::vector samples_; + std::vector samples_; std::vector dump_; std::vector dump_filename_; diff --git a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt index 7469b6192..4a4a264d2 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,28 +17,82 @@ # +if(ENABLE_RAW_UDP AND PCAP_FOUND) + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gr_complex_ip_packet_source.cc) + set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} gr_complex_ip_packet_source.h) +endif() + + set(SIGNAL_SOURCE_GR_BLOCKS_SOURCES - unpack_byte_2bit_samples.cc - unpack_byte_2bit_cpx_samples.cc - unpack_intspir_1bit_samples.cc - rtl_tcp_signal_source_c.cc - unpack_2bit_samples.cc - unpack_spir_gss6450_samples.cc - labsat23_source.cc + unpack_byte_2bit_samples.cc + unpack_byte_2bit_cpx_samples.cc + unpack_byte_4bit_samples.cc + unpack_intspir_1bit_samples.cc + rtl_tcp_signal_source_c.cc + unpack_2bit_samples.cc + unpack_spir_gss6450_samples.cc + labsat23_source.cc + ${OPT_DRIVER_SOURCES} ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} + +set(SIGNAL_SOURCE_GR_BLOCKS_HEADERS + unpack_byte_2bit_samples.h + unpack_byte_2bit_cpx_samples.h + unpack_byte_4bit_samples.h + unpack_intspir_1bit_samples.h + rtl_tcp_signal_source_c.h + unpack_2bit_samples.h + unpack_spir_gss6450_samples.h + labsat23_source.h + ${OPT_DRIVER_HEADERS} ) -file(GLOB SIGNAL_SOURCE_GR_BLOCKS_HEADERS "*.h") list(SORT SIGNAL_SOURCE_GR_BLOCKS_HEADERS) -add_library(signal_source_gr_blocks ${SIGNAL_SOURCE_GR_BLOCKS_SOURCES} ${SIGNAL_SOURCE_GR_BLOCKS_HEADERS}) +list(SORT SIGNAL_SOURCE_GR_BLOCKS_SOURCES) + source_group(Headers FILES ${SIGNAL_SOURCE_GR_BLOCKS_HEADERS}) -target_link_libraries(signal_source_gr_blocks signal_source_lib ${GNURADIO_RUNTIME_LIBRARIES} ${Boost_LIBRARIES}) -add_dependencies(signal_source_gr_blocks glog-${glog_RELEASE}) + +add_library(signal_source_gr_blocks + ${SIGNAL_SOURCE_GR_BLOCKS_SOURCES} + ${SIGNAL_SOURCE_GR_BLOCKS_HEADERS} +) + +target_link_libraries(signal_source_gr_blocks + PUBLIC + Boost::thread + Gnuradio::runtime + signal_source_libs + PRIVATE + Gflags::gflags + Glog::glog +) + +if(ENABLE_RAW_UDP AND PCAP_FOUND) + target_link_libraries(signal_source_gr_blocks + PUBLIC + Pcap::pcap + ) +endif() + +if(OS_IS_MACOSX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # not AppleClang + target_compile_definitions(signal_source_gr_blocks + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW + ) + endif() +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(signal_source_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET signal_source_gr_blocks APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES $ +) diff --git a/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc new file mode 100644 index 000000000..8085e9e81 --- /dev/null +++ b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc @@ -0,0 +1,448 @@ +/*! + * \file gr_complex_ip_packet_source.cc + * + * \brief Receives ip frames containing samples in UDP frame encapsulation + * using a high performance packet capture library (libpcap) + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "gr_complex_ip_packet_source.h" +#include +#include +#include + +const int FIFO_SIZE = 1472000; + + +/* 4 bytes IP address */ +typedef struct gr_ip_address +{ + u_char byte1; + u_char byte2; + u_char byte3; + u_char byte4; +} gr_ip_address; + + +/* IPv4 header */ +typedef struct gr_ip_header +{ + u_char ver_ihl; // Version (4 bits) + Internet header length (4 bits) + u_char tos; // Type of service + u_short tlen; // Total length + u_short identification; // Identification + u_short flags_fo; // Flags (3 bits) + Fragment offset (13 bits) + u_char ttl; // Time to live + u_char proto; // Protocol + u_short crc; // Header checksum + gr_ip_address saddr; // Source address + gr_ip_address daddr; // Destination address + u_int op_pad; // Option + Padding +} gr_ip_header; + + +/* UDP header*/ +typedef struct gr_udp_header +{ + u_short sport; // Source port + u_short dport; // Destination port + u_short len; // Datagram length + u_short crc; // Checksum +} gr_udp_header; + + +Gr_Complex_Ip_Packet_Source::sptr +Gr_Complex_Ip_Packet_Source::make(std::string src_device, + const std::string &origin_address, + int udp_port, + int udp_packet_size, + int n_baseband_channels, + const std::string &wire_sample_type, + size_t item_size, + bool IQ_swap_) +{ + return gnuradio::get_initial_sptr(new Gr_Complex_Ip_Packet_Source(std::move(src_device), + origin_address, + udp_port, + udp_packet_size, + n_baseband_channels, + wire_sample_type, + item_size, + IQ_swap_)); +} + + +/* + * The private constructor + */ +Gr_Complex_Ip_Packet_Source::Gr_Complex_Ip_Packet_Source(std::string src_device, + __attribute__((unused)) const std::string &origin_address, + int udp_port, + int udp_packet_size, + int n_baseband_channels, + const std::string &wire_sample_type, + size_t item_size, + bool IQ_swap_) + : gr::sync_block("gr_complex_ip_packet_source", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(1, 4, item_size)) // 1 to 4 baseband complex channels +{ + std::cout << "Start Ethernet packet capture\n"; + + d_n_baseband_channels = n_baseband_channels; + if (wire_sample_type == "cbyte") + { + d_wire_sample_type = 1; + d_bytes_per_sample = d_n_baseband_channels * 2; + } + else if (wire_sample_type == "c4bits") + { + d_wire_sample_type = 2; + d_bytes_per_sample = d_n_baseband_channels; + } + else + { + std::cout << "Unknown wire sample type\n"; + exit(0); + } + std::cout << "d_wire_sample_type:" << d_wire_sample_type << std::endl; + d_src_device = std::move(src_device); + d_udp_port = udp_port; + d_udp_payload_size = udp_packet_size; + d_fifo_full = false; + + // allocate signal samples buffer + fifo_buff = new char[FIFO_SIZE]; + fifo_read_ptr = 0; + fifo_write_ptr = 0; + fifo_items = 0; + d_item_size = item_size; + d_IQ_swap = IQ_swap_; + d_sock_raw = 0; + d_pcap_thread = nullptr; + descr = nullptr; + + memset(reinterpret_cast(&si_me), 0, sizeof(si_me)); +} + + +// Called by gnuradio to enable drivers, etc for i/o devices. +bool Gr_Complex_Ip_Packet_Source::start() +{ + std::cout << "gr_complex_ip_packet_source START\n"; + // open the ethernet device + if (open() == true) + { + // start pcap capture thread + d_pcap_thread = new boost::thread(boost::bind(&Gr_Complex_Ip_Packet_Source::my_pcap_loop_thread, this, descr)); + return true; + } + else + { + return false; + } +} + + +// Called by gnuradio to disable drivers, etc for i/o devices. +bool Gr_Complex_Ip_Packet_Source::stop() +{ + std::cout << "gr_complex_ip_packet_source STOP\n"; + if (descr != nullptr) + { + pcap_breakloop(descr); + d_pcap_thread->join(); + pcap_close(descr); + } + return true; +} + + +bool Gr_Complex_Ip_Packet_Source::open() +{ + char errbuf[PCAP_ERRBUF_SIZE]; + boost::mutex::scoped_lock lock(d_mutex); // hold mutex for duration of this function + // open device for reading + descr = pcap_open_live(d_src_device.c_str(), 1500, 1, 1000, errbuf); + if (descr == nullptr) + { + std::cout << "Error opening Ethernet device " << d_src_device << std::endl; + std::cout << "Fatal Error in pcap_open_live(): " << std::string(errbuf) << std::endl; + return false; + } + // bind UDP port to avoid automatic reply with ICMP port unreachable packets from kernel + d_sock_raw = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (d_sock_raw == -1) + { + std::cout << "Error opening UDP socket" << std::endl; + return false; + } + + // zero out the structure + memset(reinterpret_cast(&si_me), 0, sizeof(si_me)); + + si_me.sin_family = AF_INET; + si_me.sin_port = htons(d_udp_port); + si_me.sin_addr.s_addr = htonl(INADDR_ANY); + + // bind socket to port + if (bind(d_sock_raw, reinterpret_cast(&si_me), sizeof(si_me)) == -1) + { + std::cout << "Error opening UDP socket" << std::endl; + return false; + } + return true; +} + + +Gr_Complex_Ip_Packet_Source::~Gr_Complex_Ip_Packet_Source() +{ + if (d_pcap_thread != nullptr) + { + delete d_pcap_thread; + } + delete fifo_buff; + std::cout << "Stop Ethernet packet capture\n"; +} + + +void Gr_Complex_Ip_Packet_Source::static_pcap_callback(u_char *args, const struct pcap_pkthdr *pkthdr, + const u_char *packet) +{ + auto *bridge = reinterpret_cast(args); + bridge->pcap_callback(args, pkthdr, packet); +} + + +void Gr_Complex_Ip_Packet_Source::pcap_callback(__attribute__((unused)) u_char *args, __attribute__((unused)) const struct pcap_pkthdr *pkthdr, + const u_char *packet) +{ + boost::mutex::scoped_lock lock(d_mutex); // hold mutex for duration of this function + + const gr_ip_header *ih; + const gr_udp_header *uh; + + // eth frame parameters + // **** UDP RAW PACKET DECODER **** + if ((packet[12] == 0x08) & (packet[13] == 0x00)) // IP FRAME + { + // retrieve the position of the ip header + ih = reinterpret_cast(packet + 14); // length of ethernet header + + // retrieve the position of the udp header + u_int ip_len; + ip_len = (ih->ver_ihl & 0xf) * 4; + uh = reinterpret_cast(reinterpret_cast(ih) + ip_len); + + // convert from network byte order to host byte order + //u_short sport; + u_short dport; + dport = ntohs(uh->dport); + //sport = ntohs(uh->sport); + if (dport == d_udp_port) + { + // print ip addresses and udp ports + // printf("%d.%d.%d.%d.%d -> %d.%d.%d.%d.%d\n", + // ih->saddr.byte1, + // ih->saddr.byte2, + // ih->saddr.byte3, + // ih->saddr.byte4, + // sport, + // ih->daddr.byte1, + // ih->daddr.byte2, + // ih->daddr.byte3, + // ih->daddr.byte4, + // dport); + // std::cout<<"uh->len:"<len)<len) - 8; // total udp packet length minus the header length + // read the payload bytes and insert them into the shared circular buffer + const u_char *udp_payload = (reinterpret_cast(uh) + sizeof(gr_udp_header)); + if (fifo_items <= (FIFO_SIZE - payload_length_bytes)) + { + int aligned_write_items = FIFO_SIZE - fifo_write_ptr; + if (aligned_write_items >= payload_length_bytes) + { + // write all in a single memcpy + memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], payload_length_bytes); // size in bytes + fifo_write_ptr += payload_length_bytes; + if (fifo_write_ptr == FIFO_SIZE) fifo_write_ptr = 0; + fifo_items += payload_length_bytes; + } + else + { + // two step wrap write + memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], aligned_write_items); // size in bytes + fifo_write_ptr = payload_length_bytes - aligned_write_items; + memcpy(&fifo_buff[0], &udp_payload[aligned_write_items], fifo_write_ptr); // size in bytes + fifo_items += payload_length_bytes; + } + } + else + { + // notify overflow + std::cout << "O" << std::flush; + } + } + } +} + + +void Gr_Complex_Ip_Packet_Source::my_pcap_loop_thread(pcap_t *pcap_handle) +{ + pcap_loop(pcap_handle, -1, Gr_Complex_Ip_Packet_Source::static_pcap_callback, reinterpret_cast(this)); +} + + +void Gr_Complex_Ip_Packet_Source::demux_samples(gr_vector_void_star output_items, int num_samples_readed) +{ + int8_t real; + int8_t imag; + uint8_t tmp_char2; + for (int n = 0; n < num_samples_readed; n++) + { + switch (d_wire_sample_type) + { + case 1: // interleaved byte samples + for (auto &output_item : output_items) + { + real = fifo_buff[fifo_read_ptr++]; + imag = fifo_buff[fifo_read_ptr++]; + if (d_IQ_swap) + { + static_cast(output_item)[n] = gr_complex(real, imag); + } + else + { + static_cast(output_item)[n] = gr_complex(imag, real); + } + } + break; + case 2: // 4-bit samples + for (auto &output_item : output_items) + { + tmp_char2 = fifo_buff[fifo_read_ptr] & 0x0F; + if (tmp_char2 >= 8) + { + real = 2 * (tmp_char2 - 16) + 1; + } + else + { + real = 2 * tmp_char2 + 1; + } + tmp_char2 = fifo_buff[fifo_read_ptr++] >> 4; + tmp_char2 = tmp_char2 & 0x0F; + if (tmp_char2 >= 8) + { + imag = 2 * (tmp_char2 - 16) + 1; + } + else + { + imag = 2 * tmp_char2 + 1; + } + if (d_IQ_swap) + { + static_cast(output_item)[n] = gr_complex(imag, real); + } + else + { + static_cast(output_item)[n] = gr_complex(real, imag); + } + } + break; + default: + std::cout << "Unknown wire sample type\n"; + exit(0); + } + if (fifo_read_ptr == FIFO_SIZE) fifo_read_ptr = 0; + } +} + + +int Gr_Complex_Ip_Packet_Source::work(int noutput_items, + __attribute__((unused)) gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + // send samples to next GNU Radio block + boost::mutex::scoped_lock lock(d_mutex); // hold mutex for duration of this function + if (fifo_items == 0) return 0; + + if (output_items.size() > static_cast(d_n_baseband_channels)) + { + std::cout << "Configuration error: more baseband channels connected than the available in the UDP source\n"; + exit(0); + } + int num_samples_readed; + int bytes_requested; + switch (d_wire_sample_type) + { + case 1: // complex byte samples + bytes_requested = noutput_items * d_bytes_per_sample; + if (bytes_requested < fifo_items) + { + num_samples_readed = noutput_items; // read all + } + else + { + num_samples_readed = fifo_items / d_bytes_per_sample; // read what we have + } + break; + case 2: // complex 4 bits samples + bytes_requested = noutput_items * d_bytes_per_sample; + if (bytes_requested < fifo_items) + { + num_samples_readed = noutput_items; // read all + } + else + { + num_samples_readed = fifo_items / d_bytes_per_sample; // read what we have + } + break; + default: // complex byte samples + bytes_requested = noutput_items * d_bytes_per_sample; + if (bytes_requested < fifo_items) + { + num_samples_readed = noutput_items; // read all + } + else + { + num_samples_readed = fifo_items / d_bytes_per_sample; // read what we have + } + } + + bytes_requested = num_samples_readed * d_bytes_per_sample; + // read all in a single loop + demux_samples(output_items, num_samples_readed); // it also increases the fifo read pointer + // update fifo items + fifo_items = fifo_items - bytes_requested; + + for (uint64_t n = 0; n < output_items.size(); n++) + { + produce(static_cast(n), num_samples_readed); + } + return this->WORK_CALLED_PRODUCE; +} diff --git a/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.h b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.h new file mode 100644 index 000000000..ee915a662 --- /dev/null +++ b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.h @@ -0,0 +1,115 @@ +/*! + * \file gr_complex_ip_packet_source.h + * + * \brief Receives ip frames containing samples in UDP frame encapsulation + * using a high performance packet capture library (libpcap) + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_GR_COMPLEX_IP_PACKET_SOURCE_H +#define GNSS_SDR_GR_COMPLEX_IP_PACKET_SOURCE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Gr_Complex_Ip_Packet_Source : virtual public gr::sync_block +{ +private: + boost::mutex d_mutex; + pcap_t *descr; //ethernet pcap device descriptor + + char *fifo_buff; + + int fifo_read_ptr; + int fifo_write_ptr; + int fifo_items; + int d_sock_raw; + int d_udp_port; + struct sockaddr_in si_me; + std::string d_src_device; + std::string d_origin_address; + int d_udp_payload_size; + bool d_fifo_full; + + int d_n_baseband_channels; + int d_wire_sample_type; + int d_bytes_per_sample; + size_t d_item_size; + bool d_IQ_swap; + + boost::thread *d_pcap_thread; + /*! + * \brief + * Opens the ethernet device using libpcap raw capture mode + * If any of these fail, the fuction retuns the error and exits. + */ + bool open(); + + void demux_samples(gr_vector_void_star output_items, int num_samples_readed); + void my_pcap_loop_thread(pcap_t *pcap_handle); + void pcap_callback(u_char *args, const struct pcap_pkthdr *pkthdr, const u_char *packet); + static void static_pcap_callback(u_char *args, const struct pcap_pkthdr *pkthdr, const u_char *packet); + +public: + typedef boost::shared_ptr sptr; + static sptr make(std::string src_device, + const std::string &origin_address, + int udp_port, + int udp_packet_size, + int n_baseband_channels, + const std::string &wire_sample_type, + size_t item_size, + bool IQ_swap_); + Gr_Complex_Ip_Packet_Source(std::string src_device, + const std::string &origin_address, + int udp_port, + int udp_packet_size, + int n_baseband_channels, + const std::string &wire_sample_type, + size_t item_size, + bool IQ_swap_); + ~Gr_Complex_Ip_Packet_Source(); + + // Where all the action really happens + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + // Called by gnuradio to enable drivers, etc for i/o devices. + bool start(); + // Called by gnuradio to disable drivers, etc for i/o devices. + bool stop(); +}; + +#endif /* GNSS_SDR_GR_COMPLEX_IP_PACKET_SOURCE_H */ diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index 89e535df8..bc636f23c 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -31,6 +31,7 @@ #include "labsat23_source.h" #include +#include #include #include @@ -88,9 +89,20 @@ labsat23_source::labsat23_source(const char *signal_file_basename, labsat23_source::~labsat23_source() { - if (binary_input_file->is_open()) + try { - binary_input_file->close(); + if (binary_input_file->is_open()) + { + binary_input_file->close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing input file" << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } delete binary_input_file; } @@ -172,7 +184,7 @@ int labsat23_source::general_work(int noutput_items, __attribute__((unused)) gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr_complex *out = reinterpret_cast(output_items[0]); + auto *out = reinterpret_cast(output_items[0]); if (d_header_parsed == false) { @@ -186,7 +198,10 @@ int labsat23_source::general_work(int noutput_items, bool preamble_ok = true; for (int i = 0; i < 8; i++) { - if (memblock[byte_counter] != 0x00) preamble_ok = false; + if (memblock[byte_counter] != 0x00) + { + preamble_ok = false; + } //std::cout << "H[" << i << "]:" << (int)memblock[byte_counter] << std::endl; byte_counter++; } @@ -236,8 +251,8 @@ int labsat23_source::general_work(int noutput_items, //std::cout << "Section ID: " << (int)section_id << std::endl; byte_counter += 2; - uint8_t section_lenght_bytes = 0; - section_lenght_bytes += memblock[byte_counter] | (memblock[byte_counter + 1] << 8) | (memblock[byte_counter + 2] << 16) | (memblock[byte_counter + 3] << 24); + //uint8_t section_lenght_bytes = 0; + //section_lenght_bytes += memblock[byte_counter] | (memblock[byte_counter + 1] << 8) | (memblock[byte_counter + 2] << 16) | (memblock[byte_counter + 3] << 24); //std::cout << "section_lenght_bytes=" << (int)section_lenght_bytes << std::endl; byte_counter += 4; @@ -300,7 +315,7 @@ int labsat23_source::general_work(int noutput_items, return -1; } - //check if the selected channel in config file match the file encoding + // check if the selected channel in config file match the file encoding if (d_channel_selector_config == 2 and d_channel_selector != 0) { std::cout << "Labsat source channel config inconsistency: channel 2 is selected but the file has only one channel" << std::endl; @@ -314,7 +329,7 @@ int labsat23_source::general_work(int noutput_items, return -1; } byte_counter++; - uint8_t quantization = static_cast(memblock[byte_counter]); + auto quantization = static_cast(memblock[byte_counter]); switch (quantization) { case 1: @@ -327,7 +342,7 @@ int labsat23_source::general_work(int noutput_items, std::cout << "Unknown quantization ID " << static_cast(quantization) << std::endl; } byte_counter++; - uint8_t channel_a_constellation = static_cast(memblock[byte_counter]); + auto channel_a_constellation = static_cast(memblock[byte_counter]); switch (channel_a_constellation) { case 0: @@ -343,7 +358,7 @@ int labsat23_source::general_work(int noutput_items, std::cout << "Unknown channel A constellation ID " << static_cast(channel_a_constellation) << std::endl; } byte_counter++; - uint8_t channel_b_constellation = static_cast(memblock[byte_counter]); + auto channel_b_constellation = static_cast(memblock[byte_counter]); switch (channel_b_constellation) { case 0: @@ -359,138 +374,128 @@ int labsat23_source::general_work(int noutput_items, std::cout << "Unknown channel B constellation ID " << static_cast(channel_b_constellation) << std::endl; } - //end of header + // end of header d_header_parsed = true; - //seek file to the first signal sample + // seek file to the first signal sample binary_input_file->clear(); binary_input_file->seekg(header_bytes, binary_input_file->beg); return 0; } - else - { - std::cout << "Labsat file header error: section 2 is not available." << std::endl; - return -1; - } - } - else - { - std::cout << "Labsat file read error: file is empty." << std::endl; + std::cout << "Labsat file header error: section 2 is not available." << std::endl; return -1; } + std::cout << "Labsat file read error: file is empty." << std::endl; + return -1; } - else + + + // ready to start reading samples + switch (d_bits_per_sample) { - //ready to start reading samples - switch (d_bits_per_sample) - { - case 2: + case 2: + { + switch (d_channel_selector) { - switch (d_channel_selector) - { - case 0: - // dual channel 2 bits per complex sample - break; - default: - //single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16) - int n_int16_to_read = noutput_items / 8; - if (n_int16_to_read > 0) - { - int16_t memblock[n_int16_to_read]; - binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); - n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 - if (n_int16_to_read > 0) - { - int output_pointer = 0; - for (int i = 0; i < n_int16_to_read; i++) - { - decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); - output_pointer += 8; - } - return output_pointer; - } - else - { - //trigger the read of the next file in the sequence - std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; - - d_current_file_number++; - binary_input_file->close(); - binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); - if (binary_input_file->is_open()) - { - std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; - } - else - { - std::cout << "Last file reached, LabSat source stop" << std::endl; - return -1; - } - } - } - else - { - return 0; - } - }; + case 0: + // dual channel 2 bits per complex sample break; - } - case 4: - { - switch (d_channel_selector) + default: + // single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16) + int n_int16_to_read = noutput_items / 8; + if (n_int16_to_read > 0) { - case 0: - // dual channel - break; - default: - //single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16) - int n_int16_to_read = noutput_items / 4; + int16_t memblock[n_int16_to_read]; + binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); + n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 if (n_int16_to_read > 0) { - int16_t memblock[n_int16_to_read]; - binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); - n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 - if (n_int16_to_read > 0) + int output_pointer = 0; + for (int i = 0; i < n_int16_to_read; i++) { - int output_pointer = 0; - for (int i = 0; i < n_int16_to_read; i++) - { - decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); - output_pointer += 4; - } - return output_pointer; + decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); + output_pointer += 8; } - else - { - //trigger the read of the next file in the sequence - std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; + return output_pointer; + } - d_current_file_number++; - binary_input_file->close(); - binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); - if (binary_input_file->is_open()) - { - std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; - } - else - { - std::cout << "Last file reached, LabSat source stop" << std::endl; - return -1; - } - } + // trigger the read of the next file in the sequence + std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; + + d_current_file_number++; + binary_input_file->close(); + binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); + if (binary_input_file->is_open()) + { + std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; } else { - return 0; + std::cout << "Last file reached, LabSat source stop" << std::endl; + return -1; } } - break; - } - default: + else + { + return 0; + } + }; + break; + } + case 4: + { + switch (d_channel_selector) { - return -1; + case 0: + // dual channel + break; + default: + // single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16) + int n_int16_to_read = noutput_items / 4; + if (n_int16_to_read > 0) + { + int16_t memblock[n_int16_to_read]; + binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); + n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 + if (n_int16_to_read > 0) + { + int output_pointer = 0; + for (int i = 0; i < n_int16_to_read; i++) + { + decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); + output_pointer += 4; + } + return output_pointer; + } + + // trigger the read of the next file in the sequence + std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; + + d_current_file_number++; + binary_input_file->close(); + binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); + if (binary_input_file->is_open()) + { + std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; + } + else + { + std::cout << "Last file reached, LabSat source stop" << std::endl; + return -1; + } + } + else + { + return 0; + } } - } + break; + } + default: + { + return -1; + } } + std::cout << "Warning!!" << std::endl; return 0; } diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.h b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.h index e7776efd9..6f4435c24 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.h +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.h @@ -39,7 +39,7 @@ class labsat23_source; -typedef boost::shared_ptr labsat23_source_sptr; +using labsat23_source_sptr = boost::shared_ptr; labsat23_source_sptr labsat23_make_source(const char *signal_file_basename, int channel_selector); diff --git a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc index c956f4f4c..5450a4377 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc @@ -32,8 +32,8 @@ #include "rtl_tcp_signal_source_c.h" #include "rtl_tcp_commands.h" -#include #include +#include #include using google::LogMessage; @@ -51,7 +51,7 @@ enum rtl_tcp_signal_source_c_sptr rtl_tcp_make_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq) { return gnuradio::get_initial_sptr(new rtl_tcp_signal_source_c(address, @@ -61,7 +61,7 @@ rtl_tcp_make_signal_source_c(const std::string &address, rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq) : gr::sync_block("rtl_tcp_signal_source_c", gr::io_signature::make(0, 0, 0), @@ -152,9 +152,9 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address, } -rtl_tcp_signal_source_c::~rtl_tcp_signal_source_c() +rtl_tcp_signal_source_c::~rtl_tcp_signal_source_c() // NOLINT(modernize-use-equals-default) { - boost::mutex::scoped_lock lock(mutex_); + mutex_.unlock(); io_service_.stop(); not_empty_.notify_one(); not_full_.notify_one(); @@ -205,7 +205,7 @@ void rtl_tcp_signal_source_c::set_agc_mode(bool agc) void rtl_tcp_signal_source_c::set_gain(int gain) { - unsigned clipped = static_cast(info_.clip_gain(gain) * 10.0); + auto clipped = static_cast(info_.clip_gain(gain) * 10.0); boost::system::error_code ec = rtl_tcp_command(RTL_TCP_SET_GAIN, clipped, socket_); if (ec) { @@ -222,7 +222,7 @@ void rtl_tcp_signal_source_c::set_if_gain(int gain) { double start, stop, step; }; - if (info_.get_tuner_type() != rtl_tcp_dongle_info::TUNER_E4000) + if (info_.get_tuner_type() != Rtl_Tcp_Dongle_Info::TUNER_E4000) { return; } @@ -333,7 +333,7 @@ int rtl_tcp_signal_source_c::work(int noutput_items, gr_vector_const_void_star & /*input_items*/, gr_vector_void_star &output_items) { - gr_complex *out = reinterpret_cast(output_items[0]); + auto *out = reinterpret_cast(output_items[0]); int i = 0; if (io_service_.stopped()) { diff --git a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h index 3c8c4529a..2edbf9db0 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h +++ b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h @@ -39,22 +39,22 @@ #define GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H #include "rtl_tcp_dongle_info.h" -#include -#include -#include #include +#include #include +#include +#include #include +#include #include class rtl_tcp_signal_source_c; -typedef boost::shared_ptr - rtl_tcp_signal_source_c_sptr; +using rtl_tcp_signal_source_c_sptr = boost::shared_ptr; rtl_tcp_signal_source_c_sptr rtl_tcp_make_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq = false); /*! @@ -77,18 +77,18 @@ public: void set_if_gain(int gain); private: - typedef boost::circular_buffer_space_optimized buffer_type; + using buffer_type = boost::circular_buffer_space_optimized; friend rtl_tcp_signal_source_c_sptr rtl_tcp_make_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq); rtl_tcp_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq); - rtl_tcp_dongle_info info_; + Rtl_Tcp_Dongle_Info info_; // IO members boost::asio::io_service io_service_; diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc index 994ae5a22..db56ff0b2 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc @@ -62,12 +62,14 @@ bool systemIsBigEndian() bool systemBytesAreBigEndian() { - byte_and_samples b; + byte_and_samples b{}; b.byte = static_cast(0x01); - if (*(char *)&b.byte == 1) - return false; - else - return true; + if (*reinterpret_cast(&b.byte) == 1) + { + return false; + } + + return true; } @@ -131,17 +133,15 @@ unpack_2bit_samples::unpack_2bit_samples(bool big_endian_bytes, } -unpack_2bit_samples::~unpack_2bit_samples() -{ -} +unpack_2bit_samples::~unpack_2bit_samples() = default; int unpack_2bit_samples::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - signed char const *in = reinterpret_cast(input_items[0]); - int8_t *out = reinterpret_cast(output_items[0]); + auto const *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); size_t ninput_bytes = noutput_items / 4; size_t ninput_items = ninput_bytes / item_size_; @@ -160,7 +160,7 @@ int unpack_2bit_samples::work(int noutput_items, // 1) The samples in a byte are in big endian order // 2) The samples in a byte are in little endian order - byte_and_samples raw_byte; + byte_and_samples raw_byte{}; int n = 0; if (!reverse_interleaving_) diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.h index b2148b23b..876a38d1d 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.h +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.h @@ -39,7 +39,7 @@ * * Value_0, Value_1, Value_2, ..., Value_n, Value_n+1, Value_n+2, ... * - * \author Cillian O'Driscoll cillian.odriscoll (at) gmail . com + * \author Cillian O'Driscoll cillian.odriscoll (at) gmail . com * ------------------------------------------------------------------------- * * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) @@ -73,7 +73,7 @@ class unpack_2bit_samples; -typedef boost::shared_ptr unpack_2bit_samples_sptr; +using unpack_2bit_samples_sptr = boost::shared_ptr; unpack_2bit_samples_sptr make_unpack_2bit_samples(bool big_endian_bytes, size_t item_size, @@ -102,7 +102,7 @@ private: std::vector work_buffer_; public: - unpack_2bit_samples(bool big_endianBytes, + unpack_2bit_samples(bool big_endian_bytes, size_t item_size, bool big_endian_items, bool reverse_interleaving); diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc index ae2e2b228..692bc22d7 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc @@ -35,6 +35,7 @@ #include "unpack_byte_2bit_cpx_samples.h" #include +#include struct byte_2bit_struct { @@ -49,26 +50,24 @@ unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples() unpack_byte_2bit_cpx_samples::unpack_byte_2bit_cpx_samples() : sync_interpolator("unpack_byte_2bit_cpx_samples", - gr::io_signature::make(1, 1, sizeof(signed char)), - gr::io_signature::make(1, 1, sizeof(short)), + gr::io_signature::make(1, 1, sizeof(int8_t)), + gr::io_signature::make(1, 1, sizeof(int16_t)), 4) { } -unpack_byte_2bit_cpx_samples::~unpack_byte_2bit_cpx_samples() -{ -} +unpack_byte_2bit_cpx_samples::~unpack_byte_2bit_cpx_samples() = default; int unpack_byte_2bit_cpx_samples::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const signed char *in = reinterpret_cast(input_items[0]); - short *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); - byte_2bit_struct sample; + byte_2bit_struct sample{}; int n = 0; for (int i = 0; i < noutput_items / 4; i++) { @@ -78,34 +77,34 @@ int unpack_byte_2bit_cpx_samples::work(int noutput_items, //* Least Significant Nibble - Sample n+1 //* Packing order in Nibble Q1 Q0 I1 I0 //normal - // signed char c = in[i]; + // int8_t c = in[i]; // //Q[n] // sample.two_bit_sample = (c>>6) & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); // //I[n] // sample.two_bit_sample = (c>>4) & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); // //Q[n+1] // sample.two_bit_sample = (c>>2) & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); // //I[n+1] // sample.two_bit_sample = c & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); //I/Q swap - signed char c = in[i]; + int8_t c = in[i]; //I[n] sample.two_bit_sample = (c >> 4) & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); //Q[n] sample.two_bit_sample = (c >> 6) & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); //I[n+1] sample.two_bit_sample = c & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); //Q[n+1] sample.two_bit_sample = (c >> 2) & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); } return noutput_items; } diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.h index 090568aa7..66ff922df 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.h +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.h @@ -39,7 +39,7 @@ class unpack_byte_2bit_cpx_samples; -typedef boost::shared_ptr unpack_byte_2bit_cpx_samples_sptr; +using unpack_byte_2bit_cpx_samples_sptr = boost::shared_ptr; unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples(); diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc index 9f21299f4..28637016b 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc @@ -52,19 +52,17 @@ unpack_byte_2bit_samples::unpack_byte_2bit_samples() : sync_interpolator("unpack } -unpack_byte_2bit_samples::~unpack_byte_2bit_samples() -{ -} +unpack_byte_2bit_samples::~unpack_byte_2bit_samples() = default; int unpack_byte_2bit_samples::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const signed char *in = reinterpret_cast(input_items[0]); - float *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); - byte_2bit_struct sample; + byte_2bit_struct sample{}; int n = 0; for (int i = 0; i < noutput_items / 4; i++) { diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.h index 90ed74e60..92a115adf 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.h +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.h @@ -35,7 +35,7 @@ class unpack_byte_2bit_samples; -typedef boost::shared_ptr unpack_byte_2bit_samples_sptr; +using unpack_byte_2bit_samples_sptr = boost::shared_ptr; unpack_byte_2bit_samples_sptr make_unpack_byte_2bit_samples(); diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_4bit_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_4bit_samples.cc new file mode 100644 index 000000000..b20ccf21f --- /dev/null +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_4bit_samples.cc @@ -0,0 +1,84 @@ +/*! + * \file unpack_byte_4bit_samples.cc + * + * \brief Unpacks byte samples to 4 bits samples. + * Packing Order + * Packing order in Nibble I0 I1 I2 I3 I0 I1 I2 I3 + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "unpack_byte_4bit_samples.h" +#include + +unpack_byte_4bit_samples_sptr make_unpack_byte_4bit_samples() +{ + return unpack_byte_4bit_samples_sptr(new unpack_byte_4bit_samples()); +} + + +unpack_byte_4bit_samples::unpack_byte_4bit_samples() : sync_interpolator("unpack_byte_4bit_samples", + gr::io_signature::make(1, 1, sizeof(signed char)), + gr::io_signature::make(1, 1, sizeof(signed char)), + 2) +{ +} + + +unpack_byte_4bit_samples::~unpack_byte_4bit_samples() = default; + + +int unpack_byte_4bit_samples::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); + int n = 0; + unsigned char tmp_char2; + for (int i = 0; i < noutput_items / 2; i++) + { + tmp_char2 = in[i] & 0x0F; + if (tmp_char2 >= 8) + { + out[n++] = 2 * (tmp_char2 - 16) + 1; + } + else + { + out[n++] = 2 * tmp_char2 + 1; + } + tmp_char2 = in[i] >> 4; + tmp_char2 = tmp_char2 & 0x0F; + if (tmp_char2 >= 8) + { + out[n++] = 2 * (tmp_char2 - 16) + 1; + } + else + { + out[n++] = 2 * tmp_char2 + 1; + } + } + return noutput_items; +} diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_4bit_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_4bit_samples.h new file mode 100644 index 000000000..8b9ad7454 --- /dev/null +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_4bit_samples.h @@ -0,0 +1,61 @@ +/*! + * \file unpack_byte_4bit_samples.h + * + * \brief Unpacks byte samples to 4 bits samples. + * Packing Order + * Packing order in Nibble I0 I1 I2 I3 I0 I1 I2 I3 + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_UNPACK_BYTE_4BIT_SAMPLES_H +#define GNSS_SDR_UNPACK_BYTE_4BIT_SAMPLES_H + +#include + +class unpack_byte_4bit_samples; + +using unpack_byte_4bit_samples_sptr = boost::shared_ptr; + +unpack_byte_4bit_samples_sptr make_unpack_byte_4bit_samples(); + +/*! + * \brief This class implements conversion between byte packet samples to 4bit_cpx samples + * 1 byte = 1 x complex 4bit I, + 4bit Q samples + */ +class unpack_byte_4bit_samples : public gr::sync_interpolator +{ +private: + friend unpack_byte_4bit_samples_sptr make_unpack_byte_4bit_samples_sptr(); + +public: + unpack_byte_4bit_samples(); + ~unpack_byte_4bit_samples(); + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.cc index 5433047ea..f2a805f17 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.cc @@ -47,17 +47,15 @@ unpack_intspir_1bit_samples::unpack_intspir_1bit_samples() : sync_interpolator(" } -unpack_intspir_1bit_samples::~unpack_intspir_1bit_samples() -{ -} +unpack_intspir_1bit_samples::~unpack_intspir_1bit_samples() = default; int unpack_intspir_1bit_samples::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const signed int *in = reinterpret_cast(input_items[0]); - float *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); int n = 0; int channel = 1; diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.h index 536816f0c..7b8e7d7dc 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.h +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_intspir_1bit_samples.h @@ -35,7 +35,7 @@ class unpack_intspir_1bit_samples; -typedef boost::shared_ptr unpack_intspir_1bit_samples_sptr; +using unpack_intspir_1bit_samples_sptr = boost::shared_ptr; unpack_intspir_1bit_samples_sptr make_unpack_intspir_1bit_samples(); diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc index a9426b41f..02b9e3d30 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc @@ -3,6 +3,7 @@ * * \brief Unpacks SPIR int samples * \author Antonio Ramos, antonio(at)cttc.es + * \author Javier Arribas jarribas (at) cttc.es * ------------------------------------------------------------------------- * * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) @@ -40,64 +41,98 @@ unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int a unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(unsigned int adc_nbit) : gr::sync_interpolator("unpack_spir_gss6450_samples", - gr::io_signature::make(1, 1, sizeof(int)), + gr::io_signature::make(1, 1, sizeof(int32_t)), gr::io_signature::make(1, 1, sizeof(gr_complex)), 16 / adc_nbit) { adc_bits = adc_nbit; samples_per_int = 16 / adc_bits; - i_data.resize(adc_bits, false); - q_data.resize(adc_bits, false); - adc_bits_two_pow = static_cast(std::exp2(adc_bits)); - two_compl_thres = adc_bits_two_pow / 2; } -unpack_spir_gss6450_samples::~unpack_spir_gss6450_samples() +unpack_spir_gss6450_samples::~unpack_spir_gss6450_samples() = default; + + +void unpack_spir_gss6450_samples::decode_4bits_word(uint32_t input_uint32, gr_complex* out, int adc_bits) { -} - - -int unpack_spir_gss6450_samples::compute_two_complement(unsigned long data) -{ - int res = 0; - if (static_cast(data) < two_compl_thres) + int8_t tmp_char; + float Q; + float I; + switch (adc_bits) { - res = static_cast(data); - } - else - { - res = static_cast(data) - adc_bits_two_pow; - } - return res; -} + case 2: + //four bits per complex sample (2 I + 2 Q), 8 samples per int32[s0,s1,s2,s3,s4,s5,s6,s7] + for (int i = 0; i < 8; i++) + { + tmp_char = input_uint32 & 3; + if (tmp_char >= 2) + { + I = (tmp_char - 4); + } + else + { + I = tmp_char; + } + input_uint32 = input_uint32 >> 2; + tmp_char = input_uint32 & 3; + if (tmp_char >= 2) + { + Q = (tmp_char - 4); + } + else + { + Q = tmp_char; + } + input_uint32 = input_uint32 >> 2; + + out[7 - i] = gr_complex(I, Q); + } + break; + case 4: + //eight bits per complex sample (4 I + 4 Q), 4 samples per int32= [s0,s1,s2,s3] + for (int i = 0; i < 4; i++) + { + tmp_char = input_uint32 & 0x0F; + + if (tmp_char >= 8) + { + I = (tmp_char - 16); + } + else + { + I = tmp_char; + } + input_uint32 = input_uint32 >> 4; + tmp_char = input_uint32 & 0x0F; + if (tmp_char >= 8) + { + Q = (tmp_char - 16); + } + else + { + Q = tmp_char; + } + input_uint32 = input_uint32 >> 4; + + out[3 - i] = gr_complex(I, Q); + } + break; + } +} int unpack_spir_gss6450_samples::work(int noutput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) { - const int* in = reinterpret_cast(input_items[0]); - gr_complex* out = reinterpret_cast(output_items[0]); - unsigned int n_sample = 0; - unsigned int in_counter = 0; - std::bitset<32> bs; - for (int i = 0; i < noutput_items; i++) + const auto* in = reinterpret_cast(input_items[0]); + auto* out = reinterpret_cast(output_items[0]); + int n_sample = 0; + int in_counter = 0; + do { - bs = in[in_counter]; - int i_shift = adc_bits * 2 * (samples_per_int - n_sample - 1) + adc_bits; - int q_shift = adc_bits * 2 * (samples_per_int - n_sample - 1); - for (unsigned int k = 0; k < adc_bits; k++) - { - i_data[k] = bs[i_shift + k]; - q_data[k] = bs[q_shift + k]; - } - out[i] = gr_complex(static_cast(compute_two_complement(i_data.to_ulong())) + 0.5, - static_cast(compute_two_complement(q_data.to_ulong())) + 0.5); - n_sample++; - if (n_sample == samples_per_int) - { - n_sample = 0; - in_counter++; - } + decode_4bits_word(in[in_counter++], &out[n_sample], adc_bits); + n_sample += samples_per_int; } + while (n_sample < noutput_items); + return noutput_items; } diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h index a604982f1..dcb0552ca 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h @@ -3,6 +3,7 @@ * * \brief Unpacks SPIR int samples * \author Antonio Ramos, antonio.ramos(at)cttc.es + * \author Javier Arribas jarribas (at) cttc.es * ------------------------------------------------------------------------- * * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) @@ -32,11 +33,10 @@ #define GNSS_SDR_UNPACK_SPIR_GSS6450_SAMPLES_H #include -#include class unpack_spir_gss6450_samples; -typedef boost::shared_ptr unpack_spir_gss6450_samples_sptr; +using unpack_spir_gss6450_samples_sptr = boost::shared_ptr; unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int adc_nbit); @@ -47,18 +47,13 @@ public: int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit); + void decode_4bits_word(uint32_t input_uint32, gr_complex *out, int adc_bits); unpack_spir_gss6450_samples(unsigned int adc_nbit); ~unpack_spir_gss6450_samples(); private: - int compute_two_complement(unsigned long data); - unsigned int adc_bits; unsigned int samples_per_int; - int two_compl_thres; - int adc_bits_two_pow; - boost::dynamic_bitset<> i_data; - boost::dynamic_bitset<> q_data; }; #endif diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index f37684525..f6015ec59 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -17,68 +17,91 @@ # if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) - find_package(iio REQUIRED) - if(NOT IIO_FOUND) - message(STATUS "gnuradio-iio not found, its installation is required.") - message(STATUS "Please build and install the following projects:") - message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") - message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") - message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") - message(FATAL_ERROR "gnuradio-iio is required for building gnss-sdr with this option enabled") - endif(NOT IIO_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) -endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + if(NOT GRIIO_FOUND) + message(STATUS "gnuradio-iio not found, its installation is required.") + message(STATUS "Please build and install the following projects:") + message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") + message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") + message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") + message(FATAL_ERROR "gnuradio-iio is required for building gnss-sdr with this option enabled") + endif() +endif() if(ENABLE_FMCOMMS2 OR ENABLE_AD9361) - find_package(libiio REQUIRED) - if(NOT LIBIIO_FOUND) - message(STATUS "libiio not found, its installation is required.") - message(STATUS "Please build and install the following projects:") - message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") - message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") - message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") - message(FATAL_ERROR "libiio is required for building gnss-sdr with this option enabled") - endif(NOT LIBIIO_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${LIBIIO_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${LIBIIO_INCLUDE_DIRS}) - - ############################################### - # FMCOMMS2 based SDR Hardware - ############################################### - if(LIBIIO_FOUND) - set(OPT_SIGNAL_SOURCE_LIB_SOURCES ad9361_manager.cc) - set(OPT_SIGNAL_SOURCE_LIB_HEADERS ad9361_manager.h) - endif(LIBIIO_FOUND) -endif(ENABLE_FMCOMMS2 OR ENABLE_AD9361) + if(NOT LIBIIO_FOUND) + message(STATUS "libiio not found, its installation is required.") + message(STATUS "Please build and install the following projects:") + message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") + message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") + message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") + message(FATAL_ERROR "libiio is required for building gnss-sdr with this option enabled") + else() + set(OPT_SIGNAL_SOURCE_LIB_SOURCES ad9361_manager.cc) + set(OPT_SIGNAL_SOURCE_LIB_HEADERS ad9361_manager.h) + endif() +endif() if(ENABLE_FPGA OR ENABLE_AD9361) - set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} fpga_switch.cc) - set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_switch.h) -endif(ENABLE_FPGA OR ENABLE_AD9361) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${OPT_DRIVER_INCLUDE_DIRS} - ) + set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} fpga_switch.cc) + set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_switch.h) +endif() set(SIGNAL_SOURCE_LIB_SOURCES - rtl_tcp_commands.cc - rtl_tcp_dongle_info.cc - ${OPT_SIGNAL_SOURCE_LIB_SOURCES} - ) - + rtl_tcp_commands.cc + rtl_tcp_dongle_info.cc + gnss_sdr_valve.cc + ${OPT_SIGNAL_SOURCE_LIB_SOURCES} +) + set(SIGNAL_SOURCE_LIB_HEADERS - rtl_tcp_commands.h - rtl_tcp_dongle_info.h - ${OPT_SIGNAL_SOURCE_LIB_HEADERS} - ) + rtl_tcp_commands.h + rtl_tcp_dongle_info.h + gnss_sdr_valve.h + ${OPT_SIGNAL_SOURCE_LIB_HEADERS} +) list(SORT SIGNAL_SOURCE_LIB_HEADERS) -add_library(signal_source_lib ${SIGNAL_SOURCE_LIB_SOURCES} ${SIGNAL_SOURCE_LIB_HEADERS}) +list(SORT SIGNAL_SOURCE_LIB_SOURCES) + source_group(Headers FILES ${SIGNAL_SOURCE_LIB_HEADERS}) -target_link_libraries(signal_source_lib ${OPT_LIBRARIES}) -add_dependencies(signal_source_lib glog-${glog_RELEASE}) + +add_library(signal_source_libs ${SIGNAL_SOURCE_LIB_SOURCES} ${SIGNAL_SOURCE_LIB_HEADERS}) + +target_link_libraries(signal_source_libs + PUBLIC + Boost::boost + Gnuradio::runtime + PRIVATE + Gflags::gflags + Glog::glog + core_receiver +) + +if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + target_link_libraries(signal_source_libs + PUBLIC + Gnuradio::iio + PRIVATE + Iio::iio + ) +endif() + +if(ENABLE_FMCOMMS2 OR ENABLE_AD9361) + target_link_libraries(signal_source_libs + PUBLIC + Iio::iio + ) +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(signal_source_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET signal_source_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/signal_source/libs/ad9361_manager.cc b/src/algorithms/signal_source/libs/ad9361_manager.cc index d2583a5d5..c1786ec08 100644 --- a/src/algorithms/signal_source/libs/ad9361_manager.cc +++ b/src/algorithms/signal_source/libs/ad9361_manager.cc @@ -46,8 +46,8 @@ void errchk(int v, const char *what) } -/* write attribute: long long int */ -void wr_ch_lli(struct iio_channel *chn, const char *what, long long val) +/* write attribute: int64_t int */ +void wr_ch_lli(struct iio_channel *chn, const char *what, int64_t val) { errchk(iio_channel_attr_write_longlong(chn, what, val), what); } @@ -75,10 +75,10 @@ bool get_ad9361_stream_dev(struct iio_context *ctx, enum iodev d, struct iio_dev { case TX: *dev = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); - return *dev != NULL; + return *dev != nullptr; case RX: *dev = iio_context_find_device(ctx, "cf-ad9361-lpc"); - return *dev != NULL; + return *dev != nullptr; default: return false; } @@ -100,7 +100,7 @@ bool get_ad9361_stream_ch(struct iio_context *ctx __attribute__((unused)), enum name << chid; *chn = iio_device_find_channel(dev, name.str().c_str(), d == TX); } - return *chn != NULL; + return *chn != nullptr; } @@ -115,14 +115,14 @@ bool get_phy_chan(struct iio_context *ctx, enum iodev d, int chid, struct iio_ch name << "voltage"; name << chid; *chn = iio_device_find_channel(get_ad9361_phy(ctx), name.str().c_str(), false); - return *chn != NULL; + return *chn != nullptr; break; case TX: name.str(""); name << "voltage"; name << chid; *chn = iio_device_find_channel(get_ad9361_phy(ctx), name.str().c_str(), true); - return *chn != NULL; + return *chn != nullptr; break; default: return false; @@ -138,10 +138,10 @@ bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn // LO chan is always output, i.e. true case RX: *chn = iio_device_find_channel(get_ad9361_phy(ctx), "altvoltage0", true); - return *chn != NULL; + return *chn != nullptr; case TX: *chn = iio_device_find_channel(get_ad9361_phy(ctx), "altvoltage1", true); - return *chn != NULL; + return *chn != nullptr; default: return false; } @@ -151,7 +151,7 @@ bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn /* applies streaming configuration through IIO */ bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, enum iodev type, int chid) { - struct iio_channel *chn = NULL; + struct iio_channel *chn = nullptr; // Configure phy and lo channels //LOG(INFO)<<"* Acquiring AD9361 phy channel"<(freq_dds_tx_hz_)); if (ret < 0) { std::cout << "Failed to set TX DDS frequency I: " << ret << std::endl; } - ret = iio_channel_attr_write_longlong(dds_channel0_Q, "frequency", (long long)freq_dds_tx_hz_); + ret = iio_channel_attr_write_longlong(dds_channel0_Q, "frequency", static_cast(freq_dds_tx_hz_)); if (ret < 0) { std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl; @@ -543,12 +543,12 @@ bool config_ad9361_lo_local(unsigned long bandwidth_, } -bool config_ad9361_lo_remote(std::string remote_host, - unsigned long bandwidth_, - unsigned long sample_rate_, - unsigned long freq_rf_tx_hz_, +bool config_ad9361_lo_remote(const std::string &remote_host, + uint64_t bandwidth_, + uint64_t sample_rate_, + uint64_t freq_rf_tx_hz_, double tx_attenuation_db_, - long long freq_dds_tx_hz_, + int64_t freq_dds_tx_hz_, double scale_dds_dbfs_) { // TX stream config @@ -613,13 +613,13 @@ bool config_ad9361_lo_remote(std::string remote_host, //set frequency, scale and phase - ret = iio_channel_attr_write_longlong(dds_channel0_I, "frequency", (long long)freq_dds_tx_hz_); + ret = iio_channel_attr_write_longlong(dds_channel0_I, "frequency", static_cast(freq_dds_tx_hz_)); if (ret < 0) { std::cout << "Failed to set TX DDS frequency I: " << ret << std::endl; } - ret = iio_channel_attr_write_longlong(dds_channel0_Q, "frequency", (long long)freq_dds_tx_hz_); + ret = iio_channel_attr_write_longlong(dds_channel0_Q, "frequency", static_cast(freq_dds_tx_hz_)); if (ret < 0) { std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl; @@ -680,7 +680,7 @@ bool config_ad9361_lo_remote(std::string remote_host, } -bool ad9361_disable_lo_remote(std::string remote_host) +bool ad9361_disable_lo_remote(const std::string &remote_host) { std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl; struct iio_context *ctx; diff --git a/src/algorithms/signal_source/libs/ad9361_manager.h b/src/algorithms/signal_source/libs/ad9361_manager.h index acfe3abb5..af4390ddb 100644 --- a/src/algorithms/signal_source/libs/ad9361_manager.h +++ b/src/algorithms/signal_source/libs/ad9361_manager.h @@ -33,6 +33,7 @@ #ifndef GNSS_SDR_AD9361_MANAGER_H #define GNSS_SDR_AD9361_MANAGER_H +#include #include #ifdef __APPLE__ @@ -51,9 +52,9 @@ enum iodev /* common RX and TX streaming params */ struct stream_cfg { - long long bw_hz; // Analog banwidth in Hz - long long fs_hz; // Baseband sample rate in Hz - long long lo_hz; // Local oscillator frequency in Hz + int64_t bw_hz; // Analog banwidth in Hz + int64_t fs_hz; // Baseband sample rate in Hz + int64_t lo_hz; // Local oscillator frequency in Hz const char *rfport; // Port name }; @@ -61,8 +62,8 @@ struct stream_cfg /* check return value of attr_write function */ void errchk(int v, const char *what); -/* write attribute: long long int */ -void wr_ch_lli(struct iio_channel *chn, const char *what, long long val); +/* write attribute: int64_t int */ +void wr_ch_lli(struct iio_channel *chn, const char *what, int64_t val); /* write attribute: string */ void wr_ch_str(struct iio_channel *chn, const char *what, const char *str); @@ -88,42 +89,42 @@ bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn /* applies streaming configuration through IIO */ bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, enum iodev type, int chid); -bool config_ad9361_rx_local(unsigned long bandwidth_, - unsigned long sample_rate_, - unsigned long freq_, - std::string rf_port_select_, - std::string gain_mode_rx1_, - std::string gain_mode_rx2_, +bool config_ad9361_rx_local(uint64_t bandwidth_, + uint64_t sample_rate_, + uint64_t freq_, + const std::string &rf_port_select_, + const std::string &gain_mode_rx1_, + const std::string &gain_mode_rx2_, double rf_gain_rx1_, double rf_gain_rx2_); -bool config_ad9361_rx_remote(std::string remote_host, - unsigned long bandwidth_, - unsigned long sample_rate_, - unsigned long freq_, - std::string rf_port_select_, - std::string gain_mode_rx1_, - std::string gain_mode_rx2_, +bool config_ad9361_rx_remote(const std::string &remote_host, + uint64_t bandwidth_, + uint64_t sample_rate_, + uint64_t freq_, + const std::string &rf_port_select_, + const std::string &gain_mode_rx1_, + const std::string &gain_mode_rx2_, double rf_gain_rx1_, double rf_gain_rx2_); -bool config_ad9361_lo_local(unsigned long bandwidth_, - unsigned long sample_rate_, - unsigned long freq_rf_tx_hz_, +bool config_ad9361_lo_local(uint64_t bandwidth_, + uint64_t sample_rate_, + uint64_t freq_rf_tx_hz_, double tx_attenuation_db_, - long long freq_dds_tx_hz_, + int64_t freq_dds_tx_hz_, double scale_dds_dbfs_); -bool config_ad9361_lo_remote(std::string remote_host, - unsigned long bandwidth_, - unsigned long sample_rate_, - unsigned long freq_rf_tx_hz_, +bool config_ad9361_lo_remote(const std::string &remote_host, + uint64_t bandwidth_, + uint64_t sample_rate_, + uint64_t freq_rf_tx_hz_, double tx_attenuation_db_, - long long freq_dds_tx_hz_, + int64_t freq_dds_tx_hz_, double scale_dds_dbfs_); -bool ad9361_disable_lo_remote(std::string remote_host); +bool ad9361_disable_lo_remote(const std::string &remote_host); bool ad9361_disable_lo_local(); diff --git a/src/algorithms/signal_source/libs/fpga_switch.cc b/src/algorithms/signal_source/libs/fpga_switch.cc index ab6c58e77..5dec90e55 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.cc +++ b/src/algorithms/signal_source/libs/fpga_switch.cc @@ -2,7 +2,7 @@ * \file fpga_switch.cc * \brief Switch that connects the HW accelerator queues to the analog front end or the DMA. * \authors
                  - *
                • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
                • Marc Majoral, 2019. mmajoral(at)cttc.cat *
                • Javier Arribas, 2015. jarribas(at)cttc.es *
                * @@ -43,9 +43,9 @@ // constants const size_t PAGE_SIZE = 0x10000; -const unsigned int TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; +const uint32_t TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; -fpga_switch::fpga_switch(std::string device_name) +Fpga_Switch::Fpga_Switch(const std::string &device_name) { if ((d_device_descriptor = open(device_name.c_str(), O_RDWR | O_SYNC)) == -1) { @@ -67,7 +67,7 @@ fpga_switch::fpga_switch(std::string device_name) // sanity check : check test register unsigned writeval = TEST_REGISTER_TRACK_WRITEVAL; unsigned readval; - readval = fpga_switch::fpga_switch_test_register(writeval); + readval = Fpga_Switch::fpga_switch_test_register(writeval); if (writeval != readval) { LOG(WARNING) << "Test register sanity check failed"; @@ -81,19 +81,19 @@ fpga_switch::fpga_switch(std::string device_name) } -fpga_switch::~fpga_switch() +Fpga_Switch::~Fpga_Switch() { close_device(); } -void fpga_switch::set_switch_position(int switch_position) +void Fpga_Switch::set_switch_position(int32_t switch_position) { d_map_base[0] = switch_position; } -unsigned fpga_switch::fpga_switch_test_register( +unsigned Fpga_Switch::fpga_switch_test_register( unsigned writeval) { unsigned readval; @@ -106,9 +106,9 @@ unsigned fpga_switch::fpga_switch_test_register( } -void fpga_switch::close_device() +void Fpga_Switch::close_device() { - unsigned *aux = const_cast(d_map_base); + auto *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { std::cout << "Failed to unmap memory uio" << std::endl; diff --git a/src/algorithms/signal_source/libs/fpga_switch.h b/src/algorithms/signal_source/libs/fpga_switch.h index f4a755775..c6a67c5fc 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.h +++ b/src/algorithms/signal_source/libs/fpga_switch.h @@ -2,7 +2,7 @@ * \file fpga_switch.h * \brief Switch that connects the HW accelerator queues to the analog front end or the DMA. * \authors
                  - *
                • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
                • Marc Majoral, 2019. mmajoral(at)cttc.cat *
                • Javier Arribas, 2016. jarribas(at)cttc.es *
                * @@ -41,16 +41,16 @@ #define MAX_LENGTH_DEVICEIO_NAME 50 -class fpga_switch +class Fpga_Switch { public: - fpga_switch(std::string device_name); - ~fpga_switch(); - void set_switch_position(int switch_position); + Fpga_Switch(const std::string& device_name); + ~Fpga_Switch(); + void set_switch_position(int32_t switch_position); private: int d_device_descriptor; // driver descriptor - volatile unsigned *d_map_base; // driver memory map + volatile unsigned* d_map_base; // driver memory map // private functions unsigned fpga_switch_test_register(unsigned writeval); diff --git a/src/algorithms/signal_source/libs/gnss_sdr_valve.cc b/src/algorithms/signal_source/libs/gnss_sdr_valve.cc new file mode 100644 index 000000000..5e0d6f4cd --- /dev/null +++ b/src/algorithms/signal_source/libs/gnss_sdr_valve.cc @@ -0,0 +1,108 @@ +/*! + * \file gnss_sdr_valve.cc + * \brief Implementation of a GNU Radio block that sends a STOP message to the + * control queue right after a specific number of samples have passed through it. + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "gnss_sdr_valve.h" +#include "control_message_factory.h" +#include +#include +#include // for min +#include // for memcpy +#include + +Gnss_Sdr_Valve::Gnss_Sdr_Valve(size_t sizeof_stream_item, + uint64_t nitems, + gr::msg_queue::sptr queue, + bool stop_flowgraph) : gr::sync_block("valve", + gr::io_signature::make(1, 1, sizeof_stream_item), + gr::io_signature::make(1, 1, sizeof_stream_item)), + d_nitems(nitems), + d_ncopied_items(0), + d_queue(std::move(queue)), + d_stop_flowgraph(stop_flowgraph) +{ + d_open_valve = false; +} + + +boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, gr::msg_queue::sptr queue, bool stop_flowgraph) +{ + boost::shared_ptr valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, std::move(queue), stop_flowgraph)); + return valve_; +} + + +boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, gr::msg_queue::sptr queue) +{ + boost::shared_ptr valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, std::move(queue), true)); + return valve_; +} + + +void Gnss_Sdr_Valve::open_valve() +{ + d_open_valve = true; +} + + +int Gnss_Sdr_Valve::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + if (d_open_valve == false) + { + if (d_ncopied_items >= d_nitems) + { + auto *cmf = new ControlMessageFactory(); + d_queue->handle(cmf->GetQueueMessage(200, 0)); + LOG(INFO) << "Stopping receiver, " << d_ncopied_items << " samples processed"; + delete cmf; + if (d_stop_flowgraph) + { + return -1; // Done! + } + usleep(1000000); + return 0; // do not produce or consume + } + uint64_t n = std::min(d_nitems - d_ncopied_items, static_cast(noutput_items)); + if (n == 0) + { + return 0; + } + memcpy(output_items[0], input_items[0], n * input_signature()->sizeof_stream_item(0)); + d_ncopied_items += n; + return n; + } + + memcpy(output_items[0], input_items[0], noutput_items * input_signature()->sizeof_stream_item(0)); + return noutput_items; +} diff --git a/src/algorithms/libs/gnss_sdr_valve.h b/src/algorithms/signal_source/libs/gnss_sdr_valve.h similarity index 73% rename from src/algorithms/libs/gnss_sdr_valve.h rename to src/algorithms/signal_source/libs/gnss_sdr_valve.h index 725a34353..16a141cd4 100644 --- a/src/algorithms/libs/gnss_sdr_valve.h +++ b/src/algorithms/signal_source/libs/gnss_sdr_valve.h @@ -2,6 +2,7 @@ * \file gnss_sdr_valve.h * \brief Interface of a GNU Radio block that sends a STOP message to the * control queue right after a specific number of samples have passed through it. + * \author Javier Arribas, 2018. jarribas(at)cttc.es * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * * ------------------------------------------------------------------------- @@ -33,31 +34,46 @@ #ifndef GNSS_SDR_GNSS_SDR_VALVE_H_ #define GNSS_SDR_GNSS_SDR_VALVE_H_ -#include -#include #include - +#include +#include +#include boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue); + +boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, + uint64_t nitems, + gr::msg_queue::sptr queue, + bool stop_flowgraph); + /*! * \brief Implementation of a GNU Radio block that sends a STOP message to the * control queue right after a specific number of samples have passed through it. */ -class gnss_sdr_valve : public gr::sync_block +class Gnss_Sdr_Valve : public gr::sync_block { friend boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue); - gnss_sdr_valve(size_t sizeof_stream_item, - unsigned long long nitems, - gr::msg_queue::sptr queue); - unsigned long long d_nitems; - unsigned long long d_ncopied_items; + friend boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, + uint64_t nitems, + gr::msg_queue::sptr queue, + bool stop_flowgraph); + + uint64_t d_nitems; + uint64_t d_ncopied_items; gr::msg_queue::sptr d_queue; + bool d_stop_flowgraph; + bool d_open_valve; public: + Gnss_Sdr_Valve(size_t sizeof_stream_item, + uint64_t nitems, + gr::msg_queue::sptr queue, bool stop_flowgraph); + void open_valve(); + int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.cc b/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.cc index 0f2419498..09abb26db 100644 --- a/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.cc +++ b/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.cc @@ -37,13 +37,13 @@ using boost::asio::ip::tcp; -rtl_tcp_dongle_info::rtl_tcp_dongle_info() : tuner_type_(0), tuner_gain_count_(0) +Rtl_Tcp_Dongle_Info::Rtl_Tcp_Dongle_Info() : tuner_type_(0), tuner_gain_count_(0) { std::memset(magic_, 0, sizeof(magic_)); } -boost::system::error_code rtl_tcp_dongle_info::read(boost::asio::ip::tcp::socket &socket) +boost::system::error_code Rtl_Tcp_Dongle_Info::read(boost::asio::ip::tcp::socket &socket) { boost::system::error_code ec; @@ -67,7 +67,7 @@ boost::system::error_code rtl_tcp_dongle_info::read(boost::asio::ip::tcp::socket } -const char *rtl_tcp_dongle_info::get_type_name() const +const char *Rtl_Tcp_Dongle_Info::get_type_name() const { switch (get_tuner_type()) { @@ -89,7 +89,7 @@ const char *rtl_tcp_dongle_info::get_type_name() const } -double rtl_tcp_dongle_info::clip_gain(int gain) const +double Rtl_Tcp_Dongle_Info::clip_gain(int gain) const { // the following gain values have been copied from librtlsdr // all gain values are expressed in tenths of a dB @@ -121,37 +121,32 @@ double rtl_tcp_dongle_info::clip_gain(int gain) const } // clip - if (gains.size() == 0) + if (gains.empty()) { // no defined gains to clip to return gain; } - else - { - double last_stop = gains.front(); - BOOST_FOREACH (double g, gains) - { - g /= 10.0; - if (gain < g) + double last_stop = gains.front(); + BOOST_FOREACH (double g, gains) + { + g /= 10.0; + + if (gain < g) + { + if (std::abs(gain - g) < std::abs(gain - last_stop)) { - if (std::abs(gain - g) < std::abs(gain - last_stop)) - { - return g; - } - else - { - return last_stop; - } + return g; } - last_stop = g; + return last_stop; } - return last_stop; + last_stop = g; } + return last_stop; } -bool rtl_tcp_dongle_info::is_valid() const +bool Rtl_Tcp_Dongle_Info::is_valid() const { return std::memcmp(magic_, "RTL0", 4) == 0; } diff --git a/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h b/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h index 9b1c12f43..e7ac9eb94 100644 --- a/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h +++ b/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h @@ -39,10 +39,10 @@ * \brief This class represents the dongle information * which is sent by rtl_tcp. */ -class rtl_tcp_dongle_info +class Rtl_Tcp_Dongle_Info { private: - char magic_[4]; + char magic_[4]{}; uint32_t tuner_type_; uint32_t tuner_gain_count_; @@ -58,7 +58,7 @@ public: TUNER_R828D }; - rtl_tcp_dongle_info(); + Rtl_Tcp_Dongle_Info(); boost::system::error_code read(boost::asio::ip::tcp::socket &socket); diff --git a/src/algorithms/telemetry_decoder/CMakeLists.txt b/src/algorithms/telemetry_decoder/CMakeLists.txt index ea74d8ec3..96259341c 100644 --- a/src/algorithms/telemetry_decoder/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/CMakeLists.txt @@ -18,4 +18,4 @@ add_subdirectory(adapters) add_subdirectory(gnuradio_blocks) -add_subdirectory(libs) \ No newline at end of file +add_subdirectory(libs) diff --git a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt index 6722ce03b..17eb17e5d 100644 --- a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -20,30 +20,63 @@ set(TELEMETRY_DECODER_ADAPTER_SOURCES gps_l1_ca_telemetry_decoder.cc gps_l2c_telemetry_decoder.cc - gps_l5_telemetry_decoder.cc + gps_l5_telemetry_decoder.cc galileo_e1b_telemetry_decoder.cc sbas_l1_telemetry_decoder.cc galileo_e5a_telemetry_decoder.cc glonass_l1_ca_telemetry_decoder.cc - glonass_l2_ca_telemetry_decoder.cc + glonass_l2_ca_telemetry_decoder.cc + beidou_b1i_telemetry_decoder.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/libs/libswiftcnav - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} +set(TELEMETRY_DECODER_ADAPTER_HEADERS + gps_l1_ca_telemetry_decoder.h + gps_l2c_telemetry_decoder.h + gps_l5_telemetry_decoder.h + galileo_e1b_telemetry_decoder.h + sbas_l1_telemetry_decoder.h + galileo_e5a_telemetry_decoder.h + glonass_l1_ca_telemetry_decoder.h + glonass_l2_ca_telemetry_decoder.h + beidou_b1i_telemetry_decoder.h ) -file(GLOB TELEMETRY_DECODER_ADAPTER_HEADERS "*.h") list(SORT TELEMETRY_DECODER_ADAPTER_HEADERS) -add_library(telemetry_decoder_adapters ${TELEMETRY_DECODER_ADAPTER_SOURCES} ${TELEMETRY_DECODER_ADAPTER_HEADERS}) +list(SORT TELEMETRY_DECODER_ADAPTER_SOURCES) + source_group(Headers FILES ${TELEMETRY_DECODER_ADAPTER_HEADERS}) -target_link_libraries(telemetry_decoder_adapters telemetry_decoder_gr_blocks gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES}) + +add_library(telemetry_decoder_adapters + ${TELEMETRY_DECODER_ADAPTER_SOURCES} + ${TELEMETRY_DECODER_ADAPTER_HEADERS} +) + +target_link_libraries(telemetry_decoder_adapters + PUBLIC + telemetry_decoder_gr_blocks + core_system_parameters + PRIVATE + Gflags::gflags + Glog::glog + Gnuradio::runtime + telemetry_decoder_libs +) + +target_include_directories(telemetry_decoder_adapters + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/interfaces +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(telemetry_decoder_adapters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET telemetry_decoder_adapters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.cc new file mode 100644 index 000000000..a29fdcc01 --- /dev/null +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.cc @@ -0,0 +1,110 @@ +/*! + * \file beidou_b1i_telemetry_decoder.cc + * \brief Implementation of an adapter of a Beidou B1I NAV data decoder block + * to a TelemetryDecoderInterface + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "beidou_b1i_telemetry_decoder.h" +#include "beidou_dnav_almanac.h" +#include "beidou_dnav_ephemeris.h" +#include "beidou_dnav_iono.h" +#include "beidou_dnav_utc_model.h" +#include "configuration_interface.h" +#include +#include + + +using google::LogMessage; + +BeidouB1iTelemetryDecoder::BeidouB1iTelemetryDecoder(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + std::string default_dump_filename = "./navigation.dat"; + DLOG(INFO) << "role " << role; + dump_ = configuration->property(role + ".dump", false); + dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); + // make telemetry decoder object + telemetry_decoder_ = beidou_b1i_make_telemetry_decoder_cc(satellite_, dump_); // TODO fix me + DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; + channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } +} + + +BeidouB1iTelemetryDecoder::~BeidouB1iTelemetryDecoder() = default; + + +void BeidouB1iTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) +{ + satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + telemetry_decoder_->set_satellite(satellite_); + DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; +} + + +void BeidouB1iTelemetryDecoder::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // Nothing to connect internally + DLOG(INFO) << "nothing to connect internally"; +} + + +void BeidouB1iTelemetryDecoder::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // Nothing to disconnect +} + + +gr::basic_block_sptr BeidouB1iTelemetryDecoder::get_left_block() +{ + return telemetry_decoder_; +} + + +gr::basic_block_sptr BeidouB1iTelemetryDecoder::get_right_block() +{ + return telemetry_decoder_; +} diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.h new file mode 100644 index 000000000..2deb50c27 --- /dev/null +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.h @@ -0,0 +1,96 @@ +/*! + * \file beidou_b1i_telemetry_decoder.h + * \brief Interface of an adapter of a Beidou B1I NAV data decoder block + * to a TelemetryDecoderInterface + * \author Damian Miralles, 2018. dmiralles2009@gmail.com + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_H_ +#define GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_H_ + +#include "beidou_b1i_telemetry_decoder_cc.h" +#include "telemetry_decoder_interface.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a NAV data decoder for BEIDOU B1I + */ +class BeidouB1iTelemetryDecoder : public TelemetryDecoderInterface +{ +public: + BeidouB1iTelemetryDecoder(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~BeidouB1iTelemetryDecoder(); + + inline std::string role() override + { + return role_; + } + + //! Returns "BEIDOU_B1I_Telemetry_Decoder" + inline std::string implementation() override + { + return "BEIDOU_B1I_Telemetry_Decoder"; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + void set_satellite(const Gnss_Satellite& satellite) override; + inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } + + inline void reset() override + { + return; + } + + inline size_t item_size() override + { + return 0; + } + +private: + beidou_b1i_telemetry_decoder_cc_sptr telemetry_decoder_; + Gnss_Satellite satellite_; + int channel_; + bool dump_; + std::string dump_filename_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; +}; + +#endif diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc index a7f0f3470..be7dd59ce 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc @@ -33,18 +33,18 @@ #include "galileo_e1b_telemetry_decoder.h" #include "configuration_interface.h" -#include "galileo_ephemeris.h" #include "galileo_almanac.h" +#include "galileo_ephemeris.h" #include "galileo_iono.h" #include "galileo_utc_model.h" -#include #include +#include using google::LogMessage; GalileoE1BTelemetryDecoder::GalileoE1BTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -55,15 +55,21 @@ GalileoE1BTelemetryDecoder::GalileoE1BTelemetryDecoder(ConfigurationInterface* c dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); // make telemetry decoder object - telemetry_decoder_ = galileo_e1b_make_telemetry_decoder_cc(satellite_, dump_); // TODO fix me + telemetry_decoder_ = galileo_make_telemetry_decoder_cc(satellite_, 1, dump_); //unified galileo decoder set to INAV (frame_type=1) DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GalileoE1BTelemetryDecoder::~GalileoE1BTelemetryDecoder() -{ -} +GalileoE1BTelemetryDecoder::~GalileoE1BTelemetryDecoder() = default; void GalileoE1BTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h index d762eabd8..c277725ce 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h @@ -35,9 +35,9 @@ #define GNSS_SDR_GALILEO_E1B_TELEMETRY_DECODER_H_ -#include "telemetry_decoder_interface.h" -#include "galileo_e1b_telemetry_decoder_cc.h" +#include "galileo_telemetry_decoder_cc.h" #include "gnss_satellite.h" +#include "telemetry_decoder_interface.h" #include @@ -50,7 +50,7 @@ class GalileoE1BTelemetryDecoder : public TelemetryDecoderInterface { public: GalileoE1BTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -76,7 +76,6 @@ public: void set_satellite(const Gnss_Satellite& satellite) override; inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - inline void reset() override { return; @@ -88,7 +87,7 @@ public: } private: - galileo_e1b_telemetry_decoder_cc_sptr telemetry_decoder_; + galileo_telemetry_decoder_cc_sptr telemetry_decoder_; Gnss_Satellite satellite_; int channel_; bool dump_; diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc index 6470e2783..715e5c1cb 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc @@ -36,18 +36,18 @@ #include "galileo_e5a_telemetry_decoder.h" #include "configuration_interface.h" -#include "galileo_ephemeris.h" #include "galileo_almanac.h" +#include "galileo_ephemeris.h" #include "galileo_iono.h" #include "galileo_utc_model.h" -#include #include +#include using google::LogMessage; GalileoE5aTelemetryDecoder::GalileoE5aTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -58,15 +58,21 @@ GalileoE5aTelemetryDecoder::GalileoE5aTelemetryDecoder(ConfigurationInterface* c dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); // make telemetry decoder object - telemetry_decoder_ = galileo_e5a_make_telemetry_decoder_cc(satellite_, dump_); // TODO fix me + telemetry_decoder_ = galileo_make_telemetry_decoder_cc(satellite_, 2, dump_); //unified galileo decoder set to FNAV (frame_type=2) DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GalileoE5aTelemetryDecoder::~GalileoE5aTelemetryDecoder() -{ -} +GalileoE5aTelemetryDecoder::~GalileoE5aTelemetryDecoder() = default; void GalileoE5aTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h index 4a4167bf5..cdb21af2d 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h @@ -37,7 +37,7 @@ #ifndef GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_H_ #define GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_H_ -#include "galileo_e5a_telemetry_decoder_cc.h" +#include "galileo_telemetry_decoder_cc.h" #include "telemetry_decoder_interface.h" #include @@ -50,7 +50,7 @@ class GalileoE5aTelemetryDecoder : public TelemetryDecoderInterface { public: GalileoE5aTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -76,7 +76,6 @@ public: void set_satellite(const Gnss_Satellite& satellite) override; inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - inline void reset() override { return; @@ -88,7 +87,7 @@ public: } private: - galileo_e5a_telemetry_decoder_cc_sptr telemetry_decoder_; + galileo_telemetry_decoder_cc_sptr telemetry_decoder_; Gnss_Satellite satellite_; int channel_; bool dump_; diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc index 3d6555157..c0d88314f 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc @@ -33,17 +33,17 @@ #include "glonass_l1_ca_telemetry_decoder.h" #include "configuration_interface.h" -#include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" +#include "glonass_gnav_ephemeris.h" #include "glonass_gnav_utc_model.h" -#include #include +#include using google::LogMessage; GlonassL1CaTelemetryDecoder::GlonassL1CaTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -57,12 +57,18 @@ GlonassL1CaTelemetryDecoder::GlonassL1CaTelemetryDecoder(ConfigurationInterface* telemetry_decoder_ = glonass_l1_ca_make_telemetry_decoder_cc(satellite_, dump_); DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GlonassL1CaTelemetryDecoder::~GlonassL1CaTelemetryDecoder() -{ -} +GlonassL1CaTelemetryDecoder::~GlonassL1CaTelemetryDecoder() = default; void GlonassL1CaTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h index c35fc68e0..33bc3ecbd 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h @@ -34,8 +34,8 @@ #ifndef GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_H_ #define GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_H_ -#include "telemetry_decoder_interface.h" #include "glonass_l1_ca_telemetry_decoder_cc.h" +#include "telemetry_decoder_interface.h" #include class ConfigurationInterface; @@ -47,7 +47,7 @@ class GlonassL1CaTelemetryDecoder : public TelemetryDecoderInterface { public: GlonassL1CaTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc index 8376cc27b..c96851552 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc @@ -32,17 +32,17 @@ #include "glonass_l2_ca_telemetry_decoder.h" #include "configuration_interface.h" -#include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" +#include "glonass_gnav_ephemeris.h" #include "glonass_gnav_utc_model.h" -#include #include +#include using google::LogMessage; GlonassL2CaTelemetryDecoder::GlonassL2CaTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -56,12 +56,18 @@ GlonassL2CaTelemetryDecoder::GlonassL2CaTelemetryDecoder(ConfigurationInterface* telemetry_decoder_ = glonass_l2_ca_make_telemetry_decoder_cc(satellite_, dump_); DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GlonassL2CaTelemetryDecoder::~GlonassL2CaTelemetryDecoder() -{ -} +GlonassL2CaTelemetryDecoder::~GlonassL2CaTelemetryDecoder() = default; void GlonassL2CaTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h index 27c7774bd..83c7c8c4e 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h @@ -33,8 +33,8 @@ #ifndef GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_H_ #define GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_H_ -#include "telemetry_decoder_interface.h" #include "glonass_l2_ca_telemetry_decoder_cc.h" +#include "telemetry_decoder_interface.h" #include class ConfigurationInterface; @@ -46,7 +46,7 @@ class GlonassL2CaTelemetryDecoder : public TelemetryDecoderInterface { public: GlonassL2CaTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc index 98b4e6d79..b7a4530b3 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc @@ -32,18 +32,18 @@ #include "gps_l1_ca_telemetry_decoder.h" #include "configuration_interface.h" -#include "gps_ephemeris.h" #include "gps_almanac.h" +#include "gps_ephemeris.h" #include "gps_iono.h" #include "gps_utc_model.h" -#include #include +#include using google::LogMessage; GpsL1CaTelemetryDecoder::GpsL1CaTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -57,12 +57,18 @@ GpsL1CaTelemetryDecoder::GpsL1CaTelemetryDecoder(ConfigurationInterface* configu telemetry_decoder_ = gps_l1_ca_make_telemetry_decoder_cc(satellite_, dump_); // TODO fix me DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL1CaTelemetryDecoder::~GpsL1CaTelemetryDecoder() -{ -} +GpsL1CaTelemetryDecoder::~GpsL1CaTelemetryDecoder() = default; void GpsL1CaTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h index ec4efbb86..9436e8ae5 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h @@ -46,7 +46,7 @@ class GpsL1CaTelemetryDecoder : public TelemetryDecoderInterface { public: GpsL1CaTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc index 5e1f9c6b2..db451a045 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc @@ -32,18 +32,18 @@ #include "gps_l2c_telemetry_decoder.h" #include "configuration_interface.h" -#include "gps_cnav_ephemeris.h" #include "gps_almanac.h" +#include "gps_cnav_ephemeris.h" #include "gps_cnav_iono.h" #include "gps_cnav_utc_model.h" -#include #include +#include using google::LogMessage; GpsL2CTelemetryDecoder::GpsL2CTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -57,12 +57,18 @@ GpsL2CTelemetryDecoder::GpsL2CTelemetryDecoder(ConfigurationInterface* configura telemetry_decoder_ = gps_l2c_make_telemetry_decoder_cc(satellite_, dump_); // TODO fix me DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL2CTelemetryDecoder::~GpsL2CTelemetryDecoder() -{ -} +GpsL2CTelemetryDecoder::~GpsL2CTelemetryDecoder() = default; void GpsL2CTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h index fefb15e97..f7e9fb76b 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h @@ -46,7 +46,7 @@ class GpsL2CTelemetryDecoder : public TelemetryDecoderInterface { public: GpsL2CTelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc index f86cedf55..68fa96d26 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc @@ -32,14 +32,14 @@ #include "gps_l5_telemetry_decoder.h" #include "configuration_interface.h" -#include #include +#include using google::LogMessage; GpsL5TelemetryDecoder::GpsL5TelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -53,12 +53,18 @@ GpsL5TelemetryDecoder::GpsL5TelemetryDecoder(ConfigurationInterface* configurati telemetry_decoder_ = gps_l5_make_telemetry_decoder_cc(satellite_, dump_); DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL5TelemetryDecoder::~GpsL5TelemetryDecoder() -{ -} +GpsL5TelemetryDecoder::~GpsL5TelemetryDecoder() = default; void GpsL5TelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h index 06da22d47..c895b3b48 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h @@ -34,9 +34,9 @@ #define GNSS_SDR_GPS_L5_TELEMETRY_DECODER_H_ -#include "telemetry_decoder_interface.h" -#include "gps_l5_telemetry_decoder_cc.h" #include "gnss_satellite.h" +#include "gps_l5_telemetry_decoder_cc.h" +#include "telemetry_decoder_interface.h" #include @@ -49,7 +49,7 @@ class GpsL5TelemetryDecoder : public TelemetryDecoderInterface { public: GpsL5TelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); diff --git a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc index d695f0861..2083509e1 100644 --- a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc @@ -34,14 +34,14 @@ #include "configuration_interface.h" #include "sbas_ephemeris.h" #include "sbas_l1_telemetry_decoder_cc.h" -#include #include +#include using google::LogMessage; SbasL1TelemetryDecoder::SbasL1TelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -55,12 +55,18 @@ SbasL1TelemetryDecoder::SbasL1TelemetryDecoder(ConfigurationInterface* configura telemetry_decoder_ = sbas_l1_make_telemetry_decoder_cc(satellite_, dump_); // TODO fix me channel_ = 0; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -SbasL1TelemetryDecoder::~SbasL1TelemetryDecoder() -{ -} +SbasL1TelemetryDecoder::~SbasL1TelemetryDecoder() = default; void SbasL1TelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) diff --git a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h index 9da1b44f9..c7ab0043b 100644 --- a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h @@ -34,8 +34,8 @@ #define GNSS_SDR_SBAS_L1_TELEMETRY_DECODER_H_ -#include "telemetry_decoder_interface.h" #include "sbas_l1_telemetry_decoder_cc.h" +#include "telemetry_decoder_interface.h" #include @@ -48,7 +48,7 @@ class SbasL1TelemetryDecoder : public TelemetryDecoderInterface { public: SbasL1TelemetryDecoder(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index 3af26e46b..8e71b0681 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,35 +17,60 @@ # set(TELEMETRY_DECODER_GR_BLOCKS_SOURCES - gps_l1_ca_telemetry_decoder_cc.cc - gps_l2c_telemetry_decoder_cc.cc - gps_l5_telemetry_decoder_cc.cc - galileo_e1b_telemetry_decoder_cc.cc - sbas_l1_telemetry_decoder_cc.cc - galileo_e5a_telemetry_decoder_cc.cc - glonass_l1_ca_telemetry_decoder_cc.cc - glonass_l2_ca_telemetry_decoder_cc.cc + gps_l1_ca_telemetry_decoder_cc.cc + gps_l2c_telemetry_decoder_cc.cc + gps_l5_telemetry_decoder_cc.cc + sbas_l1_telemetry_decoder_cc.cc + glonass_l1_ca_telemetry_decoder_cc.cc + glonass_l2_ca_telemetry_decoder_cc.cc + galileo_telemetry_decoder_cc.cc + beidou_b1i_telemetry_decoder_cc.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/libs/libswiftcnav - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} +set(TELEMETRY_DECODER_GR_BLOCKS_HEADERS + gps_l1_ca_telemetry_decoder_cc.h + gps_l2c_telemetry_decoder_cc.h + gps_l5_telemetry_decoder_cc.h + sbas_l1_telemetry_decoder_cc.h + glonass_l1_ca_telemetry_decoder_cc.h + glonass_l2_ca_telemetry_decoder_cc.h + galileo_telemetry_decoder_cc.h + beidou_b1i_telemetry_decoder_cc.h ) -file(GLOB TELEMETRY_DECODER_GR_BLOCKS_HEADERS "*.h") list(SORT TELEMETRY_DECODER_GR_BLOCKS_HEADERS) -add_library(telemetry_decoder_gr_blocks ${TELEMETRY_DECODER_GR_BLOCKS_SOURCES} ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS}) -source_group(Headers FILES ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS}) -target_link_libraries(telemetry_decoder_gr_blocks telemetry_decoder_libswiftcnav telemetry_decoder_lib gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES}) +list(SORT TELEMETRY_DECODER_GR_BLOCKS_SOURCES) -if(NOT VOLK_GNSSSDR_FOUND) - add_dependencies(telemetry_decoder_gr_blocks volk_gnsssdr_module) -endif(NOT VOLK_GNSSSDR_FOUND) +source_group(Headers FILES ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS}) + +add_library(telemetry_decoder_gr_blocks + ${TELEMETRY_DECODER_GR_BLOCKS_SOURCES} + ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS} +) + +target_link_libraries(telemetry_decoder_gr_blocks + PUBLIC + Gnuradio::runtime + Volkgnsssdr::volkgnsssdr + telemetry_decoder_libswiftcnav + telemetry_decoder_libs + core_system_parameters + PRIVATE + Boost::boost + Gflags::gflags + Glog::glog +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(telemetry_decoder_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET telemetry_decoder_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc new file mode 100644 index 000000000..7a39e31ec --- /dev/null +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc @@ -0,0 +1,591 @@ +/*! + * \file beidou_b1i_telemetry_decoder_cc.cc + * \brief Implementation of an adapter of a BEIDOU BI1 DNAV data decoder block + * to a TelemetryDecoderInterface + * \note Code added as part of GSoC 2018 program + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "beidou_b1i_telemetry_decoder_cc.h" +#include "convolutional.h" +#include "display.h" +#include "gnss_synchro.h" +#include +#include +#include +#include +#include + +#define CRC_ERROR_LIMIT 8 + +using google::LogMessage; + + +beidou_b1i_telemetry_decoder_cc_sptr +beidou_b1i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump) +{ + return beidou_b1i_telemetry_decoder_cc_sptr(new beidou_b1i_telemetry_decoder_cc(satellite, dump)); +} + + +beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc( + const Gnss_Satellite &satellite, + bool dump) : gr::block("beidou_b1i_telemetry_decoder_cc", + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Ephemeris data port out + this->message_port_register_out(pmt::mp("telemetry")); + // initialize internal vars + d_dump = dump; + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + LOG(INFO) << "Initializing BeiDou B1i Telemetry Decoding for satellite " << this->d_satellite; + + d_samples_per_symbol = (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS) / BEIDOU_D1NAV_SYMBOL_RATE_SPS; + d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; + d_secondary_code_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_B1I_SECONDARY_CODE_LENGTH * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; + + // Setting samples of secondary code + for (int32_t i = 0; i < BEIDOU_B1I_SECONDARY_CODE_LENGTH; i++) + { + if (BEIDOU_B1I_SECONDARY_CODE.at(i) == '1') + { + d_secondary_code_symbols[i] = 1; + } + else + { + d_secondary_code_symbols[i] = -1; + } + } + + // Setting samples of preamble code + int32_t n = 0; + for (int32_t i = 0; i < d_symbols_per_preamble; i++) + { + int32_t m = 0; + if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = d_secondary_code_symbols[m]; + n++; + m++; + m = m % BEIDOU_B1I_SECONDARY_CODE_LENGTH; + } + } + else + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = -d_secondary_code_symbols[m]; + n++; + m++; + m = m % BEIDOU_B1I_SECONDARY_CODE_LENGTH; + } + } + } + + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble; + + // Generic settings + d_sample_counter = 0; + d_stat = 0; + d_preamble_index = 0; + d_flag_frame_sync = false; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0U; + Flag_valid_word = false; + d_CRC_error_counter = 0; + d_flag_preamble = false; + d_channel = 0; + flag_SOW_set = false; +} + + +beidou_b1i_telemetry_decoder_cc::~beidou_b1i_telemetry_decoder_cc() +{ + volk_gnsssdr_free(d_preamble_samples); + volk_gnsssdr_free(d_secondary_code_symbols); + volk_gnsssdr_free(d_subframe_symbols); + + if (d_dump_file.is_open() == true) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); + } + } +} + + +void beidou_b1i_telemetry_decoder_cc::decode_bch15_11_01(const int32_t *bits, int32_t *decbits) +{ + int32_t bit, err, reg[4] = {1, 1, 1, 1}; + int32_t errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2}; + + for (uint32_t i = 0; i < 15; i++) + { + decbits[i] = bits[i]; + } + + for (uint32_t i = 0; i < 15; i++) + { + bit = reg[3]; + reg[3] = reg[2]; + reg[2] = reg[1]; + reg[1] = reg[0]; + reg[0] = bits[i] * bit; + reg[1] *= bit; + } + + err = errind[reg[0] + reg[1] * 2 + reg[2] * 4 + reg[3] * 8]; + + if (err > 0) + { + decbits[err - 1] *= -1; + } +} + + +void beidou_b1i_telemetry_decoder_cc::decode_word( + int32_t word_counter, + const double *enc_word_symbols, + int32_t *dec_word_symbols) +{ + int32_t bitsbch[30], first_branch[15], second_branch[15]; + + if (word_counter == 1) + { + for (uint32_t j = 0; j < 30; j++) + { + dec_word_symbols[j] = static_cast(enc_word_symbols[j] > 0) ? (1) : (-1); + } + } + else + { + for (uint32_t r = 0; r < 2; r++) + { + for (uint32_t c = 0; c < 15; c++) + { + bitsbch[r * 15 + c] = static_cast(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1); + } + } + + decode_bch15_11_01(&bitsbch[0], first_branch); + decode_bch15_11_01(&bitsbch[15], second_branch); + + for (uint32_t j = 0; j < 11; j++) + { + dec_word_symbols[j] = first_branch[j]; + dec_word_symbols[j + 11] = second_branch[j]; + } + + for (uint32_t j = 0; j < 4; j++) + { + dec_word_symbols[j + 22] = first_branch[11 + j]; + dec_word_symbols[j + 26] = second_branch[11 + j]; + } + } +} + + +void beidou_b1i_telemetry_decoder_cc::decode_subframe(double *frame_symbols) +{ + // 1. Transform from symbols to bits + std::string data_bits; + int32_t dec_word_bits[30]; + + // Decode each word in subframe + for (uint32_t ii = 0; ii < BEIDOU_DNAV_WORDS_SUBFRAME; ii++) + { + // decode the word + decode_word((ii + 1), &frame_symbols[ii * 30], dec_word_bits); + + // Save word to string format + for (uint32_t jj = 0; jj < (BEIDOU_DNAV_WORD_LENGTH_BITS); jj++) + { + data_bits.push_back((dec_word_bits[jj] > 0) ? ('1') : ('0')); + } + } + + if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) + { + d_nav.d2_subframe_decoder(data_bits); + } + else + { + d_nav.d1_subframe_decoder(data_bits); + } + + + // 3. Check operation executed correctly + if (d_nav.flag_crc_test == true) + { + LOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite; + } + else + { + LOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel << " from satellite " << d_satellite; + } + // 4. Push the new navigation data to the queues + if (d_nav.have_new_ephemeris() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; + std::cout << "New BEIDOU B1I DNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << std::endl; + } + if (d_nav.have_new_utc_model() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "BEIDOU DNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite; + std::cout << "New BEIDOU B1I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << std::endl; + } + if (d_nav.have_new_iono() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "BEIDOU DNAV Iono have been received in channel" << d_channel << " from satellite " << d_satellite; + std::cout << "New BEIDOU B1I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " << d_satellite << std::endl; + } + if (d_nav.have_new_almanac() == true) + { + // uint32_t slot_nbr = d_nav.i_alm_satellite_PRN; + // std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); + // this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "BEIDOU DNAV Almanac have been received in channel" << d_channel << " from satellite " << d_satellite << std::endl; + std::cout << "New BEIDOU B1I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl; + } +} + + +void beidou_b1i_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + uint32_t sat_prn = 0; + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; + + // Update satellite information for DNAV decoder + sat_prn = d_satellite.get_PRN(); + d_nav.i_satellite_PRN = sat_prn; + + // Update tel dec parameters for D2 NAV Messages + if (sat_prn > 0 and sat_prn < 6) + { + // Clear values from previous declaration + volk_gnsssdr_free(d_preamble_samples); + volk_gnsssdr_free(d_secondary_code_symbols); + volk_gnsssdr_free(d_subframe_symbols); + + d_samples_per_symbol = (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS) / BEIDOU_D2NAV_SYMBOL_RATE_SPS; + d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; + d_secondary_code_symbols = nullptr; + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; + + // Setting samples of preamble code + int32_t n = 0; + for (int32_t i = 0; i < d_symbols_per_preamble; i++) + { + if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = 1; + n++; + } + } + else + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = -1; + n++; + } + } + } + + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble; + } +} + + +void beidou_b1i_telemetry_decoder_cc::set_channel(int32_t channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(std::to_string(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << ": exception opening Beidou TLM dump file. " << e.what(); + } + } + } +} + + +int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + int32_t corr_value = 0; + int32_t preamble_diff = 0; + + auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer + const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer + + Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output + current_symbol = in[0][0]; + d_symbol_history.push_back(current_symbol.Prompt_I); // add new symbol to the symbol queue + d_sample_counter++; // count for the processed samples + consume_each(1); + + d_flag_preamble = false; + + if (d_symbol_history.size() > d_required_symbols) + { + //******* preamble correlation ******** + for (int32_t i = 0; i < d_samples_per_preamble; i++) + { + if (d_symbol_history.at(i) < 0) // symbols clipping + { + corr_value -= d_preamble_samples[i]; + } + else + { + corr_value += d_preamble_samples[i]; + } + } + } + + //******* frame sync ****************** + if (d_stat == 0) // no preamble information + { + if (abs(corr_value) >= d_samples_per_preamble) + { + // Record the preamble sample stamp + d_preamble_index = d_sample_counter; + LOG(INFO) << "Preamble detection for BEIDOU B1I SAT " << this->d_satellite; + // Enter into frame pre-detection status + d_stat = 1; + } + } + else if (d_stat == 1) // possible preamble lock + { + if (abs(corr_value) >= d_samples_per_preamble) + { + // check preamble separation + preamble_diff = static_cast(d_sample_counter - d_preamble_index); + if (abs(preamble_diff - d_preamble_period_samples) == 0) + { + // try to decode frame + LOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B1I SAT " << this->d_satellite; + d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_stat = 2; + } + else + { + if (preamble_diff > d_preamble_period_samples) + { + d_stat = 0; // start again + } + DLOG(INFO) << "Failed BeiDou DNAV frame decoding for BeiDou B1I SAT " << this->d_satellite; + } + } + } + else if (d_stat == 2) // preamble acquired + { + if (d_sample_counter == d_preamble_index + static_cast(d_preamble_period_samples)) + { + // ******* SAMPLES TO SYMBOLS ******* + if (corr_value > 0) //normal PLL lock + { + int32_t k = 0; + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = 0; + // integrate samples into symbols + for (uint32_t m = 0; m < d_samples_per_symbol; m++) + { + if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] += d_symbol_history.at(i * d_samples_per_symbol + m); + } + else + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] += static_cast(d_secondary_code_symbols[k]) * d_symbol_history.at(i * d_samples_per_symbol + m); + k++; + k = k % BEIDOU_B1I_SECONDARY_CODE_LENGTH; + } + } + } + } + else // 180 deg. inverted carrier phase PLL lock + { + int32_t k = 0; + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = 0; + // integrate samples into symbols + for (uint32_t m = 0; m < d_samples_per_symbol; m++) + { + if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] -= d_symbol_history.at(i * d_samples_per_symbol + m); + } + else + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] -= static_cast(d_secondary_code_symbols[k]) * d_symbol_history.at(i * d_samples_per_symbol + m); + k++; + k = k % BEIDOU_B1I_SECONDARY_CODE_LENGTH; + } + } + } + } + + // call the decoder + decode_subframe(d_subframe_symbols); + + if (d_nav.flag_crc_test == true) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << "BeiDou DNAV frame sync found for SAT " << this->d_satellite; + } + } + else + { + d_CRC_error_counter++; + d_preamble_index = d_sample_counter; // record the preamble sample stamp + if (d_CRC_error_counter > CRC_ERROR_LIMIT) + { + LOG(INFO) << "BeiDou DNAV frame sync lost for SAT " << this->d_satellite; + d_flag_frame_sync = false; + d_stat = 0; + flag_SOW_set = false; + } + } + } + } + + // UPDATE GNSS SYNCHRO DATA + // 2. Add the telemetry decoder information + if (this->d_flag_preamble == true and d_nav.flag_new_SOW_available == true) + // update TOW at the preamble instant + { + // Reporting sow as gps time of week + d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + 14) * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * BEIDOU_B1I_CODE_PERIOD_MS); + flag_SOW_set = true; + d_nav.flag_new_SOW_available = false; + } + else // if there is not a new preamble, we define the TOW of the current symbol + { + d_TOW_at_current_symbol_ms += static_cast(BEIDOU_B1I_CODE_PERIOD_MS); + } + + + if (d_flag_frame_sync == true and flag_SOW_set == true) + { + current_symbol.Flag_valid_word = true; + } + else + { + current_symbol.Flag_valid_word = false; + } + + current_symbol.PRN = this->d_satellite.get_PRN(); + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + uint64_t tmp_ulong_int; + tmp_double = d_TOW_at_current_symbol_ms; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + tmp_double = 0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + } + } + + // remove used symbols from history + if (d_symbol_history.size() > d_required_symbols) + { + d_symbol_history.pop_front(); + } + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + + return 1; +} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h new file mode 100644 index 000000000..e1b0b02ec --- /dev/null +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h @@ -0,0 +1,124 @@ +/*! + * \file beidou_b1i_telemetry_decoder_cc.h + * \brief Implementation of an adapter of a BEIDOU BI1 DNAV data decoder block + * to a TelemetryDecoderInterface + * \details Code added as part of GSoC 2018 program. However new modifications included to mimic + * decoding of existing signals + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_CC_H +#define GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_CC_H + +#include "Beidou_B1I.h" +#include "beidou_dnav_almanac.h" +#include "beidou_dnav_ephemeris.h" +#include "beidou_dnav_navigation_message.h" +#include "beidou_dnav_utc_model.h" +#include "gnss_satellite.h" +#include "gnss_synchro.h" +#include +#include +#include + + +class beidou_b1i_telemetry_decoder_cc; + +using beidou_b1i_telemetry_decoder_cc_sptr = boost::shared_ptr; + +beidou_b1i_telemetry_decoder_cc_sptr beidou_b1i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); + +//!!!! edit +/*! + * \brief This class implements a block that decodes the GNAV data defined in BEIDOU ICD v5.1 + * \note Code added as part of GSoC 2018 program + * \see GLONASS ICD + * + */ +class beidou_b1i_telemetry_decoder_cc : public gr::block +{ +public: + ~beidou_b1i_telemetry_decoder_cc(); //!< Class destructor + void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN + void set_channel(int channel); //!< Set receiver's channel + + /*! + * \brief This is where all signal processing takes place + */ + int general_work(int noutput_items, gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); + +private: + friend beidou_b1i_telemetry_decoder_cc_sptr + beidou_b1i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); + beidou_b1i_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); + + void decode_subframe(double *symbols); + void decode_word(int32_t word_counter, const double *enc_word_symbols, int32_t *dec_word_symbols); + void decode_bch15_11_01(const int32_t *bits, int32_t *decbits); + + + // Preamble decoding + int32_t *d_preamble_samples; + int32_t *d_secondary_code_symbols; + uint32_t d_samples_per_symbol; + int32_t d_symbols_per_preamble; + int32_t d_samples_per_preamble; + int32_t d_preamble_period_samples; + double *d_subframe_symbols; + uint32_t d_required_symbols; + + // Storage for incoming data + std::deque d_symbol_history; + + // Variables for internal functionality + uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed + uint64_t d_preamble_index; // Index of sample number where preamble was found + uint32_t d_stat; // Status of decoder + bool d_flag_frame_sync; // Indicate when a frame sync is achieved + bool d_flag_preamble; // Flag indicating when preamble was found + int32_t d_CRC_error_counter; // Number of failed CRC operations + bool flag_SOW_set; // Indicates when time of week is set + + //!< Navigation Message variable + Beidou_Dnav_Navigation_Message d_nav; + + //!< Values to populate gnss synchronization structure + uint32_t d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; + bool Flag_valid_word; + + //!< Satellite Information and logging capacity + Gnss_Satellite d_satellite; + int32_t d_channel; + bool d_dump; + std::string d_dump_filename; + std::ofstream d_dump_file; +}; + +#endif diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc deleted file mode 100644 index 264646524..000000000 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc +++ /dev/null @@ -1,491 +0,0 @@ -/*! - * \file galileo_e1b_telemetry_decoder_cc.cc - * \brief Implementation of a Galileo INAV message demodulator block - * \author Mara Branzanti 2013. mara.branzanti(at)gmail.com - * \author Javier Arribas 2013. jarribas(at)cttc.es - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - - -#include "galileo_e1b_telemetry_decoder_cc.h" -#include "control_message_factory.h" -#include "convolutional.h" -#include "gnss_synchro.h" -#include -#include -#include -#include -#include - - -#define CRC_ERROR_LIMIT 6 - -using google::LogMessage; - - -galileo_e1b_telemetry_decoder_cc_sptr -galileo_e1b_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump) -{ - return galileo_e1b_telemetry_decoder_cc_sptr(new galileo_e1b_telemetry_decoder_cc(satellite, dump)); -} - - -void galileo_e1b_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits) -{ - Viterbi(page_part_bits, out0, state0, out1, state1, - page_part_symbols, KK, nn, DataLength); -} - - -void galileo_e1b_telemetry_decoder_cc::deinterleaver(int rows, int cols, double *in, double *out) -{ - for (int r = 0; r < rows; r++) - { - for (int c = 0; c < cols; c++) - { - out[c * rows + r] = in[r * cols + c]; - } - } -} - - -galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( - const Gnss_Satellite &satellite, - bool dump) : gr::block("galileo_e1b_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) -{ - // Ephemeris data port out - this->message_port_register_out(pmt::mp("telemetry")); - // initialize internal vars - d_dump = dump; - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "Initializing GALILEO E1B TELEMETRY PROCESSING"; - d_samples_per_symbol = (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS) / Galileo_E1_B_SYMBOL_RATE_BPS; - - // set the preamble - unsigned short int preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS] = GALILEO_INAV_PREAMBLE; - - d_symbols_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol; - - memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); - - // preamble bits to sampled symbols - d_preambles_symbols = static_cast(volk_gnsssdr_malloc(d_symbols_per_preamble * sizeof(int), volk_gnsssdr_get_alignment())); - int n = 0; - for (int i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++) - { - for (unsigned int j = 0; j < d_samples_per_symbol; j++) - { - if (d_preambles_bits[i] == 1) - { - d_preambles_symbols[n] = 1; - } - else - { - d_preambles_symbols[n] = -1; - } - n++; - } - } - d_sample_counter = 0; - d_stat = 0; - d_preamble_index = 0; - - d_flag_frame_sync = false; - - d_flag_parity = false; - d_TOW_at_current_symbol = 0; - delta_t = 0; - d_CRC_error_counter = 0; - flag_even_word_arrived = 0; - d_flag_preamble = false; - d_channel = 0; - flag_TOW_set = false; - - // vars for Viterbi decoder - int max_states = 1 << mm; /* 2^mm */ - g_encoder[0] = 121; // Polynomial G1 - g_encoder[1] = 91; // Polynomial G2 - out0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - /* create appropriate transition matrices */ - nsc_transit(out0, state0, 0, g_encoder, KK, nn); - nsc_transit(out1, state1, 1, g_encoder, KK, nn); -} - - -galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc() -{ - volk_gnsssdr_free(d_preambles_symbols); - volk_gnsssdr_free(out0); - volk_gnsssdr_free(out1); - volk_gnsssdr_free(state0); - volk_gnsssdr_free(state1); - if (d_dump_file.is_open() == true) - { - try - { - d_dump_file.close(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); - } - } -} - - -void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, int frame_length) -{ - double page_part_symbols_deint[frame_length]; - // 1. De-interleave - deinterleaver(GALILEO_INAV_INTERLEAVER_ROWS, GALILEO_INAV_INTERLEAVER_COLS, page_part_symbols, page_part_symbols_deint); - - // 2. Viterbi decoder - // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) - // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180� - for (int i = 0; i < frame_length; i++) - { - if ((i + 1) % 2 == 0) - { - page_part_symbols_deint[i] = -page_part_symbols_deint[i]; - } - } - - int page_part_bits[frame_length / 2]; - viterbi_decoder(page_part_symbols_deint, page_part_bits); - - // 3. Call the Galileo page decoder - std::string page_String; - for (int i = 0; i < (frame_length / 2); i++) - { - if (page_part_bits[i] > 0) - { - page_String.push_back('1'); - } - else - { - page_String.push_back('0'); - } - } - - if (page_part_bits[0] == 1) - { - // DECODE COMPLETE WORD (even + odd) and TEST CRC - d_nav.split_page(page_String, flag_even_word_arrived); - if (d_nav.flag_CRC_test == true) - { - LOG(INFO) << "Galileo E1 CRC correct in channel " << d_channel << " from satellite " << d_satellite; - //std::cout << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl; - } - else - { - std::cout << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite << std::endl; - LOG(INFO) << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite; - } - flag_even_word_arrived = 0; - } - else - { - // STORE HALF WORD (even page) - d_nav.split_page(page_String.c_str(), flag_even_word_arrived); - flag_even_word_arrived = 1; - } - - // 4. Push the new navigation data to the queues - if (d_nav.have_new_ephemeris() == true) - { - // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); - std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << std::endl; - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - if (d_nav.have_new_iono_and_GST() == true) - { - // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); - std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << std::endl; - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - if (d_nav.have_new_utc_model() == true) - { - // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); - std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << std::endl; - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - if (d_nav.have_new_almanac() == true) - { - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac()); - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - //debug - std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl; - DLOG(INFO) << "GPS_to_Galileo time conversion:"; - DLOG(INFO) << "A0G=" << tmp_obj->A_0G_10; - DLOG(INFO) << "A1G=" << tmp_obj->A_1G_10; - DLOG(INFO) << "T0G=" << tmp_obj->t_0G_10; - DLOG(INFO) << "WN_0G_10=" << tmp_obj->WN_0G_10; - DLOG(INFO) << "Current parameters:"; - DLOG(INFO) << "d_TOW_at_current_symbol=" << d_TOW_at_current_symbol; - DLOG(INFO) << "d_nav.WN_0=" << d_nav.WN_0; - delta_t = tmp_obj->A_0G_10 + tmp_obj->A_1G_10 * (d_TOW_at_current_symbol - tmp_obj->t_0G_10 + 604800 * (fmod((d_nav.WN_0 - tmp_obj->WN_0G_10), 64))); - DLOG(INFO) << "delta_t=" << delta_t << "[s]"; - } -} - - -void galileo_e1b_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; - DLOG(INFO) << "Navigation Satellite set to " << d_satellite; -} - - -void galileo_e1b_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - LOG(INFO) << "Navigation channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} - - -int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) -{ - int corr_value = 0; - int preamble_diff = 0; - - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer - const Gnss_Synchro **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - - Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output - current_symbol = in[0][0]; - d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue - d_sample_counter++; //count for the processed samples - consume_each(1); - - d_flag_preamble = false; - unsigned int required_symbols = GALILEO_INAV_PAGE_SYMBOLS + d_symbols_per_preamble; - - if (d_symbol_history.size() > required_symbols) - { - // TODO Optimize me! - //******* preamble correlation ******** - for (int i = 0; i < d_symbols_per_preamble; i++) - { - if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping - { - corr_value -= d_preambles_symbols[i]; - } - else - { - corr_value += d_preambles_symbols[i]; - } - } - } - - //******* frame sync ****************** - if (d_stat == 0) //no preamble information - { - if (abs(corr_value) >= d_symbols_per_preamble) - { - d_preamble_index = d_sample_counter; //record the preamble sample stamp - LOG(INFO) << "Preamble detection for Galileo satellite " << this->d_satellite; - d_stat = 1; // enter into frame pre-detection status - } - } - else if (d_stat == 1) // possible preamble lock - { - if (abs(corr_value) >= d_symbols_per_preamble) - { - //check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; - if (abs(preamble_diff - GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) == 0) - { - //try to decode frame - LOG(INFO) << "Starting page decoder for Galileo satellite " << this->d_satellite; - d_preamble_index = d_sample_counter; //record the preamble sample stamp - d_stat = 2; - } - else - { - if (preamble_diff > GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) - { - d_stat = 0; // start again - } - } - } - } - else if (d_stat == 2) - { - if (d_sample_counter == d_preamble_index + GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) - { - // NEW Galileo page part is received - // 0. fetch the symbols into an array - int frame_length = GALILEO_INAV_PAGE_PART_SYMBOLS - d_symbols_per_preamble; - double page_part_symbols[frame_length]; - - for (int i = 0; i < frame_length; i++) - { - if (corr_value > 0) - { - page_part_symbols[i] = d_symbol_history.at(i + d_symbols_per_preamble).Prompt_I; // because last symbol of the preamble is just received now! - } - else - { - page_part_symbols[i] = -d_symbol_history.at(i + d_symbols_per_preamble).Prompt_I; // because last symbol of the preamble is just received now! - } - } - - //call the decoder - decode_word(page_part_symbols, frame_length); - if (d_nav.flag_CRC_test == true) - { - d_CRC_error_counter = 0; - d_flag_preamble = true; //valid preamble indicator (initialized to false every work()) - d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P) - if (!d_flag_frame_sync) - { - d_flag_frame_sync = true; - DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " - << d_symbol_history.at(0).Tracking_sample_counter << " [samples]"; - } - } - else - { - d_CRC_error_counter++; - d_preamble_index = d_sample_counter; //record the preamble sample stamp - if (d_CRC_error_counter > CRC_ERROR_LIMIT) - { - LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; - d_flag_frame_sync = false; - d_stat = 0; - } - } - } - } - - // UPDATE GNSS SYNCHRO DATA - //2. Add the telemetry decoder information - if (this->d_flag_preamble == true and d_nav.flag_TOW_set == true) - //update TOW at the preamble instant - { - if (d_nav.flag_TOW_5 == true) //page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) - { - //TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay - d_TOW_at_current_symbol = d_nav.TOW_5 + static_cast(GALILEO_INAV_PAGE_PART_SECONDS) + static_cast(required_symbols - 1) * GALILEO_E1_CODE_PERIOD; //-GALILEO_E1_CODE_PERIOD;//+ (double)GALILEO_INAV_PREAMBLE_LENGTH_BITS/(double)GALILEO_TELEMETRY_RATE_BITS_SECOND; - d_nav.flag_TOW_5 = false; - } - - else if (d_nav.flag_TOW_6 == true) //page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) - { - //TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay - d_TOW_at_current_symbol = d_nav.TOW_6 + static_cast(GALILEO_INAV_PAGE_PART_SECONDS) + static_cast(required_symbols - 1) * GALILEO_E1_CODE_PERIOD; //-GALILEO_E1_CODE_PERIOD;//+ (double)GALILEO_INAV_PREAMBLE_LENGTH_BITS/(double)GALILEO_TELEMETRY_RATE_BITS_SECOND; - d_nav.flag_TOW_6 = false; - } - else - { - //this page has no timing information - d_TOW_at_current_symbol += GALILEO_E1_CODE_PERIOD; // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD; - } - } - else //if there is not a new preamble, we define the TOW of the current symbol - { - d_TOW_at_current_symbol += GALILEO_E1_CODE_PERIOD; - } - - //if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) - - if (d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) //all GGTO parameters arrived - { - delta_t = d_nav.A_0G_10 + d_nav.A_1G_10 * (d_TOW_at_current_symbol - d_nav.t_0G_10 + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G_10), 64.0))); - } - - if (d_flag_frame_sync == true and d_nav.flag_TOW_set == true) - { - current_symbol.Flag_valid_word = true; - } - else - { - current_symbol.Flag_valid_word = false; - } - - current_symbol.TOW_at_current_symbol_s = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0; - current_symbol.TOW_at_current_symbol_s -= delta_t; //Galileo to GPS TOW - - if (d_dump == true) - { - // MULTIPLEXED FILE RECORDING - Record results to file - try - { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = d_TOW_at_current_symbol; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = 0; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); - } - } - - // remove used symbols from history - if (d_symbol_history.size() > required_symbols) - { - d_symbol_history.pop_front(); - } - //3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; - //std::cout<<"GPS L1 TLM output on CH="<d_channel << " SAMPLE STAMP="<. - * - * ------------------------------------------------------------------------- - */ - -#ifndef GNSS_SDR_GALILEO_E1B_TELEMETRY_DECODER_CC_H -#define GNSS_SDR_GALILEO_E1B_TELEMETRY_DECODER_CC_H - - -#include "Galileo_E1.h" -#include "galileo_navigation_message.h" -#include "galileo_ephemeris.h" -#include "galileo_almanac.h" -#include "galileo_iono.h" -#include "galileo_utc_model.h" -#include "gnss_satellite.h" -#include "gnss_synchro.h" -#include -#include -#include - - -class galileo_e1b_telemetry_decoder_cc; - -typedef boost::shared_ptr galileo_e1b_telemetry_decoder_cc_sptr; - -galileo_e1b_telemetry_decoder_cc_sptr galileo_e1b_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - -/*! - * \brief This class implements a block that decodes the INAV data defined in Galileo ICD - * - */ -class galileo_e1b_telemetry_decoder_cc : public gr::block -{ -public: - ~galileo_e1b_telemetry_decoder_cc(); - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel - int flag_even_word_arrived; - - /*! - * \brief This is where all signal processing takes place - */ - int general_work(int noutput_items, gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - -private: - friend galileo_e1b_telemetry_decoder_cc_sptr - galileo_e1b_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - galileo_e1b_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - - void viterbi_decoder(double *page_part_symbols, int *page_part_bits); - - void deinterleaver(int rows, int cols, double *in, double *out); - - void decode_word(double *symbols, int frame_length); - - unsigned short int d_preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS]; - - int *d_preambles_symbols; - unsigned int d_samples_per_symbol; - int d_symbols_per_preamble; - - std::deque d_symbol_history; - - long unsigned int d_sample_counter; - long unsigned int d_preamble_index; - unsigned int d_stat; - bool d_flag_frame_sync; - - bool d_flag_parity; - bool d_flag_preamble; - int d_CRC_error_counter; - - // navigation message vars - Galileo_Navigation_Message d_nav; - - bool d_dump; - Gnss_Satellite d_satellite; - int d_channel; - - double d_TOW_at_current_symbol; - - bool flag_TOW_set; - double delta_t; //GPS-GALILEO time offset - - std::string d_dump_filename; - std::ofstream d_dump_file; - - // vars for Viterbi decoder - int *out0, *out1, *state0, *state1; - int g_encoder[2]; - const int nn = 2; // Coding rate 1/n - const int KK = 7; // Constraint Length - int mm = KK - 1; - const int CodeLength = 240; - int DataLength = (CodeLength / nn) - mm; -}; - -#endif diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc deleted file mode 100644 index 3b3739248..000000000 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ /dev/null @@ -1,509 +0,0 @@ -/*! - * \file galileo_e5a_telemetry_decoder_cc.cc - * \brief Implementation of a Galileo FNAV message demodulator block - * \author Marc Sales, 2014. marcsales92(at)gmail.com - * Javier Arribas, 2017. jarribas(at)cttc.es - * \based on work from: - *
                  - *
                • Javier Arribas, 2011. jarribas(at)cttc.es - *
                - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include "galileo_e5a_telemetry_decoder_cc.h" -#include "control_message_factory.h" -#include "convolutional.h" -#include "display.h" -#include -#include -#include -#include -#include -#include - - -#define GALILEO_E5a_CRC_ERROR_LIMIT 6 - -using google::LogMessage; - - -galileo_e5a_telemetry_decoder_cc_sptr -galileo_e5a_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump) -{ - return galileo_e5a_telemetry_decoder_cc_sptr(new galileo_e5a_telemetry_decoder_cc(satellite, dump)); -} - - -void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits) -{ - Viterbi(page_part_bits, out0, state0, out1, state1, - page_part_symbols, KK, nn, DataLength); -} - - -void galileo_e5a_telemetry_decoder_cc::deinterleaver(int rows, int cols, double *in, double *out) -{ - for (int r = 0; r < rows; r++) - { - for (int c = 0; c < cols; c++) - { - out[c * rows + r] = in[r * cols + c]; - } - } -} - - -void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int frame_length) -{ - double page_symbols_deint[frame_length]; - // 1. De-interleave - deinterleaver(GALILEO_FNAV_INTERLEAVER_ROWS, GALILEO_FNAV_INTERLEAVER_COLS, page_symbols, page_symbols_deint); - - // 2. Viterbi decoder - // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) - // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180� - for (int i = 0; i < frame_length; i++) - { - if ((i + 1) % 2 == 0) - { - page_symbols_deint[i] = -page_symbols_deint[i]; - } - } - int page_bits[frame_length / 2]; - viterbi_decoder(page_symbols_deint, page_bits); - - // 3. Call the Galileo page decoder - std::string page_String; - for (int i = 0; i < frame_length; i++) - { - if (page_bits[i] > 0) - { - page_String.push_back('1'); - } - else - { - page_String.push_back('0'); - } - } - - // DECODE COMPLETE WORD (even + odd) and TEST CRC - d_nav.split_page(page_String); - if (d_nav.flag_CRC_test == true) - { - LOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite; - } - else - { - std::cout << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite << std::endl; - LOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite; - } - - // 4. Push the new navigation data to the queues - if (d_nav.have_new_ephemeris() == true) - { - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); - std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - if (d_nav.have_new_iono_and_GST() == true) - { - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); - std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - if (d_nav.have_new_utc_model() == true) - { - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); - std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } -} - - -galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( - const Gnss_Satellite &satellite, bool dump) : gr::block("galileo_e5a_telemetry_decoder_cc", - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) -{ - // Ephemeris data port out - this->message_port_register_out(pmt::mp("telemetry")); - // initialize internal vars - d_dump = dump; - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "GALILEO E5A TELEMETRY PROCESSING: satellite " << d_satellite; - - // set the preamble - for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) - { - if (GALILEO_FNAV_PREAMBLE.at(i) == '0') - { - d_preambles_bits[i] = 1; - } - else - { - d_preambles_bits[i] = -1; - } - } - for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) - { - for (int k = 0; k < GALILEO_FNAV_CODES_PER_SYMBOL; k++) - { - d_preamble_samples[(i * GALILEO_FNAV_CODES_PER_SYMBOL) + k] = d_preambles_bits[i]; - } - } - - d_sample_counter = 0; - d_stat = 0; - corr_value = 0; - d_flag_preamble = false; - d_preamble_index = 0; - d_flag_frame_sync = false; - d_TOW_at_current_symbol = 0.0; - flag_TOW_set = false; - d_CRC_error_counter = 0; - d_channel = 0; - delta_t = 0.0; - d_symbol_counter = 0; - d_prompt_acum = 0.0; - flag_bit_start = true; - new_symbol = false; - required_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS; - - // vars for Viterbi decoder - int max_states = 1 << mm; // 2^mm - g_encoder[0] = 121; // Polynomial G1 - g_encoder[1] = 91; // Polynomial G2 - out0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - // create appropriate transition matrices - nsc_transit(out0, state0, 0, g_encoder, KK, nn); - nsc_transit(out1, state1, 1, g_encoder, KK, nn); -} - - -galileo_e5a_telemetry_decoder_cc::~galileo_e5a_telemetry_decoder_cc() -{ - volk_gnsssdr_free(out0); - volk_gnsssdr_free(out1); - volk_gnsssdr_free(state0); - volk_gnsssdr_free(state1); - if (d_dump_file.is_open() == true) - { - try - { - d_dump_file.close(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); - } - } -} - - -void galileo_e5a_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; - DLOG(INFO) << "Navigation Satellite set to " << d_satellite; -} - - -void galileo_e5a_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - LOG(INFO) << "Navigation channel set to " << channel; - // Enable data file logging - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} - - -int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) -{ - int preamble_diff = 0; - - Gnss_Synchro *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer - const Gnss_Synchro *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer - - // 1. Copy the current tracking output - Gnss_Synchro current_sample = in[0]; - d_symbol_counter++; - if (flag_bit_start) - { - d_prompt_acum += current_sample.Prompt_I; - if (d_symbol_counter == GALILEO_FNAV_CODES_PER_SYMBOL) - { - current_sample.Prompt_I = d_prompt_acum / static_cast(GALILEO_FNAV_CODES_PER_SYMBOL); - d_symbol_history.push_back(current_sample); // add new symbol to the symbol queue - d_prompt_acum = 0.0; - d_symbol_counter = 0; - new_symbol = true; - } - } - else - { - if (current_sample.Prompt_I < 0.0) - { - d_preamble_init.push_back(1); - } - else - { - d_preamble_init.push_back(-1); - } - - if (d_preamble_init.size() == GALILEO_FNAV_CODES_PER_PREAMBLE) - { - std::deque::iterator iter; - int k = 0; - corr_value = 0; - for (iter = d_preamble_init.begin(); iter != d_preamble_init.end(); iter++) - { - corr_value += *iter * d_preamble_samples[k]; - k++; - } - if (abs(corr_value) == GALILEO_FNAV_CODES_PER_PREAMBLE) - { - d_symbol_counter = 0; - flag_bit_start = true; - corr_value = 0; - d_preamble_init.clear(); - d_symbol_history.clear(); - LOG(INFO) << "Bit start sync for Galileo E5a satellite " << d_satellite; - } - else - { - d_preamble_init.pop_front(); - } - } - } - d_sample_counter++; // count for the processed samples - consume_each(1); - - d_flag_preamble = false; - - if ((d_symbol_history.size() > required_symbols) && new_symbol) - { - // ****************** Preamble orrelation ****************** - corr_value = 0; - for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) - { - if (d_symbol_history.at(i).Prompt_I < 0.0) // symbols clipping - { - corr_value -= d_preambles_bits[i]; - } - else - { - corr_value += d_preambles_bits[i]; - } - } - } - // ****************** Frame sync ****************** - if ((d_stat == 0) && new_symbol) // no preamble information - { - if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS) - { - d_preamble_index = d_sample_counter; // record the preamble sample stamp - LOG(INFO) << "Preamble detection for Galileo E5a satellite " << d_satellite; - d_stat = 1; // enter into frame pre-detection status - } - } - else if ((d_stat == 1) && new_symbol) // possible preamble lock - { - if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS) - { - // check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; - if (preamble_diff == GALILEO_FNAV_CODES_PER_PAGE) - { - // try to decode frame - LOG(INFO) << "Starting page decoder for Galileo E5a satellite " << d_satellite; - d_preamble_index = d_sample_counter; // record the preamble sample stamp - d_stat = 2; - } - else if (preamble_diff > GALILEO_FNAV_CODES_PER_PAGE) - { - d_stat = 0; // start again - flag_bit_start = false; - LOG(INFO) << "Preamble diff = " << preamble_diff; - } - } - } - else if ((d_stat == 2) && new_symbol) - { - if (d_sample_counter == (d_preamble_index + GALILEO_FNAV_CODES_PER_PAGE)) - { - // NEW Galileo page part is received - // 0. fetch the symbols into an array - int frame_length = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS; - double corr_sign = 0.0; - if (corr_value > 0) - { - corr_sign = -1.0; - } - else - { - corr_sign = 1.0; - } - for (int i = 0; i < frame_length; i++) - { - page_symbols[i] = corr_sign * d_symbol_history.at(i + GALILEO_FNAV_PREAMBLE_LENGTH_BITS).Prompt_I; // because last symbol of the preamble is just received now! - } - - // call the decoder - decode_word(page_symbols, frame_length); - if (d_nav.flag_CRC_test == true) - { - d_CRC_error_counter = 0; - d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) - d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) - if (!d_flag_frame_sync) - { - d_flag_frame_sync = true; - DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " - << d_symbol_history.at(0).Tracking_sample_counter << " [samples]"; - } - } - else - { - d_CRC_error_counter++; - d_preamble_index = d_sample_counter; // record the preamble sample stamp - if (d_CRC_error_counter > GALILEO_E5A_CRC_ERROR_LIMIT) - { - LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; - d_flag_frame_sync = false; - d_stat = 0; - flag_bit_start = false; - } - } - } - } - new_symbol = false; - - // UPDATE GNSS SYNCHRO DATA - // Add the telemetry decoder information - if (d_flag_preamble and d_nav.flag_TOW_set) - // update TOW at the preamble instant - // We expect a preamble each 10 seconds (FNAV page period) - { - if (d_nav.flag_TOW_1 == true) - { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_1 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); - d_nav.flag_TOW_1 = false; - } - else if (d_nav.flag_TOW_2 == true) - { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_2 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); - d_nav.flag_TOW_2 = false; - } - else if (d_nav.flag_TOW_3 == true) - { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_3 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); - d_nav.flag_TOW_3 = false; - } - else if (d_nav.flag_TOW_4 == true) - { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_4 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); - d_nav.flag_TOW_4 = false; - } - else - { - d_TOW_at_current_symbol += GALILEO_E5a_CODE_PERIOD; - } - } - else // if there is not a new preamble, we define the TOW of the current symbol - { - d_TOW_at_current_symbol += GALILEO_E5a_CODE_PERIOD; - } - - //if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) - if (d_flag_frame_sync and d_nav.flag_TOW_set) - { - current_sample.Flag_valid_word = true; - } - else - { - current_sample.Flag_valid_word = false; - } - - current_sample.TOW_at_current_symbol_s = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0; - - if (d_dump) - { - // MULTIPLEXED FILE RECORDING - Record results to file - try - { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = d_TOW_at_current_symbol; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_sample.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = 0.0; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing Galileo E5a Telemetry Decoder dump file " << e.what(); - } - } - // remove used symbols from history - while (d_symbol_history.size() > required_symbols) - { - d_symbol_history.pop_front(); - } - // 3. Make the output - if (current_sample.Flag_valid_word) - { - out[0] = current_sample; - return 1; - } - else - { - return 0; - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h deleted file mode 100644 index 32400ca01..000000000 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h +++ /dev/null @@ -1,126 +0,0 @@ -/*! - * \file galileo_e5a_telemetry_decoder_cc.cc - * \brief Implementation of a Galileo FNAV message demodulator block - * \author Marc Sales, 2014. marcsales92(at)gmail.com - * Javier Arribas, 2017. jarribas(at)cttc.es - * \based on work from: - *
                  - *
                • Javier Arribas, 2011. jarribas(at)cttc.es - *
                - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#ifndef GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ -#define GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ - -#include "Galileo_E5a.h" -#include "gnss_satellite.h" -#include "galileo_fnav_message.h" -#include "galileo_ephemeris.h" -#include "galileo_almanac.h" -#include "galileo_iono.h" -#include "galileo_utc_model.h" -#include "gnss_synchro.h" -#include -#include -#include -#include - - -class galileo_e5a_telemetry_decoder_cc; - -typedef boost::shared_ptr galileo_e5a_telemetry_decoder_cc_sptr; - -galileo_e5a_telemetry_decoder_cc_sptr galileo_e5a_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - - -/*! - * \brief This class implements a block that decodes the FNAV data defined in Galileo ICD - * - */ -class galileo_e5a_telemetry_decoder_cc : public gr::block -{ -public: - ~galileo_e5a_telemetry_decoder_cc(); - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel - /*! - * \brief This is where all signal processing takes place - */ - int general_work(int noutput_items, gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - -private: - friend galileo_e5a_telemetry_decoder_cc_sptr - galileo_e5a_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - galileo_e5a_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - - void viterbi_decoder(double *page_part_symbols, int *page_part_bits); - - void deinterleaver(int rows, int cols, double *in, double *out); - - void decode_word(double *page_symbols, int frame_length); - - int d_preambles_bits[GALILEO_FNAV_PREAMBLE_LENGTH_BITS]; - int d_preamble_samples[GALILEO_FNAV_CODES_PER_PREAMBLE]; - std::deque d_preamble_init; - int d_stat; - int d_CRC_error_counter; - int d_channel; - int d_symbol_counter; - int corr_value; - unsigned int required_symbols; - long unsigned int d_sample_counter; - long unsigned int d_preamble_index; - bool d_flag_frame_sync; - bool d_flag_preamble; - bool d_dump; - bool flag_TOW_set; - bool flag_bit_start; - bool new_symbol; - double d_prompt_acum; - double page_symbols[GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS]; - double d_TOW_at_current_symbol; - double delta_t; //GPS-GALILEO time offset - std::string d_dump_filename; - std::ofstream d_dump_file; - std::deque d_symbol_history; - Gnss_Satellite d_satellite; - // navigation message vars - Galileo_Fnav_Message d_nav; - - // vars for Viterbi decoder - int *out0, *out1, *state0, *state1; - int g_encoder[2]; - const int nn = 2; // Coding rate 1/n - const int KK = 7; // Constraint Length - int mm = KK - 1; - const int CodeLength = 488; - int DataLength = (CodeLength / nn) - mm; -}; - -#endif /* GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ */ diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc new file mode 100644 index 000000000..f2b4a3896 --- /dev/null +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc @@ -0,0 +1,783 @@ +/*! + * \file galileo_telemetry_decoder_cc.cc + * \brief Implementation of a Galileo unified INAV and FNAV message demodulator block + * \author Javier Arribas 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "galileo_telemetry_decoder_cc.h" +#include "convolutional.h" +#include "display.h" +#include "gnss_synchro.h" +#include +#include +#include +#include +#include + + +#define CRC_ERROR_LIMIT 6 + +using google::LogMessage; + + +galileo_telemetry_decoder_cc_sptr +galileo_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, int frame_type, bool dump) +{ + return galileo_telemetry_decoder_cc_sptr(new galileo_telemetry_decoder_cc(satellite, frame_type, dump)); +} + + +void galileo_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits) +{ + Viterbi(page_part_bits, out0, state0, out1, state1, + page_part_symbols, KK, nn, DataLength); +} + + +void galileo_telemetry_decoder_cc::deinterleaver(int32_t rows, int32_t cols, const double *in, double *out) +{ + for (int32_t r = 0; r < rows; r++) + { + for (int32_t c = 0; c < cols; c++) + { + out[c * rows + r] = in[r * cols + c]; + } + } +} + + +galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc( + const Gnss_Satellite &satellite, int frame_type, + bool dump) : gr::block("galileo_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Ephemeris data port out + this->message_port_register_out(pmt::mp("telemetry")); + // initialize internal vars + d_dump = dump; + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + d_frame_type = frame_type; + LOG(INFO) << "Initializing GALILEO UNIFIED TELEMETRY DECODER"; + + switch (d_frame_type) + { + case 1: // INAV + { + d_PRN_code_period_ms = static_cast(GALILEO_E1_CODE_PERIOD_MS); + d_samples_per_symbol = GALILEO_E1_B_SAMPLES_PER_SYMBOL; + d_bits_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS; + // set the preamble + d_samples_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol; + d_preamble_period_symbols = GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS; + d_required_symbols = static_cast(GALILEO_INAV_PAGE_SYMBOLS) + d_samples_per_preamble; + // preamble bits to sampled symbols + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_secondary_code_samples = nullptr; + d_frame_length_symbols = GALILEO_INAV_PAGE_PART_SYMBOLS - GALILEO_INAV_PREAMBLE_LENGTH_BITS; + CodeLength = GALILEO_INAV_PAGE_PART_SYMBOLS - GALILEO_INAV_PREAMBLE_LENGTH_BITS; + DataLength = (CodeLength / nn) - mm; + break; + } + case 2: // FNAV + { + d_PRN_code_period_ms = static_cast(GALILEO_E5A_CODE_PERIOD_MS); + d_samples_per_symbol = GALILEO_FNAV_CODES_PER_SYMBOL; + d_bits_per_preamble = GALILEO_FNAV_PREAMBLE_LENGTH_BITS; + // set the preamble + d_samples_per_preamble = GALILEO_FNAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol; + d_preamble_period_symbols = GALILEO_FNAV_CODES_PER_PAGE; + d_required_symbols = static_cast(GALILEO_FNAV_SYMBOLS_PER_PAGE) * d_samples_per_symbol + d_samples_per_preamble; + // preamble bits to sampled symbols + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_secondary_code_samples = static_cast(volk_gnsssdr_malloc(GALILEO_E5A_I_SECONDARY_CODE_LENGTH * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_frame_length_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS; + CodeLength = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS; + DataLength = (CodeLength / nn) - mm; + for (int32_t i = 0; i < GALILEO_E5A_I_SECONDARY_CODE_LENGTH; i++) + { + if (GALILEO_E5A_I_SECONDARY_CODE.at(i) == '1') + { + d_secondary_code_samples[i] = 1; + } + else + { + d_secondary_code_samples[i] = -1; + } + } + break; + } + default: + d_bits_per_preamble = 0; + d_samples_per_preamble = 0; + d_preamble_period_symbols = 0; + d_preamble_samples = nullptr; + d_secondary_code_samples = nullptr; + d_samples_per_symbol = 0U; + d_PRN_code_period_ms = 0U; + d_required_symbols = 0U; + d_frame_length_symbols = 0U; + CodeLength = 0; + DataLength = 0; + std::cout << "Galileo unified telemetry decoder error: Unknown frame type " << std::endl; + } + + d_page_part_symbols = static_cast(volk_gnsssdr_malloc(d_frame_length_symbols * sizeof(double), volk_gnsssdr_get_alignment())); + int32_t n = 0; + for (int32_t i = 0; i < d_bits_per_preamble; i++) + { + switch (d_frame_type) + { + case 1: // INAV + { + if (GALILEO_INAV_PREAMBLE.at(i) == '1') + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = 1; + n++; + } + } + else + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = -1; + n++; + } + } + break; + } + case 2: // FNAV for E5a-I + { + // Galileo E5a data channel (E5a-I) still has a secondary code + int m = 0; + if (GALILEO_FNAV_PREAMBLE.at(i) == '1') + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = d_secondary_code_samples[m]; + n++; + m++; + m = m % GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + } + } + else + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = -d_secondary_code_samples[m]; + n++; + m++; + m = m % GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + } + } + break; + } + } + } + d_sample_counter = 0ULL; + d_stat = 0; + d_preamble_index = 0ULL; + + d_flag_frame_sync = false; + + d_flag_parity = false; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; + delta_t = 0; + d_CRC_error_counter = 0; + flag_even_word_arrived = 0; + d_flag_preamble = false; + d_channel = 0; + flag_TOW_set = false; + + // vars for Viterbi decoder + int32_t max_states = 1 << mm; // 2^mm + g_encoder[0] = 121; // Polynomial G1 + g_encoder[1] = 91; // Polynomial G2 + out0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + // create appropriate transition matrices + nsc_transit(out0, state0, 0, g_encoder, KK, nn); + nsc_transit(out1, state1, 1, g_encoder, KK, nn); +} + + +galileo_telemetry_decoder_cc::~galileo_telemetry_decoder_cc() +{ + volk_gnsssdr_free(d_preamble_samples); + if (d_frame_type == 2) + { + volk_gnsssdr_free(d_secondary_code_samples); + } + volk_gnsssdr_free(d_page_part_symbols); + volk_gnsssdr_free(out0); + volk_gnsssdr_free(out1); + volk_gnsssdr_free(state0); + volk_gnsssdr_free(state1); + if (d_dump_file.is_open() == true) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); + } + } +} + + +void galileo_telemetry_decoder_cc::decode_INAV_word(double *page_part_symbols, int32_t frame_length) +{ + // 1. De-interleave + auto *page_part_symbols_deint = static_cast(volk_gnsssdr_malloc(frame_length * sizeof(double), volk_gnsssdr_get_alignment())); + deinterleaver(GALILEO_INAV_INTERLEAVER_ROWS, GALILEO_INAV_INTERLEAVER_COLS, page_part_symbols, page_part_symbols_deint); + + // 2. Viterbi decoder + // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) + // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180º + for (int32_t i = 0; i < frame_length; i++) + { + if ((i + 1) % 2 == 0) + { + page_part_symbols_deint[i] = -page_part_symbols_deint[i]; + } + } + + auto *page_part_bits = static_cast(volk_gnsssdr_malloc((frame_length / 2) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + viterbi_decoder(page_part_symbols_deint, page_part_bits); + volk_gnsssdr_free(page_part_symbols_deint); + + // 3. Call the Galileo page decoder + std::string page_String; + for (int32_t i = 0; i < (frame_length / 2); i++) + { + if (page_part_bits[i] > 0) + { + page_String.push_back('1'); + } + else + { + page_String.push_back('0'); + } + } + + if (page_part_bits[0] == 1) + { + // DECODE COMPLETE WORD (even + odd) and TEST CRC + d_inav_nav.split_page(page_String, flag_even_word_arrived); + if (d_inav_nav.flag_CRC_test == true) + { + LOG(INFO) << "Galileo E1 CRC correct in channel " << d_channel << " from satellite " << d_satellite; + } + else + { + LOG(INFO) << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite; + } + flag_even_word_arrived = 0; + } + else + { + // STORE HALF WORD (even page) + d_inav_nav.split_page(page_String, flag_even_word_arrived); + flag_even_word_arrived = 1; + } + volk_gnsssdr_free(page_part_bits); + + // 4. Push the new navigation data to the queues + if (d_inav_nav.have_new_ephemeris() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_ephemeris()); + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << std::endl; + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } + if (d_inav_nav.have_new_iono_and_GST() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_iono()); + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << std::endl; + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } + if (d_inav_nav.have_new_utc_model() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_utc_model()); + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << std::endl; + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + delta_t = tmp_obj->A_0G_10 + tmp_obj->A_1G_10 * (static_cast(d_TOW_at_current_symbol_ms) / 1000.0 - tmp_obj->t_0G_10 + 604800 * (fmod((d_inav_nav.WN_0 - tmp_obj->WN_0G_10), 64))); + DLOG(INFO) << "delta_t=" << delta_t << "[s]"; + } + if (d_inav_nav.have_new_almanac() == true) + { + std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_almanac()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + //debug + std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl; + DLOG(INFO) << "Current parameters:"; + DLOG(INFO) << "d_TOW_at_current_symbol_ms=" << d_TOW_at_current_symbol_ms; + DLOG(INFO) << "d_nav.WN_0=" << d_inav_nav.WN_0; + } +} + + +void galileo_telemetry_decoder_cc::decode_FNAV_word(double *page_symbols, int32_t frame_length) +{ + // 1. De-interleave + auto *page_symbols_deint = static_cast(volk_gnsssdr_malloc(frame_length * sizeof(double), volk_gnsssdr_get_alignment())); + deinterleaver(GALILEO_FNAV_INTERLEAVER_ROWS, GALILEO_FNAV_INTERLEAVER_COLS, page_symbols, page_symbols_deint); + + // 2. Viterbi decoder + // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) + // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180� + for (int32_t i = 0; i < frame_length; i++) + { + if ((i + 1) % 2 == 0) + { + page_symbols_deint[i] = -page_symbols_deint[i]; + } + } + auto *page_bits = static_cast(volk_gnsssdr_malloc((frame_length / 2) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + viterbi_decoder(page_symbols_deint, page_bits); + volk_gnsssdr_free(page_symbols_deint); + + // 3. Call the Galileo page decoder + std::string page_String; + for (int32_t i = 0; i < frame_length; i++) + { + if (page_bits[i] > 0) + { + page_String.push_back('1'); + } + else + { + page_String.push_back('0'); + } + } + volk_gnsssdr_free(page_bits); + + // DECODE COMPLETE WORD (even + odd) and TEST CRC + d_fnav_nav.split_page(page_String); + if (d_fnav_nav.flag_CRC_test == true) + { + LOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite; + } + else + { + LOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite; + } + + // 4. Push the new navigation data to the queues + if (d_fnav_nav.have_new_ephemeris() == true) + { + std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_ephemeris()); + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } + if (d_fnav_nav.have_new_iono_and_GST() == true) + { + std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_iono()); + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } + if (d_fnav_nav.have_new_utc_model() == true) + { + std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_utc_model()); + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } +} + + +void galileo_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; +} + + +void galileo_telemetry_decoder_cc::set_channel(int32_t channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(std::to_string(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + +int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + int32_t corr_value = 0; + int32_t preamble_diff = 0; + + auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer + const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer + + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output + current_symbol = in[0][0]; + // add new symbol to the symbol queue + d_symbol_history.push_back(current_symbol.Prompt_I); + d_sample_counter++; // count for the processed samples + consume_each(1); + d_flag_preamble = false; + + if (d_symbol_history.size() > d_required_symbols) + { + // TODO Optimize me! + // ******* preamble correlation ******** + for (int32_t i = 0; i < d_samples_per_preamble; i++) + { + if (d_symbol_history.at(i) < 0.0) // symbols clipping + { + corr_value -= d_preamble_samples[i]; + } + else + { + corr_value += d_preamble_samples[i]; + } + } + } + + // ******* frame sync ****************** + switch (d_stat) + { + case 0: // no preamble information + { + if (abs(corr_value) >= d_samples_per_preamble) + { + d_preamble_index = d_sample_counter; // record the preamble sample stamp + LOG(INFO) << "Preamble detection for Galileo satellite " << this->d_satellite; + d_stat = 1; // enter into frame pre-detection status + } + break; + } + case 1: // possible preamble lock + { + if (abs(corr_value) >= d_samples_per_preamble) + { + // check preamble separation + preamble_diff = static_cast(d_sample_counter - d_preamble_index); + if (abs(preamble_diff - d_preamble_period_symbols) == 0) + { + // try to decode frame + LOG(INFO) << "Starting page decoder for Galileo satellite " << this->d_satellite; + d_preamble_index = d_sample_counter; // record the preamble sample stamp + d_stat = 2; + } + else + { + if (preamble_diff > d_preamble_period_symbols) + { + d_stat = 0; // start again + } + } + } + break; + } + case 2: //preamble acquired + { + if (d_sample_counter == d_preamble_index + static_cast(d_preamble_period_symbols)) + { + // call the decoder + switch (d_frame_type) + { + case 1: // INAV + // NEW Galileo page part is received + // 0. fetch the symbols into an array + if (corr_value > 0) //normal PLL lock + { + for (uint32_t i = 0; i < d_frame_length_symbols; i++) + { + d_page_part_symbols[i] = d_symbol_history.at(i + d_samples_per_preamble); // because last symbol of the preamble is just received now! + } + } + else //180 deg. inverted carrier phase PLL lock + { + for (uint32_t i = 0; i < d_frame_length_symbols; i++) + { + d_page_part_symbols[i] = d_symbol_history.at(i + d_samples_per_preamble); // because last symbol of the preamble is just received now! + } + } + decode_INAV_word(d_page_part_symbols, d_frame_length_symbols); + break; + case 2: // FNAV + // NEW Galileo page part is received + // 0. fetch the symbols into an array + if (corr_value > 0) //normal PLL lock + { + int k = 0; + for (uint32_t i = 0; i < d_frame_length_symbols; i++) + { + d_page_part_symbols[i] = 0; + for (uint32_t m = 0; m < d_samples_per_symbol; m++) + { + d_page_part_symbols[i] += static_cast(d_secondary_code_samples[k]) * d_symbol_history.at(i * d_samples_per_symbol + d_samples_per_preamble + m); // because last symbol of the preamble is just received now! + k++; + k = k % GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + } + } + } + else //180 deg. inverted carrier phase PLL lock + { + int k = 0; + for (uint32_t i = 0; i < d_frame_length_symbols; i++) + { + d_page_part_symbols[i] = 0; + for (uint32_t m = 0; m < d_samples_per_symbol; m++) //integrate samples into symbols + { + d_page_part_symbols[i] -= static_cast(d_secondary_code_samples[k]) * d_symbol_history.at(i * d_samples_per_symbol + d_samples_per_preamble + m); // because last symbol of the preamble is just received now! + k++; + k = k % GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + } + } + } + decode_FNAV_word(d_page_part_symbols, d_frame_length_symbols); + break; + default: + return -1; + break; + } + + if (d_inav_nav.flag_CRC_test == true or d_fnav_nav.flag_CRC_test == true) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << " Frame sync SAT " << this->d_satellite; + } + } + else + { + d_CRC_error_counter++; + d_preamble_index = d_sample_counter; // record the preamble sample stamp + if (d_CRC_error_counter > CRC_ERROR_LIMIT) + { + LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; + d_flag_frame_sync = false; + d_stat = 0; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; + d_fnav_nav.flag_TOW_set = false; + d_inav_nav.flag_TOW_set = false; + } + } + } + break; + } + } + + // UPDATE GNSS SYNCHRO DATA + // 2. Add the telemetry decoder information + if (this->d_flag_preamble == true) + // update TOW at the preamble instant + { + switch (d_frame_type) + { + case 1: // INAV + { + if (d_inav_nav.flag_TOW_set == true) + { + if (d_inav_nav.flag_TOW_5 == true) // page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) + { + // TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay + d_TOW_at_Preamble_ms = static_cast(d_inav_nav.TOW_5 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS); + d_inav_nav.flag_TOW_5 = false; + } + + else if (d_inav_nav.flag_TOW_6 == true) // page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) + { + // TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay + d_TOW_at_Preamble_ms = static_cast(d_inav_nav.TOW_6 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS); + d_inav_nav.flag_TOW_6 = false; + } + else + { + // this page has no timing information + d_TOW_at_current_symbol_ms += static_cast(GALILEO_E1_CODE_PERIOD_MS); // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD; + } + } + break; + } + case 2: // FNAV + { + if (d_fnav_nav.flag_TOW_set == true) + { + if (d_fnav_nav.flag_TOW_1 == true) + { + d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.FNAV_TOW_1 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS); + //d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS); + d_fnav_nav.flag_TOW_1 = false; + } + else if (d_fnav_nav.flag_TOW_2 == true) + { + d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.FNAV_TOW_2 * 1000.0); + //d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS); + d_fnav_nav.flag_TOW_2 = false; + } + else if (d_fnav_nav.flag_TOW_3 == true) + { + d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.FNAV_TOW_3 * 1000.0); + //d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS); + d_fnav_nav.flag_TOW_3 = false; + } + else if (d_fnav_nav.flag_TOW_4 == true) + { + d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.FNAV_TOW_4 * 1000.0); + //d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS); + d_fnav_nav.flag_TOW_4 = false; + } + else + { + d_TOW_at_current_symbol_ms += static_cast(GALILEO_E5A_CODE_PERIOD_MS); + } + break; + } + } + } + } + else // if there is not a new preamble, we define the TOW of the current symbol + { + switch (d_frame_type) + { + case 1: // INAV + { + if (d_inav_nav.flag_TOW_set == true) + { + d_TOW_at_current_symbol_ms += d_PRN_code_period_ms; + } + break; + } + case 2: // FNAV + { + if (d_fnav_nav.flag_TOW_set == true) + { + d_TOW_at_current_symbol_ms += d_PRN_code_period_ms; + } + break; + } + } + } + + // remove used symbols from history + // todo: Use circular buffer here + if (d_symbol_history.size() > d_required_symbols) + { + d_symbol_history.pop_front(); + } + + switch (d_frame_type) + { + case 1: // INAV + { + if (d_inav_nav.flag_TOW_set) + { + if (d_inav_nav.flag_GGTO_1 == true and d_inav_nav.flag_GGTO_2 == true and d_inav_nav.flag_GGTO_3 == true and d_inav_nav.flag_GGTO_4 == true) // all GGTO parameters arrived + { + delta_t = d_inav_nav.A_0G_10 + d_inav_nav.A_1G_10 * (static_cast(d_TOW_at_current_symbol_ms) / 1000.0 - d_inav_nav.t_0G_10 + 604800.0 * (fmod((d_inav_nav.WN_0 - d_inav_nav.WN_0G_10), 64.0))); + } + + current_symbol.Flag_valid_word = true; + } + break; + } + + case 2: // FNAV + { + if (d_fnav_nav.flag_TOW_set) + { + current_symbol.Flag_valid_word = true; + } + break; + } + } + + if (d_inav_nav.flag_TOW_set or d_fnav_nav.flag_TOW_set) + { + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + // todo: Galileo to GPS time conversion should be moved to observable block. + // current_symbol.TOW_at_current_symbol_ms -= delta_t; //Galileo to GPS TOW + + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + uint64_t tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + } + } + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + return 1; + } + return 0; +} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h new file mode 100644 index 000000000..91aecd117 --- /dev/null +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h @@ -0,0 +1,136 @@ +/*! + * \file galileo_telemetry_decoder_cc.h + * \brief Implementation of a Galileo unified INAV and FNAV message demodulator block + * \author Javier Arribas 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_GALILEO_TELEMETRY_DECODER_CC_H +#define GNSS_SDR_GALILEO_TELEMETRY_DECODER_CC_H + + +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "galileo_almanac_helper.h" +#include "galileo_ephemeris.h" +#include "galileo_fnav_message.h" +#include "galileo_iono.h" +#include "galileo_navigation_message.h" +#include "galileo_utc_model.h" +#include "gnss_satellite.h" +#include "gnss_synchro.h" +#include +#include +#include + + +class galileo_telemetry_decoder_cc; + +using galileo_telemetry_decoder_cc_sptr = boost::shared_ptr; + +galileo_telemetry_decoder_cc_sptr galileo_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, int frame_type, bool dump); + +/*! + * \brief This class implements a block that decodes the INAV and FNAV data defined in Galileo ICD + */ +class galileo_telemetry_decoder_cc : public gr::block +{ +public: + ~galileo_telemetry_decoder_cc(); + void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN + void set_channel(int32_t channel); //!< Set receiver's channel + int32_t flag_even_word_arrived; + + /*! + * \brief This is where all signal processing takes place + */ + int general_work(int noutput_items, gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); + +private: + friend galileo_telemetry_decoder_cc_sptr + galileo_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, int frame_type, bool dump); + galileo_telemetry_decoder_cc(const Gnss_Satellite &satellite, int frame_type, bool dump); + + void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits); + + void deinterleaver(int32_t rows, int32_t cols, const double *in, double *out); + + void decode_INAV_word(double *page_part_symbols, int32_t frame_length); + void decode_FNAV_word(double *page_symbols, int32_t frame_length); + + int d_frame_type; + int32_t d_bits_per_preamble; + int32_t d_samples_per_preamble; + int32_t d_preamble_period_symbols; + int32_t *d_preamble_samples; + int32_t *d_secondary_code_samples; + uint32_t d_samples_per_symbol; + uint32_t d_PRN_code_period_ms; + uint32_t d_required_symbols; + uint32_t d_frame_length_symbols; + double *d_page_part_symbols; + + std::deque d_symbol_history; + + uint64_t d_sample_counter; + uint64_t d_preamble_index; + uint32_t d_stat; + bool d_flag_frame_sync; + + bool d_flag_parity; + bool d_flag_preamble; + int32_t d_CRC_error_counter; + + // navigation message vars + Galileo_Navigation_Message d_inav_nav; + Galileo_Fnav_Message d_fnav_nav; + + bool d_dump; + Gnss_Satellite d_satellite; + int32_t d_channel; + + uint32_t d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; + + bool flag_TOW_set; + double delta_t; //GPS-GALILEO time offset + + std::string d_dump_filename; + std::ofstream d_dump_file; + + // vars for Viterbi decoder + int32_t *out0, *out1, *state0, *state1; + int32_t g_encoder[2]{}; + const int32_t nn = 2; // Coding rate 1/n + const int32_t KK = 7; // Constraint Length + int32_t mm = KK - 1; + int32_t CodeLength; + int32_t DataLength; +}; + +#endif diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index baacf8fce..7ead9f53b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -33,8 +33,8 @@ #include "glonass_l1_ca_telemetry_decoder_cc.h" #include -#include #include +#include #define CRC_ERROR_LIMIT 6 @@ -61,24 +61,24 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); LOG(INFO) << "Initializing GLONASS L1 CA TELEMETRY DECODING"; // Define the number of sampes per symbol. Notice that GLONASS has 2 rates, - //one for the navigation data and the other for the preamble information + // one for the navigation data and the other for the preamble information d_samples_per_symbol = (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS) / GLONASS_L1_CA_SYMBOL_RATE_BPS; // Set the preamble information - unsigned short int preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; + uint16_t preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; // Since preamble rate is different than navigation data rate we use a constant d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; - memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); + memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t)); // preamble bits to sampled symbols - d_preambles_symbols = static_cast(malloc(sizeof(signed int) * d_symbols_per_preamble)); - int n = 0; - for (int i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++) + d_preambles_symbols = static_cast(malloc(sizeof(int32_t) * d_symbols_per_preamble)); + int32_t n = 0; + for (uint16_t d_preambles_bit : d_preambles_bits) { - for (unsigned int j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) + for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) { - if (d_preambles_bits[i] == 1) + if (d_preambles_bit == 1) { d_preambles_symbols[n] = 1; } @@ -89,9 +89,9 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( n++; } } - d_sample_counter = 0; + d_sample_counter = 0ULL; d_stat = 0; - d_preamble_index = 0; + d_preamble_index = 0ULL; d_flag_frame_sync = false; @@ -124,10 +124,10 @@ glonass_l1_ca_telemetry_decoder_cc::~glonass_l1_ca_telemetry_decoder_cc() } -void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int frame_length) +void glonass_l1_ca_telemetry_decoder_cc::decode_string(const double *frame_symbols, int32_t frame_length) { double chip_acc = 0.0; - int chip_acc_counter = 0; + int32_t chip_acc_counter = 0; // 1. Transform from symbols to bits std::string bi_binary_code; @@ -135,7 +135,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in std::string data_bits; // Group samples into bi-binary code - for (int i = 0; i < (frame_length); i++) + for (int32_t i = 0; i < (frame_length); i++) { chip_acc += frame_symbols[i]; chip_acc_counter += 1; @@ -157,7 +157,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } } // Convert from bi-binary code to relative code - for (int i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) { if (bi_binary_code[2 * i] == '1' && bi_binary_code[2 * i + 1] == '0') { @@ -170,7 +170,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } // Convert from relative code to data bits data_bits.push_back('0'); - for (int i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) { data_bits.push_back(((relative_code[i - 1] - '0') ^ (relative_code[i] - '0')) + '0'); } @@ -207,7 +207,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } if (d_nav.have_new_almanac() == true) { - unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; + uint32_t slot_nbr = d_nav.i_alm_satellite_slot_number; std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr; @@ -232,7 +232,7 @@ void glonass_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &sat } -void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel) +void glonass_l1_ca_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; @@ -244,7 +244,7 @@ void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel) try { d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -262,26 +262,26 @@ void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel) int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int corr_value = 0; - int preamble_diff = 0; + int32_t corr_value = 0; + int32_t preamble_diff = 0; - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer - const Gnss_Synchro **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer + auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer + const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output current_symbol = in[0][0]; - d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue - d_sample_counter++; //count for the processed samples + d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue + d_sample_counter++; // count for the processed samples consume_each(1); d_flag_preamble = false; - unsigned int required_symbols = GLONASS_GNAV_STRING_SYMBOLS; + uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS; if (d_symbol_history.size() > required_symbols) { - //******* preamble correlation ******** - for (int i = 0; i < d_symbols_per_preamble; i++) + // ******* preamble correlation ******** + for (int32_t i = 0; i < d_symbols_per_preamble; i++) { if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping { @@ -294,8 +294,8 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } } - //******* frame sync ****************** - if (d_stat == 0) //no preamble information + // ******* frame sync ****************** + if (d_stat == 0) // no preamble information { if (abs(corr_value) >= d_symbols_per_preamble) { @@ -311,15 +311,15 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { if (abs(corr_value) >= d_symbols_per_preamble) { - //check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; + // check preamble separation + preamble_diff = static_cast(d_sample_counter - d_preamble_index); // Record the PRN start sample index associated to the preamble - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; + d_preamble_time_samples = static_cast(d_symbol_history.at(0).Tracking_sample_counter); if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { - //try to decode frame + // try to decode frame LOG(INFO) << "Starting string decoder for GLONASS L1 C/A SAT " << this->d_satellite; - d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_preamble_index = d_sample_counter; // record the preamble sample stamp d_stat = 2; } else @@ -335,15 +335,15 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu else if (d_stat == 2) { // FIXME: The preamble index marks the first symbol of the string count. Here I just wait for another full string to be received before processing - if (d_sample_counter == d_preamble_index + GLONASS_GNAV_STRING_SYMBOLS) + if (d_sample_counter == d_preamble_index + static_cast(GLONASS_GNAV_STRING_SYMBOLS)) { // NEW GLONASS string received // 0. fetch the symbols into an array - int string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; + int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; double string_symbols[GLONASS_GNAV_DATA_SYMBOLS] = {0}; - //******* SYMBOL TO BIT ******* - for (int i = 0; i < string_length; i++) + // ******* SYMBOL TO BIT ******* + for (int32_t i = 0; i < string_length; i++) { if (corr_value > 0) { @@ -355,13 +355,13 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } } - //call the decoder + // call the decoder decode_string(string_symbols, string_length); if (d_nav.flag_CRC_test == true) { d_CRC_error_counter = 0; - d_flag_preamble = true; //valid preamble indicator (initialized to false every work()) - d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P) + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) if (!d_flag_frame_sync) { d_flag_frame_sync = true; @@ -372,7 +372,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu else { d_CRC_error_counter++; - d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_preamble_index = d_sample_counter; // record the preamble sample stamp if (d_CRC_error_counter > CRC_ERROR_LIMIT) { LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; @@ -384,21 +384,21 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } // UPDATE GNSS SYNCHRO DATA - //2. Add the telemetry decoder information + // 2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_nav.flag_TOW_new == true) - //update TOW at the preamble instant + // update TOW at the preamble instant { d_TOW_at_current_symbol = floor((d_nav.gnav_ephemeris.d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S) * 1000) / 1000; d_nav.flag_TOW_new = false; } - else //if there is not a new preamble, we define the TOW of the current symbol + else // if there is not a new preamble, we define the TOW of the current symbol { d_TOW_at_current_symbol = d_TOW_at_current_symbol + GLONASS_L1_CA_CODE_PERIOD; } - //if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) + // if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) - // if(d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) //all GGTO parameters arrived + // if(d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived // { // delta_t = d_nav.A_0G_10 + d_nav.A_1G_10 * (d_TOW_at_current_symbol - d_nav.t_0G_10 + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G_10), 64))); // } @@ -413,8 +413,9 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } current_symbol.PRN = this->d_satellite.get_PRN(); - current_symbol.TOW_at_current_symbol_s = d_TOW_at_current_symbol; - current_symbol.TOW_at_current_symbol_s -= delta_t; // Galileo to GPS TOW + current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); + // todo: glonass time to gps time should be done in observables block + // current_symbol.TOW_at_current_symbol_ms -= -= static_cast(delta_t) * 1000; // Galileo to GPS TOW if (d_dump == true) { @@ -422,11 +423,11 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu try { double tmp_double; - unsigned long int tmp_ulong_int; + uint64_t tmp_ulong_int; tmp_double = d_TOW_at_current_symbol; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); tmp_double = 0; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); } @@ -441,7 +442,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { d_symbol_history.pop_front(); } - //3. Make the output (copy the object contents to the GNURadio reserved memory) + // 3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; return 1; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h index fd3d8d5d8..01b8dcd5a 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h @@ -34,13 +34,13 @@ #define GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_CC_H -#include "glonass_gnav_navigation_message.h" -#include "glonass_gnav_ephemeris.h" +#include "GLONASS_L1_L2_CA.h" #include "glonass_gnav_almanac.h" +#include "glonass_gnav_ephemeris.h" +#include "glonass_gnav_navigation_message.h" #include "glonass_gnav_utc_model.h" #include "gnss_satellite.h" #include "gnss_synchro.h" -#include "GLONASS_L1_L2_CA.h" #include #include #include @@ -48,7 +48,7 @@ class glonass_l1_ca_telemetry_decoder_cc; -typedef boost::shared_ptr glonass_l1_ca_telemetry_decoder_cc_sptr; +using glonass_l1_ca_telemetry_decoder_cc_sptr = boost::shared_ptr; glonass_l1_ca_telemetry_decoder_cc_sptr glonass_l1_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -63,7 +63,7 @@ class glonass_l1_ca_telemetry_decoder_cc : public gr::block public: ~glonass_l1_ca_telemetry_decoder_cc(); //!< Class destructor void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -76,30 +76,30 @@ private: glonass_l1_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); glonass_l1_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void decode_string(double *symbols, int frame_length); + void decode_string(const double *symbols, int32_t frame_length); //!< Help with coherent tracking double d_preamble_time_samples; //!< Preamble decoding - unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; - int *d_preambles_symbols; - unsigned int d_samples_per_symbol; - int d_symbols_per_preamble; + uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{}; + int32_t *d_preambles_symbols; + uint32_t d_samples_per_symbol; + int32_t d_symbols_per_preamble; //!< Storage for incoming data std::deque d_symbol_history; //!< Variables for internal functionality - long unsigned int d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed - long unsigned int d_preamble_index; //!< Index of sample number where preamble was found - unsigned int d_stat; //!< Status of decoder - bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved - bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) - bool d_flag_preamble; //!< Flag indicating when preamble was found - int d_CRC_error_counter; //!< Number of failed CRC operations - bool flag_TOW_set; //!< Indicates when time of week is set - double delta_t; //!< GPS-GLONASS time offset + uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed + uint64_t d_preamble_index; //!< Index of sample number where preamble was found + uint32_t d_stat; //!< Status of decoder + bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved + bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) + bool d_flag_preamble; //!< Flag indicating when preamble was found + int32_t d_CRC_error_counter; //!< Number of failed CRC operations + bool flag_TOW_set; //!< Indicates when time of week is set + double delta_t; //!< GPS-GLONASS time offset //!< Navigation Message variable Glonass_Gnav_Navigation_Message d_nav; @@ -110,7 +110,7 @@ private: //!< Satellite Information and logging capacity Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; bool d_dump; std::string d_dump_filename; std::ofstream d_dump_file; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc index 0c8813694..b250fb912 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc @@ -61,24 +61,24 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); LOG(INFO) << "Initializing GLONASS L2 CA TELEMETRY DECODING"; // Define the number of sampes per symbol. Notice that GLONASS has 2 rates, - //one for the navigation data and the other for the preamble information + // one for the navigation data and the other for the preamble information d_samples_per_symbol = (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS) / GLONASS_L2_CA_SYMBOL_RATE_BPS; // Set the preamble information - unsigned short int preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; + uint16_t preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; // Since preamble rate is different than navigation data rate we use a constant d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; - memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); + memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t)); // preamble bits to sampled symbols - d_preambles_symbols = static_cast(malloc(sizeof(signed int) * d_symbols_per_preamble)); - int n = 0; - for (int i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++) + d_preambles_symbols = static_cast(malloc(sizeof(int32_t) * d_symbols_per_preamble)); + int32_t n = 0; + for (uint16_t d_preambles_bit : d_preambles_bits) { - for (unsigned int j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) + for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) { - if (d_preambles_bits[i] == 1) + if (d_preambles_bit == 1) { d_preambles_symbols[n] = 1; } @@ -89,9 +89,9 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( n++; } } - d_sample_counter = 0; + d_sample_counter = 0ULL; d_stat = 0; - d_preamble_index = 0; + d_preamble_index = 0ULL; d_flag_frame_sync = false; @@ -124,10 +124,10 @@ glonass_l2_ca_telemetry_decoder_cc::~glonass_l2_ca_telemetry_decoder_cc() } -void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int frame_length) +void glonass_l2_ca_telemetry_decoder_cc::decode_string(const double *frame_symbols, int32_t frame_length) { double chip_acc = 0.0; - int chip_acc_counter = 0; + int32_t chip_acc_counter = 0; // 1. Transform from symbols to bits std::string bi_binary_code; @@ -135,7 +135,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in std::string data_bits; // Group samples into bi-binary code - for (int i = 0; i < (frame_length); i++) + for (int32_t i = 0; i < (frame_length); i++) { chip_acc += frame_symbols[i]; chip_acc_counter += 1; @@ -157,7 +157,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } } // Convert from bi-binary code to relative code - for (int i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) { if (bi_binary_code[2 * i] == '1' && bi_binary_code[2 * i + 1] == '0') { @@ -170,7 +170,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } // Convert from relative code to data bits data_bits.push_back('0'); - for (int i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) { data_bits.push_back(((relative_code[i - 1] - '0') ^ (relative_code[i] - '0')) + '0'); } @@ -207,7 +207,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } if (d_nav.have_new_almanac() == true) { - unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; + uint32_t slot_nbr = d_nav.i_alm_satellite_slot_number; std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr; @@ -232,7 +232,7 @@ void glonass_l2_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &sat } -void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) +void glonass_l2_ca_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; @@ -244,7 +244,7 @@ void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) try { d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -262,26 +262,26 @@ void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int corr_value = 0; - int preamble_diff = 0; + int32_t corr_value = 0; + int32_t preamble_diff = 0; - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer - const Gnss_Synchro **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer + auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer + const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output current_symbol = in[0][0]; - d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue - d_sample_counter++; //count for the processed samples + d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue + d_sample_counter++; // count for the processed samples consume_each(1); d_flag_preamble = false; - unsigned int required_symbols = GLONASS_GNAV_STRING_SYMBOLS; + uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS; if (d_symbol_history.size() > required_symbols) { - //******* preamble correlation ******** - for (int i = 0; i < d_symbols_per_preamble; i++) + // ******* preamble correlation ******** + for (int32_t i = 0; i < d_symbols_per_preamble; i++) { if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping { @@ -294,8 +294,8 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } } - //******* frame sync ****************** - if (d_stat == 0) //no preamble information + // ******* frame sync ****************** + if (d_stat == 0) // no preamble information { if (abs(corr_value) >= d_symbols_per_preamble) { @@ -311,15 +311,15 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { if (abs(corr_value) >= d_symbols_per_preamble) { - //check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; + // check preamble separation + preamble_diff = static_cast(d_sample_counter - d_preamble_index); // Record the PRN start sample index associated to the preamble - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; + d_preamble_time_samples = static_cast(d_symbol_history.at(0).Tracking_sample_counter); if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { - //try to decode frame + // try to decode frame LOG(INFO) << "Starting string decoder for GLONASS L2 C/A SAT " << this->d_satellite; - d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_preamble_index = d_sample_counter; // record the preamble sample stamp d_stat = 2; } else @@ -335,15 +335,15 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu else if (d_stat == 2) { // FIXME: The preamble index marks the first symbol of the string count. Here I just wait for another full string to be received before processing - if (d_sample_counter == d_preamble_index + GLONASS_GNAV_STRING_SYMBOLS) + if (d_sample_counter == d_preamble_index + static_cast(GLONASS_GNAV_STRING_SYMBOLS)) { // NEW GLONASS string received // 0. fetch the symbols into an array - int string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; + int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; double string_symbols[GLONASS_GNAV_DATA_SYMBOLS] = {0}; - //******* SYMBOL TO BIT ******* - for (int i = 0; i < string_length; i++) + // ******* SYMBOL TO BIT ******* + for (int32_t i = 0; i < string_length; i++) { if (corr_value > 0) { @@ -355,13 +355,13 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } } - //call the decoder + // call the decoder decode_string(string_symbols, string_length); if (d_nav.flag_CRC_test == true) { d_CRC_error_counter = 0; - d_flag_preamble = true; //valid preamble indicator (initialized to false every work()) - d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P) + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) if (!d_flag_frame_sync) { d_flag_frame_sync = true; @@ -372,7 +372,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu else { d_CRC_error_counter++; - d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_preamble_index = d_sample_counter; // record the preamble sample stamp if (d_CRC_error_counter > CRC_ERROR_LIMIT) { LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; @@ -384,21 +384,21 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } // UPDATE GNSS SYNCHRO DATA - //2. Add the telemetry decoder information + // 2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_nav.flag_TOW_new == true) - //update TOW at the preamble instant + // update TOW at the preamble instant { d_TOW_at_current_symbol = floor((d_nav.gnav_ephemeris.d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S) * 1000) / 1000; d_nav.flag_TOW_new = false; } - else //if there is not a new preamble, we define the TOW of the current symbol + else // if there is not a new preamble, we define the TOW of the current symbol { d_TOW_at_current_symbol = d_TOW_at_current_symbol + GLONASS_L2_CA_CODE_PERIOD; } - //if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) + // if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) - // if(d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) //all GGTO parameters arrived + // if(d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived // { // delta_t = d_nav.A_0G_10 + d_nav.A_1G_10 * (d_TOW_at_current_symbol - d_nav.t_0G_10 + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G_10), 64))); // } @@ -413,8 +413,9 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } current_symbol.PRN = this->d_satellite.get_PRN(); - current_symbol.TOW_at_current_symbol_s = d_TOW_at_current_symbol; - current_symbol.TOW_at_current_symbol_s -= delta_t; // Galileo to GPS TOW + current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); + // todo: glonass time to gps time should be done in observables block + // current_symbol.TOW_at_current_symbol_ms -= static_cast(delta_t) * 1000; if (d_dump == true) { @@ -422,11 +423,11 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu try { double tmp_double; - unsigned long int tmp_ulong_int; + uint64_t tmp_ulong_int; tmp_double = d_TOW_at_current_symbol; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); tmp_double = 0; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); } @@ -441,7 +442,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { d_symbol_history.pop_front(); } - //3. Make the output (copy the object contents to the GNURadio reserved memory) + // 3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; return 1; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h index bad3ad62f..0ee799a34 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h @@ -34,9 +34,9 @@ #include "GLONASS_L1_L2_CA.h" -#include "glonass_gnav_navigation_message.h" -#include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" +#include "glonass_gnav_ephemeris.h" +#include "glonass_gnav_navigation_message.h" #include "glonass_gnav_utc_model.h" #include "gnss_satellite.h" #include "gnss_synchro.h" @@ -47,7 +47,7 @@ class glonass_l2_ca_telemetry_decoder_cc; -typedef boost::shared_ptr glonass_l2_ca_telemetry_decoder_cc_sptr; +using glonass_l2_ca_telemetry_decoder_cc_sptr = boost::shared_ptr; glonass_l2_ca_telemetry_decoder_cc_sptr glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -61,7 +61,7 @@ class glonass_l2_ca_telemetry_decoder_cc : public gr::block public: ~glonass_l2_ca_telemetry_decoder_cc(); //!< Class destructor void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -74,30 +74,30 @@ private: glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); glonass_l2_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void decode_string(double *symbols, int frame_length); + void decode_string(const double *symbols, int32_t frame_length); //!< Help with coherent tracking double d_preamble_time_samples; //!< Preamble decoding - unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; - int *d_preambles_symbols; - unsigned int d_samples_per_symbol; - int d_symbols_per_preamble; + uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{}; + int32_t *d_preambles_symbols; + uint32_t d_samples_per_symbol; + int32_t d_symbols_per_preamble; //!< Storage for incoming data std::deque d_symbol_history; //!< Variables for internal functionality - long unsigned int d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed - long unsigned int d_preamble_index; //!< Index of sample number where preamble was found - unsigned int d_stat; //!< Status of decoder - bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved - bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) - bool d_flag_preamble; //!< Flag indicating when preamble was found - int d_CRC_error_counter; //!< Number of failed CRC operations - bool flag_TOW_set; //!< Indicates when time of week is set - double delta_t; //!< GPS-GLONASS time offset + uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed + uint64_t d_preamble_index; //!< Index of sample number where preamble was found + uint32_t d_stat; //!< Status of decoder + bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved + bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) + bool d_flag_preamble; //!< Flag indicating when preamble was found + int32_t d_CRC_error_counter; //!< Number of failed CRC operations + bool flag_TOW_set; //!< Indicates when time of week is set + double delta_t; //!< GPS-GLONASS time offset //!< Navigation Message variable Glonass_Gnav_Navigation_Message d_nav; @@ -108,7 +108,7 @@ private: //!< Satellite Information and logging capacity Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; bool d_dump; std::string d_dump_filename; std::ofstream d_dump_file; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 1621eef58..4d3b9f315 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -30,7 +30,6 @@ */ #include "gps_l1_ca_telemetry_decoder_cc.h" -#include "control_message_factory.h" #include #include #include @@ -38,7 +37,7 @@ #ifndef _rotl -#define _rotl(X, N) ((X << N) ^ (X >> (32 - N))) // Used in the parity check algorithm +#define _rotl(X, N) (((X) << (N)) ^ ((X) >> (32 - (N)))) // Used in the parity check algorithm #endif using google::LogMessage; @@ -62,16 +61,16 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); // set the preamble - unsigned short int preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; + uint16_t preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; // preamble bits to sampled symbols - d_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int), volk_gnsssdr_get_alignment())); - int n = 0; - for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); + int32_t n = 0; + for (uint16_t preambles_bit : preambles_bits) { - for (unsigned int j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) + for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) { - if (preambles_bits[i] == 1) + if (preambles_bit == 1) { d_preambles_symbols[n] = 1; } @@ -82,36 +81,27 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( n++; } } - d_stat = 0; - d_symbol_accumulator = 0; - d_symbol_accumulator_counter = 0; - d_frame_bit_index = 0; + d_stat = 0U; d_flag_frame_sync = false; - d_GPS_frame_4bytes = 0; d_prev_GPS_frame_4bytes = 0; - d_flag_parity = false; - d_TOW_at_Preamble = 0.0; - d_TOW_at_current_symbol = 0.0; + d_TOW_at_Preamble_ms = 0; flag_TOW_set = false; - d_average_count = 0; d_flag_preamble = false; d_flag_new_tow_available = false; - d_word_number = 0; - d_decimation_output_factor = 1; d_channel = 0; flag_PLL_180_deg_phase_locked = false; - d_preamble_time_samples = 0; + d_preamble_time_samples = 0ULL; d_TOW_at_current_symbol_ms = 0; - d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS + 1); // Change fixed buffer size - d_symbol_history.clear(); // Clear all the elements in the buffer - d_make_correlation = true; - d_symbol_counter_corr = 0; + d_symbol_history.set_capacity(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); + d_crc_error_synchronization_counter = 0; + d_current_subframe_symbol = 0; } gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc() { volk_gnsssdr_free(d_preambles_symbols); + d_symbol_history.clear(); if (d_dump_file.is_open() == true) { try @@ -126,13 +116,13 @@ gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc() } -bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword) +bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(uint32_t gpsword) { - unsigned int d1, d2, d3, d4, d5, d6, d7, t, parity; - /* XOR as many bits in parallel as possible. The magic constants pick - up bits which are to be XOR'ed together to implement the GPS parity - check algorithm described in IS-GPS-200E. This avoids lengthy shift- - and-xor loops. */ + uint32_t d1, d2, d3, d4, d5, d6, d7, t, parity; + // XOR as many bits in parallel as possible. The magic constants pick + // up bits which are to be XOR'ed together to implement the GPS parity + // check algorithm described in IS-GPS-200E. This avoids lengthy shift- + // and-xor loops. d1 = gpsword & 0xFBFFBF00; d2 = _rotl(gpsword, 1) & 0x07FFBF01; d3 = _rotl(gpsword, 2) & 0xFC0F8100; @@ -145,25 +135,28 @@ bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword) parity = t ^ _rotl(t, 6) ^ _rotl(t, 12) ^ _rotl(t, 18) ^ _rotl(t, 24); parity = parity & 0x3F; if (parity == (gpsword & 0x3F)) - return (true); - else - return (false); + { + return (true); + } + + return (false); } void gps_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) { + d_nav.reset(); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; - d_GPS_FSM.i_satellite_PRN = d_satellite.get_PRN(); + d_nav.i_satellite_PRN = d_satellite.get_PRN(); DLOG(INFO) << "Navigation Satellite set to " << d_satellite; } -void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel) +void gps_l1_ca_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; - d_GPS_FSM.i_channel_ID = channel; + d_nav.i_channel_ID = channel; DLOG(INFO) << "Navigation channel set to " << channel; // ############# ENABLE DATA FILE LOG ################# if (d_dump == true) @@ -173,7 +166,7 @@ void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel) try { d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -189,32 +182,168 @@ void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel) } +bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() +{ + char subframe[GPS_SUBFRAME_LENGTH]; + + int32_t symbol_accumulator_counter = 0; + int32_t frame_bit_index = 0; + int32_t word_index = 0; + uint32_t GPS_frame_4bytes = 0; + float symbol_accumulator = 0; + bool subframe_synchro_confirmation = false; + bool CRC_ok = true; + + for (float d_subframe_symbol : d_subframe_symbols) + { + // ******* SYMBOL TO BIT ******* + // extended correlation to bit period is enabled in tracking! + symbol_accumulator += d_subframe_symbol; // accumulate the input value in d_symbol_accumulator + symbol_accumulator_counter++; + if (symbol_accumulator_counter == 20) + { + // symbol to bit + if (symbol_accumulator > 0) + { + GPS_frame_4bytes += 1; // insert the telemetry bit in LSB + } + symbol_accumulator = 0; + symbol_accumulator_counter = 0; + + // ******* bits to words ****** + frame_bit_index++; + if (frame_bit_index == 30) + { + frame_bit_index = 0; + // parity check + // Each word in wordbuff is composed of: + // Bits 0 to 29 = the GPS data word + // Bits 30 to 31 = 2 LSBs of the GPS word ahead. + // prepare the extended frame [-2 -1 0 ... 30] + if (d_prev_GPS_frame_4bytes & 0x00000001) + { + GPS_frame_4bytes = GPS_frame_4bytes | 0x40000000; + } + if (d_prev_GPS_frame_4bytes & 0x00000002) + { + GPS_frame_4bytes = GPS_frame_4bytes | 0x80000000; + } + // Check that the 2 most recently logged words pass parity. Have to first + // invert the data bits according to bit 30 of the previous word. + if (GPS_frame_4bytes & 0x40000000) + { + GPS_frame_4bytes ^= 0x3FFFFFC0; // invert the data bits (using XOR) + } + if (gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(GPS_frame_4bytes)) + { + subframe_synchro_confirmation = true; + } + else + { + // std::cout << "word invalid sat " << this->d_satellite << std::endl; + CRC_ok = false; + } + // add word to subframe + // insert the word in the correct position of the subframe + std::memcpy(&subframe[word_index * GPS_WORD_LENGTH], &GPS_frame_4bytes, sizeof(uint32_t)); + word_index++; + d_prev_GPS_frame_4bytes = GPS_frame_4bytes; // save the actual frame + GPS_frame_4bytes = 0; + } + else + { + GPS_frame_4bytes <<= 1; // shift 1 bit left the telemetry word + } + } + } + + // decode subframe + // NEW GPS SUBFRAME HAS ARRIVED! + if (CRC_ok) + { + int32_t subframe_ID = d_nav.subframe_decoder(subframe); //d ecode the subframe + if (subframe_ID > 0 and subframe_ID < 6) + { + std::cout << "New GPS NAV message received in channel " << this->d_channel << ": " + << "subframe " + << subframe_ID << " from satellite " + << Gnss_Satellite(std::string("GPS"), d_nav.i_satellite_PRN) << std::endl; + + switch (subframe_ID) + { + case 3: // we have a new set of ephemeris data for the current SV + if (d_nav.satellite_validation() == true) + { + // get ephemeris object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } + break; + case 4: // Possible IONOSPHERE and UTC model update (page 18) + if (d_nav.flag_iono_valid == true) + { + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } + if (d_nav.flag_utc_model_valid == true) + { + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + } + break; + case 5: + // get almanac (if available) + //TODO: implement almanac reader in navigation_message + break; + default: + break; + } + d_flag_new_tow_available = true; + } + else + { + return false; + } + } + + return subframe_synchro_confirmation; +} + + int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int corr_value = 0; - int preamble_diff_ms = 0; + int32_t preamble_diff_ms = 0; - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer - const Gnss_Synchro **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer + auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer + const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output current_symbol = in[0][0]; - d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue + + // record the oldest subframe symbol before inserting a new symbol into the circular buffer + if (d_current_subframe_symbol < GPS_SUBFRAME_MS and !d_symbol_history.empty()) + { + d_subframe_symbols[d_current_subframe_symbol] = d_symbol_history[0].Prompt_I; + d_current_subframe_symbol++; + } + + d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue consume_each(1); - unsigned int required_symbols = GPS_CA_PREAMBLE_LENGTH_SYMBOLS; d_flag_preamble = false; - if ((d_symbol_history.size() > required_symbols) and (d_make_correlation or !d_flag_frame_sync)) + // ******* preamble correlation ******** + int32_t corr_value = 0; + if ((d_symbol_history.size() == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)) { - //******* preamble correlation ******** - for (unsigned int i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) + int i = 0; + for (const auto &iter : d_symbol_history) { - if (d_symbol_history.at(i).Flag_valid_symbol_output == true) + if (iter.Flag_valid_symbol_output == true) { - if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping + if (iter.Prompt_I < 0) // symbols clipping { corr_value -= d_preambles_symbols[i]; } @@ -223,40 +352,29 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ corr_value += d_preambles_symbols[i]; } } - } - if (std::abs(corr_value) >= GPS_CA_PREAMBLE_LENGTH_SYMBOLS) - { - d_symbol_counter_corr++; + i++; } } - //******* frame sync ****************** + // ******* frame sync ****************** if (std::abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS) { //TODO: Rewrite with state machine if (d_stat == 0) { - d_GPS_FSM.Event_gps_word_preamble(); - //record the preamble sample stamp - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the preamble sample stamp - DLOG(INFO) << "Preamble detection for SAT " << this->d_satellite << "d_symbol_history.at(0).Tracking_sample_counter=" << d_symbol_history.at(0).Tracking_sample_counter; - //sync the symbol to bits integrator - d_symbol_accumulator = 0; - d_symbol_accumulator_counter = 0; - d_frame_bit_index = 0; + // record the preamble sample stamp + d_preamble_time_samples = d_symbol_history[0].Tracking_sample_counter; // record the preamble sample stamp + DLOG(INFO) << "Preamble detection for SAT " << this->d_satellite << "d_symbol_history[0].Tracking_sample_counter=" << d_symbol_history[0].Tracking_sample_counter; d_stat = 1; // enter into frame pre-detection status } - else if (d_stat == 1) //check 6 seconds of preamble separation + else if (d_stat == 1) // check 6 seconds of preamble separation { - preamble_diff_ms = std::round(((static_cast(d_symbol_history.at(0).Tracking_sample_counter) - d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs)) * 1000.0); - if (std::abs(preamble_diff_ms - GPS_SUBFRAME_MS) < 1) + preamble_diff_ms = std::round(((static_cast(d_symbol_history[0].Tracking_sample_counter) - static_cast(d_preamble_time_samples)) / static_cast(d_symbol_history[0].fs)) * 1000.0); + if (std::abs(preamble_diff_ms - GPS_SUBFRAME_MS) % GPS_SUBFRAME_MS == 0) { DLOG(INFO) << "Preamble confirmation for SAT " << this->d_satellite; - d_GPS_FSM.Event_gps_word_preamble(); d_flag_preamble = true; - d_make_correlation = false; - d_symbol_counter_corr = 0; - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the PRN start sample index associated to the preamble + d_preamble_time_samples = d_symbol_history[0].Tracking_sample_counter; // record the PRN start sample index associated to the preamble if (!d_flag_frame_sync) { d_flag_frame_sync = true; @@ -270,181 +388,97 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ flag_PLL_180_deg_phase_locked = false; } DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " - << static_cast(d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs) << " [s]"; + << static_cast(d_preamble_time_samples) / static_cast(d_symbol_history[0].fs) << " [s]"; } + + // try to decode the subframe: + if (decode_subframe() == false) + { + d_crc_error_synchronization_counter++; + if (d_crc_error_synchronization_counter > 3) + { + DLOG(INFO) << "TOO MANY CRC ERRORS: Lost of frame sync SAT " << this->d_satellite << std::endl; + d_stat = 0; // lost of frame sync + d_flag_frame_sync = false; + flag_TOW_set = false; + d_crc_error_synchronization_counter = 0; + } + } + d_current_subframe_symbol = 0; } } } else { - d_symbol_counter_corr++; - if (d_symbol_counter_corr > (GPS_SUBFRAME_MS - GPS_CA_TELEMETRY_SYMBOLS_PER_BIT)) - { - d_make_correlation = true; - } if (d_stat == 1) { - preamble_diff_ms = round(((static_cast(d_symbol_history.at(0).Tracking_sample_counter) - static_cast(d_preamble_time_samples)) / static_cast(d_symbol_history.at(0).fs)) * 1000.0); - if (preamble_diff_ms > GPS_SUBFRAME_MS + 1) + preamble_diff_ms = round(((static_cast(d_symbol_history[0].Tracking_sample_counter) - static_cast(d_preamble_time_samples)) / static_cast(d_symbol_history[0].fs)) * 1000.0); + if (preamble_diff_ms > GPS_SUBFRAME_MS) { DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms; - d_stat = 0; //lost of frame sync + // std::cout << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms << std::endl; + d_stat = 0; // lost of frame sync d_flag_frame_sync = false; flag_TOW_set = false; - d_make_correlation = true; - d_symbol_counter_corr = 0; + d_current_subframe_symbol = 0; + d_crc_error_synchronization_counter = 0; + d_TOW_at_current_symbol_ms = 0; } } } - //******* SYMBOL TO BIT ******* - if (d_symbol_history.at(0).Flag_valid_symbol_output == true) - { - // extended correlation to bit period is enabled in tracking! - d_symbol_accumulator += d_symbol_history.at(0).Prompt_I; // accumulate the input value in d_symbol_accumulator - d_symbol_accumulator_counter += d_symbol_history.at(0).correlation_length_ms; - } - if (d_symbol_accumulator_counter >= 20) - { - if (d_symbol_accumulator > 0) - { //symbol to bit - d_GPS_frame_4bytes += 1; //insert the telemetry bit in LSB - } - d_symbol_accumulator = 0; - d_symbol_accumulator_counter = 0; - //******* bits to words ****** - d_frame_bit_index++; - if (d_frame_bit_index == 30) - { - d_frame_bit_index = 0; - // parity check - // Each word in wordbuff is composed of: - // Bits 0 to 29 = the GPS data word - // Bits 30 to 31 = 2 LSBs of the GPS word ahead. - // prepare the extended frame [-2 -1 0 ... 30] - if (d_prev_GPS_frame_4bytes & 0x00000001) - { - d_GPS_frame_4bytes = d_GPS_frame_4bytes | 0x40000000; - } - if (d_prev_GPS_frame_4bytes & 0x00000002) - { - d_GPS_frame_4bytes = d_GPS_frame_4bytes | 0x80000000; - } - /* Check that the 2 most recently logged words pass parity. Have to first - invert the data bits according to bit 30 of the previous word. */ - if (d_GPS_frame_4bytes & 0x40000000) - { - d_GPS_frame_4bytes ^= 0x3FFFFFC0; // invert the data bits (using XOR) - } - if (gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(d_GPS_frame_4bytes)) - { - memcpy(&d_GPS_FSM.d_GPS_frame_4bytes, &d_GPS_frame_4bytes, sizeof(char) * 4); - //d_GPS_FSM.d_preamble_time_ms = d_preamble_time_seconds * 1000.0; - d_GPS_FSM.Event_gps_word_valid(); - // send TLM data to PVT using asynchronous message queues - if (d_GPS_FSM.d_flag_new_subframe == true) - { - switch (d_GPS_FSM.d_subframe_ID) - { - case 3: //we have a new set of ephemeris data for the current SV - if (d_GPS_FSM.d_nav.satellite_validation() == true) - { - // get ephemeris object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_GPS_FSM.d_nav.get_ephemeris()); - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - break; - case 4: // Possible IONOSPHERE and UTC model update (page 18) - if (d_GPS_FSM.d_nav.flag_iono_valid == true) - { - std::shared_ptr tmp_obj = std::make_shared(d_GPS_FSM.d_nav.get_iono()); - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - if (d_GPS_FSM.d_nav.flag_utc_model_valid == true) - { - std::shared_ptr tmp_obj = std::make_shared(d_GPS_FSM.d_nav.get_utc_model()); - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - } - break; - case 5: - // get almanac (if available) - //TODO: implement almanac reader in navigation_message - break; - default: - break; - } - d_GPS_FSM.clear_flag_new_subframe(); - d_flag_new_tow_available = true; - } - - d_flag_parity = true; - } - else - { - d_GPS_FSM.Event_gps_word_invalid(); - d_flag_parity = false; - } - d_prev_GPS_frame_4bytes = d_GPS_frame_4bytes; // save the actual frame - d_GPS_frame_4bytes = d_GPS_frame_4bytes & 0; - } - else - { - d_GPS_frame_4bytes <<= 1; //shift 1 bit left the telemetry word - } - } - - //2. Add the telemetry decoder information + // 2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_flag_new_tow_available == true) { - //double decoder_latency_ms=(double)(current_symbol.Tracking_sample_counter-d_symbol_history.at(0).Tracking_sample_counter) - // /(double)current_symbol.fs; - // update TOW at the preamble instant (account with decoder latency) - - d_TOW_at_Preamble = d_GPS_FSM.d_nav.d_TOW + 2.0 * GPS_L1_CA_CODE_PERIOD + GPS_CA_PREAMBLE_DURATION_S; - d_TOW_at_current_symbol_ms = static_cast(d_GPS_FSM.d_nav.d_TOW) * 1000 + 161; - //d_TOW_at_current_symbol = floor(d_TOW_at_Preamble * 1000.0) / 1000.0; - d_TOW_at_current_symbol = d_TOW_at_Preamble; + d_TOW_at_current_symbol_ms = static_cast(d_nav.d_TOW * 1000.0) + GPS_CA_PREAMBLE_DURATION_MS; + d_TOW_at_Preamble_ms = static_cast(d_nav.d_TOW * 1000.0); flag_TOW_set = true; d_flag_new_tow_available = false; } else { - d_TOW_at_current_symbol += GPS_L1_CA_CODE_PERIOD; - d_TOW_at_current_symbol_ms += GPS_L1_CA_CODE_PERIOD_MS; - } - - current_symbol.TOW_at_current_symbol_s = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; - //current_symbol.TOW_at_current_symbol_s = d_TOW_at_current_symbol; - current_symbol.Flag_valid_word = flag_TOW_set; - - if (flag_PLL_180_deg_phase_locked == true) - { - //correct the accumulated phase for the Costas loop phase shift, if required - current_symbol.Carrier_phase_rads += GPS_PI; - } - - if (d_dump == true) - { - // MULTIPLEXED FILE RECORDING - Record results to file - try + if (flag_TOW_set == true) { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = d_TOW_at_current_symbol; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = d_TOW_at_Preamble; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); + d_TOW_at_current_symbol_ms += GPS_L1_CA_CODE_PERIOD_MS; } } - //3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; + if (flag_TOW_set == true) + { + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + current_symbol.Flag_valid_word = flag_TOW_set; - return 1; + if (flag_PLL_180_deg_phase_locked == true) + { + // correct the accumulated phase for the Costas loop phase shift, if required + current_symbol.Carrier_phase_rads += GPS_PI; + } + + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + uint64_t tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + } + } + + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + + return 1; + } + + return 0; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h index 5a6c4c7db..f77a98153 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h @@ -32,17 +32,17 @@ #define GNSS_SDR_GPS_L1_CA_TELEMETRY_DECODER_CC_H #include "GPS_L1_CA.h" -#include "gps_l1_ca_subframe_fsm.h" #include "gnss_satellite.h" #include "gnss_synchro.h" +#include "gps_navigation_message.h" +#include #include #include #include -#include class gps_l1_ca_telemetry_decoder_cc; -typedef boost::shared_ptr gps_l1_ca_telemetry_decoder_cc_sptr; +using gps_l1_ca_telemetry_decoder_cc_sptr = boost::shared_ptr; gps_l1_ca_telemetry_decoder_cc_sptr gps_l1_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -70,50 +70,37 @@ private: gps_l1_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - bool gps_word_parityCheck(unsigned int gpsword); + bool gps_word_parityCheck(uint32_t gpsword); - // class private vars + bool decode_subframe(); + bool new_decoder(); + int d_crc_error_synchronization_counter; int *d_preambles_symbols; - unsigned int d_stat; + uint32_t d_stat; bool d_flag_frame_sync; // symbols boost::circular_buffer d_symbol_history; + float d_subframe_symbols[GPS_SUBFRAME_MS]{}; // symbols per subframe + int d_current_subframe_symbol; - double d_symbol_accumulator; - short int d_symbol_accumulator_counter; - - // symbol counting - bool d_make_correlation; - unsigned int d_symbol_counter_corr; - - //bits and frame - unsigned short int d_frame_bit_index; - unsigned int d_GPS_frame_4bytes; - unsigned int d_prev_GPS_frame_4bytes; - bool d_flag_parity; + // bits and frame + uint32_t d_prev_GPS_frame_4bytes; bool d_flag_preamble; bool d_flag_new_tow_available; - int d_word_number; - - // output averaging and decimation - int d_average_count; - int d_decimation_output_factor; // navigation message vars Gps_Navigation_Message d_nav; - GpsL1CaSubframeFsm d_GPS_FSM; bool d_dump; Gnss_Satellite d_satellite; int d_channel; - unsigned long int d_preamble_time_samples; + uint64_t d_preamble_time_samples; - double d_TOW_at_Preamble; - double d_TOW_at_current_symbol; - unsigned int d_TOW_at_current_symbol_ms; + uint32_t d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; bool flag_TOW_set; bool flag_PLL_180_deg_phase_locked; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc index 5c4e34184..49e5704d6 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc @@ -31,8 +31,8 @@ #include "gps_l2c_telemetry_decoder_cc.h" -#include "gnss_synchro.h" #include "display.h" +#include "gnss_synchro.h" #include #include #include @@ -61,7 +61,7 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc( d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); DLOG(INFO) << "GPS L2C M TELEMETRY PROCESSING: satellite " << d_satellite; - //set_output_multiple (1); + // set_output_multiple (1); d_channel = 0; d_flag_valid_word = false; d_TOW_at_current_symbol = 0; @@ -69,7 +69,7 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc( d_state = 0; //initial state d_crc_error_count = 0; - //initialize the CNAV frame decoder (libswiftcnav) + // initialize the CNAV frame decoder (libswiftcnav) cnav_msg_decoder_init(&d_cnav_decoder); } @@ -109,7 +109,7 @@ void gps_l2c_telemetry_decoder_cc::set_channel(int channel) try { d_dump_filename = "telemetry_L2CM_"; - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -129,39 +129,39 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // get pointers on in- and output gnss-synchro objects - Gnss_Synchro *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer - const Gnss_Synchro *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer + auto *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer + const auto *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer bool flag_new_cnav_frame = false; cnav_msg_t msg; - u32 delay = 0; + uint32_t delay = 0; - //add the symbol to the decoder - u8 symbol_clip = static_cast(in[0].Prompt_I > 0) * 255; + // add the symbol to the decoder + uint8_t symbol_clip = static_cast(in[0].Prompt_I > 0) * 255; flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay); - consume_each(1); //one by one + consume_each(1); // one by one // UPDATE GNSS SYNCHRO DATA - Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_synchro_data{}; // structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + // 1. Copy the current tracking output current_synchro_data = in[0]; - //2. Add the telemetry decoder information - //check if new CNAV frame is available + // 2. Add the telemetry decoder information + // check if new CNAV frame is available if (flag_new_cnav_frame == true) { std::bitset raw_bits; - //Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder - for (u32 i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS; i++) + // Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder + for (uint32_t i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS; i++) { raw_bits[GPS_L2_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1u); } d_CNAV_Message.decode_page(raw_bits); - //Push the new navigation data to the queues + // Push the new navigation data to the queues if (d_CNAV_Message.have_new_ephemeris() == true) { // get ephemeris object for this SV @@ -183,12 +183,12 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } - //update TOW at the preamble instant + // update TOW at the preamble instant d_TOW_at_Preamble = static_cast(msg.tow); - //* The time of the last input symbol can be computed from the message ToW and - //* delay by the formulae: - //* \code - //* symbolTime_ms = msg->tow * 6000 + *pdelay * 20 + (12 * 20); 12 symbols of the encoder's transitory + // The time of the last input symbol can be computed from the message ToW and + // delay by the formulae: + // \code + // symbolTime_ms = msg->tow * 6000 + *pdelay * 20 + (12 * 20); 12 symbols of the encoder's transitory d_TOW_at_current_symbol = static_cast(msg.tow) * 6.0 + static_cast(delay) * GPS_L2_M_PERIOD + 12 * GPS_L2_M_PERIOD; //d_TOW_at_current_symbol = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0; d_flag_valid_word = true; @@ -201,7 +201,7 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( d_flag_valid_word = false; } } - current_synchro_data.TOW_at_current_symbol_s = d_TOW_at_current_symbol; + current_synchro_data.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); current_synchro_data.Flag_valid_word = d_flag_valid_word; if (d_dump == true) @@ -210,11 +210,11 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( try { double tmp_double; - unsigned long int tmp_ulong_int; + uint64_t tmp_ulong_int; tmp_double = d_TOW_at_current_symbol; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_ulong_int = current_synchro_data.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); tmp_double = d_TOW_at_Preamble; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); } @@ -224,7 +224,7 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( } } - //3. Make the output (copy the object contents to the GNURadio reserved memory) + // 3. Make the output (copy the object contents to the GNURadio reserved memory) out[0] = current_synchro_data; return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h index 9235c5c2d..3c7747f1b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h @@ -33,11 +33,12 @@ #include "gnss_satellite.h" -#include "gps_cnav_navigation_message.h" #include "gps_cnav_ephemeris.h" #include "gps_cnav_iono.h" +#include "gps_cnav_navigation_message.h" #include #include // for copy +#include #include #include #include @@ -47,16 +48,16 @@ extern "C" { +#include "bits.h" #include "cnav_msg.h" #include "edc.h" -#include "bits.h" } #include "GPS_L2C.h" class gps_l2c_telemetry_decoder_cc; -typedef boost::shared_ptr gps_l2c_telemetry_decoder_cc_sptr; +using gps_l2c_telemetry_decoder_cc_sptr = boost::shared_ptr; gps_l2c_telemetry_decoder_cc_sptr gps_l2c_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -70,7 +71,7 @@ class gps_l2c_telemetry_decoder_cc : public gr::block public: ~gps_l2c_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -78,7 +79,6 @@ public: int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - private: friend gps_l2c_telemetry_decoder_cc_sptr gps_l2c_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -86,15 +86,15 @@ private: bool d_dump; Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; std::string d_dump_filename; std::ofstream d_dump_file; - cnav_msg_decoder_t d_cnav_decoder; + cnav_msg_decoder_t d_cnav_decoder{}; - int d_state; - int d_crc_error_count; + int32_t d_state; + int32_t d_crc_error_count; double d_TOW_at_current_symbol; double d_TOW_at_Preamble; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index 56ba9267f..a0b54b74d 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -64,13 +64,13 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc( DLOG(INFO) << "GPS L5 TELEMETRY PROCESSING: satellite " << d_satellite; d_channel = 0; d_flag_valid_word = false; - d_TOW_at_current_symbol = 0.0; - d_TOW_at_Preamble = 0.0; - //initialize the CNAV frame decoder (libswiftcnav) + d_TOW_at_current_symbol_ms = 0U; + d_TOW_at_Preamble_ms = 0U; + // initialize the CNAV frame decoder (libswiftcnav) cnav_msg_decoder_init(&d_cnav_decoder); - for (int aux = 0; aux < GPS_L5i_NH_CODE_LENGTH; aux++) + for (int32_t aux = 0; aux < GPS_L5I_NH_CODE_LENGTH; aux++) { - if (GPS_L5i_NH_CODE[aux] == 0) + if (GPS_L5I_NH_CODE[aux] == 0) { bits_NH[aux] = -1.0; } @@ -108,7 +108,7 @@ void gps_l5_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) } -void gps_l5_telemetry_decoder_cc::set_channel(int channel) +void gps_l5_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; d_CNAV_Message.reset(); @@ -121,7 +121,7 @@ void gps_l5_telemetry_decoder_cc::set_channel(int channel) try { d_dump_filename = "telemetry_L5_"; - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -141,22 +141,22 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // get pointers on in- and output gnss-synchro objects - Gnss_Synchro *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer - const Gnss_Synchro *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer + auto *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer + const auto *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer // UPDATE GNSS SYNCHRO DATA - Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + Gnss_Synchro current_synchro_data{}; //structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output current_synchro_data = in[0]; consume_each(1); //one by one sym_hist.push_back(in[0].Prompt_I); - int corr_NH = 0; - int symbol_value = 0; + int32_t corr_NH = 0; + int32_t symbol_value = 0; - //Search correlation with Neuman-Hofman Code (see IS-GPS-705D) - if (sym_hist.size() == GPS_L5i_NH_CODE_LENGTH) + // Search correlation with Neuman-Hofman Code (see IS-GPS-705D) + if (sym_hist.size() == GPS_L5I_NH_CODE_LENGTH) { - for (int i = 0; i < GPS_L5i_NH_CODE_LENGTH; i++) + for (int32_t i = 0; i < GPS_L5I_NH_CODE_LENGTH; i++) { if ((bits_NH[i] * sym_hist.at(i)) > 0.0) { @@ -167,7 +167,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u corr_NH -= 1; } } - if (abs(corr_NH) == GPS_L5i_NH_CODE_LENGTH) + if (abs(corr_NH) == GPS_L5I_NH_CODE_LENGTH) { sync_NH = true; if (corr_NH > 0) @@ -191,29 +191,29 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u bool flag_new_cnav_frame = false; cnav_msg_t msg; - u32 delay = 0; + uint32_t delay = 0; - //add the symbol to the decoder + // add the symbol to the decoder if (new_sym) { - u8 symbol_clip = static_cast(symbol_value > 0) * 255; + uint8_t symbol_clip = static_cast(symbol_value > 0) * 255; flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay); new_sym = false; } - //2. Add the telemetry decoder information - //check if new CNAV frame is available + // 2. Add the telemetry decoder information + // check if new CNAV frame is available if (flag_new_cnav_frame == true) { std::bitset raw_bits; - //Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder - for (u32 i = 0; i < GPS_L5_CNAV_DATA_PAGE_BITS; i++) + // Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder + for (uint32_t i = 0; i < GPS_L5_CNAV_DATA_PAGE_BITS; i++) { raw_bits[GPS_L5_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1u); } d_CNAV_Message.decode_page(raw_bits); - //Push the new navigation data to the queues + // Push the new navigation data to the queues if (d_CNAV_Message.have_new_ephemeris() == true) { // get ephemeris object for this SV @@ -235,48 +235,52 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } - //update TOW at the preamble instant - d_TOW_at_Preamble = static_cast(msg.tow) * 6.0; - //* The time of the last input symbol can be computed from the message ToW and - //* delay by the formulae: - //* \code - //* symbolTime_ms = msg->tow * 6000 + *pdelay * 10 + (12 * 10); 12 symbols of the encoder's transitory - d_TOW_at_current_symbol = (static_cast(msg.tow) * 6.0) + (static_cast(delay) + 12.0) * GPS_L5i_SYMBOL_PERIOD; - d_TOW_at_current_symbol = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0; + // update TOW at the preamble instant + d_TOW_at_Preamble_ms = msg.tow * 6000; + // The time of the last input symbol can be computed from the message ToW and + // delay by the formulae: + // \code + // symbolTime_ms = msg->tow * 6000 + *pdelay * 10 + (12 * 10); 12 symbols of the encoder's transitory + d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5I_SYMBOL_PERIOD_MS; d_flag_valid_word = true; } else { - d_TOW_at_current_symbol += GPS_L5i_PERIOD; + d_TOW_at_current_symbol_ms += GPS_L5I_PERIOD_MS; if (current_synchro_data.Flag_valid_symbol_output == false) { d_flag_valid_word = false; } } - current_synchro_data.TOW_at_current_symbol_s = d_TOW_at_current_symbol; - current_synchro_data.Flag_valid_word = d_flag_valid_word; - if (d_dump == true) + if (d_flag_valid_word == true) { - // MULTIPLEXED FILE RECORDING - Record results to file - try - { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = d_TOW_at_current_symbol; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_synchro_data.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = d_TOW_at_Preamble; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing Telemetry GPS L5 dump file " << e.what(); - } - } + current_synchro_data.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + current_synchro_data.Flag_valid_word = d_flag_valid_word; - //3. Make the output (copy the object contents to the GNURadio reserved memory) - out[0] = current_synchro_data; - return 1; + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + uint64_t tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_synchro_data.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing Telemetry GPS L5 dump file " << e.what(); + } + } + + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + out[0] = current_synchro_data; + return 1; + } + return 0; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h index c5e838382..d28e8b58f 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h @@ -35,6 +35,7 @@ #include "gps_cnav_navigation_message.h" #include #include +#include #include #include #include @@ -43,16 +44,16 @@ extern "C" { +#include "bits.h" #include "cnav_msg.h" #include "edc.h" -#include "bits.h" } #include "GPS_L5.h" class gps_l5_telemetry_decoder_cc; -typedef boost::shared_ptr gps_l5_telemetry_decoder_cc_sptr; +using gps_l5_telemetry_decoder_cc_sptr = boost::shared_ptr; gps_l5_telemetry_decoder_cc_sptr gps_l5_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -66,11 +67,10 @@ class gps_l5_telemetry_decoder_cc : public gr::block public: ~gps_l5_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - private: friend gps_l5_telemetry_decoder_cc_sptr gps_l5_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -78,19 +78,19 @@ private: bool d_dump; Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; std::string d_dump_filename; std::ofstream d_dump_file; - cnav_msg_decoder_t d_cnav_decoder; + cnav_msg_decoder_t d_cnav_decoder{}; - double d_TOW_at_current_symbol; - double d_TOW_at_Preamble; + uint32_t d_TOW_at_current_symbol_ms; + uint32_t d_TOW_at_Preamble_ms; bool d_flag_valid_word; Gps_CNAV_Navigation_Message d_CNAV_Message; - double bits_NH[GPS_L5i_NH_CODE_LENGTH]; + double bits_NH[GPS_L5I_NH_CODE_LENGTH]{}; std::deque sym_hist; bool sync_NH; bool new_sym; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc index ba65ce7df..8a3628cbd 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc @@ -29,7 +29,6 @@ */ #include "sbas_l1_telemetry_decoder_cc.h" -#include "control_message_factory.h" #include "gnss_synchro.h" #include #include @@ -65,7 +64,7 @@ sbas_l1_telemetry_decoder_cc::sbas_l1_telemetry_decoder_cc( d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); LOG(INFO) << "SBAS L1 TELEMETRY PROCESSING: satellite " << d_satellite; - d_block_size = d_samples_per_symbol * d_symbols_per_bit * d_block_size_in_bits; + d_block_size = D_SAMPLES_PER_SYMBOL * D_SYMBOLS_PER_BIT * D_BLOCK_SIZE_IN_BITS; d_channel = 0; set_output_multiple(1); } @@ -94,7 +93,7 @@ void sbas_l1_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite } -void sbas_l1_telemetry_decoder_cc::set_channel(int channel) +void sbas_l1_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "SBAS channel set to " << channel; @@ -102,7 +101,7 @@ void sbas_l1_telemetry_decoder_cc::set_channel(int channel) // ### helper class for sample alignment ### -sbas_l1_telemetry_decoder_cc::sample_aligner::sample_aligner() +sbas_l1_telemetry_decoder_cc::Sample_Aligner::Sample_Aligner() { d_n_smpls_in_history = 3; d_iir_par = 0.05; @@ -110,12 +109,10 @@ sbas_l1_telemetry_decoder_cc::sample_aligner::sample_aligner() } -sbas_l1_telemetry_decoder_cc::sample_aligner::~sample_aligner() -{ -} +sbas_l1_telemetry_decoder_cc::Sample_Aligner::~Sample_Aligner() = default; -void sbas_l1_telemetry_decoder_cc::sample_aligner::reset() +void sbas_l1_telemetry_decoder_cc::Sample_Aligner::reset() { d_past_sample = 0; d_corr_paired = 0; @@ -127,7 +124,7 @@ void sbas_l1_telemetry_decoder_cc::sample_aligner::reset() /* * samples length must be a multiple of two */ -bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector samples, std::vector &symbols) +bool sbas_l1_telemetry_decoder_cc::Sample_Aligner::get_symbols(const std::vector &samples, std::vector &symbols) { double smpls[3] = {}; double corr_diff; @@ -137,12 +134,12 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector VLOG(FLOW) << "get_symbols(): " << "d_past_sample=" << d_past_sample << "\tsamples size=" << samples.size(); - for (unsigned int i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_cc::d_samples_per_symbol; i_sym++) + for (uint32_t i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_cc::D_SAMPLES_PER_SYMBOL; i_sym++) { // get the next samples - for (int i = 0; i < d_n_smpls_in_history; i++) + for (int32_t i = 0; i < d_n_smpls_in_history; i++) { - smpls[i] = static_cast(i_sym) * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1 == -1 ? d_past_sample : samples[i_sym * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1]; + smpls[i] = static_cast(i_sym) * sbas_l1_telemetry_decoder_cc::D_SAMPLES_PER_SYMBOL + i - 1 == -1 ? d_past_sample : samples[i_sym * sbas_l1_telemetry_decoder_cc::D_SAMPLES_PER_SYMBOL + i - 1]; } // update the pseudo correlations (IIR method) of the two possible alignments @@ -158,7 +155,7 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector } // sum the correct pair of samples to a symbol, depending on the current alignment d_align - sym = smpls[0 + int(d_aligned) * 2] + smpls[1]; + sym = smpls[0 + int32_t(d_aligned) * 2] + smpls[1]; symbols.push_back(sym); // sample alignment debug output @@ -185,12 +182,12 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector // ### helper class for symbol alignment and viterbi decoding ### -sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::symbol_aligner_and_decoder() +sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::Symbol_Aligner_And_Decoder() { // convolutional code properties d_KK = 7; - int nn = 2; - int g_encoder[nn]; + const int32_t nn = 2; + int32_t g_encoder[nn]; g_encoder[0] = 121; g_encoder[1] = 91; @@ -200,14 +197,14 @@ sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::symbol_aligner_and_dec } -sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::~symbol_aligner_and_decoder() +sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::~Symbol_Aligner_And_Decoder() { delete d_vd1; delete d_vd2; } -void sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::reset() +void sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::reset() { d_past_symbol = 0; d_vd1->reset(); @@ -215,27 +212,27 @@ void sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::reset() } -bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const std::vector symbols, std::vector &bits) +bool sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::get_bits(const std::vector &symbols, std::vector &bits) { - const int traceback_depth = 5 * d_KK; - int nbits_requested = symbols.size() / d_symbols_per_bit; - int nbits_decoded; + const int32_t traceback_depth = 5 * d_KK; + int32_t nbits_requested = symbols.size() / D_SYMBOLS_PER_BIT; + int32_t nbits_decoded; // fill two vectors with the two possible symbol alignments std::vector symbols_vd1(symbols); // aligned symbol vector -> copy input symbol vector std::vector symbols_vd2; // shifted symbol vector -> add past sample in front of input vector symbols_vd2.push_back(d_past_symbol); - for (std::vector::const_iterator symbol_it = symbols.cbegin(); symbol_it != symbols.cend() - 1; ++symbol_it) + for (auto symbol_it = symbols.cbegin(); symbol_it != symbols.cend() - 1; ++symbol_it) { symbols_vd2.push_back(*symbol_it); } // arrays for decoded bits - int *bits_vd1 = new int[nbits_requested]; - int *bits_vd2 = new int[nbits_requested]; + auto *bits_vd1 = new int32_t[nbits_requested]; + auto *bits_vd2 = new int32_t[nbits_requested]; // decode float metric_vd1 = d_vd1->decode_continuous(symbols_vd1.data(), traceback_depth, bits_vd1, nbits_requested, nbits_decoded); float metric_vd2 = d_vd2->decode_continuous(symbols_vd2.data(), traceback_depth, bits_vd2, nbits_requested, nbits_decoded); // choose the bits with the better metric - for (int i = 0; i < nbits_decoded; i++) + for (int32_t i = 0; i < nbits_decoded; i++) { if (metric_vd1 > metric_vd2) { // symbols aligned @@ -254,41 +251,41 @@ bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const st // ### helper class for detecting the preamble and collect the corresponding message candidates ### -void sbas_l1_telemetry_decoder_cc::frame_detector::reset() +void sbas_l1_telemetry_decoder_cc::Frame_Detector::reset() { d_buffer.clear(); } -void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const std::vector bits, std::vector>> &msg_candidates) +void sbas_l1_telemetry_decoder_cc::Frame_Detector::get_frame_candidates(const std::vector &bits, std::vector>> &msg_candidates) { std::stringstream ss; - unsigned int sbas_msg_length = 250; - std::vector> preambles = {{0, 1, 0, 1, 0, 0, 1, 1}, + uint32_t sbas_msg_length = 250; + std::vector> preambles = {{0, 1, 0, 1, 0, 0, 1, 1}, {1, 0, 0, 1, 1, 0, 1, 0}, {1, 1, 0, 0, 0, 1, 1, 0}}; VLOG(FLOW) << "get_frame_candidates(): " << "d_buffer.size()=" << d_buffer.size() << "\tbits.size()=" << bits.size(); ss << "copy bits "; - int count = 0; + int32_t count = 0; // copy new bits into the working buffer - for (std::vector::const_iterator bit_it = bits.cbegin(); bit_it < bits.cend(); ++bit_it) + for (auto bit_it = bits.cbegin(); bit_it < bits.cend(); ++bit_it) { d_buffer.push_back(*bit_it); ss << *bit_it; count++; } VLOG(SAMP_SYNC) << ss.str() << " into working buffer (" << count << " bits)"; - int relative_preamble_start = 0; + int32_t relative_preamble_start = 0; while (d_buffer.size() >= sbas_msg_length) { // compare with all preambles - for (std::vector>::iterator preample_it = preambles.begin(); preample_it < preambles.end(); ++preample_it) + for (auto preample_it = preambles.begin(); preample_it < preambles.end(); ++preample_it) { bool preamble_detected = true; bool inv_preamble_detected = true; // compare the buffer bits with the preamble bits - for (std::vector::iterator preample_bit_it = preample_it->begin(); preample_bit_it < preample_it->end(); ++preample_bit_it) + for (auto preample_bit_it = preample_it->begin(); preample_bit_it < preample_it->end(); ++preample_bit_it) { preamble_detected = *preample_bit_it == d_buffer[preample_bit_it - preample_it->begin()] ? preamble_detected : false; inv_preamble_detected = *preample_bit_it != d_buffer[preample_bit_it - preample_it->begin()] ? inv_preamble_detected : false; @@ -296,19 +293,23 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st if (preamble_detected || inv_preamble_detected) { // copy candidate - std::vector candidate; + std::vector candidate; std::copy(d_buffer.begin(), d_buffer.begin() + sbas_msg_length, std::back_inserter(candidate)); if (inv_preamble_detected) { // invert bits - for (std::vector::iterator candidate_bit_it = candidate.begin(); candidate_bit_it != candidate.end(); candidate_bit_it++) - *candidate_bit_it = *candidate_bit_it == 0 ? 1 : 0; + for (int &candidate_bit_it : candidate) + { + candidate_bit_it = candidate_bit_it == 0 ? 1 : 0; + } } - msg_candidates.push_back(std::pair>(relative_preamble_start, candidate)); + msg_candidates.emplace_back(relative_preamble_start, candidate); ss.str(""); ss << "preamble " << preample_it - preambles.begin() << (inv_preamble_detected ? " inverted" : " normal") << " detected! candidate="; - for (std::vector::iterator bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it) - ss << *bit_it; + for (auto bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it) + { + ss << *bit_it; + } VLOG(EVENT) << ss.str(); } } @@ -320,33 +321,33 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st // ### helper class for checking the CRC of the message candidates ### -void sbas_l1_telemetry_decoder_cc::crc_verifier::reset() +void sbas_l1_telemetry_decoder_cc::Crc_Verifier::reset() { } -void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vector msg_candidates, std::vector &valid_msgs) +void sbas_l1_telemetry_decoder_cc::Crc_Verifier::get_valid_frames(const std::vector &msg_candidates, std::vector &valid_msgs) { std::stringstream ss; VLOG(FLOW) << "get_valid_frames(): " << "msg_candidates.size()=" << msg_candidates.size(); // for each candidate - for (std::vector::const_iterator candidate_it = msg_candidates.cbegin(); candidate_it < msg_candidates.cend(); ++candidate_it) + for (auto candidate_it = msg_candidates.cbegin(); candidate_it < msg_candidates.cend(); ++candidate_it) { // convert to bytes - std::vector candidate_bytes; + std::vector candidate_bytes; zerropad_back_and_convert_to_bytes(candidate_it->second, candidate_bytes); // verify CRC d_checksum_agent.reset(0); d_checksum_agent.process_bytes(candidate_bytes.data(), candidate_bytes.size()); - unsigned int crc = d_checksum_agent.checksum(); + uint32_t crc = d_checksum_agent.checksum(); VLOG(SAMP_SYNC) << "candidate " << candidate_it - msg_candidates.begin() << ": final crc remainder= " << std::hex << crc << std::setfill(' ') << std::resetiosflags(std::ios::hex); // the final remainder must be zero for a valid message, because the CRC is done over the received CRC value if (crc == 0) { - valid_msgs.push_back(msg_candiate_char_t(candidate_it->first, candidate_bytes)); + valid_msgs.emplace_back(candidate_it->first, candidate_bytes); ss << "Valid message found!"; } else @@ -354,66 +355,66 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vec ss << "Not a valid message."; } ss << " Relbitoffset=" << candidate_it->first << " content="; - for (std::vector::iterator byte_it = candidate_bytes.begin(); byte_it < candidate_bytes.end(); ++byte_it) + for (auto byte_it = candidate_bytes.begin(); byte_it < candidate_bytes.end(); ++byte_it) { - ss << std::setw(2) << std::setfill('0') << std::hex << static_cast((*byte_it)); + ss << std::setw(2) << std::setfill('0') << std::hex << static_cast((*byte_it)); } VLOG(SAMP_SYNC) << ss.str() << std::setfill(' ') << std::resetiosflags(std::ios::hex) << std::endl; } } -void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes) +void sbas_l1_telemetry_decoder_cc::Crc_Verifier::zerropad_back_and_convert_to_bytes(const std::vector &msg_candidate, std::vector &bytes) { std::stringstream ss; const size_t bits_per_byte = 8; - unsigned char byte = 0; + uint8_t byte = 0; VLOG(LMORE) << "zerropad_back_and_convert_to_bytes():" << byte; - for (std::vector::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) + for (auto candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) { - int idx_bit = candidate_bit_it - msg_candidate.begin(); - int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); - byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; + int32_t idx_bit = candidate_bit_it - msg_candidate.begin(); + int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); + byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; ss << *candidate_bit_it; if (idx_bit % bits_per_byte == bits_per_byte - 1) { bytes.push_back(byte); - VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) << std::setfill('0') << std::hex << static_cast(byte); + VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) << std::setfill('0') << std::hex << static_cast(byte); ss.str(""); byte = 0; } } bytes.push_back(byte); // implies: insert 6 zeros at the end to fit the 250bits into a multiple of bytes VLOG(LMORE) << " -> byte=" << std::setw(2) - << std::setfill('0') << std::hex << static_cast(byte) + << std::setfill('0') << std::hex << static_cast(byte) << std::setfill(' ') << std::resetiosflags(std::ios::hex); } -void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes) +void sbas_l1_telemetry_decoder_cc::Crc_Verifier::zerropad_front_and_convert_to_bytes(const std::vector &msg_candidate, std::vector &bytes) { std::stringstream ss; const size_t bits_per_byte = 8; - unsigned char byte = 0; - int idx_bit = 6; // insert 6 zeros at the front to fit the 250bits into a multiple of bytes + uint8_t byte = 0; + int32_t idx_bit = 6; // insert 6 zeros at the front to fit the 250bits into a multiple of bytes VLOG(LMORE) << "zerropad_front_and_convert_to_bytes():" << byte; - for (std::vector::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) + for (auto candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) { - int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); - byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; + int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); + byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; ss << *candidate_bit_it; if (idx_bit % bits_per_byte == bits_per_byte - 1) { bytes.push_back(byte); VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) - << std::setfill('0') << std::hex << static_cast(byte); + << std::setfill('0') << std::hex << static_cast(byte); ss.str(""); byte = 0; } idx_bit++; } VLOG(LMORE) << " -> byte=" << std::setw(2) - << std::setfill('0') << std::hex << static_cast(byte) + << std::setfill('0') << std::hex << static_cast(byte) << std::setfill(' ') << std::resetiosflags(std::ios::hex); } @@ -424,11 +425,11 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( VLOG(FLOW) << "general_work(): " << "noutput_items=" << noutput_items << "\toutput_items real size=" << output_items.size() << "\tninput_items size=" << ninput_items.size() << "\tinput_items real size=" << input_items.size() << "\tninput_items[0]=" << ninput_items[0]; // get pointers on in- and output gnss-synchro objects - Gnss_Synchro *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer - const Gnss_Synchro *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer + auto *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer + const auto *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output current_symbol = in[0]; // copy correlation samples into samples vector d_sample_buf.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue @@ -446,7 +447,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( // align symbols in pairs // and obtain the bits by decoding the symbol pairs - std::vector bits; + std::vector bits; bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(symbols, bits); // search for preambles @@ -462,17 +463,16 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( // compute message sample stamp // and fill messages in SBAS raw message objects //std::vector sbas_raw_msgs; - for (std::vector::const_iterator it = valid_msgs.cbegin(); - it != valid_msgs.cend(); ++it) + for (const auto &valid_msg : valid_msgs) { - int message_sample_offset = - (sample_alignment ? 0 : -1) + d_samples_per_symbol * (symbol_alignment ? -1 : 0) + d_samples_per_symbol * d_symbols_per_bit * it->first; + int32_t message_sample_offset = + (sample_alignment ? 0 : -1) + D_SAMPLES_PER_SYMBOL * (symbol_alignment ? -1 : 0) + D_SAMPLES_PER_SYMBOL * D_SYMBOLS_PER_BIT * valid_msg.first; double message_sample_stamp = sample_stamp + static_cast(message_sample_offset) / 1000.0; VLOG(EVENT) << "message_sample_stamp=" << message_sample_stamp << " (sample_stamp=" << sample_stamp << " sample_alignment=" << sample_alignment << " symbol_alignment=" << symbol_alignment - << " relative_preamble_start=" << it->first + << " relative_preamble_start=" << valid_msg.first << " message_sample_offset=" << message_sample_offset << ")"; //Sbas_Raw_Msg sbas_raw_msg(message_sample_stamp, this->d_satellite.get_PRN(), it->second); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h index 39a315015..f1188737b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h @@ -36,6 +36,7 @@ #include #include #include // for copy +#include #include #include #include @@ -45,7 +46,7 @@ class sbas_l1_telemetry_decoder_cc; -typedef boost::shared_ptr sbas_l1_telemetry_decoder_cc_sptr; +using sbas_l1_telemetry_decoder_cc_sptr = boost::shared_ptr; sbas_l1_telemetry_decoder_cc_sptr sbas_l1_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -59,7 +60,7 @@ class sbas_l1_telemetry_decoder_cc : public gr::block public: ~sbas_l1_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -72,16 +73,16 @@ private: sbas_l1_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); sbas_l1_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void viterbi_decoder(double *page_part_symbols, int *page_part_bits); + void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits); void align_samples(); - static const int d_samples_per_symbol = 2; - static const int d_symbols_per_bit = 2; - static const int d_block_size_in_bits = 30; + static const int32_t D_SAMPLES_PER_SYMBOL = 2; + static const int32_t D_SYMBOLS_PER_BIT = 2; + static const int32_t D_BLOCK_SIZE_IN_BITS = 30; bool d_dump; Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; std::string d_dump_filename; std::ofstream d_dump_file; @@ -89,24 +90,24 @@ private: size_t d_block_size; //!< number of samples which are processed during one invocation of the algorithms std::vector d_sample_buf; //!< input buffer holding the samples to be processed in one block - typedef std::pair> msg_candiate_int_t; - typedef std::pair> msg_candiate_char_t; + typedef std::pair> msg_candiate_int_t; + typedef std::pair> msg_candiate_char_t; // helper class for sample alignment - class sample_aligner + class Sample_Aligner { public: - sample_aligner(); - ~sample_aligner(); + Sample_Aligner(); + ~Sample_Aligner(); void reset(); /* * samples length must be a multiple of two * for block operation */ - bool get_symbols(const std::vector samples, std::vector &symbols); + bool get_symbols(const std::vector &samples, std::vector &symbols); private: - int d_n_smpls_in_history; + int32_t d_n_smpls_in_history; double d_iir_par; double d_corr_paired; double d_corr_shifted; @@ -115,16 +116,16 @@ private: } d_sample_aligner; // helper class for symbol alignment and Viterbi decoding - class symbol_aligner_and_decoder + class Symbol_Aligner_And_Decoder { public: - symbol_aligner_and_decoder(); - ~symbol_aligner_and_decoder(); + Symbol_Aligner_And_Decoder(); + ~Symbol_Aligner_And_Decoder(); void reset(); - bool get_bits(const std::vector symbols, std::vector &bits); + bool get_bits(const std::vector &symbols, std::vector &bits); private: - int d_KK; + int32_t d_KK; Viterbi_Decoder *d_vd1; Viterbi_Decoder *d_vd2; double d_past_symbol; @@ -132,29 +133,29 @@ private: // helper class for detecting the preamble and collect the corresponding message candidates - class frame_detector + class Frame_Detector { public: void reset(); - void get_frame_candidates(const std::vector bits, std::vector>> &msg_candidates); + void get_frame_candidates(const std::vector &bits, std::vector>> &msg_candidates); private: - std::deque d_buffer; + std::deque d_buffer; } d_frame_detector; // helper class for checking the CRC of the message candidates - class crc_verifier + class Crc_Verifier { public: void reset(); - void get_valid_frames(const std::vector msg_candidates, std::vector &valid_msgs); + void get_valid_frames(const std::vector &msg_candidates, std::vector &valid_msgs); private: typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> crc_24_q_type; crc_24_q_type d_checksum_agent; - void zerropad_front_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes); - void zerropad_back_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes); + void zerropad_front_and_convert_to_bytes(const std::vector &msg_candidate, std::vector &bytes); + void zerropad_back_and_convert_to_bytes(const std::vector &msg_candidate, std::vector &bytes); } d_crc_verifier; }; diff --git a/src/algorithms/telemetry_decoder/libs/CMakeLists.txt b/src/algorithms/telemetry_decoder/libs/CMakeLists.txt index 523ef2df2..a802b970c 100644 --- a/src/algorithms/telemetry_decoder/libs/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,27 +16,44 @@ # along with GNSS-SDR. If not, see . # + add_subdirectory(libswiftcnav) -set(TELEMETRY_DECODER_LIB_SOURCES - gps_l1_ca_subframe_fsm.cc - viterbi_decoder.cc +set(TELEMETRY_DECODER_LIB_SOURCES + viterbi_decoder.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/adapters - ${Boost_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} +set(TELEMETRY_DECODER_LIB_HEADERS + viterbi_decoder.h + convolutional.h ) -file(GLOB TELEMETRY_DECODER_LIB_HEADERS "*.h") - list(SORT TELEMETRY_DECODER_LIB_HEADERS) -add_library(telemetry_decoder_lib ${TELEMETRY_DECODER_LIB_SOURCES} ${TELEMETRY_DECODER_LIB_HEADERS}) +list(SORT TELEMETRY_DECODER_LIB_SOURCES) + source_group(Headers FILES ${TELEMETRY_DECODER_LIB_HEADERS}) -target_link_libraries(telemetry_decoder_lib gnss_system_parameters) + +add_library(telemetry_decoder_libs + ${TELEMETRY_DECODER_LIB_SOURCES} + ${TELEMETRY_DECODER_LIB_HEADERS} +) + +target_link_libraries(telemetry_decoder_libs + PRIVATE + Gflags::gflags + Glog::glog +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(telemetry_decoder_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET telemetry_decoder_libs + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/telemetry_decoder/libs/convolutional.h b/src/algorithms/telemetry_decoder/libs/convolutional.h index 4195154df..cc775110b 100644 --- a/src/algorithms/telemetry_decoder/libs/convolutional.h +++ b/src/algorithms/telemetry_decoder/libs/convolutional.h @@ -88,7 +88,7 @@ inline static int parity_counter(int symbol, int length) inline static int nsc_enc_bit(int state_out_p[], int input, int state_in, - int g[], + const int g[], int KK, int nn) { @@ -144,7 +144,7 @@ inline static void nsc_transit(int output_p[], * \param[in] nn The length of the received vector * */ -inline static float Gamma(float rec_array[], +inline static float Gamma(const float rec_array[], int symbol, int nn) { @@ -155,7 +155,9 @@ inline static float Gamma(float rec_array[], for (i = 0; i < nn; i++) { if (symbol & mask) - rm += rec_array[nn - i - 1]; + { + rm += rec_array[nn - i - 1]; + } mask = mask << 1; } return (rm); @@ -175,11 +177,11 @@ inline static float Gamma(float rec_array[], * */ inline static void Viterbi(int output_u_int[], - int out0[], - int state0[], - int out1[], - int state1[], - double input_c[], + const int out0[], + const int state0[], + const int out1[], + const int state1[], + const double input_c[], int KK, int nn, int LL) @@ -219,11 +221,15 @@ inline static void Viterbi(int output_u_int[], for (t = 0; t < LL + mm; t++) { for (i = 0; i < nn; i++) - rec_array[i] = static_cast(input_c[nn * t + i]); + { + rec_array[i] = static_cast(input_c[nn * t + i]); + } /* precompute all possible branch metrics */ for (i = 0; i < number_symbols; i++) - metric_c[i] = Gamma(rec_array, i, nn); + { + metric_c[i] = Gamma(rec_array, i, nn); + } /* step through all states */ for (state = 0; state < states; state++) diff --git a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc deleted file mode 100644 index d5317734e..000000000 --- a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc +++ /dev/null @@ -1,289 +0,0 @@ -/*! - * \file gps_l1_ca_subframe_fsm.cc - * \brief Implementation of a GPS NAV message word-to-subframe decoder state machine - * \author Javier Arribas, 2011. jarribas(at)cttc.es - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include "gps_l1_ca_subframe_fsm.h" -#include "gnss_satellite.h" -#include -#include -#include -#include -#include -#include - - -//************ GPS WORD TO SUBFRAME DECODER STATE MACHINE ********** -struct Ev_gps_word_valid : sc::event -{ -}; - - -struct Ev_gps_word_invalid : sc::event -{ -}; - - -struct Ev_gps_word_preamble : sc::event -{ -}; - - -struct gps_subframe_fsm_S0 : public sc::state -{ -public: - // sc::transition(event,next_status) - typedef sc::transition reactions; - gps_subframe_fsm_S0(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S0 "< -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S1(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S1 "< -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S2(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S2 "<().gps_word_to_subframe(0); - } -}; - - -struct gps_subframe_fsm_S3 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S3(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S3 "<().gps_word_to_subframe(1); - } -}; - - -struct gps_subframe_fsm_S4 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S4(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S4 "<().gps_word_to_subframe(2); - } -}; - - -struct gps_subframe_fsm_S5 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S5(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S5 "<().gps_word_to_subframe(3); - } -}; - - -struct gps_subframe_fsm_S6 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S6(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S6 "<().gps_word_to_subframe(4); - } -}; - - -struct gps_subframe_fsm_S7 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S7(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S7 "<().gps_word_to_subframe(5); - } -}; - - -struct gps_subframe_fsm_S8 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S8(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S8 "<().gps_word_to_subframe(6); - } -}; - - -struct gps_subframe_fsm_S9 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S9(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S9 "<().gps_word_to_subframe(7); - } -}; - - -struct gps_subframe_fsm_S10 : public sc::state -{ -public: - typedef mpl::list, - sc::transition > - reactions; - - gps_subframe_fsm_S10(my_context ctx) : my_base(ctx) - { - //std::cout<<"Enter S10 "<().gps_word_to_subframe(8); - } -}; - - -struct gps_subframe_fsm_S11 : public sc::state -{ -public: - typedef sc::transition reactions; - - gps_subframe_fsm_S11(my_context ctx) : my_base(ctx) - { - //std::cout<<"Completed GPS Subframe!"<().gps_word_to_subframe(9); - context().gps_subframe_to_nav_msg(); //decode the subframe - // DECODE SUBFRAME - //std::cout<<"Enter S11"<d_subframe); //decode the subframe - std::cout << "New GPS NAV message received in channel " << i_channel_ID << ": " - << "subframe " - << d_subframe_ID << " from satellite " - << Gnss_Satellite(std::string("GPS"), i_satellite_PRN) << std::endl; - d_nav.i_satellite_PRN = i_satellite_PRN; - d_nav.i_channel_ID = i_channel_ID; - - d_flag_new_subframe = true; -} - - -void GpsL1CaSubframeFsm::Event_gps_word_valid() -{ - this->process_event(Ev_gps_word_valid()); -} - - -void GpsL1CaSubframeFsm::Event_gps_word_invalid() -{ - this->process_event(Ev_gps_word_invalid()); -} - - -void GpsL1CaSubframeFsm::Event_gps_word_preamble() -{ - this->process_event(Ev_gps_word_preamble()); -} diff --git a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h deleted file mode 100644 index 9a9a04bd8..000000000 --- a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h +++ /dev/null @@ -1,100 +0,0 @@ -/*! - * \file gps_l1_ca_subframe_fsm.h - * \brief Interface of a GPS NAV message word-to-subframe decoder state machine - * \author Javier Arribas, 2011. jarribas(at)cttc.es - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - - -#ifndef GNSS_SDR_GPS_L1_CA_SUBFRAME_FSM_H_ -#define GNSS_SDR_GPS_L1_CA_SUBFRAME_FSM_H_ - -#include "GPS_L1_CA.h" -#include "gps_navigation_message.h" -#include "gps_ephemeris.h" -#include "gps_iono.h" -#include "gps_almanac.h" -#include "gps_utc_model.h" -#include - -namespace sc = boost::statechart; -namespace mpl = boost::mpl; - -struct gps_subframe_fsm_S0; -struct gps_subframe_fsm_S1; -struct gps_subframe_fsm_S2; -struct gps_subframe_fsm_S3; -struct gps_subframe_fsm_S4; -struct gps_subframe_fsm_S5; -struct gps_subframe_fsm_S6; -struct gps_subframe_fsm_S7; -struct gps_subframe_fsm_S8; -struct gps_subframe_fsm_S9; -struct gps_subframe_fsm_S10; -struct gps_subframe_fsm_S11; - - -/*! - * \brief This class implements a Finite State Machine that handles the decoding - * of the GPS L1 C/A NAV message - */ -class GpsL1CaSubframeFsm : public sc::state_machine -{ -public: - GpsL1CaSubframeFsm(); //!< The constructor starts the Finite State Machine - void clear_flag_new_subframe(); - // channel and satellite info - int i_channel_ID; //!< Channel id - unsigned int i_satellite_PRN; //!< Satellite PRN number - - Gps_Navigation_Message d_nav; //!< GPS L1 C/A navigation message object - - // GPS SV and System parameters - Gps_Ephemeris ephemeris; //!< Object that handles GPS ephemeris parameters - Gps_Almanac almanac; //!< Object that handles GPS almanac data - Gps_Utc_Model utc_model; //!< Object that handles UTM model parameters - Gps_Iono iono; //!< Object that handles ionospheric parameters - - char d_subframe[GPS_SUBFRAME_LENGTH]; - int d_subframe_ID; - bool d_flag_new_subframe; - char d_GPS_frame_4bytes[GPS_WORD_LENGTH]; - //double d_preamble_time_ms; - - void gps_word_to_subframe(int position); //!< inserts the word in the correct position of the subframe - - /*! - * \brief This function decodes a NAv message subframe and pushes the information to the right queues - */ - void gps_subframe_to_nav_msg(); - - //FSM EVENTS - void Event_gps_word_valid(); //!< FSM event: the received word is valid - void Event_gps_word_invalid(); //!< FSM event: the received word is not valid - void Event_gps_word_preamble(); //!< FSM event: word preamble detected -}; - -#endif diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/CMakeLists.txt b/src/algorithms/telemetry_decoder/libs/libswiftcnav/CMakeLists.txt index a9f7a1622..ffe8b2c37 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,20 +16,36 @@ # along with GNSS-SDR. If not, see . # -set(TELEMETRY_DECODER_LIBSWIFTCNAV_SOURCES - cnav_msg.c - bits.c - edc.c - viterbi27.c +set(TELEMETRY_DECODER_LIBSWIFTCNAV_SOURCES + cnav_msg.c + bits.c + edc.c + viterbi27.c ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} +set(TELEMETRY_DECODER_LIBSWIFTCNAV_HEADERS + cnav_msg.h + bits.h + edc.h + swift_common.h + fec.h ) -file(GLOB TELEMETRY_DECODER_LIBSWIFTCNAV_HEADERS "*.h") list(SORT TELEMETRY_DECODER_LIBSWIFTCNAV_HEADERS) +list(SORT TELEMETRY_DECODER_LIBSWIFTCNAV_SOURCES) -add_library(telemetry_decoder_libswiftcnav STATIC ${TELEMETRY_DECODER_LIBSWIFTCNAV_SOURCES} ${TELEMETRY_DECODER_LIBSWIFTCNAV_HEADERS}) source_group(Headers FILES ${TELEMETRY_DECODER_LIBSWIFTCNAV_HEADERS}) -set_target_properties(telemetry_decoder_libswiftcnav PROPERTIES LINKER_LANGUAGE C) \ No newline at end of file + +add_library(telemetry_decoder_libswiftcnav STATIC + ${TELEMETRY_DECODER_LIBSWIFTCNAV_SOURCES} + ${TELEMETRY_DECODER_LIBSWIFTCNAV_HEADERS} +) + +set_property(TARGET telemetry_decoder_libswiftcnav + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) + +set_target_properties(telemetry_decoder_libswiftcnav + PROPERTIES LINKER_LANGUAGE C +) diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c index 866b822fb..1cbe9eb12 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c @@ -30,12 +30,11 @@ */ #include "bits.h" - #include #include -static const u8 bitn[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; +static const uint8_t BITN[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; /** \defgroup bits Bit Utils * Bit field packing, unpacking and utility functions. @@ -50,7 +49,7 @@ static const u8 bitn[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; * \return 1 if there are an odd number of bits set. * 0 if there are an even number of bits set. */ -u8 parity(u32 x) +uint8_t parity(uint32_t x) { x ^= x >> 16; x ^= x >> 8; @@ -69,14 +68,14 @@ u8 parity(u32 x) * \param len Length of bit field in bits. * \return Bit field as an unsigned value. */ -u32 getbitu(const u8 *buff, u32 pos, u8 len) +uint32_t getbitu(const uint8_t *buff, uint32_t pos, uint8_t len) { - u32 bits = 0; - u32 i=0; + uint32_t bits = 0; + uint32_t i = 0; for (i = pos; i < pos + len; i++) { bits = (bits << 1) + - ((buff[i/8] >> (7 - i%8)) & 1u); + ((buff[i / 8] >> (7 - i % 8)) & 1u); } return bits; @@ -93,14 +92,14 @@ u32 getbitu(const u8 *buff, u32 pos, u8 len) * \param len Length of bit field in bits. * \return Bit field as a signed value. */ -s32 getbits(const u8 *buff, u32 pos, u8 len) +int32_t getbits(const uint8_t *buff, uint32_t pos, uint8_t len) { - s32 bits = (s32)getbitu(buff, pos, len); + int32_t bits = (int32_t)getbitu(buff, pos, len); /* Sign extend, taken from: * http://graphics.stanford.edu/~seander/bithacks.html#VariableSignExtend */ - s32 m = 1u << (len - 1); + int32_t m = 1u << (len - 1); return (bits ^ m) - m; } @@ -113,19 +112,25 @@ s32 getbits(const u8 *buff, u32 pos, u8 len) * \param len Length of bit field in bits. * \param data Unsigned integer to be packed into bit field. */ -void setbitu(u8 *buff, u32 pos, u32 len, u32 data) +void setbitu(uint8_t *buff, uint32_t pos, uint32_t len, uint32_t data) { - u32 mask = 1u << (len - 1); + uint32_t mask = 1u << (len - 1); if (len <= 0 || 32 < len) - return; - u32 i = 0; + { + return; + } + uint32_t i = 0; for (i = pos; i < pos + len; i++, mask >>= 1) { if (data & mask) - buff[i/8] |= 1u << (7 - i % 8); + { + buff[i / 8] |= 1u << (7 - i % 8); + } else - buff[i/8] &= ~(1u << (7 - i % 8)); + { + buff[i / 8] &= ~(1u << (7 - i % 8)); + } } } @@ -138,9 +143,9 @@ void setbitu(u8 *buff, u32 pos, u32 len, u32 data) * \param len Length of bit field in bits. * \param data Signed integer to be packed into bit field. */ -void setbits(u8 *buff, u32 pos, u32 len, s32 data) +void setbits(uint8_t *buff, uint32_t pos, uint32_t len, int32_t data) { - setbitu(buff, pos, len, (u32)data); + setbitu(buff, pos, len, (uint32_t)data); } /** @@ -153,7 +158,7 @@ void setbits(u8 *buff, u32 pos, u32 len, s32 data) * * \return None */ -void bitshl(void *buf, u32 size, u32 shift) +void bitshl(void *buf, uint32_t size, uint32_t shift) { if (shift > size * CHAR_BIT) { @@ -162,12 +167,12 @@ void bitshl(void *buf, u32 size, u32 shift) return; } - unsigned char *dst = buf; /* Destination byte. */ + unsigned char *dst = buf; /* Destination byte. */ const unsigned char *src = dst + shift / CHAR_BIT; /* First source byte, possibly incomplete. */ - u32 copy_bits = size * CHAR_BIT - shift; /* Number of bits to move */ - u32 byte_shift = copy_bits % CHAR_BIT; /* Shift of data */ - u32 full_bytes = copy_bits / CHAR_BIT; /* Number of bytes to move */ + uint32_t copy_bits = size * CHAR_BIT - shift; /* Number of bits to move */ + uint32_t byte_shift = copy_bits % CHAR_BIT; /* Shift of data */ + uint32_t full_bytes = copy_bits / CHAR_BIT; /* Number of bytes to move */ if (0 == byte_shift) { @@ -179,8 +184,8 @@ void bitshl(void *buf, u32 size, u32 shift) else { /* Create an accumulator: it will hold a value of two consecutive bytes */ - u32 acc = *src++; - u32 i = 0; + uint32_t acc = *src++; + uint32_t i = 0; for (i = 0; i < full_bytes; ++i) { acc = (acc << CHAR_BIT) | *src++; @@ -210,22 +215,22 @@ void bitshl(void *buf, u32 size, u32 shift) * \todo This function can be optimized for copying aligned data and using * proper native type like long. */ -void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index, - u32 count) +void bitcopy(void *dst, uint32_t dst_index, const void *src, uint32_t src_index, + uint32_t count) { - u32 limit1 = count / 32; - u32 limit2 = count % 32; - u32 idx = 0; + uint32_t limit1 = count / 32; + uint32_t limit2 = count % 32; + uint32_t idx = 0; for (idx = 0; idx < limit1; ++idx) { - u32 tmp = getbitu(src, src_index, 32); + uint32_t tmp = getbitu(src, src_index, 32); setbitu(dst, dst_index, 32, tmp); src_index += 32; dst_index += 32; } if (0 != limit2) { - u32 tmp = getbitu(src, src_index, limit2); + uint32_t tmp = getbitu(src, src_index, limit2); setbitu(dst, dst_index, limit2, tmp); } } @@ -238,12 +243,14 @@ void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index, * * \return Number of bits set to one or zero. */ -u8 count_bits_u64(u64 v, u8 bv) +uint8_t count_bits_u64(uint64_t v, uint8_t bv) { - u8 r = 0; + uint8_t r = 0; int i = 0; for (i = 0; i < 16; i++) - r += bitn[(v >> (i*4)) & 0xf]; + { + r += BITN[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 64 - r; } @@ -255,12 +262,14 @@ u8 count_bits_u64(u64 v, u8 bv) * * \return Number of bits set to one or zero. */ -u8 count_bits_u32(u32 v, u8 bv) +uint8_t count_bits_u32(uint32_t v, uint8_t bv) { - u8 r = 0; + uint8_t r = 0; int i = 0; for (i = 0; i < 8; i++) - r += bitn[(v >> (i*4)) & 0xf]; + { + r += BITN[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 32 - r; } @@ -272,12 +281,14 @@ u8 count_bits_u32(u32 v, u8 bv) * * \return Number of bits set to one or zero. */ -u8 count_bits_u16(u16 v, u8 bv) +uint8_t count_bits_u16(uint16_t v, uint8_t bv) { - u8 r = 0; + uint8_t r = 0; int i = 0; - for (i= 0; i < 4; i++) - r += bitn[(v >> (i*4)) & 0xf]; + for (i = 0; i < 4; i++) + { + r += BITN[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 16 - r; } @@ -289,12 +300,14 @@ u8 count_bits_u16(u16 v, u8 bv) * * \return Number of bits set to one or zero. */ -u8 count_bits_u8(u8 v, u8 bv) +uint8_t count_bits_u8(uint8_t v, uint8_t bv) { - u8 r = 0; + uint8_t r = 0; int i = 0; for (i = 0; i < 2; i++) - r += bitn[(v >> (i*4)) & 0xf]; + { + r += BITN[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 8 - r; } diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.h b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.h index 8e73ccf4a..11f5e512e 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.h +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.h @@ -34,17 +34,17 @@ #include "swift_common.h" -u8 parity(u32 x); -u32 getbitu(const u8 *buff, u32 pos, u8 len); -s32 getbits(const u8 *buff, u32 pos, u8 len); -void setbitu(u8 *buff, u32 pos, u32 len, u32 data); -void setbits(u8 *buff, u32 pos, u32 len, s32 data); -void bitcopy(void *dst, u32 dst_index, - const void *src, u32 src_index, u32 count); -void bitshl(void *buf, u32 size, u32 shift); -u8 count_bits_u64(u64 v, u8 bv); -u8 count_bits_u32(u32 v, u8 bv); -u8 count_bits_u16(u16 v, u8 bv); -u8 count_bits_u8(u8 v, u8 bv); +uint8_t parity(uint32_t x); +uint32_t getbitu(const uint8_t *buff, uint32_t pos, uint8_t len); +int32_t getbits(const uint8_t *buff, uint32_t pos, uint8_t len); +void setbitu(uint8_t *buff, uint32_t pos, uint32_t len, uint32_t data); +void setbits(uint8_t *buff, uint32_t pos, uint32_t len, int32_t data); +void bitcopy(void *dst, uint32_t dst_index, + const void *src, uint32_t src_index, uint32_t count); +void bitshl(void *buf, uint32_t size, uint32_t shift); +uint8_t count_bits_u64(uint64_t v, uint8_t bv); +uint8_t count_bits_u32(uint32_t v, uint8_t bv); +uint8_t count_bits_u16(uint16_t v, uint8_t bv); +uint8_t count_bits_u8(uint8_t v, uint8_t bv); #endif /* LIBSWIFTNAV_BITS_H */ diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c index 5248c0f7c..1676fc0cd 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c @@ -30,7 +30,6 @@ */ - #include "edc.h" #include "bits.h" #include "cnav_msg.h" @@ -48,26 +47,26 @@ * Block Viterbi decoding parameters. */ /** Viterbi decoder reversed polynomial A */ -#define GPS_L2C_V27_POLY_A (0x4F) /* 0b01001111 - reversed 0171*/ +#define GPS_L2C_V27_POLY_A (0x4F) /* 0b01001111 - reversed 0171*/ /** Viterbi decoder reversed polynomial B */ -#define GPS_L2C_V27_POLY_B (0x6D) /* 0b01101101 - reversed 0133 */ +#define GPS_L2C_V27_POLY_B (0x6D) /* 0b01101101 - reversed 0133 */ /* * GPS L2C message constants. */ /** GPS L2C preamble */ -#define GPS_CNAV_PREAMBLE1 (0b10001011u) +const uint32_t GPS_CNAV_PREAMBLE1 = 0x8Bu; /* (0b10001011u) */ /** Inverted GPS L2C preamble */ -#define GPS_CNAV_PREAMBLE2 (0b01110100u) +const uint32_t GPS_CNAV_PREAMBLE2 = 0x74u; /* (0b01110100u) */ /** GPS L2C preamble length in bits */ -#define GPS_CNAV_PREAMBLE_LENGTH (8) +#define GPS_CNAV_PREAMBLE_LENGTH (8) /** GPS L2C CNAV message length in bits */ -#define GPS_CNAV_MSG_LENGTH (300) +#define GPS_CNAV_MSG_LENGTH (300) /** GPS LC2 CNAV CRC length in bits */ -#define GPS_CNAV_MSG_CRC_LENGTH (24) +#define GPS_CNAV_MSG_CRC_LENGTH (24) /** GPS L2C CNAV message payload length in bits */ -#define GPS_CNAV_MSG_DATA_LENGTH (GPS_CNAV_MSG_LENGTH - GPS_CNAV_MSG_CRC_LENGTH) +#define GPS_CNAV_MSG_DATA_LENGTH (GPS_CNAV_MSG_LENGTH - GPS_CNAV_MSG_CRC_LENGTH) /** GPS L2C CNAV message lock detector threshold */ #define GPS_CNAV_LOCK_MAX_CRC_FAILS (10) @@ -82,10 +81,10 @@ * * \private */ -static u32 _cnav_compute_crc(cnav_v27_part_t *part) +static uint32_t _cnav_compute_crc(cnav_v27_part_t *part) { - u32 crc = crc24q_bits(0, part->decoded, GPS_CNAV_MSG_DATA_LENGTH, - part->invert); + uint32_t crc = crc24q_bits(0, part->decoded, GPS_CNAV_MSG_DATA_LENGTH, + part->invert); return crc; } @@ -101,10 +100,10 @@ static u32 _cnav_compute_crc(cnav_v27_part_t *part) * * \private */ -static u32 _cnav_extract_crc(const cnav_v27_part_t *part) +static uint32_t _cnav_extract_crc(const cnav_v27_part_t *part) { - u32 crc = getbitu(part->decoded, GPS_CNAV_MSG_DATA_LENGTH, - GPS_CNAV_MSG_CRC_LENGTH); + uint32_t crc = getbitu(part->decoded, GPS_CNAV_MSG_DATA_LENGTH, + GPS_CNAV_MSG_CRC_LENGTH); if (part->invert) { crc ^= 0xFFFFFF; @@ -137,7 +136,7 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part) size_t j = 0; for (i = 1, j = part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH; i < j; ++i) { - u32 c = getbitu(part->decoded, i, GPS_CNAV_PREAMBLE_LENGTH); + uint32_t c = getbitu(part->decoded, i, GPS_CNAV_PREAMBLE_LENGTH); if (GPS_CNAV_PREAMBLE1 == c || GPS_CNAV_PREAMBLE2 == c) { part->preamble_seen = true; @@ -152,7 +151,7 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part) if (!part->preamble_seen && part->n_decoded >= GPS_CNAV_PREAMBLE_LENGTH) { bitshl(part->decoded, sizeof(part->decoded), - part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH + 1); + part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH + 1); part->n_decoded = GPS_CNAV_PREAMBLE_LENGTH - 1; } } @@ -172,7 +171,7 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part) * * \private */ -static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch) +static void _cnav_add_symbol(cnav_v27_part_t *part, uint8_t ch) { part->symbols[part->n_symbols++] = ch; @@ -200,11 +199,12 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch) * - N - Number of bits to put into decoded buffer * - M - Number of bits in the tail to ignore. */ - unsigned char tmp_bits[ (GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS + - CHAR_BIT - 1) / CHAR_BIT]; + unsigned char tmp_bits[(GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS + + CHAR_BIT - 1) / + CHAR_BIT]; v27_chainback_likely(&part->dec, tmp_bits, - GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS); + GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS); /* Read decoded bits and add them to the decoded buffer */ bitcopy(part->decoded, part->n_decoded, tmp_bits, 0, GPS_L2C_V27_DECODE_BITS); @@ -238,11 +238,10 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch) } if (part->preamble_seen && GPS_CNAV_MSG_LENGTH <= part->n_decoded) { - /* We have collected 300 bits starting from message preamble. Now try * to compute CRC-24Q */ - u32 crc = _cnav_compute_crc(part); - u32 crc2 = _cnav_extract_crc(part); + uint32_t crc = _cnav_compute_crc(part); + uint32_t crc2 = _cnav_extract_crc(part); if (part->message_lock) { @@ -260,8 +259,8 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch) if (part->n_crc_fail > GPS_CNAV_LOCK_MAX_CRC_FAILS) { /* CRC has failed too many times - drop the lock. */ - part->n_crc_fail = 0; - part->message_lock = false; + part->n_crc_fail = 0; + part->message_lock = false; part->preamble_seen = false; /* Try to find a new preamble, reuse data from buffer. */ retry = true; @@ -272,8 +271,8 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch) { /* CRC match - message can be decoded */ part->message_lock = true; - part->crc_ok = true; - part->n_crc_fail = 0; + part->crc_ok = true; + part->n_crc_fail = 0; } else { @@ -333,7 +332,7 @@ static void _cnav_msg_invert(cnav_v27_part_t *part) * * \private */ -static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, u32 *delay) +static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, uint32_t *delay) { bool res = false; if (GPS_CNAV_MSG_LENGTH <= part->n_decoded) @@ -346,13 +345,13 @@ static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, u32 *delay) _cnav_msg_invert(part); } - msg->prn = getbitu(part->decoded, 8, 6); + msg->prn = getbitu(part->decoded, 8, 6); msg->msg_id = getbitu(part->decoded, 14, 6); - msg->tow = getbitu(part->decoded, 20, 17); - msg->alert = getbitu(part->decoded, 37, 1) ? true : false; + msg->tow = getbitu(part->decoded, 20, 17); + msg->alert = getbitu(part->decoded, 37, 1) ? true : false; /* copy RAW message for GNSS-SDR */ - memcpy(msg->raw_msg,part->decoded,GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS); + memcpy(msg->raw_msg, part->decoded, GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS); *delay = (part->n_decoded - GPS_CNAV_MSG_LENGTH + GPS_L2C_V27_DELAY_BITS) * 2 + part->n_symbols; @@ -388,15 +387,15 @@ void cnav_msg_decoder_init(cnav_msg_decoder_t *dec) { memset(dec, 0, sizeof(*dec)); v27_init(&dec->part1.dec, - dec->part1.decisions, - GPS_L2_V27_HISTORY_LENGTH_BITS, - cnav_msg_decoder_get_poly(), - 0); + dec->part1.decisions, + GPS_L2_V27_HISTORY_LENGTH_BITS, + cnav_msg_decoder_get_poly(), + 0); v27_init(&dec->part2.dec, - dec->part2.decisions, - GPS_L2_V27_HISTORY_LENGTH_BITS, - cnav_msg_decoder_get_poly(), - 0); + dec->part2.decisions, + GPS_L2_V27_HISTORY_LENGTH_BITS, + cnav_msg_decoder_get_poly(), + 0); dec->part1.init = true; dec->part2.init = true; _cnav_add_symbol(&dec->part2, 0x80); @@ -426,9 +425,9 @@ void cnav_msg_decoder_init(cnav_msg_decoder_t *dec) * \retval false More data is required. */ bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec, - u8 symbol, - cnav_msg_t *msg, - u32 *pdelay) + uint8_t symbol, + cnav_msg_t *msg, + uint32_t *pdelay) { _cnav_add_symbol(&dec->part1, symbol); _cnav_add_symbol(&dec->part2, symbol); @@ -470,7 +469,7 @@ const v27_poly_t *cnav_msg_decoder_get_poly(void) if (!initialized) { /* Coefficients for polynomial object */ - const signed char coeffs[2] = { GPS_L2C_V27_POLY_A, GPS_L2C_V27_POLY_B }; + const signed char coeffs[2] = {GPS_L2C_V27_POLY_A, GPS_L2C_V27_POLY_B}; /* Racing condition handling: the data can be potential initialized more * than once in case multiple threads request concurrent access. However, diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.h b/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.h index 23e29d958..9e4bdd65f 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.h +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.h @@ -34,13 +34,11 @@ #define LIBSWIFTNAV_CNAV_MSG_H #include "fec.h" - +#include "swift_common.h" +#include #include #include #include -#include - -#include "swift_common.h" /** \addtogroup GPS_L2 * \{ */ @@ -62,11 +60,11 @@ */ typedef struct { - u8 prn; /**< SV PRN. 0..31 */ - u8 msg_id; /**< Message id. 0..31 */ - u32 tow; /**< GPS ToW in 6-second units. Multiply to 6 to get seconds. */ - bool alert; /**< CNAV message alert flag */ - u8 raw_msg[GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS]; /**< RAW MSG for GNSS-SDR */ + uint8_t prn; /**< SV PRN. 0..31 */ + uint8_t msg_id; /**< Message id. 0..31 */ + uint32_t tow; /**< GPS ToW in 6-second units. Multiply to 6 to get seconds. */ + bool alert; /**< CNAV message alert flag */ + uint8_t raw_msg[GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS]; /**< RAW MSG for GNSS-SDR */ } cnav_msg_t; /** @@ -114,7 +112,7 @@ void cnav_msg_decoder_init(cnav_msg_decoder_t *dec); bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec, unsigned char symbol, cnav_msg_t *msg, - u32 *delay); + uint32_t *delay); /** \} */ /** \} */ diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c index c89bae64d..6e3e06c6f 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c @@ -39,40 +39,39 @@ * Cyclic redundancy checks. * \{ */ -static const u32 crc24qtab[256] = { - 0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17, - 0xA18139, 0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E, - 0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E, - 0x64CFB0, 0xE2834B, 0xEE1ABD, 0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7, - 0x0CD1E9, 0x8A9D12, 0x8604E4, 0x00481F, 0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE, - 0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926, 0x3EB631, 0xB8FACA, 0xB4633C, 0x322FC7, - 0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A, 0xD0AC8C, 0x56E077, - 0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5, 0xF7614E, - 0x19A3D2, 0x9FEF29, 0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5, - 0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A, 0xAD88F1, 0xA11107, 0x275DFC, - 0xDCED5B, 0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C, - 0x7D6C62, 0xFB2099, 0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375, - 0x15723B, 0x933EC0, 0x9FA736, 0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C, - 0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4, 0x2715E3, 0xA15918, 0xADC0EE, 0x2B8C15, - 0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53, 0xC596A8, 0xC90F5E, 0x4F43A5, - 0x71BD8B, 0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791, 0x688E67, 0xEEC29C, - 0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52, 0xA0A145, 0x26EDBE, 0x2A7448, 0xAC38B3, - 0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571, 0x0DB98A, - 0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A, - 0x578814, 0xD1C4EF, 0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703, - 0x3F964D, 0xB9DAB6, 0xB54340, 0x330FBB, 0xAC70AC, 0x2A3C57, 0x26A5A1, 0xA0E95A, - 0x9E1774, 0x185B8F, 0x14C279, 0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863, - 0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132, 0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3, - 0x5B59FD, 0xDD1506, 0xD18CF0, 0x57C00B, 0xC8BF1C, 0x4EF3E7, 0x426A11, 0xC426EA, - 0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C, 0x33D79A, 0xB59B61, - 0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3, 0x141A58, - 0xEFAAFF, 0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8, - 0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230, 0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1, - 0x26359F, 0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673, 0xB94A88, - 0x87B4A6, 0x01F85D, 0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1, - 0xE37B16, 0x6537ED, 0x69AE1B, 0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401, - 0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538 -}; +static const uint32_t CRC24QTAB[256] = { + 0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17, + 0xA18139, 0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E, + 0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E, + 0x64CFB0, 0xE2834B, 0xEE1ABD, 0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7, + 0x0CD1E9, 0x8A9D12, 0x8604E4, 0x00481F, 0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE, + 0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926, 0x3EB631, 0xB8FACA, 0xB4633C, 0x322FC7, + 0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A, 0xD0AC8C, 0x56E077, + 0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5, 0xF7614E, + 0x19A3D2, 0x9FEF29, 0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5, + 0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A, 0xAD88F1, 0xA11107, 0x275DFC, + 0xDCED5B, 0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C, + 0x7D6C62, 0xFB2099, 0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375, + 0x15723B, 0x933EC0, 0x9FA736, 0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C, + 0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4, 0x2715E3, 0xA15918, 0xADC0EE, 0x2B8C15, + 0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53, 0xC596A8, 0xC90F5E, 0x4F43A5, + 0x71BD8B, 0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791, 0x688E67, 0xEEC29C, + 0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52, 0xA0A145, 0x26EDBE, 0x2A7448, 0xAC38B3, + 0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571, 0x0DB98A, + 0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A, + 0x578814, 0xD1C4EF, 0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703, + 0x3F964D, 0xB9DAB6, 0xB54340, 0x330FBB, 0xAC70AC, 0x2A3C57, 0x26A5A1, 0xA0E95A, + 0x9E1774, 0x185B8F, 0x14C279, 0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863, + 0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132, 0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3, + 0x5B59FD, 0xDD1506, 0xD18CF0, 0x57C00B, 0xC8BF1C, 0x4EF3E7, 0x426A11, 0xC426EA, + 0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C, 0x33D79A, 0xB59B61, + 0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3, 0x141A58, + 0xEFAAFF, 0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8, + 0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230, 0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1, + 0x26359F, 0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673, 0xB94A88, + 0x87B4A6, 0x01F85D, 0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1, + 0xE37B16, 0x6537ED, 0x69AE1B, 0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401, + 0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538}; /** Calculate Qualcomm 24-bit Cyclical Redundancy Check (CRC-24Q). * @@ -89,11 +88,13 @@ static const u32 crc24qtab[256] = { * * \return CRC-24Q value */ -u32 crc24q(const u8 *buf, u32 len, u32 crc) +uint32_t crc24q(const uint8_t *buf, uint32_t len, uint32_t crc) { - u32 i = 0; + uint32_t i = 0; for (i = 0; i < len; i++) - crc = ((crc << 8) & 0xFFFFFF) ^ crc24qtab[((crc >> 16) ^ buf[i]) & 0xff]; + { + crc = ((crc << 8) & 0xFFFFFF) ^ CRC24QTAB[((crc >> 16) ^ buf[i]) & 0xff]; + } return crc; } @@ -112,30 +113,30 @@ u32 crc24q(const u8 *buf, u32 len, u32 crc) * * \return CRC-24Q value */ -u32 crc24q_bits(u32 crc, const u8 *buf, u32 n_bits, bool invert) +uint32_t crc24q_bits(uint32_t crc, const uint8_t *buf, uint32_t n_bits, bool invert) { - u16 acc = 0; - u8 b = 0; - u32 shift = 8 - n_bits % 8; + uint16_t acc = 0; + uint8_t b = 0; + uint32_t shift = 8 - n_bits % 8; - u32 i = 0; + uint32_t i = 0; for (i = 0; i < n_bits / 8; ++i) { - acc = (acc << 8) | *buf++; + acc = (acc << 8) | *buf++; if (invert) { acc ^= 0xFFu; } - b = (acc >> shift) & 0xFFu; - crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu]; + b = (acc >> shift) & 0xFFu; + crc = ((crc << 8) & 0xFFFFFFu) ^ CRC24QTAB[((crc >> 16) ^ b) & 0xFFu]; } - acc = (acc << 8) | *buf; + acc = (acc << 8) | *buf; if (invert) { acc ^= 0xFFu; } - b = (acc >> shift) & 0xFFu; - crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu]; + b = (acc >> shift) & 0xFFu; + crc = ((crc << 8) & 0xFFFFFFu) ^ CRC24QTAB[((crc >> 16) ^ b) & 0xFFu]; return crc; } diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.h b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.h index 58a968a65..03a4022a7 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.h +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.h @@ -35,7 +35,7 @@ #include "swift_common.h" -u32 crc24q(const u8 *buf, u32 len, u32 crc); -u32 crc24q_bits(u32 crc, const u8 *buf, u32 n_bits, bool invert); +uint32_t crc24q(const uint8_t *buf, uint32_t len, uint32_t crc); +uint32_t crc24q_bits(uint32_t crc, const uint8_t *buf, uint32_t n_bits, bool invert); #endif /* LIBSWIFTNAV_EDC_H */ diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/swift_common.h b/src/algorithms/telemetry_decoder/libs/libswiftcnav/swift_common.h index 78d99ca0f..3b83f3034 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/swift_common.h +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/swift_common.h @@ -44,40 +44,9 @@ #define MAX(x, y) (((x) > (y)) ? (x) : (y)) #define CLAMP_DIFF(a, b) (MAX((a), (b)) - (b)) -#include -#include #include - -#ifndef COMMON_INT_TYPES -#define COMMON_INT_TYPES - -/** \defgroup common_inttypes Integer types - * Specified-width integer type definitions for shorter and nicer code. - * - * These should be used in preference to unspecified width types such as - * `int` which can lead to portability issues between different platforms. - * \{ */ - -/** Signed 8-bit integer. */ -typedef int8_t s8; -/** Signed 16-bit integer. */ -typedef int16_t s16; -/** Signed 32-bit integer. */ -typedef int32_t s32; -/** Signed 64-bit integer. */ -typedef int64_t s64; -/** Unsigned 8-bit integer. */ -typedef uint8_t u8; -/** Unsigned 16-bit integer. */ -typedef uint16_t u16; -/** Unsigned 32-bit integer. */ -typedef uint32_t u32; -/** Unsigned 64-bit integer. */ -typedef uint64_t u64; - -#endif - -/** \} */ +#include +#include /** \} */ diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c index bf14cb297..c6486412a 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c @@ -30,8 +30,8 @@ */ -#include #include "fec.h" +#include static inline int parity(int x) { @@ -52,10 +52,10 @@ void v27_poly_init(v27_poly_t *poly, const signed char polynomial[2]) { int state; - for(state = 0; state < 32; state++) + for (state = 0; state < 32; state++) { - poly->c0[state] = (polynomial[0] < 0) ^ parity((2*state) & abs(polynomial[0])) ? 255 : 0; - poly->c1[state] = (polynomial[1] < 0) ^ parity((2*state) & abs(polynomial[1])) ? 255 : 0; + poly->c0[state] = (polynomial[0] < 0) ^ parity((2 * state) & abs(polynomial[0])) ? 255 : 0; + poly->c1[state] = (polynomial[1] < 0) ^ parity((2 * state) & abs(polynomial[1])) ? 255 : 0; } } @@ -72,7 +72,7 @@ void v27_poly_init(v27_poly_t *poly, const signed char polynomial[2]) * \param initial_state Initial state of the decoder shift register. Usually zero. */ void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count, - const v27_poly_t *poly, unsigned char initial_state) + const v27_poly_t *poly, unsigned char initial_state) { int i; @@ -83,28 +83,31 @@ void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count, v->decisions_index = 0; v->decisions_count = decisions_count; - for(i = 0; i < 64; i++) - v->old_metrics[i] = 63; + for (i = 0; i < 64; i++) + { + v->old_metrics[i] = 63; + } v->old_metrics[initial_state & 63] = 0; /* Bias known start state */ } /* C-language butterfly */ -#define BFLY(i) {\ - unsigned int metric,m0,m1,decision;\ - metric = (v->poly->c0[i] ^ sym0) + (v->poly->c1[i] ^ sym1);\ - m0 = v->old_metrics[i] + metric;\ - m1 = v->old_metrics[i+32] + (510 - metric);\ - decision = (signed int)(m0-m1) > 0;\ - v->new_metrics[2*i] = decision ? m1 : m0;\ - d->w[i/16] |= decision << ((2*i)&31);\ - m0 -= (metric+metric-510);\ - m1 += (metric+metric-510);\ - decision = (signed int)(m0-m1) > 0;\ - v->new_metrics[2*i+1] = decision ? m1 : m0;\ - d->w[i/16] |= decision << ((2*i+1)&31);\ -} +#define BFLY(i) \ + { \ + unsigned int metric, m0, m1, decision; \ + metric = (v->poly->c0[i] ^ sym0) + (v->poly->c1[i] ^ sym1); \ + m0 = v->old_metrics[i] + metric; \ + m1 = v->old_metrics[(i) + 32] + (510 - metric); \ + decision = (signed int)(m0 - m1) > 0; \ + v->new_metrics[2 * (i)] = decision ? m1 : m0; \ + d->w[(i) / 16] |= decision << ((2 * (i)) & 31); \ + m0 -= (metric + metric - 510); \ + m1 += (metric + metric - 510); \ + decision = (signed int)(m0 - m1) > 0; \ + v->new_metrics[2 * (i) + 1] = decision ? m1 : m0; \ + d->w[(i) / 16] |= decision << ((2 * (i) + 1) & 31); \ + } /** Update a v27_t decoder with a block of symbols. * @@ -119,7 +122,7 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits) unsigned int *tmp; int normalize = 0; - while(nbits--) + while (nbits--) { v27_decision_t *d = &v->decisions[v->decisions_index]; @@ -161,26 +164,32 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits) BFLY(31); /* Normalize metrics if they are nearing overflow */ - if(v->new_metrics[0] > (1 << 30)) + if (v->new_metrics[0] > (1 << 30)) { int i; unsigned int minmetric = 1 << 31; - for(i = 0; i < 64; i++) + for (i = 0; i < 64; i++) { - if(v->new_metrics[i] < minmetric) - minmetric = v->new_metrics[i]; + if (v->new_metrics[i] < minmetric) + { + minmetric = v->new_metrics[i]; + } } - for(i = 0; i < 64; i++) - v->new_metrics[i] -= minmetric; + for (i = 0; i < 64; i++) + { + v->new_metrics[i] -= minmetric; + } normalize += minmetric; } /* Advance decision index */ - if(++v->decisions_index >= v->decisions_count) - v->decisions_index = 0; + if (++v->decisions_index >= v->decisions_count) + { + v->decisions_index = 0; + } /* Swap pointers to old and new metrics */ tmp = v->old_metrics; @@ -199,7 +208,7 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits) * \param final_state Known final state of the decoder shift register. */ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits, - unsigned char final_state) + unsigned char final_state) { int k; unsigned int decisions_index = v->decisions_index; @@ -207,12 +216,10 @@ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits, final_state %= 64; final_state <<= 2; - while(nbits-- != 0) + while (nbits-- != 0) { - /* Decrement decision index */ - decisions_index = (decisions_index == 0) ? - v->decisions_count-1 : decisions_index-1; + decisions_index = (decisions_index == 0) ? v->decisions_count - 1 : decisions_index - 1; v27_decision_t *d = &v->decisions[decisions_index]; k = (d->w[(final_state >> 2) / 32] >> ((final_state >> 2) % 32)) & 1; @@ -239,9 +246,9 @@ void v27_chainback_likely(v27_t *v, unsigned char *data, unsigned int nbits) int i; unsigned int best_metric = 0xffffffff; unsigned char best_state = 0; - for(i = 0; i < 64; i++) + for (i = 0; i < 64; i++) { - if(v->new_metrics[i] < best_metric) + if (v->new_metrics[i] < best_metric) { best_metric = v->new_metrics[i]; best_state = i; diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc index 4d399939a..febb18294 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc @@ -180,7 +180,7 @@ int Viterbi_Decoder::do_acs(const double sym[], int nbits) int t, i, state_at_t; float metric; float max_val; - float* pm_t_next = new float[d_states]; + auto* pm_t_next = new float[d_states]; /* t: * - state: state at t @@ -199,7 +199,9 @@ int Viterbi_Decoder::do_acs(const double sym[], int nbits) { /* Temporarily store the received symbols current decoding step */ for (i = 0; i < d_nn; i++) - d_rec_array[i] = static_cast(sym[d_nn * t + i]); + { + d_rec_array[i] = static_cast(sym[d_nn * t + i]); + } /* precompute all possible branch metrics */ for (i = 0; i < d_number_symbols; i++) @@ -354,7 +356,7 @@ int Viterbi_Decoder::do_tb_and_decode(int traceback_length, int requested_decodi nn The length of the received vector This function is used by siso() */ -float Viterbi_Decoder::gamma(float rec_array[], int symbol, int nn) +float Viterbi_Decoder::gamma(const float rec_array[], int symbol, int nn) { float rm = 0; int i; @@ -559,12 +561,9 @@ int Viterbi_Decoder::Prev::get_anchestor_state_of_current_state(int current_stat { return state[current_state]; } - else - { - //std::cout<<"alarm "<<"num_states="< +) diff --git a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc new file mode 100644 index 000000000..d74732151 --- /dev/null +++ b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc @@ -0,0 +1,219 @@ +/*! + * \file beidou_b1i_dll_pll_tracking.cc + * \brief Implementation of an adapter of a DLL+PLL tracking loop block + * for Beidou B1I to a TrackingInterface + * \author Sergi Segura, 2018. sergi.segura.munoz@gmail.com + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_b1i_dll_pll_tracking.h" +#include "Beidou_B1I.h" +#include "configuration_interface.h" +#include "display.h" +#include "dll_pll_conf.h" +#include "gnss_sdr_flags.h" +#include + +using google::LogMessage; + +BeidouB1iDllPllTracking::BeidouB1iDllPllTracking( + ConfigurationInterface* configuration, const std::string& role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + Dll_Pll_Conf trk_param = Dll_Pll_Conf(); + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + std::string default_item_type = "gr_complex"; + std::string item_type = configuration->property(role + ".item_type", default_item_type); + int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + trk_param.fs_in = fs_in; + bool dump = configuration->property(role + ".dump", false); + trk_param.dump = dump; + float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } + trk_param.pll_bw_hz = pll_bw_hz; + float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); + trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; + float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); + trk_param.dll_bw_narrow_hz = dll_bw_narrow_hz; + float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } + trk_param.dll_bw_hz = dll_bw_hz; + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + trk_param.early_late_space_chips = early_late_space_chips; + float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.5); + trk_param.early_late_space_narrow_chips = early_late_space_narrow_chips; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param.dump_filename = dump_filename; + int vector_length = std::round(fs_in / (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS)); + trk_param.vector_length = vector_length; + int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); + if (symbols_extended_correlator < 1) + { + symbols_extended_correlator = 1; + std::cout << TEXT_RED << "WARNING: BEIDOU B1I. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << std::endl; + } + else if (symbols_extended_correlator > 20) + { + symbols_extended_correlator = 20; + std::cout << TEXT_RED << "WARNING: BEIDOU B1I. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << std::endl; + } + trk_param.extend_correlation_symbols = symbols_extended_correlator; + bool track_pilot = configuration->property(role + ".track_pilot", false); + if (track_pilot) + { + std::cout << TEXT_RED << "WARNING: BEIDOU B1I does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << std::endl; + } + if ((symbols_extended_correlator > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) + { + std::cout << TEXT_RED << "WARNING: BEIDOU B1I. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << std::endl; + } + trk_param.very_early_late_space_chips = 0.0; + trk_param.very_early_late_space_narrow_chips = 0.0; + trk_param.track_pilot = false; + trk_param.system = 'C'; + char sig_[3] = "B1"; + std::memcpy(trk_param.signal, sig_, 3); + int cn0_samples = configuration->property(role + ".cn0_samples", 20); + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } + trk_param.cn0_samples = cn0_samples; + int cn0_min = configuration->property(role + ".cn0_min", 25); + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } + trk_param.cn0_min = cn0_min; + int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } + trk_param.max_lock_fail = max_lock_fail; + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } + trk_param.carrier_lock_th = carrier_lock_th; + + //################# MAKE TRACKING GNURadio object ################### + if (item_type == "gr_complex") + { + item_size_ = sizeof(gr_complex); + tracking_ = dll_pll_veml_make_tracking(trk_param); + } + else + { + item_size_ = sizeof(gr_complex); + LOG(WARNING) << item_type << " unknown tracking item type."; + } + channel_ = 0; + DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } +} + + +BeidouB1iDllPllTracking::~BeidouB1iDllPllTracking() = default; + + +void BeidouB1iDllPllTracking::start_tracking() +{ + tracking_->start_tracking(); +} + +void BeidouB1iDllPllTracking::stop_tracking() +{ + tracking_->stop_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void BeidouB1iDllPllTracking::set_channel(unsigned int channel) +{ + channel_ = channel; + tracking_->set_channel(channel); +} + + +void BeidouB1iDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + tracking_->set_gnss_synchro(p_gnss_synchro); +} + + +void BeidouB1iDllPllTracking::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void BeidouB1iDllPllTracking::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr BeidouB1iDllPllTracking::get_left_block() +{ + return tracking_; +} + + +gr::basic_block_sptr BeidouB1iDllPllTracking::get_right_block() +{ + return tracking_; +} diff --git a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.h b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.h new file mode 100644 index 000000000..0716c0142 --- /dev/null +++ b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.h @@ -0,0 +1,106 @@ +/*! + * \file beidou_b1i_dll_pll_tracking.h + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for Beidou B1I to a TrackingInterface + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BEIDOU_B1I_DLL_PLL_TRACKING_H_ +#define GNSS_SDR_BEIDOU_B1I_DLL_PLL_TRACKING_H_ + +#include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a code DLL + carrier PLL tracking loop + */ +class BeidouB1iDllPllTracking : public TrackingInterface +{ +public: + BeidouB1iDllPllTracking(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~BeidouB1iDllPllTracking(); + + inline std::string role() override + { + return role_; + } + + inline std::string implementation() override + { + return "BEIDOU_B1I_DLL_PLL_Tracking"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + +private: + dll_pll_veml_tracking_sptr tracking_; + size_t item_size_; + unsigned int channel_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; +}; + +#endif // GNSS_SDR_BEIDOU_B1I_DLL_PLL_TRACKING_H_ diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc index 377b913e3..6c2bc02d0 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc @@ -35,20 +35,22 @@ */ #include "galileo_e1_dll_pll_veml_tracking.h" -#include "configuration_interface.h" #include "Galileo_E1.h" -#include "gnss_sdr_flags.h" +#include "configuration_interface.h" #include "display.h" +#include "dll_pll_conf.h" +#include "gnss_sdr_flags.h" #include using google::LogMessage; + GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - dllpllconf_t trk_param; + Dll_Pll_Conf trk_param = Dll_Pll_Conf(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; @@ -58,11 +60,32 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( trk_param.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param.dump_mat = dump_mat; + trk_param.high_dyn = configuration->property(role + ".high_dyn", false); + if (configuration->property(role + ".smoother_length", 10) < 1) + { + trk_param.smoother_length = 1; + std::cout << TEXT_RED << "WARNING: Gal. E1. smoother_length must be bigger than 0. It has been set to 1" << TEXT_RESET << std::endl; + } + else + { + trk_param.smoother_length = configuration->property(role + ".smoother_length", 10); + } float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 5.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.5); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 2.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; @@ -94,29 +117,38 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( } trk_param.track_pilot = track_pilot; trk_param.extend_correlation_symbols = extend_correlation_symbols; - std::string default_dump_filename = "./track_ch"; - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - trk_param.dump_filename = dump_filename; - int vector_length = std::round(fs_in / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS)); + int vector_length = std::round(fs_in / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); trk_param.vector_length = vector_length; trk_param.system = 'E'; char sig_[3] = "1B"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = dll_pll_veml_make_tracking(trk_param); @@ -129,10 +161,21 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GalileoE1DllPllVemlTracking::~GalileoE1DllPllVemlTracking() +GalileoE1DllPllVemlTracking::~GalileoE1DllPllVemlTracking() = default; + + +void GalileoE1DllPllVemlTracking::stop_tracking() { } diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h index 7904b958d..035daf48e 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h @@ -37,8 +37,8 @@ #ifndef GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_H_ #define GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_H_ -#include "tracking_interface.h" #include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" #include @@ -52,7 +52,7 @@ class GalileoE1DllPllVemlTracking : public TrackingInterface { public: GalileoE1DllPllVemlTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -92,6 +92,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: dll_pll_veml_tracking_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc new file mode 100644 index 000000000..1175d35d5 --- /dev/null +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -0,0 +1,252 @@ +/*! + * \file galileo_e1_dll_pll_veml_tracking_fpga.cc + * \brief Adapts a DLL+PLL VEML (Very Early Minus Late) tracking loop block + * to a TrackingInterface for Galileo E1 signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat + * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "galileo_e1_dll_pll_veml_tracking_fpga.h" +#include "Galileo_E1.h" +#include "configuration_interface.h" +#include "display.h" +#include "galileo_e1_signal_processing.h" +#include "gnss_sdr_flags.h" +#include + +using google::LogMessage; + +void GalileoE1DllPllVemlTrackingFpga::stop_tracking() +{ +} + +GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( + ConfigurationInterface* configuration, const std::string& role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + std::string default_item_type = "gr_complex"; + std::string item_type = configuration->property(role + ".item_type", default_item_type); + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + trk_param_fpga.fs_in = fs_in; + bool dump = configuration->property(role + ".dump", false); + trk_param_fpga.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param_fpga.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param_fpga.dump_mat = dump_mat; + float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 5.0); + if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + trk_param_fpga.pll_bw_hz = pll_bw_hz; + float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.5); + if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + trk_param_fpga.dll_bw_hz = dll_bw_hz; + float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 2.0); + trk_param_fpga.pll_bw_narrow_hz = pll_bw_narrow_hz; + float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 0.25); + trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; + int32_t extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.15); + trk_param_fpga.early_late_space_chips = early_late_space_chips; + float very_early_late_space_chips = configuration->property(role + ".very_early_late_space_chips", 0.6); + trk_param_fpga.very_early_late_space_chips = very_early_late_space_chips; + float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); + trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; + float very_early_late_space_narrow_chips = configuration->property(role + ".very_early_late_space_narrow_chips", 0.6); + trk_param_fpga.very_early_late_space_narrow_chips = very_early_late_space_narrow_chips; + bool track_pilot = configuration->property(role + ".track_pilot", false); + if (extend_correlation_symbols < 1) + { + extend_correlation_symbols = 1; + std::cout << TEXT_RED << "WARNING: Galileo E1. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (4 ms)" << TEXT_RESET << std::endl; + } + else if (!track_pilot and extend_correlation_symbols > 1) + { + extend_correlation_symbols = 1; + std::cout << TEXT_RED << "WARNING: Galileo E1. Extended coherent integration is not allowed when tracking the data component. Coherent integration has been set to 4 ms (1 symbol)" << TEXT_RESET << std::endl; + } + if ((extend_correlation_symbols > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) + { + std::cout << TEXT_RED << "WARNING: Galileo E1. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << std::endl; + } + trk_param_fpga.track_pilot = track_pilot; + d_track_pilot = track_pilot; + trk_param_fpga.extend_correlation_symbols = extend_correlation_symbols; + int32_t vector_length = std::round(fs_in / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); + trk_param_fpga.vector_length = vector_length; + trk_param_fpga.system = 'E'; + char sig_[3] = "1B"; + std::memcpy(trk_param_fpga.signal, sig_, 3); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); + if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + trk_param_fpga.cn0_samples = cn0_samples; + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); + if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + trk_param_fpga.cn0_min = cn0_min; + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + trk_param_fpga.max_lock_fail = max_lock_fail; + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); + if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + trk_param_fpga.carrier_lock_th = carrier_lock_th; + + // FPGA configuration parameters + std::string default_device_name = "/dev/uio"; + std::string device_name = configuration->property(role + ".devicename", default_device_name); + trk_param_fpga.device_name = device_name; + uint32_t device_base = configuration->property(role + ".device_base", 15); + trk_param_fpga.device_base = device_base; + trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> 5 correlators + + //################# PRE-COMPUTE ALL THE CODES ################# + uint32_t code_samples_per_chip = 2; + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); + float* ca_codes_f; + float* data_codes_f; + + + if (trk_param_fpga.track_pilot) + { + d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); + } + ca_codes_f = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); + + if (trk_param_fpga.track_pilot) + { + data_codes_f = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); + } + + for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) + { + char data_signal[3] = "1B"; + if (trk_param_fpga.track_pilot) + { + char pilot_signal[3] = "1C"; + galileo_e1_code_gen_sinboc11_float(ca_codes_f, pilot_signal, PRN); + galileo_e1_code_gen_sinboc11_float(data_codes_f, data_signal, PRN); + + for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) + { + d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); + d_data_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(data_codes_f[s]); + } + } + else + { + galileo_e1_code_gen_sinboc11_float(ca_codes_f, data_signal, PRN); + + for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) + { + d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); + } + } + } + + delete[] ca_codes_f; + if (trk_param_fpga.track_pilot) + { + delete[] data_codes_f; + } + trk_param_fpga.ca_codes = d_ca_codes; + trk_param_fpga.data_codes = d_data_codes; + trk_param_fpga.code_length_chips = GALILEO_E1_B_CODE_LENGTH_CHIPS; + trk_param_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip + //################# MAKE TRACKING GNURadio object ################### + tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); + channel_ = 0; + DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; +} + + +GalileoE1DllPllVemlTrackingFpga::~GalileoE1DllPllVemlTrackingFpga() +{ + delete[] d_ca_codes; + if (d_track_pilot) + { + delete[] d_data_codes; + } +} + +void GalileoE1DllPllVemlTrackingFpga::start_tracking() +{ + tracking_fpga_sc->start_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void GalileoE1DllPllVemlTrackingFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + tracking_fpga_sc->set_channel(channel); +} + + +void GalileoE1DllPllVemlTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); +} + + +void GalileoE1DllPllVemlTrackingFpga::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GalileoE1DllPllVemlTrackingFpga::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GalileoE1DllPllVemlTrackingFpga::get_left_block() +{ + return tracking_fpga_sc; +} + + +gr::basic_block_sptr GalileoE1DllPllVemlTrackingFpga::get_right_block() +{ + return tracking_fpga_sc; +} diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h new file mode 100644 index 000000000..003aec195 --- /dev/null +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h @@ -0,0 +1,116 @@ +/*! + * \file galileo_e1_dll_pll_veml_tracking_fpga.h + * \brief Adapts a DLL+PLL VEML (Very Early Minus Late) tracking loop block + * to a TrackingInterface for Galileo E1 signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat + * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_FPGA_H_ +#define GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_FPGA_H_ + +#include "dll_pll_veml_tracking_fpga.h" +#include "tracking_interface.h" +#include + + +class ConfigurationInterface; + +/*! + * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking + * loop block to a TrackingInterface for Galileo E1 signals + */ +class GalileoE1DllPllVemlTrackingFpga : public TrackingInterface +{ +public: + GalileoE1DllPllVemlTrackingFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GalileoE1DllPllVemlTrackingFpga(); + + inline std::string role() override + { + return role_; + } + + //! Returns "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga" + inline std::string implementation() override + { + return "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + + +private: + dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; + size_t item_size_; + uint32_t channel_; + std::string role_; + uint32_t in_streams_; + uint32_t out_streams_; + int32_t* d_ca_codes; + int32_t* d_data_codes; + bool d_track_pilot; +}; + + +#endif // GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_FPGA_H_ diff --git a/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc b/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc index 6a9d4000f..be3a99f0c 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc @@ -36,23 +36,24 @@ */ #include "galileo_e1_tcp_connector_tracking.h" -#include #include "Galileo_E1.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include +#include using google::LogMessage; + GalileoE1TcpConnectorTracking::GalileoE1TcpConnectorTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string item_type; @@ -65,25 +66,29 @@ GalileoE1TcpConnectorTracking::GalileoE1TcpConnectorTracking( item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.15); very_early_late_space_chips = configuration->property(role + ".very_early_late_space_chips", 0.6); port_ch0 = configuration->property(role + ".port_ch0", 2060); std::string default_dump_filename = "./track_ch"; dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - vector_length = std::round(fs_in / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS)); + vector_length = std::round(fs_in / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = galileo_e1_tcp_connector_make_tracking_cc( - f_if, fs_in, vector_length, dump, @@ -101,10 +106,21 @@ GalileoE1TcpConnectorTracking::GalileoE1TcpConnectorTracking( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GalileoE1TcpConnectorTracking::~GalileoE1TcpConnectorTracking() +GalileoE1TcpConnectorTracking::~GalileoE1TcpConnectorTracking() = default; + + +void GalileoE1TcpConnectorTracking::stop_tracking() { } diff --git a/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.h b/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.h index ae4b38220..ff68056f7 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.h @@ -39,9 +39,9 @@ #ifndef GNSS_SDR_GALILEO_E1_TCP_CONNECTOR_TRACKING_H_ #define GNSS_SDR_GALILEO_E1_TCP_CONNECTOR_TRACKING_H_ -#include -#include "tracking_interface.h" #include "galileo_e1_tcp_connector_tracking_cc.h" +#include "tracking_interface.h" +#include class ConfigurationInterface; @@ -53,7 +53,7 @@ class GalileoE1TcpConnectorTracking : public TrackingInterface { public: GalileoE1TcpConnectorTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -93,6 +93,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: galileo_e1_tcp_connector_tracking_cc_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc index 1ee9ede0a..8e5fe8314 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc @@ -35,21 +35,22 @@ * * ------------------------------------------------------------------------- */ - #include "galileo_e5a_dll_pll_tracking.h" -#include "configuration_interface.h" #include "Galileo_E5a.h" -#include "gnss_sdr_flags.h" +#include "configuration_interface.h" #include "display.h" +#include "dll_pll_conf.h" +#include "gnss_sdr_flags.h" #include using google::LogMessage; + GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - dllpllconf_t trk_param; + Dll_Pll_Conf trk_param = Dll_Pll_Conf(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; @@ -59,11 +60,32 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( trk_param.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param.dump_mat = dump_mat; + trk_param.high_dyn = configuration->property(role + ".high_dyn", false); + if (configuration->property(role + ".smoother_length", 10) < 1) + { + trk_param.smoother_length = 1; + std::cout << TEXT_RED << "WARNING: Gal. E5a. smoother_length must be bigger than 0. It has been set to 1" << TEXT_RESET << std::endl; + } + else + { + trk_param.smoother_length = configuration->property(role + ".smoother_length", 10); + } float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 20.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 20.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 5.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; @@ -71,10 +93,7 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( trk_param.dll_bw_narrow_hz = dll_bw_narrow_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param.early_late_space_chips = early_late_space_chips; - std::string default_dump_filename = "./track_ch"; - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - trk_param.dump_filename = dump_filename; - int vector_length = std::round(fs_in / (Galileo_E5a_CODE_CHIP_RATE_HZ / Galileo_E5a_CODE_LENGTH_CHIPS)); + int vector_length = std::round(fs_in / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS)); trk_param.vector_length = vector_length; int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); @@ -85,9 +104,9 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << std::endl; } - else if (!track_pilot and extend_correlation_symbols > Galileo_E5a_I_SECONDARY_CODE_LENGTH) + else if (!track_pilot and extend_correlation_symbols > GALILEO_E5A_I_SECONDARY_CODE_LENGTH) { - extend_correlation_symbols = Galileo_E5a_I_SECONDARY_CODE_LENGTH; + extend_correlation_symbols = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be lower than 21 when tracking the data component. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << std::endl; } if ((extend_correlation_symbols > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) @@ -102,20 +121,32 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( char sig_[3] = "5X"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = dll_pll_veml_make_tracking(trk_param); @@ -127,10 +158,21 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GalileoE5aDllPllTracking::~GalileoE5aDllPllTracking() +GalileoE5aDllPllTracking::~GalileoE5aDllPllTracking() = default; + + +void GalileoE5aDllPllTracking::stop_tracking() { } diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h index 484754b23..1aefcf2cf 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h @@ -39,8 +39,8 @@ #ifndef GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_H_ #define GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_H_ -#include "tracking_interface.h" #include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -52,7 +52,7 @@ class GalileoE5aDllPllTracking : public TrackingInterface { public: GalileoE5aDllPllTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -91,6 +91,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: dll_pll_veml_tracking_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc new file mode 100644 index 000000000..f66c967bd --- /dev/null +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -0,0 +1,240 @@ +/*! + * \file galileo_e5a_dll_pll_tracking_fpga.cc + * \brief Adapts a code DLL + carrier PLL + * tracking block to a TrackingInterface for Galileo E5a signals for the FPGA + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Galileo E5a data and pilot Signals for the FPGA + * \author Marc Sales, 2014. marcsales92(at)gmail.com + * \based on work from: + *
                  + *
                • Marc Majoral, 2019. mmajoral(at)cttc.cat + *
                • Javier Arribas, 2011. jarribas(at)cttc.es + *
                • Luis Esteve, 2012. luis(at)epsilon-formacion.com + *
                + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "galileo_e5a_dll_pll_tracking_fpga.h" +#include "Galileo_E5a.h" +#include "configuration_interface.h" +#include "display.h" +#include "galileo_e5_signal_processing.h" +#include "gnss_sdr_flags.h" +#include + +using google::LogMessage; + +void GalileoE5aDllPllTrackingFpga::stop_tracking() +{ +} + +GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( + ConfigurationInterface *configuration, const std::string &role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + std::string default_item_type = "gr_complex"; + std::string item_type = configuration->property(role + ".item_type", default_item_type); + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12000000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + trk_param_fpga.fs_in = fs_in; + bool dump = configuration->property(role + ".dump", false); + trk_param_fpga.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param_fpga.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param_fpga.dump_mat = dump_mat; + float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 20.0); + if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + trk_param_fpga.pll_bw_hz = pll_bw_hz; + float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 20.0); + if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + trk_param_fpga.dll_bw_hz = dll_bw_hz; + float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 5.0); + trk_param_fpga.pll_bw_narrow_hz = pll_bw_narrow_hz; + float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); + trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + trk_param_fpga.early_late_space_chips = early_late_space_chips; + int32_t vector_length = std::round(fs_in / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS)); + trk_param_fpga.vector_length = vector_length; + int32_t extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); + float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); + trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; + bool track_pilot = configuration->property(role + ".track_pilot", false); + d_track_pilot = track_pilot; + if (extend_correlation_symbols < 1) + { + extend_correlation_symbols = 1; + std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << std::endl; + } + else if (!track_pilot and extend_correlation_symbols > GALILEO_E5A_I_SECONDARY_CODE_LENGTH) + { + extend_correlation_symbols = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be lower than 21 when tracking the data component. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << std::endl; + } + if ((extend_correlation_symbols > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) + { + std::cout << TEXT_RED << "WARNING: Galileo E5a. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << std::endl; + } + trk_param_fpga.extend_correlation_symbols = extend_correlation_symbols; + trk_param_fpga.track_pilot = track_pilot; + trk_param_fpga.very_early_late_space_chips = 0.0; + trk_param_fpga.very_early_late_space_narrow_chips = 0.0; + trk_param_fpga.system = 'E'; + char sig_[3] = "5X"; + std::memcpy(trk_param_fpga.signal, sig_, 3); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); + if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + trk_param_fpga.cn0_samples = cn0_samples; + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); + if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + trk_param_fpga.cn0_min = cn0_min; + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + trk_param_fpga.max_lock_fail = max_lock_fail; + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); + if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + trk_param_fpga.carrier_lock_th = carrier_lock_th; + + // FPGA configuration parameters + std::string default_device_name = "/dev/uio"; + std::string device_name = configuration->property(role + ".devicename", default_device_name); + trk_param_fpga.device_name = device_name; + uint32_t device_base = configuration->property(role + ".device_base", 27); + trk_param_fpga.device_base = device_base; + trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> up to 5+1 correlators + + //################# PRE-COMPUTE ALL THE CODES ################# + uint32_t code_samples_per_chip = 1; + auto code_length_chips = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); + + auto *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * code_length_chips * code_samples_per_chip, volk_gnsssdr_get_alignment())); + + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); + + if (trk_param_fpga.track_pilot) + { + d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); + } + + + for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) + { + galileo_e5_a_code_gen_complex_primary(aux_code, PRN, const_cast(sig_)); + if (trk_param_fpga.track_pilot) + { + for (uint32_t s = 0; s < code_length_chips; s++) + { + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].imag()); + d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); + } + } + else + { + for (uint32_t s = 0; s < code_length_chips; s++) + { + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); + } + } + } + + volk_gnsssdr_free(aux_code); + trk_param_fpga.ca_codes = d_ca_codes; + trk_param_fpga.data_codes = d_data_codes; + trk_param_fpga.code_length_chips = code_length_chips; + trk_param_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip + //################# MAKE TRACKING GNURadio object ################### + tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); + channel_ = 0; + + DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; +} + + +GalileoE5aDllPllTrackingFpga::~GalileoE5aDllPllTrackingFpga() +{ + delete[] d_ca_codes; + if (d_track_pilot) + { + delete[] d_data_codes; + } +} + + +void GalileoE5aDllPllTrackingFpga::start_tracking() +{ + tracking_fpga_sc->start_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void GalileoE5aDllPllTrackingFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + tracking_fpga_sc->set_channel(channel); +} + + +void GalileoE5aDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); +} + + +void GalileoE5aDllPllTrackingFpga::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GalileoE5aDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GalileoE5aDllPllTrackingFpga::get_left_block() +{ + return tracking_fpga_sc; +} + + +gr::basic_block_sptr GalileoE5aDllPllTrackingFpga::get_right_block() +{ + return tracking_fpga_sc; +} diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h new file mode 100644 index 000000000..026069a51 --- /dev/null +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h @@ -0,0 +1,114 @@ +/*! + * \file galileo_e5a_dll_pll_tracking_fpga.h + * \brief Adapts a code DLL + carrier PLL + * tracking block to a TrackingInterface for Galileo E5a signals for the FPGA + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Galileo E5a data and pilot Signals for the FPGA + * \author Marc Sales, 2014. marcsales92(at)gmail.com + * \based on work from: + *
                  + *
                • Marc Majoral, 2019. mmajoral(at)cttc.cat + *
                • Javier Arribas, 2011. jarribas(at)cttc.es + *
                • Luis Esteve, 2012. luis(at)epsilon-formacion.com + *
                + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_FPGA_H_ +#define GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_FPGA_H_ + +#include "dll_pll_veml_tracking_fpga.h" +#include "tracking_interface.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a code DLL + carrier PLL tracking loop + */ +class GalileoE5aDllPllTrackingFpga : public TrackingInterface +{ +public: + GalileoE5aDllPllTrackingFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GalileoE5aDllPllTrackingFpga(); + + inline std::string role() override + { + return role_; + } + + //! Returns "Galileo_E5a_DLL_PLL_Tracking_Fpga" + inline std::string implementation() override + { + return "Galileo_E5a_DLL_PLL_Tracking_Fpga"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + +private: + dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; + size_t item_size_; + uint32_t channel_; + std::string role_; + uint32_t in_streams_; + uint32_t out_streams_; + + + int32_t* d_ca_codes; + int32_t* d_data_codes; + bool d_track_pilot; +}; + +#endif /* GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_FPGA_H_ */ diff --git a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc index 789cc6695..e3ca80dbe 100644 --- a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc @@ -38,23 +38,23 @@ */ #include "glonass_l1_ca_dll_pll_c_aid_tracking.h" +#include "GLONASS_L1_L2_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include "GLONASS_L1_L2_CA.h" #include using google::LogMessage; + GlonassL1CaDllPllCAidTracking::GlonassL1CaDllPllCAidTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string default_item_type = "gr_complex"; @@ -67,12 +67,17 @@ GlonassL1CaDllPllCAidTracking::GlonassL1CaDllPllCAidTracking( //vector_length = configuration->property(role + ".vector_length", 2048); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); int extend_correlation_ms; @@ -84,11 +89,10 @@ GlonassL1CaDllPllCAidTracking::GlonassL1CaDllPllCAidTracking( vector_length = std::round(fs_in / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); //################# MAKE TRACKING GNURadio object ################### - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_cc = glonass_l1_ca_dll_pll_c_aid_make_tracking_cc( - f_if, fs_in, vector_length, dump, @@ -101,11 +105,10 @@ GlonassL1CaDllPllCAidTracking::GlonassL1CaDllPllCAidTracking( early_late_space_chips); DLOG(INFO) << "tracking(" << tracking_cc->unique_id() << ")"; } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); tracking_sc = glonass_l1_ca_dll_pll_c_aid_make_tracking_sc( - f_if, fs_in, vector_length, dump, @@ -124,21 +127,32 @@ GlonassL1CaDllPllCAidTracking::GlonassL1CaDllPllCAidTracking( LOG(WARNING) << item_type_ << " unknown tracking item type."; } channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GlonassL1CaDllPllCAidTracking::~GlonassL1CaDllPllCAidTracking() +GlonassL1CaDllPllCAidTracking::~GlonassL1CaDllPllCAidTracking() = default; + + +void GlonassL1CaDllPllCAidTracking::stop_tracking() { } void GlonassL1CaDllPllCAidTracking::start_tracking() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->start_tracking(); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->start_tracking(); } @@ -156,11 +170,11 @@ void GlonassL1CaDllPllCAidTracking::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->set_channel(channel); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->set_channel(channel); } @@ -173,11 +187,11 @@ void GlonassL1CaDllPllCAidTracking::set_channel(unsigned int channel) void GlonassL1CaDllPllCAidTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->set_gnss_synchro(p_gnss_synchro); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->set_gnss_synchro(p_gnss_synchro); } @@ -208,35 +222,31 @@ void GlonassL1CaDllPllCAidTracking::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GlonassL1CaDllPllCAidTracking::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return tracking_cc; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } gr::basic_block_sptr GlonassL1CaDllPllCAidTracking::get_right_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return tracking_cc; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + + + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } diff --git a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.h b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.h index 3f75715dc..d50003964 100644 --- a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.h +++ b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.h @@ -40,9 +40,9 @@ #ifndef GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_H_ #define GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_H_ -#include "tracking_interface.h" #include "glonass_l1_ca_dll_pll_c_aid_tracking_cc.h" #include "glonass_l1_ca_dll_pll_c_aid_tracking_sc.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -54,7 +54,7 @@ class GlonassL1CaDllPllCAidTracking : public TrackingInterface { public: GlonassL1CaDllPllCAidTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -93,6 +93,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr tracking_cc; diff --git a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc index 7ab511b0c..406271643 100644 --- a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc @@ -37,23 +37,23 @@ */ #include "glonass_l1_ca_dll_pll_tracking.h" +#include "GLONASS_L1_L2_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include "GLONASS_L1_L2_CA.h" #include using google::LogMessage; + GlonassL1CaDllPllTracking::GlonassL1CaDllPllTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string item_type; @@ -64,23 +64,27 @@ GlonassL1CaDllPllTracking::GlonassL1CaDllPllTracking( item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); std::string default_dump_filename = "./track_ch"; dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); vector_length = std::round(fs_in / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = glonass_l1_ca_dll_pll_make_tracking_cc( - f_if, fs_in, vector_length, dump, @@ -96,10 +100,21 @@ GlonassL1CaDllPllTracking::GlonassL1CaDllPllTracking( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GlonassL1CaDllPllTracking::~GlonassL1CaDllPllTracking() +GlonassL1CaDllPllTracking::~GlonassL1CaDllPllTracking() = default; + + +void GlonassL1CaDllPllTracking::stop_tracking() { } diff --git a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.h b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.h index f752239d3..cd8482113 100644 --- a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.h @@ -39,8 +39,8 @@ #ifndef GNSS_SDR_GLONASS_L1_CA_DLL_PLL_TRACKING_H_ #define GNSS_SDR_GLONASS_L1_CA_DLL_PLL_TRACKING_H_ -#include "tracking_interface.h" #include "glonass_l1_ca_dll_pll_tracking_cc.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -52,7 +52,7 @@ class GlonassL1CaDllPllTracking : public TrackingInterface { public: GlonassL1CaDllPllTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -91,6 +91,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: glonass_l1_ca_dll_pll_tracking_cc_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc index 0219ca05d..419ccc462 100644 --- a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc @@ -36,23 +36,23 @@ */ #include "glonass_l2_ca_dll_pll_c_aid_tracking.h" -#include "configuration_interface.h" #include "GLONASS_L1_L2_CA.h" +#include "configuration_interface.h" #include "gnss_sdr_flags.h" #include using google::LogMessage; + GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string default_item_type = "gr_complex"; @@ -65,12 +65,17 @@ GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking( //vector_length = configuration->property(role + ".vector_length", 2048); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); int extend_correlation_ms; @@ -82,11 +87,10 @@ GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking( vector_length = std::round(fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); //################# MAKE TRACKING GNURadio object ################### - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_cc = glonass_l2_ca_dll_pll_c_aid_make_tracking_cc( - f_if, fs_in, vector_length, dump, @@ -99,11 +103,10 @@ GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking( early_late_space_chips); DLOG(INFO) << "tracking(" << tracking_cc->unique_id() << ")"; } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); tracking_sc = glonass_l2_ca_dll_pll_c_aid_make_tracking_sc( - f_if, fs_in, vector_length, dump, @@ -122,21 +125,32 @@ GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking( LOG(WARNING) << item_type_ << " unknown tracking item type."; } channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GlonassL2CaDllPllCAidTracking::~GlonassL2CaDllPllCAidTracking() +GlonassL2CaDllPllCAidTracking::~GlonassL2CaDllPllCAidTracking() = default; + + +void GlonassL2CaDllPllCAidTracking::stop_tracking() { } void GlonassL2CaDllPllCAidTracking::start_tracking() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->start_tracking(); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->start_tracking(); } @@ -154,11 +168,11 @@ void GlonassL2CaDllPllCAidTracking::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->set_channel(channel); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->set_channel(channel); } @@ -171,11 +185,11 @@ void GlonassL2CaDllPllCAidTracking::set_channel(unsigned int channel) void GlonassL2CaDllPllCAidTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->set_gnss_synchro(p_gnss_synchro); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->set_gnss_synchro(p_gnss_synchro); } @@ -206,35 +220,29 @@ void GlonassL2CaDllPllCAidTracking::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GlonassL2CaDllPllCAidTracking::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return tracking_cc; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } gr::basic_block_sptr GlonassL2CaDllPllCAidTracking::get_right_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return tracking_cc; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.h b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.h index bdd377b75..b5659c527 100644 --- a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.h +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.h @@ -38,9 +38,9 @@ #ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_H_ #define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_H_ -#include "tracking_interface.h" #include "glonass_l2_ca_dll_pll_c_aid_tracking_cc.h" #include "glonass_l2_ca_dll_pll_c_aid_tracking_sc.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -52,7 +52,7 @@ class GlonassL2CaDllPllCAidTracking : public TrackingInterface { public: GlonassL2CaDllPllCAidTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -91,6 +91,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr tracking_cc; diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc index 814bb19d6..1e7ded9da 100644 --- a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc @@ -35,23 +35,23 @@ */ #include "glonass_l2_ca_dll_pll_tracking.h" -#include "configuration_interface.h" #include "GLONASS_L1_L2_CA.h" +#include "configuration_interface.h" #include "gnss_sdr_flags.h" #include using google::LogMessage; + GlonassL2CaDllPllTracking::GlonassL2CaDllPllTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string item_type; @@ -62,23 +62,27 @@ GlonassL2CaDllPllTracking::GlonassL2CaDllPllTracking( item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); std::string default_dump_filename = "./track_ch"; dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); vector_length = std::round(fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = glonass_l2_ca_dll_pll_make_tracking_cc( - f_if, fs_in, vector_length, dump, @@ -94,10 +98,21 @@ GlonassL2CaDllPllTracking::GlonassL2CaDllPllTracking( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GlonassL2CaDllPllTracking::~GlonassL2CaDllPllTracking() +GlonassL2CaDllPllTracking::~GlonassL2CaDllPllTracking() = default; + + +void GlonassL2CaDllPllTracking::stop_tracking() { } diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.h b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.h index 66346bd71..1ca41a94b 100644 --- a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.h @@ -38,8 +38,8 @@ #ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_H_ #define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_H_ -#include "tracking_interface.h" #include "glonass_l2_ca_dll_pll_tracking_cc.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -51,7 +51,7 @@ class GlonassL2CaDllPllTracking : public TrackingInterface { public: GlonassL2CaDllPllTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -90,6 +90,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: glonass_l2_ca_dll_pll_tracking_cc_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc index 2d429329e..5531be4e0 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc @@ -45,15 +45,15 @@ using google::LogMessage; + GpsL1CaDllPllCAidTracking::GpsL1CaDllPllCAidTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string default_item_type = "gr_complex"; @@ -66,12 +66,17 @@ GpsL1CaDllPllCAidTracking::GpsL1CaDllPllCAidTracking( //vector_length = configuration->property(role + ".vector_length", 2048); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); int extend_correlation_ms; @@ -83,11 +88,10 @@ GpsL1CaDllPllCAidTracking::GpsL1CaDllPllCAidTracking( vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); //################# MAKE TRACKING GNURadio object ################### - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_cc = gps_l1_ca_dll_pll_c_aid_make_tracking_cc( - f_if, fs_in, vector_length, dump, @@ -100,11 +104,10 @@ GpsL1CaDllPllCAidTracking::GpsL1CaDllPllCAidTracking( early_late_space_chips); DLOG(INFO) << "tracking(" << tracking_cc->unique_id() << ")"; } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); tracking_sc = gps_l1_ca_dll_pll_c_aid_make_tracking_sc( - f_if, fs_in, vector_length, dump, @@ -123,21 +126,32 @@ GpsL1CaDllPllCAidTracking::GpsL1CaDllPllCAidTracking( LOG(WARNING) << item_type_ << " unknown tracking item type."; } channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL1CaDllPllCAidTracking::~GpsL1CaDllPllCAidTracking() +GpsL1CaDllPllCAidTracking::~GpsL1CaDllPllCAidTracking() = default; + + +void GpsL1CaDllPllCAidTracking::stop_tracking() { } void GpsL1CaDllPllCAidTracking::start_tracking() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->start_tracking(); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->start_tracking(); } @@ -154,11 +168,11 @@ void GpsL1CaDllPllCAidTracking::set_channel(unsigned int channel) { channel_ = channel; - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->set_channel(channel); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->set_channel(channel); } @@ -170,11 +184,11 @@ void GpsL1CaDllPllCAidTracking::set_channel(unsigned int channel) void GpsL1CaDllPllCAidTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { tracking_cc->set_gnss_synchro(p_gnss_synchro); } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { tracking_sc->set_gnss_synchro(p_gnss_synchro); } @@ -202,34 +216,28 @@ void GpsL1CaDllPllCAidTracking::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GpsL1CaDllPllCAidTracking::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return tracking_cc; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } gr::basic_block_sptr GpsL1CaDllPllCAidTracking::get_right_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return tracking_cc; } - else if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.h index 357a5a0c1..a1c54aa46 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.h @@ -38,9 +38,9 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_H_ #define GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_H_ -#include "tracking_interface.h" #include "gps_l1_ca_dll_pll_c_aid_tracking_cc.h" #include "gps_l1_ca_dll_pll_c_aid_tracking_sc.h" +#include "tracking_interface.h" #include @@ -53,7 +53,7 @@ class GpsL1CaDllPllCAidTracking : public TrackingInterface { public: GpsL1CaDllPllCAidTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -92,6 +92,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr tracking_cc; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc index 3c0cade84..83a60b49a 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc @@ -35,21 +35,22 @@ * ------------------------------------------------------------------------- */ - #include "gps_l1_ca_dll_pll_tracking.h" -#include "configuration_interface.h" #include "GPS_L1_CA.h" -#include "gnss_sdr_flags.h" +#include "configuration_interface.h" #include "display.h" +#include "dll_pll_conf.h" +#include "gnss_sdr_flags.h" #include using google::LogMessage; + GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - dllpllconf_t trk_param; + Dll_Pll_Conf trk_param = Dll_Pll_Conf(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; @@ -57,25 +58,43 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param.fs_in = fs_in; + trk_param.high_dyn = configuration->property(role + ".high_dyn", false); + if (configuration->property(role + ".smoother_length", 10) < 1) + { + trk_param.smoother_length = 1; + std::cout << TEXT_RED << "WARNING: GPS L1 C/A. smoother_length must be bigger than 0. It has been set to 1" << TEXT_RESET << std::endl; + } + else + { + trk_param.smoother_length = configuration->property(role + ".smoother_length", 10); + } bool dump = configuration->property(role + ".dump", false); trk_param.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param.dump_mat = dump_mat; float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); trk_param.dll_bw_narrow_hz = dll_bw_narrow_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param.early_late_space_chips = early_late_space_chips; float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.5); trk_param.early_late_space_narrow_chips = early_late_space_narrow_chips; - std::string default_dump_filename = "./track_ch"; - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - trk_param.dump_filename = dump_filename; int vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); trk_param.vector_length = vector_length; int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); @@ -106,20 +125,32 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( char sig_[3] = "1C"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; - int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + int cn0_min = configuration->property(role + ".cn0_min", 30); + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; - double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.80); + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = dll_pll_veml_make_tracking(trk_param); @@ -131,11 +162,23 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL1CaDllPllTracking::~GpsL1CaDllPllTracking() +GpsL1CaDllPllTracking::~GpsL1CaDllPllTracking() = default; + + +void GpsL1CaDllPllTracking::stop_tracking() { + tracking_->stop_tracking(); } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h index b85147b58..288de9ae0 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h @@ -38,8 +38,8 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_H_ #define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_H_ -#include "tracking_interface.h" #include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -51,7 +51,7 @@ class GpsL1CaDllPllTracking : public TrackingInterface { public: GpsL1CaDllPllTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -91,6 +91,11 @@ public: void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + private: dll_pll_veml_tracking_sptr tracking_; size_t item_size_; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index d7becc755..10939dbe8 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -1,8 +1,8 @@ /*! - * \file gps_l1_ca_dll_pll_tracking.cc + * \file gps_l1_ca_dll_pll_tracking_fpga.cc * \brief Implementation of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface that uses the FPGA - * \author Marc Majoral, 2018, mmajoral(at)cttc.es + * for GPS L1 C/A to a TrackingInterface for the FPGA + * \author Marc Majoral, 2019, mmajoral(at)cttc.es * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Javier Arribas, 2011. jarribas(at)cttc.es * @@ -13,7 +13,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -31,37 +31,45 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . + * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- */ #include "gps_l1_ca_dll_pll_tracking_fpga.h" +#include "GPS_L1_CA.h" #include "configuration_interface.h" #include "display.h" #include "gnss_sdr_flags.h" -#include "GPS_L1_CA.h" #include "gps_sdr_signal_processing.h" #include - #define NUM_PRNs 32 using google::LogMessage; +void GpsL1CaDllPllTrackingFpga::stop_tracking() +{ +} + GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - dllpllconf_fpga_t trk_param_fpga; + Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param_fpga.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param_fpga.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param_fpga.dump_mat = dump_mat; float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); trk_param_fpga.pll_bw_hz = pll_bw_hz; @@ -76,12 +84,9 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( trk_param_fpga.early_late_space_chips = early_late_space_chips; float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.5); trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; - std::string default_dump_filename = "./track_ch"; - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - trk_param_fpga.dump_filename = dump_filename; - int vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); + int32_t vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); trk_param_fpga.vector_length = vector_length; - int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); + int32_t symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); if (symbols_extended_correlator < 1) { symbols_extended_correlator = 1; @@ -108,13 +113,13 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( trk_param_fpga.system = 'G'; char sig_[3] = "1C"; std::memcpy(trk_param_fpga.signal, sig_, 3); - int cn0_samples = configuration->property(role + ".cn0_samples", 20); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; trk_param_fpga.cn0_samples = cn0_samples; - int cn0_min = configuration->property(role + ".cn0_min", 25); + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; trk_param_fpga.cn0_min = cn0_min; - int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; trk_param_fpga.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); @@ -125,17 +130,19 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 1); + uint32_t device_base = configuration->property(role + ".device_base", 3); trk_param_fpga.device_base = device_base; + trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators //################# PRE-COMPUTE ALL THE CODES ################# - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { - gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); + gps_l1_ca_code_gen_int(&d_ca_codes[(int32_t(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); } trk_param_fpga.ca_codes = d_ca_codes; - trk_param_fpga.code_length = GPS_L1_CA_CODE_LENGTH_CHIPS; + trk_param_fpga.code_length_chips = GPS_L1_CA_CODE_LENGTH_CHIPS; + trk_param_fpga.code_samples_per_chip = 1; // 1 sample per chip //################# MAKE TRACKING GNURadio object ################### tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); @@ -143,19 +150,16 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; } - GpsL1CaDllPllTrackingFpga::~GpsL1CaDllPllTrackingFpga() { delete[] d_ca_codes; } - void GpsL1CaDllPllTrackingFpga::start_tracking() { tracking_fpga_sc->start_tracking(); } - /* * Set tracking channel unique ID */ @@ -165,13 +169,11 @@ void GpsL1CaDllPllTrackingFpga::set_channel(unsigned int channel) tracking_fpga_sc->set_channel(channel); } - void GpsL1CaDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); } - void GpsL1CaDllPllTrackingFpga::connect(gr::top_block_sptr top_block) { if (top_block) diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index de77dff2e..cd1b8415f 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -1,8 +1,8 @@ /*! - * \file gps_l1_ca_dll_pll_tracking.h + * \file gps_l1_ca_dll_pll_tracking_fpga.h * \brief Interface of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface that uses the FPGA - * \author Marc Majoral, 2018. mmajoral(at)cttc.es + * for GPS L1 C/A to a TrackingInterface for the FPGA + * \author Marc Majoral, 2019, mmajoral(at)cttc.es * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Javier Arribas, 2011. jarribas(at)cttc.es * @@ -13,7 +13,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -31,7 +31,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . + * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- */ @@ -39,10 +39,11 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ #define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ -#include "tracking_interface.h" #include "dll_pll_veml_tracking_fpga.h" +#include "tracking_interface.h" #include + class ConfigurationInterface; /*! @@ -52,7 +53,7 @@ class GpsL1CaDllPllTrackingFpga : public TrackingInterface { public: GpsL1CaDllPllTrackingFpga(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -92,14 +93,19 @@ public: void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; - unsigned int channel_; + uint32_t channel_; std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; - int* d_ca_codes; + uint32_t in_streams_; + uint32_t out_streams_; + int32_t* d_ca_codes; }; #endif // GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.cc index b2a9e84ec..848cd2bd6 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.cc @@ -36,14 +36,18 @@ #include "gps_l1_ca_dll_pll_tracking_gpu.h" -#include #include "GPS_L1_CA.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" +#include using google::LogMessage; +void GpsL1CaDllPllTrackingGPU::stop_tracking() +{ +} + GpsL1CaDllPllTrackingGPU::GpsL1CaDllPllTrackingGPU( ConfigurationInterface* configuration, std::string role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) @@ -52,7 +56,6 @@ GpsL1CaDllPllTrackingGPU::GpsL1CaDllPllTrackingGPU( //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string item_type; @@ -64,7 +67,6 @@ GpsL1CaDllPllTrackingGPU::GpsL1CaDllPllTrackingGPU( //vector_length = configuration->property(role + ".vector_length", 2048); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); @@ -80,7 +82,6 @@ GpsL1CaDllPllTrackingGPU::GpsL1CaDllPllTrackingGPU( { item_size_ = sizeof(gr_complex); tracking_ = gps_l1_ca_dll_pll_make_tracking_gpu_cc( - f_if, fs_in, vector_length, dump, @@ -96,6 +97,14 @@ GpsL1CaDllPllTrackingGPU::GpsL1CaDllPllTrackingGPU( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.h index 9c77f4743..1a5c381ab 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.h @@ -37,9 +37,9 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_GPU_H_ #define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_GPU_H_ -#include -#include "tracking_interface.h" #include "gps_l1_ca_dll_pll_tracking_gpu_cc.h" +#include "tracking_interface.h" +#include class ConfigurationInterface; @@ -91,6 +91,11 @@ public: void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + private: gps_l1_ca_dll_pll_tracking_gpu_cc_sptr tracking_; size_t item_size_; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc new file mode 100644 index 000000000..b10cecafd --- /dev/null +++ b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc @@ -0,0 +1,181 @@ +/*! + * \file gps_l1_ca_kf_tracking.cc + * \brief Implementation of an adapter of a DLL + Kalman carrier + * tracking loop block for GPS L1 C/A signals + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Jordi Vila-Valls 2018. jvila(at)cttc.es + * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es + * + * Reference: + * J. Vila-Valls, P. Closas, M. Navarro and C. Fernández-Prades, + * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital + * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, + * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "gps_l1_ca_kf_tracking.h" +#include "GPS_L1_CA.h" +#include "configuration_interface.h" +#include "gnss_sdr_flags.h" +#include + + +using google::LogMessage; + + +GpsL1CaKfTracking::GpsL1CaKfTracking( + ConfigurationInterface* configuration, const std::string& role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + int order; + int fs_in; + int vector_length; + int f_if; + bool dump; + std::string dump_filename; + std::string item_type; + std::string default_item_type = "gr_complex"; + float dll_bw_hz; + float early_late_space_chips; + bool bce_run; + unsigned int bce_ptrans; + unsigned int bce_strans; + int bce_nu; + int bce_kappa; + + item_type = configuration->property(role + ".item_type", default_item_type); + order = configuration->property(role + ".order", 2); + int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + f_if = configuration->property(role + ".if", 0); + dump = configuration->property(role + ".dump", false); + dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } + early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + std::string default_dump_filename = "./track_ch"; + dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); + + bce_run = configuration->property(role + ".bce_run", false); + bce_ptrans = configuration->property(role + ".p_transient", 0); + bce_strans = configuration->property(role + ".s_transient", 0); + bce_nu = configuration->property(role + ".bce_nu", 0); + bce_kappa = configuration->property(role + ".bce_kappa", 0); + + //################# MAKE TRACKING GNURadio object ################### + if (item_type == "gr_complex") + { + item_size_ = sizeof(gr_complex); + tracking_ = gps_l1_ca_kf_make_tracking_cc( + order, + f_if, + fs_in, + vector_length, + dump, + dump_filename, + dll_bw_hz, + early_late_space_chips, + bce_run, + bce_ptrans, + bce_strans, + bce_nu, + bce_kappa); + } + else + { + item_size_ = sizeof(gr_complex); + LOG(WARNING) << item_type << " unknown tracking item type."; + } + channel_ = 0; + DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; +} + + +GpsL1CaKfTracking::~GpsL1CaKfTracking() = default; + + +void GpsL1CaKfTracking::stop_tracking() +{ +} + + +void GpsL1CaKfTracking::start_tracking() +{ + tracking_->start_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void GpsL1CaKfTracking::set_channel(unsigned int channel) +{ + channel_ = channel; + tracking_->set_channel(channel); +} + + +void GpsL1CaKfTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + tracking_->set_gnss_synchro(p_gnss_synchro); +} + + +void GpsL1CaKfTracking::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GpsL1CaKfTracking::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GpsL1CaKfTracking::get_left_block() +{ + return tracking_; +} + + +gr::basic_block_sptr GpsL1CaKfTracking::get_right_block() +{ + return tracking_; +} diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.h new file mode 100644 index 000000000..e26198619 --- /dev/null +++ b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.h @@ -0,0 +1,110 @@ +/*! + * \file gps_l1_ca_kf_tracking.h + * \brief Interface of an adapter of a DLL + Kalman carrier + * tracking loop block for GPS L1 C/A signals + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Jordi Vila-Valls 2018. jvila(at)cttc.es + * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es + * + * Reference: + * J. Vila-Valls, P. Closas, M. Navarro and C. Fernandez-Prades, + * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital + * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, + * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GPS_L1_CA_KF_TRACKING_H_ +#define GNSS_SDR_GPS_L1_CA_KF_TRACKING_H_ + +#include "gps_l1_ca_kf_tracking_cc.h" +#include "tracking_interface.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a code DLL + carrier PLL tracking loop + */ +class GpsL1CaKfTracking : public TrackingInterface +{ +public: + GpsL1CaKfTracking(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GpsL1CaKfTracking(); + + inline std::string role() override + { + return role_; + } + + //! Returns "GPS_L1_CA_KF_Tracking" + inline std::string implementation() override + { + return "GPS_L1_CA_KF_Tracking"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + +private: + gps_l1_ca_kf_tracking_cc_sptr tracking_; + size_t item_size_; + unsigned int channel_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; +}; + +#endif // GNSS_SDR_GPS_L1_CA_KF_TRACKING_H_ diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.cc index c7cd025a4..15e7f650b 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.cc @@ -36,22 +36,23 @@ */ #include "gps_l1_ca_tcp_connector_tracking.h" -#include #include "GPS_L1_CA.h" #include "configuration_interface.h" +#include +#include using google::LogMessage; + GpsL1CaTcpConnectorTracking::GpsL1CaTcpConnectorTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string item_type; @@ -62,7 +63,6 @@ GpsL1CaTcpConnectorTracking::GpsL1CaTcpConnectorTracking( //vector_length = configuration->property(role + ".vector_length", 2048); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); port_ch0 = configuration->property(role + ".port_ch0", 2060); @@ -71,11 +71,10 @@ GpsL1CaTcpConnectorTracking::GpsL1CaTcpConnectorTracking( vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = gps_l1_ca_tcp_connector_make_tracking_cc( - f_if, fs_in, vector_length, dump, @@ -91,10 +90,21 @@ GpsL1CaTcpConnectorTracking::GpsL1CaTcpConnectorTracking( channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL1CaTcpConnectorTracking::~GpsL1CaTcpConnectorTracking() +GpsL1CaTcpConnectorTracking::~GpsL1CaTcpConnectorTracking() = default; + + +void GpsL1CaTcpConnectorTracking::stop_tracking() { } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.h index 75a986cfc..1e910839e 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_tcp_connector_tracking.h @@ -38,9 +38,9 @@ #ifndef GNSS_SDR_GPS_L1_CA_TCP_CONNECTOR_TRACKING_H_ #define GNSS_SDR_GPS_L1_CA_TCP_CONNECTOR_TRACKING_H_ -#include -#include "tracking_interface.h" #include "gps_l1_ca_tcp_connector_tracking_cc.h" +#include "tracking_interface.h" +#include class ConfigurationInterface; @@ -52,7 +52,7 @@ class GpsL1CaTcpConnectorTracking : public TrackingInterface { public: GpsL1CaTcpConnectorTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -91,6 +91,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: gps_l1_ca_tcp_connector_tracking_cc_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc index 2de8eb7cf..c55191bd2 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc @@ -34,22 +34,23 @@ * ------------------------------------------------------------------------- */ - #include "gps_l2_m_dll_pll_tracking.h" -#include "configuration_interface.h" #include "GPS_L2C.h" -#include "gnss_sdr_flags.h" +#include "configuration_interface.h" #include "display.h" +#include "dll_pll_conf.h" +#include "gnss_sdr_flags.h" #include using google::LogMessage; + GpsL2MDllPllTracking::GpsL2MDllPllTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - dllpllconf_t trk_param; + Dll_Pll_Conf trk_param = Dll_Pll_Conf(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; @@ -59,18 +60,26 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking( trk_param.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param.dump_mat = dump_mat; float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 2.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.75); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param.early_late_space_chips = early_late_space_chips; trk_param.early_late_space_narrow_chips = 0.0; - std::string default_dump_filename = "./track_ch"; - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - trk_param.dump_filename = dump_filename; int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L2_M_CODE_RATE_HZ) / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); trk_param.vector_length = vector_length; int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); @@ -93,20 +102,32 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking( char sig_[3] = "2S"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = dll_pll_veml_make_tracking(trk_param); @@ -118,14 +139,24 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL2MDllPllTracking::~GpsL2MDllPllTracking() +GpsL2MDllPllTracking::~GpsL2MDllPllTracking() = default; + + +void GpsL2MDllPllTracking::stop_tracking() { } - void GpsL2MDllPllTracking::start_tracking() { tracking_->start_tracking(); diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h index 68305ad6a..20618a4cf 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h @@ -38,8 +38,8 @@ #ifndef GNSS_SDR_gps_l2_m_dll_pll_tracking_H_ #define GNSS_SDR_gps_l2_m_dll_pll_tracking_H_ -#include "tracking_interface.h" #include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -51,7 +51,7 @@ class GpsL2MDllPllTracking : public TrackingInterface { public: GpsL2MDllPllTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -90,6 +90,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: dll_pll_veml_tracking_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc new file mode 100644 index 000000000..c133b1ea1 --- /dev/null +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc @@ -0,0 +1,227 @@ +/*! + * \file gps_l2_m_dll_pll_tracking.cc + * \brief Implementation of an adapter of a DLL+PLL tracking loop block + * for GPS L1 C/A to a TrackingInterface + * \author Javier Arribas, 2015. jarribas(at)cttc.es + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "gps_l2_m_dll_pll_tracking_fpga.h" +#include "GPS_L2C.h" +#include "configuration_interface.h" +#include "display.h" +#include "gnss_sdr_flags.h" +#include "gps_l2c_signal.h" +#include + +#define NUM_PRNs 32 + +using google::LogMessage; + +void GpsL2MDllPllTrackingFpga::stop_tracking() +{ +} + +GpsL2MDllPllTrackingFpga::GpsL2MDllPllTrackingFpga( + ConfigurationInterface* configuration, const std::string& role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + //dllpllconf_t trk_param; + Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + //std::string default_item_type = "gr_complex"; + //std::string item_type = configuration->property(role + ".item_type", default_item_type); + int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + trk_param_fpga.fs_in = fs_in; + bool dump = configuration->property(role + ".dump", false); + trk_param_fpga.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param_fpga.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param_fpga.dump_mat = dump_mat; + float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 2.0); + if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + trk_param_fpga.pll_bw_hz = pll_bw_hz; + float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.75); + if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + trk_param_fpga.dll_bw_hz = dll_bw_hz; + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + trk_param_fpga.early_late_space_chips = early_late_space_chips; + trk_param_fpga.early_late_space_narrow_chips = 0.0; + int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L2_M_CODE_RATE_HZ) / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); + trk_param_fpga.vector_length = vector_length; + int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); + if (symbols_extended_correlator != 1) + { + std::cout << TEXT_RED << "WARNING: Extended coherent integration is not allowed in GPS L2. Coherent integration has been set to 20 ms (1 symbol)" << TEXT_RESET << std::endl; + } + trk_param_fpga.extend_correlation_symbols = 1; + bool track_pilot = configuration->property(role + ".track_pilot", false); + if (track_pilot) + { + std::cout << TEXT_RED << "WARNING: GPS L2 does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << std::endl; + } + trk_param_fpga.track_pilot = false; + trk_param_fpga.very_early_late_space_chips = 0.0; + trk_param_fpga.very_early_late_space_narrow_chips = 0.0; + trk_param_fpga.pll_bw_narrow_hz = 0.0; + trk_param_fpga.dll_bw_narrow_hz = 0.0; + trk_param_fpga.system = 'G'; + char sig_[3] = "2S"; + std::memcpy(trk_param_fpga.signal, sig_, 3); + int cn0_samples = configuration->property(role + ".cn0_samples", 20); + if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + trk_param_fpga.cn0_samples = cn0_samples; + int cn0_min = configuration->property(role + ".cn0_min", 25); + if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + trk_param_fpga.cn0_min = cn0_min; + int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + trk_param_fpga.max_lock_fail = max_lock_fail; + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); + if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + trk_param_fpga.carrier_lock_th = carrier_lock_th; + + // FPGA configuration parameters + std::string default_device_name = "/dev/uio"; + std::string device_name = configuration->property(role + ".devicename", default_device_name); + trk_param_fpga.device_name = device_name; + unsigned int device_base = configuration->property(role + ".device_base", 1); + trk_param_fpga.device_base = device_base; + //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 0); + trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators + + //d_tracking_code = static_cast(volk_gnsssdr_malloc(2 * static_cast(GPS_L2_M_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment())); + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L2_M_CODE_LENGTH_CHIPS) * NUM_PRNs * sizeof(int), volk_gnsssdr_get_alignment())); + auto* ca_codes_f = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L2_M_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment())); + + //################# PRE-COMPUTE ALL THE CODES ################# + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L2_M_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); + for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + { + //gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); + gps_l2c_m_code_gen_float(ca_codes_f, PRN); + for (unsigned int s = 0; s < 2 * static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); s++) + { + d_ca_codes[static_cast(GPS_L2_M_CODE_LENGTH_CHIPS) * (PRN - 1) + s] = static_cast(ca_codes_f[s]); + } + } + + delete[] ca_codes_f; + + trk_param_fpga.ca_codes = d_ca_codes; + trk_param_fpga.code_length_chips = GPS_L2_M_CODE_LENGTH_CHIPS; + trk_param_fpga.code_samples_per_chip = 1; // 1 sample per chip + + //################# MAKE TRACKING GNURadio object ################### + + // //################# MAKE TRACKING GNURadio object ################### + // if (item_type.compare("gr_complex") == 0) + // { + // item_size_ = sizeof(gr_complex); + // tracking_ = dll_pll_veml_make_tracking(trk_param); + // } + // else + // { + // item_size_ = sizeof(gr_complex); + // LOG(WARNING) << item_type << " unknown tracking item type."; + // } + + //################# MAKE TRACKING GNURadio object ################### + tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); + + channel_ = 0; + DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; +} + + +GpsL2MDllPllTrackingFpga::~GpsL2MDllPllTrackingFpga() = default; + + +void GpsL2MDllPllTrackingFpga::start_tracking() +{ + //tracking_->start_tracking(); + tracking_fpga_sc->start_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void GpsL2MDllPllTrackingFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + //tracking_->set_channel(channel); + tracking_fpga_sc->set_channel(channel); +} + + +void GpsL2MDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + //tracking_->set_gnss_synchro(p_gnss_synchro); + tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); +} + + +void GpsL2MDllPllTrackingFpga::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GpsL2MDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GpsL2MDllPllTrackingFpga::get_left_block() +{ + //return tracking_; + return tracking_fpga_sc; +} + + +gr::basic_block_sptr GpsL2MDllPllTrackingFpga::get_right_block() +{ + //return tracking_; + return tracking_fpga_sc; +} diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h new file mode 100644 index 000000000..e1a606f1f --- /dev/null +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h @@ -0,0 +1,110 @@ +/*! + * \file gps_l2_m_dll_pll_tracking.h + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for GPS L1 C/A to a TrackingInterface + * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com + * Javier Arribas, 2011. jarribas(at)cttc.es + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_gps_l2_m_dll_pll_tracking_FPGA_H_ +#define GNSS_SDR_gps_l2_m_dll_pll_tracking_FPGA_H_ + +#include "tracking_interface.h" +//#include "dll_pll_veml_tracking.h" +#include "dll_pll_veml_tracking_fpga.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a code DLL + carrier PLL tracking loop + */ +class GpsL2MDllPllTrackingFpga : public TrackingInterface +{ +public: + GpsL2MDllPllTrackingFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GpsL2MDllPllTrackingFpga(); + + inline std::string role() override + { + return role_; + } + + //! Returns "GPS_L2_M_DLL_PLL_Tracking_Fpga" + inline std::string implementation() override + { + return "GPS_L2_M_DLL_PLL_Tracking_Fpga"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + +private: + //dll_pll_veml_tracking_sptr tracking_; + dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; + size_t item_size_; + unsigned int channel_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; + int* d_ca_codes; +}; + +#endif // GNSS_SDR_gps_l2_m_dll_pll_tracking_FPGA_H_ diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc index e3aa382d8..1fdba0405 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc @@ -34,22 +34,23 @@ * ------------------------------------------------------------------------- */ - #include "gps_l5_dll_pll_tracking.h" -#include "configuration_interface.h" #include "GPS_L5.h" -#include "gnss_sdr_flags.h" +#include "configuration_interface.h" #include "display.h" +#include "dll_pll_conf.h" +#include "gnss_sdr_flags.h" #include using google::LogMessage; + GpsL5DllPllTracking::GpsL5DllPllTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - dllpllconf_t trk_param; + Dll_Pll_Conf trk_param = Dll_Pll_Conf(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; @@ -59,11 +60,32 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( trk_param.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param.dump_mat = dump_mat; + trk_param.high_dyn = configuration->property(role + ".high_dyn", false); + if (configuration->property(role + ".smoother_length", 10) < 1) + { + trk_param.smoother_length = 1; + std::cout << TEXT_RED << "WARNING: GPS L5. smoother_length must be bigger than 0. It has been set to 1" << TEXT_RESET << std::endl; + } + else + { + trk_param.smoother_length = configuration->property(role + ".smoother_length", 10); + } float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 2.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; @@ -71,10 +93,7 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( trk_param.dll_bw_narrow_hz = dll_bw_narrow_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param.early_late_space_chips = early_late_space_chips; - std::string default_dump_filename = "./track_ch"; - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - trk_param.dump_filename = dump_filename; - int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5i_CODE_RATE_HZ) / static_cast(GPS_L5i_CODE_LENGTH_CHIPS))); + int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5I_CODE_RATE_HZ) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS))); trk_param.vector_length = vector_length; int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); @@ -85,9 +104,9 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << std::endl; } - else if (!track_pilot and extend_correlation_symbols > GPS_L5i_NH_CODE_LENGTH) + else if (!track_pilot and extend_correlation_symbols > GPS_L5I_NH_CODE_LENGTH) { - extend_correlation_symbols = GPS_L5i_NH_CODE_LENGTH; + extend_correlation_symbols = GPS_L5I_NH_CODE_LENGTH; std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be lower than 11 when tracking the data component. Coherent integration has been set to 10 symbols (10 ms)" << TEXT_RESET << std::endl; } if ((extend_correlation_symbols > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) @@ -102,20 +121,32 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( char sig_[3] = "L5"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; - double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.75); + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = dll_pll_veml_make_tracking(trk_param); @@ -127,10 +158,21 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } -GpsL5DllPllTracking::~GpsL5DllPllTracking() +GpsL5DllPllTracking::~GpsL5DllPllTracking() = default; + + +void GpsL5DllPllTracking::stop_tracking() { } diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h index 9cfbd58fa..763df8bb0 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h @@ -37,8 +37,8 @@ #ifndef GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_H_ #define GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_H_ -#include "tracking_interface.h" #include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" #include class ConfigurationInterface; @@ -50,7 +50,7 @@ class GpsL5DllPllTracking : public TrackingInterface { public: GpsL5DllPllTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -89,6 +89,10 @@ public: void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; private: dll_pll_veml_tracking_sptr tracking_; diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc new file mode 100644 index 000000000..764a69a97 --- /dev/null +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -0,0 +1,253 @@ +/*! + * \file gps_l5_dll_pll_tracking.cc + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for GPS L5 to a TrackingInterface + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat + * \author Javier Arribas, 2017. jarribas(at)cttc.es + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "gps_l5_dll_pll_tracking_fpga.h" +#include "GPS_L5.h" +#include "configuration_interface.h" +#include "display.h" +#include "gnss_sdr_flags.h" +#include "gps_l5_signal.h" +#include + +#define NUM_PRNs 32 + +using google::LogMessage; + +void GpsL5DllPllTrackingFpga::stop_tracking() +{ +} + +GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( + ConfigurationInterface *configuration, const std::string &role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12500000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + trk_param_fpga.fs_in = fs_in; + bool dump = configuration->property(role + ".dump", false); + trk_param_fpga.dump = dump; + std::string default_dump_filename = "./track_ch"; + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param_fpga.dump_filename = dump_filename; + bool dump_mat = configuration->property(role + ".dump_mat", true); + trk_param_fpga.dump_mat = dump_mat; + float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); + if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + trk_param_fpga.pll_bw_hz = pll_bw_hz; + float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); + if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + trk_param_fpga.dll_bw_hz = dll_bw_hz; + float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 2.0); + trk_param_fpga.pll_bw_narrow_hz = pll_bw_narrow_hz; + float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 0.25); + trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + trk_param_fpga.early_late_space_chips = early_late_space_chips; + int32_t vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5I_CODE_RATE_HZ) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS))); + trk_param_fpga.vector_length = vector_length; + int32_t extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); + float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); + trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; + bool track_pilot = configuration->property(role + ".track_pilot", false); + if (extend_correlation_symbols < 1) + { + extend_correlation_symbols = 1; + std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << std::endl; + } + else if (!track_pilot and extend_correlation_symbols > GPS_L5I_NH_CODE_LENGTH) + { + extend_correlation_symbols = GPS_L5I_NH_CODE_LENGTH; + std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be lower than 11 when tracking the data component. Coherent integration has been set to 10 symbols (10 ms)" << TEXT_RESET << std::endl; + } + if ((extend_correlation_symbols > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) + { + std::cout << TEXT_RED << "WARNING: GPS L5. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << std::endl; + } + trk_param_fpga.extend_correlation_symbols = extend_correlation_symbols; + trk_param_fpga.track_pilot = track_pilot; + d_track_pilot = track_pilot; + trk_param_fpga.very_early_late_space_chips = 0.0; + trk_param_fpga.very_early_late_space_narrow_chips = 0.0; + trk_param_fpga.system = 'G'; + char sig_[3] = "L5"; + std::memcpy(trk_param_fpga.signal, sig_, 3); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); + if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + trk_param_fpga.cn0_samples = cn0_samples; + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); + if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + trk_param_fpga.cn0_min = cn0_min; + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + trk_param_fpga.max_lock_fail = max_lock_fail; + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.75); + if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + trk_param_fpga.carrier_lock_th = carrier_lock_th; + + // FPGA configuration parameters + + std::string default_device_name = "/dev/uio"; + std::string device_name = configuration->property(role + ".devicename", default_device_name); + trk_param_fpga.device_name = device_name; + uint32_t device_base = configuration->property(role + ".device_base", 27); + trk_param_fpga.device_base = device_base; + trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators + //################# PRE-COMPUTE ALL THE CODES ################# + uint32_t code_samples_per_chip = 1; + auto code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); + + float *tracking_code; + float *data_code; + + tracking_code = static_cast(volk_gnsssdr_malloc(code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); + + if (trk_param_fpga.track_pilot) + { + data_code = static_cast(volk_gnsssdr_malloc(code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); + } + + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + + if (trk_param_fpga.track_pilot) + { + d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * NUM_PRNs * sizeof(int32_t), volk_gnsssdr_get_alignment())); + } + + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) + { + if (trk_param_fpga.track_pilot) + { + gps_l5q_code_gen_float(tracking_code, PRN); + gps_l5i_code_gen_float(data_code, PRN); + + + for (uint32_t s = 0; s < code_length_chips; s++) + { + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); + } + } + + else + { + gps_l5i_code_gen_float(tracking_code, PRN); + for (uint32_t s = 0; s < code_length_chips; s++) + { + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + } + } + } + + delete[] tracking_code; + if (trk_param_fpga.track_pilot) + { + delete[] data_code; + } + trk_param_fpga.ca_codes = d_ca_codes; + trk_param_fpga.data_codes = d_data_codes; + trk_param_fpga.code_length_chips = code_length_chips; + trk_param_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip + tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); + channel_ = 0; + DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; +} + + +GpsL5DllPllTrackingFpga::~GpsL5DllPllTrackingFpga() +{ + delete[] d_ca_codes; + if (d_track_pilot) + { + delete[] d_data_codes; + } +} + + +void GpsL5DllPllTrackingFpga::start_tracking() +{ + tracking_fpga_sc->start_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void GpsL5DllPllTrackingFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + tracking_fpga_sc->set_channel(channel); +} + + +void GpsL5DllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); +} + + +void GpsL5DllPllTrackingFpga::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GpsL5DllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GpsL5DllPllTrackingFpga::get_left_block() +{ + return tracking_fpga_sc; +} + + +gr::basic_block_sptr GpsL5DllPllTrackingFpga::get_right_block() +{ + return tracking_fpga_sc; +} diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h new file mode 100644 index 000000000..08c085d73 --- /dev/null +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h @@ -0,0 +1,110 @@ +/*! + * \file gps_l5_dll_pll_tracking.h + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for GPS L5 to a TrackingInterface + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat + * \author Javier Arribas, 2017. jarribas(at)cttc.es + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H_ +#define GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H_ + +#include "dll_pll_veml_tracking_fpga.h" +#include "tracking_interface.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a code DLL + carrier PLL tracking loop + */ +class GpsL5DllPllTrackingFpga : public TrackingInterface +{ +public: + GpsL5DllPllTrackingFpga(ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GpsL5DllPllTrackingFpga(); + + inline std::string role() override + { + return role_; + } + + //! Returns "GPS_L5_DLL_PLL_Tracking" + inline std::string implementation() override + { + return "GPS_L5_DLL_PLL_Tracking"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + /*! + * \brief Stop running tracking + */ + void stop_tracking() override; + +private: + dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; + size_t item_size_; + uint32_t channel_; + std::string role_; + uint32_t in_streams_; + uint32_t out_streams_; + bool d_track_pilot; + int32_t* d_ca_codes; + int32_t* d_data_codes; +}; + +#endif // GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H_ diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index a0bd80004..48da0fc1b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,65 +17,101 @@ # if(ENABLE_CUDA) - set(OPT_TRACKING_BLOCKS ${OPT_TRACKING_BLOCKS} gps_l1_ca_dll_pll_tracking_gpu_cc.cc) - set(OPT_TRACKING_INCLUDES ${OPT_TRACKING_INCLUDES} ${CUDA_INCLUDE_DIRS}) - set(OPT_TRACKING_LIBRARIES ${OPT_TRACKING_LIBRARIES} ${CUDA_LIBRARIES}) -endif(ENABLE_CUDA) + set(OPT_TRACKING_BLOCKS_SOURCES + ${OPT_TRACKING_BLOCKS_SOURCES} + gps_l1_ca_dll_pll_tracking_gpu_cc.cc + ) + set(OPT_TRACKING_BLOCKS_HEADERS + ${OPT_TRACKING_BLOCKS_HEADERS} + gps_l1_ca_dll_pll_tracking_gpu_cc.h + ) +endif() if(ENABLE_FPGA) - set(OPT_TRACKING_BLOCKS ${OPT_TRACKING_BLOCKS} dll_pll_veml_tracking_fpga.cc) -endif(ENABLE_FPGA) + set(OPT_TRACKING_BLOCKS_SOURCES + ${OPT_TRACKING_BLOCKS_SOURCES} + dll_pll_veml_tracking_fpga.cc + ) + set(OPT_TRACKING_BLOCKS_HEADERS + ${OPT_TRACKING_BLOCKS_HEADERS} + dll_pll_veml_tracking_fpga.h + ) +endif() set(TRACKING_GR_BLOCKS_SOURCES - galileo_e1_tcp_connector_tracking_cc.cc - gps_l1_ca_tcp_connector_tracking_cc.cc - gps_l1_ca_dll_pll_c_aid_tracking_cc.cc - gps_l1_ca_dll_pll_c_aid_tracking_sc.cc - glonass_l1_ca_dll_pll_tracking_cc.cc - glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc - glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc - glonass_l2_ca_dll_pll_tracking_cc.cc - glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc - glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc - dll_pll_veml_tracking.cc - ${OPT_TRACKING_BLOCKS} + galileo_e1_tcp_connector_tracking_cc.cc + gps_l1_ca_tcp_connector_tracking_cc.cc + gps_l1_ca_dll_pll_c_aid_tracking_cc.cc + gps_l1_ca_dll_pll_c_aid_tracking_sc.cc + glonass_l1_ca_dll_pll_tracking_cc.cc + glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc + glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc + gps_l1_ca_kf_tracking_cc.cc + glonass_l2_ca_dll_pll_tracking_cc.cc + glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc + glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc + dll_pll_veml_tracking.cc + ${OPT_TRACKING_BLOCKS_SOURCES} ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} - ${OPT_TRACKING_INCLUDES} - ${MATIO_INCLUDE_DIRS} +set(TRACKING_GR_BLOCKS_HEADERS + galileo_e1_tcp_connector_tracking_cc.h + gps_l1_ca_tcp_connector_tracking_cc.h + gps_l1_ca_dll_pll_c_aid_tracking_cc.h + gps_l1_ca_dll_pll_c_aid_tracking_sc.h + glonass_l1_ca_dll_pll_tracking_cc.h + glonass_l1_ca_dll_pll_c_aid_tracking_cc.h + glonass_l1_ca_dll_pll_c_aid_tracking_sc.h + gps_l1_ca_kf_tracking_cc.h + glonass_l2_ca_dll_pll_tracking_cc.h + glonass_l2_ca_dll_pll_c_aid_tracking_cc.h + glonass_l2_ca_dll_pll_c_aid_tracking_sc.h + dll_pll_veml_tracking.h + ${OPT_TRACKING_BLOCKS_HEADERS} ) -if(ENABLE_GENERIC_ARCH) - add_definitions( -DGENERIC_ARCH=1 ) -endif(ENABLE_GENERIC_ARCH) - -file(GLOB TRACKING_GR_BLOCKS_HEADERS "*.h") list(SORT TRACKING_GR_BLOCKS_HEADERS) -add_library(tracking_gr_blocks ${TRACKING_GR_BLOCKS_SOURCES} ${TRACKING_GR_BLOCKS_HEADERS}) +list(SORT TRACKING_GR_BLOCKS_SOURCES) + source_group(Headers FILES ${TRACKING_GR_BLOCKS_HEADERS}) -target_link_libraries(tracking_gr_blocks tracking_lib ${GNURADIO_RUNTIME_LIBRARIES} gnss_sdr_flags gnss_sp_libs ${Boost_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${MATIO_LIBRARIES} ${OPT_TRACKING_LIBRARIES}) +add_library(tracking_gr_blocks + ${TRACKING_GR_BLOCKS_SOURCES} + ${TRACKING_GR_BLOCKS_HEADERS} +) -if(NOT VOLK_GNSSSDR_FOUND) - if(MATIO_FOUND) - add_dependencies(tracking_gr_blocks volk_gnsssdr_module) - else(MATIO_FOUND) - add_dependencies(tracking_gr_blocks volk_gnsssdr_module matio-${GNSSSDR_MATIO_LOCAL_VERSION}) - endif(MATIO_FOUND) -else(NOT VOLK_GNSSSDR_FOUND) - if(NOT MATIO_FOUND) - add_dependencies(tracking_gr_blocks matio-${GNSSSDR_MATIO_LOCAL_VERSION}) - endif(NOT MATIO_FOUND) -endif(NOT VOLK_GNSSSDR_FOUND) +target_link_libraries(tracking_gr_blocks + PUBLIC + Boost::boost + Gnuradio::blocks + Matio::matio + Volkgnsssdr::volkgnsssdr + gnss_sdr_flags + algorithms_libs + tracking_libs +) + +if(ENABLE_CUDA) + target_link_libraries(tracking_gr_blocks + PUBLIC + ${CUDA_LIBRARIES} + ) + target_include_directories(tracking_gr_blocks + PUBLIC + ${CUDA_INCLUDE_DIRS} + ) +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(tracking_gr_blocks + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET tracking_gr_blocks + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc old mode 100755 new mode 100644 index f18c0fc90..033e49493 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -1,6 +1,7 @@ /*! * \file dll_pll_veml_tracking.cc * \brief Implementation of a code DLL + carrier PLL tracking block. + * \author Javier Arribas, 2018. jarribas(at)cttc.es * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * * Code DLL + carrier PLL according to the algorithms described in: @@ -34,33 +35,37 @@ */ #include "dll_pll_veml_tracking.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" -#include "control_message_factory.h" -#include "MATH_CONSTANTS.h" -#include "Galileo_E1.h" -#include "galileo_e1_signal_processing.h" -#include "Galileo_E5a.h" -#include "galileo_e5_signal_processing.h" +#include "Beidou_B1I.h" #include "GPS_L1_CA.h" -#include "gps_sdr_signal_processing.h" #include "GPS_L2C.h" -#include "gps_l2c_signal.h" #include "GPS_L5.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "MATH_CONSTANTS.h" +#include "beidou_b1i_signal_processing.h" +#include "galileo_e1_signal_processing.h" +#include "galileo_e5_signal_processing.h" +#include "gnss_sdr_create_directory.h" +#include "gps_l2c_signal.h" #include "gps_l5_signal.h" -#include +#include "gps_sdr_signal_processing.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" +#include #include #include #include #include #include #include +#include #include +#include #include using google::LogMessage; -dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(dllpllconf_t conf_) +dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_) { return dll_pll_veml_tracking_sptr(new dll_pll_veml_tracking(conf_)); } @@ -71,26 +76,30 @@ void dll_pll_veml_tracking::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(trk_parameters.vector_length) * 2; + ninput_items_required[0] = static_cast(trk_parameters.vector_length) * 2; } } -dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dll_pll_veml_tracking", gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::block("dll_pll_veml_tracking", gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { trk_parameters = conf_; // Telemetry bit synchronization message port input this->message_port_register_out(pmt::mp("events")); this->set_relative_rate(1.0 / static_cast(trk_parameters.vector_length)); + // Telemetry bit synchronization message port input (mainly for GPS L1 CA) + this->message_port_register_in(pmt::mp("preamble_samplestamp")); + // initialize internal vars d_veml = false; d_cloop = true; - d_synchonizing = false; d_code_chip_rate = 0.0; - d_secondary_code_length = 0; + d_secondary_code_length = 0U; d_secondary_code_string = nullptr; + d_preambles_symbols = nullptr; + d_preamble_length_symbols = 0; signal_type = std::string(trk_parameters.signal); std::map map_signal_pretty_name; @@ -101,13 +110,14 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl map_signal_pretty_name["2G"] = "L2 C/A"; map_signal_pretty_name["5X"] = "E5a"; map_signal_pretty_name["L5"] = "L5"; + map_signal_pretty_name["B1"] = "B1I"; signal_pretty_name = map_signal_pretty_name[signal_type]; if (trk_parameters.system == 'G') { systemName = "GPS"; - if (signal_type.compare("1C") == 0) + if (signal_type == "1C") { d_signal_carrier_freq = GPS_L1_FREQ_HZ; d_code_period = GPS_L1_CA_CODE_PERIOD; @@ -115,18 +125,43 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_symbols_per_bit = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; d_correlation_length_ms = 1; d_code_samples_per_chip = 1; - d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); + d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); // GPS L1 C/A does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; interchange_iq = false; + + // set the preamble + uint16_t preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; + + // preamble bits to sampled symbols + d_preamble_length_symbols = GPS_CA_PREAMBLE_LENGTH_SYMBOLS; + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); + int32_t n = 0; + for (uint16_t preambles_bit : preambles_bits) + { + for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) + { + if (preambles_bit == 1) + { + d_preambles_symbols[n] = 1; + } + else + { + d_preambles_symbols[n] = -1; + } + n++; + } + } + d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); // Change fixed buffer size + d_symbol_history.clear(); // Clear all the elements in the buffer } - else if (signal_type.compare("2S") == 0) + else if (signal_type == "2S") { d_signal_carrier_freq = GPS_L2_FREQ_HZ; d_code_period = GPS_L2_M_PERIOD; d_code_chip_rate = GPS_L2_M_CODE_RATE_HZ; - d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); + d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); d_symbols_per_bit = GPS_L2_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 20; d_code_samples_per_chip = 1; @@ -135,27 +170,27 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl trk_parameters.track_pilot = false; interchange_iq = false; } - else if (signal_type.compare("L5") == 0) + else if (signal_type == "L5") { d_signal_carrier_freq = GPS_L5_FREQ_HZ; - d_code_period = GPS_L5i_PERIOD; - d_code_chip_rate = GPS_L5i_CODE_RATE_HZ; + d_code_period = GPS_L5I_PERIOD; + d_code_chip_rate = GPS_L5I_CODE_RATE_HZ; d_symbols_per_bit = GPS_L5_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 1; d_code_samples_per_chip = 1; - d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); + d_code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); d_secondary = true; if (trk_parameters.track_pilot) { - d_secondary_code_length = static_cast(GPS_L5q_NH_CODE_LENGTH); - d_secondary_code_string = const_cast(&GPS_L5q_NH_CODE_STR); + d_secondary_code_length = static_cast(GPS_L5Q_NH_CODE_LENGTH); + d_secondary_code_string = const_cast(&GPS_L5Q_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "Q"; interchange_iq = true; } else { - d_secondary_code_length = static_cast(GPS_L5i_NH_CODE_LENGTH); - d_secondary_code_string = const_cast(&GPS_L5i_NH_CODE_STR); + d_secondary_code_length = static_cast(GPS_L5I_NH_CODE_LENGTH); + d_secondary_code_string = const_cast(&GPS_L5I_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "I"; interchange_iq = false; } @@ -169,20 +204,20 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - d_code_length_chips = 0; - d_code_samples_per_chip = 0; + d_code_length_chips = 0U; + d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } } else if (trk_parameters.system == 'E') { systemName = "Galileo"; - if (signal_type.compare("1B") == 0) + if (signal_type == "1B") { - d_signal_carrier_freq = Galileo_E1_FREQ_HZ; - d_code_period = Galileo_E1_CODE_PERIOD; - d_code_chip_rate = Galileo_E1_CODE_CHIP_RATE_HZ; - d_code_length_chips = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); + d_signal_carrier_freq = GALILEO_E1_FREQ_HZ; + d_code_period = GALILEO_E1_CODE_PERIOD; + d_code_chip_rate = GALILEO_E1_CODE_CHIP_RATE_HZ; + d_code_length_chips = static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS); d_symbols_per_bit = 1; d_correlation_length_ms = 4; d_code_samples_per_chip = 2; // CBOC disabled: 2 samples per chip. CBOC enabled: 12 samples per chip @@ -190,8 +225,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl if (trk_parameters.track_pilot) { d_secondary = true; - d_secondary_code_length = static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); - d_secondary_code_string = const_cast(&Galileo_E1_C_SECONDARY_CODE); + d_secondary_code_length = static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH); + d_secondary_code_string = const_cast(&GALILEO_E1_C_SECONDARY_CODE); signal_pretty_name = signal_pretty_name + "C"; } else @@ -201,30 +236,64 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl } interchange_iq = false; // Note that E1-B and E1-C are in anti-phase, NOT IN QUADRATURE. See Galileo ICD. } - else if (signal_type.compare("5X") == 0) + else if (signal_type == "5X") { - d_signal_carrier_freq = Galileo_E5a_FREQ_HZ; - d_code_period = GALILEO_E5a_CODE_PERIOD; - d_code_chip_rate = Galileo_E5a_CODE_CHIP_RATE_HZ; + d_signal_carrier_freq = GALILEO_E5A_FREQ_HZ; + d_code_period = GALILEO_E5A_CODE_PERIOD; + d_code_chip_rate = GALILEO_E5A_CODE_CHIP_RATE_HZ; d_symbols_per_bit = 20; d_correlation_length_ms = 1; d_code_samples_per_chip = 1; - d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); - d_secondary = true; + d_code_length_chips = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); + if (trk_parameters.track_pilot) { - d_secondary_code_length = static_cast(Galileo_E5a_Q_SECONDARY_CODE_LENGTH); + d_secondary = true; + d_secondary_code_length = static_cast(GALILEO_E5A_Q_SECONDARY_CODE_LENGTH); signal_pretty_name = signal_pretty_name + "Q"; interchange_iq = true; } else { - d_secondary_code_length = static_cast(Galileo_E5a_I_SECONDARY_CODE_LENGTH); - d_secondary_code_string = const_cast(&Galileo_E5a_I_SECONDARY_CODE); + //Do not acquire secondary code in data component. It is done in telemetry decoder + d_secondary = false; signal_pretty_name = signal_pretty_name + "I"; interchange_iq = false; } } + else + { + LOG(WARNING) << "Invalid Signal argument when instantiating tracking blocks"; + std::cout << "Invalid Signal argument when instantiating tracking blocks" << std::endl; + d_correlation_length_ms = 1; + d_secondary = false; + interchange_iq = false; + d_signal_carrier_freq = 0.0; + d_code_period = 0.0; + d_code_length_chips = 0U; + d_code_samples_per_chip = 0U; + d_symbols_per_bit = 0; + } + } + else if (trk_parameters.system == 'C') + { + systemName = "Beidou"; + if (signal_type == "B1") + { + // GEO Satellites use different secondary code + d_signal_carrier_freq = BEIDOU_B1I_FREQ_HZ; + d_code_period = BEIDOU_B1I_CODE_PERIOD; + d_code_chip_rate = BEIDOU_B1I_CODE_RATE_HZ; + d_code_length_chips = static_cast(BEIDOU_B1I_CODE_LENGTH_CHIPS); + d_symbols_per_bit = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; + d_correlation_length_ms = 1; + d_code_samples_per_chip = 1; + d_secondary = true; + trk_parameters.track_pilot = false; + interchange_iq = false; + d_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); + d_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); + } else { LOG(WARNING) << "Invalid Signal argument when instantiating tracking blocks"; @@ -239,6 +308,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_symbols_per_bit = 0; } } + else { LOG(WARNING) << "Invalid System argument when instantiating tracking blocks"; @@ -248,8 +318,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - d_code_length_chips = 0; - d_code_samples_per_chip = 0; + d_code_length_chips = 0U; + d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } T_chip_seconds = 0.0; @@ -258,11 +328,10 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl K_blk_samples = 0.0; // Initialize tracking ========================================== - - d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); - d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); d_code_loop_filter = Tracking_2nd_DLL_filter(static_cast(d_code_period)); d_carrier_loop_filter = Tracking_2nd_PLL_filter(static_cast(d_code_period)); + d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); + d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); // Initialization of local code replica // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip @@ -281,7 +350,6 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); - std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); // map memory pointers of correlator outputs if (d_veml) @@ -328,17 +396,16 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl { // Extra correlator for the data component correlator_data_cpu.init(2 * trk_parameters.vector_length, 1); - d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); - d_Prompt_Data[0] = gr_complex(0.0, 0.0); + correlator_data_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); d_data_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); } else { - d_Prompt_Data = nullptr; d_data_code = nullptr; } - //--- Initializations ---// + // --- Initializations --- + multicorrelator_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); // Initial code frequency basis of NCO d_code_freq_chips = d_code_chip_rate; // Residual code phase (in chips) @@ -347,10 +414,10 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_rem_carr_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; - d_acq_sample_stamp = 0; + d_sample_counter = 0ULL; + d_acq_sample_stamp = 0ULL; - d_current_prn_length_samples = static_cast(trk_parameters.vector_length); + d_current_prn_length_samples = static_cast(trk_parameters.vector_length); // CN0 estimation and lock detector buffers d_cn0_estimation_counter = 0; @@ -359,8 +426,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_CN0_SNV_dB_Hz = 0.0; d_carrier_lock_fail_counter = 0; d_carrier_lock_threshold = trk_parameters.carrier_lock_th; - - clear_tracking_vars(); + d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_acquisition_gnss_synchro = nullptr; d_channel = 0; @@ -371,69 +437,89 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_extend_correlation_symbols_count = 0; d_code_phase_step_chips = 0.0; + d_code_phase_rate_step_chips = 0.0; d_carrier_phase_step_rad = 0.0; + d_carrier_phase_rate_step_rad = 0.0; d_rem_code_phase_chips = 0.0; - d_K_blk_samples = 0.0; - d_code_phase_samples = 0.0; d_last_prompt = gr_complex(0.0, 0.0); d_state = 0; // initial state: standby + clear_tracking_vars(); + if (trk_parameters.smoother_length > 0) + { + d_carr_ph_history.resize(trk_parameters.smoother_length * 2); + d_code_ph_history.resize(trk_parameters.smoother_length * 2); + } + else + { + d_carr_ph_history.resize(1); + d_code_ph_history.resize(1); + } + + d_dump = trk_parameters.dump; + d_dump_mat = trk_parameters.dump_mat and d_dump; + if (d_dump) + { + d_dump_filename = trk_parameters.dump_filename; + std::string dump_path; + // Get path + if (d_dump_filename.find_last_of('/') != std::string::npos) + { + std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); + dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); + d_dump_filename = dump_filename_; + } + else + { + dump_path = std::string("."); + } + if (d_dump_filename.empty()) + { + d_dump_filename = "trk_channel_"; + } + // remove extension if any + if (d_dump_filename.substr(1).find_last_of('.') != std::string::npos) + { + d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); + } + + d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + // create directory + if (!gnss_sdr_create_directory(dump_path)) + { + std::cerr << "GNSS-SDR cannot create dump files for the tracking block. Wrong permissions?" << std::endl; + d_dump = false; + } + } } void dll_pll_veml_tracking::start_tracking() { gr::thread::scoped_lock l(d_setlock); - /* - * correct the code phase according to the delay between acq and trk - */ + + // correct the code phase according to the delay between acq and trk d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); - double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; - DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples; - DLOG(INFO) << "Number of seconds between Acquisition and Tracking = " << acq_trk_diff_seconds; - // Doppler effect Fd = (C / (C + Vr)) * F - double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; - // new chip and prn sequence periods based on acq Doppler - d_code_freq_chips = radial_velocity * d_code_chip_rate; - d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; - double T_chip_mod_seconds = 1.0 / d_code_freq_chips; - double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); - double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; - - d_current_prn_length_samples = std::round(T_prn_mod_samples); - - double T_prn_true_seconds = static_cast(d_code_length_chips) / d_code_chip_rate; - double T_prn_true_samples = T_prn_true_seconds * trk_parameters.fs_in; - double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; - double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; - double corrected_acq_phase_samples = std::fmod(d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * trk_parameters.fs_in, T_prn_true_samples); - if (corrected_acq_phase_samples < 0.0) - { - corrected_acq_phase_samples += T_prn_mod_samples; - } - double delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; - - d_acq_code_phase_samples = corrected_acq_phase_samples; - d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / trk_parameters.fs_in; - + d_carrier_phase_rate_step_rad = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); // DLL/PLL filter initialization d_carrier_loop_filter.initialize(); // initialize the carrier filter d_code_loop_filter.initialize(); // initialize the code filter - if (systemName.compare("GPS") == 0 and signal_type.compare("1C") == 0) + if (systemName == "GPS" and signal_type == "1C") { gps_l1_ca_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); } - else if (systemName.compare("GPS") == 0 and signal_type.compare("2S") == 0) + else if (systemName == "GPS" and signal_type == "2S") { gps_l2c_m_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); } - else if (systemName.compare("GPS") == 0 and signal_type.compare("L5") == 0) + else if (systemName == "GPS" and signal_type == "L5") { if (trk_parameters.track_pilot) { @@ -447,7 +533,7 @@ void dll_pll_veml_tracking::start_tracking() gps_l5i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); } } - else if (systemName.compare("Galileo") == 0 and signal_type.compare("1B") == 0) + else if (systemName == "Galileo" and signal_type == "1B") { if (trk_parameters.track_pilot) { @@ -462,30 +548,69 @@ void dll_pll_veml_tracking::start_tracking() galileo_e1_code_gen_sinboc11_float(d_tracking_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); } } - else if (systemName.compare("Galileo") == 0 and signal_type.compare("5X") == 0) + else if (systemName == "Galileo" and signal_type == "5X") { - gr_complex *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * d_code_length_chips, volk_gnsssdr_get_alignment())); + auto *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * d_code_length_chips, volk_gnsssdr_get_alignment())); galileo_e5_a_code_gen_complex_primary(aux_code, d_acquisition_gnss_synchro->PRN, const_cast(signal_type.c_str())); if (trk_parameters.track_pilot) { - d_secondary_code_string = const_cast(&Galileo_E5a_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); - for (unsigned int i = 0; i < d_code_length_chips; i++) + d_secondary_code_string = const_cast(&GALILEO_E5A_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); + for (uint32_t i = 0; i < d_code_length_chips; i++) { d_tracking_code[i] = aux_code[i].imag(); - d_data_code[i] = aux_code[i].real(); + d_data_code[i] = aux_code[i].real(); //the same because it is generated the full signal (E5aI + E5aQ) } d_Prompt_Data[0] = gr_complex(0.0, 0.0); correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); } else { - for (unsigned int i = 0; i < d_code_length_chips; i++) + for (uint32_t i = 0; i < d_code_length_chips; i++) { d_tracking_code[i] = aux_code[i].real(); } } volk_gnsssdr_free(aux_code); } + else if (systemName == "Beidou" and signal_type == "B1") + { + beidou_b1i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); + // Update secondary code settings for geo satellites + if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) + { + d_symbols_per_bit = 2; + d_correlation_length_ms = 1; + d_code_samples_per_chip = 1; + d_secondary = false; + trk_parameters.track_pilot = false; + interchange_iq = false; + d_secondary_code_length = 0; + d_secondary_code_string = const_cast(&BEIDOU_B1I_D2_SECONDARY_CODE_STR); + + // preamble bits to sampled symbols + d_preamble_length_symbols = 22; + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(22 * sizeof(int32_t), volk_gnsssdr_get_alignment())); + int32_t n = 0; + uint16_t preambles_bits[BEIDOU_B1I_PREAMBLE_LENGTH_BITS] = {1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0}; + for (uint16_t preambles_bit : preambles_bits) + { + for (int32_t j = 0; j < d_symbols_per_bit; j++) + { + if (preambles_bit == 1) + { + d_preambles_symbols[n] = 1; + } + else + { + d_preambles_symbols[n] = -1; + } + n++; + } + } + d_symbol_history.resize(22); // Change fixed buffer size + d_symbol_history.clear(); + } + } multicorrelator_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_tracking_code, d_local_code_shift_chips); std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); @@ -512,7 +637,6 @@ void dll_pll_veml_tracking::start_tracking() d_local_code_shift_chips[2] = trk_parameters.early_late_space_chips * static_cast(d_code_samples_per_chip); } - d_code_phase_samples = d_acq_code_phase_samples; d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); d_carrier_loop_filter.set_pdi(static_cast(d_code_period)); @@ -520,22 +644,23 @@ void dll_pll_veml_tracking::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of " << systemName << " " << signal_pretty_name << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + DLOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking pull-in d_state = 1; - d_synchonizing = false; d_cloop = true; d_Prompt_buffer_deque.clear(); d_last_prompt = gr_complex(0.0, 0.0); - LOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz - << ". Code Phase correction [samples] = " << delay_correction_samples - << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; } dll_pll_veml_tracking::~dll_pll_veml_tracking() { + if (signal_type == "1C") + { + volk_gnsssdr_free(d_preambles_symbols); + } + if (d_dump_file.is_open()) { try @@ -547,16 +672,15 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking() LOG(WARNING) << "Exception in destructor " << ex.what(); } } - if (trk_parameters.dump) + if (d_dump_mat) { - if (d_channel == 0) + try { - std::cout << "Writing .mat files ..."; + save_matfile(); } - save_matfile(); - if (d_channel == 0) + catch (const std::exception &ex) { - std::cout << " done." << std::endl; + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); } } try @@ -564,9 +688,9 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking() volk_gnsssdr_free(d_local_code_shift_chips); volk_gnsssdr_free(d_correlator_outs); volk_gnsssdr_free(d_tracking_code); + volk_gnsssdr_free(d_Prompt_Data); if (trk_parameters.track_pilot) { - volk_gnsssdr_free(d_Prompt_Data); volk_gnsssdr_free(d_data_code); correlator_data_cpu.free(); } @@ -583,8 +707,8 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking() bool dll_pll_veml_tracking::acquire_secondary() { // ******* preamble correlation ******** - int corr_value = 0; - for (unsigned int i = 0; i < d_secondary_code_length; i++) + int32_t corr_value = 0; + for (uint32_t i = 0; i < d_secondary_code_length; i++) { if (d_Prompt_buffer_deque.at(i).real() < 0.0) // symbols clipping { @@ -610,21 +734,18 @@ bool dll_pll_veml_tracking::acquire_secondary() } } - if (abs(corr_value) == d_secondary_code_length) + if (abs(corr_value) == static_cast(d_secondary_code_length)) { return true; } - else - { - return false; - } + + return false; } bool dll_pll_veml_tracking::cn0_and_tracking_lock_status(double coh_integration_time_s) { // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### - if (d_cn0_estimation_counter < trk_parameters.cn0_samples) { // fill buffer with prompt correlator output values @@ -632,35 +753,32 @@ bool dll_pll_veml_tracking::cn0_and_tracking_lock_status(double coh_integration_ d_cn0_estimation_counter++; return true; } + d_cn0_estimation_counter = 0; + // Code lock indicator + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, coh_integration_time_s); + // Carrier lock indicator + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); + // Loss of lock detection + if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < trk_parameters.cn0_min) + { + d_carrier_lock_fail_counter++; + } else { - d_cn0_estimation_counter = 0; - // Code lock indicator - d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, coh_integration_time_s); - // Carrier lock indicator - d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); - // Loss of lock detection - if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < trk_parameters.cn0_min) + if (d_carrier_lock_fail_counter > 0) { - d_carrier_lock_fail_counter++; - } - else - { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; - } - if (d_carrier_lock_fail_counter > trk_parameters.max_lock_fail) - { - std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; - LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; - this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock - d_carrier_lock_fail_counter = 0; - return false; - } - else - { - return true; + d_carrier_lock_fail_counter--; } } + if (d_carrier_lock_fail_counter > trk_parameters.max_lock_fail) + { + std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; + LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; + this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock + d_carrier_lock_fail_counter = 0; + return false; + } + return true; } @@ -676,9 +794,10 @@ void dll_pll_veml_tracking::do_correlation_step(const gr_complex *input_samples) multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, input_samples); multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler( d_rem_carr_phase_rad, - d_carrier_phase_step_rad, + d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), trk_parameters.vector_length); // DATA CORRELATOR (if tracking tracks the pilot signal) @@ -687,9 +806,10 @@ void dll_pll_veml_tracking::do_correlation_step(const gr_complex *input_samples) correlator_data_cpu.set_input_output_vectors(d_Prompt_Data, input_samples); correlator_data_cpu.Carrier_wipeoff_multicorrelator_resampler( d_rem_carr_phase_rad, - d_carrier_phase_step_rad, + d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), trk_parameters.vector_length); } } @@ -714,8 +834,7 @@ void dll_pll_veml_tracking::run_dll_pll() d_carr_error_filt_hz = d_carrier_loop_filter.get_carrier_nco(d_carr_error_hz); // New carrier Doppler frequency estimation d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_carr_error_filt_hz; - // New code Doppler frequency estimation - d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate; + // ################## DLL ########################################################## // DLL discriminator @@ -729,13 +848,19 @@ void dll_pll_veml_tracking::run_dll_pll() } // Code discriminator filter d_code_error_filt_chips = d_code_loop_filter.get_code_nco(d_code_error_chips); // [chips/second] + + // New code Doppler frequency estimation + d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate - d_code_error_filt_chips; } void dll_pll_veml_tracking::clear_tracking_vars() { std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); - if (trk_parameters.track_pilot) *d_Prompt_Data = gr_complex(0.0, 0.0); + if (trk_parameters.track_pilot) + { + d_Prompt_Data[0] = gr_complex(0.0, 0.0); + } d_carr_error_hz = 0.0; d_carr_error_filt_hz = 0.0; d_code_error_chips = 0.0; @@ -743,6 +868,10 @@ void dll_pll_veml_tracking::clear_tracking_vars() d_current_symbol = 0; d_Prompt_buffer_deque.clear(); d_last_prompt = gr_complex(0.0, 0.0); + d_carrier_phase_rate_step_rad = 0.0; + d_code_phase_rate_step_chips = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); } @@ -750,27 +879,72 @@ void dll_pll_veml_tracking::update_tracking_vars() { T_chip_seconds = 1.0 / d_code_freq_chips; T_prn_seconds = T_chip_seconds * static_cast(d_code_length_chips); - double code_error_filt_secs = T_prn_seconds * d_code_error_filt_chips * T_chip_seconds; //[seconds] // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation T_prn_samples = T_prn_seconds * trk_parameters.fs_in; - K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * trk_parameters.fs_in; - d_current_prn_length_samples = static_cast(round(K_blk_samples)); // round to a discrete number of samples + K_blk_samples = T_prn_samples + d_rem_code_phase_samples; + //d_current_prn_length_samples = static_cast(round(K_blk_samples)); // round to a discrete number of samples + d_current_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples //################### PLL COMMANDS ################################################# // carrier phase step (NCO phase increment per sample) [rads/sample] d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / trk_parameters.fs_in; + // carrier phase rate step (NCO phase increment rate per sample) [rads/sample^2] + if (trk_parameters.high_dyn) + { + d_carr_ph_history.push_back(std::pair(d_carrier_phase_step_rad, static_cast(d_current_prn_length_samples))); + if (d_carr_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_carr_ph_history.at(k).first; + tmp_cp2 += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; + tmp_samples += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + } + tmp_cp1 /= static_cast(trk_parameters.smoother_length); + tmp_cp2 /= static_cast(trk_parameters.smoother_length); + d_carrier_phase_rate_step_rad = (tmp_cp2 - tmp_cp1) / tmp_samples; + } + } + //std::cout << d_carrier_phase_rate_step_rad * trk_parameters.fs_in * trk_parameters.fs_in / PI_2 << std::endl; // remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad += d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); + + // carrier phase accumulator - d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + //double a = d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + //double b = 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples); + //std::cout << fmod(b, PI_2) / fmod(a, PI_2) << std::endl; + d_acc_carrier_phase_rad -= (d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); //################### DLL COMMANDS ################################################# // code phase step (Code resampler phase increment per sample) [chips/sample] d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; + if (trk_parameters.high_dyn) + { + d_code_ph_history.push_back(std::pair(d_code_phase_step_chips, static_cast(d_current_prn_length_samples))); + if (d_code_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_code_ph_history.at(k).first; + tmp_cp2 += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; + tmp_samples += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + } + tmp_cp1 /= static_cast(trk_parameters.smoother_length); + tmp_cp2 /= static_cast(trk_parameters.smoother_length); + d_code_phase_rate_step_chips = (tmp_cp2 - tmp_cp1) / tmp_samples; + } + } // remnant code phase [chips] d_rem_code_phase_samples = K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample d_rem_code_phase_chips = d_code_freq_chips * d_rem_code_phase_samples / trk_parameters.fs_in; @@ -822,15 +996,19 @@ void dll_pll_veml_tracking::save_correlation_results() } // If tracking pilot, disable Costas loop if (trk_parameters.track_pilot) - d_cloop = false; + { + d_cloop = false; + } else - d_cloop = true; + { + d_cloop = true; + } } void dll_pll_veml_tracking::log_data(bool integrating) { - if (trk_parameters.dump) + if (d_dump) { // Dump results to file float prompt_I; @@ -838,6 +1016,7 @@ void dll_pll_veml_tracking::log_data(bool integrating) float tmp_VE, tmp_E, tmp_P, tmp_L, tmp_VL; float tmp_float; double tmp_double; + uint64_t tmp_long_int; if (trk_parameters.track_pilot) { if (interchange_iq) @@ -904,15 +1083,22 @@ void dll_pll_veml_tracking::log_data(bool integrating) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + tmp_long_int = d_sample_counter + static_cast(d_current_prn_length_samples); + d_dump_file.write(reinterpret_cast(&tmp_long_int), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_rad; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency tmp_float = d_carrier_doppler_hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // carrier phase rate [Hz/s] + tmp_float = d_carrier_phase_rate_step_rad * trk_parameters.fs_in * trk_parameters.fs_in / PI_2; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); tmp_float = d_code_freq_chips; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // code phase rate [chips/s^2] + tmp_float = d_code_phase_rate_step_chips * trk_parameters.fs_in * trk_parameters.fs_in; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // PLL commands tmp_float = d_carr_error_hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -934,8 +1120,8 @@ void dll_pll_veml_tracking::log_data(bool integrating) tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } catch (const std::ifstream::failure &e) { @@ -945,19 +1131,25 @@ void dll_pll_veml_tracking::log_data(bool integrating) } -int dll_pll_veml_tracking::save_matfile() +int32_t dll_pll_veml_tracking::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 1; - int number_of_float_vars = 17; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 1; + int32_t number_of_float_vars = 19; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; + std::string dump_filename_ = d_dump_filename; + // add channel number to the filename + dump_filename_.append(std::to_string(d_channel)); + // add extension + dump_filename_.append(".dat"); + std::cout << "Generating .mat file for " << dump_filename_ << std::endl; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try { - dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::binary | std::ios::ate); + dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate); } catch (const std::ifstream::failure &e) { @@ -965,43 +1157,45 @@ int dll_pll_veml_tracking::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_VE = new float[num_epoch]; - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *abs_VL = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - float *acc_carrier_phase_rad = new float[num_epoch]; - float *carrier_doppler_hz = new float[num_epoch]; - float *code_freq_chips = new float[num_epoch]; - float *carr_error_hz = new float[num_epoch]; - float *carr_error_filt_hz = new float[num_epoch]; - float *code_error_chips = new float[num_epoch]; - float *code_error_filt_chips = new float[num_epoch]; - float *CN0_SNV_dB_Hz = new float[num_epoch]; - float *carrier_lock_test = new float[num_epoch]; - float *aux1 = new float[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_VE = new float[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *abs_VL = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new float[num_epoch]; + auto *carrier_doppler_hz = new float[num_epoch]; + auto *carrier_doppler_rate_hz = new float[num_epoch]; + auto *code_freq_chips = new float[num_epoch]; + auto *code_freq_rate_chips = new float[num_epoch]; + auto *carr_error_hz = new float[num_epoch]; + auto *carr_error_filt_hz = new float[num_epoch]; + auto *code_error_chips = new float[num_epoch]; + auto *code_error_filt_chips = new float[num_epoch]; + auto *CN0_SNV_dB_Hz = new float[num_epoch]; + auto *carrier_lock_test = new float[num_epoch]; + auto *aux1 = new float[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_VE[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); @@ -1010,10 +1204,12 @@ int dll_pll_veml_tracking::save_matfile() dump_file.read(reinterpret_cast(&abs_VL[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_doppler_rate_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_freq_rate_chips[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(float)); @@ -1022,7 +1218,7 @@ int dll_pll_veml_tracking::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(float)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(float)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -1040,7 +1236,9 @@ int dll_pll_veml_tracking::save_matfile() delete[] PRN_start_sample_count; delete[] acc_carrier_phase_rad; delete[] carrier_doppler_hz; + delete[] carrier_doppler_rate_hz; delete[] code_freq_chips; + delete[] code_freq_rate_chips; delete[] carr_error_hz; delete[] carr_error_filt_hz; delete[] code_error_chips; @@ -1056,11 +1254,11 @@ int dll_pll_veml_tracking::save_matfile() // WRITE MAT FILE mat_t *matfp; matvar_t *matvar; - std::string filename = trk_parameters.dump_filename; + std::string filename = dump_filename_; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_VE, 0); @@ -1103,10 +1301,18 @@ int dll_pll_veml_tracking::save_matfile() Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + matvar = Mat_VarCreate("carrier_doppler_rate_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_rate_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + matvar = Mat_VarCreate("code_freq_rate_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_rate_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -1154,7 +1360,9 @@ int dll_pll_veml_tracking::save_matfile() delete[] PRN_start_sample_count; delete[] acc_carrier_phase_rad; delete[] carrier_doppler_hz; + delete[] carrier_doppler_rate_hz; delete[] code_freq_chips; + delete[] code_freq_rate_chips; delete[] carr_error_hz; delete[] carr_error_filt_hz; delete[] code_error_chips; @@ -1168,23 +1376,29 @@ int dll_pll_veml_tracking::save_matfile() } -void dll_pll_veml_tracking::set_channel(unsigned int channel) +void dll_pll_veml_tracking::set_channel(uint32_t channel) { gr::thread::scoped_lock l(d_setlock); d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; // ############# ENABLE DATA FILE LOG ################# - if (trk_parameters.dump) + if (d_dump) { + std::string dump_filename_ = d_dump_filename; + // add channel number to the filename + dump_filename_.append(std::to_string(d_channel)); + // add extension + dump_filename_.append(".dat"); + if (!d_dump_file.is_open()) { try { - trk_parameters.dump_filename.append(boost::lexical_cast(d_channel)); - trk_parameters.dump_filename.append(".dat"); + //trk_parameters.dump_filename.append(boost::lexical_cast(d_channel)); + //trk_parameters.dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << trk_parameters.dump_filename.c_str(); + d_dump_file.open(dump_filename_.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << dump_filename_.c_str(); } catch (const std::ifstream::failure &e) { @@ -1202,19 +1416,25 @@ void dll_pll_veml_tracking::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) } +void dll_pll_veml_tracking::stop_tracking() +{ + gr::thread::scoped_lock l(d_setlock); + d_state = 0; +} + int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { gr::thread::scoped_lock l(d_setlock); - const gr_complex *in = reinterpret_cast(input_items[0]); - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); switch (d_state) { case 0: // Standby - Consume samples at full throttle, do nothing { - d_sample_counter += ninput_items[0]; + d_sample_counter += static_cast(ninput_items[0]); consume_each(ninput_items[0]); return 0; break; @@ -1222,17 +1442,34 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) case 1: // Pull-in { // Signal alignment (skip samples until the incoming signal is aligned with local replica) - unsigned long int acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; - double acq_trk_shif_correction_samples = static_cast(d_current_prn_length_samples) - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); - int samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - if (samples_offset < 0) - { - samples_offset = 0; - } - d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * d_acq_code_phase_samples; + int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); + double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; + double delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; + + // Doppler effect Fd = (C / (C + Vr)) * F + double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; + // new chip and PRN sequence periods based on acq Doppler + d_code_freq_chips = radial_velocity * d_code_chip_rate; + d_code_freq_chips = d_code_chip_rate; + d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; + d_code_phase_rate_step_chips = 0.0; + double T_chip_mod_seconds = 1.0 / d_code_freq_chips; + double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); + double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; + + d_acq_code_phase_samples = T_prn_mod_samples - std::fmod(delta_trk_to_acq_prn_start_samples, T_prn_mod_samples); + d_current_prn_length_samples = round(T_prn_mod_samples); + + int32_t samples_offset = round(d_acq_code_phase_samples); + d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(samples_offset); d_state = 2; d_sample_counter += samples_offset; // count for the processed samples - consume_each(samples_offset); // shift input to perform alignment with local replica + + DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples << " ( " << acq_trk_diff_seconds << " s)"; + DLOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz + << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; + + consume_each(samples_offset); // shift input to perform alignment with local replica return 0; } case 2: // Wide tracking and symbol synchronization @@ -1272,6 +1509,8 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) next_state = acquire_secondary(); if (next_state) { + LOG(INFO) << systemName << " " << signal_pretty_name << " secondary code locked in channel " << d_channel + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; std::cout << systemName << " " << signal_pretty_name << " secondary code locked in channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; } @@ -1281,39 +1520,84 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) } else if (d_symbols_per_bit > 1) //Signal does not have secondary code. Search a bit transition by sign change { - if (d_synchonizing) + float current_tracking_time_s = static_cast(d_sample_counter - d_acq_sample_stamp) / trk_parameters.fs_in; + if (current_tracking_time_s > 10) { - if (d_Prompt->real() * d_last_prompt.real() > 0.0) + d_symbol_history.push_back(d_Prompt->real()); + //******* preamble correlation ******** + int32_t corr_value = 0; + if ((static_cast(d_symbol_history.size()) == d_preamble_length_symbols)) // and (d_make_correlation or !d_flag_frame_sync)) { - d_current_symbol++; + for (int32_t i = 0; i < d_preamble_length_symbols; i++) + { + if (d_symbol_history.at(i) < 0) // symbols clipping + { + corr_value -= d_preambles_symbols[i]; + } + else + { + corr_value += d_preambles_symbols[i]; + } + } } - else if (d_current_symbol > d_symbols_per_bit) + if (corr_value == d_preamble_length_symbols) { - d_synchonizing = false; - d_current_symbol = 1; + LOG(INFO) << systemName << " " << signal_pretty_name << " tracking preamble detected in channel " << d_channel + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + next_state = true; } else { - d_current_symbol = 1; - d_last_prompt = *d_Prompt; + next_state = false; } } - else if (d_last_prompt.real() != 0.0) - { - d_current_symbol++; - if (d_current_symbol == d_symbols_per_bit) next_state = true; - } else { - d_last_prompt = *d_Prompt; - d_synchonizing = true; - d_current_symbol = 1; + next_state = false; } } else { next_state = true; } + + // ########### Output the tracking results to Telemetry block ########## + if (interchange_iq) + { + if (trk_parameters.track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).real()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).real()); + } + } + else + { + if (trk_parameters.track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).imag()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); + } + } + + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + current_synchro_data.Flag_valid_symbol_output = true; + current_synchro_data.correlation_length_ms = d_correlation_length_ms; + if (next_state) { // reset extended correlator d_VE_accu = gr_complex(0.0, 0.0); @@ -1324,7 +1608,6 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) d_last_prompt = gr_complex(0.0, 0.0); d_Prompt_buffer_deque.clear(); d_current_symbol = 0; - d_synchonizing = false; if (d_enable_extended_integration) { @@ -1334,10 +1617,10 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) d_carrier_loop_filter.set_pdi(new_correlation_time); d_code_loop_filter.set_pdi(new_correlation_time); d_state = 3; // next state is the extended correlator integrator - LOG(INFO) << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " + LOG(INFO) << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN); - std::cout << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " + std::cout << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; // Set narrow taps delay values [chips] @@ -1488,10 +1771,10 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) } } consume_each(d_current_prn_length_samples); - d_sample_counter += d_current_prn_length_samples; + d_sample_counter += static_cast(d_current_prn_length_samples); if (current_synchro_data.Flag_valid_symbol_output) { - current_synchro_data.fs = static_cast(trk_parameters.fs_in); + current_synchro_data.fs = static_cast(trk_parameters.fs_in); current_synchro_data.Tracking_sample_counter = d_sample_counter; *out[0] = current_synchro_data; return 1; diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h old mode 100755 new mode 100644 index 9444c6ccb..477880b03 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h @@ -1,6 +1,7 @@ /*! * \file dll_pll_veml_tracking.h * \brief Implementation of a code DLL + carrier PLL tracking block. + * \author Javier Arribas, 2018. jarribas(at)cttc.es * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * * ------------------------------------------------------------------------- @@ -31,45 +32,24 @@ #ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_H #define GNSS_SDR_DLL_PLL_VEML_TRACKING_H +#include "cpu_multicorrelator_real_codes.h" +#include "dll_pll_conf.h" #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_2nd_PLL_filter.h" -#include "cpu_multicorrelator_real_codes.h" +#include #include #include -#include #include - -typedef struct -{ - /* DLL/PLL tracking configuration */ - double fs_in; - unsigned int vector_length; - bool dump; - std::string dump_filename; - float pll_bw_hz; - float dll_bw_hz; - float pll_bw_narrow_hz; - float dll_bw_narrow_hz; - float early_late_space_chips; - float very_early_late_space_chips; - float early_late_space_narrow_chips; - float very_early_late_space_narrow_chips; - int extend_correlation_symbols; - int cn0_samples; - int cn0_min; - int max_lock_fail; - double carrier_lock_th; - bool track_pilot; - char system; - char signal[3]; -} dllpllconf_t; +#include +#include +#include class dll_pll_veml_tracking; -typedef boost::shared_ptr dll_pll_veml_tracking_sptr; +using dll_pll_veml_tracking_sptr = boost::shared_ptr; -dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(dllpllconf_t conf_); +dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_); /*! * \brief This class implements a code DLL + carrier PLL tracking block. @@ -79,9 +59,10 @@ class dll_pll_veml_tracking : public gr::block public: ~dll_pll_veml_tracking(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); void start_tracking(); + void stop_tracking(); int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); @@ -89,9 +70,10 @@ public: void forecast(int noutput_items, gr_vector_int &ninput_items_required); private: - friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(dllpllconf_t conf_); + friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_); - dll_pll_veml_tracking(dllpllconf_t conf_); + dll_pll_veml_tracking(const Dll_Pll_Conf &conf_); + void msg_handler_preamble_index(pmt::pmt_t msg); bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool acquire_secondary(); @@ -101,13 +83,13 @@ private: void clear_tracking_vars(); void save_correlation_results(); void log_data(bool integrating); - int save_matfile(); + int32_t save_matfile(); // tracking configuration vars - dllpllconf_t trk_parameters; + Dll_Pll_Conf trk_parameters; bool d_veml; bool d_cloop; - unsigned int d_channel; + uint32_t d_channel; Gnss_Synchro *d_acquisition_gnss_synchro; //Signal parameters @@ -116,28 +98,31 @@ private: double d_signal_carrier_freq; double d_code_period; double d_code_chip_rate; - unsigned int d_secondary_code_length; - unsigned int d_code_length_chips; - unsigned int d_code_samples_per_chip; // All signals have 1 sample per chip code except Gal. E1 which has 2 (CBOC disabled) or 12 (CBOC enabled) - int d_symbols_per_bit; + uint32_t d_secondary_code_length; + uint32_t d_code_length_chips; + uint32_t d_code_samples_per_chip; // All signals have 1 sample per chip code except Gal. E1 which has 2 (CBOC disabled) or 12 (CBOC enabled) + int32_t d_symbols_per_bit; std::string systemName; std::string signal_type; std::string *d_secondary_code_string; std::string signal_pretty_name; + int32_t *d_preambles_symbols; + int32_t d_preamble_length_symbols; + boost::circular_buffer d_symbol_history; + //tracking state machine - int d_state; - bool d_synchonizing; + int32_t d_state; //Integration period in samples - int d_correlation_length_ms; - int d_n_correlator_taps; + int32_t d_correlation_length_ms; + int32_t d_n_correlator_taps; float *d_tracking_code; float *d_data_code; float *d_local_code_shift_chips; float *d_prompt_data_shift; - cpu_multicorrelator_real_codes multicorrelator_cpu; - cpu_multicorrelator_real_codes correlator_data_cpu; //for data channel + Cpu_Multicorrelator_Real_Codes multicorrelator_cpu; + Cpu_Multicorrelator_Real_Codes correlator_data_cpu; //for data channel /* TODO: currently the multicorrelator does not support adding extra correlator with different local code, thus we need extra multicorrelator instance. Implement this functionality inside multicorrelator class @@ -151,8 +136,8 @@ private: gr_complex *d_Very_Late; bool d_enable_extended_integration; - int d_extend_correlation_symbols_count; - int d_current_symbol; + int32_t d_extend_correlation_symbols_count; + int32_t d_current_symbol; gr_complex d_VE_accu; gr_complex d_E_accu; @@ -164,10 +149,14 @@ private: gr_complex *d_Prompt_Data; double d_code_phase_step_chips; + double d_code_phase_rate_step_chips; + boost::circular_buffer> d_code_ph_history; double d_carrier_phase_step_rad; + double d_carrier_phase_rate_step_rad; + boost::circular_buffer> d_carr_ph_history; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; - double d_rem_carr_phase_rad; + float d_rem_carr_phase_rad; // PLL and DLL filter library Tracking_2nd_DLL_filter d_code_loop_filter; @@ -182,25 +171,24 @@ private: double d_carr_error_filt_hz; double d_code_error_chips; double d_code_error_filt_chips; - double d_K_blk_samples; double d_code_freq_chips; double d_carrier_doppler_hz; double d_acc_carrier_phase_rad; double d_rem_code_phase_chips; - double d_code_phase_samples; double T_chip_seconds; double T_prn_seconds; double T_prn_samples; double K_blk_samples; // PRN period in samples - int d_current_prn_length_samples; + int32_t d_current_prn_length_samples; // processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; - int d_carrier_lock_fail_counter; + int32_t d_cn0_estimation_counter; + int32_t d_carrier_lock_fail_counter; + std::deque d_carrier_lock_detector_queue; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; @@ -209,6 +197,9 @@ private: // file dump std::ofstream d_dump_file; + std::string d_dump_filename; + bool d_dump; + bool d_dump_mat; }; #endif // GNSS_SDR_DLL_PLL_VEML_TRACKING_H diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 2b74c274c..fe944d612 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -1,8 +1,9 @@ /*! - * \file dll_pll_veml_tracking.cc + * \file dll_pll_veml_tracking_fpga.cc * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA - * \author Marc Majoral, 2018. marc.majoral(at)cttc.es - * Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com + * \author Marc Majoral, 2019. marc.majoral(at)cttc.es + * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com + * \author Javier Arribas, 2018. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, @@ -11,7 +12,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -35,50 +36,59 @@ */ #include "dll_pll_veml_tracking_fpga.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" -#include "control_message_factory.h" -#include "MATH_CONSTANTS.h" -#include "Galileo_E1.h" -#include "Galileo_E5a.h" #include "GPS_L1_CA.h" #include "GPS_L2C.h" -#include "gps_l2c_signal.h" #include "GPS_L5.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "MATH_CONSTANTS.h" +#include "control_message_factory.h" +#include "galileo_e1_signal_processing.h" +#include "galileo_e5_signal_processing.h" +#include "gnss_sdr_create_directory.h" +#include "gps_l2c_signal.h" #include "gps_l5_signal.h" -#include +#include "gps_sdr_signal_processing.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" +#include #include #include #include #include #include #include +#include #include +#include #include using google::LogMessage; -dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_t conf_) +dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_) { return dll_pll_veml_tracking_fpga_sptr(new dll_pll_veml_tracking_fpga(conf_)); } -dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) : gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_) : gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { trk_parameters = conf_; // Telemetry bit synchronization message port input this->message_port_register_out(pmt::mp("events")); this->set_relative_rate(1.0 / static_cast(trk_parameters.vector_length)); + // Telemetry bit synchronization message port input (mainly for GPS L1 CA) + this->message_port_register_in(pmt::mp("preamble_samplestamp")); + // initialize internal vars d_veml = false; d_cloop = true; - d_synchonizing = false; d_code_chip_rate = 0.0; - d_secondary_code_length = 0; + d_secondary_code_length = 0U; d_secondary_code_string = nullptr; + d_gps_l1ca_preambles_symbols = nullptr; signal_type = std::string(trk_parameters.signal); std::map map_signal_pretty_name; @@ -92,58 +102,79 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) signal_pretty_name = map_signal_pretty_name[signal_type]; + d_code_samples_per_chip = trk_parameters.code_samples_per_chip; // number of samples per chip + d_code_length_chips = trk_parameters.code_length_chips; + if (trk_parameters.system == 'G') { systemName = "GPS"; - if (signal_type.compare("1C") == 0) + if (signal_type == "1C") { d_signal_carrier_freq = GPS_L1_FREQ_HZ; d_code_period = GPS_L1_CA_CODE_PERIOD; d_code_chip_rate = GPS_L1_CA_CODE_RATE_HZ; d_symbols_per_bit = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; d_correlation_length_ms = 1; - d_code_samples_per_chip = 1; - d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); // GPS L1 C/A does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; interchange_iq = false; + + // set the preamble + uint16_t preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; + + // preamble bits to sampled symbols + d_gps_l1ca_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); + int32_t n = 0; + for (uint16_t preambles_bit : preambles_bits) + { + for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) + { + if (preambles_bit == 1) + { + d_gps_l1ca_preambles_symbols[n] = 1; + } + else + { + d_gps_l1ca_preambles_symbols[n] = -1; + } + n++; + } + } + d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); // Change fixed buffer size + d_symbol_history.clear(); // Clear all the elements in the buffer } - else if (signal_type.compare("2S") == 0) + else if (signal_type == "2S") { d_signal_carrier_freq = GPS_L2_FREQ_HZ; d_code_period = GPS_L2_M_PERIOD; d_code_chip_rate = GPS_L2_M_CODE_RATE_HZ; - d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); d_symbols_per_bit = GPS_L2_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 20; - d_code_samples_per_chip = 1; // GPS L2 does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; interchange_iq = false; } - else if (signal_type.compare("L5") == 0) + else if (signal_type == "L5") { d_signal_carrier_freq = GPS_L5_FREQ_HZ; - d_code_period = GPS_L5i_PERIOD; - d_code_chip_rate = GPS_L5i_CODE_RATE_HZ; + d_code_period = GPS_L5I_PERIOD; + d_code_chip_rate = GPS_L5I_CODE_RATE_HZ; d_symbols_per_bit = GPS_L5_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 1; - d_code_samples_per_chip = 1; - d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); d_secondary = true; if (trk_parameters.track_pilot) { - d_secondary_code_length = static_cast(GPS_L5q_NH_CODE_LENGTH); - d_secondary_code_string = const_cast(&GPS_L5q_NH_CODE_STR); + d_secondary_code_length = static_cast(GPS_L5Q_NH_CODE_LENGTH); + d_secondary_code_string = const_cast(&GPS_L5Q_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "Q"; interchange_iq = true; } else { - d_secondary_code_length = static_cast(GPS_L5i_NH_CODE_LENGTH); - d_secondary_code_string = const_cast(&GPS_L5i_NH_CODE_STR); + d_secondary_code_length = static_cast(GPS_L5I_NH_CODE_LENGTH); + d_secondary_code_string = const_cast(&GPS_L5I_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "I"; interchange_iq = false; } @@ -157,29 +188,25 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - d_code_length_chips = 0; - d_code_samples_per_chip = 0; d_symbols_per_bit = 0; } } else if (trk_parameters.system == 'E') { systemName = "Galileo"; - if (signal_type.compare("1B") == 0) + if (signal_type == "1B") { - d_signal_carrier_freq = Galileo_E1_FREQ_HZ; - d_code_period = Galileo_E1_CODE_PERIOD; - d_code_chip_rate = Galileo_E1_CODE_CHIP_RATE_HZ; - d_code_length_chips = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); + d_signal_carrier_freq = GALILEO_E1_FREQ_HZ; + d_code_period = GALILEO_E1_CODE_PERIOD; + d_code_chip_rate = GALILEO_E1_CODE_CHIP_RATE_HZ; d_symbols_per_bit = 1; d_correlation_length_ms = 4; - d_code_samples_per_chip = 2; // CBOC disabled: 2 samples per chip. CBOC enabled: 12 samples per chip d_veml = true; if (trk_parameters.track_pilot) { d_secondary = true; - d_secondary_code_length = static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); - d_secondary_code_string = const_cast(&Galileo_E1_C_SECONDARY_CODE); + d_secondary_code_length = static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH); + d_secondary_code_string = const_cast(&GALILEO_E1_C_SECONDARY_CODE); signal_pretty_name = signal_pretty_name + "C"; } else @@ -189,26 +216,25 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) } interchange_iq = false; // Note that E1-B and E1-C are in anti-phase, NOT IN QUADRATURE. See Galileo ICD. } - else if (signal_type.compare("5X") == 0) + else if (signal_type == "5X") { - d_signal_carrier_freq = Galileo_E5a_FREQ_HZ; - d_code_period = GALILEO_E5a_CODE_PERIOD; - d_code_chip_rate = Galileo_E5a_CODE_CHIP_RATE_HZ; + d_signal_carrier_freq = GALILEO_E5A_FREQ_HZ; + d_code_period = GALILEO_E5A_CODE_PERIOD; + d_code_chip_rate = GALILEO_E5A_CODE_CHIP_RATE_HZ; d_symbols_per_bit = 20; d_correlation_length_ms = 1; - d_code_samples_per_chip = 1; - d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); - d_secondary = true; + if (trk_parameters.track_pilot) { - d_secondary_code_length = static_cast(Galileo_E5a_Q_SECONDARY_CODE_LENGTH); + d_secondary = true; + d_secondary_code_length = static_cast(GALILEO_E5A_Q_SECONDARY_CODE_LENGTH); signal_pretty_name = signal_pretty_name + "Q"; interchange_iq = true; } else { - d_secondary_code_length = static_cast(Galileo_E5a_I_SECONDARY_CODE_LENGTH); - d_secondary_code_string = const_cast(&Galileo_E5a_I_SECONDARY_CODE); + //Do not acquire secondary code in data component. It is done in telemetry decoder + d_secondary = false; signal_pretty_name = signal_pretty_name + "I"; interchange_iq = false; } @@ -222,8 +248,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - d_code_length_chips = 0; - d_code_samples_per_chip = 0; d_symbols_per_bit = 0; } } @@ -236,8 +260,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - d_code_length_chips = 0; - d_code_samples_per_chip = 0; d_symbols_per_bit = 0; } T_chip_seconds = 0.0; @@ -246,10 +268,10 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) K_blk_samples = 0.0; // Initialize tracking ========================================== + d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); + d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); d_code_loop_filter = Tracking_2nd_DLL_filter(static_cast(d_code_period)); d_carrier_loop_filter = Tracking_2nd_PLL_filter(static_cast(d_code_period)); - d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); - d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); if (d_veml) { @@ -264,7 +286,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); - std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); // map memory pointers of correlator outputs if (d_veml) @@ -294,6 +315,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_prompt_data_shift = &d_local_code_shift_chips[1]; } + if (trk_parameters.extend_correlation_symbols > 1) { d_enable_extended_integration = true; @@ -304,19 +326,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) trk_parameters.extend_correlation_symbols = 1; } - // Enable Data component prompt correlator (slave to Pilot prompt) if tracking uses Pilot signal - if (trk_parameters.track_pilot) - { - // Extra correlator for the data component - d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); - d_Prompt_Data[0] = gr_complex(0.0, 0.0); - } - else - { - d_Prompt_Data = nullptr; - } - - //--- Initializations ---// + // --- Initializations --- // Initial code frequency basis of NCO d_code_freq_chips = d_code_chip_rate; // Residual code phase (in chips) @@ -325,12 +335,13 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_rem_carr_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; - d_acq_sample_stamp = 0; + d_sample_counter = 0ULL; + d_acq_sample_stamp = 0ULL; + d_absolute_samples_offset = 0ULL; - d_current_prn_length_samples = static_cast(trk_parameters.vector_length); + d_current_prn_length_samples = static_cast(trk_parameters.vector_length); d_next_prn_length_samples = d_current_prn_length_samples; - d_correlation_length_samples = static_cast(trk_parameters.vector_length); // this one is only for initialisation and does not change its value (MM) + d_correlation_length_samples = static_cast(trk_parameters.vector_length); // this one is only for initialisation and does not change its value (MM) // CN0 estimation and lock detector buffers d_cn0_estimation_counter = 0; @@ -339,8 +350,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_CN0_SNV_dB_Hz = 0.0; d_carrier_lock_fail_counter = 0; d_carrier_lock_threshold = trk_parameters.carrier_lock_th; - - clear_tracking_vars(); + d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_acquisition_gnss_synchro = nullptr; d_channel = 0; @@ -351,114 +361,108 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_extend_correlation_symbols_count = 0; d_code_phase_step_chips = 0.0; + d_code_phase_rate_step_chips = 0.0; d_carrier_phase_step_rad = 0.0; + d_carrier_phase_rate_step_rad = 0.0; d_rem_code_phase_chips = 0.0; - d_K_blk_samples = 0.0; - d_code_phase_samples = 0.0; d_last_prompt = gr_complex(0.0, 0.0); d_state = 0; // initial state: standby + clear_tracking_vars(); + if (trk_parameters.smoother_length > 0) + { + d_carr_ph_history.resize(trk_parameters.smoother_length * 2); + d_code_ph_history.resize(trk_parameters.smoother_length * 2); + } + else + { + d_carr_ph_history.resize(1); + d_code_ph_history.resize(1); + } + + d_dump = trk_parameters.dump; + d_dump_mat = trk_parameters.dump_mat and d_dump; + if (d_dump) + { + d_dump_filename = trk_parameters.dump_filename; + std::string dump_path; + // Get path + if (d_dump_filename.find_last_of("/") != std::string::npos) + { + std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); + dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); + d_dump_filename = dump_filename_; + } + else + { + dump_path = std::string("."); + } + if (d_dump_filename.empty()) + { + d_dump_filename = "trk_channel_"; + } + // remove extension if any + if (d_dump_filename.substr(1).find_last_of('.') != std::string::npos) + { + d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); + } + + d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + // create directory + if (!gnss_sdr_create_directory(dump_path)) + { + std::cerr << "GNSS-SDR cannot create dump files for the tracking block. Wrong permissions?" << std::endl; + d_dump = false; + } + } // create multicorrelator class std::string device_name = trk_parameters.device_name; - unsigned int device_base = trk_parameters.device_base; - int *ca_codes = trk_parameters.ca_codes; - unsigned int code_length = trk_parameters.code_length; - multicorrelator_fpga = std::make_shared(d_n_correlator_taps, device_name, device_base, ca_codes, code_length); - multicorrelator_fpga->set_output_vectors(d_correlator_outs); - - d_pull_in = 0; + uint32_t device_base = trk_parameters.device_base; + int32_t *ca_codes = trk_parameters.ca_codes; + int32_t *data_codes = trk_parameters.data_codes; + uint32_t multicorr_type = trk_parameters.multicorr_type; + multicorrelator_fpga = std::make_shared(d_n_correlator_taps, device_name, device_base, ca_codes, data_codes, d_code_length_chips, trk_parameters.track_pilot, multicorr_type, d_code_samples_per_chip); + multicorrelator_fpga->set_output_vectors(d_correlator_outs, d_Prompt_Data); } + void dll_pll_veml_tracking_fpga::start_tracking() { - /* - * correct the code phase according to the delay between acq and trk - */ + // correct the code phase according to the delay between acq and trk d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - double acq_trk_diff_seconds = 0; // when using the FPGA we don't use the global sample counter - // Doppler effect Fd = (C / (C + Vr)) * F - double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; - // new chip and prn sequence periods based on acq Doppler - d_code_freq_chips = radial_velocity * d_code_chip_rate; - d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; - double T_chip_mod_seconds = 1.0 / d_code_freq_chips; - double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); - double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; - - d_current_prn_length_samples = std::round(T_prn_mod_samples); - d_next_prn_length_samples = d_current_prn_length_samples; - double T_prn_true_seconds = static_cast(d_code_length_chips) / d_code_chip_rate; - double T_prn_true_samples = T_prn_true_seconds * trk_parameters.fs_in; - double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; - double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; - double corrected_acq_phase_samples = std::fmod(d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * trk_parameters.fs_in, T_prn_true_samples); - if (corrected_acq_phase_samples < 0.0) - { - corrected_acq_phase_samples += T_prn_mod_samples; - } - double delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; - - d_acq_code_phase_samples = corrected_acq_phase_samples; - d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / trk_parameters.fs_in; - + d_carrier_phase_rate_step_rad = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); // DLL/PLL filter initialization d_carrier_loop_filter.initialize(); // initialize the carrier filter d_code_loop_filter.initialize(); // initialize the code filter - if (systemName.compare("GPS") == 0 and signal_type.compare("1C") == 0) - { - // nothing to compute : the local codes are pre-computed in the adapter class - } - else if (systemName.compare("GPS") == 0 and signal_type.compare("2S") == 0) - { - // nothing to compute : the local codes are pre-computed in the adapter class - } - else if (systemName.compare("GPS") == 0 and signal_type.compare("L5") == 0) + if (systemName == "GPS" and signal_type == "L5") { if (trk_parameters.track_pilot) { d_Prompt_Data[0] = gr_complex(0.0, 0.0); } - else - { - // nothing to compute : the local codes are pre-computed in the adapter class - } } - else if (systemName.compare("Galileo") == 0 and signal_type.compare("1B") == 0) + else if (systemName == "Galileo" and signal_type == "1B") { if (trk_parameters.track_pilot) { - char pilot_signal[3] = "1C"; d_Prompt_Data[0] = gr_complex(0.0, 0.0); } - else - { - // nothing to compute : the local codes are pre-computed in the adapter class - } } - else if (systemName.compare("Galileo") == 0 and signal_type.compare("5X") == 0) + else if (systemName == "Galileo" and signal_type == "5X") { if (trk_parameters.track_pilot) { - d_secondary_code_string = const_cast(&Galileo_E5a_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); - for (unsigned int i = 0; i < d_code_length_chips; i++) - { - // nothing to compute : the local codes are pre-computed in the adapter class - } + d_secondary_code_string = const_cast(&GALILEO_E5A_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); d_Prompt_Data[0] = gr_complex(0.0, 0.0); } - else - { - for (unsigned int i = 0; i < d_code_length_chips; i++) - { - // nothing to compute : the local codes are pre-computed in the adapter class - } - } } std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); @@ -485,7 +489,6 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_local_code_shift_chips[2] = trk_parameters.early_late_space_chips * static_cast(d_code_samples_per_chip); } - d_code_phase_samples = d_acq_code_phase_samples; d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); d_carrier_loop_filter.set_pdi(static_cast(d_code_period)); @@ -493,23 +496,25 @@ void dll_pll_veml_tracking_fpga::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of " << systemName << " " << signal_pretty_name << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + DLOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; - d_synchonizing = false; + + multicorrelator_fpga->set_local_code_and_taps(d_local_code_shift_chips, d_prompt_data_shift, d_acquisition_gnss_synchro->PRN); + // enable tracking pull-in + d_state = 1; d_cloop = true; d_Prompt_buffer_deque.clear(); d_last_prompt = gr_complex(0.0, 0.0); - LOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz - << ". Code Phase correction [samples] = " << delay_correction_samples - << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; - multicorrelator_fpga->set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_local_code_shift_chips, d_acquisition_gnss_synchro->PRN); - d_pull_in = 1; - // enable tracking pull-in and d_state at the end to avoid general work from starting pull-in before the start tracking function is finished - d_state = 1; } + dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { + if (signal_type.compare("1C") == 0) + { + volk_gnsssdr_free(d_gps_l1ca_preambles_symbols); + } + if (d_dump_file.is_open()) { try @@ -521,26 +526,22 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() LOG(WARNING) << "Exception in destructor " << ex.what(); } } - if (trk_parameters.dump) + if (d_dump_mat) { - if (d_channel == 0) + try { - std::cout << "Writing .mat files ..."; + save_matfile(); } - save_matfile(); - if (d_channel == 0) + catch (const std::exception &ex) { - std::cout << " done." << std::endl; + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); } } try { volk_gnsssdr_free(d_local_code_shift_chips); volk_gnsssdr_free(d_correlator_outs); - if (trk_parameters.track_pilot) - { - volk_gnsssdr_free(d_Prompt_Data); - } + volk_gnsssdr_free(d_Prompt_Data); delete[] d_Prompt_buffer; multicorrelator_fpga->free(); } @@ -554,8 +555,8 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() bool dll_pll_veml_tracking_fpga::acquire_secondary() { // ******* preamble correlation ******** - int corr_value = 0; - for (unsigned int i = 0; i < d_secondary_code_length; i++) + int32_t corr_value = 0; + for (uint32_t i = 0; i < d_secondary_code_length; i++) { if (d_Prompt_buffer_deque.at(i).real() < 0.0) // symbols clipping { @@ -581,7 +582,7 @@ bool dll_pll_veml_tracking_fpga::acquire_secondary() } } - if (abs(corr_value) == d_secondary_code_length) + if (abs(corr_value) == static_cast(d_secondary_code_length)) { return true; } @@ -595,6 +596,7 @@ bool dll_pll_veml_tracking_fpga::acquire_secondary() bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integration_time_s) { // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### + if (d_cn0_estimation_counter < trk_parameters.cn0_samples) { // fill buffer with prompt correlator output values @@ -635,6 +637,26 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra } +// correlation requires: +// - updated remnant carrier phase in radians (rem_carr_phase_rad) +// - updated remnant code phase in samples (d_rem_code_phase_samples) +// - d_code_freq_chips +// - d_carrier_doppler_hz +//void dll_pll_veml_tracking_fpga::do_correlation_step(const gr_complex *input_samples) +void dll_pll_veml_tracking_fpga::do_correlation_step(void) +{ + // // ################# CARRIER WIPEOFF AND CORRELATORS ############################## + + multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( + d_rem_carr_phase_rad, + d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, + static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), + d_current_prn_length_samples); +} + + void dll_pll_veml_tracking_fpga::run_dll_pll() { // ################## PLL ########################################################## @@ -654,8 +676,7 @@ void dll_pll_veml_tracking_fpga::run_dll_pll() d_carr_error_filt_hz = d_carrier_loop_filter.get_carrier_nco(d_carr_error_hz); // New carrier Doppler frequency estimation d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_carr_error_filt_hz; - // New code Doppler frequency estimation - d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate; + // ################## DLL ########################################################## // DLL discriminator @@ -669,13 +690,16 @@ void dll_pll_veml_tracking_fpga::run_dll_pll() } // Code discriminator filter d_code_error_filt_chips = d_code_loop_filter.get_code_nco(d_code_error_chips); // [chips/second] + + // New code Doppler frequency estimation + d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate - d_code_error_filt_chips; } void dll_pll_veml_tracking_fpga::clear_tracking_vars() { std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); - if (trk_parameters.track_pilot) *d_Prompt_Data = gr_complex(0.0, 0.0); + if (trk_parameters.track_pilot) d_Prompt_Data[0] = gr_complex(0.0, 0.0); d_carr_error_hz = 0.0; d_carr_error_filt_hz = 0.0; d_code_error_chips = 0.0; @@ -683,6 +707,10 @@ void dll_pll_veml_tracking_fpga::clear_tracking_vars() d_current_symbol = 0; d_Prompt_buffer_deque.clear(); d_last_prompt = gr_complex(0.0, 0.0); + d_carrier_phase_rate_step_rad = 0.0; + d_code_phase_rate_step_chips = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); } @@ -690,26 +718,67 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() { T_chip_seconds = 1.0 / d_code_freq_chips; T_prn_seconds = T_chip_seconds * static_cast(d_code_length_chips); - double code_error_filt_secs = T_prn_seconds * d_code_error_filt_chips * T_chip_seconds; //[seconds] // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation T_prn_samples = T_prn_seconds * trk_parameters.fs_in; - K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * trk_parameters.fs_in; - d_next_prn_length_samples = round(K_blk_samples); + K_blk_samples = T_prn_samples + d_rem_code_phase_samples; + d_next_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples + //################### PLL COMMANDS ################################################# // carrier phase step (NCO phase increment per sample) [rads/sample] d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / trk_parameters.fs_in; + // carrier phase rate step (NCO phase increment rate per sample) [rads/sample^2] + if (trk_parameters.high_dyn) + { + d_carr_ph_history.push_back(std::pair(d_carrier_phase_step_rad, static_cast(d_current_prn_length_samples))); + if (d_carr_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (uint32_t k = 0; k < trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_carr_ph_history.at(k).first; + tmp_cp2 += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; + tmp_samples += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + } + tmp_cp1 /= static_cast(trk_parameters.smoother_length); + tmp_cp2 /= static_cast(trk_parameters.smoother_length); + d_carrier_phase_rate_step_rad = (tmp_cp2 - tmp_cp1) / tmp_samples; + } + } // remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad += d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); + + // carrier phase accumulator - d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + d_acc_carrier_phase_rad -= (d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); //################### DLL COMMANDS ################################################# // code phase step (Code resampler phase increment per sample) [chips/sample] d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; + if (trk_parameters.high_dyn) + { + d_code_ph_history.push_back(std::pair(d_code_phase_step_chips, static_cast(d_current_prn_length_samples))); + if (d_code_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (uint32_t k = 0; k < trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_code_ph_history.at(k).first; + tmp_cp2 += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; + tmp_samples += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + } + tmp_cp1 /= static_cast(trk_parameters.smoother_length); + tmp_cp2 /= static_cast(trk_parameters.smoother_length); + d_code_phase_rate_step_chips = (tmp_cp2 - tmp_cp1) / tmp_samples; + } + } // remnant code phase [chips] d_rem_code_phase_samples = K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample d_rem_code_phase_chips = d_code_freq_chips * d_rem_code_phase_samples / trk_parameters.fs_in; @@ -769,7 +838,7 @@ void dll_pll_veml_tracking_fpga::save_correlation_results() void dll_pll_veml_tracking_fpga::log_data(bool integrating) { - if (trk_parameters.dump) + if (d_dump) { // Dump results to file float prompt_I; @@ -777,6 +846,7 @@ void dll_pll_veml_tracking_fpga::log_data(bool integrating) float tmp_VE, tmp_E, tmp_P, tmp_L, tmp_VL; float tmp_float; double tmp_double; + uint64_t tmp_long_int; if (trk_parameters.track_pilot) { if (interchange_iq) @@ -843,15 +913,22 @@ void dll_pll_veml_tracking_fpga::log_data(bool integrating) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + tmp_long_int = d_sample_counter + static_cast(d_current_prn_length_samples); + d_dump_file.write(reinterpret_cast(&tmp_long_int), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_rad; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency tmp_float = d_carrier_doppler_hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // carrier phase rate [Hz/s] + tmp_float = d_carrier_phase_rate_step_rad * trk_parameters.fs_in * trk_parameters.fs_in / PI_2; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); tmp_float = d_code_freq_chips; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // code phase rate [chips/s^2] + tmp_float = d_code_phase_rate_step_chips * trk_parameters.fs_in * trk_parameters.fs_in; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // PLL commands tmp_float = d_carr_error_hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -873,8 +950,8 @@ void dll_pll_veml_tracking_fpga::log_data(bool integrating) tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } catch (const std::ifstream::failure &e) { @@ -884,19 +961,25 @@ void dll_pll_veml_tracking_fpga::log_data(bool integrating) } -int dll_pll_veml_tracking_fpga::save_matfile() +int32_t dll_pll_veml_tracking_fpga::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 1; - int number_of_float_vars = 17; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 1; + int32_t number_of_float_vars = 19; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; + std::string dump_filename_ = d_dump_filename; + // add channel number to the filename + dump_filename_.append(std::to_string(d_channel)); + // add extension + dump_filename_.append(".dat"); + std::cout << "Generating .mat file for " << dump_filename_ << std::endl; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try { - dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::binary | std::ios::ate); + dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate); } catch (const std::ifstream::failure &e) { @@ -904,11 +987,11 @@ int dll_pll_veml_tracking_fpga::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else @@ -922,10 +1005,12 @@ int dll_pll_veml_tracking_fpga::save_matfile() float *abs_VL = new float[num_epoch]; float *Prompt_I = new float[num_epoch]; float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; + uint64_t *PRN_start_sample_count = new uint64_t[num_epoch]; float *acc_carrier_phase_rad = new float[num_epoch]; float *carrier_doppler_hz = new float[num_epoch]; + float *carrier_doppler_rate_hz = new float[num_epoch]; float *code_freq_chips = new float[num_epoch]; + float *code_freq_rate_chips = new float[num_epoch]; float *carr_error_hz = new float[num_epoch]; float *carr_error_filt_hz = new float[num_epoch]; float *code_error_chips = new float[num_epoch]; @@ -934,13 +1019,14 @@ int dll_pll_veml_tracking_fpga::save_matfile() float *carrier_lock_test = new float[num_epoch]; float *aux1 = new float[num_epoch]; double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + uint32_t *PRN = new uint32_t[num_epoch]; + try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_VE[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); @@ -949,10 +1035,12 @@ int dll_pll_veml_tracking_fpga::save_matfile() dump_file.read(reinterpret_cast(&abs_VL[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_doppler_rate_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_freq_rate_chips[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(float)); @@ -961,7 +1049,7 @@ int dll_pll_veml_tracking_fpga::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(float)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(float)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -979,7 +1067,9 @@ int dll_pll_veml_tracking_fpga::save_matfile() delete[] PRN_start_sample_count; delete[] acc_carrier_phase_rad; delete[] carrier_doppler_hz; + delete[] carrier_doppler_rate_hz; delete[] code_freq_chips; + delete[] code_freq_rate_chips; delete[] carr_error_hz; delete[] carr_error_filt_hz; delete[] code_error_chips; @@ -995,11 +1085,11 @@ int dll_pll_veml_tracking_fpga::save_matfile() // WRITE MAT FILE mat_t *matfp; matvar_t *matvar; - std::string filename = trk_parameters.dump_filename; + std::string filename = dump_filename_; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_VE, 0); @@ -1042,10 +1132,18 @@ int dll_pll_veml_tracking_fpga::save_matfile() Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + matvar = Mat_VarCreate("carrier_doppler_rate_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_rate_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + matvar = Mat_VarCreate("code_freq_rate_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_rate_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -1093,7 +1191,9 @@ int dll_pll_veml_tracking_fpga::save_matfile() delete[] PRN_start_sample_count; delete[] acc_carrier_phase_rad; delete[] carrier_doppler_hz; + delete[] carrier_doppler_rate_hz; delete[] code_freq_chips; + delete[] code_freq_rate_chips; delete[] carr_error_hz; delete[] carr_error_filt_hz; delete[] code_error_chips; @@ -1106,23 +1206,28 @@ int dll_pll_veml_tracking_fpga::save_matfile() return 0; } -void dll_pll_veml_tracking_fpga::set_channel(unsigned int channel) + +void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { d_channel = channel; multicorrelator_fpga->set_channel(d_channel); LOG(INFO) << "Tracking Channel set to " << d_channel; // ############# ENABLE DATA FILE LOG ################# - if (trk_parameters.dump) + if (d_dump) { + std::string dump_filename_ = d_dump_filename; + // add channel number to the filename + dump_filename_.append(std::to_string(d_channel)); + // add extension + dump_filename_.append(".dat"); + if (!d_dump_file.is_open()) { try { - trk_parameters.dump_filename.append(boost::lexical_cast(d_channel)); - trk_parameters.dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << trk_parameters.dump_filename.c_str(); + d_dump_file.open(dump_filename_.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << dump_filename_.c_str(); } catch (const std::ifstream::failure &e) { @@ -1139,206 +1244,107 @@ void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) } -void dll_pll_veml_tracking_fpga::reset(void) +void dll_pll_veml_tracking_fpga::stop_tracking() { - multicorrelator_fpga->unlock_channel(); + d_state = 0; } - -int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), +int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - // Block input data and block output stream pointers Gnss_Synchro **out = reinterpret_cast(&output_items[0]); - - // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); d_current_prn_length_samples = d_next_prn_length_samples; - current_synchro_data = *d_acquisition_gnss_synchro; + switch (d_state) { case 0: // Standby - Consume samples at full throttle, do nothing { - for (int n = 0; n < d_n_correlator_taps; n++) - { - d_correlator_outs[n] = gr_complex(0, 0); - } - - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; - current_synchro_data.System = {'G'}; - current_synchro_data.correlation_length_ms = 1; - break; - } - case 1: // Standby - Consume samples at full throttle, do nothing - { - d_pull_in = 0; - multicorrelator_fpga->lock_channel(); - unsigned counter_value = multicorrelator_fpga->read_sample_counter(); - unsigned num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); - unsigned absolute_samples_offset = current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames * d_correlation_length_samples; - multicorrelator_fpga->set_initial_sample(absolute_samples_offset); - d_sample_counter = absolute_samples_offset; - current_synchro_data.Tracking_sample_counter = absolute_samples_offset; - d_sample_counter_next = d_sample_counter; - d_state = 2; return 0; break; } - - case 2: + case 1: // Pull-in { - d_sample_counter = d_sample_counter_next; - d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; + int64_t acq_trk_diff_samples; + double acq_trk_diff_seconds; + double delta_trk_to_acq_prn_start_samples; - // ################# CARRIER WIPEOFF AND CORRELATORS ############################## - // perform carrier wipe-off and compute Early, Prompt and Late correlation - multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips, d_code_phase_step_chips, - d_current_prn_length_samples); - - // Save single correlation step variables - if (d_veml) + multicorrelator_fpga->lock_channel(); + uint64_t counter_value = multicorrelator_fpga->read_sample_counter(); + uint64_t absolute_samples_offset; + if (counter_value > (d_acq_sample_stamp + d_acq_code_phase_samples)) { - d_VE_accu = *d_Very_Early; - d_VL_accu = *d_Very_Late; - } - d_E_accu = *d_Early; - d_P_accu = *d_Prompt; - d_L_accu = *d_Late; + // Signal alignment (skip samples until the incoming signal is aligned with local replica) + acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; + delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; - if (!cn0_and_tracking_lock_status(d_code_period)) - { - clear_tracking_vars(); - d_state = 0; // loss-of-lock detected + uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_correlation_length_samples); + absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); } else { - bool next_state = false; - // Perform DLL/PLL tracking loop computations. Costas Loop enabled - run_dll_pll(); - update_tracking_vars(); + // test mode - // enable write dump file this cycle (valid DLL/PLL cycle) - log_data(false); - if (d_secondary) - { - // ####### SECONDARY CODE LOCK ##### - d_Prompt_buffer_deque.push_back(*d_Prompt); - if (d_Prompt_buffer_deque.size() == d_secondary_code_length) - { - next_state = acquire_secondary(); - if (next_state) - { - std::cout << systemName << " " << signal_pretty_name << " secondary code locked in channel " << d_channel - << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; - } + acq_trk_diff_samples = -static_cast(counter_value) + static_cast(d_acq_sample_stamp); + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; + delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) + d_acq_code_phase_samples; - d_Prompt_buffer_deque.pop_front(); - } - } - else if (d_symbols_per_bit > 1) //Signal does not have secondary code. Search a bit transition by sign change - { - if (d_synchonizing) - { - if (d_Prompt->real() * d_last_prompt.real() > 0.0) - { - d_current_symbol++; - } - else if (d_current_symbol > d_symbols_per_bit) - { - d_synchonizing = false; - d_current_symbol = 1; - } - else - { - d_current_symbol = 1; - d_last_prompt = *d_Prompt; - } - } - else if (d_last_prompt.real() != 0.0) - { - d_current_symbol++; - if (d_current_symbol == d_symbols_per_bit) next_state = true; - } - else - { - d_last_prompt = *d_Prompt; - d_synchonizing = true; - d_current_symbol = 1; - } - } - else - { - next_state = true; - } - - if (next_state) - { // reset extended correlator - d_VE_accu = gr_complex(0.0, 0.0); - d_E_accu = gr_complex(0.0, 0.0); - d_P_accu = gr_complex(0.0, 0.0); - d_L_accu = gr_complex(0.0, 0.0); - d_VL_accu = gr_complex(0.0, 0.0); - d_last_prompt = gr_complex(0.0, 0.0); - d_Prompt_buffer_deque.clear(); - d_current_symbol = 0; - d_synchonizing = false; - - if (d_enable_extended_integration) - { - // UPDATE INTEGRATION TIME - d_extend_correlation_symbols_count = 0; - float new_correlation_time = static_cast(trk_parameters.extend_correlation_symbols) * static_cast(d_code_period); - d_carrier_loop_filter.set_pdi(new_correlation_time); - d_code_loop_filter.set_pdi(new_correlation_time); - d_state = 3; // next state is the extended correlator integrator - LOG(INFO) << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " - << d_channel - << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN); - std::cout << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " - << d_channel - << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; - // Set narrow taps delay values [chips] - d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_narrow_hz); - d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_narrow_hz); - if (d_veml) - { - d_local_code_shift_chips[0] = -trk_parameters.very_early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); - d_local_code_shift_chips[1] = -trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); - d_local_code_shift_chips[3] = trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); - d_local_code_shift_chips[4] = trk_parameters.very_early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); - } - else - { - d_local_code_shift_chips[0] = -trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); - d_local_code_shift_chips[2] = trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); - } - } - else - { - d_state = 4; - } - } + absolute_samples_offset = static_cast(delta_trk_to_acq_prn_start_samples); } + multicorrelator_fpga->set_initial_sample(absolute_samples_offset); + d_absolute_samples_offset = absolute_samples_offset; + d_sample_counter = absolute_samples_offset; + current_synchro_data.Tracking_sample_counter = absolute_samples_offset; + d_sample_counter_next = d_sample_counter; + + // Signal alignment (skip samples until the incoming signal is aligned with local replica) + + // Doppler effect Fd = (C / (C + Vr)) * F + double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; + // new chip and PRN sequence periods based on acq Doppler + d_code_freq_chips = radial_velocity * d_code_chip_rate; + d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; + d_code_phase_rate_step_chips = 0.0; + double T_chip_mod_seconds = 1.0 / d_code_freq_chips; + double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); + double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; + + d_acq_code_phase_samples = absolute_samples_offset; + + d_current_prn_length_samples = round(T_prn_mod_samples); + + d_next_prn_length_samples = d_current_prn_length_samples; + int32_t samples_offset = round(d_acq_code_phase_samples); + d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(samples_offset); + d_state = 2; + + DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples << " ( " << acq_trk_diff_seconds << " s)"; + DLOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz + << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; + + // don't leave the HW module blocking the signal path before the first sample arrives + // start the first tracking process + run_state_2(current_synchro_data); break; } - - case 3: + case 2: // Wide tracking and symbol synchronization + { + run_state_2(current_synchro_data); + break; + } + case 3: // coherent integration (correlation time extension) { d_sample_counter = d_sample_counter_next; - d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; + d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); // Fill the acquisition data current_synchro_data = *d_acquisition_gnss_synchro; // perform a correlation step - multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips, d_code_phase_step_chips, - d_current_prn_length_samples); + do_correlation_step(); update_tracking_vars(); save_correlation_results(); @@ -1386,19 +1392,15 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un log_data(true); break; } - case 4: // narrow tracking { d_sample_counter = d_sample_counter_next; - d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; + d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); + // Fill the acquisition data + current_synchro_data = *d_acquisition_gnss_synchro; // perform a correlation step - //do_correlation_step(in); - multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips, d_code_phase_step_chips, - d_current_prn_length_samples); - + do_correlation_step(); save_correlation_results(); // check lock status @@ -1441,7 +1443,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); } } - current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -1465,10 +1466,192 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } if (current_synchro_data.Flag_valid_symbol_output) { - current_synchro_data.fs = static_cast(trk_parameters.fs_in); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.fs = static_cast(trk_parameters.fs_in); + // two choices for the reporting of the sample counter: + // either the sample counter position that should be (d_sample_counter_next) + //or the sample counter corresponding to the number of samples that the FPGA actually consumed. + current_synchro_data.Tracking_sample_counter = d_sample_counter_next; *out[0] = current_synchro_data; return 1; } return 0; } + +void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) +{ + d_sample_counter = d_sample_counter_next; + d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); + + do_correlation_step(); + // Save single correlation step variables + if (d_veml) + { + d_VE_accu = *d_Very_Early; + d_VL_accu = *d_Very_Late; + } + d_E_accu = *d_Early; + d_P_accu = *d_Prompt; + d_L_accu = *d_Late; + + // Check lock status + if (!cn0_and_tracking_lock_status(d_code_period)) + { + clear_tracking_vars(); + d_state = 0; // loss-of-lock detected + } + else + { + bool next_state = false; + // Perform DLL/PLL tracking loop computations. Costas Loop enabled + run_dll_pll(); + update_tracking_vars(); + + // enable write dump file this cycle (valid DLL/PLL cycle) + log_data(false); + if (d_secondary) + { + // ####### SECONDARY CODE LOCK ##### + d_Prompt_buffer_deque.push_back(*d_Prompt); + if (d_Prompt_buffer_deque.size() == d_secondary_code_length) + { + next_state = acquire_secondary(); + if (next_state) + { + std::cout << systemName << " " << signal_pretty_name << " secondary code locked in channel " << d_channel + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + } + + d_Prompt_buffer_deque.pop_front(); + } + } + else if (d_symbols_per_bit > 1) //Signal does not have secondary code. Search a bit transition by sign change + { + float current_tracking_time_s = static_cast(d_sample_counter - d_absolute_samples_offset) / trk_parameters.fs_in; + if (current_tracking_time_s > 10) + { + d_symbol_history.push_back(d_Prompt->real()); + //******* preamble correlation ******** + int32_t corr_value = 0; + if ((d_symbol_history.size() == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)) // and (d_make_correlation or !d_flag_frame_sync)) + { + for (uint32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) + { + if (d_symbol_history.at(i) < 0) // symbols clipping + { + corr_value -= d_gps_l1ca_preambles_symbols[i]; + } + else + { + corr_value += d_gps_l1ca_preambles_symbols[i]; + } + } + } + if (corr_value == GPS_CA_PREAMBLE_LENGTH_SYMBOLS) + { + next_state = true; + } + else + { + next_state = false; + } + } + else + { + next_state = false; + } + } + else + { + next_state = true; + } + + // ########### Output the tracking results to Telemetry block ########## + if (interchange_iq) + { + if (trk_parameters.track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).real()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).real()); + } + } + else + { + if (trk_parameters.track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).imag()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); + } + } + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + current_synchro_data.Flag_valid_symbol_output = true; + current_synchro_data.correlation_length_ms = d_correlation_length_ms; + + if (next_state) + { // reset extended correlator + d_VE_accu = gr_complex(0.0, 0.0); + d_E_accu = gr_complex(0.0, 0.0); + d_P_accu = gr_complex(0.0, 0.0); + d_L_accu = gr_complex(0.0, 0.0); + d_VL_accu = gr_complex(0.0, 0.0); + d_last_prompt = gr_complex(0.0, 0.0); + d_Prompt_buffer_deque.clear(); + d_current_symbol = 0; + + if (d_enable_extended_integration) + { + // UPDATE INTEGRATION TIME + d_extend_correlation_symbols_count = 0; + float new_correlation_time = static_cast(trk_parameters.extend_correlation_symbols) * static_cast(d_code_period); + d_carrier_loop_filter.set_pdi(new_correlation_time); + d_code_loop_filter.set_pdi(new_correlation_time); + d_state = 3; // next state is the extended correlator integrator + LOG(INFO) << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " + << d_channel + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN); + std::cout << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " + << d_channel + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + // Set narrow taps delay values [chips] + d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_narrow_hz); + d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_narrow_hz); + if (d_veml) + { + d_local_code_shift_chips[0] = -trk_parameters.very_early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[1] = -trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[3] = trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[4] = trk_parameters.very_early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); + } + else + { + d_local_code_shift_chips[0] = -trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[2] = trk_parameters.early_late_space_narrow_chips * static_cast(d_code_samples_per_chip); + } + } + else + { + d_state = 4; + } + } + } +} + + +void dll_pll_veml_tracking_fpga::reset(void) +{ + multicorrelator_fpga->unlock_channel(); +} diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 09efbd9b7..a280c2cad 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -1,19 +1,13 @@ /*! - * \file gps_l1_ca_dll_pll_tracking_fpga.h - * \brief Interface of a code DLL + carrier PLL tracking block - * \author Marc Majoral, 2018. marc.majoral(at)cttc.es - * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Javier Arribas, 2011. jarribas(at)cttc.es - * Cillian O'Driscoll, 2017. cillian.odriscoll(at)gmail.com - * - * Code DLL + carrier PLL according to the algorithms described in: - * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, - * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, - * Birkhauser, 2007 + * \file dll_pll_veml_tracking_fpga.h + * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA. + * \author Marc Majoral, 2019. marc.majoral(at)cttc.es + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -39,64 +33,38 @@ #ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H #define GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H +#include "dll_pll_conf_fpga.h" #include "fpga_multicorrelator.h" #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_2nd_PLL_filter.h" +#include #include #include -#include #include - - -typedef struct -{ - /* DLL/PLL tracking configuration */ - double fs_in; - unsigned int vector_length; - bool dump; - std::string dump_filename; - float pll_bw_hz; - float dll_bw_hz; - float pll_bw_narrow_hz; - float dll_bw_narrow_hz; - float early_late_space_chips; - float very_early_late_space_chips; - float early_late_space_narrow_chips; - float very_early_late_space_narrow_chips; - int extend_correlation_symbols; - int cn0_samples; - int cn0_min; - int max_lock_fail; - double carrier_lock_th; - bool track_pilot; - char system; - char signal[3]; - std::string device_name; - unsigned int device_base; - unsigned int code_length; - int *ca_codes; -} dllpllconf_fpga_t; +#include +#include +//#include class dll_pll_veml_tracking_fpga; -typedef boost::shared_ptr - dll_pll_veml_tracking_fpga_sptr; +typedef boost::shared_ptr dll_pll_veml_tracking_fpga_sptr; -dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_t conf_); +dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); /*! - * \brief This class implements a DLL + PLL tracking loop block + * \brief This class implements a code DLL + carrier PLL tracking block. */ class dll_pll_veml_tracking_fpga : public gr::block { public: ~dll_pll_veml_tracking_fpga(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); void start_tracking(); + void stop_tracking(); int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); @@ -104,24 +72,28 @@ public: void reset(void); private: - friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_t conf_); + friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); - dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_); + dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); + void msg_handler_preamble_index(pmt::pmt_t msg); bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool acquire_secondary(); + void do_correlation_step(void); void run_dll_pll(); void update_tracking_vars(); void clear_tracking_vars(); void save_correlation_results(); void log_data(bool integrating); - int save_matfile(); + int32_t save_matfile(); + + void run_state_2(Gnss_Synchro ¤t_synchro_data); // tracking configuration vars - dllpllconf_fpga_t trk_parameters; + Dll_Pll_Conf_Fpga trk_parameters; bool d_veml; bool d_cloop; - unsigned int d_channel; + uint32_t d_channel; Gnss_Synchro *d_acquisition_gnss_synchro; //Signal parameters @@ -130,25 +102,34 @@ private: double d_signal_carrier_freq; double d_code_period; double d_code_chip_rate; - unsigned int d_secondary_code_length; - unsigned int d_code_length_chips; - unsigned int d_code_samples_per_chip; // All signals have 1 sample per chip code except Gal. E1 which has 2 (CBOC disabled) or 12 (CBOC enabled) - int d_symbols_per_bit; + uint32_t d_secondary_code_length; + uint32_t d_code_length_chips; + uint32_t d_code_samples_per_chip; // All signals have 1 sample per chip code except Gal. E1 which has 2 (CBOC disabled) or 12 (CBOC enabled) + int32_t d_symbols_per_bit; std::string systemName; std::string signal_type; std::string *d_secondary_code_string; std::string signal_pretty_name; + int32_t *d_gps_l1ca_preambles_symbols; + boost::circular_buffer d_symbol_history; + //tracking state machine - int d_state; - bool d_synchonizing; + int32_t d_state; //Integration period in samples - int d_correlation_length_ms; - int d_n_correlator_taps; + int32_t d_correlation_length_ms; + int32_t d_n_correlator_taps; + + float *d_tracking_code; + float *d_data_code; float *d_local_code_shift_chips; float *d_prompt_data_shift; std::shared_ptr multicorrelator_fpga; - + /* TODO: currently the multicorrelator does not support adding extra correlator + with different local code, thus we need extra multicorrelator instance. + Implement this functionality inside multicorrelator class + as an enhancement to increase the performance + */ gr_complex *d_correlator_outs; gr_complex *d_Very_Early; gr_complex *d_Early; @@ -157,8 +138,8 @@ private: gr_complex *d_Very_Late; bool d_enable_extended_integration; - int d_extend_correlation_symbols_count; - int d_current_symbol; + int32_t d_extend_correlation_symbols_count; + int32_t d_current_symbol; gr_complex d_VE_accu; gr_complex d_E_accu; @@ -170,10 +151,14 @@ private: gr_complex *d_Prompt_Data; double d_code_phase_step_chips; + double d_code_phase_rate_step_chips; + boost::circular_buffer> d_code_ph_history; double d_carrier_phase_step_rad; + double d_carrier_phase_rate_step_rad; + boost::circular_buffer> d_carr_ph_history; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; - double d_rem_carr_phase_rad; + float d_rem_carr_phase_rad; // PLL and DLL filter library Tracking_2nd_DLL_filter d_code_loop_filter; @@ -188,25 +173,26 @@ private: double d_carr_error_filt_hz; double d_code_error_chips; double d_code_error_filt_chips; - double d_K_blk_samples; double d_code_freq_chips; double d_carrier_doppler_hz; double d_acc_carrier_phase_rad; double d_rem_code_phase_chips; - double d_code_phase_samples; double T_chip_seconds; double T_prn_seconds; double T_prn_samples; double K_blk_samples; // PRN period in samples - int d_current_prn_length_samples; + int32_t d_current_prn_length_samples; // processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; + + uint64_t d_absolute_samples_offset; // CN0 estimation and lock detector - int d_cn0_estimation_counter; - int d_carrier_lock_fail_counter; + int32_t d_cn0_estimation_counter; + int32_t d_carrier_lock_fail_counter; + std::deque d_carrier_lock_detector_queue; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; @@ -215,12 +201,14 @@ private: // file dump std::ofstream d_dump_file; + std::string d_dump_filename; + bool d_dump; + bool d_dump_mat; // extra - int d_correlation_length_samples; - int d_next_prn_length_samples; - unsigned long int d_sample_counter_next; - unsigned int d_pull_in = 0; + int32_t d_correlation_length_samples; + int32_t d_next_prn_length_samples; + uint64_t d_sample_counter_next; }; #endif //GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc index 384e40765..e6177bbe7 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc @@ -37,41 +37,38 @@ */ #include "galileo_e1_tcp_connector_tracking_cc.h" +#include "GPS_L1_CA.h" +#include "Galileo_E1.h" +#include "galileo_e1_signal_processing.h" +#include "gnss_sdr_flags.h" +#include "lock_detectors.h" +#include "tcp_communication.h" +#include "tcp_packet_data.h" +#include "tracking_discriminators.h" +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include "galileo_e1_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" -#include "GPS_L1_CA.h" -#include "Galileo_E1.h" -#include "control_message_factory.h" -#include "gnss_sdr_flags.h" -#include "tcp_communication.h" -#include "tcp_packet_data.h" +#include using google::LogMessage; galileo_e1_tcp_connector_tracking_cc_sptr galileo_e1_tcp_connector_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips, float very_early_late_space_chips, size_t port_ch0) { - return galileo_e1_tcp_connector_tracking_cc_sptr(new Galileo_E1_Tcp_Connector_Tracking_cc(if_freq, + return galileo_e1_tcp_connector_tracking_cc_sptr(new Galileo_E1_Tcp_Connector_Tracking_cc( fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips, very_early_late_space_chips, port_ch0)); } @@ -81,17 +78,16 @@ void Galileo_E1_Tcp_Connector_Tracking_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; // set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; // set the required available samples in each call } } Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float pll_bw_hz __attribute__((unused)), float dll_bw_hz __attribute__((unused)), float early_late_space_chips, @@ -103,7 +99,6 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc( this->set_relative_rate(1.0 / vector_length); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; d_dump_filename = dump_filename; @@ -121,12 +116,12 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc( // Initialization of local code replica // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc((2 * Galileo_E1_B_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc((2 * GALILEO_E1_B_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 5; // Very-Early, Early, Prompt, Late, Very-Late d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -151,20 +146,20 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc( //--- Perform initializations ------------------------------ // define initial code frequency basis of NCO - d_code_freq_chips = Galileo_E1_CODE_CHIP_RATE_HZ; + d_code_freq_chips = GALILEO_E1_CODE_CHIP_RATE_HZ; // define residual code phase (in chips) d_rem_code_phase_samples = 0.0; // define residual carrier phase d_rem_carr_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; + d_sample_counter = 0ULL; d_acq_sample_stamp = 0; d_enable_tracking = false; d_pull_in = false; - d_current_prn_length_samples = static_cast(d_vector_length); + d_current_prn_length_samples = static_cast(d_vector_length); // CN0 estimation and lock detector buffers d_cn0_estimation_counter = 0; @@ -175,7 +170,7 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc( d_carrier_lock_threshold = FLAGS_carrier_lock_th; systemName["E"] = std::string("Galileo"); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_next_rem_code_phase_samples = 0; d_acq_code_phase_samples = 0.0; @@ -199,11 +194,11 @@ void Galileo_E1_Tcp_Connector_Tracking_cc::start_tracking() d_acquisition_gnss_synchro->Signal, false, d_acquisition_gnss_synchro->PRN, - 2 * Galileo_E1_CODE_CHIP_RATE_HZ, + 2 * GALILEO_E1_CODE_CHIP_RATE_HZ, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(2 * Galileo_E1_B_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu.set_local_code_and_taps(static_cast(2 * GALILEO_E1_B_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -261,7 +256,7 @@ Galileo_E1_Tcp_Connector_Tracking_cc::~Galileo_E1_Tcp_Connector_Tracking_cc() } -void Galileo_E1_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) +void Galileo_E1_Tcp_Connector_Tracking_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -272,7 +267,7 @@ void Galileo_E1_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -307,12 +302,12 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri float carr_error_filt_hz = 0.0; float code_error_filt_chips = 0.0; - tcp_packet_data tcp_data; + Tcp_Packet_Data tcp_data; // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto **out = reinterpret_cast(&output_items[0]); if (d_enable_tracking == true) { // Fill the acquisition data @@ -322,16 +317,16 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri /* * Signal alignment (skip samples until the incoming signal is aligned with local replica) */ - int samples_offset; + int32_t samples_offset; float acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; - acq_trk_shif_correction_samples = d_current_prn_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); - samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; + acq_trk_shif_correction_samples = d_current_prn_length_samples - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); + samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; - d_sample_counter = d_sample_counter + samples_offset; //count for the processed samples + d_sample_counter = d_sample_counter + static_cast(samples_offset); //count for the processed samples d_pull_in = false; consume_each(samples_offset); //shift input to perform alignment with local replica return 1; @@ -377,11 +372,11 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri // New carrier Doppler frequency estimation d_carrier_doppler_hz = d_acq_carrier_doppler_hz + carr_error_filt_hz; // New code Doppler frequency estimation - d_code_freq_chips = Galileo_E1_CODE_CHIP_RATE_HZ + ((d_carrier_doppler_hz * Galileo_E1_CODE_CHIP_RATE_HZ) / Galileo_E1_FREQ_HZ); + d_code_freq_chips = GALILEO_E1_CODE_CHIP_RATE_HZ + ((d_carrier_doppler_hz * GALILEO_E1_CODE_CHIP_RATE_HZ) / GALILEO_E1_FREQ_HZ); //carrier phase accumulator for (K) doppler estimation - d_acc_carrier_phase_rad -= GPS_TWO_PI * d_carrier_doppler_hz * Galileo_E1_CODE_PERIOD; + d_acc_carrier_phase_rad -= GPS_TWO_PI * d_carrier_doppler_hz * GALILEO_E1_CODE_PERIOD; //remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad = d_rem_carr_phase_rad + GPS_TWO_PI * d_carrier_doppler_hz * Galileo_E1_CODE_PERIOD; + d_rem_carr_phase_rad = d_rem_carr_phase_rad + GPS_TWO_PI * d_carrier_doppler_hz * GALILEO_E1_CODE_PERIOD; d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, GPS_TWO_PI); // ################## DLL ########################################################## @@ -389,7 +384,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri code_error_filt_chips = tcp_data.proc_pack_code_error; //Code phase accumulator float code_error_filt_secs; - code_error_filt_secs = (Galileo_E1_CODE_PERIOD * code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; //[seconds] + code_error_filt_secs = (GALILEO_E1_CODE_PERIOD * code_error_filt_chips) / GALILEO_E1_CODE_CHIP_RATE_HZ; //[seconds] d_acc_code_phase_secs = d_acc_code_phase_secs + code_error_filt_secs; // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### @@ -400,7 +395,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri double K_blk_samples; // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation T_chip_seconds = 1 / static_cast(d_code_freq_chips); - T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; + T_prn_seconds = T_chip_seconds * GALILEO_E1_B_CODE_LENGTH_CHIPS; T_prn_samples = T_prn_seconds * static_cast(d_fs_in); K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast(d_fs_in); d_current_prn_length_samples = round(K_blk_samples); //round to a discrete samples @@ -418,7 +413,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri d_cn0_estimation_counter = 0; // Code lock indicator - d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, Galileo_E1_CODE_PERIOD); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, GALILEO_E1_CODE_PERIOD); // Carrier lock indicator d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); @@ -430,7 +425,10 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -447,7 +445,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri current_synchro_data.Prompt_I = static_cast((*d_Prompt).real()); current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); // Tracking_timestamp_secs is aligned with the PRN start sample - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample current_synchro_data.Carrier_phase_rads = static_cast(d_acc_carrier_phase_rad); @@ -461,7 +459,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri *d_Early = gr_complex(0, 0); *d_Prompt = gr_complex(0, 0); *d_Late = gr_complex(0, 0); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); //! When tracking is disabled an array of 1's is sent to maintain the TCP connection boost::array tx_variables_array = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}}; d_tcp_com.send_receive_tcp_packet_galileo_e1(tx_variables_array, &tcp_data); @@ -501,7 +499,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_rad; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -528,11 +526,11 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri // AUX vars (for debug purposes) tmp_float = 0.0; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } catch (const std::ifstream::failure &e) { @@ -546,8 +544,6 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri { return 1; } - else - { - return 0; - } + + return 0; } diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.h index 6a7e3c728..423eef516 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.h @@ -39,25 +39,25 @@ #ifndef GNSS_SDR_GALILEO_E1_TCP_CONNECTOR_TRACKING_CC_H #define GNSS_SDR_GALILEO_E1_TCP_CONNECTOR_TRACKING_CC_H +#include "cpu_multicorrelator.h" +#include "gnss_synchro.h" +#include "tcp_communication.h" +#include +#include #include #include #include -#include -#include -#include "gnss_synchro.h" -#include "cpu_multicorrelator.h" -#include "tcp_communication.h" class Galileo_E1_Tcp_Connector_Tracking_cc; -typedef boost::shared_ptr galileo_e1_tcp_connector_tracking_cc_sptr; +using galileo_e1_tcp_connector_tracking_cc_sptr = boost::shared_ptr; galileo_e1_tcp_connector_tracking_cc_sptr -galileo_e1_tcp_connector_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, +galileo_e1_tcp_connector_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips, @@ -73,7 +73,7 @@ class Galileo_E1_Tcp_Connector_Tracking_cc : public gr::block public: ~Galileo_E1_Tcp_Connector_Tracking_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); void start_tracking(); @@ -84,20 +84,20 @@ public: private: friend galileo_e1_tcp_connector_tracking_cc_sptr - galileo_e1_tcp_connector_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + galileo_e1_tcp_connector_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips, float very_early_late_space_chips, size_t port_ch0); - Galileo_E1_Tcp_Connector_Tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + Galileo_E1_Tcp_Connector_Tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips, @@ -109,17 +109,16 @@ private: void update_local_carrier(); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro *d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; + int64_t d_fs_in; - int d_correlation_length_samples; - int d_n_correlator_taps; + int32_t d_correlation_length_samples; + int32_t d_n_correlator_taps; float d_early_late_spc_chips; float d_very_early_late_spc_chips; @@ -143,7 +142,7 @@ private: // correlator float *d_local_code_shift_chips; gr_complex *d_correlator_outs; - cpu_multicorrelator multicorrelator_cpu; + Cpu_Multicorrelator multicorrelator_cpu; // tracking vars double d_code_freq_chips; @@ -153,25 +152,25 @@ private: float d_code_phase_samples; size_t d_port_ch0; size_t d_port; - int d_listen_connection; + int32_t d_listen_connection; float d_control_id; - tcp_communication d_tcp_com; + Tcp_Communication d_tcp_com; //PRN period in samples - int d_current_prn_length_samples; - int d_next_prn_length_samples; + int32_t d_current_prn_length_samples; + int32_t d_next_prn_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex *d_Prompt_buffer; float d_carrier_lock_test; float d_CN0_SNV_dB_Hz; float d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc index f822ae6af..21a040646 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -1,5 +1,5 @@ /*! - * \file glonass_l1_ca_dll_pll_c_aid_tracking_cc.h + * \file glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc * \brief Implementation of a code DLL + carrier PLL tracking block * \author Gabriel Araujo, 2017. gabriel.araujo.5000(at)gmail.com * \author Luis Esteve, 2017. luis(at)epsilon-formacion.com @@ -37,23 +37,23 @@ */ #include "glonass_l1_ca_dll_pll_c_aid_tracking_cc.h" -#include "glonass_l1_signal_processing.h" #include "GLONASS_L1_L2_CA.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" +#include "glonass_l1_signal_processing.h" #include "gnss_sdr_flags.h" -#include "control_message_factory.h" -#include +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include +#include #include #include #include #include -#include #include +#include #include #include #include +#include #define CN0_ESTIMATION_SAMPLES 10 @@ -62,20 +62,19 @@ using google::LogMessage; glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr glonass_l1_ca_dll_pll_c_aid_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) { - return glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr(new glonass_l1_ca_dll_pll_c_aid_tracking_cc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + return glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr(new glonass_l1_ca_dll_pll_c_aid_tracking_cc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -84,7 +83,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } @@ -95,7 +94,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pm DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_s = pmt::to_double(std::move(msg)); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -103,16 +102,15 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pm glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) : gr::block("glonass_l1_ca_dll_pll_c_aid_tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { @@ -125,11 +123,10 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; - d_correlation_length_samples = static_cast(d_vector_length); + d_dump_filename = std::move(dump_filename); + d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_pll_bw_hz = pll_bw_hz; @@ -145,12 +142,12 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -171,7 +168,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc d_rem_carrier_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; //(from trk to tlm) + d_sample_counter = 0ULL; //(from trk to tlm) d_acq_sample_stamp = 0; d_enable_tracking = false; d_pull_in = false; @@ -188,7 +185,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc set_relative_rate(1.0 / static_cast(d_vector_length)); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -214,7 +211,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc d_glonass_freq_ch = 0; - //set_min_output_buffer((long int)300); + //set_min_output_buffer((int64_t)300); } @@ -227,9 +224,9 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -262,10 +259,10 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; - // d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ1_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + // d_carrier_doppler_hz = d_acq_carrier_doppler_hz + (DFRQ1_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); // d_carrier_doppler_hz = d_acq_carrier_doppler_hz; // d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); - d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ1_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ1_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); @@ -277,8 +274,8 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) glonass_l1_ca_code_gen_complex(d_ca_code, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -329,7 +326,14 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::~glonass_l1_ca_dll_pll_c_aid_tracking_c { std::cout << "Writing .mat files ..."; } - glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + try + { + glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } if (d_channel == 0) { std::cout << " done." << std::endl; @@ -351,14 +355,14 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::~glonass_l1_ca_dll_pll_c_aid_tracking_c } -int glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() +int32_t glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -371,48 +375,48 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -424,7 +428,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -459,8 +463,8 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -558,7 +562,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() } -void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) +void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -569,15 +573,15 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -594,8 +598,8 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); // PRN start block alignment - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); // PRN start block alignment + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -612,14 +616,14 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter += samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter += static_cast(samples_offset); // count for the processed samples d_pull_in = false; d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GLONASS_TWO_PI; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; @@ -645,7 +649,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_P_history.push_back(d_correlator_outs[1]); // save prompt output d_L_history.push_back(d_correlator_outs[2]); // save late output - if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) { d_E_history.pop_front(); d_P_history.pop_front(); @@ -655,7 +659,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -664,7 +668,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_correlator_outs[0] = gr_complex(0.0, 0.0); d_correlator_outs[1] = gr_complex(0.0, 0.0); d_correlator_outs[2] = gr_complex(0.0, 0.0); - for (int n = 0; n < d_extend_correlation_ms; n++) + for (int32_t n = 0; n < d_extend_correlation_ms; n++) { d_correlator_outs[0] += d_E_history.at(n); d_correlator_outs[1] += d_P_history.at(n); @@ -694,7 +698,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at double T_chip_seconds = 1.0 / d_code_freq_chips; double T_prn_seconds = T_chip_seconds * GLONASS_L1_CA_CODE_LENGTH_CHIPS; double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - int K_prn_samples = round(T_prn_samples); + int32_t K_prn_samples = round(T_prn_samples); double K_T_prn_error_samples = K_prn_samples - T_prn_samples; d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; @@ -804,7 +808,10 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -818,7 +825,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at // ########### Output the tracking data to navigation and PVT ########## current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -837,7 +844,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at { current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler @@ -846,13 +853,13 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } current_synchro_data.System = {'R'}; - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } //assign the GNURadio block output data current_synchro_data.fs = d_fs_in; @@ -883,7 +890,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -910,15 +917,15 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at // AUX vars (for debug purposes) tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.h index e1ef7cacf..93c43c35a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.h @@ -46,26 +46,25 @@ #include "cpu_multicorrelator.h" #include #include +#include #include #include -#include #include class glonass_l1_ca_dll_pll_c_aid_tracking_cc; -typedef boost::shared_ptr - glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr; +using glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr = boost::shared_ptr; glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr -glonass_l1_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, +glonass_l1_ca_dll_pll_c_aid_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); @@ -77,7 +76,7 @@ class glonass_l1_ca_dll_pll_c_aid_tracking_cc : public gr::block public: ~glonass_l1_ca_dll_pll_c_aid_tracking_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -88,52 +87,51 @@ public: private: friend glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr - glonass_l1_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l1_ca_dll_pll_c_aid_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); - glonass_l1_ca_dll_pll_c_aid_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l1_ca_dll_pll_c_aid_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; + int64_t d_fs_in; double d_glonass_freq_ch; double d_early_late_spc_chips; - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; float* d_local_code_shift_chips; gr_complex* d_correlator_outs; - cpu_multicorrelator multicorrelator_cpu; + Cpu_Multicorrelator multicorrelator_cpu; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; double d_rem_code_phase_chips; double d_rem_carrier_phase_rad; - int d_rem_code_phase_integer_samples; + int32_t d_rem_code_phase_integer_samples; // PLL and DLL filter library //Tracking_2nd_DLL_filter d_code_loop_filter; @@ -168,25 +166,25 @@ private: std::deque d_P_history; std::deque d_L_history; double d_preamble_timestamp_s; - int d_extend_correlation_ms; + int32_t d_extend_correlation_ms; bool d_enable_extended_integration; bool d_preamble_synchronized; void msg_handler_preamble_index(pmt::pmt_t msg); //Integration period in samples - int d_correlation_length_samples; + int32_t d_correlation_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -199,7 +197,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index 8b66a3605..3e0338be2 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -37,23 +37,22 @@ */ #include "glonass_l1_ca_dll_pll_c_aid_tracking_sc.h" -#include "gnss_synchro.h" -#include "glonass_l1_signal_processing.h" #include "GLONASS_L1_L2_CA.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" +#include "glonass_l1_signal_processing.h" #include "gnss_sdr_flags.h" -#include "control_message_factory.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include -#include +#include #include #include #include -#include #include +#include #include #include #include +#include #define CN0_ESTIMATION_SAMPLES 10 @@ -61,20 +60,19 @@ using google::LogMessage; glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr glonass_l1_ca_dll_pll_c_aid_make_tracking_sc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) { - return glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr(new glonass_l1_ca_dll_pll_c_aid_tracking_sc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + return glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr(new glonass_l1_ca_dll_pll_c_aid_tracking_sc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -83,7 +81,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } @@ -94,23 +92,22 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(pmt::pm DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_s = pmt::to_double(std::move(msg)); d_enable_extended_integration = true; d_preamble_synchronized = false; } } glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) : gr::block("glonass_l1_ca_dll_pll_c_aid_tracking_sc", gr::io_signature::make(1, 1, sizeof(lv_16sc_t)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { @@ -121,11 +118,10 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; - d_correlation_length_samples = static_cast(d_vector_length); + d_dump_filename = std::move(dump_filename); + d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_pll_bw_hz = pll_bw_hz; @@ -141,14 +137,14 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - d_ca_code_16sc = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code_16sc = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs_16sc = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_cmake(0, 0); } @@ -170,7 +166,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc d_rem_carrier_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; //(from trk to tlm) + d_sample_counter = 0ULL; //(from trk to tlm) d_acq_sample_stamp = 0; d_enable_tracking = false; d_pull_in = false; @@ -187,7 +183,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc set_relative_rate(1.0 / static_cast(d_vector_length)); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -211,7 +207,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc d_carrier_doppler_old_hz = 0.0; d_glonass_freq_ch = 0; - //set_min_output_buffer((long int)300); + //set_min_output_buffer((int64_t)300); } @@ -224,9 +220,9 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -259,7 +255,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; - d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ1_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ1_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); ; d_carrier_doppler_hz = d_acq_carrier_doppler_hz; @@ -271,10 +267,10 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) glonass_l1_ca_code_gen_complex(d_ca_code, 0); - volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS)); + volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS)); - multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_16sc_t(0, 0); } @@ -306,14 +302,14 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() } -int glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() +int32_t glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -326,48 +322,48 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -379,7 +375,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -414,8 +410,8 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -533,7 +529,15 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::~glonass_l1_ca_dll_pll_c_aid_tracking_s { std::cout << "Writing .mat files ..."; } - glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + try + { + glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; @@ -550,7 +554,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::~glonass_l1_ca_dll_pll_c_aid_tracking_s } -void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) +void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -561,15 +565,15 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -586,8 +590,8 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // Block input data and block output stream pointers - const lv_16sc_t *in = reinterpret_cast(input_items[0]); // PRN start block alignment - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); // PRN start block alignment + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -604,14 +608,14 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter += samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter += static_cast(samples_offset); // count for the processed samples d_pull_in = false; d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GLONASS_TWO_PI; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; @@ -637,7 +641,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output d_L_history.push_back(d_correlator_outs_16sc[2]); // save late output - if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) { d_E_history.pop_front(); d_P_history.pop_front(); @@ -647,7 +651,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -656,7 +660,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_correlator_outs_16sc[0] = lv_cmake(0, 0); d_correlator_outs_16sc[1] = lv_cmake(0, 0); d_correlator_outs_16sc[2] = lv_cmake(0, 0); - for (int n = 0; n < d_extend_correlation_ms; n++) + for (int32_t n = 0; n < d_extend_correlation_ms; n++) { d_correlator_outs_16sc[0] += d_E_history.at(n); d_correlator_outs_16sc[1] += d_P_history.at(n); @@ -685,7 +689,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at double T_chip_seconds = 1.0 / d_code_freq_chips; double T_prn_seconds = T_chip_seconds * GLONASS_L1_CA_CODE_LENGTH_CHIPS; double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - int K_prn_samples = round(T_prn_samples); + int32_t K_prn_samples = round(T_prn_samples); double K_T_prn_error_samples = K_prn_samples - T_prn_samples; d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; @@ -794,7 +798,10 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -809,7 +816,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); // Tracking_timestamp_secs is aligned with the CURRENT PRN start sample (Hybridization OK!) - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -828,7 +835,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at { current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler @@ -837,13 +844,13 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_cmake(0, 0); } current_synchro_data.System = {'R'}; - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; @@ -873,7 +880,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -900,15 +907,15 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at // AUX vars (for debug purposes) tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h index f585cb3e1..a58fee4aa 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h @@ -39,11 +39,11 @@ #ifndef GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H #define GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H +#include "cpu_multicorrelator_16sc.h" #include "glonass_l1_signal_processing.h" #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_FLL_PLL_filter.h" -#include "cpu_multicorrelator_16sc.h" #include #include #include @@ -54,19 +54,18 @@ class glonass_l1_ca_dll_pll_c_aid_tracking_sc; -typedef boost::shared_ptr - glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr; +using glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr = boost::shared_ptr; glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr -glonass_l1_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, +glonass_l1_ca_dll_pll_c_aid_make_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); @@ -78,7 +77,7 @@ class glonass_l1_ca_dll_pll_c_aid_tracking_sc : public gr::block public: ~glonass_l1_ca_dll_pll_c_aid_tracking_sc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -89,41 +88,40 @@ public: private: friend glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr - glonass_l1_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l1_ca_dll_pll_c_aid_make_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); - glonass_l1_ca_dll_pll_c_aid_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l1_ca_dll_pll_c_aid_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; - long d_glonass_freq_ch; + int64_t d_fs_in; + int64_t d_glonass_freq_ch; double d_early_late_spc_chips; - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; lv_16sc_t* d_ca_code_16sc; @@ -131,13 +129,13 @@ private: //gr_complex* d_correlator_outs; lv_16sc_t* d_correlator_outs_16sc; //cpu_multicorrelator multicorrelator_cpu; - cpu_multicorrelator_16sc multicorrelator_cpu_16sc; + Cpu_Multicorrelator_16sc multicorrelator_cpu_16sc; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; double d_rem_code_phase_chips; double d_rem_carrier_phase_rad; - int d_rem_code_phase_integer_samples; + int32_t d_rem_code_phase_integer_samples; // PLL and DLL filter library Tracking_2nd_DLL_filter d_code_loop_filter; @@ -164,7 +162,7 @@ private: double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; double d_preamble_timestamp_s; - int d_extend_correlation_ms; + int32_t d_extend_correlation_ms; bool d_enable_extended_integration; bool d_preamble_synchronized; double d_code_error_filt_chips_s; @@ -177,19 +175,19 @@ private: std::deque d_L_history; //Integration period in samples - int d_correlation_length_samples; + int32_t d_correlation_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -202,7 +200,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc index 1bad82419..e00604c90 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc @@ -37,21 +37,21 @@ */ #include "glonass_l1_ca_dll_pll_tracking_cc.h" -#include "glonass_l1_signal_processing.h" #include "GLONASS_L1_L2_CA.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" +#include "glonass_l1_signal_processing.h" #include "gnss_sdr_flags.h" -#include "control_message_factory.h" -#include -#include +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include +#include #include #include #include +#include #include #include #include +#include #define CN0_ESTIMATION_SAMPLES 10 @@ -59,17 +59,16 @@ using google::LogMessage; glonass_l1_ca_dll_pll_tracking_cc_sptr glonass_l1_ca_dll_pll_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips) { - return glonass_l1_ca_dll_pll_tracking_cc_sptr(new Glonass_L1_Ca_Dll_Pll_Tracking_cc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips)); + return glonass_l1_ca_dll_pll_tracking_cc_sptr(new Glonass_L1_Ca_Dll_Pll_Tracking_cc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, early_late_space_chips)); } @@ -78,15 +77,14 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -98,12 +96,11 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc( // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); - d_current_prn_length_samples = static_cast(d_vector_length); + d_current_prn_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_code_loop_filter.set_DLL_BW(dll_bw_hz); @@ -114,12 +111,12 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc( // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -140,7 +137,7 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc( d_rem_carr_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; + d_sample_counter = 0ULL; //d_sample_counter_seconds = 0; d_acq_sample_stamp = 0; @@ -157,7 +154,7 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc( systemName["R"] = std::string("Glonass"); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -185,9 +182,9 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -220,7 +217,7 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; - d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ1_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ1_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); d_carrier_doppler_phase_step_rad = GLONASS_TWO_PI * (d_carrier_doppler_hz) / static_cast(d_fs_in); @@ -232,8 +229,8 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) glonass_l1_ca_code_gen_complex(d_ca_code, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -282,7 +279,15 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::~Glonass_L1_Ca_Dll_Pll_Tracking_cc() { std::cout << "Writing .mat files ..."; } - Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile(); + try + { + Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; @@ -303,14 +308,14 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::~Glonass_L1_Ca_Dll_Pll_Tracking_cc() } -int Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() +int32_t Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -323,48 +328,48 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -376,7 +381,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -411,8 +416,8 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -510,7 +515,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() } -void Glonass_L1_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) +void Glonass_L1_Ca_Dll_Pll_Tracking_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -521,7 +526,7 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -552,8 +557,8 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut double code_error_filt_chips = 0.0; // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); // PRN start block alignment - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); // PRN start block alignment + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -565,14 +570,14 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; - acq_trk_shif_correction_samples = d_current_prn_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); + acq_trk_shif_correction_samples = d_current_prn_length_samples - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter = d_sample_counter + samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter = d_sample_counter + static_cast(samples_offset); // count for the processed samples d_pull_in = false; // take into account the carrier cycles accumulated in the pull in signal alignment d_acc_carrier_phase_rad -= d_carrier_doppler_phase_step_rad * samples_offset; @@ -662,7 +667,10 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -676,7 +684,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // ########### Output the tracking data to navigation and PVT ########## current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -686,12 +694,12 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); current_synchro_data.System = {'R'}; current_synchro_data.correlation_length_ms = 1; } @@ -725,7 +733,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_rad; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -752,11 +760,11 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // AUX vars (for debug purposes) tmp_float = d_rem_code_phase_samples; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } catch (const std::ifstream::failure &e) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.h index 7a81c64a5..158eaa761 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.h @@ -39,10 +39,10 @@ #ifndef GNSS_SDR_GLONASS_L1_CA_DLL_PLL_TRACKING_CC_H #define GNSS_SDR_GLONASS_L1_CA_DLL_PLL_TRACKING_CC_H +#include "cpu_multicorrelator.h" #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_2nd_PLL_filter.h" -#include "cpu_multicorrelator.h" #include #include #include @@ -50,12 +50,11 @@ class Glonass_L1_Ca_Dll_Pll_Tracking_cc; -typedef boost::shared_ptr - glonass_l1_ca_dll_pll_tracking_cc_sptr; +using glonass_l1_ca_dll_pll_tracking_cc_sptr = boost::shared_ptr; glonass_l1_ca_dll_pll_tracking_cc_sptr -glonass_l1_ca_dll_pll_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, +glonass_l1_ca_dll_pll_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -71,7 +70,7 @@ class Glonass_L1_Ca_Dll_Pll_Tracking_cc : public gr::block public: ~Glonass_L1_Ca_Dll_Pll_Tracking_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -82,16 +81,16 @@ public: private: friend glonass_l1_ca_dll_pll_tracking_cc_sptr - glonass_l1_ca_dll_pll_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l1_ca_dll_pll_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips); - Glonass_L1_Ca_Dll_Pll_Tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + Glonass_L1_Ca_Dll_Pll_Tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -99,15 +98,14 @@ private: float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; - long d_glonass_freq_ch; + int64_t d_fs_in; + int64_t d_glonass_freq_ch; double d_early_late_spc_chips; @@ -124,11 +122,11 @@ private: double d_acq_code_phase_samples; double d_acq_carrier_doppler_hz; // correlator - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; float* d_local_code_shift_chips; gr_complex* d_correlator_outs; - cpu_multicorrelator multicorrelator_cpu; + Cpu_Multicorrelator multicorrelator_cpu; // tracking vars @@ -142,19 +140,19 @@ private: double d_code_phase_samples; //PRN period in samples - int d_current_prn_length_samples; + int32_t d_current_prn_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -167,7 +165,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GLONASS_L1_CA_DLL_PLL_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc index e6c9414b8..ae689ab8a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -1,5 +1,5 @@ /*! - * \file glonass_l2_ca_dll_pll_c_aid_tracking_cc.h + * \file glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc * \brief Implementation of a code DLL + carrier PLL tracking block * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com * @@ -35,23 +35,23 @@ */ #include "glonass_l2_ca_dll_pll_c_aid_tracking_cc.h" -#include "glonass_l2_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" #include "GLONASS_L1_L2_CA.h" +#include "glonass_l2_signal_processing.h" #include "gnss_sdr_flags.h" -#include "control_message_factory.h" -#include +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include +#include #include #include #include #include -#include #include +#include #include #include #include +#include #define CN0_ESTIMATION_SAMPLES 10 @@ -59,20 +59,19 @@ using google::LogMessage; glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr glonass_l2_ca_dll_pll_c_aid_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) { - return glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr(new glonass_l2_ca_dll_pll_c_aid_tracking_cc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + return glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr(new glonass_l2_ca_dll_pll_c_aid_tracking_cc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -81,7 +80,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } @@ -92,7 +91,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pm DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_s = pmt::to_double(std::move(msg)); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -100,16 +99,15 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pm glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) : gr::block("glonass_l2_ca_dll_pll_c_aid_tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { @@ -122,11 +120,10 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; - d_correlation_length_samples = static_cast(d_vector_length); + d_dump_filename = std::move(dump_filename); + d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_pll_bw_hz = pll_bw_hz; @@ -142,12 +139,12 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -168,7 +165,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc d_rem_carrier_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; //(from trk to tlm) + d_sample_counter = 0ULL; //(from trk to tlm) d_acq_sample_stamp = 0; d_enable_tracking = false; d_pull_in = false; @@ -185,7 +182,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc set_relative_rate(1.0 / static_cast(d_vector_length)); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -211,7 +208,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc d_glonass_freq_ch = 0; - //set_min_output_buffer((long int)300); + //set_min_output_buffer((int64_t)300); } @@ -224,9 +221,9 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -259,10 +256,10 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; - // d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + // d_carrier_doppler_hz = d_acq_carrier_doppler_hz + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); // d_carrier_doppler_hz = d_acq_carrier_doppler_hz; // d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); - d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); @@ -274,8 +271,8 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) glonass_l2_ca_code_gen_complex(d_ca_code, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -326,7 +323,15 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::~glonass_l2_ca_dll_pll_c_aid_tracking_c { std::cout << "Writing .mat files ..."; } - glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + try + { + glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; @@ -348,14 +353,14 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::~glonass_l2_ca_dll_pll_c_aid_tracking_c } -int glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() +int32_t glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -368,48 +373,48 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -421,7 +426,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -456,8 +461,8 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -555,7 +560,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() } -void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -566,15 +571,15 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -591,8 +596,8 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); // PRN start block alignment - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); // PRN start block alignment + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -609,14 +614,14 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter += samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter += static_cast(samples_offset); // count for the processed samples d_pull_in = false; d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GLONASS_TWO_PI; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; @@ -642,7 +647,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_P_history.push_back(d_correlator_outs[1]); // save prompt output d_L_history.push_back(d_correlator_outs[2]); // save late output - if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) { d_E_history.pop_front(); d_P_history.pop_front(); @@ -652,7 +657,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -661,7 +666,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_correlator_outs[0] = gr_complex(0.0, 0.0); d_correlator_outs[1] = gr_complex(0.0, 0.0); d_correlator_outs[2] = gr_complex(0.0, 0.0); - for (int n = 0; n < d_extend_correlation_ms; n++) + for (int32_t n = 0; n < d_extend_correlation_ms; n++) { d_correlator_outs[0] += d_E_history.at(n); d_correlator_outs[1] += d_P_history.at(n); @@ -691,7 +696,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at double T_chip_seconds = 1.0 / d_code_freq_chips; double T_prn_seconds = T_chip_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - int K_prn_samples = round(T_prn_samples); + int32_t K_prn_samples = round(T_prn_samples); double K_T_prn_error_samples = K_prn_samples - T_prn_samples; d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; @@ -801,7 +806,10 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -815,7 +823,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at // ########### Output the tracking data to navigation and PVT ########## current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -834,7 +842,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at { current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler @@ -843,13 +851,13 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } current_synchro_data.System = {'R'}; - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } //assign the GNURadio block output data current_synchro_data.fs = d_fs_in; @@ -880,7 +888,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -907,15 +915,15 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at // AUX vars (for debug purposes) tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.h index 0d29e0ffc..44b711243 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.h @@ -44,26 +44,25 @@ #include "cpu_multicorrelator.h" #include #include +#include #include #include -#include #include class glonass_l2_ca_dll_pll_c_aid_tracking_cc; -typedef boost::shared_ptr - glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr; +using glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr = boost::shared_ptr; glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr -glonass_l2_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, +glonass_l2_ca_dll_pll_c_aid_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); @@ -75,7 +74,7 @@ class glonass_l2_ca_dll_pll_c_aid_tracking_cc : public gr::block public: ~glonass_l2_ca_dll_pll_c_aid_tracking_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -86,52 +85,51 @@ public: private: friend glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr - glonass_l2_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l2_ca_dll_pll_c_aid_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); - glonass_l2_ca_dll_pll_c_aid_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l2_ca_dll_pll_c_aid_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; + int64_t d_fs_in; double d_glonass_freq_ch; double d_early_late_spc_chips; - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; float* d_local_code_shift_chips; gr_complex* d_correlator_outs; - cpu_multicorrelator multicorrelator_cpu; + Cpu_Multicorrelator multicorrelator_cpu; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; double d_rem_code_phase_chips; double d_rem_carrier_phase_rad; - int d_rem_code_phase_integer_samples; + int32_t d_rem_code_phase_integer_samples; // PLL and DLL filter library //Tracking_2nd_DLL_filter d_code_loop_filter; @@ -166,25 +164,25 @@ private: std::deque d_P_history; std::deque d_L_history; double d_preamble_timestamp_s; - int d_extend_correlation_ms; + int32_t d_extend_correlation_ms; bool d_enable_extended_integration; bool d_preamble_synchronized; void msg_handler_preamble_index(pmt::pmt_t msg); //Integration period in samples - int d_correlation_length_samples; + int32_t d_correlation_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -197,7 +195,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index c809a1038..aebdf3db7 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -35,23 +35,22 @@ */ #include "glonass_l2_ca_dll_pll_c_aid_tracking_sc.h" -#include "gnss_synchro.h" -#include "glonass_l2_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" #include "GLONASS_L1_L2_CA.h" +#include "glonass_l2_signal_processing.h" #include "gnss_sdr_flags.h" -#include "control_message_factory.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include -#include +#include #include #include #include -#include #include +#include #include #include #include +#include #define CN0_ESTIMATION_SAMPLES 10 @@ -59,20 +58,19 @@ using google::LogMessage; glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr glonass_l2_ca_dll_pll_c_aid_make_tracking_sc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) { - return glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr(new glonass_l2_ca_dll_pll_c_aid_tracking_sc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + return glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr(new glonass_l2_ca_dll_pll_c_aid_tracking_sc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -81,7 +79,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } @@ -92,23 +90,23 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(pmt::pm DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_s = pmt::to_double(std::move(msg)); d_enable_extended_integration = true; d_preamble_synchronized = false; } } + glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) : gr::block("glonass_l1_ca_dll_pll_c_aid_tracking_sc", gr::io_signature::make(1, 1, sizeof(lv_16sc_t)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { @@ -119,11 +117,10 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; - d_correlation_length_samples = static_cast(d_vector_length); + d_dump_filename = std::move(dump_filename); + d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_pll_bw_hz = pll_bw_hz; @@ -139,14 +136,14 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - d_ca_code_16sc = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code_16sc = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs_16sc = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_cmake(0, 0); } @@ -168,7 +165,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc d_rem_carrier_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; //(from trk to tlm) + d_sample_counter = 0ULL; //(from trk to tlm) d_acq_sample_stamp = 0; d_enable_tracking = false; d_pull_in = false; @@ -185,7 +182,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc set_relative_rate(1.0 / static_cast(d_vector_length)); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -209,7 +206,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc d_carrier_doppler_old_hz = 0.0; d_glonass_freq_ch = 0; - //set_min_output_buffer((long int)300); + //set_min_output_buffer((int64_t)300); } @@ -222,9 +219,9 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -257,7 +254,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; - d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); ; d_carrier_doppler_hz = d_acq_carrier_doppler_hz; @@ -269,10 +266,10 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) glonass_l2_ca_code_gen_complex(d_ca_code, 0); - volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS)); - multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_16sc_t(0, 0); } @@ -304,14 +301,14 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() } -int glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile() +int32_t glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -324,48 +321,48 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -377,7 +374,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -412,8 +409,8 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -531,7 +528,15 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::~glonass_l2_ca_dll_pll_c_aid_tracking_s { std::cout << "Writing .mat files ..."; } - glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + try + { + glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; @@ -548,7 +553,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::~glonass_l2_ca_dll_pll_c_aid_tracking_s } -void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -559,15 +564,15 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -584,8 +589,8 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // Block input data and block output stream pointers - const lv_16sc_t *in = reinterpret_cast(input_items[0]); // PRN start block alignment - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); // PRN start block alignment + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -602,14 +607,14 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter += samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter += static_cast(samples_offset); // count for the processed samples d_pull_in = false; d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GLONASS_TWO_PI; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; @@ -635,7 +640,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output d_L_history.push_back(d_correlator_outs_16sc[2]); // save late output - if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) { d_E_history.pop_front(); d_P_history.pop_front(); @@ -645,7 +650,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -654,7 +659,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_correlator_outs_16sc[0] = lv_cmake(0, 0); d_correlator_outs_16sc[1] = lv_cmake(0, 0); d_correlator_outs_16sc[2] = lv_cmake(0, 0); - for (int n = 0; n < d_extend_correlation_ms; n++) + for (int32_t n = 0; n < d_extend_correlation_ms; n++) { d_correlator_outs_16sc[0] += d_E_history.at(n); d_correlator_outs_16sc[1] += d_P_history.at(n); @@ -683,7 +688,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at double T_chip_seconds = 1.0 / d_code_freq_chips; double T_prn_seconds = T_chip_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - int K_prn_samples = round(T_prn_samples); + int32_t K_prn_samples = round(T_prn_samples); double K_T_prn_error_samples = K_prn_samples - T_prn_samples; d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; @@ -792,7 +797,10 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -807,7 +815,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); // Tracking_timestamp_secs is aligned with the CURRENT PRN start sample (Hybridization OK!) - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -826,7 +834,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at { current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler @@ -835,13 +843,13 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_cmake(0, 0); } current_synchro_data.System = {'R'}; - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; @@ -871,7 +879,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -898,15 +906,15 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at // AUX vars (for debug purposes) tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h index 17f875cf4..d451da17b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h @@ -37,11 +37,11 @@ #ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_SC_H #define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_SC_H +#include "cpu_multicorrelator_16sc.h" #include "glonass_l2_signal_processing.h" #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_FLL_PLL_filter.h" -#include "cpu_multicorrelator_16sc.h" #include #include #include @@ -52,19 +52,18 @@ class glonass_l2_ca_dll_pll_c_aid_tracking_sc; -typedef boost::shared_ptr - glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr; +using glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr = boost::shared_ptr; glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr -glonass_l2_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, +glonass_l2_ca_dll_pll_c_aid_make_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); @@ -76,7 +75,7 @@ class glonass_l2_ca_dll_pll_c_aid_tracking_sc : public gr::block public: ~glonass_l2_ca_dll_pll_c_aid_tracking_sc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -87,41 +86,40 @@ public: private: friend glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr - glonass_l2_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l2_ca_dll_pll_c_aid_make_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); - glonass_l2_ca_dll_pll_c_aid_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l2_ca_dll_pll_c_aid_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; - long d_glonass_freq_ch; + int64_t d_fs_in; + int64_t d_glonass_freq_ch; double d_early_late_spc_chips; - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; lv_16sc_t* d_ca_code_16sc; @@ -129,13 +127,13 @@ private: //gr_complex* d_correlator_outs; lv_16sc_t* d_correlator_outs_16sc; //cpu_multicorrelator multicorrelator_cpu; - cpu_multicorrelator_16sc multicorrelator_cpu_16sc; + Cpu_Multicorrelator_16sc multicorrelator_cpu_16sc; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; double d_rem_code_phase_chips; double d_rem_carrier_phase_rad; - int d_rem_code_phase_integer_samples; + int32_t d_rem_code_phase_integer_samples; // PLL and DLL filter library Tracking_2nd_DLL_filter d_code_loop_filter; @@ -162,7 +160,7 @@ private: double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; double d_preamble_timestamp_s; - int d_extend_correlation_ms; + int32_t d_extend_correlation_ms; bool d_enable_extended_integration; bool d_preamble_synchronized; double d_code_error_filt_chips_s; @@ -175,19 +173,19 @@ private: std::deque d_L_history; //Integration period in samples - int d_correlation_length_samples; + int32_t d_correlation_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -200,7 +198,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_SC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc index 4fb82650d..b161483c5 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc @@ -37,21 +37,21 @@ */ #include "glonass_l2_ca_dll_pll_tracking_cc.h" -#include "glonass_l2_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" #include "GLONASS_L1_L2_CA.h" +#include "glonass_l2_signal_processing.h" #include "gnss_sdr_flags.h" -#include "control_message_factory.h" -#include -#include +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include +#include #include #include #include +#include #include #include #include +#include #define CN0_ESTIMATION_SAMPLES 10 @@ -59,17 +59,16 @@ using google::LogMessage; glonass_l2_ca_dll_pll_tracking_cc_sptr glonass_l2_ca_dll_pll_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips) { - return glonass_l2_ca_dll_pll_tracking_cc_sptr(new Glonass_L2_Ca_Dll_Pll_Tracking_cc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips)); + return glonass_l2_ca_dll_pll_tracking_cc_sptr(new Glonass_L2_Ca_Dll_Pll_Tracking_cc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, early_late_space_chips)); } @@ -78,15 +77,14 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -98,12 +96,11 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; + d_dump_filename = std::move(dump_filename); - d_current_prn_length_samples = static_cast(d_vector_length); + d_current_prn_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_code_loop_filter.set_DLL_BW(dll_bw_hz); @@ -114,12 +111,12 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -140,7 +137,7 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( d_rem_carr_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; + d_sample_counter = 0ULL; //d_sample_counter_seconds = 0; d_acq_sample_stamp = 0; @@ -157,7 +154,7 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( systemName["R"] = std::string("Glonass"); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -185,9 +182,9 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -220,7 +217,7 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; - d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); d_carrier_doppler_phase_step_rad = GLONASS_TWO_PI * (d_carrier_doppler_hz) / static_cast(d_fs_in); @@ -232,8 +229,8 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) glonass_l2_ca_code_gen_complex(d_ca_code, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -282,7 +279,15 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::~Glonass_L2_Ca_Dll_Pll_Tracking_cc() { std::cout << "Writing .mat files ..."; } - Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile(); + try + { + Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; @@ -303,14 +308,14 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::~Glonass_L2_Ca_Dll_Pll_Tracking_cc() } -int Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() +int32_t Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -323,48 +328,48 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -376,7 +381,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -411,8 +416,8 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -510,7 +515,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() } -void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) +void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -521,7 +526,7 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -552,8 +557,8 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut double code_error_filt_chips = 0.0; // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); // PRN start block alignment - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); // PRN start block alignment + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -565,14 +570,14 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; - acq_trk_shif_correction_samples = d_current_prn_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); + acq_trk_shif_correction_samples = d_current_prn_length_samples - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter = d_sample_counter + samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter = d_sample_counter + static_cast(samples_offset); // count for the processed samples d_pull_in = false; // take into account the carrier cycles accumulated in the pull in signal alignment d_acc_carrier_phase_rad -= d_carrier_doppler_phase_step_rad * samples_offset; @@ -662,7 +667,10 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -676,7 +684,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // ########### Output the tracking data to navigation and PVT ########## current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -686,12 +694,12 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); current_synchro_data.System = {'R'}; current_synchro_data.correlation_length_ms = 1; } @@ -725,7 +733,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_rad; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -752,11 +760,11 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // AUX vars (for debug purposes) tmp_float = d_rem_code_phase_samples; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } catch (const std::ifstream::failure &e) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.h index cac8625d5..d72137d29 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.h @@ -37,10 +37,10 @@ #ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_CC_H #define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_CC_H +#include "cpu_multicorrelator.h" #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_2nd_PLL_filter.h" -#include "cpu_multicorrelator.h" #include #include #include @@ -48,12 +48,11 @@ class Glonass_L2_Ca_Dll_Pll_Tracking_cc; -typedef boost::shared_ptr - glonass_l2_ca_dll_pll_tracking_cc_sptr; +using glonass_l2_ca_dll_pll_tracking_cc_sptr = boost::shared_ptr; glonass_l2_ca_dll_pll_tracking_cc_sptr -glonass_l2_ca_dll_pll_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, +glonass_l2_ca_dll_pll_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -69,7 +68,7 @@ class Glonass_L2_Ca_Dll_Pll_Tracking_cc : public gr::block public: ~Glonass_L2_Ca_Dll_Pll_Tracking_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -80,16 +79,16 @@ public: private: friend glonass_l2_ca_dll_pll_tracking_cc_sptr - glonass_l2_ca_dll_pll_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + glonass_l2_ca_dll_pll_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips); - Glonass_L2_Ca_Dll_Pll_Tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + Glonass_L2_Ca_Dll_Pll_Tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -97,15 +96,14 @@ private: float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; - long d_glonass_freq_ch; + int64_t d_fs_in; + int64_t d_glonass_freq_ch; double d_early_late_spc_chips; @@ -122,11 +120,11 @@ private: double d_acq_code_phase_samples; double d_acq_carrier_doppler_hz; // correlator - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; float* d_local_code_shift_chips; gr_complex* d_correlator_outs; - cpu_multicorrelator multicorrelator_cpu; + Cpu_Multicorrelator multicorrelator_cpu; // tracking vars @@ -140,19 +138,19 @@ private: double d_code_phase_samples; //PRN period in samples - int d_current_prn_length_samples; + int32_t d_current_prn_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -165,7 +163,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc index f38ea3ccf..45a890cbe 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -29,42 +29,41 @@ */ #include "gps_l1_ca_dll_pll_c_aid_tracking_cc.h" -#include "gps_sdr_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" -#include "gnss_sdr_flags.h" #include "GPS_L1_CA.h" -#include "control_message_factory.h" -#include +#include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include +#include #include #include #include -#include #include +#include #include #include #include +#include using google::LogMessage; gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr gps_l1_ca_dll_pll_c_aid_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) { - return gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr(new gps_l1_ca_dll_pll_c_aid_tracking_cc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + return gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr(new gps_l1_ca_dll_pll_c_aid_tracking_cc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -73,7 +72,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } @@ -84,7 +83,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pmt_t DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_s = pmt::to_double(std::move(msg)); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -92,16 +91,15 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pmt_t gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) : gr::block("gps_l1_ca_dll_pll_c_aid_tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { @@ -114,11 +112,10 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; - d_correlation_length_samples = static_cast(d_vector_length); + d_dump_filename = std::move(dump_filename); + d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_pll_bw_hz = pll_bw_hz; @@ -134,12 +131,12 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -160,7 +157,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( d_rem_carrier_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; //(from trk to tlm) + d_sample_counter = 0ULL; //(from trk to tlm) d_acq_sample_stamp = 0; d_enable_tracking = false; d_pull_in = false; @@ -178,7 +175,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( set_relative_rate(1.0 / static_cast(d_vector_length)); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -198,7 +195,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( d_code_error_filt_chips_s = 0.0; d_carr_phase_error_secs_Ti = 0.0; d_preamble_timestamp_s = 0.0; - //set_min_output_buffer((long int)300); + //set_min_output_buffer((int64_t)300); } @@ -211,9 +208,9 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -256,8 +253,8 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -308,7 +305,15 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc() { std::cout << "Writing .mat files ..."; } - gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + try + { + gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; @@ -330,14 +335,14 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc() } -int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() +int32_t gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -350,48 +355,48 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -403,7 +408,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -438,8 +443,8 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -537,7 +542,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() } -void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) +void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -548,15 +553,15 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -573,8 +578,8 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -591,14 +596,14 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter += samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter += static_cast(samples_offset); // count for the processed samples d_pull_in = false; d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GPS_TWO_PI; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GPS_TWO_PI; @@ -624,7 +629,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib d_P_history.push_back(d_correlator_outs[1]); // save prompt output d_L_history.push_back(d_correlator_outs[2]); // save late output - if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) { d_E_history.pop_front(); d_P_history.pop_front(); @@ -634,7 +639,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib bool enable_dll_pll; if (d_enable_extended_integration == true) { - long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -643,7 +648,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib d_correlator_outs[0] = gr_complex(0.0, 0.0); d_correlator_outs[1] = gr_complex(0.0, 0.0); d_correlator_outs[2] = gr_complex(0.0, 0.0); - for (int n = 0; n < d_extend_correlation_ms; n++) + for (int32_t n = 0; n < d_extend_correlation_ms; n++) { d_correlator_outs[0] += d_E_history.at(n); d_correlator_outs[1] += d_P_history.at(n); @@ -673,7 +678,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib double T_chip_seconds = 1.0 / d_code_freq_chips; double T_prn_seconds = T_chip_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - int K_prn_samples = round(T_prn_samples); + int32_t K_prn_samples = round(T_prn_samples); double K_T_prn_error_samples = K_prn_samples - T_prn_samples; d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; @@ -782,7 +787,10 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -796,7 +804,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib // ########### Output the tracking data to navigation and PVT ########## current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GPS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -815,7 +823,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib { current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GPS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler @@ -824,13 +832,13 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } current_synchro_data.System = {'G'}; - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } //assign the GNURadio block output data current_synchro_data.fs = d_fs_in; @@ -861,7 +869,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_cycles * GPS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -888,15 +896,15 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib // AUX vars (for debug purposes) tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } @@ -907,8 +915,6 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib { return 1; } - else - { - return 0; - } + + return 0; } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h index 40b7c60c8..dc9283932 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h @@ -44,26 +44,25 @@ #include "cpu_multicorrelator.h" #include #include +#include #include #include -#include #include class gps_l1_ca_dll_pll_c_aid_tracking_cc; -typedef boost::shared_ptr - gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr; +using gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr = boost::shared_ptr; gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr -gps_l1_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, +gps_l1_ca_dll_pll_c_aid_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); @@ -75,7 +74,7 @@ class gps_l1_ca_dll_pll_c_aid_tracking_cc : public gr::block public: ~gps_l1_ca_dll_pll_c_aid_tracking_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -86,50 +85,49 @@ public: private: friend gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr - gps_l1_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + gps_l1_ca_dll_pll_c_aid_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); - gps_l1_ca_dll_pll_c_aid_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + gps_l1_ca_dll_pll_c_aid_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; - long d_if_freq; - long d_fs_in; + uint32_t d_channel; + int64_t d_fs_in; double d_early_late_spc_chips; - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; float* d_local_code_shift_chips; gr_complex* d_correlator_outs; - cpu_multicorrelator multicorrelator_cpu; + Cpu_Multicorrelator multicorrelator_cpu; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; double d_rem_code_phase_chips; double d_rem_carrier_phase_rad; - int d_rem_code_phase_integer_samples; + int32_t d_rem_code_phase_integer_samples; // PLL and DLL filter library //Tracking_2nd_DLL_filter d_code_loop_filter; @@ -162,25 +160,25 @@ private: std::deque d_P_history; std::deque d_L_history; double d_preamble_timestamp_s; - int d_extend_correlation_ms; + int32_t d_extend_correlation_ms; bool d_enable_extended_integration; bool d_preamble_synchronized; void msg_handler_preamble_index(pmt::pmt_t msg); //Integration period in samples - int d_correlation_length_samples; + int32_t d_correlation_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -193,7 +191,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc index 8c942aaeb..8a3dd9a7d 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -29,43 +29,41 @@ */ #include "gps_l1_ca_dll_pll_c_aid_tracking_sc.h" -#include "gnss_synchro.h" -#include "gps_sdr_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" #include "GPS_L1_CA.h" #include "gnss_sdr_flags.h" -#include "control_message_factory.h" +#include "gps_sdr_signal_processing.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include -#include -#include -#include #include +#include #include +#include #include +#include #include #include #include +#include using google::LogMessage; gps_l1_ca_dll_pll_c_aid_tracking_sc_sptr gps_l1_ca_dll_pll_c_aid_make_tracking_sc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) { - return gps_l1_ca_dll_pll_c_aid_tracking_sc_sptr(new gps_l1_ca_dll_pll_c_aid_tracking_sc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + return gps_l1_ca_dll_pll_c_aid_tracking_sc_sptr(new gps_l1_ca_dll_pll_c_aid_tracking_sc( + fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -74,7 +72,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } @@ -85,23 +83,22 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(pmt::pmt_t DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_s = pmt::to_double(std::move(msg)); d_enable_extended_integration = true; d_preamble_synchronized = false; } } gps_l1_ca_dll_pll_c_aid_tracking_sc::gps_l1_ca_dll_pll_c_aid_tracking_sc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips) : gr::block("gps_l1_ca_dll_pll_c_aid_tracking_sc", gr::io_signature::make(1, 1, sizeof(lv_16sc_t)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { @@ -112,11 +109,10 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::gps_l1_ca_dll_pll_c_aid_tracking_sc( this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = dump_filename; - d_correlation_length_samples = static_cast(d_vector_length); + d_dump_filename = std::move(dump_filename); + d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_pll_bw_hz = pll_bw_hz; @@ -132,14 +128,14 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::gps_l1_ca_dll_pll_c_aid_tracking_sc( // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - d_ca_code_16sc = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code_16sc = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late d_correlator_outs_16sc = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_cmake(0, 0); } @@ -161,7 +157,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::gps_l1_ca_dll_pll_c_aid_tracking_sc( d_rem_carrier_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; //(from trk to tlm) + d_sample_counter = 0ULL; //(from trk to tlm) d_acq_sample_stamp = 0; d_enable_tracking = false; d_pull_in = false; @@ -179,7 +175,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::gps_l1_ca_dll_pll_c_aid_tracking_sc( set_relative_rate(1.0 / static_cast(d_vector_length)); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; @@ -198,7 +194,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::gps_l1_ca_dll_pll_c_aid_tracking_sc( d_code_error_filt_chips_Ti = 0.0; d_preamble_timestamp_s = 0.0; d_carr_phase_error_secs_Ti = 0.0; - //set_min_output_buffer((long int)300); + //set_min_output_buffer((int64_t)300); } @@ -211,9 +207,9 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect @@ -255,10 +251,10 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0); - volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS)); + volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS)); - multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_16sc_t(0, 0); } @@ -310,7 +306,15 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::~gps_l1_ca_dll_pll_c_aid_tracking_sc() { std::cout << "Writing .mat files ..."; } - gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + try + { + gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; @@ -333,14 +337,14 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::~gps_l1_ca_dll_pll_c_aid_tracking_sc() } -int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() +int32_t gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); + int32_t number_of_double_vars = 11; + int32_t number_of_float_vars = 5; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -353,48 +357,48 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() return 1; } // count number of epochs and rewind - long int num_epoch = 0; + int64_t num_epoch = 0; if (dump_file.is_open()) { size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } else { return 1; } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new double[num_epoch]; + auto *carrier_doppler_hz = new double[num_epoch]; + auto *code_freq_chips = new double[num_epoch]; + auto *carr_error_hz = new double[num_epoch]; + auto *carr_error_filt_hz = new double[num_epoch]; + auto *code_error_chips = new double[num_epoch]; + auto *code_error_filt_chips = new double[num_epoch]; + auto *CN0_SNV_dB_Hz = new double[num_epoch]; + auto *carrier_lock_test = new double[num_epoch]; + auto *aux1 = new double[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; try { if (dump_file.is_open()) { - for (long int i = 0; i < num_epoch; i++) + for (int64_t i = 0; i < num_epoch; i++) { dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); @@ -406,7 +410,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); } } dump_file.close(); @@ -441,8 +445,8 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() std::string filename = d_dump_filename; filename.erase(filename.length() - 4, 4); filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); @@ -540,7 +544,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() } -void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) +void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -551,15 +555,15 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what(); + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -576,8 +580,8 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // Block input data and block output stream pointers - const lv_16sc_t *in = reinterpret_cast(input_items[0]); //PRN start block alignment - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); //PRN start block alignment + auto **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -594,14 +598,14 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; - d_sample_counter += samples_offset; // count for the processed samples + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); + d_sample_counter += static_cast(samples_offset); // count for the processed samples d_pull_in = false; d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GPS_TWO_PI; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GPS_TWO_PI; @@ -627,7 +631,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output d_L_history.push_back(d_correlator_outs_16sc[2]); // save late output - if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) { d_E_history.pop_front(); d_P_history.pop_front(); @@ -637,7 +641,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib bool enable_dll_pll; if (d_enable_extended_integration == true) { - long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -646,7 +650,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib d_correlator_outs_16sc[0] = lv_cmake(0, 0); d_correlator_outs_16sc[1] = lv_cmake(0, 0); d_correlator_outs_16sc[2] = lv_cmake(0, 0); - for (int n = 0; n < d_extend_correlation_ms; n++) + for (int32_t n = 0; n < d_extend_correlation_ms; n++) { d_correlator_outs_16sc[0] += d_E_history.at(n); d_correlator_outs_16sc[1] += d_P_history.at(n); @@ -675,7 +679,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib double T_chip_seconds = 1.0 / d_code_freq_chips; double T_prn_seconds = T_chip_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - int K_prn_samples = round(T_prn_samples); + int32_t K_prn_samples = round(T_prn_samples); double K_T_prn_error_samples = K_prn_samples - T_prn_samples; d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; @@ -784,7 +788,10 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -799,7 +806,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); // Tracking_timestamp_secs is aligned with the CURRENT PRN start sample (Hybridization OK!) - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GPS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -818,7 +825,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib { current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GPS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler @@ -827,13 +834,13 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs_16sc[n] = lv_cmake(0, 0); } current_synchro_data.System = {'G'}; - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; @@ -863,7 +870,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_cycles * GPS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -890,15 +897,15 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib // AUX vars (for debug purposes) tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } @@ -909,8 +916,6 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib { return 1; } - else - { - return 0; - } + + return 0; } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h index 3ae42edab..9aec25252 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h @@ -37,11 +37,11 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H #define GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H -#include "gps_sdr_signal_processing.h" +#include "cpu_multicorrelator_16sc.h" #include "gnss_synchro.h" +#include "gps_sdr_signal_processing.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_FLL_PLL_filter.h" -#include "cpu_multicorrelator_16sc.h" #include #include #include @@ -52,19 +52,18 @@ class gps_l1_ca_dll_pll_c_aid_tracking_sc; -typedef boost::shared_ptr - gps_l1_ca_dll_pll_c_aid_tracking_sc_sptr; +using gps_l1_ca_dll_pll_c_aid_tracking_sc_sptr = boost::shared_ptr; gps_l1_ca_dll_pll_c_aid_tracking_sc_sptr -gps_l1_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, +gps_l1_ca_dll_pll_c_aid_make_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); @@ -76,7 +75,7 @@ class gps_l1_ca_dll_pll_c_aid_tracking_sc : public gr::block public: ~gps_l1_ca_dll_pll_c_aid_tracking_sc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); void start_tracking(); @@ -87,40 +86,39 @@ public: private: friend gps_l1_ca_dll_pll_c_aid_tracking_sc_sptr - gps_l1_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, + gps_l1_ca_dll_pll_c_aid_make_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); - gps_l1_ca_dll_pll_c_aid_tracking_sc(long if_freq, - long fs_in, unsigned int vector_length, + gps_l1_ca_dll_pll_c_aid_tracking_sc( + int64_t fs_in, uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, float dll_bw_narrow_hz, - int extend_correlation_ms, + int32_t extend_correlation_ms, float early_late_space_chips); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro* d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; + int64_t d_fs_in; double d_early_late_spc_chips; - int d_n_correlator_taps; + int32_t d_n_correlator_taps; gr_complex* d_ca_code; lv_16sc_t* d_ca_code_16sc; @@ -128,13 +126,13 @@ private: //gr_complex* d_correlator_outs; lv_16sc_t* d_correlator_outs_16sc; //cpu_multicorrelator multicorrelator_cpu; - cpu_multicorrelator_16sc multicorrelator_cpu_16sc; + Cpu_Multicorrelator_16sc multicorrelator_cpu_16sc; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; double d_rem_code_phase_chips; double d_rem_carrier_phase_rad; - int d_rem_code_phase_integer_samples; + int32_t d_rem_code_phase_integer_samples; // PLL and DLL filter library Tracking_2nd_DLL_filter d_code_loop_filter; @@ -159,7 +157,7 @@ private: double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; double d_preamble_timestamp_s; - int d_extend_correlation_ms; + int32_t d_extend_correlation_ms; bool d_enable_extended_integration; bool d_preamble_synchronized; double d_code_error_filt_chips_s; @@ -172,19 +170,19 @@ private: std::deque d_L_history; //Integration period in samples - int d_correlation_length_samples; + int32_t d_correlation_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex* d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; @@ -197,7 +195,7 @@ private: std::map systemName; std::string sys; - int save_matfile(); + int32_t save_matfile(); }; #endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc index dc9d69948..6fb8197d1 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc @@ -29,17 +29,16 @@ */ #include "gps_l1_ca_dll_pll_tracking_gpu_cc.h" -#include "gps_sdr_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" #include "GPS_L1_CA.h" -#include "control_message_factory.h" #include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include -#include -#include #include +#include #include +#include #include #include #include @@ -49,16 +48,15 @@ using google::LogMessage; gps_l1_ca_dll_pll_tracking_gpu_cc_sptr gps_l1_ca_dll_pll_make_tracking_gpu_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips) { - return gps_l1_ca_dll_pll_tracking_gpu_cc_sptr(new Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc(if_freq, + return gps_l1_ca_dll_pll_tracking_gpu_cc_sptr(new Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc( fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips)); } @@ -68,15 +66,14 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -89,11 +86,10 @@ Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc( this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; d_dump_filename = dump_filename; - d_correlation_length_samples = static_cast(d_vector_length); + d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== d_code_loop_filter.set_DLL_BW(dll_bw_hz); @@ -108,7 +104,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc( //pinned memory mode - use special function to get OS-pinned memory d_n_correlator_taps = 3; // Early, Prompt, and Late // Get space for a vector with the C/A code replica sampled 1x/chip - cudaHostAlloc((void **)&d_ca_code, (static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex)), cudaHostAllocMapped || cudaHostAllocWriteCombined); + cudaHostAlloc((void **)&d_ca_code, (static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex)), cudaHostAllocMapped || cudaHostAllocWriteCombined); // Get space for the resampled early / prompt / late local replicas cudaHostAlloc((void **)&d_local_code_shift_chips, d_n_correlator_taps * sizeof(float), cudaHostAllocMapped || cudaHostAllocWriteCombined); cudaHostAlloc((void **)&in_gpu, 2 * d_vector_length * sizeof(gr_complex), cudaHostAllocMapped || cudaHostAllocWriteCombined); @@ -134,7 +130,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc( d_rem_carrier_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; + d_sample_counter = 0ULL; //d_sample_counter_seconds = 0; d_acq_sample_stamp = 0; @@ -166,7 +162,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc( d_rem_code_phase_chips = 0.0; d_code_phase_step_chips = 0.0; d_carrier_phase_step_rad = 0.0; - //set_min_output_buffer((long int)300); + //set_min_output_buffer((int64_t)300); } @@ -179,9 +175,9 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); //doppler effect @@ -224,9 +220,9 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0); - multicorrelator_gpu->set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips, d_n_correlator_taps); + multicorrelator_gpu->set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips, d_n_correlator_taps); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -286,7 +282,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::~Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc() } -void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_channel(unsigned int channel) +void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -344,17 +340,17 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut // Receiver signal alignment if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); current_synchro_data.fs = d_fs_in; current_synchro_data.correlation_length_ms = 1; *out[0] = current_synchro_data; - d_sample_counter += samples_offset; //count for the processed samples + d_sample_counter += static_cast(samples_offset); //count for the processed samples d_pull_in = false; consume_each(samples_offset); //shift input to perform alignment with local replica return 1; @@ -469,7 +465,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut // ########### Output the tracking data to navigation and PVT ########## current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = GPS_TWO_PI * d_acc_carrier_phase_cycles; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -479,14 +475,14 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut } else { - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } current_synchro_data.System = {'G'}; current_synchro_data.correlation_length_ms = 1; - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } //assign the GNURadio block output data @@ -519,7 +515,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_cycles * GPS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -549,8 +545,8 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } catch (const std::ifstream::failure *e) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.h index 96ecc6c58..987af5686 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.h @@ -52,9 +52,9 @@ typedef boost::shared_ptr gps_l1_ca_dll_pll_tracking_gpu_cc_sptr; gps_l1_ca_dll_pll_tracking_gpu_cc_sptr -gps_l1_ca_dll_pll_make_tracking_gpu_cc(long if_freq, - long fs_in, - unsigned int vector_length, +gps_l1_ca_dll_pll_make_tracking_gpu_cc( + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -70,7 +70,7 @@ class Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc : public gr::block public: ~Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); void start_tracking(); @@ -81,18 +81,18 @@ public: private: friend gps_l1_ca_dll_pll_tracking_gpu_cc_sptr - gps_l1_ca_dll_pll_make_tracking_gpu_cc(long if_freq, - long fs_in, - unsigned int vector_length, + gps_l1_ca_dll_pll_make_tracking_gpu_cc( + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, float dll_bw_hz, float early_late_space_chips); - Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc(long if_freq, - long fs_in, - unsigned int vector_length, + Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc( + int64_t fs_in, + uint32_t vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -102,18 +102,17 @@ private: void update_local_carrier(); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro *d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; + int64_t d_if_freq; + int64_t d_fs_in; double d_early_late_spc_chips; - int d_n_correlator_taps; - + int32_t d_n_correlator_taps; //GPU HOST PINNED MEMORY IN/OUT VECTORS gr_complex *in_gpu; @@ -150,19 +149,19 @@ private: double d_pll_to_dll_assist_secs_Ti; //Integration period in samples - int d_correlation_length_samples; + int32_t d_correlation_length_samples; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex *d_Prompt_buffer; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc new file mode 100644 index 000000000..96c478a3f --- /dev/null +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc @@ -0,0 +1,969 @@ +/*! + * \file gps_l1_ca_kf_tracking_cc.cc + * \brief Implementation of a processing block of a DLL + Kalman carrier + * tracking loop for GPS L1 C/A signals + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Jordi Vila-Valls 2018. jvila(at)cttc.es + * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es + * + * Reference: + * J. Vila-Valls, P. Closas, M. Navarro and C. Fernandez-Prades, + * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital + * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, + * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "gps_l1_ca_kf_tracking_cc.h" +#include "GPS_L1_CA.h" +#include "gnss_sdr_flags.h" +#include "gps_sdr_signal_processing.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +using google::LogMessage; + +gps_l1_ca_kf_tracking_cc_sptr +gps_l1_ca_kf_make_tracking_cc( + uint32_t order, + int64_t if_freq, + int64_t fs_in, + uint32_t vector_length, + bool dump, + std::string dump_filename, + float dll_bw_hz, + float early_late_space_chips, + bool bce_run, + uint32_t bce_ptrans, + uint32_t bce_strans, + int32_t bce_nu, + int32_t bce_kappa) +{ + return gps_l1_ca_kf_tracking_cc_sptr(new Gps_L1_Ca_Kf_Tracking_cc(order, if_freq, + fs_in, vector_length, dump, std::move(dump_filename), dll_bw_hz, early_late_space_chips, + bce_run, bce_ptrans, bce_strans, bce_nu, bce_kappa)); +} + + +void Gps_L1_Ca_Kf_Tracking_cc::forecast(int noutput_items, + gr_vector_int &ninput_items_required) +{ + if (noutput_items != 0) + { + ninput_items_required[0] = static_cast(d_vector_length) * 2; // set the required available samples in each call + } +} + + +Gps_L1_Ca_Kf_Tracking_cc::Gps_L1_Ca_Kf_Tracking_cc( + uint32_t order, + int64_t if_freq, + int64_t fs_in, + uint32_t vector_length, + bool dump, + std::string dump_filename, + float dll_bw_hz, + float early_late_space_chips, + bool bce_run, + uint32_t bce_ptrans, + uint32_t bce_strans, + int32_t bce_nu, + int32_t bce_kappa) : gr::block("Gps_L1_Ca_Kf_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Telemetry bit synchronization message port input + this->message_port_register_in(pmt::mp("preamble_timestamp_s")); + this->message_port_register_out(pmt::mp("events")); + + // initialize internal vars + d_order = order; + d_dump = dump; + d_if_freq = if_freq; + d_fs_in = fs_in; + d_vector_length = vector_length; + d_dump_filename = std::move(dump_filename); + + d_current_prn_length_samples = static_cast(d_vector_length); + + // Initialize tracking ========================================== + d_code_loop_filter.set_DLL_BW(dll_bw_hz); + + // --- DLL variables -------------------------------------------------------- + d_early_late_spc_chips = early_late_space_chips; // Define early-late offset (in chips) + + // Initialization of local code replica + // Get space for a vector with the C/A code replica sampled 1x/chip + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment())); + + // correlator outputs (scalar) + d_n_correlator_taps = 3; // Early, Prompt, and Late + d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + for (int32_t n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs[n] = gr_complex(0, 0); + } + d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); + // Set TAPs delay values [chips] + d_local_code_shift_chips[0] = -d_early_late_spc_chips; + d_local_code_shift_chips[1] = 0.0; + d_local_code_shift_chips[2] = d_early_late_spc_chips; + + multicorrelator_cpu.init(2 * d_current_prn_length_samples, d_n_correlator_taps); + + // --- Perform initializations ------------------------------ + // define initial code frequency basis of NCO + d_code_freq_chips = GPS_L1_CA_CODE_RATE_HZ; + // define residual code phase (in chips) + d_rem_code_phase_samples = 0.0; + // define residual carrier phase + d_rem_carr_phase_rad = 0.0; + // define residual carrier phase covariance + d_carr_phase_sigma2 = 0.0; + + // sample synchronization + d_sample_counter = 0; + d_acq_sample_stamp = 0; + + d_enable_tracking = false; + d_pull_in = false; + + // CN0 estimation and lock detector buffers + d_cn0_estimation_counter = 0; + d_Prompt_buffer = new gr_complex[FLAGS_cn0_samples]; + d_carrier_lock_test = 1; + d_CN0_SNV_dB_Hz = 0; + d_carrier_lock_fail_counter = 0; + d_carrier_lock_threshold = FLAGS_carrier_lock_th; + + systemName["G"] = std::string("GPS"); + systemName["S"] = std::string("SBAS"); + + d_acquisition_gnss_synchro = nullptr; + d_channel = 0; + d_acq_code_phase_samples = 0.0; + d_acq_carrier_doppler_hz = 0.0; + d_carrier_doppler_hz = 0.0; + d_carrier_dopplerrate_hz2 = 0.0; + d_acc_carrier_phase_rad = 0.0; + d_code_phase_samples = 0.0; + d_rem_code_phase_chips = 0.0; + d_code_phase_step_chips = 0.0; + d_code_phase_rate_step_chips = 0.0; + d_carrier_phase_step_rad = 0.0; + code_error_chips = 0.0; + code_error_filt_chips = 0.0; + + set_relative_rate(1.0 / static_cast(d_vector_length)); + + // Kalman filter initialization (receiver initialization) + + double CN_dB_Hz = 30; + double CN_lin = pow(10, CN_dB_Hz / 10.0); + + double sigma2_phase_detector_cycles2; + sigma2_phase_detector_cycles2 = (1.0 / (2.0 * CN_lin * GPS_L1_CA_CODE_PERIOD)) * (1.0 + 1.0 / (2.0 * CN_lin * GPS_L1_CA_CODE_PERIOD)); + + // covariances (static) + double sigma2_carrier_phase = GPS_TWO_PI / 4; + double sigma2_doppler = 450; + double sigma2_doppler_rate = pow(4.0 * GPS_TWO_PI, 2) / 12.0; + + kf_P_x_ini = arma::zeros(2, 2); + kf_P_x_ini(0, 0) = sigma2_carrier_phase; + kf_P_x_ini(1, 1) = sigma2_doppler; + + kf_R = arma::zeros(1, 1); + kf_R(0, 0) = sigma2_phase_detector_cycles2; + + kf_Q = arma::zeros(2, 2); + kf_Q(0, 0) = pow(GPS_L1_CA_CODE_PERIOD, 4); + kf_Q(1, 1) = GPS_L1_CA_CODE_PERIOD; + + kf_F = arma::zeros(2, 2); + kf_F(0, 0) = 1.0; + kf_F(0, 1) = GPS_TWO_PI * GPS_L1_CA_CODE_PERIOD; + kf_F(1, 0) = 0.0; + kf_F(1, 1) = 1.0; + + kf_H = arma::zeros(1, 2); + kf_H(0, 0) = 1.0; + + kf_x = arma::zeros(2, 1); + kf_y = arma::zeros(1, 1); + kf_P_y = arma::zeros(1, 1); + + // order three + if (d_order == 3) + { + kf_P_x_ini = arma::resize(kf_P_x_ini, 3, 3); + kf_P_x_ini(2, 2) = sigma2_doppler_rate; + + kf_Q = arma::zeros(3, 3); + kf_Q(0, 0) = pow(GPS_L1_CA_CODE_PERIOD, 4); + kf_Q(1, 1) = GPS_L1_CA_CODE_PERIOD; + kf_Q(2, 2) = GPS_L1_CA_CODE_PERIOD; + + kf_F = arma::resize(kf_F, 3, 3); + kf_F(0, 2) = 0.5 * GPS_TWO_PI * pow(GPS_L1_CA_CODE_PERIOD, 2); + kf_F(1, 2) = GPS_L1_CA_CODE_PERIOD; + kf_F(2, 0) = 0.0; + kf_F(2, 1) = 0.0; + kf_F(2, 2) = 1.0; + + kf_H = arma::resize(kf_H, 1, 3); + kf_H(0, 2) = 0.0; + + kf_x = arma::resize(kf_x, 3, 1); + kf_x(2, 0) = 0.0; + } + + // Bayesian covariance estimator initialization + kf_iter = 0; + bayes_run = bce_run; + bayes_ptrans = bce_ptrans; + bayes_strans = bce_strans; + + bayes_kappa = bce_kappa; + bayes_nu = bce_nu; + kf_R_est = kf_R; + + bayes_estimator.init(arma::zeros(1, 1), bayes_kappa, bayes_nu, (kf_H * kf_P_x_ini * kf_H.t() + kf_R) * (bayes_nu + 2)); +} + +void Gps_L1_Ca_Kf_Tracking_cc::start_tracking() +{ + /* + * correct the code phase according to the delay between acq and trk + */ + d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; + d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; + d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; + d_acq_carrier_doppler_step_hz = static_cast(d_acquisition_gnss_synchro->Acq_doppler_step); + + // Correct Kalman filter covariance according to acq doppler step size (3 sigma) + if (d_acquisition_gnss_synchro->Acq_doppler_step > 0) + { + kf_P_x_ini(1, 1) = pow(d_acq_carrier_doppler_step_hz / 3.0, 2); + bayes_estimator.init(arma::zeros(1, 1), bayes_kappa, bayes_nu, (kf_H * kf_P_x_ini * kf_H.t() + kf_R) * (bayes_nu + 2)); + } + + int64_t acq_trk_diff_samples; + double acq_trk_diff_seconds; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples; + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); + // Doppler effect Fd = (C / (C + Vr)) * F + double radial_velocity = (GPS_L1_FREQ_HZ + d_acq_carrier_doppler_hz) / GPS_L1_FREQ_HZ; + // new chip and prn sequence periods based on acq Doppler + double T_chip_mod_seconds; + double T_prn_mod_seconds; + double T_prn_mod_samples; + d_code_freq_chips = radial_velocity * GPS_L1_CA_CODE_RATE_HZ; + d_code_phase_step_chips = static_cast(d_code_freq_chips) / static_cast(d_fs_in); + T_chip_mod_seconds = 1 / d_code_freq_chips; + T_prn_mod_seconds = T_chip_mod_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; + T_prn_mod_samples = T_prn_mod_seconds * static_cast(d_fs_in); + + d_current_prn_length_samples = round(T_prn_mod_samples); + + double T_prn_true_seconds = GPS_L1_CA_CODE_LENGTH_CHIPS / GPS_L1_CA_CODE_RATE_HZ; + double T_prn_true_samples = T_prn_true_seconds * static_cast(d_fs_in); + double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; + double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; + double corrected_acq_phase_samples, delay_correction_samples; + corrected_acq_phase_samples = fmod((d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * static_cast(d_fs_in)), T_prn_true_samples); + if (corrected_acq_phase_samples < 0) + { + corrected_acq_phase_samples = T_prn_mod_samples + corrected_acq_phase_samples; + } + delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; + + d_acq_code_phase_samples = corrected_acq_phase_samples; + + d_carrier_doppler_hz = d_acq_carrier_doppler_hz; + d_carrier_dopplerrate_hz2 = 0; + d_carrier_phase_step_rad = GPS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); + + // DLL filter initialization + d_code_loop_filter.initialize(); // initialize the code filter + + // generate local reference ALWAYS starting at chip 1 (1 sample per chip) + gps_l1_ca_code_gen_float(d_ca_code, d_acquisition_gnss_synchro->PRN, 0); + + multicorrelator_cpu.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs[n] = gr_complex(0, 0); + } + + d_carrier_lock_fail_counter = 0; + d_rem_code_phase_samples = 0; + d_rem_carr_phase_rad = 0.0; + d_rem_code_phase_chips = 0.0; + d_acc_carrier_phase_rad = 0.0; + d_carr_phase_sigma2 = 0.0; + + d_code_phase_samples = d_acq_code_phase_samples; + + std::string sys_ = &d_acquisition_gnss_synchro->System; + sys = sys_.substr(0, 1); + + // DEBUG OUTPUT + std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + + // enable tracking + d_pull_in = true; + d_enable_tracking = true; + + LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz + << " Code Phase correction [samples]=" << delay_correction_samples + << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; +} + + +Gps_L1_Ca_Kf_Tracking_cc::~Gps_L1_Ca_Kf_Tracking_cc() +{ + if (d_dump_file.is_open()) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } + } + if (d_dump) + { + if (d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + try + { + Gps_L1_Ca_Kf_Tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + + if (d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + try + { + volk_gnsssdr_free(d_local_code_shift_chips); + volk_gnsssdr_free(d_correlator_outs); + volk_gnsssdr_free(d_ca_code); + delete[] d_Prompt_buffer; + multicorrelator_cpu.free(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } +} + + +int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + int32_t number_of_double_vars = 1; + int32_t number_of_float_vars = 19; + int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + int64_t num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + auto *abs_VE = new float[num_epoch]; + auto *abs_E = new float[num_epoch]; + auto *abs_P = new float[num_epoch]; + auto *abs_L = new float[num_epoch]; + auto *abs_VL = new float[num_epoch]; + auto *Prompt_I = new float[num_epoch]; + auto *Prompt_Q = new float[num_epoch]; + auto *PRN_start_sample_count = new uint64_t[num_epoch]; + auto *acc_carrier_phase_rad = new float[num_epoch]; + auto *carrier_doppler_hz = new float[num_epoch]; + auto *carrier_dopplerrate_hz2 = new float[num_epoch]; + auto *code_freq_chips = new float[num_epoch]; + auto *carr_error_hz = new float[num_epoch]; + auto *carr_noise_sigma2 = new float[num_epoch]; + auto *carr_error_filt_hz = new float[num_epoch]; + auto *code_error_chips = new float[num_epoch]; + auto *code_error_filt_chips = new float[num_epoch]; + auto *CN0_SNV_dB_Hz = new float[num_epoch]; + auto *carrier_lock_test = new float[num_epoch]; + auto *aux1 = new float[num_epoch]; + auto *aux2 = new double[num_epoch]; + auto *PRN = new uint32_t[num_epoch]; + + try + { + if (dump_file.is_open()) + { + for (int64_t i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_VE[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_VL[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_dopplerrate_hz2[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carr_noise_sigma2[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(uint32_t)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_VE; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] abs_VL; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] carrier_dopplerrate_hz2; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_noise_sigma2; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_VE, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_VL", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_VL, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_dopplerrate_hz2", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_dopplerrate_hz2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_noise_sigma2", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_noise_sigma2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_VE; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] abs_VL; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] carrier_dopplerrate_hz2; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_noise_sigma2; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + +void Gps_L1_Ca_Kf_Tracking_cc::set_channel(uint32_t channel) +{ + gr::thread::scoped_lock l(d_setlock); + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump) + { + if (!d_dump_file.is_open()) + { + try + { + d_dump_filename.append(std::to_string(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + +void Gps_L1_Ca_Kf_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + +int Gps_L1_Ca_Kf_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + // process vars + d_carr_phase_error_rad = 0.0; + double code_error_chips = 0.0; + double code_error_filt_chips = 0.0; + + // Block input data and block output stream pointers + const auto *in = reinterpret_cast(input_items[0]); + auto **out = reinterpret_cast(&output_items[0]); + + // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder + Gnss_Synchro current_synchro_data = Gnss_Synchro(); + + if (d_enable_tracking == true) + { + // Fill the acquisition data + current_synchro_data = *d_acquisition_gnss_synchro; + // Receiver signal alignment + if (d_pull_in == true) + { + // Signal alignment (skip samples until the incoming signal is aligned with local replica) + uint64_t acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; + double acq_trk_shif_correction_samples = static_cast(d_current_prn_length_samples) - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); + int32_t samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); + if (samples_offset < 0) + { + samples_offset = 0; + } + d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * d_acq_code_phase_samples; + + d_sample_counter += samples_offset; // count for the processed samples + d_pull_in = false; + + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.fs = d_fs_in; + current_synchro_data.correlation_length_ms = 1; + *out[0] = current_synchro_data; + // Kalman filter initialization reset + kf_P_x = kf_P_x_ini; + // Update Kalman states based on acquisition information + kf_x(0) = d_carrier_phase_step_rad * samples_offset; + kf_x(1) = d_carrier_doppler_hz; + if (kf_x.n_elem > 2) + { + kf_x(2) = d_carrier_dopplerrate_hz2; + } + + // Covariance estimation initialization reset + kf_iter = 0; + bayes_estimator.init(arma::zeros(1, 1), bayes_kappa, bayes_nu, (kf_H * kf_P_x_ini * kf_H.t() + kf_R) * (bayes_nu + 2)); + + consume_each(samples_offset); // shift input to perform alignment with local replica + return 1; + } + + // ################# CARRIER WIPEOFF AND CORRELATORS ############################## + // Perform carrier wipe-off and compute Early, Prompt and Late correlation + multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in); + multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(d_rem_carr_phase_rad, + d_carrier_phase_step_rad, + d_rem_code_phase_chips, + d_code_phase_step_chips, + d_code_phase_rate_step_chips, + d_current_prn_length_samples); + + // ################## Kalman Carrier Tracking ###################################### + + // Kalman state prediction (time update) + kf_x_pre = kf_F * kf_x; //state prediction + kf_P_x_pre = kf_F * kf_P_x * kf_F.t() + kf_Q; //state error covariance prediction + + // Update discriminator [rads/Ti] + d_carr_phase_error_rad = pll_cloop_two_quadrant_atan(d_correlator_outs[1]); // prompt output + + // Kalman estimation (measurement update) + double sigma2_phase_detector_cycles2; + double CN_lin = pow(10, d_CN0_SNV_dB_Hz / 10.0); + sigma2_phase_detector_cycles2 = (1.0 / (2.0 * CN_lin * GPS_L1_CA_CODE_PERIOD)) * (1.0 + 1.0 / (2.0 * CN_lin * GPS_L1_CA_CODE_PERIOD)); + + kf_y(0) = d_carr_phase_error_rad; // measurement vector + kf_R(0, 0) = sigma2_phase_detector_cycles2; + + if (bayes_run && (kf_iter >= bayes_ptrans)) + { + bayes_estimator.update_sequential(kf_y); + } + if (bayes_run && (kf_iter >= (bayes_ptrans + bayes_strans))) + { + // TODO: Resolve segmentation fault + kf_P_y = bayes_estimator.get_Psi_est(); + kf_R_est = kf_P_y - kf_H * kf_P_x_pre * kf_H.t(); + } + else + { + kf_P_y = kf_H * kf_P_x_pre * kf_H.t() + kf_R; // innovation covariance matrix + kf_R_est = kf_R; + } + + // Kalman filter update step + kf_K = (kf_P_x_pre * kf_H.t()) * arma::inv(kf_P_y); // Kalman gain + kf_x = kf_x_pre + kf_K * kf_y; // updated state estimation + kf_P_x = (arma::eye(size(kf_P_x_pre)) - kf_K * kf_H) * kf_P_x_pre; // update state estimation error covariance matrix + + // Store Kalman filter results + d_rem_carr_phase_rad = kf_x(0); // set a new carrier Phase estimation to the NCO + d_carrier_doppler_hz = kf_x(1); // set a new carrier Doppler estimation to the NCO + if (kf_x.n_elem > 2) + { + d_carrier_dopplerrate_hz2 = kf_x(2); + } + else + { + d_carrier_dopplerrate_hz2 = 0; + } + d_carr_phase_sigma2 = kf_R_est(0, 0); + + // ################## DLL ########################################################## + // New code Doppler frequency estimation based on carrier frequency estimation + d_code_freq_chips = GPS_L1_CA_CODE_RATE_HZ + ((d_carrier_doppler_hz * GPS_L1_CA_CODE_RATE_HZ) / GPS_L1_FREQ_HZ); + // DLL discriminator + code_error_chips = dll_nc_e_minus_l_normalized(d_correlator_outs[0], d_correlator_outs[2]); // [chips/Ti] early and late + // Code discriminator filter + code_error_filt_chips = d_code_loop_filter.get_code_nco(code_error_chips); // [chips/second] + double T_chip_seconds = 1.0 / static_cast(d_code_freq_chips); + double T_prn_seconds = T_chip_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; + double code_error_filt_secs = (T_prn_seconds * code_error_filt_chips * T_chip_seconds); // [seconds] + + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### + // keep alignment parameters for the next input buffer + // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation + double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); + double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast(d_fs_in); + d_current_prn_length_samples = static_cast(round(K_blk_samples)); // round to a discrete number of samples + + //################### NCO COMMANDS ################################################# + // carrier phase step (NCO phase increment per sample) [rads/sample] + d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / static_cast(d_fs_in); + // carrier phase accumulator + d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + + //################### DLL COMMANDS ################################################# + // code phase step (Code resampler phase increment per sample) [chips/sample] + d_code_phase_step_chips = d_code_freq_chips / static_cast(d_fs_in); + // remnant code phase [chips] + d_rem_code_phase_samples = K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample + d_rem_code_phase_chips = d_code_freq_chips * (d_rem_code_phase_samples / static_cast(d_fs_in)); + + // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### + if (d_cn0_estimation_counter < FLAGS_cn0_samples) + { + // fill buffer with prompt correlator output values + d_Prompt_buffer[d_cn0_estimation_counter] = d_correlator_outs[1]; //prompt + d_cn0_estimation_counter++; + } + else + { + d_cn0_estimation_counter = 0; + // Code lock indicator + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, GPS_L1_CA_CODE_PERIOD); + // Carrier lock indicator + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); + // Loss of lock detection + if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) + { + //if (d_channel == 1) + //std::cout << "Carrier Lock Test Fail in channel " << d_channel << ": " << d_carrier_lock_test << " < " << d_carrier_lock_threshold << "," << nfail++ << std::endl; + d_carrier_lock_fail_counter++; + //nfail++; + } + else + { + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } + } + if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) + { + std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; + LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; + this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock + d_carrier_lock_fail_counter = 0; + d_enable_tracking = false; + } + } + // ########### Output the tracking data to navigation and PVT ########## + current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); + current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + current_synchro_data.Flag_valid_symbol_output = true; + current_synchro_data.correlation_length_ms = 1; + + kf_iter++; + } + else + { + for (int32_t n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs[n] = gr_complex(0, 0); + } + + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); + current_synchro_data.System = {'G'}; + current_synchro_data.correlation_length_ms = 1; + } + + // assign the GNU Radio block output data + current_synchro_data.fs = d_fs_in; + *out[0] = current_synchro_data; + + if (d_dump) + { + // MULTIPLEXED FILE RECORDING - Record results to file + float prompt_I; + float prompt_Q; + float tmp_E, tmp_P, tmp_L; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; + double tmp_double; + prompt_I = d_correlator_outs[1].real(); + prompt_Q = d_correlator_outs[1].imag(); + tmp_E = std::abs(d_correlator_outs[0]); + tmp_P = std::abs(d_correlator_outs[1]); + tmp_L = std::abs(d_correlator_outs[2]); + try + { + // EPR + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); + // PROMPT I and Q (to analyze navigation symbols) + d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); + d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); + // PRN start sample stamp + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); + // accumulated carrier phase + tmp_float = d_acc_carrier_phase_rad; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // carrier and code frequency + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_dopplerrate_hz2; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // Kalman commands + tmp_float = static_cast(d_carr_phase_error_rad * GPS_TWO_PI); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = static_cast(d_carr_phase_sigma2); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = static_cast(d_rem_carr_phase_rad * GPS_TWO_PI); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = code_error_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = code_error_filt_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // CN0 and carrier lock test + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // AUX vars (for debug purposes) + tmp_float = d_rem_code_phase_samples; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_double = static_cast(d_sample_counter + static_cast(d_current_prn_length_samples)); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + // PRN + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing trk dump file " << e.what(); + } + } + + consume_each(d_current_prn_length_samples); // this is necessary in gr::block derivates + d_sample_counter += d_current_prn_length_samples; // count for the processed samples + return 1; // output tracking result ALWAYS even in the case of d_enable_tracking==false +} diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.h new file mode 100644 index 000000000..e2faa339c --- /dev/null +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.h @@ -0,0 +1,221 @@ +/*! + * \file gps_l1_ca_kf_tracking_cc.h + * \brief Interface of a processing block of a DLL + Kalman carrier + * tracking loop for GPS L1 C/A signals + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Jordi Vila-Valls 2018. jvila(at)cttc.es + * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es + * + * Reference: + * J. Vila-Valls, P. Closas, M. Navarro and C. Fernandez-Prades, + * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital + * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, + * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H +#define GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H + +#include "bayesian_estimation.h" +#include "cpu_multicorrelator_real_codes.h" +#include "gnss_synchro.h" +#include "tracking_2nd_DLL_filter.h" +#include "tracking_2nd_PLL_filter.h" +#include +#include +#include +#include +#include + +class Gps_L1_Ca_Kf_Tracking_cc; + +using gps_l1_ca_kf_tracking_cc_sptr = boost::shared_ptr; + +gps_l1_ca_kf_tracking_cc_sptr +gps_l1_ca_kf_make_tracking_cc(uint32_t order, + int64_t if_freq, + int64_t fs_in, uint32_t vector_length, + bool dump, + std::string dump_filename, + float dll_bw_hz, + float early_late_space_chips, + bool bce_run, + uint32_t bce_ptrans, + uint32_t bce_strans, + int32_t bce_nu, + int32_t bce_kappa); + + +/*! + * \brief This class implements a DLL + PLL tracking loop block + */ +class Gps_L1_Ca_Kf_Tracking_cc : public gr::block +{ +public: + ~Gps_L1_Ca_Kf_Tracking_cc(); + + void set_channel(uint32_t channel); + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); + void start_tracking(); + + int general_work(int noutput_items, gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); + + void forecast(int noutput_items, gr_vector_int& ninput_items_required); + +private: + friend gps_l1_ca_kf_tracking_cc_sptr + gps_l1_ca_kf_make_tracking_cc(uint32_t order, + int64_t if_freq, + int64_t fs_in, uint32_t vector_length, + bool dump, + std::string dump_filename, + float dll_bw_hz, + float early_late_space_chips, + bool bce_run, + uint32_t bce_ptrans, + uint32_t bce_strans, + int32_t bce_nu, + int32_t bce_kappa); + + Gps_L1_Ca_Kf_Tracking_cc(uint32_t order, + int64_t if_freq, + int64_t fs_in, uint32_t vector_length, + bool dump, + std::string dump_filename, + float dll_bw_hz, + float early_late_space_chips, + bool bce_run, + uint32_t bce_ptrans, + uint32_t bce_strans, + int32_t bce_nu, + int32_t bce_kappa); + + // tracking configuration vars + uint32_t d_order; + uint32_t d_vector_length; + bool d_dump; + + Gnss_Synchro* d_acquisition_gnss_synchro; + uint32_t d_channel; + + int64_t d_if_freq; + int64_t d_fs_in; + + double d_early_late_spc_chips; + + // remaining code phase and carrier phase between tracking loops + double d_rem_code_phase_samples; + double d_rem_code_phase_chips; + double d_rem_carr_phase_rad; + + // Kalman filter variables + arma::mat kf_P_x_ini; // initial state error covariance matrix + arma::mat kf_P_x; // state error covariance matrix + arma::mat kf_P_x_pre; // Predicted state error covariance matrix + arma::mat kf_P_y; // innovation covariance matrix + + arma::mat kf_F; // state transition matrix + arma::mat kf_H; // system matrix + arma::mat kf_R; // measurement error covariance matrix + arma::mat kf_Q; // system error covariance matrix + + arma::colvec kf_x; // state vector + arma::colvec kf_x_pre; // predicted state vector + arma::colvec kf_y; // measurement vector + arma::mat kf_K; // Kalman gain matrix + + // Bayesian estimator + Bayesian_estimator bayes_estimator; + arma::mat kf_R_est; // measurement error covariance + uint32_t bayes_ptrans; + uint32_t bayes_strans; + int32_t bayes_nu; + int32_t bayes_kappa; + + bool bayes_run; + uint32_t kf_iter; + + // PLL and DLL filter library + Tracking_2nd_DLL_filter d_code_loop_filter; + // Tracking_2nd_PLL_filter d_carrier_loop_filter; + + // acquisition + double d_acq_carrier_doppler_step_hz; + double d_acq_code_phase_samples; + double d_acq_carrier_doppler_hz; + // correlator + int32_t d_n_correlator_taps; + float* d_ca_code; + float* d_local_code_shift_chips; + gr_complex* d_correlator_outs; + Cpu_Multicorrelator_Real_Codes multicorrelator_cpu; + + // tracking vars + double d_code_freq_chips; + double d_code_phase_step_chips; + double d_code_phase_rate_step_chips; + double d_carrier_doppler_hz; + double d_carrier_dopplerrate_hz2; + double d_carrier_phase_step_rad; + double d_acc_carrier_phase_rad; + double d_carr_phase_error_rad; + double d_carr_phase_sigma2; + double d_code_phase_samples; + double code_error_chips; + double code_error_filt_chips; + + // PRN period in samples + int32_t d_current_prn_length_samples; + + // processing samples counters + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; + + // CN0 estimation and lock detector + int32_t d_cn0_estimation_counter; + gr_complex* d_Prompt_buffer; + double d_carrier_lock_test; + double d_CN0_SNV_dB_Hz; + double d_carrier_lock_threshold; + int32_t d_carrier_lock_fail_counter; + + // control vars + bool d_enable_tracking; + bool d_pull_in; + + // file dump + std::string d_dump_filename; + std::ofstream d_dump_file; + + std::map systemName; + std::string sys; + + int32_t save_matfile(); +}; + +#endif // GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index 41697da8d..8521314b4 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -36,37 +36,35 @@ */ #include "gps_l1_ca_tcp_connector_tracking_cc.h" -#include "control_message_factory.h" +#include "GPS_L1_CA.h" #include "gnss_sdr_flags.h" #include "gps_sdr_signal_processing.h" -#include "GPS_L1_CA.h" #include "lock_detectors.h" #include "tcp_communication.h" #include "tcp_packet_data.h" #include "tracking_discriminators.h" -#include -#include -#include #include +#include #include #include +#include #include #include +#include using google::LogMessage; gps_l1_ca_tcp_connector_tracking_cc_sptr gps_l1_ca_tcp_connector_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float early_late_space_chips, size_t port_ch0) { - return gps_l1_ca_tcp_connector_tracking_cc_sptr(new Gps_L1_Ca_Tcp_Connector_Tracking_cc(if_freq, + return gps_l1_ca_tcp_connector_tracking_cc_sptr(new Gps_L1_Ca_Tcp_Connector_Tracking_cc( fs_in, vector_length, dump, dump_filename, early_late_space_chips, port_ch0)); } @@ -76,17 +74,16 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::forecast(int noutput_items, { if (noutput_items != 0) { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call } } Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, + int64_t fs_in, + uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float early_late_space_chips, size_t port_ch0) : gr::block("Gps_L1_Ca_Tcp_Connector_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) @@ -94,7 +91,6 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc( this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; - d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; d_dump_filename = dump_filename; @@ -115,7 +111,7 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc( // correlator outputs (scalar) d_n_correlator_taps = 3; // Very-Early, Early, Prompt, Late, Very-Late d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -143,14 +139,14 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc( d_rem_carr_phase_rad = 0.0; // sample synchronization - d_sample_counter = 0; + d_sample_counter = 0ULL; d_sample_counter_seconds = 0; - d_acq_sample_stamp = 0; + d_acq_sample_stamp = 0ULL; d_enable_tracking = false; d_pull_in = false; - d_current_prn_length_samples = static_cast(d_vector_length); + d_current_prn_length_samples = static_cast(d_vector_length); // CN0 estimation and lock detector buffers d_cn0_estimation_counter = 0; @@ -166,7 +162,7 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc( systemName["E"] = std::string("Galileo"); systemName["C"] = std::string("Compass"); - d_acquisition_gnss_synchro = 0; + d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_next_rem_code_phase_samples = 0; d_acq_code_phase_samples = 0.0; @@ -189,9 +185,9 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - long int acq_trk_diff_samples; + int64_t acq_trk_diff_samples; float acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); std::cout << "acq_trk_diff_samples=" << acq_trk_diff_samples << std::endl; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); //doppler effect @@ -208,7 +204,7 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking() T_prn_mod_seconds = T_chip_mod_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; T_prn_mod_samples = T_prn_mod_seconds * static_cast(d_fs_in); - d_next_prn_length_samples = round(T_prn_mod_samples); + d_next_prn_length_samples = std::round(T_prn_mod_samples); float T_prn_true_seconds = GPS_L1_CA_CODE_LENGTH_CHIPS / GPS_L1_CA_CODE_RATE_HZ; float T_prn_true_samples = T_prn_true_seconds * static_cast(d_fs_in); @@ -217,7 +213,7 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking() float N_prn_diff; N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; float corrected_acq_phase_samples, delay_correction_samples; - corrected_acq_phase_samples = fmod((d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * static_cast(d_fs_in)), T_prn_true_samples); + corrected_acq_phase_samples = std::fmod((d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * static_cast(d_fs_in)), T_prn_true_samples); if (corrected_acq_phase_samples < 0) { corrected_acq_phase_samples = T_prn_mod_samples + corrected_acq_phase_samples; @@ -230,8 +226,8 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking() // generate local reference ALWAYS starting at chip 1 (1 sample per chip) gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) + multicorrelator_cpu.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int32_t n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); } @@ -291,7 +287,7 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::~Gps_L1_Ca_Tcp_Connector_Tracking_cc() } -void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) +void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_channel(uint32_t channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -302,7 +298,7 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) { try { - d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); @@ -338,13 +334,13 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib float code_error = 0.0; float code_nco = 0.0; - tcp_packet_data tcp_data; + Tcp_Packet_Data tcp_data; // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto **out = reinterpret_cast(&output_items[0]); if (d_enable_tracking == true) { @@ -355,19 +351,19 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib */ if (d_pull_in == true) { - int samples_offset; + int32_t samples_offset; // 28/11/2011 ACQ to TRK transition BUG CORRECTION float acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; + int32_t acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; - acq_trk_shif_correction_samples = d_next_prn_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_next_prn_length_samples)); - samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; + acq_trk_shif_correction_samples = d_next_prn_length_samples - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_next_prn_length_samples)); + samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; d_sample_counter_seconds = d_sample_counter_seconds + (static_cast(samples_offset) / static_cast(d_fs_in)); - d_sample_counter = d_sample_counter + samples_offset; //count for the processed samples + d_sample_counter = d_sample_counter + static_cast(samples_offset); //count for the processed samples d_pull_in = false; consume_each(samples_offset); //shift input to perform alignment with local replica return 1; @@ -465,7 +461,10 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { @@ -483,7 +482,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); //compute remnant code phase samples AFTER the Tracking timestamp d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = static_cast(d_acc_carrier_phase_rad); current_synchro_data.Carrier_Doppler_hz = static_cast(d_carrier_doppler_hz); @@ -497,7 +496,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib *d_Prompt = gr_complex(0, 0); *d_Late = gr_complex(0, 0); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder - current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); //! When tracking is disabled an array of 1's is sent to maintain the TCP connection boost::array tx_variables_array = {{1, 1, 1, 1, 1, 1, 1, 1, 0}}; d_tcp_com.send_receive_tcp_packet_gps_l1_ca(tx_variables_array, &tcp_data); @@ -538,7 +537,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(uint64_t)); // accumulated carrier phase tmp_float = d_acc_carrier_phase_rad; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -565,11 +564,11 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib // AUX vars (for debug purposes) tmp_float = 0.0; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + auto tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + uint32_t prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } catch (const std::ifstream::failure &e) { @@ -585,8 +584,6 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib { return 1; } - else - { - return 0; - } + + return 0; } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.h index 298203e2f..3fa928a4d 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.h @@ -48,13 +48,13 @@ class Gps_L1_Ca_Tcp_Connector_Tracking_cc; -typedef boost::shared_ptr gps_l1_ca_tcp_connector_tracking_cc_sptr; +using gps_l1_ca_tcp_connector_tracking_cc_sptr = boost::shared_ptr; gps_l1_ca_tcp_connector_tracking_cc_sptr -gps_l1_ca_tcp_connector_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, +gps_l1_ca_tcp_connector_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float early_late_space_chips, size_t port_ch0); @@ -67,7 +67,7 @@ class Gps_L1_Ca_Tcp_Connector_Tracking_cc : public gr::block public: ~Gps_L1_Ca_Tcp_Connector_Tracking_cc(); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); void start_tracking(); @@ -83,31 +83,30 @@ public: private: friend gps_l1_ca_tcp_connector_tracking_cc_sptr - gps_l1_ca_tcp_connector_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + gps_l1_ca_tcp_connector_make_tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float early_late_space_chips, size_t port_ch0); - Gps_L1_Ca_Tcp_Connector_Tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + Gps_L1_Ca_Tcp_Connector_Tracking_cc( + int64_t fs_in, uint32_t vector_length, bool dump, - std::string dump_filename, + const std::string &dump_filename, float early_late_space_chips, size_t port_ch0); // tracking configuration vars - unsigned int d_vector_length; + uint32_t d_vector_length; bool d_dump; Gnss_Synchro *d_acquisition_gnss_synchro; - unsigned int d_channel; + uint32_t d_channel; - long d_if_freq; - long d_fs_in; - int d_correlation_length_samples; - int d_n_correlator_taps; + int64_t d_fs_in; + int32_t d_correlation_length_samples; + int32_t d_n_correlator_taps; double d_early_late_spc_chips; double d_code_phase_step_chips; @@ -129,7 +128,7 @@ private: // correlator float *d_local_code_shift_chips; gr_complex *d_correlator_outs; - cpu_multicorrelator multicorrelator_cpu; + Cpu_Multicorrelator multicorrelator_cpu; // tracking vars double d_code_freq_hz; @@ -138,26 +137,26 @@ private: double d_code_phase_samples; size_t d_port_ch0; size_t d_port; - int d_listen_connection; + int32_t d_listen_connection; float d_control_id; - tcp_communication d_tcp_com; + Tcp_Communication d_tcp_com; //PRN period in samples - int d_current_prn_length_samples; - int d_next_prn_length_samples; + int32_t d_current_prn_length_samples; + int32_t d_next_prn_length_samples; double d_sample_counter_seconds; //processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; + uint64_t d_sample_counter; + uint64_t d_acq_sample_stamp; // CN0 estimation and lock detector - int d_cn0_estimation_counter; + int32_t d_cn0_estimation_counter; gr_complex *d_Prompt_buffer; float d_carrier_lock_test; float d_CN0_SNV_dB_Hz; float d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + int32_t d_carrier_lock_fail_counter; // control vars bool d_enable_tracking; diff --git a/src/algorithms/tracking/libs/CMakeLists.txt b/src/algorithms/tracking/libs/CMakeLists.txt index 9c5051ea2..7a7951645 100644 --- a/src/algorithms/tracking/libs/CMakeLists.txt +++ b/src/algorithms/tracking/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -22,63 +22,94 @@ if(ENABLE_CUDA) # set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --gpu-architecture sm_30) list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_30,code=sm_30; -std=c++11;-O3; -use_fast_math -default-stream per-thread") set(CUDA_PROPAGATE_HOST_FLAGS OFF) - CUDA_INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}) + cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(LIB_TYPE STATIC) #set the lib type - CUDA_ADD_LIBRARY(CUDA_CORRELATOR_LIB ${LIB_TYPE} cuda_multicorrelator.h cuda_multicorrelator.cu) + cuda_add_library(CUDA_CORRELATOR_LIB ${LIB_TYPE} cuda_multicorrelator.h cuda_multicorrelator.cu) set(OPT_TRACKING_LIBRARIES ${OPT_TRACKING_LIBRARIES} CUDA_CORRELATOR_LIB) - set(OPT_TRACKING_INCLUDES ${OPT_TRACKING_INCLUDES} ${CUDA_INCLUDE_DIRS} ) -endif(ENABLE_CUDA) - - + set(OPT_TRACKING_INCLUDES ${OPT_TRACKING_INCLUDES} ${CUDA_INCLUDE_DIRS}) +endif() set(TRACKING_LIB_SOURCES - cpu_multicorrelator.cc - cpu_multicorrelator_real_codes.cc - cpu_multicorrelator_16sc.cc - lock_detectors.cc - tcp_communication.cc - tcp_packet_data.cc - tracking_2nd_DLL_filter.cc - tracking_2nd_PLL_filter.cc - tracking_discriminators.cc - tracking_FLL_PLL_filter.cc - tracking_loop_filter.cc + cpu_multicorrelator.cc + cpu_multicorrelator_real_codes.cc + cpu_multicorrelator_16sc.cc + lock_detectors.cc + tcp_communication.cc + tcp_packet_data.cc + tracking_2nd_DLL_filter.cc + tracking_2nd_PLL_filter.cc + tracking_discriminators.cc + tracking_FLL_PLL_filter.cc + tracking_loop_filter.cc + dll_pll_conf.cc + bayesian_estimation.cc +) + +set(TRACKING_LIB_HEADERS + cpu_multicorrelator.h + cpu_multicorrelator_real_codes.h + cpu_multicorrelator_16sc.h + lock_detectors.h + tcp_communication.h + tcp_packet_data.h + tracking_2nd_DLL_filter.h + tracking_2nd_PLL_filter.h + tracking_discriminators.h + tracking_FLL_PLL_filter.h + tracking_loop_filter.h + dll_pll_conf.h + bayesian_estimation.h ) if(ENABLE_FPGA) - SET(TRACKING_LIB_SOURCES ${TRACKING_LIB_SOURCES} fpga_multicorrelator.cc) -endif(ENABLE_FPGA) + set(TRACKING_LIB_SOURCES ${TRACKING_LIB_SOURCES} fpga_multicorrelator.cc dll_pll_conf_fpga.cc) + set(TRACKING_LIB_HEADERS ${TRACKING_LIB_HEADERS} fpga_multicorrelator.h dll_pll_conf_fpga.h) +endif() -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${VOLK_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${OPT_TRACKING_INCLUDES} - ${VOLK_GNSSSDR_INCLUDE_DIRS} +list(SORT TRACKING_LIB_HEADERS) +list(SORT TRACKING_LIB_SOURCES) + +source_group(Headers FILES ${TRACKING_LIB_HEADERS}) + +add_library(tracking_libs ${TRACKING_LIB_SOURCES} ${TRACKING_LIB_HEADERS}) + +target_link_libraries(tracking_libs + PUBLIC + Armadillo::armadillo + Boost::boost + Gnuradio::runtime + Volkgnsssdr::volkgnsssdr + core_system_parameters + ${OPT_TRACKING_LIBRARIES} + PRIVATE + Gflags::gflags + Glog::glog ) -if(ENABLE_GENERIC_ARCH) - add_definitions( -DGENERIC_ARCH=1 ) -endif(ENABLE_GENERIC_ARCH) +target_include_directories(tracking_libs + PUBLIC + ${OPT_TRACKING_INCLUDES} +) -if (SSE3_AVAILABLE) - add_definitions( -DHAVE_SSE3=1 ) -endif(SSE3_AVAILABLE) - - -file(GLOB TRACKING_LIB_HEADERS "*.h") -list(SORT TRACKING_LIB_HEADERS) -add_library(tracking_lib ${TRACKING_LIB_SOURCES} ${TRACKING_LIB_HEADERS}) -source_group(Headers FILES ${TRACKING_LIB_HEADERS}) -target_link_libraries(tracking_lib ${OPT_TRACKING_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}) - -if(VOLK_GNSSSDR_FOUND) - add_dependencies(tracking_lib glog-${glog_RELEASE}) -else(VOLK_GNSSSDR_FOUND) - add_dependencies(tracking_lib glog-${glog_RELEASE} volk_gnsssdr_module) +if(OS_IS_MACOSX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # not AppleClang + target_compile_definitions(tracking_libs + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW + ) + endif() endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(tracking_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET tracking_libs + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/algorithms/tracking/libs/bayesian_estimation.cc b/src/algorithms/tracking/libs/bayesian_estimation.cc new file mode 100644 index 000000000..227cd6321 --- /dev/null +++ b/src/algorithms/tracking/libs/bayesian_estimation.cc @@ -0,0 +1,185 @@ +/*! + * \file bayesian_estimation.cc + * \brief Interface of a library with Bayesian noise statistic estimation + * + * Bayesian_estimator is a Bayesian estimator which attempts to estimate + * the properties of a stochastic process based on a sequence of + * discrete samples of the sequence. + * + * [1] TODO: Refs + * + * \authors
                  + *
                • Gerald LaMountain, 2018. gerald(at)ece.neu.edu + *
                • Jordi Vila-Valls 2018. jvila(at)cttc.es + *
                + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "bayesian_estimation.h" + + +Bayesian_estimator::Bayesian_estimator() +{ + int ny = 1; + mu_prior = arma::zeros(ny, 1); + kappa_prior = 0; + nu_prior = 0; + Psi_prior = arma::eye(ny, ny) * (nu_prior + ny + 1); + + mu_est = mu_prior; + Psi_est = Psi_prior; +} + +Bayesian_estimator::Bayesian_estimator(int ny) +{ + mu_prior = arma::zeros(ny, 1); + kappa_prior = 0; + nu_prior = 0; + Psi_prior = arma::eye(ny, ny) * (nu_prior + ny + 1); + + mu_est = mu_prior; + Psi_est = Psi_prior; +} + +Bayesian_estimator::Bayesian_estimator(const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0) +{ + mu_prior = mu_prior_0; + kappa_prior = kappa_prior_0; + nu_prior = nu_prior_0; + Psi_prior = Psi_prior_0; + + mu_est = mu_prior; + Psi_est = Psi_prior; +} + +Bayesian_estimator::~Bayesian_estimator() = default; + +void Bayesian_estimator::init(const arma::mat& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0) +{ + mu_prior = mu_prior_0; + kappa_prior = kappa_prior_0; + nu_prior = nu_prior_0; + Psi_prior = Psi_prior_0; + + mu_est = mu_prior; + Psi_est = Psi_prior; +} + +/* + * Perform Bayesian noise estimation using the normal-inverse-Wishart priors stored in + * the class structure, and update the priors according to the computed posteriors + */ +void Bayesian_estimator::update_sequential(const arma::vec& data) +{ + int K = data.n_cols; + int ny = data.n_rows; + + if (mu_prior.is_empty()) + { + mu_prior = arma::zeros(ny, 1); + } + + if (Psi_prior.is_empty()) + { + Psi_prior = arma::zeros(ny, ny); + } + + arma::vec y_mean = arma::mean(data, 1); + arma::mat Psi_N = arma::zeros(ny, ny); + + for (int kk = 0; kk < K; kk++) + { + Psi_N = Psi_N + (data.col(kk) - y_mean) * ((data.col(kk) - y_mean).t()); + } + + arma::vec mu_posterior = (kappa_prior * mu_prior + K * y_mean) / (kappa_prior + K); + int kappa_posterior = kappa_prior + K; + int nu_posterior = nu_prior + K; + arma::mat Psi_posterior = Psi_prior + Psi_N + (kappa_prior * K) / (kappa_prior + K) * (y_mean - mu_prior) * ((y_mean - mu_prior).t()); + + mu_est = mu_posterior; + if ((nu_posterior - ny - 1) > 0) + { + Psi_est = Psi_posterior / (nu_posterior - ny - 1); + } + else + { + Psi_est = Psi_posterior / (nu_posterior + ny + 1); + } + + mu_prior = mu_posterior; + kappa_prior = kappa_posterior; + nu_prior = nu_posterior; + Psi_prior = Psi_posterior; +} + + +/* + * Perform Bayesian noise estimation using a new set of normal-inverse-Wishart priors + * and update the priors according to the computed posteriors + */ +void Bayesian_estimator::update_sequential(const arma::vec& data, const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0) +{ + int K = data.n_cols; + int ny = data.n_rows; + + arma::vec y_mean = arma::mean(data, 1); + arma::mat Psi_N = arma::zeros(ny, ny); + + for (int kk = 0; kk < K; kk++) + { + Psi_N = Psi_N + (data.col(kk) - y_mean) * ((data.col(kk) - y_mean).t()); + } + + arma::vec mu_posterior = (kappa_prior_0 * mu_prior_0 + K * y_mean) / (kappa_prior_0 + K); + int kappa_posterior = kappa_prior_0 + K; + int nu_posterior = nu_prior_0 + K; + arma::mat Psi_posterior = Psi_prior_0 + Psi_N + (kappa_prior_0 * K) / (kappa_prior_0 + K) * (y_mean - mu_prior_0) * ((y_mean - mu_prior_0).t()); + + mu_est = mu_posterior; + if ((nu_posterior - ny - 1) > 0) + { + Psi_est = Psi_posterior / (nu_posterior - ny - 1); + } + else + { + Psi_est = Psi_posterior / (nu_posterior + ny + 1); + } + + mu_prior = mu_posterior; + kappa_prior = kappa_posterior; + nu_prior = nu_posterior; + Psi_prior = Psi_posterior; +} + +arma::mat Bayesian_estimator::get_mu_est() const +{ + return mu_est; +} + +arma::mat Bayesian_estimator::get_Psi_est() const +{ + return Psi_est; +} diff --git a/src/algorithms/tracking/libs/bayesian_estimation.h b/src/algorithms/tracking/libs/bayesian_estimation.h new file mode 100644 index 000000000..02f54143e --- /dev/null +++ b/src/algorithms/tracking/libs/bayesian_estimation.h @@ -0,0 +1,85 @@ +/*! + * \file bayesian_estimation.h + * \brief Interface of a library with Bayesian noise statistic estimation + * + * Bayesian_estimator is a Bayesian estimator which attempts to estimate + * the properties of a stochastic process based on a sequence of + * discrete samples of the sequence. + * + * [1] TODO: Refs + * + * \authors
                  + *
                • Gerald LaMountain, 2018. gerald(at)ece.neu.edu + *
                • Jordi Vila-Valls 2018. jvila(at)cttc.es + *
                + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BAYESIAN_ESTIMATION_H_ +#define GNSS_SDR_BAYESIAN_ESTIMATION_H_ + +#include +#include + +/*! \brief Bayesian_estimator is an estimator of noise characteristics (i.e. mean, covariance) + * + * Bayesian_estimator is an estimator which performs estimation of noise characteristics from + * a sequence of identically and independently distributed (IID) samples of a stationary + * stochastic process by way of Bayesian inference using conjugate priors. The posterior + * distribution is assumed to be Gaussian with mean \mathbf{\mu} and covariance \hat{\mathbf{C}}, + * which has a conjugate prior given by a normal-inverse-Wishart distribution with paramemters + * \mathbf{\mu}_{0}, \kappa_{0}, \nu_{0}, and \mathbf{\Psi}. + * + * [1] TODO: Ref1 + * + */ + +class Bayesian_estimator +{ +public: + Bayesian_estimator(); + Bayesian_estimator(int ny); + Bayesian_estimator(const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0); + ~Bayesian_estimator(); + + void init(const arma::mat& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0); + + void update_sequential(const arma::vec& data); + void update_sequential(const arma::vec& data, const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0); + + arma::mat get_mu_est() const; + arma::mat get_Psi_est() const; + +private: + arma::vec mu_est; + arma::mat Psi_est; + + arma::vec mu_prior; + int kappa_prior; + int nu_prior; + arma::mat Psi_prior; +}; + +#endif diff --git a/src/algorithms/tracking/libs/cpu_multicorrelator.cc b/src/algorithms/tracking/libs/cpu_multicorrelator.cc index 0e30856ce..c201a5df7 100644 --- a/src/algorithms/tracking/libs/cpu_multicorrelator.cc +++ b/src/algorithms/tracking/libs/cpu_multicorrelator.cc @@ -37,7 +37,7 @@ #include -cpu_multicorrelator::cpu_multicorrelator() +Cpu_Multicorrelator::Cpu_Multicorrelator() { d_sig_in = nullptr; d_local_code_in = nullptr; @@ -49,16 +49,16 @@ cpu_multicorrelator::cpu_multicorrelator() } -cpu_multicorrelator::~cpu_multicorrelator() +Cpu_Multicorrelator::~Cpu_Multicorrelator() { if (d_local_codes_resampled != nullptr) { - cpu_multicorrelator::free(); + Cpu_Multicorrelator::free(); } } -bool cpu_multicorrelator::init( +bool Cpu_Multicorrelator::init( int max_signal_length_samples, int n_correlators) { @@ -75,7 +75,7 @@ bool cpu_multicorrelator::init( } -bool cpu_multicorrelator::set_local_code_and_taps( +bool Cpu_Multicorrelator::set_local_code_and_taps( int code_length_chips, const std::complex* local_code_in, float* shifts_chips) @@ -87,7 +87,7 @@ bool cpu_multicorrelator::set_local_code_and_taps( } -bool cpu_multicorrelator::set_input_output_vectors(std::complex* corr_out, const std::complex* sig_in) +bool Cpu_Multicorrelator::set_input_output_vectors(std::complex* corr_out, const std::complex* sig_in) { // Save CPU pointers d_sig_in = sig_in; @@ -96,7 +96,7 @@ bool cpu_multicorrelator::set_input_output_vectors(std::complex* corr_out } -void cpu_multicorrelator::update_local_code(int correlator_length_samples, float rem_code_phase_chips, float code_phase_step_chips) +void Cpu_Multicorrelator::update_local_code(int correlator_length_samples, float rem_code_phase_chips, float code_phase_step_chips) { volk_gnsssdr_32fc_xn_resampler_32fc_xn(d_local_codes_resampled, d_local_code_in, @@ -109,7 +109,7 @@ void cpu_multicorrelator::update_local_code(int correlator_length_samples, float } -bool cpu_multicorrelator::Carrier_wipeoff_multicorrelator_resampler( +bool Cpu_Multicorrelator::Carrier_wipeoff_multicorrelator_resampler( float rem_carrier_phase_in_rad, float phase_step_rad, float rem_code_phase_chips, @@ -126,7 +126,7 @@ bool cpu_multicorrelator::Carrier_wipeoff_multicorrelator_resampler( } -bool cpu_multicorrelator::free() +bool Cpu_Multicorrelator::free() { // Free memory if (d_local_codes_resampled != nullptr) diff --git a/src/algorithms/tracking/libs/cpu_multicorrelator.h b/src/algorithms/tracking/libs/cpu_multicorrelator.h index 8dab4c4a4..d0f73d616 100644 --- a/src/algorithms/tracking/libs/cpu_multicorrelator.h +++ b/src/algorithms/tracking/libs/cpu_multicorrelator.h @@ -41,11 +41,11 @@ /*! * \brief Class that implements carrier wipe-off and correlators. */ -class cpu_multicorrelator +class Cpu_Multicorrelator { public: - cpu_multicorrelator(); - ~cpu_multicorrelator(); + Cpu_Multicorrelator(); + ~Cpu_Multicorrelator(); bool init(int max_signal_length_samples, int n_correlators); bool set_local_code_and_taps(int code_length_chips, const std::complex *local_code_in, float *shifts_chips); bool set_input_output_vectors(std::complex *corr_out, const std::complex *sig_in); diff --git a/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.cc b/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.cc index e57d1c2eb..107a38f7d 100644 --- a/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.cc +++ b/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.cc @@ -36,7 +36,7 @@ #include -bool cpu_multicorrelator_16sc::init( +bool Cpu_Multicorrelator_16sc::init( int max_signal_length_samples, int n_correlators) { @@ -54,7 +54,7 @@ bool cpu_multicorrelator_16sc::init( } -bool cpu_multicorrelator_16sc::set_local_code_and_taps( +bool Cpu_Multicorrelator_16sc::set_local_code_and_taps( int code_length_chips, const lv_16sc_t* local_code_in, float* shifts_chips) @@ -66,7 +66,7 @@ bool cpu_multicorrelator_16sc::set_local_code_and_taps( } -bool cpu_multicorrelator_16sc::set_input_output_vectors(lv_16sc_t* corr_out, const lv_16sc_t* sig_in) +bool Cpu_Multicorrelator_16sc::set_input_output_vectors(lv_16sc_t* corr_out, const lv_16sc_t* sig_in) { // Save CPU pointers d_sig_in = sig_in; @@ -75,7 +75,7 @@ bool cpu_multicorrelator_16sc::set_input_output_vectors(lv_16sc_t* corr_out, con } -void cpu_multicorrelator_16sc::update_local_code(int correlator_length_samples, float rem_code_phase_chips, float code_phase_step_chips) +void Cpu_Multicorrelator_16sc::update_local_code(int correlator_length_samples, float rem_code_phase_chips, float code_phase_step_chips) { volk_gnsssdr_16ic_xn_resampler_16ic_xn(d_local_codes_resampled, d_local_code_in, @@ -88,7 +88,7 @@ void cpu_multicorrelator_16sc::update_local_code(int correlator_length_samples, } -bool cpu_multicorrelator_16sc::Carrier_wipeoff_multicorrelator_resampler( +bool Cpu_Multicorrelator_16sc::Carrier_wipeoff_multicorrelator_resampler( float rem_carrier_phase_in_rad, float phase_step_rad, float rem_code_phase_chips, @@ -105,7 +105,7 @@ bool cpu_multicorrelator_16sc::Carrier_wipeoff_multicorrelator_resampler( } -cpu_multicorrelator_16sc::cpu_multicorrelator_16sc() +Cpu_Multicorrelator_16sc::Cpu_Multicorrelator_16sc() { d_sig_in = nullptr; d_local_code_in = nullptr; @@ -117,16 +117,16 @@ cpu_multicorrelator_16sc::cpu_multicorrelator_16sc() } -cpu_multicorrelator_16sc::~cpu_multicorrelator_16sc() +Cpu_Multicorrelator_16sc::~Cpu_Multicorrelator_16sc() { if (d_local_codes_resampled != nullptr) { - cpu_multicorrelator_16sc::free(); + Cpu_Multicorrelator_16sc::free(); } } -bool cpu_multicorrelator_16sc::free() +bool Cpu_Multicorrelator_16sc::free() { // Free memory if (d_local_codes_resampled != nullptr) diff --git a/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.h b/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.h index 16881ca07..7ef9549e8 100644 --- a/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.h +++ b/src/algorithms/tracking/libs/cpu_multicorrelator_16sc.h @@ -41,11 +41,11 @@ /*! * \brief Class that implements carrier wipe-off and correlators. */ -class cpu_multicorrelator_16sc +class Cpu_Multicorrelator_16sc { public: - cpu_multicorrelator_16sc(); - ~cpu_multicorrelator_16sc(); + Cpu_Multicorrelator_16sc(); + ~Cpu_Multicorrelator_16sc(); bool init(int max_signal_length_samples, int n_correlators); bool set_local_code_and_taps(int code_length_chips, const lv_16sc_t *local_code_in, float *shifts_chips); bool set_input_output_vectors(lv_16sc_t *corr_out, const lv_16sc_t *sig_in); diff --git a/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc b/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc index dc65db462..46475c286 100644 --- a/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc +++ b/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc @@ -1,6 +1,6 @@ /*! * \file cpu_multicorrelator_real_codes.cc - * \brief High optimized CPU vector multiTAP correlator class with real-valued local codes + * \brief Highly optimized CPU vector multiTAP correlator class with real-valued local codes * \authors
                  *
                • Javier Arribas, 2015. jarribas(at)cttc.es *
                • Cillian O'Driscoll, 2017. cillian.odriscoll(at)gmail.com @@ -37,8 +37,7 @@ #include #include - -cpu_multicorrelator_real_codes::cpu_multicorrelator_real_codes() +Cpu_Multicorrelator_Real_Codes::Cpu_Multicorrelator_Real_Codes() { d_sig_in = nullptr; d_local_code_in = nullptr; @@ -47,19 +46,20 @@ cpu_multicorrelator_real_codes::cpu_multicorrelator_real_codes() d_local_codes_resampled = nullptr; d_code_length_chips = 0; d_n_correlators = 0; + d_use_high_dynamics_resampler = true; } -cpu_multicorrelator_real_codes::~cpu_multicorrelator_real_codes() +Cpu_Multicorrelator_Real_Codes::~Cpu_Multicorrelator_Real_Codes() { if (d_local_codes_resampled != nullptr) { - cpu_multicorrelator_real_codes::free(); + Cpu_Multicorrelator_Real_Codes::free(); } } -bool cpu_multicorrelator_real_codes::init( +bool Cpu_Multicorrelator_Real_Codes::init( int max_signal_length_samples, int n_correlators) { @@ -76,7 +76,7 @@ bool cpu_multicorrelator_real_codes::init( } -bool cpu_multicorrelator_real_codes::set_local_code_and_taps( +bool Cpu_Multicorrelator_Real_Codes::set_local_code_and_taps( int code_length_chips, const float* local_code_in, float* shifts_chips) @@ -84,11 +84,12 @@ bool cpu_multicorrelator_real_codes::set_local_code_and_taps( d_local_code_in = local_code_in; d_shifts_chips = shifts_chips; d_code_length_chips = code_length_chips; + return true; } -bool cpu_multicorrelator_real_codes::set_input_output_vectors(std::complex* corr_out, const std::complex* sig_in) +bool Cpu_Multicorrelator_Real_Codes::set_input_output_vectors(std::complex* corr_out, const std::complex* sig_in) { // Save CPU pointers d_sig_in = sig_in; @@ -97,27 +98,68 @@ bool cpu_multicorrelator_real_codes::set_input_output_vectors(std::complex(d_local_codes_resampled), d_n_correlators, signal_length_samples); + } + else + { + volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn(d_corr_out, d_sig_in, std::exp(lv_32fc_t(0.0, -phase_step_rad)), phase_offset_as_complex, const_cast(d_local_codes_resampled), d_n_correlators, signal_length_samples); + } + return true; +} +// Overload Carrier_wipeoff_multicorrelator_resampler to ensure back compatibility +bool Cpu_Multicorrelator_Real_Codes::Carrier_wipeoff_multicorrelator_resampler( float rem_carrier_phase_in_rad, float phase_step_rad, float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, int signal_length_samples) { - update_local_code(signal_length_samples, rem_code_phase_chips, code_phase_step_chips); + update_local_code(signal_length_samples, rem_code_phase_chips, code_phase_step_chips, code_phase_rate_step_chips); // Regenerate phase at each call in order to avoid numerical issues lv_32fc_t phase_offset_as_complex[1]; phase_offset_as_complex[0] = lv_cmake(std::cos(rem_carrier_phase_in_rad), -std::sin(rem_carrier_phase_in_rad)); @@ -127,7 +169,7 @@ bool cpu_multicorrelator_real_codes::Carrier_wipeoff_multicorrelator_resampler( } -bool cpu_multicorrelator_real_codes::free() +bool Cpu_Multicorrelator_Real_Codes::free() { // Free memory if (d_local_codes_resampled != nullptr) @@ -141,3 +183,10 @@ bool cpu_multicorrelator_real_codes::free() } return true; } + + +void Cpu_Multicorrelator_Real_Codes::set_high_dynamics_resampler( + bool use_high_dynamics_resampler) +{ + d_use_high_dynamics_resampler = use_high_dynamics_resampler; +} diff --git a/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.h b/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.h index 50b5085f7..ecaad4a00 100644 --- a/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.h +++ b/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.h @@ -1,6 +1,6 @@ /*! * \file cpu_multicorrelator_real_codes.h - * \brief High optimized CPU vector multiTAP correlator class using real-valued local codes + * \brief Highly optimized CPU vector multiTAP correlator class using real-valued local codes * \authors
                    *
                  • Javier Arribas, 2015. jarribas(at)cttc.es *
                  • Cillian O'Driscoll, 2017, cillian.odriscoll(at)gmail.com @@ -42,16 +42,19 @@ /*! * \brief Class that implements carrier wipe-off and correlators. */ -class cpu_multicorrelator_real_codes +class Cpu_Multicorrelator_Real_Codes { public: - cpu_multicorrelator_real_codes(); - ~cpu_multicorrelator_real_codes(); + Cpu_Multicorrelator_Real_Codes(); + void set_high_dynamics_resampler(bool use_high_dynamics_resampler); + ~Cpu_Multicorrelator_Real_Codes(); bool init(int max_signal_length_samples, int n_correlators); bool set_local_code_and_taps(int code_length_chips, const float *local_code_in, float *shifts_chips); bool set_input_output_vectors(std::complex *corr_out, const std::complex *sig_in); - void update_local_code(int correlator_length_samples, float rem_code_phase_chips, float code_phase_step_chips); - bool Carrier_wipeoff_multicorrelator_resampler(float rem_carrier_phase_in_rad, float phase_step_rad, float rem_code_phase_chips, float code_phase_step_chips, int signal_length_samples); + void update_local_code(int correlator_length_samples, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips = 0.0); + // Overload Carrier_wipeoff_multicorrelator_resampler to ensure back compatibility + bool Carrier_wipeoff_multicorrelator_resampler(float rem_carrier_phase_in_rad, float phase_step_rad, float phase_rate_step_rad, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, int signal_length_samples); + bool Carrier_wipeoff_multicorrelator_resampler(float rem_carrier_phase_in_rad, float phase_step_rad, float rem_code_phase_chips, float code_phase_step_chips, float code_phase_rate_step_chips, int signal_length_samples); bool free(); private: @@ -61,6 +64,7 @@ private: const float *d_local_code_in; std::complex *d_corr_out; float *d_shifts_chips; + bool d_use_high_dynamics_resampler; int d_code_length_chips; int d_n_correlators; }; diff --git a/src/algorithms/tracking/libs/dll_pll_conf.cc b/src/algorithms/tracking/libs/dll_pll_conf.cc new file mode 100644 index 000000000..77c0b48a3 --- /dev/null +++ b/src/algorithms/tracking/libs/dll_pll_conf.cc @@ -0,0 +1,66 @@ +/*! + * \file dll_pll_conf.cc + * \brief Class that contains all the configuration parameters for generic + * tracking block based on a DLL and a PLL. + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "dll_pll_conf.h" +#include + +Dll_Pll_Conf::Dll_Pll_Conf() +{ + /* DLL/PLL tracking configuration */ + high_dyn = false; + smoother_length = 10; + fs_in = 0.0; + vector_length = 0U; + dump = false; + dump_mat = true; + dump_filename = std::string("./dll_pll_dump.dat"); + pll_pull_in_bw_hz = 50.0; + dll_pull_in_bw_hz = 3.0; + pll_bw_hz = 35.0; + dll_bw_hz = 2.0; + pll_bw_narrow_hz = 5.0; + dll_bw_narrow_hz = 0.75; + early_late_space_chips = 0.5; + very_early_late_space_chips = 0.5; + early_late_space_narrow_chips = 0.1; + very_early_late_space_narrow_chips = 0.1; + extend_correlation_symbols = 5; + cn0_samples = 20; + carrier_lock_det_mav_samples = 20; + cn0_min = 25; + max_lock_fail = 50; + carrier_lock_th = 0.85; + track_pilot = false; + system = 'G'; + char sig_[3] = "1C"; + std::memcpy(signal, sig_, 3); +} diff --git a/src/algorithms/tracking/libs/dll_pll_conf.h b/src/algorithms/tracking/libs/dll_pll_conf.h new file mode 100644 index 000000000..2304404b1 --- /dev/null +++ b/src/algorithms/tracking/libs/dll_pll_conf.h @@ -0,0 +1,73 @@ +/*! + * \file dll_pll_conf.h + * \brief Class that contains all the configuration parameters for generic tracking block based on a DLL and a PLL. + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * Class that contains all the configuration parameters for generic tracking block based on a DLL and a PLL. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_DLL_PLL_CONF_H_ +#define GNSS_SDR_DLL_PLL_CONF_H_ + +#include +#include + +class Dll_Pll_Conf +{ +public: + /* DLL/PLL tracking configuration */ + double fs_in; + uint32_t vector_length; + bool dump; + bool dump_mat; + std::string dump_filename; + float pll_pull_in_bw_hz; + float dll_pull_in_bw_hz; + float pll_bw_hz; + float dll_bw_hz; + float pll_bw_narrow_hz; + float dll_bw_narrow_hz; + float early_late_space_chips; + float very_early_late_space_chips; + float early_late_space_narrow_chips; + float very_early_late_space_narrow_chips; + int32_t extend_correlation_symbols; + bool high_dyn; + int32_t cn0_samples; + int32_t carrier_lock_det_mav_samples; + int32_t cn0_min; + int32_t max_lock_fail; + uint32_t smoother_length; + double carrier_lock_th; + bool track_pilot; + char system; + char signal[3]{}; + + Dll_Pll_Conf(); +}; + +#endif diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc new file mode 100644 index 000000000..14ec6ccab --- /dev/null +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc @@ -0,0 +1,71 @@ +/*! + * \file dll_pll_conf_fpga.cc + * \brief Class that contains all the configuration parameters for generic + * tracking block based on a DLL and a PLL for the FPGA. + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "dll_pll_conf_fpga.h" +#include + +Dll_Pll_Conf_Fpga::Dll_Pll_Conf_Fpga() +{ + /* DLL/PLL tracking configuration */ + high_dyn = false; + smoother_length = 10; + fs_in = 0.0; + vector_length = 0U; + dump = false; + dump_mat = true; + dump_filename = std::string("./dll_pll_dump.dat"); + pll_bw_hz = 35.0; + dll_bw_hz = 2.0; + pll_bw_narrow_hz = 5.0; + dll_bw_narrow_hz = 0.75; + early_late_space_chips = 0.5; + very_early_late_space_chips = 0.5; + early_late_space_narrow_chips = 0.1; + very_early_late_space_narrow_chips = 0.1; + extend_correlation_symbols = 5; + cn0_samples = 20; + cn0_min = 25; + max_lock_fail = 50; + carrier_lock_th = 0.85; + track_pilot = false; + system = 'G'; + char sig_[3] = "1C"; + std::memcpy(signal, sig_, 3); + device_name = "/dev/uio"; + device_base = 1U; + multicorr_type = 0U; + code_length_chips = 0U; + code_samples_per_chip = 0U; + ca_codes = nullptr; + data_codes = nullptr; +} diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.h b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h new file mode 100644 index 000000000..33dd901d7 --- /dev/null +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h @@ -0,0 +1,79 @@ +/*! + * \file dll_pll_conf_fpga.h + * \brief Class that contains all the configuration parameters for generic + * tracking block based on a DLL and a PLL for the FPGA. + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * Class that contains all the configuration parameters for generic tracking block based on a DLL and a PLL. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_DLL_PLL_CONF_FPGA_H_ +#define GNSS_SDR_DLL_PLL_CONF_FPGA_H_ + +#include +#include + +class Dll_Pll_Conf_Fpga +{ +public: + /* DLL/PLL tracking configuration */ + double fs_in; + uint32_t vector_length; + bool dump; + bool dump_mat; + std::string dump_filename; + float pll_bw_hz; + float dll_bw_hz; + float pll_bw_narrow_hz; + float dll_bw_narrow_hz; + float early_late_space_chips; + float very_early_late_space_chips; + float early_late_space_narrow_chips; + float very_early_late_space_narrow_chips; + int32_t extend_correlation_symbols; + bool high_dyn; + int32_t cn0_samples; + int32_t cn0_min; + int32_t max_lock_fail; + uint32_t smoother_length; + double carrier_lock_th; + bool track_pilot; + char system; + char signal[3]; + std::string device_name; + uint32_t device_base; + uint32_t multicorr_type; + uint32_t code_length_chips; + uint32_t code_samples_per_chip; + int32_t* ca_codes; + int32_t* data_codes; + + Dll_Pll_Conf_Fpga(); +}; + +#endif diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 9a546caca..a19784fbe 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -2,7 +2,7 @@ * \file fpga_multicorrelator_8sc.cc * \brief High optimized FPGA vector correlator class * \authors
                      - *
                    • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
                    • Marc Majoral, 2019. mmajoral(at)cttc.cat *
                    • Javier Arribas, 2015. jarribas(at)cttc.es *
                    * @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -35,47 +35,29 @@ */ #include "fpga_multicorrelator.h" - -#include - -// FPGA stuff -#include - -// libraries used by DMA test code and GIPO test code -#include -#include -#include -#include - -// libraries used by DMA test code -#include -#include -#include -#include - -// libraries used by GPIO test code -#include -#include -#include - -// logging #include - -// string manipulation +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include -// constants -#include "GPS_L1_CA.h" - -//#include "gps_sdr_signal_processing.h" - -#define NUM_PRNs 32 +// FPGA register access constants #define PAGE_SIZE 0x10000 #define MAX_LENGTH_DEVICEIO_NAME 50 #define CODE_RESAMPLER_NUM_BITS_PRECISION 20 #define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION #define pwrtwo(x) (1 << (x)) -#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS +#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS #define PHASE_CARR_NBITS 32 #define PHASE_CARR_NBITS_INT 1 #define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT @@ -84,29 +66,35 @@ #define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 #define TEST_REGISTER_TRACK_WRITEVAL 0x55AA -int fpga_multicorrelator_8sc::read_sample_counter() + +uint64_t fpga_multicorrelator_8sc::read_sample_counter() { - return d_map_base[7]; + uint64_t sample_counter_tmp, sample_counter_msw_tmp; + sample_counter_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_LSW]; + sample_counter_msw_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_MSW]; + sample_counter_msw_tmp = sample_counter_msw_tmp << 32; + sample_counter_tmp = sample_counter_tmp + sample_counter_msw_tmp; // 2^32 + return sample_counter_tmp; } -void fpga_multicorrelator_8sc::set_initial_sample(int samples_offset) +void fpga_multicorrelator_8sc::set_initial_sample(uint64_t samples_offset) { d_initial_sample_counter = samples_offset; - d_map_base[13] = d_initial_sample_counter; + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_LSW] = (d_initial_sample_counter & 0xFFFFFFFF); + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_MSW] = (d_initial_sample_counter >> 32) & 0xFFFFFFFF; } - -void fpga_multicorrelator_8sc::set_local_code_and_taps(int code_length_chips, - float *shifts_chips, int PRN) -{ +void fpga_multicorrelator_8sc::set_local_code_and_taps(float *shifts_chips, float *prompt_data_shift, int32_t PRN) +{ d_shifts_chips = shifts_chips; - d_code_length_chips = code_length_chips; + d_prompt_data_shift = prompt_data_shift; fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(PRN); } -void fpga_multicorrelator_8sc::set_output_vectors(gr_complex* corr_out) +void fpga_multicorrelator_8sc::set_output_vectors(gr_complex *corr_out, gr_complex *Prompt_Data) { d_corr_out = corr_out; + d_Prompt_Data = Prompt_Data; } void fpga_multicorrelator_8sc::update_local_code(float rem_code_phase_chips) @@ -118,48 +106,59 @@ void fpga_multicorrelator_8sc::update_local_code(float rem_code_phase_chips) void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( - float rem_carrier_phase_in_rad, float phase_step_rad, - float rem_code_phase_chips, float code_phase_step_chips, - int signal_length_samples) + float rem_carrier_phase_in_rad, float phase_step_rad, + float carrier_phase_rate_step_rad, + float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, + int32_t signal_length_samples) { - - update_local_code(rem_code_phase_chips); d_rem_carrier_phase_in_rad = rem_carrier_phase_in_rad; d_code_phase_step_chips = code_phase_step_chips; d_phase_step_rad = phase_step_rad; d_correlator_length_samples = signal_length_samples; - fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(); - fpga_multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(); + fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(); + fpga_multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(); fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(); - int irq_count; + int32_t irq_count; ssize_t nb; nb = read(d_device_descriptor, &irq_count, sizeof(irq_count)); if (nb != sizeof(irq_count)) { - printf("Tracking_module Read failed to retrieve 4 bytes!\n"); - printf("Tracking_module Interrupt number %d\n", irq_count); + std::cout << "Tracking_module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "Tracking_module Interrupt number " << irq_count << std::endl; } fpga_multicorrelator_8sc::read_tracking_gps_results(); } -fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, - std::string device_name, unsigned int device_base, int *ca_codes, unsigned int code_length) +fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int32_t n_correlators, + std::string device_name, uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, + uint32_t multicorr_type, uint32_t code_samples_per_chip) { d_n_correlators = n_correlators; - d_device_name = device_name; + d_device_name = std::move(device_name); d_device_base = device_base; + d_track_pilot = track_pilot; d_device_descriptor = 0; d_map_base = nullptr; // instantiate variable length vectors - d_initial_index = static_cast(volk_gnsssdr_malloc( - n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment())); - d_initial_interp_counter = static_cast(volk_gnsssdr_malloc( - n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment())); - - //d_local_code_in = nullptr; + if (d_track_pilot) + { + d_initial_index = static_cast(volk_gnsssdr_malloc( + (n_correlators + 1) * sizeof(uint32_t), volk_gnsssdr_get_alignment())); + d_initial_interp_counter = static_cast(volk_gnsssdr_malloc( + (n_correlators + 1) * sizeof(uint32_t), volk_gnsssdr_get_alignment())); + } + else + { + d_initial_index = static_cast(volk_gnsssdr_malloc( + n_correlators * sizeof(uint32_t), volk_gnsssdr_get_alignment())); + d_initial_interp_counter = static_cast(volk_gnsssdr_malloc( + n_correlators * sizeof(uint32_t), volk_gnsssdr_get_alignment())); + } d_shifts_chips = nullptr; + d_prompt_data_shift = nullptr; d_corr_out = nullptr; d_code_length_chips = 0; d_rem_code_phase_chips = 0; @@ -171,23 +170,18 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, d_initial_sample_counter = 0; d_channel = 0; d_correlator_length_samples = 0, - d_code_length = code_length; - - // pre-compute all the codes -// d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS*NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); -// for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) -// { -// gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); -// } + d_code_length_chips = code_length_chips; d_ca_codes = ca_codes; + d_data_codes = data_codes; + d_multicorr_type = multicorr_type; + d_code_samples_per_chip = code_samples_per_chip; + DLOG(INFO) << "TRACKING FPGA CLASS CREATED"; - } fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc() { - delete[] d_ca_codes; close_device(); } @@ -195,7 +189,7 @@ fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc() bool fpga_multicorrelator_8sc::free() { // unlock the channel - fpga_multicorrelator_8sc::unlock_channel(); + fpga_multicorrelator_8sc::unlock_channel(); // free the FPGA dynamically created variables if (d_initial_index != nullptr) @@ -214,38 +208,44 @@ bool fpga_multicorrelator_8sc::free() } -void fpga_multicorrelator_8sc::set_channel(unsigned int channel) +void fpga_multicorrelator_8sc::set_channel(uint32_t channel) { - char device_io_name[MAX_LENGTH_DEVICEIO_NAME]; // driver io name + char device_io_name[MAX_LENGTH_DEVICEIO_NAME]; // driver io name d_channel = channel; // open the device corresponding to the assigned channel std::string mergedname; std::stringstream devicebasetemp; - int numdevice = d_device_base + d_channel; + int32_t numdevice = d_device_base + d_channel; devicebasetemp << numdevice; mergedname = d_device_name + devicebasetemp.str(); strcpy(device_io_name, mergedname.c_str()); + + std::cout << "trk device_io_name = " << device_io_name << std::endl; + if ((d_device_descriptor = open(device_io_name, O_RDWR | O_SYNC)) == -1) { LOG(WARNING) << "Cannot open deviceio" << device_io_name; + std::cout << "Cannot open deviceio" << device_io_name << std::endl; } - d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0)); + d_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0)); - if (d_map_base == reinterpret_cast(-1)) + if (d_map_base == reinterpret_cast(-1)) { LOG(WARNING) << "Cannot map the FPGA tracking module " - << d_channel << "into user memory"; + << d_channel << "into user memory"; + std::cout << "Cannot map deviceio" << device_io_name << std::endl; } // sanity check : check test register - unsigned writeval = TEST_REGISTER_TRACK_WRITEVAL; - unsigned readval; + uint32_t writeval = TEST_REGISTER_TRACK_WRITEVAL; + uint32_t readval; readval = fpga_multicorrelator_8sc::fpga_acquisition_test_register(writeval); if (writeval != readval) { LOG(WARNING) << "Test register sanity check failed"; + std::cout << "tracking test register sanity check failed" << std::endl; } else { @@ -254,33 +254,46 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel) } -unsigned fpga_multicorrelator_8sc::fpga_acquisition_test_register( - unsigned writeval) +uint32_t fpga_multicorrelator_8sc::fpga_acquisition_test_register( + uint32_t writeval) { - unsigned readval; + uint32_t readval = 0; // write value to test register - d_map_base[15] = writeval; + d_map_base[TEST_REG_ADDR] = writeval; // read value from test register - readval = d_map_base[15]; + readval = d_map_base[TEST_REG_ADDR]; // return read value return readval; } -void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int PRN) +void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PRN) { - int k, s; - unsigned code_chip; - unsigned select_fpga_correlator; - select_fpga_correlator = 0; + uint32_t k; + uint32_t code_chip; + uint32_t select_pilot_corelator = LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - for (s = 0; s < d_n_correlators; s++) + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; + for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { - d_map_base[11] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; - for (k = 0; k < d_code_length_chips; k++) + if (d_ca_codes[((int32_t(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { - //if (d_local_code_in[k] == 1) - if (d_ca_codes[((int(d_code_length)) * (PRN - 1)) + k] == 1) + code_chip = 1; + } + else + { + code_chip = 0; + } + + // copy the local code to the FPGA memory one by one + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip; // | select_fpga_correlator; + } + if (d_track_pilot) + { + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; + for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) + { + if (d_data_codes[((int32_t(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { code_chip = 1; } @@ -288,12 +301,8 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int PRN) { code_chip = 0; } - // copy the local code to the FPGA memory one by one - d_map_base[11] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY - | code_chip | select_fpga_correlator; + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip | select_pilot_corelator; } - select_fpga_correlator = select_fpga_correlator - + LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; } } @@ -301,38 +310,63 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int PRN) void fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(void) { float temp_calculation; - int i; + int32_t i; for (i = 0; i < d_n_correlators; i++) { temp_calculation = floor( - d_shifts_chips[i] - d_rem_code_phase_chips); - + d_shifts_chips[i] - d_rem_code_phase_chips); + if (temp_calculation < 0) { - temp_calculation = temp_calculation + d_code_length_chips; // % operator does not work as in Matlab with negative numbers + temp_calculation = temp_calculation + (d_code_length_chips * d_code_samples_per_chip); // % operator does not work as in Matlab with negative numbers } - d_initial_index[i] = static_cast( (static_cast(temp_calculation)) % d_code_length_chips); + d_initial_index[i] = static_cast((static_cast(temp_calculation)) % (d_code_length_chips * d_code_samples_per_chip)); temp_calculation = fmod(d_shifts_chips[i] - d_rem_code_phase_chips, - 1.0); + 1.0); if (temp_calculation < 0) { - temp_calculation = temp_calculation + 1.0; // fmod operator does not work as in Matlab with negative numbers + temp_calculation = temp_calculation + 1.0; // fmod operator does not work as in Matlab with negative numbers } - d_initial_interp_counter[i] = static_cast( floor( MAX_CODE_RESAMPLER_COUNTER * temp_calculation)); + + d_initial_interp_counter[i] = static_cast(floor(MAX_CODE_RESAMPLER_COUNTER * temp_calculation)); + } + if (d_track_pilot) + { + temp_calculation = floor( + d_prompt_data_shift[0] - d_rem_code_phase_chips); + + if (temp_calculation < 0) + { + temp_calculation = temp_calculation + (d_code_length_chips * d_code_samples_per_chip); // % operator does not work as in Matlab with negative numbers + } + d_initial_index[d_n_correlators] = static_cast((static_cast(temp_calculation)) % (d_code_length_chips * d_code_samples_per_chip)); + temp_calculation = fmod(d_prompt_data_shift[0] - d_rem_code_phase_chips, + 1.0); + if (temp_calculation < 0) + { + temp_calculation = temp_calculation + 1.0; // fmod operator does not work as in Matlab with negative numbers + } + d_initial_interp_counter[d_n_correlators] = static_cast(floor(MAX_CODE_RESAMPLER_COUNTER * temp_calculation)); } } void fpga_multicorrelator_8sc::fpga_configure_code_parameters_in_fpga(void) { - int i; + int32_t i; for (i = 0; i < d_n_correlators; i++) { - d_map_base[1 + i] = d_initial_index[i]; - d_map_base[1 + d_n_correlators + i] = d_initial_interp_counter[i]; + d_map_base[INITIAL_INDEX_REG_BASE_ADDR + i] = d_initial_index[i]; + d_map_base[INITIAL_INTERP_COUNTER_REG_BASE_ADDR + i] = d_initial_interp_counter[i]; } - d_map_base[8] = d_code_length_chips - 1; // number of samples - 1 + if (d_track_pilot) + { + d_map_base[INITIAL_INDEX_REG_BASE_ADDR + d_n_correlators] = d_initial_index[d_n_correlators]; + d_map_base[INITIAL_INTERP_COUNTER_REG_BASE_ADDR + d_n_correlators] = d_initial_interp_counter[d_n_correlators]; + } + + d_map_base[CODE_LENGTH_MINUS_1_REG_ADDR] = (d_code_length_chips * d_code_samples_per_chip) - 1; // number of samples - 1 } @@ -340,30 +374,32 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void) { float d_rem_carrier_phase_in_rad_temp; - d_code_phase_step_chips_num = static_cast( roundf(MAX_CODE_RESAMPLER_COUNTER * d_code_phase_step_chips)); + d_code_phase_step_chips_num = static_cast(roundf(MAX_CODE_RESAMPLER_COUNTER * d_code_phase_step_chips)); + if (d_code_phase_step_chips > 1.0) + { + std::cout << "Warning : d_code_phase_step_chips = " << d_code_phase_step_chips << " cannot be bigger than one" << std::endl; + } + if (d_rem_carrier_phase_in_rad > M_PI) { - d_rem_carrier_phase_in_rad_temp = -2 * M_PI - + d_rem_carrier_phase_in_rad; + d_rem_carrier_phase_in_rad_temp = -2 * M_PI + d_rem_carrier_phase_in_rad; } else if (d_rem_carrier_phase_in_rad < -M_PI) { - d_rem_carrier_phase_in_rad_temp = 2 * M_PI - + d_rem_carrier_phase_in_rad; + d_rem_carrier_phase_in_rad_temp = 2 * M_PI + d_rem_carrier_phase_in_rad; } else { d_rem_carrier_phase_in_rad_temp = d_rem_carrier_phase_in_rad; } - d_rem_carr_phase_rad_int = static_cast( roundf( - (fabs(d_rem_carrier_phase_in_rad_temp) / M_PI) - * pow(2, PHASE_CARR_NBITS_FRAC))); + d_rem_carr_phase_rad_int = static_cast(roundf( + (fabs(d_rem_carrier_phase_in_rad_temp) / M_PI) * pow(2, PHASE_CARR_NBITS_FRAC))); if (d_rem_carrier_phase_in_rad_temp < 0) { d_rem_carr_phase_rad_int = -d_rem_carr_phase_rad_int; } - d_phase_step_rad_int = static_cast( roundf( - (fabs(d_phase_step_rad) / M_PI) * pow(2, PHASE_CARR_NBITS_FRAC))); // the FPGA accepts a range for the phase step between -pi and +pi + d_phase_step_rad_int = static_cast(roundf( + (fabs(d_phase_step_rad) / M_PI) * pow(2, PHASE_CARR_NBITS_FRAC))); // the FPGA accepts a range for the phase step between -pi and +pi if (d_phase_step_rad < 0) { @@ -374,44 +410,44 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void) void fpga_multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(void) { - d_map_base[0] = d_code_phase_step_chips_num; - d_map_base[7] = d_correlator_length_samples - 1; - d_map_base[9] = d_rem_carr_phase_rad_int; - d_map_base[10] = d_phase_step_rad_int; + d_map_base[CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR] = d_code_phase_step_chips_num; + + d_map_base[NSAMPLES_MINUS_1_REG_ADDR] = d_correlator_length_samples - 1; + + d_map_base[REM_CARR_PHASE_RAD_REG_ADDR] = d_rem_carr_phase_rad_int; + + d_map_base[PHASE_STEP_RAD_REG_ADDR] = d_phase_step_rad_int; } void fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(void) { // enable interrupts - int reenable = 1; - write(d_device_descriptor, reinterpret_cast(&reenable), sizeof(int)); + int32_t reenable = 1; + write(d_device_descriptor, reinterpret_cast(&reenable), sizeof(int32_t)); - // writing 1 to reg 14 launches the tracking - d_map_base[14] = 1; + // writing 1 to reg 14 launches the tracking + d_map_base[START_FLAG_ADDR] = 1; } void fpga_multicorrelator_8sc::read_tracking_gps_results(void) { - int readval_real; - int readval_imag; - int k; + int32_t readval_real; + int32_t readval_imag; + int32_t k; for (k = 0; k < d_n_correlators; k++) { - readval_real = d_map_base[1 + k]; - if (readval_real >= 1048576) // 0x100000 (21 bits two's complement) - { - readval_real = -2097152 + readval_real; - } - - readval_imag = d_map_base[1 + d_n_correlators + k]; - if (readval_imag >= 1048576) // 0x100000 (21 bits two's complement) - { - readval_imag = -2097152 + readval_imag; - } - d_corr_out[k] = gr_complex(readval_real,readval_imag); + readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + k]; + readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + k]; + d_corr_out[k] = gr_complex(readval_real, readval_imag); + } + if (d_track_pilot) + { + readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + d_n_correlators]; + readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; + d_Prompt_Data[0] = gr_complex(readval_real, readval_imag); } } @@ -419,40 +455,23 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) void fpga_multicorrelator_8sc::unlock_channel(void) { // unlock the channel to let the next samples go through - d_map_base[12] = 1; // unlock the channel + d_map_base[DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel + d_map_base[STOP_TRACKING_REG_ADDR] = 1; // set the tracking module back to idle } void fpga_multicorrelator_8sc::close_device() { - unsigned * aux = const_cast(d_map_base); - if (munmap(static_cast(aux), PAGE_SIZE) == -1) + auto *aux = const_cast(d_map_base); + if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } -/* else - { - printf("memory uio unmapped\n"); - } */ close(d_device_descriptor); } - + void fpga_multicorrelator_8sc::lock_channel(void) { // lock the channel for processing - d_map_base[12] = 0; // lock the channel -} - -void fpga_multicorrelator_8sc::read_sample_counters(int *sample_counter, int *secondary_sample_counter, int *counter_corr_0_in, int *counter_corr_0_out) -{ - *sample_counter = d_map_base[11]; - *secondary_sample_counter = d_map_base[8]; - *counter_corr_0_in = d_map_base[10]; - *counter_corr_0_out = d_map_base[9]; - -} - -void fpga_multicorrelator_8sc::reset_multicorrelator(void) -{ - d_map_base[14] = 2; // writing a 2 to d_map_base[14] resets the multicorrelator + d_map_base[DROP_SAMPLES_REG_ADDR] = 0; // lock the channel } diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index d255ace9f..6229ea0de 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -1,8 +1,8 @@ /*! * \file fpga_multicorrelator_8sc.h - * \brief High optimized FPGA vector correlator class for lv_16sc_t (short int complex) + * \brief High optimized FPGA vector correlator class * \authors
                      - *
                    • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
                    • Marc Majoral, 2019. mmajoral(at)cttc.cat *
                    • Javier Arribas, 2016. jarribas(at)cttc.es *
                    * @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -29,7 +29,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . + * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- */ @@ -39,8 +39,32 @@ #include #include +#include + +// FPGA register addresses + +// write addresses +#define CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR 0 +#define INITIAL_INDEX_REG_BASE_ADDR 1 +#define INITIAL_INTERP_COUNTER_REG_BASE_ADDR 7 +#define NSAMPLES_MINUS_1_REG_ADDR 13 +#define CODE_LENGTH_MINUS_1_REG_ADDR 14 +#define REM_CARR_PHASE_RAD_REG_ADDR 15 +#define PHASE_STEP_RAD_REG_ADDR 16 +#define PROG_MEMS_ADDR 17 +#define DROP_SAMPLES_REG_ADDR 18 +#define INITIAL_COUNTER_VALUE_REG_ADDR_LSW 19 +#define INITIAL_COUNTER_VALUE_REG_ADDR_MSW 20 +#define STOP_TRACKING_REG_ADDR 23 +#define START_FLAG_ADDR 30 +// read-write addresses +#define TEST_REG_ADDR 31 +// read addresses +#define RESULT_REG_REAL_BASE_ADDR 1 +#define RESULT_REG_IMAG_BASE_ADDR 7 +#define SAMPLE_COUNTER_REG_ADDR_LSW 13 +#define SAMPLE_COUNTER_REG_ADDR_MSW 14 -#define MAX_LENGTH_DEVICEIO_NAME 50 /*! * \brief Class that implements carrier wipe-off and correlators. @@ -48,84 +72,77 @@ class fpga_multicorrelator_8sc { public: - fpga_multicorrelator_8sc(int n_correlators, std::string device_name, - unsigned int device_base, int *ca_codes, unsigned int code_length); + fpga_multicorrelator_8sc(int32_t n_correlators, std::string device_name, + uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip); ~fpga_multicorrelator_8sc(); - //bool set_output_vectors(gr_complex* corr_out); - void set_output_vectors(gr_complex* corr_out); -// bool set_local_code_and_taps( -// int code_length_chips, const int* local_code_in, -// float *shifts_chips, int PRN); - //bool set_local_code_and_taps( + void set_output_vectors(gr_complex *corr_out, gr_complex *Prompt_Data); void set_local_code_and_taps( - int code_length_chips, - float *shifts_chips, int PRN); - //bool set_output_vectors(lv_16sc_t* corr_out); + float *shifts_chips, float *prompt_data_shift, int32_t PRN); void update_local_code(float rem_code_phase_chips); - //bool Carrier_wipeoff_multicorrelator_resampler( void Carrier_wipeoff_multicorrelator_resampler( - float rem_carrier_phase_in_rad, float phase_step_rad, - float rem_code_phase_chips, float code_phase_step_chips, - int signal_length_samples);bool free(); - void set_channel(unsigned int channel); - void set_initial_sample(int samples_offset); - int read_sample_counter(); + float rem_carrier_phase_in_rad, float phase_step_rad, + float carrier_phase_rate_step_rad, + float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, + int32_t signal_length_samples); + bool free(); + void set_channel(uint32_t channel); + void set_initial_sample(uint64_t samples_offset); + uint64_t read_sample_counter(); void lock_channel(void); void unlock_channel(void); - void read_sample_counters(int *sample_counter, int *secondary_sample_counter, int *counter_corr_0_in, int *counter_corr_0_out); // debug - - + private: - //const int *d_local_code_in; - gr_complex * d_corr_out; + gr_complex *d_corr_out; + gr_complex *d_Prompt_Data; float *d_shifts_chips; - int d_code_length_chips; - int d_n_correlators; + float *d_prompt_data_shift; + int32_t d_code_length_chips; + int32_t d_n_correlators; // data related to the hardware module and the driver - int d_device_descriptor; // driver descriptor - volatile unsigned *d_map_base; // driver memory map + int32_t d_device_descriptor; // driver descriptor + volatile uint32_t *d_map_base; // driver memory map // configuration data received from the interface - unsigned int d_channel; // channel number - unsigned d_ncorrelators; // number of correlators - unsigned d_correlator_length_samples; + uint32_t d_channel; // channel number + uint32_t d_ncorrelators; // number of correlators + uint32_t d_correlator_length_samples; float d_rem_code_phase_chips; float d_code_phase_step_chips; float d_rem_carrier_phase_in_rad; float d_phase_step_rad; // configuration data computed in the format that the FPGA expects - unsigned *d_initial_index; - unsigned *d_initial_interp_counter; - unsigned d_code_phase_step_chips_num; - int d_rem_carr_phase_rad_int; - int d_phase_step_rad_int; - unsigned d_initial_sample_counter; + uint32_t *d_initial_index; + uint32_t *d_initial_interp_counter; + uint32_t d_code_phase_step_chips_num; + int32_t d_rem_carr_phase_rad_int; + int32_t d_phase_step_rad_int; + uint64_t d_initial_sample_counter; // driver std::string d_device_name; - unsigned int d_device_base; + uint32_t d_device_base; + int32_t *d_ca_codes; + int32_t *d_data_codes; - int* d_ca_codes; + uint32_t d_code_samples_per_chip; + bool d_track_pilot; - unsigned int d_code_length; // nominal number of chips + uint32_t d_multicorr_type; // private functions - unsigned fpga_acquisition_test_register(unsigned writeval); - void fpga_configure_tracking_gps_local_code(int PRN); + uint32_t fpga_acquisition_test_register(uint32_t writeval); + void fpga_configure_tracking_gps_local_code(int32_t PRN); void fpga_compute_code_shift_parameters(void); void fpga_configure_code_parameters_in_fpga(void); void fpga_compute_signal_parameters_in_fpga(void); void fpga_configure_signal_parameters_in_fpga(void); void fpga_launch_multicorrelator_fpga(void); void read_tracking_gps_results(void); - void reset_multicorrelator(void); - void close_device(void); - - // debug - //unsigned int first_time = 1; + void close_device(void); }; #endif /* GNSS_SDR_FPGA_MULTICORRELATOR_H_ */ diff --git a/src/algorithms/tracking/libs/tcp_communication.cc b/src/algorithms/tracking/libs/tcp_communication.cc index edba15b7f..40cf6bb55 100644 --- a/src/algorithms/tracking/libs/tcp_communication.cc +++ b/src/algorithms/tracking/libs/tcp_communication.cc @@ -29,23 +29,19 @@ * ------------------------------------------------------------------------- */ -#include "tcp_packet_data.h" #include "tcp_communication.h" +#include "tcp_packet_data.h" #include #include -tcp_communication::tcp_communication() : tcp_socket_(io_service_) -{ -} +Tcp_Communication::Tcp_Communication() : tcp_socket_(io_service_) {} // NOLINT -tcp_communication::~tcp_communication() -{ -} +Tcp_Communication::~Tcp_Communication() = default; -int tcp_communication::listen_tcp_connection(size_t d_port_, size_t d_port_ch0_) +int Tcp_Communication::listen_tcp_connection(size_t d_port_, size_t d_port_ch0_) { try { @@ -77,7 +73,7 @@ int tcp_communication::listen_tcp_connection(size_t d_port_, size_t d_port_ch0_) } -void tcp_communication::send_receive_tcp_packet_galileo_e1(boost::array buf, tcp_packet_data* tcp_data_) +void Tcp_Communication::send_receive_tcp_packet_galileo_e1(boost::array buf, Tcp_Packet_Data* tcp_data_) { int controlc = 0; boost::array readbuf; @@ -112,7 +108,7 @@ void tcp_communication::send_receive_tcp_packet_galileo_e1(boost::array buf, tcp_packet_data* tcp_data_) +void Tcp_Communication::send_receive_tcp_packet_gps_l1_ca(boost::array buf, Tcp_Packet_Data* tcp_data_) { int controlc = 0; boost::array readbuf; @@ -147,7 +143,7 @@ void tcp_communication::send_receive_tcp_packet_gps_l1_ca(boost::array -#include #include "tcp_packet_data.h" +#include +#include #define NUM_TX_VARIABLES_GALILEO_E1 13 #define NUM_TX_VARIABLES_GPS_L1_CA 9 @@ -43,15 +43,15 @@ /*! * \brief TCP communication class */ -class tcp_communication +class Tcp_Communication { public: - tcp_communication(); - ~tcp_communication(); + Tcp_Communication(); + ~Tcp_Communication(); int listen_tcp_connection(size_t d_port_, size_t d_port_ch0_); - void send_receive_tcp_packet_galileo_e1(boost::array buf, tcp_packet_data *tcp_data_); - void send_receive_tcp_packet_gps_l1_ca(boost::array buf, tcp_packet_data *tcp_data_); + void send_receive_tcp_packet_galileo_e1(boost::array buf, Tcp_Packet_Data *tcp_data_); + void send_receive_tcp_packet_gps_l1_ca(boost::array buf, Tcp_Packet_Data *tcp_data_); void close_tcp_connection(size_t d_port_); private: diff --git a/src/algorithms/tracking/libs/tcp_packet_data.cc b/src/algorithms/tracking/libs/tcp_packet_data.cc index 0bd4fcde6..a48c3631a 100644 --- a/src/algorithms/tracking/libs/tcp_packet_data.cc +++ b/src/algorithms/tracking/libs/tcp_packet_data.cc @@ -30,11 +30,11 @@ */ #include "tcp_packet_data.h" -tcp_packet_data::tcp_packet_data() +Tcp_Packet_Data::Tcp_Packet_Data() { proc_pack_code_error = 0; proc_pack_carr_error = 0; proc_pack_carrier_doppler_hz = 0; } -tcp_packet_data::~tcp_packet_data() {} +Tcp_Packet_Data::~Tcp_Packet_Data() = default; diff --git a/src/algorithms/tracking/libs/tcp_packet_data.h b/src/algorithms/tracking/libs/tcp_packet_data.h index c803fa936..44eb4346e 100644 --- a/src/algorithms/tracking/libs/tcp_packet_data.h +++ b/src/algorithms/tracking/libs/tcp_packet_data.h @@ -35,11 +35,11 @@ /*! * \brief Class that implements a TCP data packet */ -class tcp_packet_data +class Tcp_Packet_Data { public: - tcp_packet_data(); - ~tcp_packet_data(); + Tcp_Packet_Data(); + ~Tcp_Packet_Data(); float proc_pack_code_error; float proc_pack_carr_error; float proc_pack_carrier_doppler_hz; diff --git a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc index db7583303..01b8641ea 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc +++ b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc @@ -72,21 +72,23 @@ float Tracking_2nd_DLL_filter::get_code_nco(float DLL_discriminator) return code_nco; } + Tracking_2nd_DLL_filter::Tracking_2nd_DLL_filter(float pdi_code) { d_pdi_code = pdi_code; // Summation interval for code d_dlldampingratio = 0.7; } + Tracking_2nd_DLL_filter::Tracking_2nd_DLL_filter() { d_pdi_code = 0.001; // Summation interval for code d_dlldampingratio = 0.7; } -Tracking_2nd_DLL_filter::~Tracking_2nd_DLL_filter() -{ -} + +Tracking_2nd_DLL_filter::~Tracking_2nd_DLL_filter() = default; + void Tracking_2nd_DLL_filter::set_pdi(float pdi_code) { diff --git a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc index ccbc47fff..bf0b0841b 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc +++ b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc @@ -77,6 +77,7 @@ float Tracking_2nd_PLL_filter::get_carrier_nco(float PLL_discriminator) return carr_nco; } + Tracking_2nd_PLL_filter::Tracking_2nd_PLL_filter(float pdi_carr) { //--- PLL variables -------------------------------------------------------- @@ -94,9 +95,8 @@ Tracking_2nd_PLL_filter::Tracking_2nd_PLL_filter() } -Tracking_2nd_PLL_filter::~Tracking_2nd_PLL_filter() -{ -} +Tracking_2nd_PLL_filter::~Tracking_2nd_PLL_filter() = default; + void Tracking_2nd_PLL_filter::set_pdi(float pdi_carr) { diff --git a/src/algorithms/tracking/libs/tracking_FLL_PLL_filter.cc b/src/algorithms/tracking/libs/tracking_FLL_PLL_filter.cc index ffe5152e5..04624d3f4 100644 --- a/src/algorithms/tracking/libs/tracking_FLL_PLL_filter.cc +++ b/src/algorithms/tracking/libs/tracking_FLL_PLL_filter.cc @@ -131,6 +131,4 @@ Tracking_FLL_PLL_filter::Tracking_FLL_PLL_filter() } -Tracking_FLL_PLL_filter::~Tracking_FLL_PLL_filter() -{ -} +Tracking_FLL_PLL_filter::~Tracking_FLL_PLL_filter() = default; diff --git a/src/algorithms/tracking/libs/tracking_discriminators.cc b/src/algorithms/tracking/libs/tracking_discriminators.cc index 5d7283d65..f1944ddc5 100644 --- a/src/algorithms/tracking/libs/tracking_discriminators.cc +++ b/src/algorithms/tracking/libs/tracking_discriminators.cc @@ -64,7 +64,7 @@ double fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2, double */ double pll_four_quadrant_atan(gr_complex prompt_s1) { - return atan2(prompt_s1.imag(), prompt_s1.real()); + return static_cast(std::atan2(prompt_s1.imag(), prompt_s1.real())); } @@ -79,12 +79,9 @@ double pll_cloop_two_quadrant_atan(gr_complex prompt_s1) { if (prompt_s1.real() != 0.0) { - return atan(prompt_s1.imag() / prompt_s1.real()); - } - else - { - return 0.0; + return static_cast(std::atan(prompt_s1.imag() / prompt_s1.real())); } + return 0.0; } @@ -105,10 +102,7 @@ double dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1) { return 0.0; } - else - { - return 0.5 * (P_early - P_late) / (P_early + P_late); - } + return 0.5 * (P_early - P_late) / (P_early + P_late); } /* @@ -129,8 +123,5 @@ double dll_nc_vemlp_normalized(gr_complex very_early_s1, gr_complex early_s1, gr { return 0.0; } - else - { - return (P_early - P_late) / (P_early + P_late); - } + return (P_early - P_late) / (P_early + P_late); } diff --git a/src/algorithms/tracking/libs/tracking_loop_filter.cc b/src/algorithms/tracking/libs/tracking_loop_filter.cc index 07ff8f730..f5ebd5a10 100644 --- a/src/algorithms/tracking/libs/tracking_loop_filter.cc +++ b/src/algorithms/tracking/libs/tracking_loop_filter.cc @@ -33,8 +33,8 @@ #include "tracking_loop_filter.h" -#include #include +#include Tracking_loop_filter::Tracking_loop_filter(float update_interval, @@ -52,6 +52,7 @@ Tracking_loop_filter::Tracking_loop_filter(float update_interval, update_coefficients(); } + Tracking_loop_filter::Tracking_loop_filter() : d_loop_order(2), d_current_index(0), @@ -64,10 +65,9 @@ Tracking_loop_filter::Tracking_loop_filter() update_coefficients(); } -Tracking_loop_filter::~Tracking_loop_filter() -{ - // Don't need to do anything here -} + +Tracking_loop_filter::~Tracking_loop_filter() = default; + float Tracking_loop_filter::apply(float current_input) { @@ -108,6 +108,7 @@ float Tracking_loop_filter::apply(float current_input) return result; } + void Tracking_loop_filter::update_coefficients(void) { // Analog gains: @@ -216,17 +217,20 @@ void Tracking_loop_filter::update_coefficients(void) }; } + void Tracking_loop_filter::set_noise_bandwidth(float noise_bandwidth) { d_noise_bandwidth = noise_bandwidth; update_coefficients(); } + float Tracking_loop_filter::get_noise_bandwidth(void) const { return d_noise_bandwidth; } + void Tracking_loop_filter::set_update_interval(float update_interval) { d_update_interval = update_interval; @@ -238,17 +242,20 @@ float Tracking_loop_filter::get_update_interval(void) const return d_update_interval; } + void Tracking_loop_filter::set_include_last_integrator(bool include_last_integrator) { d_include_last_integrator = include_last_integrator; update_coefficients(); } + bool Tracking_loop_filter::get_include_last_integrator(void) const { return d_include_last_integrator; } + void Tracking_loop_filter::set_order(int loop_order) { if (loop_order < 1 or loop_order > MAX_LOOP_ORDER) @@ -264,11 +271,13 @@ void Tracking_loop_filter::set_order(int loop_order) update_coefficients(); } + int Tracking_loop_filter::get_order(void) const { return d_loop_order; } + void Tracking_loop_filter::initialize(float initial_output) { d_inputs.assign(MAX_LOOP_HISTORY_LENGTH, 0.0); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4eebaa950..62d75f86c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -19,4 +19,4 @@ add_subdirectory(system_parameters) add_subdirectory(libs) add_subdirectory(receiver) - +add_subdirectory(monitor) diff --git a/src/core/interfaces/acquisition_interface.h b/src/core/interfaces/acquisition_interface.h index 10668b071..7067d403a 100644 --- a/src/core/interfaces/acquisition_interface.h +++ b/src/core/interfaces/acquisition_interface.h @@ -42,7 +42,7 @@ #include "gnss_synchro.h" template -class concurrent_queue; +class Concurrent_Queue; /*! \brief This abstract class represents an interface to an acquisition GNSS block. * @@ -61,8 +61,11 @@ public: virtual void set_doppler_step(unsigned int doppler_step) = 0; virtual void init() = 0; virtual void set_local_code() = 0; + virtual void set_state(int state) = 0; virtual signed int mag() = 0; virtual void reset() = 0; + virtual void stop_acquisition() = 0; + virtual void set_resampler_latency(uint32_t latency_samples) = 0; }; #endif /* GNSS_SDR_ACQUISITION_INTERFACE */ diff --git a/src/core/interfaces/channel_interface.h b/src/core/interfaces/channel_interface.h index 48232c674..d4f97aea5 100644 --- a/src/core/interfaces/channel_interface.h +++ b/src/core/interfaces/channel_interface.h @@ -51,8 +51,13 @@ class ChannelInterface : public GNSSBlockInterface { public: + virtual gr::basic_block_sptr get_left_block_trk() = 0; + virtual gr::basic_block_sptr get_left_block_acq() = 0; + virtual gr::basic_block_sptr get_left_block() = 0; + virtual gr::basic_block_sptr get_right_block() = 0; virtual Gnss_Signal get_signal() const = 0; virtual void start_acquisition() = 0; + virtual void stop_channel() = 0; virtual void set_signal(const Gnss_Signal&) = 0; }; diff --git a/src/core/interfaces/configuration_interface.h b/src/core/interfaces/configuration_interface.h index 48e6eefa1..0108f3283 100644 --- a/src/core/interfaces/configuration_interface.h +++ b/src/core/interfaces/configuration_interface.h @@ -35,6 +35,7 @@ #ifndef GNSS_SDR_CONFIGURATION_INTERFACE_H_ #define GNSS_SDR_CONFIGURATION_INTERFACE_H_ +#include #include /*! @@ -51,13 +52,15 @@ class ConfigurationInterface { public: - virtual ~ConfigurationInterface() {} + virtual ~ConfigurationInterface() = default; virtual std::string property(std::string property_name, std::string default_value) = 0; virtual bool property(std::string property_name, bool default_value) = 0; - virtual long property(std::string property_name, long default_value) = 0; - virtual int property(std::string property_name, int default_value) = 0; - virtual unsigned int property(std::string property_name, unsigned int default_value) = 0; - virtual unsigned short property(std::string property_name, unsigned short default_value) = 0; + virtual int64_t property(std::string property_name, int64_t default_value) = 0; + virtual uint64_t property(std::string property_name, uint64_t default_value) = 0; + virtual int32_t property(std::string property_name, int32_t default_value) = 0; + virtual uint32_t property(std::string property_name, uint32_t default_value) = 0; + virtual int16_t property(std::string property_name, int16_t default_value) = 0; + virtual uint16_t property(std::string property_name, uint16_t default_value) = 0; virtual float property(std::string property_name, float default_value) = 0; virtual double property(std::string property_name, double default_value) = 0; virtual void set_property(std::string property_name, std::string value) = 0; diff --git a/src/core/interfaces/gnss_block_interface.h b/src/core/interfaces/gnss_block_interface.h index a861d87f8..8a59d14cb 100644 --- a/src/core/interfaces/gnss_block_interface.h +++ b/src/core/interfaces/gnss_block_interface.h @@ -53,7 +53,7 @@ class GNSSBlockInterface { public: - virtual ~GNSSBlockInterface() {} + virtual ~GNSSBlockInterface() = default; virtual std::string role() = 0; virtual std::string implementation() = 0; virtual size_t item_size() = 0; diff --git a/src/core/interfaces/pvt_interface.h b/src/core/interfaces/pvt_interface.h index 69b23f541..20b3df8e4 100644 --- a/src/core/interfaces/pvt_interface.h +++ b/src/core/interfaces/pvt_interface.h @@ -37,7 +37,11 @@ #ifndef GNSS_SDR_PVT_INTERFACE_H_ #define GNSS_SDR_PVT_INTERFACE_H_ +#include "galileo_almanac.h" +#include "galileo_ephemeris.h" #include "gnss_block_interface.h" +#include "gps_almanac.h" +#include "gps_ephemeris.h" /*! * \brief This class represents an interface to a PVT block. @@ -52,6 +56,18 @@ class PvtInterface : public GNSSBlockInterface { public: virtual void reset() = 0; + virtual void clear_ephemeris() = 0; + virtual std::map get_gps_ephemeris() const = 0; + virtual std::map get_galileo_ephemeris() const = 0; + virtual std::map get_gps_almanac() const = 0; + virtual std::map get_galileo_almanac() const = 0; + + virtual bool get_latest_PVT(double* longitude_deg, + double* latitude_deg, + double* height_m, + double* ground_speed_kmh, + double* course_over_ground_deg, + time_t* UTC_time) = 0; }; #endif /* GNSS_SDR_PVT_INTERFACE_H_ */ diff --git a/src/core/interfaces/tracking_interface.h b/src/core/interfaces/tracking_interface.h index 010036d72..406c5748d 100644 --- a/src/core/interfaces/tracking_interface.h +++ b/src/core/interfaces/tracking_interface.h @@ -41,7 +41,7 @@ #include "gnss_synchro.h" template -class concurrent_queue; +class Concurrent_Queue; /*! * \brief This abstract class represents an interface to a tracking block. @@ -56,6 +56,7 @@ class TrackingInterface : public GNSSBlockInterface { public: virtual void start_tracking() = 0; + virtual void stop_tracking() = 0; virtual void set_gnss_synchro(Gnss_Synchro* gnss_synchro) = 0; virtual void set_channel(unsigned int channel) = 0; }; diff --git a/src/core/libs/CMakeLists.txt b/src/core/libs/CMakeLists.txt index c68d6d1d0..68b52890c 100644 --- a/src/core/libs/CMakeLists.txt +++ b/src/core/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -18,30 +18,50 @@ add_subdirectory(supl) -if(OPENSSL_FOUND) - add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) -endif(OPENSSL_FOUND) - -set(CORE_LIBS_SOURCES - ini.cc - INIReader.cc +set(CORE_LIBS_SOURCES + ini.cc + INIReader.cc string_converter.cc gnss_sdr_supl_client.cc ) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/libs/supl - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} + +set(CORE_LIBS_HEADERS + ini.h + INIReader.h + string_converter.h + gnss_sdr_supl_client.h ) -file(GLOB CORE_LIBS_HEADERS "*.h") list(SORT CORE_LIBS_HEADERS) -add_library(rx_core_lib ${CORE_LIBS_SOURCES} ${CORE_LIBS_HEADERS}) +list(SORT CORE_LIBS_SOURCES) + source_group(Headers FILES ${CORE_LIBS_HEADERS}) -target_link_libraries(rx_core_lib supl_library) + +add_library(core_libs ${CORE_LIBS_SOURCES} ${CORE_LIBS_HEADERS}) + +target_link_libraries(core_libs + PUBLIC + Boost::boost + core_libs_supl + core_system_parameters + PRIVATE + Boost::serialization + Gflags::gflags + Glog::glog + Pugixml::pugixml +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(core_libs + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET core_libs + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ + $ +) diff --git a/src/core/libs/INIReader.cc b/src/core/libs/INIReader.cc index 1a8a63815..63c076b82 100644 --- a/src/core/libs/INIReader.cc +++ b/src/core/libs/INIReader.cc @@ -49,9 +49,10 @@ #include "ini.h" #include // for tolower #include // for stro +#include -INIReader::INIReader(std::string filename) +INIReader::INIReader(const std::string& filename) { _error = ini_parse(filename.c_str(), ValueHandler, this); } @@ -63,30 +64,32 @@ int INIReader::ParseError() } -std::string INIReader::Get(std::string section, std::string name, std::string default_value) +std::string INIReader::Get(const std::string& section, const std::string& name, std::string default_value) { std::string key = MakeKey(section, name); return _values.count(key) ? _values[key] : default_value; } -long INIReader::GetInteger(std::string section, std::string name, long default_value) +int64_t INIReader::GetInteger(const std::string& section, const std::string& name, int64_t default_value) { std::string valstr = Get(section, name, ""); const char* value = valstr.c_str(); char* end; // This parses "1234" (decimal) and also "0x4D2" (hex) - long n = strtol(value, &end, 0); + int64_t n = strtol(value, &end, 0); return end > value ? n : default_value; } -std::string INIReader::MakeKey(std::string section, std::string name) +std::string INIReader::MakeKey(const std::string& section, const std::string& name) { std::string key = section + "." + name; // Convert to lower case to make lookups case-insensitive - for (unsigned int i = 0; i < key.length(); i++) - key[i] = tolower(key[i]); + for (char& i : key) + { + i = tolower(i); + } return key; } @@ -94,7 +97,7 @@ std::string INIReader::MakeKey(std::string section, std::string name) int INIReader::ValueHandler(void* user, const char* section, const char* name, const char* value) { - INIReader* reader = static_cast(user); + auto* reader = static_cast(user); reader->_values[MakeKey(section, name)] = value; return 1; } diff --git a/src/core/libs/INIReader.h b/src/core/libs/INIReader.h index 3e70d819e..bfe168bd9 100644 --- a/src/core/libs/INIReader.h +++ b/src/core/libs/INIReader.h @@ -48,6 +48,7 @@ #ifndef __INIREADER_H__ #define __INIREADER_H__ +#include #include #include @@ -59,22 +60,22 @@ class INIReader { public: //! Construct INIReader and parse given filename. See ini.h for more info about the parsing. - INIReader(std::string filename); + INIReader(const std::string& filename); //! Return the result of ini_parse(), i.e., 0 on success, line number of first error on parse error, or -1 on file open error. int ParseError(); //! Get a string value from INI file, returning default_value if not found. - std::string Get(std::string section, std::string name, + std::string Get(const std::string& section, const std::string& name, std::string default_value); //! Get an integer (long) value from INI file, returning default_value if not found. - long GetInteger(std::string section, std::string name, long default_value); + int64_t GetInteger(const std::string& section, const std::string& name, int64_t default_value); private: int _error; std::map _values; - static std::string MakeKey(std::string section, std::string name); + static std::string MakeKey(const std::string& section, const std::string& name); static int ValueHandler(void* user, const char* section, const char* name, const char* value); }; diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 70517e7f2..366d628ae 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -32,10 +32,12 @@ */ #include "gnss_sdr_supl_client.h" +#include +#include #include #include -gnss_sdr_supl_client::gnss_sdr_supl_client() +Gnss_Sdr_Supl_Client::Gnss_Sdr_Supl_Client() { mcc = 0; mns = 0; @@ -47,9 +49,11 @@ gnss_sdr_supl_client::gnss_sdr_supl_client() request = 0; } -gnss_sdr_supl_client::~gnss_sdr_supl_client() {} -void gnss_sdr_supl_client::print_assistance() +Gnss_Sdr_Supl_Client::~Gnss_Sdr_Supl_Client() = default; + + +void Gnss_Sdr_Supl_Client::print_assistance() { if (assist.set & SUPL_RRLP_ASSIST_REFTIME) { @@ -148,7 +152,7 @@ void gnss_sdr_supl_client::print_assistance() } -int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_ci) +int Gnss_Sdr_Supl_Client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_ci) { // SET SUPL CLIENT INFORMATION // GSM CELL PARAMETERS @@ -189,7 +193,8 @@ int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_ return err; } -void gnss_sdr_supl_client::read_supl_data() + +void Gnss_Sdr_Supl_Client::read_supl_data() { // READ REFERENCE LOCATION if (assist.set & SUPL_RRLP_ASSIST_REFLOC) @@ -216,12 +221,12 @@ void gnss_sdr_supl_client::read_supl_data() { gps_utc.d_A0 = static_cast(assist.utc.a0) * pow(2.0, -30); gps_utc.d_A1 = static_cast(assist.utc.a1) * pow(2.0, -50); - gps_utc.d_DeltaT_LS = static_cast(assist.utc.delta_tls); - gps_utc.d_DeltaT_LSF = static_cast(assist.utc.delta_tlsf); - gps_utc.d_t_OT = static_cast(assist.utc.tot) * pow(2.0, 12); - gps_utc.i_DN = static_cast(assist.utc.dn); - gps_utc.i_WN_T = static_cast(assist.utc.wnt); - gps_utc.i_WN_LSF = static_cast(assist.utc.wnlsf); + gps_utc.d_DeltaT_LS = static_cast(assist.utc.delta_tls); + gps_utc.d_DeltaT_LSF = static_cast(assist.utc.delta_tlsf); + gps_utc.d_t_OT = static_cast(assist.utc.tot) * pow(2.0, 12); + gps_utc.i_DN = static_cast(assist.utc.dn); + gps_utc.i_WN_T = static_cast(assist.utc.wnt); + gps_utc.i_WN_LSF = static_cast(assist.utc.wnlsf); gps_utc.valid = true; } @@ -264,13 +269,12 @@ void gnss_sdr_supl_client::read_supl_data() gps_almanac_iterator->second.d_OMEGA0 = static_cast(a->OMEGA_0) * pow(2.0, -23); gps_almanac_iterator->second.d_sqrt_A = static_cast(a->A_sqrt) * pow(2.0, -11); gps_almanac_iterator->second.d_OMEGA_DOT = static_cast(a->OMEGA_dot) * pow(2.0, -38); - gps_almanac_iterator->second.d_Toa = static_cast(a->toa) * pow(2.0, 12); - gps_almanac_iterator->second.d_e_eccentricity = static_cast(a->toa) * pow(2.0, -21); + gps_almanac_iterator->second.i_Toa = static_cast(a->toa * pow(2.0, 12)); + gps_almanac_iterator->second.d_e_eccentricity = static_cast(a->e) * pow(2.0, -21); gps_almanac_iterator->second.d_M_0 = static_cast(a->M0) * pow(2.0, -23); } } - // READ SV EPHEMERIS if (assist.cnt_eph) { @@ -366,15 +370,15 @@ void gnss_sdr_supl_client::read_supl_data() } -bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) +bool Gnss_Sdr_Supl_Client::load_ephemeris_xml(const std::string& file_name) { + std::ifstream ifs; try { - std::ifstream ifs(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); gps_ephemeris_map.clear(); xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gps_ephemeris_map); - ifs.close(); LOG(INFO) << "Loaded Ephemeris map data with " << this->gps_ephemeris_map.size() << " satellites"; } catch (std::exception& e) @@ -385,16 +389,17 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) return true; } -bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, std::map eph_map) + +bool Gnss_Sdr_Supl_Client::save_ephemeris_map_xml(const std::string& file_name, std::map eph_map) { - if (eph_map.size() > 0) + if (eph_map.empty() == false) { + std::ofstream ofs; try { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); boost::archive::xml_oarchive xml(ofs); xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map); - ofs.close(); LOG(INFO) << "Saved Ephemeris map data"; } catch (std::exception& e) @@ -402,23 +407,165 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s LOG(WARNING) << e.what(); return false; } - return true; } else { LOG(WARNING) << "Failed to save Ephemeris, map is empty"; return false; } + return true; } -bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name) + +bool Gnss_Sdr_Supl_Client::load_gal_ephemeris_xml(const std::string& file_name) { + std::ifstream ifs; try { - std::ifstream ifs(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); - xml >> boost::serialization::make_nvp("GNSS-SDR_utc_map", this->gps_utc); - ifs.close(); + gal_ephemeris_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", this->gal_ephemeris_map); + LOG(INFO) << "Loaded Ephemeris map data with " << this->gal_ephemeris_map.size() << " satellites"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool save_gal_ephemeris_map_xml(const std::string& file_name, std::map eph_map) +{ + if (eph_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", eph_map); + LOG(INFO) << "Saved Galileo ephemeris map data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save Galileo ephemeris, map is empty"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_cnav_ephemeris_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gps_cnav_ephemeris_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", this->gps_cnav_ephemeris_map); + LOG(INFO) << "Loaded Ephemeris map data with " << this->gps_cnav_ephemeris_map.size() << " satellites"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool save_cnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map) +{ + if (eph_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", eph_map); + LOG(INFO) << "Saved GPS CNAV ephemeris map data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save GPS CNAV ephemeris, map is empty"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_gnav_ephemeris_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gps_cnav_ephemeris_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", this->glonass_gnav_ephemeris_map); + LOG(INFO) << "Loaded GLONASS ephemeris map data with " << this->gps_cnav_ephemeris_map.size() << " satellites"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool save_gnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map) +{ + if (eph_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", eph_map); + LOG(INFO) << "Saved GLONASS GNAV ephemeris map data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save GLONASS GNAV ephemeris, map is empty"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_utc_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + xml >> boost::serialization::make_nvp("GNSS-SDR_utc_model", this->gps_utc); LOG(INFO) << "Loaded UTC model data"; } catch (std::exception& e) @@ -429,40 +576,134 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name) return true; } -bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::map utc_map) + +bool Gnss_Sdr_Supl_Client::save_utc_xml(const std::string& file_name, Gps_Utc_Model& utc) { - if (utc_map.size() > 0) + if (utc.valid) { + std::ofstream ofs; try { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_utc_map", utc_map); - ofs.close(); - LOG(INFO) << "Saved UTC Model data"; + xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", utc); + LOG(INFO) << "Saved GPS UTC Model data"; } catch (std::exception& e) { LOG(WARNING) << e.what(); return false; } - return true; } else { - LOG(WARNING) << "Failed to save UTC model, map is empty"; + LOG(WARNING) << "Failed to save GPS UTC model, no valid data"; return false; } + return true; } -bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name) + +bool Gnss_Sdr_Supl_Client::load_cnav_utc_xml(const std::string& file_name) { + std::ifstream ifs; try { - std::ifstream ifs(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); - xml >> boost::serialization::make_nvp("GNSS-SDR_iono_map", this->gps_iono); - ifs.close(); + xml >> boost::serialization::make_nvp("GNSS-SDR_cnav_utc_model", this->gps_cnav_utc); + LOG(INFO) << "Loaded CNAV UTC model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::save_cnav_utc_xml(const std::string& file_name, Gps_CNAV_Utc_Model& utc) +{ + if (utc.valid) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_utc_model", utc); + LOG(INFO) << "Saved GPS CNAV UTC model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save GPS CNAV UTC model, no valid data"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_gal_utc_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + xml >> boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", this->gal_utc); + LOG(INFO) << "Loaded Galileo UTC model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::save_gal_utc_xml(const std::string& file_name, Galileo_Utc_Model& utc) +{ + if (utc.flag_utc_model) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", utc); + LOG(INFO) << "Saved Galileo UTC Model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save Galileo UTC model, no valid data"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_iono_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + xml >> boost::serialization::make_nvp("GNSS-SDR_iono_model", this->gps_iono); LOG(INFO) << "Loaded IONO model data"; } catch (std::exception& e) @@ -473,16 +714,17 @@ bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name) return true; } -bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::map iono_map) + +bool Gnss_Sdr_Supl_Client::save_iono_xml(const std::string& file_name, Gps_Iono& iono) { - if (iono_map.size() > 0) + if (iono.valid) { + std::ofstream ofs; try { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_iono_map", iono_map); - ofs.close(); + xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", iono); LOG(INFO) << "Saved IONO Model data"; } catch (std::exception& e) @@ -490,23 +732,260 @@ bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::m LOG(WARNING) << e.what(); return false; } - return true; } else { LOG(WARNING) << "Failed to save IONO model, map is empty"; return false; } + return true; } -bool gnss_sdr_supl_client::load_ref_time_xml(const std::string file_name) + +bool Gnss_Sdr_Supl_Client::load_gal_iono_xml(const std::string& file_name) { + std::ifstream ifs; try { - std::ifstream ifs(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); - xml >> boost::serialization::make_nvp("GNSS-SDR_ref_time_map", this->gps_time); - ifs.close(); + xml >> boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", this->gal_iono); + LOG(INFO) << "Loaded Galileo IONO model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::save_gal_iono_xml(const std::string& file_name, Galileo_Iono& iono) +{ + if (iono.ai0_5 != 0.0) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", iono); + LOG(INFO) << "Saved Galileo IONO Model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save Galileo IONO model, map is empty"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_gps_almanac_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gps_almanac_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", this->gps_almanac_map); + LOG(INFO) << "Loaded GPS almanac map data with " << this->gps_almanac_map.size() << " satellites"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::save_gps_almanac_xml(const std::string& file_name, std::map gps_almanac_map) +{ + if (gps_almanac_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", gps_almanac_map); + LOG(INFO) << "Saved GPS almanac data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save GPS almanac, map is empty"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_gal_almanac_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gal_almanac_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", this->gal_almanac_map); + } + catch (std::exception& e) + { + // Maybe the file is from https://www.gsc-europa.eu/system-status/almanac-data ? + return this->read_gal_almanac_from_gsa(file_name); + } + LOG(INFO) << "Loaded Galileo almanac map data with " << this->gal_almanac_map.size() << " satellites"; + return true; +} + + +bool Gnss_Sdr_Supl_Client::read_gal_almanac_from_gsa(const std::string& file_name) +{ + pugi::xml_document doc; + pugi::xml_parse_result result = doc.load_file(file_name.c_str()); + if (!result) + { + LOG(WARNING) << "Error loading file " << file_name << ":" << result.description(); + return false; + } + for (pugi::xml_node almanac : doc.child("signalData") + .child("body") + .child("Almanacs") + .children("svAlmanac")) + { + Galileo_Almanac gal_alm; + try + { + uint32_t prn = static_cast(std::stoi(almanac.child_value("SVID"))); + gal_alm.i_satellite_PRN = prn; + gal_alm.i_Toa = std::stoi(almanac.child("almanac").child_value("t0a")); + gal_alm.i_WNa = std::stoi(almanac.child("almanac").child_value("wna")); + gal_alm.i_IODa = std::stoi(almanac.child("almanac").child_value("iod")); + gal_alm.d_Delta_i = std::stod(almanac.child("almanac").child_value("deltai")); + gal_alm.d_M_0 = std::stod(almanac.child("almanac").child_value("m0")); + gal_alm.d_e_eccentricity = std::stod(almanac.child("almanac").child_value("ecc")); + gal_alm.d_Delta_sqrt_A = std::stod(almanac.child("almanac").child_value("aSqRoot")); + gal_alm.d_OMEGA0 = std::stod(almanac.child("almanac").child_value("omega0")); + gal_alm.d_OMEGA = std::stod(almanac.child("almanac").child_value("w")); + gal_alm.d_OMEGA_DOT = std::stod(almanac.child("almanac").child_value("omegaDot")); + gal_alm.d_A_f0 = std::stod(almanac.child("almanac").child_value("af0")); + gal_alm.d_A_f1 = std::stod(almanac.child("almanac").child_value("af1")); + gal_alm.E5b_HS = std::stoi(almanac.child("svINavSignalStatus").child_value("statusE5b")); + gal_alm.E1B_HS = std::stoi(almanac.child("svINavSignalStatus").child_value("statusE1B")); + gal_alm.E5a_HS = std::stoi(almanac.child("svFNavSignalStatus").child_value("statusE5a")); + + this->gal_almanac_map[static_cast(prn)] = gal_alm; + } + catch (const std::exception& e) + { + std::cerr << e.what() << std::endl; + } + } + if (this->gal_almanac_map.empty()) + { + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::save_gal_almanac_xml(const std::string& file_name, std::map gal_almanac_map) +{ + if (gal_almanac_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", gal_almanac_map); + LOG(INFO) << "Saved Galileo almanac data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save Galileo almanac, map is empty"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_glo_utc_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + xml >> boost::serialization::make_nvp("GNSS-SDR_glo_utc_model", this->glo_gnav_utc); + LOG(INFO) << "Loaded UTC model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::save_glo_utc_xml(const std::string& file_name, Glonass_Gnav_Utc_Model& utc) +{ + if (utc.valid) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_glo_utc_model", utc); + LOG(INFO) << "Saved Glonass UTC Model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save Glonass UTC model, no valid data"; + return false; + } + return true; +} + + +bool Gnss_Sdr_Supl_Client::load_ref_time_xml(const std::string& file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + xml >> boost::serialization::make_nvp("GNSS-SDR_ref_time", this->gps_time); LOG(INFO) << "Loaded Ref Time data"; } catch (std::exception& e) @@ -517,16 +996,17 @@ bool gnss_sdr_supl_client::load_ref_time_xml(const std::string file_name) return true; } -bool gnss_sdr_supl_client::save_ref_time_map_xml(const std::string file_name, std::map ref_time_map) + +bool Gnss_Sdr_Supl_Client::save_ref_time_xml(const std::string& file_name, Agnss_Ref_Time& ref_time) { - if (ref_time_map.size() > 0) + if (ref_time.valid == true) { + std::ofstream ofs; try { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ref_time_map", ref_time_map); - ofs.close(); + xml << boost::serialization::make_nvp("GNSS-SDR_ref_time", ref_time); LOG(INFO) << "Saved Ref Time data"; } catch (std::exception& e) @@ -534,23 +1014,24 @@ bool gnss_sdr_supl_client::save_ref_time_map_xml(const std::string file_name, st LOG(WARNING) << e.what(); return false; } - return true; } else { - LOG(WARNING) << "Failed to save Ref Time, map is empty"; + LOG(WARNING) << "Failed to save Ref Time"; return false; } + return true; } -bool gnss_sdr_supl_client::load_ref_location_xml(const std::string file_name) + +bool Gnss_Sdr_Supl_Client::load_ref_location_xml(const std::string& file_name) { + std::ifstream ifs; try { - std::ifstream ifs(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); - xml >> boost::serialization::make_nvp("GNSS-SDR_ref_location_map", this->gps_ref_loc); - ifs.close(); + xml >> boost::serialization::make_nvp("GNSS-SDR_ref_location", this->gps_ref_loc); LOG(INFO) << "Loaded Ref Location data"; } catch (std::exception& e) @@ -561,16 +1042,17 @@ bool gnss_sdr_supl_client::load_ref_location_xml(const std::string file_name) return true; } -bool gnss_sdr_supl_client::save_ref_location_map_xml(const std::string file_name, std::map ref_location_map) + +bool Gnss_Sdr_Supl_Client::save_ref_location_xml(const std::string& file_name, Agnss_Ref_Location& ref_location) { - if (ref_location_map.size() > 0) + if (ref_location.valid == true) { + std::ofstream ofs; try { - std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ref_location_map", ref_location_map); - ofs.close(); + xml << boost::serialization::make_nvp("GNSS-SDR_ref_location", ref_location); LOG(INFO) << "Saved Ref Location data"; } catch (std::exception& e) @@ -578,11 +1060,11 @@ bool gnss_sdr_supl_client::save_ref_location_map_xml(const std::string file_name LOG(WARNING) << e.what(); return false; } - return true; } else { - LOG(WARNING) << "Failed to save Ref Location, map is empty"; + LOG(WARNING) << "Failed to save Ref Location"; return false; } + return true; } diff --git a/src/core/libs/gnss_sdr_supl_client.h b/src/core/libs/gnss_sdr_supl_client.h index 381045edb..af78c9f16 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -39,17 +39,24 @@ extern "C" #include "supl.h" } #include "GPS_L1_CA.h" +#include "agnss_ref_location.h" +#include "agnss_ref_time.h" +#include "galileo_almanac.h" +#include "galileo_ephemeris.h" +#include "galileo_iono.h" +#include "galileo_utc_model.h" +#include "glonass_gnav_ephemeris.h" +#include "glonass_gnav_utc_model.h" +#include "gps_acq_assist.h" +#include "gps_almanac.h" +#include "gps_cnav_ephemeris.h" +#include "gps_cnav_utc_model.h" #include "gps_ephemeris.h" #include "gps_iono.h" -#include "gps_almanac.h" #include "gps_utc_model.h" -#include "gps_acq_assist.h" -#include "gps_ref_time.h" -#include "gps_ref_location.h" -#include #include +#include #include -#include #include #include #include @@ -57,7 +64,7 @@ extern "C" /*! * \brief class that implements a C++ interface to external Secure User Location Protocol (SUPL) client library.. */ -class gnss_sdr_supl_client +class Gnss_Sdr_Supl_Client { private: // GSM CELL INFO @@ -66,9 +73,10 @@ private: int lac; int ci; // assistance protocol structure - supl_ctx_t ctx; + supl_ctx_t ctx{}; // assistance data - supl_assist_t assist; + supl_assist_t assist{}; + bool read_gal_almanac_from_gsa(const std::string& file_name); public: // SUPL SERVER INFO @@ -77,17 +85,26 @@ public: int request; // ephemeris map std::map gps_ephemeris_map; + std::map gal_ephemeris_map; + std::map gps_cnav_ephemeris_map; + std::map glonass_gnav_ephemeris_map; + // almanac map std::map gps_almanac_map; + std::map gal_almanac_map; // ionospheric model Gps_Iono gps_iono; + Galileo_Iono gal_iono; // reference time - Gps_Ref_Time gps_time; + Agnss_Ref_Time gps_time; // UTC model Gps_Utc_Model gps_utc; + Galileo_Utc_Model gal_utc; + Gps_CNAV_Utc_Model gps_cnav_utc; + Glonass_Gnav_Utc_Model glo_gnav_utc; // reference location - Gps_Ref_Location gps_ref_loc; + Agnss_Ref_Location gps_ref_loc; // Acquisition Assistance map std::map gps_acq_map; @@ -107,67 +124,158 @@ public: void read_supl_data(); /*! - * \brief Read ephemeris map from XML file + * \brief Read GPS NAV ephemeris map from XML file */ - bool load_ephemeris_xml(const std::string file_name); + bool load_ephemeris_xml(const std::string& file_name); /*! * \brief Save ephemeris map to XML file. */ - bool save_ephemeris_map_xml(const std::string file_name, + bool save_ephemeris_map_xml(const std::string& file_name, std::map eph_map); /*! - * \brief Read utc model from XML file + * \brief Read GPS CNAV ephemeris map from XML file */ - bool load_utc_xml(const std::string file_name); + bool load_cnav_ephemeris_xml(const std::string& file_name); /*! - * \brief Save utc model map to XML file - * To be called by ControlThread::gps_utc_model_data_write_to_XML() + * \brief Save GPS CNAV ephemeris map to XML file. */ - bool save_utc_map_xml(const std::string file_name, - std::map utc_map); + bool save_cnav_ephemeris_map_xml(const std::string file_name, + std::map eph_map); + + /*! + * \brief Read Galileo ephemeris map from XML file + */ + bool load_gal_ephemeris_xml(const std::string& file_name); + + /*! + * \brief Save Galileo ephemeris map to XML file. + */ + bool save_gal_ephemeris_map_xml(const std::string file_name, + std::map eph_map); + + /*! + * \brief Read GLONASS GNAV ephemeris map from XML file + */ + bool load_gnav_ephemeris_xml(const std::string& file_name); + + /*! + * \brief Save GLONASS GNAV ephemeris map to XML file. + */ + bool save_gnav_ephemeris_map_xml(const std::string file_name, + std::map eph_map); + + /*! + * \brief Read GPS utc model from XML file + */ + bool load_utc_xml(const std::string& file_name); + + /*! + * \brief Save UTC model map to XML file + */ + bool save_utc_xml(const std::string& file_name, Gps_Utc_Model& utc); + + /*! + * \brief Read CNAV GPS utc model from XML file + */ + bool load_cnav_utc_xml(const std::string& file_name); + + /*! + * \brief Save CNAV UTC model map to XML file + */ + bool save_cnav_utc_xml(const std::string& file_name, Gps_CNAV_Utc_Model& utc); + + /*! + * \brief Read Galileo utc model from XML file + */ + bool load_gal_utc_xml(const std::string& file_name); + + /*! + * \brief Save Galileo UTC model map to XML file + */ + bool save_gal_utc_xml(const std::string& file_name, Galileo_Utc_Model& utc); + + /*! + * \brief Read Galileo almanac map from XML file + */ + bool load_gal_almanac_xml(const std::string& file_name); + + /*! + * \brief Save Galileo almanac map to XML file + */ + bool save_gal_almanac_xml(const std::string& file_name, std::map gal_almanac); + + /*! + * \brief Read GPS almanac map from XML file + */ + bool load_gps_almanac_xml(const std::string& file_name); + + /*! + * \brief Save GPS almanac map to XML file + */ + bool save_gps_almanac_xml(const std::string& file_name, std::map gps_almanac_map); /*! * \brief Read iono from XML file */ - bool load_iono_xml(const std::string file_name); + bool load_iono_xml(const std::string& file_name); /*! * \brief Save iono map to XML file */ - bool save_iono_map_xml(const std::string file_name, - std::map iono_map); + bool save_iono_xml(const std::string& file_name, Gps_Iono& iono); + + /*! + * \brief Read Galileo iono from XML file + */ + bool load_gal_iono_xml(const std::string& file_name); + + /*! + * \brief Save Galileo iono map to XML file + */ + bool save_gal_iono_xml(const std::string& file_name, Galileo_Iono& iono); + + /*! + * \brief Read Glonass utc model from XML file + */ + bool load_glo_utc_xml(const std::string& file_name); + + /*! + * \brief Save Glonass UTC model map to XML file + */ + bool save_glo_utc_xml(const std::string& file_name, Glonass_Gnav_Utc_Model& utc); /*! * \brief Read ref time from XML file */ - bool load_ref_time_xml(const std::string file_name); + bool load_ref_time_xml(const std::string& file_name); /*! * \brief Save ref time map to XML file */ - bool save_ref_time_map_xml(const std::string file_name, - std::map ref_time_map); + bool save_ref_time_xml(const std::string& file_name, + Agnss_Ref_Time& ref_time_map); /*! * \brief Read ref location from XML file */ - bool load_ref_location_xml(const std::string file_name); + bool load_ref_location_xml(const std::string& file_name); /*! * \brief Save ref location map to XML file */ - bool save_ref_location_map_xml(std::string file_name, - std::map ref_location_map); + bool save_ref_location_xml(const std::string& file_name, + Agnss_Ref_Location& ref_location); /* * Prints SUPL data to std::cout. Use it for debug purposes only. */ void print_assistance(); - gnss_sdr_supl_client(); - ~gnss_sdr_supl_client(); + + Gnss_Sdr_Supl_Client(); + ~Gnss_Sdr_Supl_Client(); }; #endif diff --git a/src/core/libs/ini.cc b/src/core/libs/ini.cc index 49991e57f..17506e56e 100644 --- a/src/core/libs/ini.cc +++ b/src/core/libs/ini.cc @@ -68,7 +68,9 @@ static char* rstrip(char* s) { char* p = s + std::char_traits::length(s); while (p > s && isspace(*--p)) - *p = '\0'; + { + *p = '\0'; + } return s; } @@ -76,7 +78,9 @@ static char* rstrip(char* s) static char* lskip(char* s) { while (*s && isspace(*s)) - s++; + { + s++; + } return static_cast(s); } @@ -85,7 +89,9 @@ static char* lskip(char* s) static char* find_char_or_comment(char* s, char c) { while (*s && *s != c && *s != ';') - s++; + { + s++; + } return static_cast(s); } @@ -121,7 +127,9 @@ int ini_parse(const char* filename, file.open(filename, std::fstream::in); if (!file.is_open()) - return -1; + { + return -1; + } /* Scan through file line by line */ while (std::getline(file, line_str)) @@ -129,7 +137,10 @@ int ini_parse(const char* filename, lineno++; int len_str = line_str.length(); const char* read_line = line_str.data(); - if (len_str > (MAX_LINE - 1)) len_str = MAX_LINE - 1; + if (len_str > (MAX_LINE - 1)) + { + len_str = MAX_LINE - 1; + } int i; for (i = 0; i < len_str; i++) { @@ -144,7 +155,9 @@ int ini_parse(const char* filename, /* Non-black line with leading whitespace, treat as continuation of previous name's value (as per Python ConfigParser). */ if (!handler(user, section, prev_name, start) && !error) - error = lineno; + { + error = lineno; + } } else #endif @@ -175,13 +188,17 @@ int ini_parse(const char* filename, value = lskip(end + 1); end = find_char_or_comment(value, ';'); if (*end == ';') - *end = '\0'; + { + *end = '\0'; + } rstrip(value); /* Valid name=value pair found, call handler */ strncpy0(prev_name, name, sizeof(prev_name)); if (!handler(user, section, name, value) && !error) - error = lineno; + { + error = lineno; + } } else if (!error) { diff --git a/src/core/libs/string_converter.cc b/src/core/libs/string_converter.cc index 15360400d..ab84dab07 100644 --- a/src/core/libs/string_converter.cc +++ b/src/core/libs/string_converter.cc @@ -34,46 +34,60 @@ #include -StringConverter::StringConverter() {} +StringConverter::StringConverter() = default; + + +StringConverter::~StringConverter() = default; -StringConverter::~StringConverter() {} bool StringConverter::convert(const std::string& value, bool default_value) { - if (value.compare("true") == 0) + if (value == "true") { return true; } - else if (value.compare("false") == 0) + if (value == "false") { return false; } - else - { - return default_value; - } + + return default_value; } -long StringConverter::convert(const std::string& value, long default_value) +int64_t StringConverter::convert(const std::string& value, int64_t default_value) { std::stringstream stream(value); - long result; + int64_t result; stream >> result; if (stream.fail()) { return default_value; } - else - { - return result; - } + + return result; } -int StringConverter::convert(const std::string& value, int default_value) +uint64_t StringConverter::convert(const std::string& value, uint64_t default_value) +{ + std::stringstream stream(value); + + uint64_t result; + stream >> result; + + if (stream.fail()) + { + return default_value; + } + + return result; +} + + +int32_t StringConverter::convert(const std::string& value, int32_t default_value) { std::stringstream stream(value); @@ -84,46 +98,56 @@ int StringConverter::convert(const std::string& value, int default_value) { return default_value; } - else - { - return result; - } + + return result; } -unsigned int StringConverter::convert(const std::string& value, unsigned int default_value) +uint32_t StringConverter::convert(const std::string& value, uint32_t default_value) { std::stringstream stream(value); - unsigned int result; + uint32_t result; stream >> result; if (stream.fail()) { return default_value; } - else - { - return result; - } + + return result; } -unsigned short StringConverter::convert(const std::string& value, unsigned short default_value) +uint16_t StringConverter::convert(const std::string& value, uint16_t default_value) { std::stringstream stream(value); - unsigned short result; + uint16_t result; stream >> result; if (stream.fail()) { return default_value; } - else + + return result; +} + + +int16_t StringConverter::convert(const std::string& value, int16_t default_value) +{ + std::stringstream stream(value); + + int16_t result; + stream >> result; + + if (stream.fail()) { - return result; + return default_value; } + + return result; } @@ -138,10 +162,8 @@ float StringConverter::convert(const std::string& value, float default_value) { return default_value; } - else - { - return result; - } + + return result; } @@ -156,8 +178,6 @@ double StringConverter::convert(const std::string& value, double default_value) { return default_value; } - else - { - return result; - } + + return result; } diff --git a/src/core/libs/string_converter.h b/src/core/libs/string_converter.h index c1a480a78..1514db265 100644 --- a/src/core/libs/string_converter.h +++ b/src/core/libs/string_converter.h @@ -33,6 +33,7 @@ #ifndef GNSS_SDR_STRING_CONVERTER_H_ #define GNSS_SDR_STRING_CONVERTER_H_ +#include #include /*! @@ -46,10 +47,12 @@ public: virtual ~StringConverter(); bool convert(const std::string& value, bool default_value); - long convert(const std::string& value, long default_value); - int convert(const std::string& value, int default_value); - unsigned int convert(const std::string& value, unsigned int default_value); - unsigned short convert(const std::string& value, unsigned short default_value); + int64_t convert(const std::string& value, int64_t default_value); + uint64_t convert(const std::string& value, uint64_t default_value); + int32_t convert(const std::string& value, int32_t default_value); + uint32_t convert(const std::string& value, uint32_t default_value); + int16_t convert(const std::string& value, int16_t default_value); + uint16_t convert(const std::string& value, uint16_t default_value); float convert(const std::string& value, float default_value); double convert(const std::string& value, double default_value); }; diff --git a/src/core/libs/supl/CMakeLists.txt b/src/core/libs/supl/CMakeLists.txt index 6d0edd576..449c49b48 100644 --- a/src/core/libs/supl/CMakeLists.txt +++ b/src/core/libs/supl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -21,31 +21,39 @@ list(SORT ASN_RRLP_SOURCES) file(GLOB ASN_SUPL_SOURCES "${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl/*.c") list(SORT ASN_SUPL_SOURCES) -set (SUPL_SOURCES - supl.c - ) - -if(OPENSSL_FOUND) - add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) -endif(OPENSSL_FOUND) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/libs/supl - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl - ${GNUTLS_INCLUDE_DIR} - ) +set(SUPL_SOURCES + supl.c +) if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(CMAKE_BUILD_TYPE MATCHES "Release") - set(MY_C_FLAGS "${MY_C_FLAGS} -Wno-parentheses-equality") - endif(CMAKE_BUILD_TYPE MATCHES "Release") -endif(CMAKE_C_COMPILER_ID MATCHES "Clang") + set(MY_C_FLAGS "${MY_C_FLAGS} -Wno-parentheses-equality") + endif() +endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_FLAGS}") -add_library (supl_library STATIC ${ASN_RRLP_SOURCES} ${ASN_SUPL_SOURCES} ${SUPL_SOURCES}) -target_link_libraries (supl_library ${GNUTLS_LIBRARIES} ${GNUTLS_OPENSSL_LIBRARY} gnss_system_parameters) -set_target_properties(supl_library PROPERTIES LINKER_LANGUAGE C) +add_library(core_libs_supl STATIC ${ASN_RRLP_SOURCES} ${ASN_SUPL_SOURCES} ${SUPL_SOURCES}) +if(OPENSSL_FOUND) + target_compile_definitions(core_libs_supl PUBLIC -DUSE_OPENSSL_FALLBACK=1) +endif() +target_link_libraries(core_libs_supl + PUBLIC + ${GNUTLS_LIBRARIES} + ${GNUTLS_OPENSSL_LIBRARY} +) + +target_include_directories(core_libs_supl + PUBLIC + ${GNUTLS_INCLUDE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl + ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp +) + +set_target_properties(core_libs_supl PROPERTIES + LINKER_LANGUAGE C + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl;${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp;${GNUTLS_INCLUDE_DIR}" +) diff --git a/src/core/libs/supl/asn-rrlp/Accuracy.c b/src/core/libs/supl/asn-rrlp/Accuracy.c index b3609c7ef..a51a2e12c 100644 --- a/src/core/libs/supl/asn-rrlp/Accuracy.c +++ b/src/core/libs/supl/asn-rrlp/Accuracy.c @@ -111,7 +111,7 @@ Accuracy_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_Accuracy_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ACCURACY_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_Accuracy = { asn_DEF_Accuracy_tags_1, /* Same as above */ sizeof(asn_DEF_Accuracy_tags_1) /sizeof(asn_DEF_Accuracy_tags_1[0]), /* 1 */ - &asn_PER_type_Accuracy_constr_1, + &ASN_PER_TYPE_ACCURACY_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/AcquisElement.c b/src/core/libs/supl/asn-rrlp/AcquisElement.c index 506e7ad3a..a3fd8b936 100644 --- a/src/core/libs/supl/asn-rrlp/AcquisElement.c +++ b/src/core/libs/supl/asn-rrlp/AcquisElement.c @@ -131,27 +131,27 @@ memb_codePhaseSearchWindow_constraint_1(asn_TYPE_descriptor_t *td, const void *s } } -static asn_per_constraints_t asn_PER_memb_doppler0_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER0_CONSTR_3 = { { APC_CONSTRAINED, 12, 12, -2048, 2047 } /* (-2048..2047) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_codePhase_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_CODE_PHASE_CONSTR_5 = { { APC_CONSTRAINED, 10, 10, 0, 1022 } /* (0..1022) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_intCodePhase_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_INT_CODE_PHASE_CONSTR_6 = { { APC_CONSTRAINED, 5, 5, 0, 19 } /* (0..19) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_gpsBitNumber_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_GPS_BIT_NUMBER_CONSTR_7 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_codePhaseSearchWindow_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_CODE_PHASE_SEARCH_WINDOW_CONSTR_8 = { { APC_CONSTRAINED, 4, 4, 0, 15 } /* (0..15) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -171,7 +171,7 @@ static asn_TYPE_member_t asn_MBR_AcquisElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_doppler0_constraint_1, - &asn_PER_memb_doppler0_constr_3, + &ASN_PER_MEMB_DOPPLER0_CONSTR_3, 0, "doppler0" }, @@ -189,7 +189,7 @@ static asn_TYPE_member_t asn_MBR_AcquisElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_codePhase_constraint_1, - &asn_PER_memb_codePhase_constr_5, + &ASN_PER_MEMB_CODE_PHASE_CONSTR_5, 0, "codePhase" }, @@ -198,7 +198,7 @@ static asn_TYPE_member_t asn_MBR_AcquisElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_intCodePhase_constraint_1, - &asn_PER_memb_intCodePhase_constr_6, + &ASN_PER_MEMB_INT_CODE_PHASE_CONSTR_6, 0, "intCodePhase" }, @@ -207,7 +207,7 @@ static asn_TYPE_member_t asn_MBR_AcquisElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_gpsBitNumber_constraint_1, - &asn_PER_memb_gpsBitNumber_constr_7, + &ASN_PER_MEMB_GPS_BIT_NUMBER_CONSTR_7, 0, "gpsBitNumber" }, @@ -216,7 +216,7 @@ static asn_TYPE_member_t asn_MBR_AcquisElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_codePhaseSearchWindow_constraint_1, - &asn_PER_memb_codePhaseSearchWindow_constr_8, + &ASN_PER_MEMB_CODE_PHASE_SEARCH_WINDOW_CONSTR_8, 0, "codePhaseSearchWindow" }, diff --git a/src/core/libs/supl/asn-rrlp/AddionalAngleFields.c b/src/core/libs/supl/asn-rrlp/AddionalAngleFields.c index 5de86fe61..d7a16c0a0 100644 --- a/src/core/libs/supl/asn-rrlp/AddionalAngleFields.c +++ b/src/core/libs/supl/asn-rrlp/AddionalAngleFields.c @@ -56,12 +56,12 @@ memb_elevation_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_azimuth_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_AZIMUTH_CONSTR_2 = { { APC_CONSTRAINED, 5, 5, 0, 31 } /* (0..31) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_elevation_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_ELEVATION_CONSTR_3 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_AddionalAngleFields_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_azimuth_constraint_1, - &asn_PER_memb_azimuth_constr_2, + &ASN_PER_MEMB_AZIMUTH_CONSTR_2, 0, "azimuth" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_AddionalAngleFields_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_elevation_constraint_1, - &asn_PER_memb_elevation_constr_3, + &ASN_PER_MEMB_ELEVATION_CONSTR_3, 0, "elevation" }, diff --git a/src/core/libs/supl/asn-rrlp/AddionalDopplerFields.c b/src/core/libs/supl/asn-rrlp/AddionalDopplerFields.c index 4b0b58a30..69f732dbb 100644 --- a/src/core/libs/supl/asn-rrlp/AddionalDopplerFields.c +++ b/src/core/libs/supl/asn-rrlp/AddionalDopplerFields.c @@ -56,12 +56,12 @@ memb_dopplerUncertainty_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr } } -static asn_per_constraints_t asn_PER_memb_doppler1_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER1_CONSTR_2 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_dopplerUncertainty_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER_UNCERTAINTY_CONSTR_3 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_AddionalDopplerFields_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_doppler1_constraint_1, - &asn_PER_memb_doppler1_constr_2, + &ASN_PER_MEMB_DOPPLER1_CONSTR_2, 0, "doppler1" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_AddionalDopplerFields_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_dopplerUncertainty_constraint_1, - &asn_PER_memb_dopplerUncertainty_constr_3, + &ASN_PER_MEMB_DOPPLER_UNCERTAINTY_CONSTR_3, 0, "dopplerUncertainty" }, diff --git a/src/core/libs/supl/asn-rrlp/AdditionalDopplerFields.c b/src/core/libs/supl/asn-rrlp/AdditionalDopplerFields.c index e62840073..3dbce8753 100644 --- a/src/core/libs/supl/asn-rrlp/AdditionalDopplerFields.c +++ b/src/core/libs/supl/asn-rrlp/AdditionalDopplerFields.c @@ -56,12 +56,12 @@ memb_dopplerUncertainty_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr } } -static asn_per_constraints_t asn_PER_memb_doppler1_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER1_CONSTR_2 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_dopplerUncertainty_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER_UNCERTAINTY_CONSTR_3 = { { APC_CONSTRAINED, 3, 3, 0, 4 } /* (0..4) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_AdditionalDopplerFields_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_doppler1_constraint_1, - &asn_PER_memb_doppler1_constr_2, + &ASN_PER_MEMB_DOPPLER1_CONSTR_2, 0, "doppler1" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_AdditionalDopplerFields_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_dopplerUncertainty_constraint_1, - &asn_PER_memb_dopplerUncertainty_constr_3, + &ASN_PER_MEMB_DOPPLER_UNCERTAINTY_CONSTR_3, 0, "dopplerUncertainty" }, diff --git a/src/core/libs/supl/asn-rrlp/AlertFlag.c b/src/core/libs/supl/asn-rrlp/AlertFlag.c index 52eaeeadb..a7c3f41eb 100644 --- a/src/core/libs/supl/asn-rrlp/AlertFlag.c +++ b/src/core/libs/supl/asn-rrlp/AlertFlag.c @@ -111,7 +111,7 @@ AlertFlag_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_AlertFlag_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ALERT_FLAG_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_AlertFlag = { asn_DEF_AlertFlag_tags_1, /* Same as above */ sizeof(asn_DEF_AlertFlag_tags_1) /sizeof(asn_DEF_AlertFlag_tags_1[0]), /* 1 */ - &asn_PER_type_AlertFlag_constr_1, + &ASN_PER_TYPE_ALERT_FLAG_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/Almanac-KeplerianSet.c b/src/core/libs/supl/asn-rrlp/Almanac-KeplerianSet.c index c63036c97..2093a44e6 100644 --- a/src/core/libs/supl/asn-rrlp/Almanac-KeplerianSet.c +++ b/src/core/libs/supl/asn-rrlp/Almanac-KeplerianSet.c @@ -256,52 +256,52 @@ memb_kepAlmanacAF1_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_kepAlmanacE_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_E_CONSTR_2 = { { APC_CONSTRAINED, 11, 11, 0, 2047 } /* (0..2047) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacDeltaI_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_DELTA_I_CONSTR_3 = { { APC_CONSTRAINED, 11, 11, -1024, 1023 } /* (-1024..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacOmegaDot_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_OMEGA_DOT_CONSTR_4 = { { APC_CONSTRAINED, 11, 11, -1024, 1023 } /* (-1024..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepSVHealth_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_SV_HEALTH_CONSTR_5 = { { APC_CONSTRAINED, 4, 4, 0, 15 } /* (0..15) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacAPowerHalf_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_A_POWER_HALF_CONSTR_6 = { { APC_CONSTRAINED, 17, -1, -65536, 65535 } /* (-65536..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacOmega0_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_OMEGA0_CONSTR_7 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacW_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_W_CONSTR_8 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacM0_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_M0_CONSTR_9 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacAF0_constr_10 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_A_F0_CONSTR_10 = { { APC_CONSTRAINED, 14, 14, -8192, 8191 } /* (-8192..8191) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_kepAlmanacAF1_constr_11 = { +static asn_per_constraints_t ASN_PER_MEMB_KEP_ALMANAC_A_F1_CONSTR_11 = { { APC_CONSTRAINED, 11, 11, -1024, 1023 } /* (-1024..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -312,7 +312,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacE_constraint_1, - &asn_PER_memb_kepAlmanacE_constr_2, + &ASN_PER_MEMB_KEP_ALMANAC_E_CONSTR_2, 0, "kepAlmanacE" }, @@ -321,7 +321,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacDeltaI_constraint_1, - &asn_PER_memb_kepAlmanacDeltaI_constr_3, + &ASN_PER_MEMB_KEP_ALMANAC_DELTA_I_CONSTR_3, 0, "kepAlmanacDeltaI" }, @@ -330,7 +330,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacOmegaDot_constraint_1, - &asn_PER_memb_kepAlmanacOmegaDot_constr_4, + &ASN_PER_MEMB_KEP_ALMANAC_OMEGA_DOT_CONSTR_4, 0, "kepAlmanacOmegaDot" }, @@ -339,7 +339,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepSVHealth_constraint_1, - &asn_PER_memb_kepSVHealth_constr_5, + &ASN_PER_MEMB_KEP_SV_HEALTH_CONSTR_5, 0, "kepSVHealth" }, @@ -348,7 +348,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacAPowerHalf_constraint_1, - &asn_PER_memb_kepAlmanacAPowerHalf_constr_6, + &ASN_PER_MEMB_KEP_ALMANAC_A_POWER_HALF_CONSTR_6, 0, "kepAlmanacAPowerHalf" }, @@ -357,7 +357,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacOmega0_constraint_1, - &asn_PER_memb_kepAlmanacOmega0_constr_7, + &ASN_PER_MEMB_KEP_ALMANAC_OMEGA0_CONSTR_7, 0, "kepAlmanacOmega0" }, @@ -366,7 +366,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacW_constraint_1, - &asn_PER_memb_kepAlmanacW_constr_8, + &ASN_PER_MEMB_KEP_ALMANAC_W_CONSTR_8, 0, "kepAlmanacW" }, @@ -375,7 +375,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacM0_constraint_1, - &asn_PER_memb_kepAlmanacM0_constr_9, + &ASN_PER_MEMB_KEP_ALMANAC_M0_CONSTR_9, 0, "kepAlmanacM0" }, @@ -384,7 +384,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacAF0_constraint_1, - &asn_PER_memb_kepAlmanacAF0_constr_10, + &ASN_PER_MEMB_KEP_ALMANAC_A_F0_CONSTR_10, 0, "kepAlmanacAF0" }, @@ -393,7 +393,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_kepAlmanacAF1_constraint_1, - &asn_PER_memb_kepAlmanacAF1_constr_11, + &ASN_PER_MEMB_KEP_ALMANAC_A_F1_CONSTR_11, 0, "kepAlmanacAF1" }, diff --git a/src/core/libs/supl/asn-rrlp/Almanac.c b/src/core/libs/supl/asn-rrlp/Almanac.c index a886c36b9..7f829283d 100644 --- a/src/core/libs/supl/asn-rrlp/Almanac.c +++ b/src/core/libs/supl/asn-rrlp/Almanac.c @@ -31,7 +31,7 @@ memb_alamanacWNa_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_alamanacWNa_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_ALAMANAC_W_NA_CONSTR_2 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_Almanac_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_alamanacWNa_constraint_1, - &asn_PER_memb_alamanacWNa_constr_2, + &ASN_PER_MEMB_ALAMANAC_W_NA_CONSTR_2, 0, "alamanacWNa" }, diff --git a/src/core/libs/supl/asn-rrlp/AlmanacElement.c b/src/core/libs/supl/asn-rrlp/AlmanacElement.c index 702107187..848ba0af8 100644 --- a/src/core/libs/supl/asn-rrlp/AlmanacElement.c +++ b/src/core/libs/supl/asn-rrlp/AlmanacElement.c @@ -281,57 +281,57 @@ memb_almanacAF1_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_almanacE_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_E_CONSTR_3 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_alamanacToa_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_ALAMANAC_TOA_CONSTR_4 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacKsii_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_KSII_CONSTR_5 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacOmegaDot_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_OMEGA_DOT_CONSTR_6 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacSVhealth_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_S_VHEALTH_CONSTR_7 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacAPowerHalf_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_A_POWER_HALF_CONSTR_8 = { { APC_CONSTRAINED, 24, -1, 0, 16777215 } /* (0..16777215) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacOmega0_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_OMEGA0_CONSTR_9 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacW_constr_10 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_W_CONSTR_10 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacM0_constr_11 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_M0_CONSTR_11 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacAF0_constr_12 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_A_F0_CONSTR_12 = { { APC_CONSTRAINED, 11, 11, -1024, 1023 } /* (-1024..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_almanacAF1_constr_13 = { +static asn_per_constraints_t ASN_PER_MEMB_ALMANAC_A_F1_CONSTR_13 = { { APC_CONSTRAINED, 11, 11, -1024, 1023 } /* (-1024..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -351,7 +351,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacE_constraint_1, - &asn_PER_memb_almanacE_constr_3, + &ASN_PER_MEMB_ALMANAC_E_CONSTR_3, 0, "almanacE" }, @@ -360,7 +360,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_alamanacToa_constraint_1, - &asn_PER_memb_alamanacToa_constr_4, + &ASN_PER_MEMB_ALAMANAC_TOA_CONSTR_4, 0, "alamanacToa" }, @@ -369,7 +369,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacKsii_constraint_1, - &asn_PER_memb_almanacKsii_constr_5, + &ASN_PER_MEMB_ALMANAC_KSII_CONSTR_5, 0, "almanacKsii" }, @@ -378,7 +378,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacOmegaDot_constraint_1, - &asn_PER_memb_almanacOmegaDot_constr_6, + &ASN_PER_MEMB_ALMANAC_OMEGA_DOT_CONSTR_6, 0, "almanacOmegaDot" }, @@ -387,7 +387,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacSVhealth_constraint_1, - &asn_PER_memb_almanacSVhealth_constr_7, + &ASN_PER_MEMB_ALMANAC_S_VHEALTH_CONSTR_7, 0, "almanacSVhealth" }, @@ -396,7 +396,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacAPowerHalf_constraint_1, - &asn_PER_memb_almanacAPowerHalf_constr_8, + &ASN_PER_MEMB_ALMANAC_A_POWER_HALF_CONSTR_8, 0, "almanacAPowerHalf" }, @@ -405,7 +405,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacOmega0_constraint_1, - &asn_PER_memb_almanacOmega0_constr_9, + &ASN_PER_MEMB_ALMANAC_OMEGA0_CONSTR_9, 0, "almanacOmega0" }, @@ -414,7 +414,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacW_constraint_1, - &asn_PER_memb_almanacW_constr_10, + &ASN_PER_MEMB_ALMANAC_W_CONSTR_10, 0, "almanacW" }, @@ -423,7 +423,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacM0_constraint_1, - &asn_PER_memb_almanacM0_constr_11, + &ASN_PER_MEMB_ALMANAC_M0_CONSTR_11, 0, "almanacM0" }, @@ -432,7 +432,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacAF0_constraint_1, - &asn_PER_memb_almanacAF0_constr_12, + &ASN_PER_MEMB_ALMANAC_A_F0_CONSTR_12, 0, "almanacAF0" }, @@ -441,7 +441,7 @@ static asn_TYPE_member_t asn_MBR_AlmanacElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_almanacAF1_constraint_1, - &asn_PER_memb_almanacAF1_constr_13, + &ASN_PER_MEMB_ALMANAC_A_F1_CONSTR_13, 0, "almanacAF1" }, diff --git a/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c b/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c index 5b1d648b8..353a6d2c9 100644 --- a/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c +++ b/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c @@ -111,7 +111,7 @@ AntiSpoofFlag_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_AntiSpoofFlag_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ANTI_SPOOF_FLAG_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_AntiSpoofFlag = { asn_DEF_AntiSpoofFlag_tags_1, /* Same as above */ sizeof(asn_DEF_AntiSpoofFlag_tags_1) /sizeof(asn_DEF_AntiSpoofFlag_tags_1[0]), /* 1 */ - &asn_PER_type_AntiSpoofFlag_constr_1, + &ASN_PER_TYPE_ANTI_SPOOF_FLAG_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/BCCHCarrier.c b/src/core/libs/supl/asn-rrlp/BCCHCarrier.c index 72388ca5b..b6e340cfb 100644 --- a/src/core/libs/supl/asn-rrlp/BCCHCarrier.c +++ b/src/core/libs/supl/asn-rrlp/BCCHCarrier.c @@ -111,7 +111,7 @@ BCCHCarrier_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_BCCHCarrier_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_BCCH_CARRIER_CONSTR_1 = { { APC_CONSTRAINED, 10, 10, 0, 1023 } /* (0..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_BCCHCarrier = { asn_DEF_BCCHCarrier_tags_1, /* Same as above */ sizeof(asn_DEF_BCCHCarrier_tags_1) /sizeof(asn_DEF_BCCHCarrier_tags_1[0]), /* 1 */ - &asn_PER_type_BCCHCarrier_constr_1, + &ASN_PER_TYPE_BCCH_CARRIER_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/BSIC.c b/src/core/libs/supl/asn-rrlp/BSIC.c index 378aac7ab..de1ed2b8f 100644 --- a/src/core/libs/supl/asn-rrlp/BSIC.c +++ b/src/core/libs/supl/asn-rrlp/BSIC.c @@ -111,7 +111,7 @@ BSIC_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_BSIC_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_BSIC_CONSTR_1 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_BSIC = { asn_DEF_BSIC_tags_1, /* Same as above */ sizeof(asn_DEF_BSIC_tags_1) /sizeof(asn_DEF_BSIC_tags_1[0]), /* 1 */ - &asn_PER_type_BSIC_constr_1, + &ASN_PER_TYPE_BSIC_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/BadSignalElement.c b/src/core/libs/supl/asn-rrlp/BadSignalElement.c index b0ff80566..e162e0b3d 100644 --- a/src/core/libs/supl/asn-rrlp/BadSignalElement.c +++ b/src/core/libs/supl/asn-rrlp/BadSignalElement.c @@ -31,7 +31,7 @@ memb_badSignalID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_badSignalID_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_BAD_SIGNAL_ID_CONSTR_3 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -51,7 +51,7 @@ static asn_TYPE_member_t asn_MBR_BadSignalElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_badSignalID_constraint_1, - &asn_PER_memb_badSignalID_constr_3, + &ASN_PER_MEMB_BAD_SIGNAL_ID_CONSTR_3, 0, "badSignalID" }, diff --git a/src/core/libs/supl/asn-rrlp/BitNumber.c b/src/core/libs/supl/asn-rrlp/BitNumber.c index 36c17f637..0a430f9fa 100644 --- a/src/core/libs/supl/asn-rrlp/BitNumber.c +++ b/src/core/libs/supl/asn-rrlp/BitNumber.c @@ -111,7 +111,7 @@ BitNumber_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_BitNumber_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_BIT_NUMBER_CONSTR_1 = { { APC_CONSTRAINED, 8, 8, 0, 156 } /* (0..156) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_BitNumber = { asn_DEF_BitNumber_tags_1, /* Same as above */ sizeof(asn_DEF_BitNumber_tags_1) /sizeof(asn_DEF_BitNumber_tags_1[0]), /* 1 */ - &asn_PER_type_BitNumber_constr_1, + &ASN_PER_TYPE_BIT_NUMBER_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/CellID.c b/src/core/libs/supl/asn-rrlp/CellID.c index a66eca167..e412b5ff6 100644 --- a/src/core/libs/supl/asn-rrlp/CellID.c +++ b/src/core/libs/supl/asn-rrlp/CellID.c @@ -111,7 +111,7 @@ CellID_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_CellID_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_CELL_ID_CONSTR_1 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_CellID = { asn_DEF_CellID_tags_1, /* Same as above */ sizeof(asn_DEF_CellID_tags_1) /sizeof(asn_DEF_CellID_tags_1[0]), /* 1 */ - &asn_PER_type_CellID_constr_1, + &ASN_PER_TYPE_CELL_ID_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/DGANSSSgnElement.c b/src/core/libs/supl/asn-rrlp/DGANSSSgnElement.c index 96fd70a6e..8da024839 100644 --- a/src/core/libs/supl/asn-rrlp/DGANSSSgnElement.c +++ b/src/core/libs/supl/asn-rrlp/DGANSSSgnElement.c @@ -106,22 +106,22 @@ memb_rangeRateCor_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_iod_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_IOD_CONSTR_3 = { { APC_CONSTRAINED, 10, 10, 0, 1023 } /* (0..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_udre_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_UDRE_CONSTR_4 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_pseudoRangeCor_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_PSEUDO_RANGE_COR_CONSTR_5 = { { APC_CONSTRAINED, 12, 12, -2047, 2047 } /* (-2047..2047) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_rangeRateCor_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_RANGE_RATE_COR_CONSTR_6 = { { APC_CONSTRAINED, 8, 8, -127, 127 } /* (-127..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_DGANSSSgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_iod_constraint_1, - &asn_PER_memb_iod_constr_3, + &ASN_PER_MEMB_IOD_CONSTR_3, 0, "iod" }, @@ -150,7 +150,7 @@ static asn_TYPE_member_t asn_MBR_DGANSSSgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_udre_constraint_1, - &asn_PER_memb_udre_constr_4, + &ASN_PER_MEMB_UDRE_CONSTR_4, 0, "udre" }, @@ -159,7 +159,7 @@ static asn_TYPE_member_t asn_MBR_DGANSSSgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_pseudoRangeCor_constraint_1, - &asn_PER_memb_pseudoRangeCor_constr_5, + &ASN_PER_MEMB_PSEUDO_RANGE_COR_CONSTR_5, 0, "pseudoRangeCor" }, @@ -168,7 +168,7 @@ static asn_TYPE_member_t asn_MBR_DGANSSSgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_rangeRateCor_constraint_1, - &asn_PER_memb_rangeRateCor_constr_6, + &ASN_PER_MEMB_RANGE_RATE_COR_CONSTR_6, 0, "rangeRateCor" }, diff --git a/src/core/libs/supl/asn-rrlp/DGPSCorrections.c b/src/core/libs/supl/asn-rrlp/DGPSCorrections.c index 781d41f61..7fa907db6 100644 --- a/src/core/libs/supl/asn-rrlp/DGPSCorrections.c +++ b/src/core/libs/supl/asn-rrlp/DGPSCorrections.c @@ -56,12 +56,12 @@ memb_status_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_gpsTOW_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GPS_TOW_CONSTR_2 = { { APC_CONSTRAINED, 20, -1, 0, 604799 } /* (0..604799) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_status_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_STATUS_CONSTR_3 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_DGPSCorrections_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_gpsTOW_constraint_1, - &asn_PER_memb_gpsTOW_constr_2, + &ASN_PER_MEMB_GPS_TOW_CONSTR_2, 0, "gpsTOW" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_DGPSCorrections_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_status_constraint_1, - &asn_PER_memb_status_constr_3, + &ASN_PER_MEMB_STATUS_CONSTR_3, 0, "status" }, diff --git a/src/core/libs/supl/asn-rrlp/EOTDQuality.c b/src/core/libs/supl/asn-rrlp/EOTDQuality.c index 17fcacfe8..8e4454834 100644 --- a/src/core/libs/supl/asn-rrlp/EOTDQuality.c +++ b/src/core/libs/supl/asn-rrlp/EOTDQuality.c @@ -56,12 +56,12 @@ memb_stdOfEOTD_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_nbrOfMeasurements_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_NBR_OF_MEASUREMENTS_CONSTR_2 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_stdOfEOTD_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_STD_OF_EOTD_CONSTR_3 = { { APC_CONSTRAINED, 5, 5, 0, 31 } /* (0..31) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_EOTDQuality_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_nbrOfMeasurements_constraint_1, - &asn_PER_memb_nbrOfMeasurements_constr_2, + &ASN_PER_MEMB_NBR_OF_MEASUREMENTS_CONSTR_2, 0, "nbrOfMeasurements" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_EOTDQuality_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stdOfEOTD_constraint_1, - &asn_PER_memb_stdOfEOTD_constr_3, + &ASN_PER_MEMB_STD_OF_EOTD_CONSTR_3, 0, "stdOfEOTD" }, diff --git a/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c b/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c index d3d05c10f..18e996518 100644 --- a/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c +++ b/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c @@ -94,7 +94,7 @@ EnvironmentCharacter_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_EnvironmentCharacter_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ENVIRONMENT_CHARACTER_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -142,7 +142,7 @@ asn_TYPE_descriptor_t asn_DEF_EnvironmentCharacter = { asn_DEF_EnvironmentCharacter_tags_1, /* Same as above */ sizeof(asn_DEF_EnvironmentCharacter_tags_1) /sizeof(asn_DEF_EnvironmentCharacter_tags_1[0]), /* 1 */ - &asn_PER_type_EnvironmentCharacter_constr_1, + &ASN_PER_TYPE_ENVIRONMENT_CHARACTER_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_EnvironmentCharacter_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/EphemerisSubframe1Reserved.c b/src/core/libs/supl/asn-rrlp/EphemerisSubframe1Reserved.c index 5177a8615..00025f2af 100644 --- a/src/core/libs/supl/asn-rrlp/EphemerisSubframe1Reserved.c +++ b/src/core/libs/supl/asn-rrlp/EphemerisSubframe1Reserved.c @@ -106,22 +106,22 @@ memb_reserved4_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_reserved1_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_RESERVED1_CONSTR_2 = { { APC_CONSTRAINED, 23, -1, 0, 8388607 } /* (0..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_reserved2_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_RESERVED2_CONSTR_3 = { { APC_CONSTRAINED, 24, -1, 0, 16777215 } /* (0..16777215) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_reserved3_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_RESERVED3_CONSTR_4 = { { APC_CONSTRAINED, 24, -1, 0, 16777215 } /* (0..16777215) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_reserved4_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_RESERVED4_CONSTR_5 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -132,7 +132,7 @@ static asn_TYPE_member_t asn_MBR_EphemerisSubframe1Reserved_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_reserved1_constraint_1, - &asn_PER_memb_reserved1_constr_2, + &ASN_PER_MEMB_RESERVED1_CONSTR_2, 0, "reserved1" }, @@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_EphemerisSubframe1Reserved_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_reserved2_constraint_1, - &asn_PER_memb_reserved2_constr_3, + &ASN_PER_MEMB_RESERVED2_CONSTR_3, 0, "reserved2" }, @@ -150,7 +150,7 @@ static asn_TYPE_member_t asn_MBR_EphemerisSubframe1Reserved_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_reserved3_constraint_1, - &asn_PER_memb_reserved3_constr_4, + &ASN_PER_MEMB_RESERVED3_CONSTR_4, 0, "reserved3" }, @@ -159,7 +159,7 @@ static asn_TYPE_member_t asn_MBR_EphemerisSubframe1Reserved_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_reserved4_constraint_1, - &asn_PER_memb_reserved4_constr_5, + &ASN_PER_MEMB_RESERVED4_CONSTR_5, 0, "reserved4" }, diff --git a/src/core/libs/supl/asn-rrlp/ErrorCodes.c b/src/core/libs/supl/asn-rrlp/ErrorCodes.c index d8b61e5d2..f8def1e38 100644 --- a/src/core/libs/supl/asn-rrlp/ErrorCodes.c +++ b/src/core/libs/supl/asn-rrlp/ErrorCodes.c @@ -94,7 +94,7 @@ ErrorCodes_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_ErrorCodes_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ERROR_CODES_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 5 } /* (0..5,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -148,7 +148,7 @@ asn_TYPE_descriptor_t asn_DEF_ErrorCodes = { asn_DEF_ErrorCodes_tags_1, /* Same as above */ sizeof(asn_DEF_ErrorCodes_tags_1) /sizeof(asn_DEF_ErrorCodes_tags_1[0]), /* 1 */ - &asn_PER_type_ErrorCodes_constr_1, + &ASN_PER_TYPE_ERROR_CODES_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_ErrorCodes_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c b/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c index ff557e3d1..3f35cbf60 100644 --- a/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c +++ b/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c @@ -111,7 +111,7 @@ ExpOTDUncertainty_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_ExpOTDUncertainty_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_EXP_OTD_UNCERTAINTY_CONSTR_1 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_ExpOTDUncertainty = { asn_DEF_ExpOTDUncertainty_tags_1, /* Same as above */ sizeof(asn_DEF_ExpOTDUncertainty_tags_1) /sizeof(asn_DEF_ExpOTDUncertainty_tags_1[0]), /* 1 */ - &asn_PER_type_ExpOTDUncertainty_constr_1, + &ASN_PER_TYPE_EXP_OTD_UNCERTAINTY_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/ExpectedOTD.c b/src/core/libs/supl/asn-rrlp/ExpectedOTD.c index 947c22734..7b14272b0 100644 --- a/src/core/libs/supl/asn-rrlp/ExpectedOTD.c +++ b/src/core/libs/supl/asn-rrlp/ExpectedOTD.c @@ -111,7 +111,7 @@ ExpectedOTD_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_ExpectedOTD_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_EXPECTED_OTD_CONSTR_1 = { { APC_CONSTRAINED, 11, 11, 0, 1250 } /* (0..1250) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_ExpectedOTD = { asn_DEF_ExpectedOTD_tags_1, /* Same as above */ sizeof(asn_DEF_ExpectedOTD_tags_1) /sizeof(asn_DEF_ExpectedOTD_tags_1[0]), /* 1 */ - &asn_PER_type_ExpectedOTD_constr_1, + &ASN_PER_TYPE_EXPECTED_OTD_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c b/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c index 9df50f61d..4007fc852 100644 --- a/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c +++ b/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c @@ -112,7 +112,7 @@ Ext_GeographicalInformation_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_Ext_GeographicalInformation_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_EXT_GEOGRAPHICAL_INFORMATION_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 5, 5, 1, 20 } /* (SIZE(1..20)) */, 0, 0 /* No PER value map */ @@ -139,7 +139,7 @@ asn_TYPE_descriptor_t asn_DEF_Ext_GeographicalInformation = { asn_DEF_Ext_GeographicalInformation_tags_1, /* Same as above */ sizeof(asn_DEF_Ext_GeographicalInformation_tags_1) /sizeof(asn_DEF_Ext_GeographicalInformation_tags_1[0]), /* 1 */ - &asn_PER_type_Ext_GeographicalInformation_constr_1, + &ASN_PER_TYPE_EXT_GEOGRAPHICAL_INFORMATION_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/Extended-reference.c b/src/core/libs/supl/asn-rrlp/Extended-reference.c index 12ca01ebe..198fbffe3 100644 --- a/src/core/libs/supl/asn-rrlp/Extended-reference.c +++ b/src/core/libs/supl/asn-rrlp/Extended-reference.c @@ -56,12 +56,12 @@ memb_transaction_ID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_smlc_code_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_SMLC_CODE_CONSTR_2 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_transaction_ID_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_TRANSACTION_ID_CONSTR_3 = { { APC_CONSTRAINED, 18, -1, 0, 262143 } /* (0..262143) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_Extended_reference_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_smlc_code_constraint_1, - &asn_PER_memb_smlc_code_constr_2, + &ASN_PER_MEMB_SMLC_CODE_CONSTR_2, 0, "smlc-code" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_Extended_reference_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_transaction_ID_constraint_1, - &asn_PER_memb_transaction_ID_constr_3, + &ASN_PER_MEMB_TRANSACTION_ID_CONSTR_3, 0, "transaction-ID" }, diff --git a/src/core/libs/supl/asn-rrlp/FineRTD.c b/src/core/libs/supl/asn-rrlp/FineRTD.c index 6a31fa718..a692cc908 100644 --- a/src/core/libs/supl/asn-rrlp/FineRTD.c +++ b/src/core/libs/supl/asn-rrlp/FineRTD.c @@ -111,7 +111,7 @@ FineRTD_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_FineRTD_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_FINE_RTD_CONSTR_1 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_FineRTD = { asn_DEF_FineRTD_tags_1, /* Same as above */ sizeof(asn_DEF_FineRTD_tags_1) /sizeof(asn_DEF_FineRTD_tags_1[0]), /* 1 */ - &asn_PER_type_FineRTD_constr_1, + &ASN_PER_TYPE_FINE_RTD_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/FixType.c b/src/core/libs/supl/asn-rrlp/FixType.c index d413f29c7..17c34842b 100644 --- a/src/core/libs/supl/asn-rrlp/FixType.c +++ b/src/core/libs/supl/asn-rrlp/FixType.c @@ -111,7 +111,7 @@ FixType_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_FixType_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_FIX_TYPE_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_FixType = { asn_DEF_FixType_tags_1, /* Same as above */ sizeof(asn_DEF_FixType_tags_1) /sizeof(asn_DEF_FixType_tags_1[0]), /* 1 */ - &asn_PER_type_FixType_constr_1, + &ASN_PER_TYPE_FIX_TYPE_CONSTR_1, 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/FrameDrift.c b/src/core/libs/supl/asn-rrlp/FrameDrift.c index 0a0238c9f..ae533e585 100644 --- a/src/core/libs/supl/asn-rrlp/FrameDrift.c +++ b/src/core/libs/supl/asn-rrlp/FrameDrift.c @@ -111,7 +111,7 @@ FrameDrift_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_FrameDrift_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_FRAME_DRIFT_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, -64, 63 } /* (-64..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_FrameDrift = { asn_DEF_FrameDrift_tags_1, /* Same as above */ sizeof(asn_DEF_FrameDrift_tags_1) /sizeof(asn_DEF_FrameDrift_tags_1[0]), /* 1 */ - &asn_PER_type_FrameDrift_constr_1, + &ASN_PER_TYPE_FRAME_DRIFT_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/FrameNumber.c b/src/core/libs/supl/asn-rrlp/FrameNumber.c index b8778f7f8..b028e5903 100644 --- a/src/core/libs/supl/asn-rrlp/FrameNumber.c +++ b/src/core/libs/supl/asn-rrlp/FrameNumber.c @@ -111,7 +111,7 @@ FrameNumber_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_FrameNumber_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_FRAME_NUMBER_CONSTR_1 = { { APC_CONSTRAINED, 21, -1, 0, 2097151 } /* (0..2097151) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_FrameNumber = { asn_DEF_FrameNumber_tags_1, /* Same as above */ sizeof(asn_DEF_FrameNumber_tags_1) /sizeof(asn_DEF_FrameNumber_tags_1[0]), /* 1 */ - &asn_PER_type_FrameNumber_constr_1, + &ASN_PER_TYPE_FRAME_NUMBER_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSS-MsrSetElement.c b/src/core/libs/supl/asn-rrlp/GANSS-MsrSetElement.c index 229783ca8..f6cf5ba0f 100644 --- a/src/core/libs/supl/asn-rrlp/GANSS-MsrSetElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSS-MsrSetElement.c @@ -31,7 +31,7 @@ memb_deltaGNASSTOD_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_deltaGNASSTOD_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_DELTA_GNASSTOD_CONSTR_4 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -60,7 +60,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_MsrSetElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_deltaGNASSTOD_constraint_1, - &asn_PER_memb_deltaGNASSTOD_constr_4, + &ASN_PER_MEMB_DELTA_GNASSTOD_CONSTR_4, 0, "deltaGNASSTOD" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSS-SgnElement.c b/src/core/libs/supl/asn-rrlp/GANSS-SgnElement.c index 6f31ab9b9..302a2fc62 100644 --- a/src/core/libs/supl/asn-rrlp/GANSS-SgnElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSS-SgnElement.c @@ -181,37 +181,37 @@ memb_adr_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_cNo_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_C_NO_CONSTR_3 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_carrierQualityInd_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_CARRIER_QUALITY_IND_CONSTR_5 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_codePhase_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_CODE_PHASE_CONSTR_6 = { { APC_CONSTRAINED, 21, -1, 0, 2097151 } /* (0..2097151) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_integerCodePhase_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_INTEGER_CODE_PHASE_CONSTR_7 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_codePhaseRMSError_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_CODE_PHASE_RMS_ERROR_CONSTR_8 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_doppler_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER_CONSTR_9 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_adr_constr_10 = { +static asn_per_constraints_t ASN_PER_MEMB_ADR_CONSTR_10 = { { APC_CONSTRAINED, 25, -1, 0, 33554431 } /* (0..33554431) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -231,7 +231,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_cNo_constraint_1, - &asn_PER_memb_cNo_constr_3, + &ASN_PER_MEMB_C_NO_CONSTR_3, 0, "cNo" }, @@ -249,7 +249,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_carrierQualityInd_constraint_1, - &asn_PER_memb_carrierQualityInd_constr_5, + &ASN_PER_MEMB_CARRIER_QUALITY_IND_CONSTR_5, 0, "carrierQualityInd" }, @@ -258,7 +258,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_codePhase_constraint_1, - &asn_PER_memb_codePhase_constr_6, + &ASN_PER_MEMB_CODE_PHASE_CONSTR_6, 0, "codePhase" }, @@ -267,7 +267,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_integerCodePhase_constraint_1, - &asn_PER_memb_integerCodePhase_constr_7, + &ASN_PER_MEMB_INTEGER_CODE_PHASE_CONSTR_7, 0, "integerCodePhase" }, @@ -276,7 +276,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_codePhaseRMSError_constraint_1, - &asn_PER_memb_codePhaseRMSError_constr_8, + &ASN_PER_MEMB_CODE_PHASE_RMS_ERROR_CONSTR_8, 0, "codePhaseRMSError" }, @@ -285,7 +285,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_doppler_constraint_1, - &asn_PER_memb_doppler_constr_9, + &ASN_PER_MEMB_DOPPLER_CONSTR_9, 0, "doppler" }, @@ -294,7 +294,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_adr_constraint_1, - &asn_PER_memb_adr_constr_10, + &ASN_PER_MEMB_ADR_CONSTR_10, 0, "adr" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSS-SgnTypeElement.c b/src/core/libs/supl/asn-rrlp/GANSS-SgnTypeElement.c index cffb812c8..fce8af4e8 100644 --- a/src/core/libs/supl/asn-rrlp/GANSS-SgnTypeElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSS-SgnTypeElement.c @@ -31,7 +31,7 @@ memb_ganssSignalID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssSignalID_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_SIGNAL_ID_CONSTR_2 = { { APC_CONSTRAINED, 4, 4, 0, 15 } /* (0..15) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_GANSS_SgnTypeElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssSignalID_constraint_1, - &asn_PER_memb_ganssSignalID_constr_2, + &ASN_PER_MEMB_GANSS_SIGNAL_ID_CONSTR_2, 0, "ganssSignalID" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSAlmanacElement.c b/src/core/libs/supl/asn-rrlp/GANSSAlmanacElement.c index c41627282..906260ab4 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSAlmanacElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSSAlmanacElement.c @@ -6,7 +6,7 @@ #include "GANSSAlmanacElement.h" -static asn_per_constraints_t asn_PER_type_GANSSAlmanacElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSS_ALMANAC_ELEMENT_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 0, 0, 0, 0 } /* (0..0,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -52,7 +52,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSAlmanacElement = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_GANSSAlmanacElement_constr_1, + &ASN_PER_TYPE_GANSS_ALMANAC_ELEMENT_CONSTR_1, asn_MBR_GANSSAlmanacElement_1, 1, /* Elements count */ &asn_SPC_GANSSAlmanacElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/GANSSAlmanacModel.c b/src/core/libs/supl/asn-rrlp/GANSSAlmanacModel.c index 3fb9dff20..77630b337 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSAlmanacModel.c +++ b/src/core/libs/supl/asn-rrlp/GANSSAlmanacModel.c @@ -81,17 +81,17 @@ memb_ioda_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_weekNumber_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_WEEK_NUMBER_CONSTR_2 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_toa_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_TOA_CONSTR_4 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ioda_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_IODA_CONSTR_5 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -102,7 +102,7 @@ static asn_TYPE_member_t asn_MBR_GANSSAlmanacModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_weekNumber_constraint_1, - &asn_PER_memb_weekNumber_constr_2, + &ASN_PER_MEMB_WEEK_NUMBER_CONSTR_2, 0, "weekNumber" }, @@ -120,7 +120,7 @@ static asn_TYPE_member_t asn_MBR_GANSSAlmanacModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_toa_constraint_1, - &asn_PER_memb_toa_constr_4, + &ASN_PER_MEMB_TOA_CONSTR_4, 0, "toa" }, @@ -129,7 +129,7 @@ static asn_TYPE_member_t asn_MBR_GANSSAlmanacModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ioda_constraint_1, - &asn_PER_memb_ioda_constr_5, + &ASN_PER_MEMB_IODA_CONSTR_5, 0, "ioda" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c b/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c index dbf9340b3..8d6fda870 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c +++ b/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c @@ -112,7 +112,7 @@ GANSSAssistanceData_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GANSSAssistanceData_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSS_ASSISTANCE_DATA_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 6, 6, 1, 40 } /* (SIZE(1..40)) */, 0, 0 /* No PER value map */ @@ -139,7 +139,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSAssistanceData = { asn_DEF_GANSSAssistanceData_tags_1, /* Same as above */ sizeof(asn_DEF_GANSSAssistanceData_tags_1) /sizeof(asn_DEF_GANSSAssistanceData_tags_1[0]), /* 1 */ - &asn_PER_type_GANSSAssistanceData_constr_1, + &ASN_PER_TYPE_GANSS_ASSISTANCE_DATA_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSSClockModel.c b/src/core/libs/supl/asn-rrlp/GANSSClockModel.c index 3dd4501e7..bfe58654d 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSClockModel.c +++ b/src/core/libs/supl/asn-rrlp/GANSSClockModel.c @@ -6,7 +6,7 @@ #include "GANSSClockModel.h" -static asn_per_constraints_t asn_PER_type_GANSSClockModel_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSS_CLOCK_MODEL_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 0, 0, 0, 0 } /* (0..0,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -52,7 +52,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSClockModel = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_GANSSClockModel_constr_1, + &ASN_PER_TYPE_GANSS_CLOCK_MODEL_CONSTR_1, asn_MBR_GANSSClockModel_1, 1, /* Elements count */ &asn_SPC_GANSSClockModel_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/GANSSDataBit.c b/src/core/libs/supl/asn-rrlp/GANSSDataBit.c index 67e8a5f0a..5f1ab2f6a 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSDataBit.c +++ b/src/core/libs/supl/asn-rrlp/GANSSDataBit.c @@ -111,7 +111,7 @@ GANSSDataBit_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GANSSDataBit_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSS_DATA_BIT_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSDataBit = { asn_DEF_GANSSDataBit_tags_1, /* Same as above */ sizeof(asn_DEF_GANSSDataBit_tags_1) /sizeof(asn_DEF_GANSSDataBit_tags_1[0]), /* 1 */ - &asn_PER_type_GANSSDataBit_constr_1, + &ASN_PER_TYPE_GANSS_DATA_BIT_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSSDataBitAssist.c b/src/core/libs/supl/asn-rrlp/GANSSDataBitAssist.c index 83aae91c6..29945a448 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSDataBitAssist.c +++ b/src/core/libs/supl/asn-rrlp/GANSSDataBitAssist.c @@ -56,12 +56,12 @@ memb_ganssDataTypeID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssTOD_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_TOD_CONSTR_2 = { { APC_CONSTRAINED, 6, 6, 0, 59 } /* (0..59) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssDataTypeID_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_DATA_TYPE_ID_CONSTR_4 = { { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_GANSSDataBitAssist_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssTOD_constraint_1, - &asn_PER_memb_ganssTOD_constr_2, + &ASN_PER_MEMB_GANSS_TOD_CONSTR_2, 0, "ganssTOD" }, @@ -90,7 +90,7 @@ static asn_TYPE_member_t asn_MBR_GANSSDataBitAssist_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssDataTypeID_constraint_1, - &asn_PER_memb_ganssDataTypeID_constr_4, + &ASN_PER_MEMB_GANSS_DATA_TYPE_ID_CONSTR_4, 0, "ganssDataTypeID" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSDiffCorrections.c b/src/core/libs/supl/asn-rrlp/GANSSDiffCorrections.c index 4492d1eba..ded9c4b2f 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSDiffCorrections.c +++ b/src/core/libs/supl/asn-rrlp/GANSSDiffCorrections.c @@ -31,7 +31,7 @@ memb_dganssRefTime_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_dganssRefTime_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_DGANSS_REF_TIME_CONSTR_2 = { { APC_CONSTRAINED, 7, 7, 0, 119 } /* (0..119) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_GANSSDiffCorrections_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_dganssRefTime_constraint_1, - &asn_PER_memb_dganssRefTime_constr_2, + &ASN_PER_MEMB_DGANSS_REF_TIME_CONSTR_2, 0, "dganssRefTime" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSGenericAssistDataElement.c b/src/core/libs/supl/asn-rrlp/GANSSGenericAssistDataElement.c index f9ee75d4f..abc4c3225 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSGenericAssistDataElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSSGenericAssistDataElement.c @@ -31,7 +31,7 @@ memb_ganssID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssID_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_ID_CONSTR_2 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_GANSSGenericAssistDataElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssID_constraint_1, - &asn_PER_memb_ganssID_constr_2, + &ASN_PER_MEMB_GANSS_ID_CONSTR_2, 0, "ganssID" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSIonoStormFlags.c b/src/core/libs/supl/asn-rrlp/GANSSIonoStormFlags.c index 9f5ad93bc..0ca6bbf45 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSIonoStormFlags.c +++ b/src/core/libs/supl/asn-rrlp/GANSSIonoStormFlags.c @@ -131,27 +131,27 @@ memb_ionoStormFlag5_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ionoStormFlag1_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_IONO_STORM_FLAG1_CONSTR_2 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ionoStormFlag2_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_IONO_STORM_FLAG2_CONSTR_3 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ionoStormFlag3_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_IONO_STORM_FLAG3_CONSTR_4 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ionoStormFlag4_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_IONO_STORM_FLAG4_CONSTR_5 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ionoStormFlag5_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_IONO_STORM_FLAG5_CONSTR_6 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -162,7 +162,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonoStormFlags_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ionoStormFlag1_constraint_1, - &asn_PER_memb_ionoStormFlag1_constr_2, + &ASN_PER_MEMB_IONO_STORM_FLAG1_CONSTR_2, 0, "ionoStormFlag1" }, @@ -171,7 +171,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonoStormFlags_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ionoStormFlag2_constraint_1, - &asn_PER_memb_ionoStormFlag2_constr_3, + &ASN_PER_MEMB_IONO_STORM_FLAG2_CONSTR_3, 0, "ionoStormFlag2" }, @@ -180,7 +180,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonoStormFlags_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ionoStormFlag3_constraint_1, - &asn_PER_memb_ionoStormFlag3_constr_4, + &ASN_PER_MEMB_IONO_STORM_FLAG3_CONSTR_4, 0, "ionoStormFlag3" }, @@ -189,7 +189,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonoStormFlags_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ionoStormFlag4_constraint_1, - &asn_PER_memb_ionoStormFlag4_constr_5, + &ASN_PER_MEMB_IONO_STORM_FLAG4_CONSTR_5, 0, "ionoStormFlag4" }, @@ -198,7 +198,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonoStormFlags_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ionoStormFlag5_constraint_1, - &asn_PER_memb_ionoStormFlag5_constr_6, + &ASN_PER_MEMB_IONO_STORM_FLAG5_CONSTR_6, 0, "ionoStormFlag5" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSIonosphereModel.c b/src/core/libs/supl/asn-rrlp/GANSSIonosphereModel.c index 10e7c67f0..5390b0def 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSIonosphereModel.c +++ b/src/core/libs/supl/asn-rrlp/GANSSIonosphereModel.c @@ -81,17 +81,17 @@ memb_ai2_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ai0_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_AI0_CONSTR_2 = { { APC_CONSTRAINED, 12, 12, 0, 4095 } /* (0..4095) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ai1_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_AI1_CONSTR_3 = { { APC_CONSTRAINED, 12, 12, 0, 4095 } /* (0..4095) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ai2_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_AI2_CONSTR_4 = { { APC_CONSTRAINED, 12, 12, 0, 4095 } /* (0..4095) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -102,7 +102,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonosphereModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ai0_constraint_1, - &asn_PER_memb_ai0_constr_2, + &ASN_PER_MEMB_AI0_CONSTR_2, 0, "ai0" }, @@ -111,7 +111,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonosphereModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ai1_constraint_1, - &asn_PER_memb_ai1_constr_3, + &ASN_PER_MEMB_AI1_CONSTR_3, 0, "ai1" }, @@ -120,7 +120,7 @@ static asn_TYPE_member_t asn_MBR_GANSSIonosphereModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ai2_constraint_1, - &asn_PER_memb_ai2_constr_4, + &ASN_PER_MEMB_AI2_CONSTR_4, 0, "ai2" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSLocationInfo.c b/src/core/libs/supl/asn-rrlp/GANSSLocationInfo.c index c98360895..3dbae18cf 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSLocationInfo.c +++ b/src/core/libs/supl/asn-rrlp/GANSSLocationInfo.c @@ -81,17 +81,17 @@ memb_stationaryIndication_constraint_1(asn_TYPE_descriptor_t *td, const void *sp } } -static asn_per_constraints_t asn_PER_memb_ganssTODFrac_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_TOD_FRAC_CONSTR_4 = { { APC_CONSTRAINED, 15, 15, 0, 16384 } /* (0..16384) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssTimeID_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_TIME_ID_CONSTR_6 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_stationaryIndication_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_STATIONARY_INDICATION_CONSTR_9 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -120,7 +120,7 @@ static asn_TYPE_member_t asn_MBR_GANSSLocationInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssTODFrac_constraint_1, - &asn_PER_memb_ganssTODFrac_constr_4, + &ASN_PER_MEMB_GANSS_TOD_FRAC_CONSTR_4, 0, "ganssTODFrac" }, @@ -138,7 +138,7 @@ static asn_TYPE_member_t asn_MBR_GANSSLocationInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssTimeID_constraint_1, - &asn_PER_memb_ganssTimeID_constr_6, + &ASN_PER_MEMB_GANSS_TIME_ID_CONSTR_6, 0, "ganssTimeID" }, @@ -165,7 +165,7 @@ static asn_TYPE_member_t asn_MBR_GANSSLocationInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stationaryIndication_constraint_1, - &asn_PER_memb_stationaryIndication_constr_9, + &ASN_PER_MEMB_STATIONARY_INDICATION_CONSTR_9, 0, "stationaryIndication" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSNavModel.c b/src/core/libs/supl/asn-rrlp/GANSSNavModel.c index 46c7cc984..1d9b2cb66 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSNavModel.c +++ b/src/core/libs/supl/asn-rrlp/GANSSNavModel.c @@ -106,22 +106,22 @@ memb_sqrtAMBS_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_nonBroadcastIndFlag_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_NON_BROADCAST_IND_FLAG_CONSTR_2 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_toeMSB_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_TOE_MSB_CONSTR_3 = { { APC_CONSTRAINED, 5, 5, 0, 31 } /* (0..31) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_eMSB_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_E_MSB_CONSTR_4 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_sqrtAMBS_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_SQRT_AMBS_CONSTR_5 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -132,7 +132,7 @@ static asn_TYPE_member_t asn_MBR_GANSSNavModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_nonBroadcastIndFlag_constraint_1, - &asn_PER_memb_nonBroadcastIndFlag_constr_2, + &ASN_PER_MEMB_NON_BROADCAST_IND_FLAG_CONSTR_2, 0, "nonBroadcastIndFlag" }, @@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_GANSSNavModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_toeMSB_constraint_1, - &asn_PER_memb_toeMSB_constr_3, + &ASN_PER_MEMB_TOE_MSB_CONSTR_3, 0, "toeMSB" }, @@ -150,7 +150,7 @@ static asn_TYPE_member_t asn_MBR_GANSSNavModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_eMSB_constraint_1, - &asn_PER_memb_eMSB_constr_4, + &ASN_PER_MEMB_E_MSB_CONSTR_4, 0, "eMSB" }, @@ -159,7 +159,7 @@ static asn_TYPE_member_t asn_MBR_GANSSNavModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_sqrtAMBS_constraint_1, - &asn_PER_memb_sqrtAMBS_constr_5, + &ASN_PER_MEMB_SQRT_AMBS_CONSTR_5, 0, "sqrtAMBS" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSOrbitModel.c b/src/core/libs/supl/asn-rrlp/GANSSOrbitModel.c index 5bd45837a..ff3bba79c 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSOrbitModel.c +++ b/src/core/libs/supl/asn-rrlp/GANSSOrbitModel.c @@ -6,7 +6,7 @@ #include "GANSSOrbitModel.h" -static asn_per_constraints_t asn_PER_type_GANSSOrbitModel_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSS_ORBIT_MODEL_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 0, 0, 0, 0 } /* (0..0,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -52,7 +52,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSOrbitModel = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_GANSSOrbitModel_constr_1, + &ASN_PER_TYPE_GANSS_ORBIT_MODEL_CONSTR_1, asn_MBR_GANSSOrbitModel_1, 1, /* Elements count */ &asn_SPC_GANSSOrbitModel_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c b/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c index aaff620c7..77f16b6d7 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c +++ b/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c @@ -117,7 +117,7 @@ GANSSPositioningMethod_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GANSSPositioningMethod_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSS_POSITIONING_METHOD_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 2, 16 } /* (SIZE(2..16)) */, 0, 0 /* No PER value map */ @@ -144,7 +144,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSPositioningMethod = { asn_DEF_GANSSPositioningMethod_tags_1, /* Same as above */ sizeof(asn_DEF_GANSSPositioningMethod_tags_1) /sizeof(asn_DEF_GANSSPositioningMethod_tags_1[0]), /* 1 */ - &asn_PER_type_GANSSPositioningMethod_constr_1, + &ASN_PER_TYPE_GANSS_POSITIONING_METHOD_CONSTR_1, 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementAssist.c b/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementAssist.c index 9a5a09290..28f7fb4ed 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementAssist.c +++ b/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementAssist.c @@ -31,7 +31,7 @@ memb_ganssSignalID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssSignalID_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_SIGNAL_ID_CONSTR_2 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_GANSSRefMeasurementAssist_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssSignalID_constraint_1, - &asn_PER_memb_ganssSignalID_constr_2, + &ASN_PER_MEMB_GANSS_SIGNAL_ID_CONSTR_2, 0, "ganssSignalID" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementElement.c b/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementElement.c index f67633244..c527baf5a 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSSRefMeasurementElement.c @@ -106,22 +106,22 @@ memb_codePhaseSearchWindow_constraint_1(asn_TYPE_descriptor_t *td, const void *s } } -static asn_per_constraints_t asn_PER_memb_doppler0_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER0_CONSTR_3 = { { APC_CONSTRAINED, 12, 12, -2048, 2047 } /* (-2048..2047) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_codePhase_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_CODE_PHASE_CONSTR_5 = { { APC_CONSTRAINED, 10, 10, 0, 1022 } /* (0..1022) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_intCodePhase_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_INT_CODE_PHASE_CONSTR_6 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_codePhaseSearchWindow_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_CODE_PHASE_SEARCH_WINDOW_CONSTR_7 = { { APC_CONSTRAINED, 5, 5, 0, 31 } /* (0..31) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_GANSSRefMeasurementElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_doppler0_constraint_1, - &asn_PER_memb_doppler0_constr_3, + &ASN_PER_MEMB_DOPPLER0_CONSTR_3, 0, "doppler0" }, @@ -159,7 +159,7 @@ static asn_TYPE_member_t asn_MBR_GANSSRefMeasurementElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_codePhase_constraint_1, - &asn_PER_memb_codePhase_constr_5, + &ASN_PER_MEMB_CODE_PHASE_CONSTR_5, 0, "codePhase" }, @@ -168,7 +168,7 @@ static asn_TYPE_member_t asn_MBR_GANSSRefMeasurementElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_intCodePhase_constraint_1, - &asn_PER_memb_intCodePhase_constr_6, + &ASN_PER_MEMB_INT_CODE_PHASE_CONSTR_6, 0, "intCodePhase" }, @@ -177,7 +177,7 @@ static asn_TYPE_member_t asn_MBR_GANSSRefMeasurementElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_codePhaseSearchWindow_constraint_1, - &asn_PER_memb_codePhaseSearchWindow_constr_7, + &ASN_PER_MEMB_CODE_PHASE_SEARCH_WINDOW_CONSTR_7, 0, "codePhaseSearchWindow" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSRefTimeInfo.c b/src/core/libs/supl/asn-rrlp/GANSSRefTimeInfo.c index 406523ba9..c1bd034fe 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSRefTimeInfo.c +++ b/src/core/libs/supl/asn-rrlp/GANSSRefTimeInfo.c @@ -56,12 +56,12 @@ memb_ganssTimeID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssDay_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_DAY_CONSTR_2 = { { APC_CONSTRAINED, 13, 13, 0, 8191 } /* (0..8191) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssTimeID_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_TIME_ID_CONSTR_5 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_GANSSRefTimeInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssDay_constraint_1, - &asn_PER_memb_ganssDay_constr_2, + &ASN_PER_MEMB_GANSS_DAY_CONSTR_2, 0, "ganssDay" }, @@ -99,7 +99,7 @@ static asn_TYPE_member_t asn_MBR_GANSSRefTimeInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssTimeID_constraint_1, - &asn_PER_memb_ganssTimeID_constr_5, + &ASN_PER_MEMB_GANSS_TIME_ID_CONSTR_5, 0, "ganssTimeID" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSSatelliteElement.c b/src/core/libs/supl/asn-rrlp/GANSSSatelliteElement.c index d32e86bf5..67367ff6f 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSSatelliteElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSSSatelliteElement.c @@ -56,12 +56,12 @@ memb_iod_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_svHealth_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_SV_HEALTH_CONSTR_3 = { { APC_CONSTRAINED, 5, 5, -7, 13 } /* (-7..13) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_iod_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_IOD_CONSTR_4 = { { APC_CONSTRAINED, 10, 10, 0, 1023 } /* (0..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_GANSSSatelliteElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_svHealth_constraint_1, - &asn_PER_memb_svHealth_constr_3, + &ASN_PER_MEMB_SV_HEALTH_CONSTR_3, 0, "svHealth" }, @@ -90,7 +90,7 @@ static asn_TYPE_member_t asn_MBR_GANSSSatelliteElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_iod_constraint_1, - &asn_PER_memb_iod_constr_4, + &ASN_PER_MEMB_IOD_CONSTR_4, 0, "iod" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSSignalID.c b/src/core/libs/supl/asn-rrlp/GANSSSignalID.c index dfcdb15da..05ddb3db6 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSSignalID.c +++ b/src/core/libs/supl/asn-rrlp/GANSSSignalID.c @@ -111,7 +111,7 @@ GANSSSignalID_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GANSSSignalID_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSS_SIGNAL_ID_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSSignalID = { asn_DEF_GANSSSignalID_tags_1, /* Same as above */ sizeof(asn_DEF_GANSSSignalID_tags_1) /sizeof(asn_DEF_GANSSSignalID_tags_1[0]), /* 1 */ - &asn_PER_type_GANSSSignalID_constr_1, + &ASN_PER_TYPE_GANSS_SIGNAL_ID_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSSTOD.c b/src/core/libs/supl/asn-rrlp/GANSSTOD.c index b2007aaa9..5022d5bd3 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSTOD.c +++ b/src/core/libs/supl/asn-rrlp/GANSSTOD.c @@ -111,7 +111,7 @@ GANSSTOD_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GANSSTOD_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSSTOD_CONSTR_1 = { { APC_CONSTRAINED, 17, -1, 0, 86399 } /* (0..86399) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSTOD = { asn_DEF_GANSSTOD_tags_1, /* Same as above */ sizeof(asn_DEF_GANSSTOD_tags_1) /sizeof(asn_DEF_GANSSTOD_tags_1[0]), /* 1 */ - &asn_PER_type_GANSSTOD_constr_1, + &ASN_PER_TYPE_GANSSTOD_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c b/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c index a07695911..72519d28c 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c +++ b/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c @@ -111,7 +111,7 @@ GANSSTODUncertainty_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GANSSTODUncertainty_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSSTOD_UNCERTAINTY_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSTODUncertainty = { asn_DEF_GANSSTODUncertainty_tags_1, /* Same as above */ sizeof(asn_DEF_GANSSTODUncertainty_tags_1) /sizeof(asn_DEF_GANSSTODUncertainty_tags_1[0]), /* 1 */ - &asn_PER_type_GANSSTODUncertainty_constr_1, + &ASN_PER_TYPE_GANSSTOD_UNCERTAINTY_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSSTODm.c b/src/core/libs/supl/asn-rrlp/GANSSTODm.c index 02a84dfe7..2bc765980 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSTODm.c +++ b/src/core/libs/supl/asn-rrlp/GANSSTODm.c @@ -111,7 +111,7 @@ GANSSTODm_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GANSSTODm_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GANSSTO_DM_CONSTR_1 = { { APC_CONSTRAINED, 22, -1, 0, 3599999 } /* (0..3599999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GANSSTODm = { asn_DEF_GANSSTODm_tags_1, /* Same as above */ sizeof(asn_DEF_GANSSTODm_tags_1) /sizeof(asn_DEF_GANSSTODm_tags_1[0]), /* 1 */ - &asn_PER_type_GANSSTODm_constr_1, + &ASN_PER_TYPE_GANSSTO_DM_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GANSSTimeModelElement.c b/src/core/libs/supl/asn-rrlp/GANSSTimeModelElement.c index 6ba69bb30..cd993b5e5 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSTimeModelElement.c +++ b/src/core/libs/supl/asn-rrlp/GANSSTimeModelElement.c @@ -81,17 +81,17 @@ memb_weekNumber_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssTimeModelRefTime_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_TIME_MODEL_REF_TIME_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_gnssTOID_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_GNSS_TOID_CONSTR_6 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_weekNumber_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_WEEK_NUMBER_CONSTR_7 = { { APC_CONSTRAINED, 13, 13, 0, 8191 } /* (0..8191) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -102,7 +102,7 @@ static asn_TYPE_member_t asn_MBR_GANSSTimeModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssTimeModelRefTime_constraint_1, - &asn_PER_memb_ganssTimeModelRefTime_constr_2, + &ASN_PER_MEMB_GANSS_TIME_MODEL_REF_TIME_CONSTR_2, 0, "ganssTimeModelRefTime" }, @@ -138,7 +138,7 @@ static asn_TYPE_member_t asn_MBR_GANSSTimeModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_gnssTOID_constraint_1, - &asn_PER_memb_gnssTOID_constr_6, + &ASN_PER_MEMB_GNSS_TOID_CONSTR_6, 0, "gnssTOID" }, @@ -147,7 +147,7 @@ static asn_TYPE_member_t asn_MBR_GANSSTimeModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_weekNumber_constraint_1, - &asn_PER_memb_weekNumber_constr_7, + &ASN_PER_MEMB_WEEK_NUMBER_CONSTR_7, 0, "weekNumber" }, diff --git a/src/core/libs/supl/asn-rrlp/GANSSUTCModel.c b/src/core/libs/supl/asn-rrlp/GANSSUTCModel.c index 5366ea85d..8d37ddc7a 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSUTCModel.c +++ b/src/core/libs/supl/asn-rrlp/GANSSUTCModel.c @@ -206,42 +206,42 @@ memb_ganssUtcDeltaTlsf_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssUtcA1_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_A1_CONSTR_2 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssUtcA0_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_A0_CONSTR_3 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssUtcTot_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_TOT_CONSTR_4 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssUtcWNt_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_W_NT_CONSTR_5 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssUtcDeltaTls_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_DELTA_TLS_CONSTR_6 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssUtcWNlsf_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_W_NLSF_CONSTR_7 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssUtcDN_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_DN_CONSTR_8 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ganssUtcDeltaTlsf_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_UTC_DELTA_TLSF_CONSTR_9 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -252,7 +252,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcA1_constraint_1, - &asn_PER_memb_ganssUtcA1_constr_2, + &ASN_PER_MEMB_GANSS_UTC_A1_CONSTR_2, 0, "ganssUtcA1" }, @@ -261,7 +261,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcA0_constraint_1, - &asn_PER_memb_ganssUtcA0_constr_3, + &ASN_PER_MEMB_GANSS_UTC_A0_CONSTR_3, 0, "ganssUtcA0" }, @@ -270,7 +270,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcTot_constraint_1, - &asn_PER_memb_ganssUtcTot_constr_4, + &ASN_PER_MEMB_GANSS_UTC_TOT_CONSTR_4, 0, "ganssUtcTot" }, @@ -279,7 +279,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcWNt_constraint_1, - &asn_PER_memb_ganssUtcWNt_constr_5, + &ASN_PER_MEMB_GANSS_UTC_W_NT_CONSTR_5, 0, "ganssUtcWNt" }, @@ -288,7 +288,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcDeltaTls_constraint_1, - &asn_PER_memb_ganssUtcDeltaTls_constr_6, + &ASN_PER_MEMB_GANSS_UTC_DELTA_TLS_CONSTR_6, 0, "ganssUtcDeltaTls" }, @@ -297,7 +297,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcWNlsf_constraint_1, - &asn_PER_memb_ganssUtcWNlsf_constr_7, + &ASN_PER_MEMB_GANSS_UTC_W_NLSF_CONSTR_7, 0, "ganssUtcWNlsf" }, @@ -306,7 +306,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcDN_constraint_1, - &asn_PER_memb_ganssUtcDN_constr_8, + &ASN_PER_MEMB_GANSS_UTC_DN_CONSTR_8, 0, "ganssUtcDN" }, @@ -315,7 +315,7 @@ static asn_TYPE_member_t asn_MBR_GANSSUTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssUtcDeltaTlsf_constraint_1, - &asn_PER_memb_ganssUtcDeltaTlsf_constr_9, + &ASN_PER_MEMB_GANSS_UTC_DELTA_TLSF_CONSTR_9, 0, "ganssUtcDeltaTlsf" }, diff --git a/src/core/libs/supl/asn-rrlp/GPS-MsrElement.c b/src/core/libs/supl/asn-rrlp/GPS-MsrElement.c index 96d4d1de7..756a7f54e 100644 --- a/src/core/libs/supl/asn-rrlp/GPS-MsrElement.c +++ b/src/core/libs/supl/asn-rrlp/GPS-MsrElement.c @@ -131,27 +131,27 @@ memb_pseuRangeRMSErr_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_cNo_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_C_NO_CONSTR_3 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_doppler_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_DOPPLER_CONSTR_4 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_wholeChips_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_WHOLE_CHIPS_CONSTR_5 = { { APC_CONSTRAINED, 10, 10, 0, 1022 } /* (0..1022) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_fracChips_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_FRAC_CHIPS_CONSTR_6 = { { APC_CONSTRAINED, 11, 11, 0, 1024 } /* (0..1024) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_pseuRangeRMSErr_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_PSEU_RANGE_RMS_ERR_CONSTR_8 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -171,7 +171,7 @@ static asn_TYPE_member_t asn_MBR_GPS_MsrElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_cNo_constraint_1, - &asn_PER_memb_cNo_constr_3, + &ASN_PER_MEMB_C_NO_CONSTR_3, 0, "cNo" }, @@ -180,7 +180,7 @@ static asn_TYPE_member_t asn_MBR_GPS_MsrElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_doppler_constraint_1, - &asn_PER_memb_doppler_constr_4, + &ASN_PER_MEMB_DOPPLER_CONSTR_4, 0, "doppler" }, @@ -189,7 +189,7 @@ static asn_TYPE_member_t asn_MBR_GPS_MsrElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_wholeChips_constraint_1, - &asn_PER_memb_wholeChips_constr_5, + &ASN_PER_MEMB_WHOLE_CHIPS_CONSTR_5, 0, "wholeChips" }, @@ -198,7 +198,7 @@ static asn_TYPE_member_t asn_MBR_GPS_MsrElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_fracChips_constraint_1, - &asn_PER_memb_fracChips_constr_6, + &ASN_PER_MEMB_FRAC_CHIPS_CONSTR_6, 0, "fracChips" }, @@ -216,7 +216,7 @@ static asn_TYPE_member_t asn_MBR_GPS_MsrElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_pseuRangeRMSErr_constraint_1, - &asn_PER_memb_pseuRangeRMSErr_constr_8, + &ASN_PER_MEMB_PSEU_RANGE_RMS_ERR_CONSTR_8, 0, "pseuRangeRMSErr" }, diff --git a/src/core/libs/supl/asn-rrlp/GPS-MsrSetElement.c b/src/core/libs/supl/asn-rrlp/GPS-MsrSetElement.c index 91c0ce711..c1aec7065 100644 --- a/src/core/libs/supl/asn-rrlp/GPS-MsrSetElement.c +++ b/src/core/libs/supl/asn-rrlp/GPS-MsrSetElement.c @@ -31,7 +31,7 @@ memb_refFrame_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_refFrame_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_FRAME_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_GPS_MsrSetElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refFrame_constraint_1, - &asn_PER_memb_refFrame_constr_2, + &ASN_PER_MEMB_REF_FRAME_CONSTR_2, 0, "refFrame" }, diff --git a/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c b/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c index f2604dbcf..6f93d65f3 100644 --- a/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c +++ b/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c @@ -112,7 +112,7 @@ GPSAssistanceData_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GPSAssistanceData_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GPS_ASSISTANCE_DATA_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 6, 6, 1, 40 } /* (SIZE(1..40)) */, 0, 0 /* No PER value map */ @@ -139,7 +139,7 @@ asn_TYPE_descriptor_t asn_DEF_GPSAssistanceData = { asn_DEF_GPSAssistanceData_tags_1, /* Same as above */ sizeof(asn_DEF_GPSAssistanceData_tags_1) /sizeof(asn_DEF_GPSAssistanceData_tags_1[0]), /* 1 */ - &asn_PER_type_GPSAssistanceData_constr_1, + &ASN_PER_TYPE_GPS_ASSISTANCE_DATA_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c b/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c index 1250731f0..c80de1dad 100644 --- a/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c +++ b/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c @@ -111,7 +111,7 @@ GPSReferenceTimeUncertainty_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GPSReferenceTimeUncertainty_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GPS_REFERENCE_TIME_UNCERTAINTY_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GPSReferenceTimeUncertainty = { asn_DEF_GPSReferenceTimeUncertainty_tags_1, /* Same as above */ sizeof(asn_DEF_GPSReferenceTimeUncertainty_tags_1) /sizeof(asn_DEF_GPSReferenceTimeUncertainty_tags_1[0]), /* 1 */ - &asn_PER_type_GPSReferenceTimeUncertainty_constr_1, + &ASN_PER_TYPE_GPS_REFERENCE_TIME_UNCERTAINTY_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GPSTOW23b.c b/src/core/libs/supl/asn-rrlp/GPSTOW23b.c index 8ad2591cb..fe1c9d773 100644 --- a/src/core/libs/supl/asn-rrlp/GPSTOW23b.c +++ b/src/core/libs/supl/asn-rrlp/GPSTOW23b.c @@ -111,7 +111,7 @@ GPSTOW23b_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GPSTOW23b_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GPSTO_W23B_CONSTR_1 = { { APC_CONSTRAINED, 23, -1, 0, 7559999 } /* (0..7559999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GPSTOW23b = { asn_DEF_GPSTOW23b_tags_1, /* Same as above */ sizeof(asn_DEF_GPSTOW23b_tags_1) /sizeof(asn_DEF_GPSTOW23b_tags_1[0]), /* 1 */ - &asn_PER_type_GPSTOW23b_constr_1, + &ASN_PER_TYPE_GPSTO_W23B_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GPSTOW24b.c b/src/core/libs/supl/asn-rrlp/GPSTOW24b.c index 6a110adac..805fe2577 100644 --- a/src/core/libs/supl/asn-rrlp/GPSTOW24b.c +++ b/src/core/libs/supl/asn-rrlp/GPSTOW24b.c @@ -111,7 +111,7 @@ GPSTOW24b_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GPSTOW24b_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GPSTO_W24B_CONSTR_1 = { { APC_CONSTRAINED, 24, -1, 0, 14399999 } /* (0..14399999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GPSTOW24b = { asn_DEF_GPSTOW24b_tags_1, /* Same as above */ sizeof(asn_DEF_GPSTOW24b_tags_1) /sizeof(asn_DEF_GPSTOW24b_tags_1[0]), /* 1 */ - &asn_PER_type_GPSTOW24b_constr_1, + &ASN_PER_TYPE_GPSTO_W24B_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/GPSTOWAssist.c b/src/core/libs/supl/asn-rrlp/GPSTOWAssist.c index aac3de697..0ce4905d9 100644 --- a/src/core/libs/supl/asn-rrlp/GPSTOWAssist.c +++ b/src/core/libs/supl/asn-rrlp/GPSTOWAssist.c @@ -6,7 +6,7 @@ #include "GPSTOWAssist.h" -static asn_per_constraints_t asn_PER_type_GPSTOWAssist_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GPSTOW_ASSIST_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 12 } /* (SIZE(1..12)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_GPSTOWAssist = { asn_DEF_GPSTOWAssist_tags_1, /* Same as above */ sizeof(asn_DEF_GPSTOWAssist_tags_1) /sizeof(asn_DEF_GPSTOWAssist_tags_1[0]), /* 1 */ - &asn_PER_type_GPSTOWAssist_constr_1, + &ASN_PER_TYPE_GPSTOW_ASSIST_CONSTR_1, asn_MBR_GPSTOWAssist_1, 1, /* Single element */ &asn_SPC_GPSTOWAssist_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/GPSTimeAssistanceMeasurements.c b/src/core/libs/supl/asn-rrlp/GPSTimeAssistanceMeasurements.c index 6e7fe01d8..67ef9b1a3 100644 --- a/src/core/libs/supl/asn-rrlp/GPSTimeAssistanceMeasurements.c +++ b/src/core/libs/supl/asn-rrlp/GPSTimeAssistanceMeasurements.c @@ -81,17 +81,17 @@ memb_deltaTow_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_referenceFrameMSB_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REFERENCE_FRAME_MSB_CONSTR_2 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_gpsTowSubms_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_GPS_TOW_SUBMS_CONSTR_3 = { { APC_CONSTRAINED, 14, 14, 0, 9999 } /* (0..9999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_deltaTow_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_DELTA_TOW_CONSTR_4 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -102,7 +102,7 @@ static asn_TYPE_member_t asn_MBR_GPSTimeAssistanceMeasurements_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_referenceFrameMSB_constraint_1, - &asn_PER_memb_referenceFrameMSB_constr_2, + &ASN_PER_MEMB_REFERENCE_FRAME_MSB_CONSTR_2, 0, "referenceFrameMSB" }, @@ -111,7 +111,7 @@ static asn_TYPE_member_t asn_MBR_GPSTimeAssistanceMeasurements_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_gpsTowSubms_constraint_1, - &asn_PER_memb_gpsTowSubms_constr_3, + &ASN_PER_MEMB_GPS_TOW_SUBMS_CONSTR_3, 0, "gpsTowSubms" }, @@ -120,7 +120,7 @@ static asn_TYPE_member_t asn_MBR_GPSTimeAssistanceMeasurements_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_deltaTow_constraint_1, - &asn_PER_memb_deltaTow_constr_4, + &ASN_PER_MEMB_DELTA_TOW_CONSTR_4, 0, "deltaTow" }, diff --git a/src/core/libs/supl/asn-rrlp/GPSWeek.c b/src/core/libs/supl/asn-rrlp/GPSWeek.c index 33cb12809..0b312cb38 100644 --- a/src/core/libs/supl/asn-rrlp/GPSWeek.c +++ b/src/core/libs/supl/asn-rrlp/GPSWeek.c @@ -111,7 +111,7 @@ GPSWeek_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_GPSWeek_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_GPS_WEEK_CONSTR_1 = { { APC_CONSTRAINED, 10, 10, 0, 1023 } /* (0..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_GPSWeek = { asn_DEF_GPSWeek_tags_1, /* Same as above */ sizeof(asn_DEF_GPSWeek_tags_1) /sizeof(asn_DEF_GPSWeek_tags_1[0]), /* 1 */ - &asn_PER_type_GPSWeek_constr_1, + &ASN_PER_TYPE_GPS_WEEK_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/IonosphericModel.c b/src/core/libs/supl/asn-rrlp/IonosphericModel.c index 552004de2..bafe72b87 100644 --- a/src/core/libs/supl/asn-rrlp/IonosphericModel.c +++ b/src/core/libs/supl/asn-rrlp/IonosphericModel.c @@ -206,42 +206,42 @@ memb_beta3_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_alfa0_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_ALFA0_CONSTR_2 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_alfa1_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_ALFA1_CONSTR_3 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_alfa2_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_ALFA2_CONSTR_4 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_alfa3_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_ALFA3_CONSTR_5 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_beta0_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_BETA0_CONSTR_6 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_beta1_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_BETA1_CONSTR_7 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_beta2_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_BETA2_CONSTR_8 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_beta3_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_BETA3_CONSTR_9 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -252,7 +252,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_alfa0_constraint_1, - &asn_PER_memb_alfa0_constr_2, + &ASN_PER_MEMB_ALFA0_CONSTR_2, 0, "alfa0" }, @@ -261,7 +261,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_alfa1_constraint_1, - &asn_PER_memb_alfa1_constr_3, + &ASN_PER_MEMB_ALFA1_CONSTR_3, 0, "alfa1" }, @@ -270,7 +270,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_alfa2_constraint_1, - &asn_PER_memb_alfa2_constr_4, + &ASN_PER_MEMB_ALFA2_CONSTR_4, 0, "alfa2" }, @@ -279,7 +279,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_alfa3_constraint_1, - &asn_PER_memb_alfa3_constr_5, + &ASN_PER_MEMB_ALFA3_CONSTR_5, 0, "alfa3" }, @@ -288,7 +288,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_beta0_constraint_1, - &asn_PER_memb_beta0_constr_6, + &ASN_PER_MEMB_BETA0_CONSTR_6, 0, "beta0" }, @@ -297,7 +297,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_beta1_constraint_1, - &asn_PER_memb_beta1_constr_7, + &ASN_PER_MEMB_BETA1_CONSTR_7, 0, "beta1" }, @@ -306,7 +306,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_beta2_constraint_1, - &asn_PER_memb_beta2_constr_8, + &ASN_PER_MEMB_BETA2_CONSTR_8, 0, "beta2" }, @@ -315,7 +315,7 @@ static asn_TYPE_member_t asn_MBR_IonosphericModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_beta3_constraint_1, - &asn_PER_memb_beta3_constr_9, + &ASN_PER_MEMB_BETA3_CONSTR_9, 0, "beta3" }, diff --git a/src/core/libs/supl/asn-rrlp/LAC.c b/src/core/libs/supl/asn-rrlp/LAC.c index e15942e24..d6de9a0ae 100644 --- a/src/core/libs/supl/asn-rrlp/LAC.c +++ b/src/core/libs/supl/asn-rrlp/LAC.c @@ -111,7 +111,7 @@ LAC_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_LAC_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_LAC_CONSTR_1 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_LAC = { asn_DEF_LAC_tags_1, /* Same as above */ sizeof(asn_DEF_LAC_tags_1) /sizeof(asn_DEF_LAC_tags_1[0]), /* 1 */ - &asn_PER_type_LAC_constr_1, + &ASN_PER_TYPE_LAC_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/LocErrorReason.c b/src/core/libs/supl/asn-rrlp/LocErrorReason.c index 2d98516db..217112048 100644 --- a/src/core/libs/supl/asn-rrlp/LocErrorReason.c +++ b/src/core/libs/supl/asn-rrlp/LocErrorReason.c @@ -94,7 +94,7 @@ LocErrorReason_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_LocErrorReason_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_LOC_ERROR_REASON_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 4, 4, 0, 10 } /* (0..10,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -164,7 +164,7 @@ asn_TYPE_descriptor_t asn_DEF_LocErrorReason = { asn_DEF_LocErrorReason_tags_1, /* Same as above */ sizeof(asn_DEF_LocErrorReason_tags_1) /sizeof(asn_DEF_LocErrorReason_tags_1[0]), /* 1 */ - &asn_PER_type_LocErrorReason_constr_1, + &ASN_PER_TYPE_LOC_ERROR_REASON_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_LocErrorReason_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/LocationInfo.c b/src/core/libs/supl/asn-rrlp/LocationInfo.c index 92d0990f6..53a747679 100644 --- a/src/core/libs/supl/asn-rrlp/LocationInfo.c +++ b/src/core/libs/supl/asn-rrlp/LocationInfo.c @@ -56,12 +56,12 @@ memb_gpsTOW_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_refFrame_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_FRAME_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_gpsTOW_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_GPS_TOW_CONSTR_3 = { { APC_CONSTRAINED, 24, -1, 0, 14399999 } /* (0..14399999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_LocationInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refFrame_constraint_1, - &asn_PER_memb_refFrame_constr_2, + &ASN_PER_MEMB_REF_FRAME_CONSTR_2, 0, "refFrame" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_LocationInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_gpsTOW_constraint_1, - &asn_PER_memb_gpsTOW_constr_3, + &ASN_PER_MEMB_GPS_TOW_CONSTR_3, 0, "gpsTOW" }, diff --git a/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c b/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c index 808aef74c..f46280af2 100644 --- a/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c +++ b/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c @@ -111,7 +111,7 @@ MeasureResponseTime_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_MeasureResponseTime_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_MEASURE_RESPONSE_TIME_CONSTR_1 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_MeasureResponseTime = { asn_DEF_MeasureResponseTime_tags_1, /* Same as above */ sizeof(asn_DEF_MeasureResponseTime_tags_1) /sizeof(asn_DEF_MeasureResponseTime_tags_1[0]), /* 1 */ - &asn_PER_type_MeasureResponseTime_constr_1, + &ASN_PER_TYPE_MEASURE_RESPONSE_TIME_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/MethodType.c b/src/core/libs/supl/asn-rrlp/MethodType.c index 7a2b9ecfa..dc7782e8e 100644 --- a/src/core/libs/supl/asn-rrlp/MethodType.c +++ b/src/core/libs/supl/asn-rrlp/MethodType.c @@ -6,7 +6,7 @@ #include "MethodType.h" -static asn_per_constraints_t asn_PER_type_MethodType_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_METHOD_TYPE_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -82,7 +82,7 @@ asn_TYPE_descriptor_t asn_DEF_MethodType = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_MethodType_constr_1, + &ASN_PER_TYPE_METHOD_TYPE_CONSTR_1, asn_MBR_MethodType_1, 4, /* Elements count */ &asn_SPC_MethodType_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c b/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c index bf42ed64a..b14a2967f 100644 --- a/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c +++ b/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c @@ -111,7 +111,7 @@ ModuloTimeSlot_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_ModuloTimeSlot_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_MODULO_TIME_SLOT_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_ModuloTimeSlot = { asn_DEF_ModuloTimeSlot_tags_1, /* Same as above */ sizeof(asn_DEF_ModuloTimeSlot_tags_1) /sizeof(asn_DEF_ModuloTimeSlot_tags_1[0]), /* 1 */ - &asn_PER_type_ModuloTimeSlot_constr_1, + &ASN_PER_TYPE_MODULO_TIME_SLOT_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c b/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c index b2a849cb5..dd107752c 100644 --- a/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c +++ b/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c @@ -94,7 +94,7 @@ MoreAssDataToBeSent_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_MoreAssDataToBeSent_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_MORE_ASS_DATA_TO_BE_SENT_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_MoreAssDataToBeSent = { asn_DEF_MoreAssDataToBeSent_tags_1, /* Same as above */ sizeof(asn_DEF_MoreAssDataToBeSent_tags_1) /sizeof(asn_DEF_MoreAssDataToBeSent_tags_1[0]), /* 1 */ - &asn_PER_type_MoreAssDataToBeSent_constr_1, + &ASN_PER_TYPE_MORE_ASS_DATA_TO_BE_SENT_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_MoreAssDataToBeSent_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/MpathIndic.c b/src/core/libs/supl/asn-rrlp/MpathIndic.c index 8a1a0a280..67e26d4b0 100644 --- a/src/core/libs/supl/asn-rrlp/MpathIndic.c +++ b/src/core/libs/supl/asn-rrlp/MpathIndic.c @@ -94,7 +94,7 @@ MpathIndic_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_MpathIndic_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_MPATH_INDIC_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -142,7 +142,7 @@ asn_TYPE_descriptor_t asn_DEF_MpathIndic = { asn_DEF_MpathIndic_tags_1, /* Same as above */ sizeof(asn_DEF_MpathIndic_tags_1) /sizeof(asn_DEF_MpathIndic_tags_1[0]), /* 1 */ - &asn_PER_type_MpathIndic_constr_1, + &ASN_PER_TYPE_MPATH_INDIC_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_MpathIndic_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c b/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c index 8d9149817..297d81b3f 100644 --- a/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c +++ b/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c @@ -111,7 +111,7 @@ MultiFrameOffset_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_MultiFrameOffset_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_MULTI_FRAME_OFFSET_CONSTR_1 = { { APC_CONSTRAINED, 6, 6, 0, 51 } /* (0..51) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_MultiFrameOffset = { asn_DEF_MultiFrameOffset_tags_1, /* Same as above */ sizeof(asn_DEF_MultiFrameOffset_tags_1) /sizeof(asn_DEF_MultiFrameOffset_tags_1[0]), /* 1 */ - &asn_PER_type_MultiFrameOffset_constr_1, + &ASN_PER_TYPE_MULTI_FRAME_OFFSET_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/MultipleSets.c b/src/core/libs/supl/asn-rrlp/MultipleSets.c index cce55bd21..7199ac11d 100644 --- a/src/core/libs/supl/asn-rrlp/MultipleSets.c +++ b/src/core/libs/supl/asn-rrlp/MultipleSets.c @@ -56,12 +56,12 @@ memb_nbrOfReferenceBTSs_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr } } -static asn_per_constraints_t asn_PER_memb_nbrOfSets_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_NBR_OF_SETS_CONSTR_2 = { { APC_CONSTRAINED, 1, 1, 2, 3 } /* (2..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_nbrOfReferenceBTSs_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_NBR_OF_REFERENCE_BT_SS_CONSTR_3 = { { APC_CONSTRAINED, 2, 2, 1, 3 } /* (1..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_MultipleSets_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_nbrOfSets_constraint_1, - &asn_PER_memb_nbrOfSets_constr_2, + &ASN_PER_MEMB_NBR_OF_SETS_CONSTR_2, 0, "nbrOfSets" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_MultipleSets_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_nbrOfReferenceBTSs_constraint_1, - &asn_PER_memb_nbrOfReferenceBTSs_constr_3, + &ASN_PER_MEMB_NBR_OF_REFERENCE_BT_SS_CONSTR_3, 0, "nbrOfReferenceBTSs" }, diff --git a/src/core/libs/supl/asn-rrlp/NavModel-KeplerianSet.c b/src/core/libs/supl/asn-rrlp/NavModel-KeplerianSet.c index 1b2ae3a79..4dcb8a6ec 100644 --- a/src/core/libs/supl/asn-rrlp/NavModel-KeplerianSet.c +++ b/src/core/libs/supl/asn-rrlp/NavModel-KeplerianSet.c @@ -406,82 +406,82 @@ memb_keplerCuc_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_keplerToeLSB_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_TOE_LSB_CONSTR_2 = { { APC_CONSTRAINED, 9, 9, 0, 511 } /* (0..511) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerW_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_W_CONSTR_3 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerDeltaN_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_DELTA_N_CONSTR_4 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerM0_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_M0_CONSTR_5 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerOmegaDot_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_OMEGA_DOT_CONSTR_6 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerELSB_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_ELSB_CONSTR_7 = { { APC_CONSTRAINED, 25, -1, 0, 33554431 } /* (0..33554431) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerIDot_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_I_DOT_CONSTR_8 = { { APC_CONSTRAINED, 14, 14, -8192, 8191 } /* (-8192..8191) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerAPowerHalfLSB_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_A_POWER_HALF_LSB_CONSTR_9 = { { APC_CONSTRAINED, 26, -1, 0, 67108863 } /* (0..67108863) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerI0_constr_10 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_I0_CONSTR_10 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerOmega0_constr_11 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_OMEGA0_CONSTR_11 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerCrs_constr_12 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_CRS_CONSTR_12 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerCis_constr_13 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_CIS_CONSTR_13 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerCus_constr_14 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_CUS_CONSTR_14 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerCrc_constr_15 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_CRC_CONSTR_15 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerCic_constr_16 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_CIC_CONSTR_16 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_keplerCuc_constr_17 = { +static asn_per_constraints_t ASN_PER_MEMB_KEPLER_CUC_CONSTR_17 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -492,7 +492,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerToeLSB_constraint_1, - &asn_PER_memb_keplerToeLSB_constr_2, + &ASN_PER_MEMB_KEPLER_TOE_LSB_CONSTR_2, 0, "keplerToeLSB" }, @@ -501,7 +501,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerW_constraint_1, - &asn_PER_memb_keplerW_constr_3, + &ASN_PER_MEMB_KEPLER_W_CONSTR_3, 0, "keplerW" }, @@ -510,7 +510,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerDeltaN_constraint_1, - &asn_PER_memb_keplerDeltaN_constr_4, + &ASN_PER_MEMB_KEPLER_DELTA_N_CONSTR_4, 0, "keplerDeltaN" }, @@ -519,7 +519,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerM0_constraint_1, - &asn_PER_memb_keplerM0_constr_5, + &ASN_PER_MEMB_KEPLER_M0_CONSTR_5, 0, "keplerM0" }, @@ -528,7 +528,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerOmegaDot_constraint_1, - &asn_PER_memb_keplerOmegaDot_constr_6, + &ASN_PER_MEMB_KEPLER_OMEGA_DOT_CONSTR_6, 0, "keplerOmegaDot" }, @@ -537,7 +537,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerELSB_constraint_1, - &asn_PER_memb_keplerELSB_constr_7, + &ASN_PER_MEMB_KEPLER_ELSB_CONSTR_7, 0, "keplerELSB" }, @@ -546,7 +546,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerIDot_constraint_1, - &asn_PER_memb_keplerIDot_constr_8, + &ASN_PER_MEMB_KEPLER_I_DOT_CONSTR_8, 0, "keplerIDot" }, @@ -555,7 +555,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerAPowerHalfLSB_constraint_1, - &asn_PER_memb_keplerAPowerHalfLSB_constr_9, + &ASN_PER_MEMB_KEPLER_A_POWER_HALF_LSB_CONSTR_9, 0, "keplerAPowerHalfLSB" }, @@ -564,7 +564,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerI0_constraint_1, - &asn_PER_memb_keplerI0_constr_10, + &ASN_PER_MEMB_KEPLER_I0_CONSTR_10, 0, "keplerI0" }, @@ -573,7 +573,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerOmega0_constraint_1, - &asn_PER_memb_keplerOmega0_constr_11, + &ASN_PER_MEMB_KEPLER_OMEGA0_CONSTR_11, 0, "keplerOmega0" }, @@ -582,7 +582,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerCrs_constraint_1, - &asn_PER_memb_keplerCrs_constr_12, + &ASN_PER_MEMB_KEPLER_CRS_CONSTR_12, 0, "keplerCrs" }, @@ -591,7 +591,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerCis_constraint_1, - &asn_PER_memb_keplerCis_constr_13, + &ASN_PER_MEMB_KEPLER_CIS_CONSTR_13, 0, "keplerCis" }, @@ -600,7 +600,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerCus_constraint_1, - &asn_PER_memb_keplerCus_constr_14, + &ASN_PER_MEMB_KEPLER_CUS_CONSTR_14, 0, "keplerCus" }, @@ -609,7 +609,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerCrc_constraint_1, - &asn_PER_memb_keplerCrc_constr_15, + &ASN_PER_MEMB_KEPLER_CRC_CONSTR_15, 0, "keplerCrc" }, @@ -618,7 +618,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerCic_constraint_1, - &asn_PER_memb_keplerCic_constr_16, + &ASN_PER_MEMB_KEPLER_CIC_CONSTR_16, 0, "keplerCic" }, @@ -627,7 +627,7 @@ static asn_TYPE_member_t asn_MBR_NavModel_KeplerianSet_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_keplerCuc_constraint_1, - &asn_PER_memb_keplerCuc_constr_17, + &ASN_PER_MEMB_KEPLER_CUC_CONSTR_17, 0, "keplerCuc" }, diff --git a/src/core/libs/supl/asn-rrlp/NeighborIdentity.c b/src/core/libs/supl/asn-rrlp/NeighborIdentity.c index 624b5cec2..4c6a649bb 100644 --- a/src/core/libs/supl/asn-rrlp/NeighborIdentity.c +++ b/src/core/libs/supl/asn-rrlp/NeighborIdentity.c @@ -6,7 +6,7 @@ #include "NeighborIdentity.h" -static asn_per_constraints_t asn_PER_type_NeighborIdentity_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_NEIGHBOR_IDENTITY_CONSTR_1 = { { APC_CONSTRAINED, 3, 3, 0, 5 } /* (0..5) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -102,7 +102,7 @@ asn_TYPE_descriptor_t asn_DEF_NeighborIdentity = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_NeighborIdentity_constr_1, + &ASN_PER_TYPE_NEIGHBOR_IDENTITY_CONSTR_1, asn_MBR_NeighborIdentity_1, 6, /* Elements count */ &asn_SPC_NeighborIdentity_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c b/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c index 1f748f2cc..047b97557 100644 --- a/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c +++ b/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c @@ -111,7 +111,7 @@ NumOfMeasurements_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_NumOfMeasurements_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_NUM_OF_MEASUREMENTS_CONSTR_1 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_NumOfMeasurements = { asn_DEF_NumOfMeasurements_tags_1, /* Same as above */ sizeof(asn_DEF_NumOfMeasurements_tags_1) /sizeof(asn_DEF_NumOfMeasurements_tags_1[0]), /* 1 */ - &asn_PER_type_NumOfMeasurements_constr_1, + &ASN_PER_TYPE_NUM_OF_MEASUREMENTS_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/OCTET_STRING.c b/src/core/libs/supl/asn-rrlp/OCTET_STRING.c index 584def8b4..98aebb3bf 100644 --- a/src/core/libs/supl/asn-rrlp/OCTET_STRING.c +++ b/src/core/libs/supl/asn-rrlp/OCTET_STRING.c @@ -19,7 +19,7 @@ static asn_OCTET_STRING_specifics_t asn_DEF_OCTET_STRING_specs = { offsetof(OCTET_STRING_t, _asn_ctx), ASN_OSUBV_STR }; -static asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = { +static asn_per_constraints_t ASN_DEF_OCTET_STRING_CONSTRAINTS = { { APC_CONSTRAINED, 8, 8, 0, 255 }, { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, 0, 0 @@ -52,9 +52,9 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { #undef NEXT_PHASE #undef PREV_PHASE #define _CH_PHASE(ctx, inc) do { \ - if(ctx->phase == 0) \ - ctx->context = 0; \ - ctx->phase += inc; \ + if((ctx)->phase == 0) \ + (ctx)->context = 0; \ + (ctx)->phase += (inc); \ } while(0) #define NEXT_PHASE(ctx) _CH_PHASE(ctx, +1) #define PREV_PHASE(ctx) _CH_PHASE(ctx, -1) @@ -1351,8 +1351,8 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, cval = &pc->value; csiz = &pc->size; } else { - cval = &asn_DEF_OCTET_STRING_constraints.value; - csiz = &asn_DEF_OCTET_STRING_constraints.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; } switch(specs->subvariant) { @@ -1400,8 +1400,8 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, int inext = per_get_few_bits(pd, 1); if(inext < 0) RETURN(RC_WMORE); if(inext) { - csiz = &asn_DEF_OCTET_STRING_constraints.size; - cval = &asn_DEF_OCTET_STRING_constraints.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; unit_bits = canonical_unit_bits; } } @@ -1526,8 +1526,8 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, cval = &pc->value; csiz = &pc->size; } else { - cval = &asn_DEF_OCTET_STRING_constraints.value; - csiz = &asn_DEF_OCTET_STRING_constraints.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; } ct_extensible = csiz->flags & APC_EXTENSIBLE; @@ -1577,8 +1577,8 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, if((int)sizeinunits < csiz->lower_bound || (int)sizeinunits > csiz->upper_bound) { if(ct_extensible) { - cval = &asn_DEF_OCTET_STRING_constraints.value; - csiz = &asn_DEF_OCTET_STRING_constraints.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; unit_bits = canonical_unit_bits; inext = 1; } else diff --git a/src/core/libs/supl/asn-rrlp/OTD-MsrElementFirst.c b/src/core/libs/supl/asn-rrlp/OTD-MsrElementFirst.c index 5a55a2d96..a61d02dc6 100644 --- a/src/core/libs/supl/asn-rrlp/OTD-MsrElementFirst.c +++ b/src/core/libs/supl/asn-rrlp/OTD-MsrElementFirst.c @@ -56,12 +56,12 @@ memb_taCorrection_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_refFrameNumber_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_FRAME_NUMBER_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 42431 } /* (0..42431) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_taCorrection_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_TA_CORRECTION_CONSTR_6 = { { APC_CONSTRAINED, 10, 10, 0, 960 } /* (0..960) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_OTD_MsrElementFirst_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refFrameNumber_constraint_1, - &asn_PER_memb_refFrameNumber_constr_2, + &ASN_PER_MEMB_REF_FRAME_NUMBER_CONSTR_2, 0, "refFrameNumber" }, @@ -108,7 +108,7 @@ static asn_TYPE_member_t asn_MBR_OTD_MsrElementFirst_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_taCorrection_constraint_1, - &asn_PER_memb_taCorrection_constr_6, + &ASN_PER_MEMB_TA_CORRECTION_CONSTR_6, 0, "taCorrection" }, diff --git a/src/core/libs/supl/asn-rrlp/OTD-MsrElementRest.c b/src/core/libs/supl/asn-rrlp/OTD-MsrElementRest.c index d779dab1d..ad523960e 100644 --- a/src/core/libs/supl/asn-rrlp/OTD-MsrElementRest.c +++ b/src/core/libs/supl/asn-rrlp/OTD-MsrElementRest.c @@ -56,12 +56,12 @@ memb_taCorrection_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_refFrameNumber_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_FRAME_NUMBER_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 42431 } /* (0..42431) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_taCorrection_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_TA_CORRECTION_CONSTR_6 = { { APC_CONSTRAINED, 10, 10, 0, 960 } /* (0..960) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_OTD_MsrElementRest_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refFrameNumber_constraint_1, - &asn_PER_memb_refFrameNumber_constr_2, + &ASN_PER_MEMB_REF_FRAME_NUMBER_CONSTR_2, 0, "refFrameNumber" }, @@ -108,7 +108,7 @@ static asn_TYPE_member_t asn_MBR_OTD_MsrElementRest_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_taCorrection_constraint_1, - &asn_PER_memb_taCorrection_constr_6, + &ASN_PER_MEMB_TA_CORRECTION_CONSTR_6, 0, "taCorrection" }, diff --git a/src/core/libs/supl/asn-rrlp/OTD-MsrsOfOtherSets.c b/src/core/libs/supl/asn-rrlp/OTD-MsrsOfOtherSets.c index a331cc268..d018129ab 100644 --- a/src/core/libs/supl/asn-rrlp/OTD-MsrsOfOtherSets.c +++ b/src/core/libs/supl/asn-rrlp/OTD-MsrsOfOtherSets.c @@ -6,7 +6,7 @@ #include "OTD-MsrsOfOtherSets.h" -static asn_per_constraints_t asn_PER_type_OTD_MsrsOfOtherSets_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_OTD_MSRS_OF_OTHER_SETS_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -62,7 +62,7 @@ asn_TYPE_descriptor_t asn_DEF_OTD_MsrsOfOtherSets = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_OTD_MsrsOfOtherSets_constr_1, + &ASN_PER_TYPE_OTD_MSRS_OF_OTHER_SETS_CONSTR_1, asn_MBR_OTD_MsrsOfOtherSets_1, 2, /* Elements count */ &asn_SPC_OTD_MsrsOfOtherSets_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/OTDValue.c b/src/core/libs/supl/asn-rrlp/OTDValue.c index 28ae50d85..4f837f8c9 100644 --- a/src/core/libs/supl/asn-rrlp/OTDValue.c +++ b/src/core/libs/supl/asn-rrlp/OTDValue.c @@ -111,7 +111,7 @@ OTDValue_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_OTDValue_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_OTD_VALUE_CONSTR_1 = { { APC_CONSTRAINED, 16, 16, 0, 39999 } /* (0..39999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_OTDValue = { asn_DEF_OTDValue_tags_1, /* Same as above */ sizeof(asn_DEF_OTDValue_tags_1) /sizeof(asn_DEF_OTDValue_tags_1[0]), /* 1 */ - &asn_PER_type_OTDValue_constr_1, + &ASN_PER_TYPE_OTD_VALUE_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/PDU.c b/src/core/libs/supl/asn-rrlp/PDU.c index ae0cceeed..bf4708ddd 100644 --- a/src/core/libs/supl/asn-rrlp/PDU.c +++ b/src/core/libs/supl/asn-rrlp/PDU.c @@ -31,7 +31,7 @@ memb_referenceNumber_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_referenceNumber_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REFERENCE_NUMBER_CONSTR_2 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_PDU_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_referenceNumber_constraint_1, - &asn_PER_memb_referenceNumber_constr_2, + &ASN_PER_MEMB_REFERENCE_NUMBER_CONSTR_2, 0, "referenceNumber" }, diff --git a/src/core/libs/supl/asn-rrlp/PositionData.c b/src/core/libs/supl/asn-rrlp/PositionData.c index 7f53011b8..249c4bf46 100644 --- a/src/core/libs/supl/asn-rrlp/PositionData.c +++ b/src/core/libs/supl/asn-rrlp/PositionData.c @@ -117,7 +117,7 @@ PositionData_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_PositionData_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_POSITION_DATA_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 3, 16 } /* (SIZE(3..16)) */, 0, 0 /* No PER value map */ @@ -144,7 +144,7 @@ asn_TYPE_descriptor_t asn_DEF_PositionData = { asn_DEF_PositionData_tags_1, /* Same as above */ sizeof(asn_DEF_PositionData_tags_1) /sizeof(asn_DEF_PositionData_tags_1[0]), /* 1 */ - &asn_PER_type_PositionData_constr_1, + &ASN_PER_TYPE_POSITION_DATA_CONSTR_1, 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/PositionMethod.c b/src/core/libs/supl/asn-rrlp/PositionMethod.c index 07e07f2a3..b1c3df488 100644 --- a/src/core/libs/supl/asn-rrlp/PositionMethod.c +++ b/src/core/libs/supl/asn-rrlp/PositionMethod.c @@ -94,7 +94,7 @@ PositionMethod_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_PositionMethod_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_POSITION_METHOD_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -140,7 +140,7 @@ asn_TYPE_descriptor_t asn_DEF_PositionMethod = { asn_DEF_PositionMethod_tags_1, /* Same as above */ sizeof(asn_DEF_PositionMethod_tags_1) /sizeof(asn_DEF_PositionMethod_tags_1[0]), /* 1 */ - &asn_PER_type_PositionMethod_constr_1, + &ASN_PER_TYPE_POSITION_METHOD_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_PositionMethod_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/RRLP-Component.c b/src/core/libs/supl/asn-rrlp/RRLP-Component.c index e587f7de4..fe8f448a7 100644 --- a/src/core/libs/supl/asn-rrlp/RRLP-Component.c +++ b/src/core/libs/supl/asn-rrlp/RRLP-Component.c @@ -6,7 +6,7 @@ #include "RRLP-Component.h" -static asn_per_constraints_t asn_PER_type_RRLP_Component_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_RRLP_COMPONENT_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 4 } /* (0..4,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -92,7 +92,7 @@ asn_TYPE_descriptor_t asn_DEF_RRLP_Component = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_RRLP_Component_constr_1, + &ASN_PER_TYPE_RRLP_COMPONENT_CONSTR_1, asn_MBR_RRLP_Component_1, 5, /* Elements count */ &asn_SPC_RRLP_Component_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/RefQuality.c b/src/core/libs/supl/asn-rrlp/RefQuality.c index f64877ef4..0b4fd5c23 100644 --- a/src/core/libs/supl/asn-rrlp/RefQuality.c +++ b/src/core/libs/supl/asn-rrlp/RefQuality.c @@ -111,7 +111,7 @@ RefQuality_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_RefQuality_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_REF_QUALITY_CONSTR_1 = { { APC_CONSTRAINED, 5, 5, 0, 31 } /* (0..31) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_RefQuality = { asn_DEF_RefQuality_tags_1, /* Same as above */ sizeof(asn_DEF_RefQuality_tags_1) /sizeof(asn_DEF_RefQuality_tags_1[0]), /* 1 */ - &asn_PER_type_RefQuality_constr_1, + &ASN_PER_TYPE_REF_QUALITY_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/ReferenceFrame.c b/src/core/libs/supl/asn-rrlp/ReferenceFrame.c index 56c1bbc50..96d482637 100644 --- a/src/core/libs/supl/asn-rrlp/ReferenceFrame.c +++ b/src/core/libs/supl/asn-rrlp/ReferenceFrame.c @@ -56,12 +56,12 @@ memb_referenceFNMSB_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_referenceFN_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REFERENCE_FN_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_referenceFNMSB_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_REFERENCE_FNMSB_CONSTR_3 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_ReferenceFrame_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_referenceFN_constraint_1, - &asn_PER_memb_referenceFN_constr_2, + &ASN_PER_MEMB_REFERENCE_FN_CONSTR_2, 0, "referenceFN" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_ReferenceFrame_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_referenceFNMSB_constraint_1, - &asn_PER_memb_referenceFNMSB_constr_3, + &ASN_PER_MEMB_REFERENCE_FNMSB_CONSTR_3, 0, "referenceFNMSB" }, diff --git a/src/core/libs/supl/asn-rrlp/ReferenceIdentityType.c b/src/core/libs/supl/asn-rrlp/ReferenceIdentityType.c index d36515591..95e47ecb4 100644 --- a/src/core/libs/supl/asn-rrlp/ReferenceIdentityType.c +++ b/src/core/libs/supl/asn-rrlp/ReferenceIdentityType.c @@ -6,7 +6,7 @@ #include "ReferenceIdentityType.h" -static asn_per_constraints_t asn_PER_type_ReferenceIdentityType_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_REFERENCE_IDENTITY_TYPE_CONSTR_1 = { { APC_CONSTRAINED, 3, 3, 0, 4 } /* (0..4) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -92,7 +92,7 @@ asn_TYPE_descriptor_t asn_DEF_ReferenceIdentityType = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_ReferenceIdentityType_constr_1, + &ASN_PER_TYPE_REFERENCE_IDENTITY_TYPE_CONSTR_1, asn_MBR_ReferenceIdentityType_1, 5, /* Elements count */ &asn_SPC_ReferenceIdentityType_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/ReferenceRelation.c b/src/core/libs/supl/asn-rrlp/ReferenceRelation.c index 931e2c477..c4497a860 100644 --- a/src/core/libs/supl/asn-rrlp/ReferenceRelation.c +++ b/src/core/libs/supl/asn-rrlp/ReferenceRelation.c @@ -94,7 +94,7 @@ ReferenceRelation_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_ReferenceRelation_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_REFERENCE_RELATION_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -140,7 +140,7 @@ asn_TYPE_descriptor_t asn_DEF_ReferenceRelation = { asn_DEF_ReferenceRelation_tags_1, /* Same as above */ sizeof(asn_DEF_ReferenceRelation_tags_1) /sizeof(asn_DEF_ReferenceRelation_tags_1[0]), /* 1 */ - &asn_PER_type_ReferenceRelation_constr_1, + &ASN_PER_TYPE_REFERENCE_RELATION_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_ReferenceRelation_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/RelDistance.c b/src/core/libs/supl/asn-rrlp/RelDistance.c index a444e3f70..8273278e4 100644 --- a/src/core/libs/supl/asn-rrlp/RelDistance.c +++ b/src/core/libs/supl/asn-rrlp/RelDistance.c @@ -111,7 +111,7 @@ RelDistance_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_RelDistance_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_REL_DISTANCE_CONSTR_1 = { { APC_CONSTRAINED, 19, -1, -200000, 200000 } /* (-200000..200000) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_RelDistance = { asn_DEF_RelDistance_tags_1, /* Same as above */ sizeof(asn_DEF_RelDistance_tags_1) /sizeof(asn_DEF_RelDistance_tags_1[0]), /* 1 */ - &asn_PER_type_RelDistance_constr_1, + &ASN_PER_TYPE_REL_DISTANCE_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/RelativeAlt.c b/src/core/libs/supl/asn-rrlp/RelativeAlt.c index c65d44aa1..78cc612e4 100644 --- a/src/core/libs/supl/asn-rrlp/RelativeAlt.c +++ b/src/core/libs/supl/asn-rrlp/RelativeAlt.c @@ -111,7 +111,7 @@ RelativeAlt_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_RelativeAlt_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_RELATIVE_ALT_CONSTR_1 = { { APC_CONSTRAINED, 13, 13, -4000, 4000 } /* (-4000..4000) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_RelativeAlt = { asn_DEF_RelativeAlt_tags_1, /* Same as above */ sizeof(asn_DEF_RelativeAlt_tags_1) /sizeof(asn_DEF_RelativeAlt_tags_1[0]), /* 1 */ - &asn_PER_type_RelativeAlt_constr_1, + &ASN_PER_TYPE_RELATIVE_ALT_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/RequestIndex.c b/src/core/libs/supl/asn-rrlp/RequestIndex.c index 6d481f20f..f238a32f6 100644 --- a/src/core/libs/supl/asn-rrlp/RequestIndex.c +++ b/src/core/libs/supl/asn-rrlp/RequestIndex.c @@ -111,7 +111,7 @@ RequestIndex_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_RequestIndex_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_REQUEST_INDEX_CONSTR_1 = { { APC_CONSTRAINED, 4, 4, 1, 16 } /* (1..16) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_RequestIndex = { asn_DEF_RequestIndex_tags_1, /* Same as above */ sizeof(asn_DEF_RequestIndex_tags_1) /sizeof(asn_DEF_RequestIndex_tags_1[0]), /* 1 */ - &asn_PER_type_RequestIndex_constr_1, + &ASN_PER_TYPE_REQUEST_INDEX_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c b/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c index 52aff059d..89fd8b230 100644 --- a/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c +++ b/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c @@ -111,7 +111,7 @@ RequiredResponseTime_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_RequiredResponseTime_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_REQUIRED_RESPONSE_TIME_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 1, 128 } /* (1..128) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_RequiredResponseTime = { asn_DEF_RequiredResponseTime_tags_1, /* Same as above */ sizeof(asn_DEF_RequiredResponseTime_tags_1) /sizeof(asn_DEF_RequiredResponseTime_tags_1[0]), /* 1 */ - &asn_PER_type_RequiredResponseTime_constr_1, + &ASN_PER_TYPE_REQUIRED_RESPONSE_TIME_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/RoughRTD.c b/src/core/libs/supl/asn-rrlp/RoughRTD.c index db420b619..d9222b869 100644 --- a/src/core/libs/supl/asn-rrlp/RoughRTD.c +++ b/src/core/libs/supl/asn-rrlp/RoughRTD.c @@ -111,7 +111,7 @@ RoughRTD_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_RoughRTD_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ROUGH_RTD_CONSTR_1 = { { APC_CONSTRAINED, 11, 11, 0, 1250 } /* (0..1250) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_RoughRTD = { asn_DEF_RoughRTD_tags_1, /* Same as above */ sizeof(asn_DEF_RoughRTD_tags_1) /sizeof(asn_DEF_RoughRTD_tags_1[0]), /* 1 */ - &asn_PER_type_RoughRTD_constr_1, + &ASN_PER_TYPE_ROUGH_RTD_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/SVID.c b/src/core/libs/supl/asn-rrlp/SVID.c index 5a9adbd3a..ab082f9c0 100644 --- a/src/core/libs/supl/asn-rrlp/SVID.c +++ b/src/core/libs/supl/asn-rrlp/SVID.c @@ -111,7 +111,7 @@ SVID_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_SVID_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SVID_CONSTR_1 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_SVID = { asn_DEF_SVID_tags_1, /* Same as above */ sizeof(asn_DEF_SVID_tags_1) /sizeof(asn_DEF_SVID_tags_1[0]), /* 1 */ - &asn_PER_type_SVID_constr_1, + &ASN_PER_TYPE_SVID_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/SVIDMASK.c b/src/core/libs/supl/asn-rrlp/SVIDMASK.c index 7c2c1a590..9791443d6 100644 --- a/src/core/libs/supl/asn-rrlp/SVIDMASK.c +++ b/src/core/libs/supl/asn-rrlp/SVIDMASK.c @@ -117,7 +117,7 @@ SVIDMASK_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_SVIDMASK_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SVIDMASK_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 6, 6, 1, 36 } /* (SIZE(1..36)) */, 0, 0 /* No PER value map */ @@ -144,7 +144,7 @@ asn_TYPE_descriptor_t asn_DEF_SVIDMASK = { asn_DEF_SVIDMASK_tags_1, /* Same as above */ sizeof(asn_DEF_SVIDMASK_tags_1) /sizeof(asn_DEF_SVIDMASK_tags_1[0]), /* 1 */ - &asn_PER_type_SVIDMASK_constr_1, + &ASN_PER_TYPE_SVIDMASK_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/SatElement.c b/src/core/libs/supl/asn-rrlp/SatElement.c index 5a3eaf8e1..bab8b9de3 100644 --- a/src/core/libs/supl/asn-rrlp/SatElement.c +++ b/src/core/libs/supl/asn-rrlp/SatElement.c @@ -206,42 +206,42 @@ memb_deltaRangeRateCor3_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr } } -static asn_per_constraints_t asn_PER_memb_iode_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_IODE_CONSTR_3 = { { APC_CONSTRAINED, 8, 8, 0, 239 } /* (0..239) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_udre_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_UDRE_CONSTR_4 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_pseudoRangeCor_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_PSEUDO_RANGE_COR_CONSTR_5 = { { APC_CONSTRAINED, 12, 12, -2047, 2047 } /* (-2047..2047) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_rangeRateCor_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_RANGE_RATE_COR_CONSTR_6 = { { APC_CONSTRAINED, 8, 8, -127, 127 } /* (-127..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_deltaPseudoRangeCor2_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_DELTA_PSEUDO_RANGE_COR2_CONSTR_7 = { { APC_CONSTRAINED, 8, 8, -127, 127 } /* (-127..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_deltaRangeRateCor2_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_DELTA_RANGE_RATE_COR2_CONSTR_8 = { { APC_CONSTRAINED, 4, 4, -7, 7 } /* (-7..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_deltaPseudoRangeCor3_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_DELTA_PSEUDO_RANGE_COR3_CONSTR_9 = { { APC_CONSTRAINED, 8, 8, -127, 127 } /* (-127..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_deltaRangeRateCor3_constr_10 = { +static asn_per_constraints_t ASN_PER_MEMB_DELTA_RANGE_RATE_COR3_CONSTR_10 = { { APC_CONSTRAINED, 4, 4, -7, 7 } /* (-7..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -261,7 +261,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_iode_constraint_1, - &asn_PER_memb_iode_constr_3, + &ASN_PER_MEMB_IODE_CONSTR_3, 0, "iode" }, @@ -270,7 +270,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_udre_constraint_1, - &asn_PER_memb_udre_constr_4, + &ASN_PER_MEMB_UDRE_CONSTR_4, 0, "udre" }, @@ -279,7 +279,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_pseudoRangeCor_constraint_1, - &asn_PER_memb_pseudoRangeCor_constr_5, + &ASN_PER_MEMB_PSEUDO_RANGE_COR_CONSTR_5, 0, "pseudoRangeCor" }, @@ -288,7 +288,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_rangeRateCor_constraint_1, - &asn_PER_memb_rangeRateCor_constr_6, + &ASN_PER_MEMB_RANGE_RATE_COR_CONSTR_6, 0, "rangeRateCor" }, @@ -297,7 +297,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_deltaPseudoRangeCor2_constraint_1, - &asn_PER_memb_deltaPseudoRangeCor2_constr_7, + &ASN_PER_MEMB_DELTA_PSEUDO_RANGE_COR2_CONSTR_7, 0, "deltaPseudoRangeCor2" }, @@ -306,7 +306,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_deltaRangeRateCor2_constraint_1, - &asn_PER_memb_deltaRangeRateCor2_constr_8, + &ASN_PER_MEMB_DELTA_RANGE_RATE_COR2_CONSTR_8, 0, "deltaRangeRateCor2" }, @@ -315,7 +315,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_deltaPseudoRangeCor3_constraint_1, - &asn_PER_memb_deltaPseudoRangeCor3_constr_9, + &ASN_PER_MEMB_DELTA_PSEUDO_RANGE_COR3_CONSTR_9, 0, "deltaPseudoRangeCor3" }, @@ -324,7 +324,7 @@ static asn_TYPE_member_t asn_MBR_SatElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_deltaRangeRateCor3_constraint_1, - &asn_PER_memb_deltaRangeRateCor3_constr_10, + &ASN_PER_MEMB_DELTA_RANGE_RATE_COR3_CONSTR_10, 0, "deltaRangeRateCor3" }, diff --git a/src/core/libs/supl/asn-rrlp/SatStatus.c b/src/core/libs/supl/asn-rrlp/SatStatus.c index b92afe853..4f7306873 100644 --- a/src/core/libs/supl/asn-rrlp/SatStatus.c +++ b/src/core/libs/supl/asn-rrlp/SatStatus.c @@ -6,7 +6,7 @@ #include "SatStatus.h" -static asn_per_constraints_t asn_PER_type_SatStatus_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SAT_STATUS_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ asn_TYPE_descriptor_t asn_DEF_SatStatus = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_SatStatus_constr_1, + &ASN_PER_TYPE_SAT_STATUS_CONSTR_1, asn_MBR_SatStatus_1, 3, /* Elements count */ &asn_SPC_SatStatus_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SatelliteID.c b/src/core/libs/supl/asn-rrlp/SatelliteID.c index 84951ec1a..9d95fda67 100644 --- a/src/core/libs/supl/asn-rrlp/SatelliteID.c +++ b/src/core/libs/supl/asn-rrlp/SatelliteID.c @@ -111,7 +111,7 @@ SatelliteID_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_SatelliteID_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SATELLITE_ID_CONSTR_1 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_SatelliteID = { asn_DEF_SatelliteID_tags_1, /* Same as above */ sizeof(asn_DEF_SatelliteID_tags_1) /sizeof(asn_DEF_SatelliteID_tags_1[0]), /* 1 */ - &asn_PER_type_SatelliteID_constr_1, + &ASN_PER_TYPE_SATELLITE_ID_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/SeqOf-BadSatelliteSet.c b/src/core/libs/supl/asn-rrlp/SeqOf-BadSatelliteSet.c index 7425bba8d..867b4dbae 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOf-BadSatelliteSet.c +++ b/src/core/libs/supl/asn-rrlp/SeqOf-BadSatelliteSet.c @@ -6,7 +6,7 @@ #include "SeqOf-BadSatelliteSet.h" -static asn_per_constraints_t asn_PER_type_SeqOf_BadSatelliteSet_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_BAD_SATELLITE_SET_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOf_BadSatelliteSet = { asn_DEF_SeqOf_BadSatelliteSet_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOf_BadSatelliteSet_tags_1) /sizeof(asn_DEF_SeqOf_BadSatelliteSet_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOf_BadSatelliteSet_constr_1, + &ASN_PER_TYPE_SEQ_OF_BAD_SATELLITE_SET_CONSTR_1, asn_MBR_SeqOf_BadSatelliteSet_1, 1, /* Single element */ &asn_SPC_SeqOf_BadSatelliteSet_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOf-GANSSDataBits.c b/src/core/libs/supl/asn-rrlp/SeqOf-GANSSDataBits.c index 2347dbef1..c613f6ea8 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOf-GANSSDataBits.c +++ b/src/core/libs/supl/asn-rrlp/SeqOf-GANSSDataBits.c @@ -6,7 +6,7 @@ #include "SeqOf-GANSSDataBits.h" -static asn_per_constraints_t asn_PER_type_SeqOf_GANSSDataBits_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_DATA_BITS_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 10, 10, 1, 1024 } /* (SIZE(1..1024)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOf_GANSSDataBits = { asn_DEF_SeqOf_GANSSDataBits_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOf_GANSSDataBits_tags_1) /sizeof(asn_DEF_SeqOf_GANSSDataBits_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOf_GANSSDataBits_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_DATA_BITS_CONSTR_1, asn_MBR_SeqOf_GANSSDataBits_1, 1, /* Single element */ &asn_SPC_SeqOf_GANSSDataBits_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfAcquisElement.c b/src/core/libs/supl/asn-rrlp/SeqOfAcquisElement.c index 4084ecaf0..a52a77112 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfAcquisElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfAcquisElement.c @@ -6,7 +6,7 @@ #include "SeqOfAcquisElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfAcquisElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_ACQUIS_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfAcquisElement = { asn_DEF_SeqOfAcquisElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfAcquisElement_tags_1) /sizeof(asn_DEF_SeqOfAcquisElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfAcquisElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_ACQUIS_ELEMENT_CONSTR_1, asn_MBR_SeqOfAcquisElement_1, 1, /* Single element */ &asn_SPC_SeqOfAcquisElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfAlmanacElement.c b/src/core/libs/supl/asn-rrlp/SeqOfAlmanacElement.c index 33843ff27..3d030ddc1 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfAlmanacElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfAlmanacElement.c @@ -6,7 +6,7 @@ #include "SeqOfAlmanacElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfAlmanacElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_ALMANAC_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 6, 6, 1, 64 } /* (SIZE(1..64)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfAlmanacElement = { asn_DEF_SeqOfAlmanacElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfAlmanacElement_tags_1) /sizeof(asn_DEF_SeqOfAlmanacElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfAlmanacElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_ALMANAC_ELEMENT_CONSTR_1, asn_MBR_SeqOfAlmanacElement_1, 1, /* Single element */ &asn_SPC_SeqOfAlmanacElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfBadSignalElement.c b/src/core/libs/supl/asn-rrlp/SeqOfBadSignalElement.c index 1e77ca7ff..61e5d3c6f 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfBadSignalElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfBadSignalElement.c @@ -6,7 +6,7 @@ #include "SeqOfBadSignalElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfBadSignalElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_BAD_SIGNAL_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfBadSignalElement = { asn_DEF_SeqOfBadSignalElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfBadSignalElement_tags_1) /sizeof(asn_DEF_SeqOfBadSignalElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfBadSignalElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_BAD_SIGNAL_ELEMENT_CONSTR_1, asn_MBR_SeqOfBadSignalElement_1, 1, /* Single element */ &asn_SPC_SeqOfBadSignalElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfDGANSSSgnElement.c b/src/core/libs/supl/asn-rrlp/SeqOfDGANSSSgnElement.c index e65dcad05..d53e83fe1 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfDGANSSSgnElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfDGANSSSgnElement.c @@ -6,7 +6,7 @@ #include "SeqOfDGANSSSgnElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfDGANSSSgnElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_DGANSS_SGN_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfDGANSSSgnElement = { asn_DEF_SeqOfDGANSSSgnElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfDGANSSSgnElement_tags_1) /sizeof(asn_DEF_SeqOfDGANSSSgnElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfDGANSSSgnElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_DGANSS_SGN_ELEMENT_CONSTR_1, asn_MBR_SeqOfDGANSSSgnElement_1, 1, /* Single element */ &asn_SPC_SeqOfDGANSSSgnElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSS-MsrSetElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSS-MsrSetElement.c index 689475fdd..066acec5a 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSS-MsrSetElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSS-MsrSetElement.c @@ -6,7 +6,7 @@ #include "SeqOfGANSS-MsrSetElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSS_MsrSetElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_MSR_SET_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 2, 2, 1, 3 } /* (SIZE(1..3)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSS_MsrSetElement = { asn_DEF_SeqOfGANSS_MsrSetElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSS_MsrSetElement_tags_1) /sizeof(asn_DEF_SeqOfGANSS_MsrSetElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSS_MsrSetElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_MSR_SET_ELEMENT_CONSTR_1, asn_MBR_SeqOfGANSS_MsrSetElement_1, 1, /* Single element */ &asn_SPC_SeqOfGANSS_MsrSetElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnElement.c index 8543904c5..e77545690 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnElement.c @@ -6,7 +6,7 @@ #include "SeqOfGANSS-SgnElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSS_SgnElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_SGN_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSS_SgnElement = { asn_DEF_SeqOfGANSS_SgnElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSS_SgnElement_tags_1) /sizeof(asn_DEF_SeqOfGANSS_SgnElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSS_SgnElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_SGN_ELEMENT_CONSTR_1, asn_MBR_SeqOfGANSS_SgnElement_1, 1, /* Single element */ &asn_SPC_SeqOfGANSS_SgnElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnTypeElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnTypeElement.c index 706d36493..4144d9ae6 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnTypeElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSS-SgnTypeElement.c @@ -6,7 +6,7 @@ #include "SeqOfGANSS-SgnTypeElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSS_SgnTypeElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_SGN_TYPE_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 3, 3, 1, 6 } /* (SIZE(1..6)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSS_SgnTypeElement = { asn_DEF_SeqOfGANSS_SgnTypeElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSS_SgnTypeElement_tags_1) /sizeof(asn_DEF_SeqOfGANSS_SgnTypeElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSS_SgnTypeElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_SGN_TYPE_ELEMENT_CONSTR_1, asn_MBR_SeqOfGANSS_SgnTypeElement_1, 1, /* Single element */ &asn_SPC_SeqOfGANSS_SgnTypeElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSSAlmanacElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSSAlmanacElement.c index 1b6a339f8..18eb57152 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSSAlmanacElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSSAlmanacElement.c @@ -6,7 +6,7 @@ #include "SeqOfGANSSAlmanacElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSSAlmanacElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_ALMANAC_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 6, 6, 1, 36 } /* (SIZE(1..36)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSSAlmanacElement = { asn_DEF_SeqOfGANSSAlmanacElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSSAlmanacElement_tags_1) /sizeof(asn_DEF_SeqOfGANSSAlmanacElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSSAlmanacElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_ALMANAC_ELEMENT_CONSTR_1, asn_MBR_SeqOfGANSSAlmanacElement_1, 1, /* Single element */ &asn_SPC_SeqOfGANSSAlmanacElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSSGenericAssistDataElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSSGenericAssistDataElement.c index 737ab2623..56bdf4074 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSSGenericAssistDataElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSSGenericAssistDataElement.c @@ -6,7 +6,7 @@ #include "SeqOfGANSSGenericAssistDataElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSSGenericAssistDataElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_GENERIC_ASSIST_DATA_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 3, 3, 1, 8 } /* (SIZE(1..8)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSSGenericAssistDataElement = { asn_DEF_SeqOfGANSSGenericAssistDataElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSSGenericAssistDataElement_tags_1) /sizeof(asn_DEF_SeqOfGANSSGenericAssistDataElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSSGenericAssistDataElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_GENERIC_ASSIST_DATA_ELEMENT_CONSTR_1, asn_MBR_SeqOfGANSSGenericAssistDataElement_1, 1, /* Single element */ &asn_SPC_SeqOfGANSSGenericAssistDataElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSSRefMeasurementElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSSRefMeasurementElement.c index 8e9a1bf16..f38140eec 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSSRefMeasurementElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSSRefMeasurementElement.c @@ -6,7 +6,7 @@ #include "SeqOfGANSSRefMeasurementElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSSRefMeasurementElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_REF_MEASUREMENT_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSSRefMeasurementElement = { asn_DEF_SeqOfGANSSRefMeasurementElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSSRefMeasurementElement_tags_1) /sizeof(asn_DEF_SeqOfGANSSRefMeasurementElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSSRefMeasurementElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_REF_MEASUREMENT_ELEMENT_CONSTR_1, asn_MBR_SeqOfGANSSRefMeasurementElement_1, 1, /* Single element */ &asn_SPC_SeqOfGANSSRefMeasurementElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSSSatelliteElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSSSatelliteElement.c index 5c9c95fa5..21c130866 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSSSatelliteElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSSSatelliteElement.c @@ -6,7 +6,7 @@ #include "SeqOfGANSSSatelliteElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSSSatelliteElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_SATELLITE_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 5, 5, 1, 32 } /* (SIZE(1..32)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSSSatelliteElement = { asn_DEF_SeqOfGANSSSatelliteElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSSSatelliteElement_tags_1) /sizeof(asn_DEF_SeqOfGANSSSatelliteElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSSSatelliteElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_SATELLITE_ELEMENT_CONSTR_1, asn_MBR_SeqOfGANSSSatelliteElement_1, 1, /* Single element */ &asn_SPC_SeqOfGANSSSatelliteElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGANSSTimeModel.c b/src/core/libs/supl/asn-rrlp/SeqOfGANSSTimeModel.c index d3a923f23..e3341bd4d 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGANSSTimeModel.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGANSSTimeModel.c @@ -6,7 +6,7 @@ #include "SeqOfGANSSTimeModel.h" -static asn_per_constraints_t asn_PER_type_SeqOfGANSSTimeModel_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GANSS_TIME_MODEL_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 3, 3, 1, 7 } /* (SIZE(1..7)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGANSSTimeModel = { asn_DEF_SeqOfGANSSTimeModel_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGANSSTimeModel_tags_1) /sizeof(asn_DEF_SeqOfGANSSTimeModel_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGANSSTimeModel_constr_1, + &ASN_PER_TYPE_SEQ_OF_GANSS_TIME_MODEL_CONSTR_1, asn_MBR_SeqOfGANSSTimeModel_1, 1, /* Single element */ &asn_SPC_SeqOfGANSSTimeModel_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrElement.c index c66328606..16637c8b6 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrElement.c @@ -6,7 +6,7 @@ #include "SeqOfGPS-MsrElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGPS_MsrElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GPS_MSR_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGPS_MsrElement = { asn_DEF_SeqOfGPS_MsrElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGPS_MsrElement_tags_1) /sizeof(asn_DEF_SeqOfGPS_MsrElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGPS_MsrElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GPS_MSR_ELEMENT_CONSTR_1, asn_MBR_SeqOfGPS_MsrElement_1, 1, /* Single element */ &asn_SPC_SeqOfGPS_MsrElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrSetElement.c b/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrSetElement.c index b9f6297a5..ab5c3a559 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrSetElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfGPS-MsrSetElement.c @@ -6,7 +6,7 @@ #include "SeqOfGPS-MsrSetElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfGPS_MsrSetElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_GPS_MSR_SET_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 2, 2, 1, 3 } /* (SIZE(1..3)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfGPS_MsrSetElement = { asn_DEF_SeqOfGPS_MsrSetElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfGPS_MsrSetElement_tags_1) /sizeof(asn_DEF_SeqOfGPS_MsrSetElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfGPS_MsrSetElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_GPS_MSR_SET_ELEMENT_CONSTR_1, asn_MBR_SeqOfGPS_MsrSetElement_1, 1, /* Single element */ &asn_SPC_SeqOfGPS_MsrSetElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS-R98-ExpOTD.c b/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS-R98-ExpOTD.c index 15f1cefff..60bd0348d 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS-R98-ExpOTD.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS-R98-ExpOTD.c @@ -6,7 +6,7 @@ #include "SeqOfMsrAssistBTS-R98-ExpOTD.h" -static asn_per_constraints_t asn_PER_type_SeqOfMsrAssistBTS_R98_ExpOTD_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_MSR_ASSIST_BTS_R98_EXP_OTD_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 15 } /* (SIZE(1..15)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfMsrAssistBTS_R98_ExpOTD = { asn_DEF_SeqOfMsrAssistBTS_R98_ExpOTD_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfMsrAssistBTS_R98_ExpOTD_tags_1) /sizeof(asn_DEF_SeqOfMsrAssistBTS_R98_ExpOTD_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfMsrAssistBTS_R98_ExpOTD_constr_1, + &ASN_PER_TYPE_SEQ_OF_MSR_ASSIST_BTS_R98_EXP_OTD_CONSTR_1, asn_MBR_SeqOfMsrAssistBTS_R98_ExpOTD_1, 1, /* Single element */ &asn_SPC_SeqOfMsrAssistBTS_R98_ExpOTD_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS.c b/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS.c index fb1b5638e..27bff4abf 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfMsrAssistBTS.c @@ -6,7 +6,7 @@ #include "SeqOfMsrAssistBTS.h" -static asn_per_constraints_t asn_PER_type_SeqOfMsrAssistBTS_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_MSR_ASSIST_BTS_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 15 } /* (SIZE(1..15)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfMsrAssistBTS = { asn_DEF_SeqOfMsrAssistBTS_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfMsrAssistBTS_tags_1) /sizeof(asn_DEF_SeqOfMsrAssistBTS_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfMsrAssistBTS_constr_1, + &ASN_PER_TYPE_SEQ_OF_MSR_ASSIST_BTS_CONSTR_1, asn_MBR_SeqOfMsrAssistBTS_1, 1, /* Single element */ &asn_SPC_SeqOfMsrAssistBTS_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfNavModelElement.c b/src/core/libs/supl/asn-rrlp/SeqOfNavModelElement.c index d28ec04a2..1606f1a20 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfNavModelElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfNavModelElement.c @@ -6,7 +6,7 @@ #include "SeqOfNavModelElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfNavModelElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_NAV_MODEL_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfNavModelElement = { asn_DEF_SeqOfNavModelElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfNavModelElement_tags_1) /sizeof(asn_DEF_SeqOfNavModelElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfNavModelElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_NAV_MODEL_ELEMENT_CONSTR_1, asn_MBR_SeqOfNavModelElement_1, 1, /* Single element */ &asn_SPC_SeqOfNavModelElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs-R98-Ext.c b/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs-R98-Ext.c index ace76ee1a..5e2bb795d 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs-R98-Ext.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs-R98-Ext.c @@ -6,7 +6,7 @@ #include "SeqOfOTD-FirstSetMsrs-R98-Ext.h" -static asn_per_constraints_t asn_PER_type_SeqOfOTD_FirstSetMsrs_R98_Ext_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_OTD_FIRST_SET_MSRS_R98_EXT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 3, 3, 1, 5 } /* (SIZE(1..5)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfOTD_FirstSetMsrs_R98_Ext = { asn_DEF_SeqOfOTD_FirstSetMsrs_R98_Ext_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_R98_Ext_tags_1) /sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_R98_Ext_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfOTD_FirstSetMsrs_R98_Ext_constr_1, + &ASN_PER_TYPE_SEQ_OF_OTD_FIRST_SET_MSRS_R98_EXT_CONSTR_1, asn_MBR_SeqOfOTD_FirstSetMsrs_R98_Ext_1, 1, /* Single element */ &asn_SPC_SeqOfOTD_FirstSetMsrs_R98_Ext_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs.c b/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs.c index d3f9263f8..bfebd113d 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfOTD-FirstSetMsrs.c @@ -6,7 +6,7 @@ #include "SeqOfOTD-FirstSetMsrs.h" -static asn_per_constraints_t asn_PER_type_SeqOfOTD_FirstSetMsrs_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_OTD_FIRST_SET_MSRS_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 10 } /* (SIZE(1..10)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfOTD_FirstSetMsrs = { asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1) /sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfOTD_FirstSetMsrs_constr_1, + &ASN_PER_TYPE_SEQ_OF_OTD_FIRST_SET_MSRS_CONSTR_1, asn_MBR_SeqOfOTD_FirstSetMsrs_1, 1, /* Single element */ &asn_SPC_SeqOfOTD_FirstSetMsrs_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrElementRest.c b/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrElementRest.c index 27c86b0a5..dae155d61 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrElementRest.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrElementRest.c @@ -6,7 +6,7 @@ #include "SeqOfOTD-MsrElementRest.h" -static asn_per_constraints_t asn_PER_type_SeqOfOTD_MsrElementRest_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_OTD_MSR_ELEMENT_REST_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 1, 1, 1, 2 } /* (SIZE(1..2)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfOTD_MsrElementRest = { asn_DEF_SeqOfOTD_MsrElementRest_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfOTD_MsrElementRest_tags_1) /sizeof(asn_DEF_SeqOfOTD_MsrElementRest_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfOTD_MsrElementRest_constr_1, + &ASN_PER_TYPE_SEQ_OF_OTD_MSR_ELEMENT_REST_CONSTR_1, asn_MBR_SeqOfOTD_MsrElementRest_1, 1, /* Single element */ &asn_SPC_SeqOfOTD_MsrElementRest_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrsOfOtherSets.c b/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrsOfOtherSets.c index 51b804707..2c7b3b47d 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrsOfOtherSets.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfOTD-MsrsOfOtherSets.c @@ -6,7 +6,7 @@ #include "SeqOfOTD-MsrsOfOtherSets.h" -static asn_per_constraints_t asn_PER_type_SeqOfOTD_MsrsOfOtherSets_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_OTD_MSRS_OF_OTHER_SETS_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 10 } /* (SIZE(1..10)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfOTD_MsrsOfOtherSets = { asn_DEF_SeqOfOTD_MsrsOfOtherSets_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfOTD_MsrsOfOtherSets_tags_1) /sizeof(asn_DEF_SeqOfOTD_MsrsOfOtherSets_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfOTD_MsrsOfOtherSets_constr_1, + &ASN_PER_TYPE_SEQ_OF_OTD_MSRS_OF_OTHER_SETS_CONSTR_1, asn_MBR_SeqOfOTD_MsrsOfOtherSets_1, 1, /* Single element */ &asn_SPC_SeqOfOTD_MsrsOfOtherSets_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfReferenceIdentityType.c b/src/core/libs/supl/asn-rrlp/SeqOfReferenceIdentityType.c index e02edb83c..9e55174be 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfReferenceIdentityType.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfReferenceIdentityType.c @@ -6,7 +6,7 @@ #include "SeqOfReferenceIdentityType.h" -static asn_per_constraints_t asn_PER_type_SeqOfReferenceIdentityType_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_REFERENCE_IDENTITY_TYPE_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 2, 2, 1, 3 } /* (SIZE(1..3)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfReferenceIdentityType = { asn_DEF_SeqOfReferenceIdentityType_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfReferenceIdentityType_tags_1) /sizeof(asn_DEF_SeqOfReferenceIdentityType_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfReferenceIdentityType_constr_1, + &ASN_PER_TYPE_SEQ_OF_REFERENCE_IDENTITY_TYPE_CONSTR_1, asn_MBR_SeqOfReferenceIdentityType_1, 1, /* Single element */ &asn_SPC_SeqOfReferenceIdentityType_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfSatElement.c b/src/core/libs/supl/asn-rrlp/SeqOfSatElement.c index c70089990..2e8aaa42c 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfSatElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfSatElement.c @@ -6,7 +6,7 @@ #include "SeqOfSatElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfSatElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_SAT_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 16 } /* (SIZE(1..16)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfSatElement = { asn_DEF_SeqOfSatElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfSatElement_tags_1) /sizeof(asn_DEF_SeqOfSatElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfSatElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_SAT_ELEMENT_CONSTR_1, asn_MBR_SeqOfSatElement_1, 1, /* Single element */ &asn_SPC_SeqOfSatElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfSgnTypeElement.c b/src/core/libs/supl/asn-rrlp/SeqOfSgnTypeElement.c index 36a8f243a..23920f7fc 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfSgnTypeElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfSgnTypeElement.c @@ -6,7 +6,7 @@ #include "SeqOfSgnTypeElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfSgnTypeElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_SGN_TYPE_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 2, 2, 1, 3 } /* (SIZE(1..3)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfSgnTypeElement = { asn_DEF_SeqOfSgnTypeElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfSgnTypeElement_tags_1) /sizeof(asn_DEF_SeqOfSgnTypeElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfSgnTypeElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_SGN_TYPE_ELEMENT_CONSTR_1, asn_MBR_SeqOfSgnTypeElement_1, 1, /* Single element */ &asn_SPC_SeqOfSgnTypeElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfStandardClockModelElement.c b/src/core/libs/supl/asn-rrlp/SeqOfStandardClockModelElement.c index 4ecbbcbb7..43c0778d7 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfStandardClockModelElement.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfStandardClockModelElement.c @@ -6,7 +6,7 @@ #include "SeqOfStandardClockModelElement.h" -static asn_per_constraints_t asn_PER_type_SeqOfStandardClockModelElement_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_STANDARD_CLOCK_MODEL_ELEMENT_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 1, 1, 1, 2 } /* (SIZE(1..2)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfStandardClockModelElement = { asn_DEF_SeqOfStandardClockModelElement_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfStandardClockModelElement_tags_1) /sizeof(asn_DEF_SeqOfStandardClockModelElement_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfStandardClockModelElement_constr_1, + &ASN_PER_TYPE_SEQ_OF_STANDARD_CLOCK_MODEL_ELEMENT_CONSTR_1, asn_MBR_SeqOfStandardClockModelElement_1, 1, /* Single element */ &asn_SPC_SeqOfStandardClockModelElement_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS-R98-ExpOTD.c b/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS-R98-ExpOTD.c index ae77b5fee..0f53a336b 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS-R98-ExpOTD.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS-R98-ExpOTD.c @@ -6,7 +6,7 @@ #include "SeqOfSystemInfoAssistBTS-R98-ExpOTD.h" -static asn_per_constraints_t asn_PER_type_SeqOfSystemInfoAssistBTS_R98_ExpOTD_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_SYSTEM_INFO_ASSIST_BTS_R98_EXP_OTD_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 5, 5, 1, 32 } /* (SIZE(1..32)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfSystemInfoAssistBTS_R98_ExpOTD = { asn_DEF_SeqOfSystemInfoAssistBTS_R98_ExpOTD_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfSystemInfoAssistBTS_R98_ExpOTD_tags_1) /sizeof(asn_DEF_SeqOfSystemInfoAssistBTS_R98_ExpOTD_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfSystemInfoAssistBTS_R98_ExpOTD_constr_1, + &ASN_PER_TYPE_SEQ_OF_SYSTEM_INFO_ASSIST_BTS_R98_EXP_OTD_CONSTR_1, asn_MBR_SeqOfSystemInfoAssistBTS_R98_ExpOTD_1, 1, /* Single element */ &asn_SPC_SeqOfSystemInfoAssistBTS_R98_ExpOTD_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS.c b/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS.c index a728a3bde..9a0af489a 100644 --- a/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS.c +++ b/src/core/libs/supl/asn-rrlp/SeqOfSystemInfoAssistBTS.c @@ -6,7 +6,7 @@ #include "SeqOfSystemInfoAssistBTS.h" -static asn_per_constraints_t asn_PER_type_SeqOfSystemInfoAssistBTS_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_SYSTEM_INFO_ASSIST_BTS_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 5, 5, 1, 32 } /* (SIZE(1..32)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SeqOfSystemInfoAssistBTS = { asn_DEF_SeqOfSystemInfoAssistBTS_tags_1, /* Same as above */ sizeof(asn_DEF_SeqOfSystemInfoAssistBTS_tags_1) /sizeof(asn_DEF_SeqOfSystemInfoAssistBTS_tags_1[0]), /* 1 */ - &asn_PER_type_SeqOfSystemInfoAssistBTS_constr_1, + &ASN_PER_TYPE_SEQ_OF_SYSTEM_INFO_ASSIST_BTS_CONSTR_1, asn_MBR_SeqOfSystemInfoAssistBTS_1, 1, /* Single element */ &asn_SPC_SeqOfSystemInfoAssistBTS_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SgnTypeElement.c b/src/core/libs/supl/asn-rrlp/SgnTypeElement.c index fa49b6689..946abbe38 100644 --- a/src/core/libs/supl/asn-rrlp/SgnTypeElement.c +++ b/src/core/libs/supl/asn-rrlp/SgnTypeElement.c @@ -31,7 +31,7 @@ memb_ganssStatusHealth_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_ganssStatusHealth_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_GANSS_STATUS_HEALTH_CONSTR_3 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -51,7 +51,7 @@ static asn_TYPE_member_t asn_MBR_SgnTypeElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ganssStatusHealth_constraint_1, - &asn_PER_memb_ganssStatusHealth_constr_3, + &ASN_PER_MEMB_GANSS_STATUS_HEALTH_CONSTR_3, 0, "ganssStatusHealth" }, diff --git a/src/core/libs/supl/asn-rrlp/StandardClockModelElement.c b/src/core/libs/supl/asn-rrlp/StandardClockModelElement.c index e04f2b6c0..2e17a8a54 100644 --- a/src/core/libs/supl/asn-rrlp/StandardClockModelElement.c +++ b/src/core/libs/supl/asn-rrlp/StandardClockModelElement.c @@ -156,32 +156,32 @@ memb_stanModelID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_stanClockTocLSB_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_STAN_CLOCK_TOC_LSB_CONSTR_2 = { { APC_CONSTRAINED, 9, 9, 0, 511 } /* (0..511) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_stanClockAF2_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_STAN_CLOCK_A_F2_CONSTR_3 = { { APC_CONSTRAINED, 12, 12, -2048, 2047 } /* (-2048..2047) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_stanClockAF1_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_STAN_CLOCK_A_F1_CONSTR_4 = { { APC_CONSTRAINED, 18, -1, -131072, 131071 } /* (-131072..131071) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_stanClockAF0_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_STAN_CLOCK_A_F0_CONSTR_5 = { { APC_CONSTRAINED, 28, -1, -134217728, 134217727 } /* (-134217728..134217727) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_stanClockTgd_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_STAN_CLOCK_TGD_CONSTR_6 = { { APC_CONSTRAINED, 10, 10, -512, 511 } /* (-512..511) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_stanModelID_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_STAN_MODEL_ID_CONSTR_7 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -192,7 +192,7 @@ static asn_TYPE_member_t asn_MBR_StandardClockModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stanClockTocLSB_constraint_1, - &asn_PER_memb_stanClockTocLSB_constr_2, + &ASN_PER_MEMB_STAN_CLOCK_TOC_LSB_CONSTR_2, 0, "stanClockTocLSB" }, @@ -201,7 +201,7 @@ static asn_TYPE_member_t asn_MBR_StandardClockModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stanClockAF2_constraint_1, - &asn_PER_memb_stanClockAF2_constr_3, + &ASN_PER_MEMB_STAN_CLOCK_A_F2_CONSTR_3, 0, "stanClockAF2" }, @@ -210,7 +210,7 @@ static asn_TYPE_member_t asn_MBR_StandardClockModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stanClockAF1_constraint_1, - &asn_PER_memb_stanClockAF1_constr_4, + &ASN_PER_MEMB_STAN_CLOCK_A_F1_CONSTR_4, 0, "stanClockAF1" }, @@ -219,7 +219,7 @@ static asn_TYPE_member_t asn_MBR_StandardClockModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stanClockAF0_constraint_1, - &asn_PER_memb_stanClockAF0_constr_5, + &ASN_PER_MEMB_STAN_CLOCK_A_F0_CONSTR_5, 0, "stanClockAF0" }, @@ -228,7 +228,7 @@ static asn_TYPE_member_t asn_MBR_StandardClockModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stanClockTgd_constraint_1, - &asn_PER_memb_stanClockTgd_constr_6, + &ASN_PER_MEMB_STAN_CLOCK_TGD_CONSTR_6, 0, "stanClockTgd" }, @@ -237,7 +237,7 @@ static asn_TYPE_member_t asn_MBR_StandardClockModelElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_stanModelID_constraint_1, - &asn_PER_memb_stanModelID_constr_7, + &ASN_PER_MEMB_STAN_MODEL_ID_CONSTR_7, 0, "stanModelID" }, diff --git a/src/core/libs/supl/asn-rrlp/StdResolution.c b/src/core/libs/supl/asn-rrlp/StdResolution.c index b5dd33517..574f0af9a 100644 --- a/src/core/libs/supl/asn-rrlp/StdResolution.c +++ b/src/core/libs/supl/asn-rrlp/StdResolution.c @@ -111,7 +111,7 @@ StdResolution_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_StdResolution_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_STD_RESOLUTION_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_StdResolution = { asn_DEF_StdResolution_tags_1, /* Same as above */ sizeof(asn_DEF_StdResolution_tags_1) /sizeof(asn_DEF_StdResolution_tags_1[0]), /* 1 */ - &asn_PER_type_StdResolution_constr_1, + &ASN_PER_TYPE_STD_RESOLUTION_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS-R98-ExpOTD.c b/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS-R98-ExpOTD.c index a7e14dce0..e0d73b1ff 100644 --- a/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS-R98-ExpOTD.c +++ b/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS-R98-ExpOTD.c @@ -6,7 +6,7 @@ #include "SystemInfoAssistBTS-R98-ExpOTD.h" -static asn_per_constraints_t asn_PER_type_SystemInfoAssistBTS_R98_ExpOTD_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SYSTEM_INFO_ASSIST_BTS_R98_EXP_OTD_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -62,7 +62,7 @@ asn_TYPE_descriptor_t asn_DEF_SystemInfoAssistBTS_R98_ExpOTD = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_SystemInfoAssistBTS_R98_ExpOTD_constr_1, + &ASN_PER_TYPE_SYSTEM_INFO_ASSIST_BTS_R98_EXP_OTD_CONSTR_1, asn_MBR_SystemInfoAssistBTS_R98_ExpOTD_1, 2, /* Elements count */ &asn_SPC_SystemInfoAssistBTS_R98_ExpOTD_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS.c b/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS.c index 30a007816..3b7d17674 100644 --- a/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS.c +++ b/src/core/libs/supl/asn-rrlp/SystemInfoAssistBTS.c @@ -6,7 +6,7 @@ #include "SystemInfoAssistBTS.h" -static asn_per_constraints_t asn_PER_type_SystemInfoAssistBTS_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SYSTEM_INFO_ASSIST_BTS_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -62,7 +62,7 @@ asn_TYPE_descriptor_t asn_DEF_SystemInfoAssistBTS = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_SystemInfoAssistBTS_constr_1, + &ASN_PER_TYPE_SYSTEM_INFO_ASSIST_BTS_CONSTR_1, asn_MBR_SystemInfoAssistBTS_1, 2, /* Elements count */ &asn_SPC_SystemInfoAssistBTS_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c b/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c index 713303193..68c0b86bd 100644 --- a/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c +++ b/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c @@ -111,7 +111,7 @@ SystemInfoIndex_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_SystemInfoIndex_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SYSTEM_INFO_INDEX_CONSTR_1 = { { APC_CONSTRAINED, 5, 5, 1, 32 } /* (1..32) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_SystemInfoIndex = { asn_DEF_SystemInfoIndex_tags_1, /* Same as above */ sizeof(asn_DEF_SystemInfoIndex_tags_1) /sizeof(asn_DEF_SystemInfoIndex_tags_1[0]), /* 1 */ - &asn_PER_type_SystemInfoIndex_constr_1, + &ASN_PER_TYPE_SYSTEM_INFO_INDEX_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/TA0.c b/src/core/libs/supl/asn-rrlp/TA0.c index c6e6e0a14..1879f9e19 100644 --- a/src/core/libs/supl/asn-rrlp/TA0.c +++ b/src/core/libs/supl/asn-rrlp/TA0.c @@ -111,7 +111,7 @@ TA0_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TA0_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_T_A0_CONSTR_1 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TA0 = { asn_DEF_TA0_tags_1, /* Same as above */ sizeof(asn_DEF_TA0_tags_1) /sizeof(asn_DEF_TA0_tags_1[0]), /* 1 */ - &asn_PER_type_TA0_constr_1, + &ASN_PER_TYPE_T_A0_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/TA1.c b/src/core/libs/supl/asn-rrlp/TA1.c index d118cab48..43b3fb216 100644 --- a/src/core/libs/supl/asn-rrlp/TA1.c +++ b/src/core/libs/supl/asn-rrlp/TA1.c @@ -111,7 +111,7 @@ TA1_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TA1_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_T_A1_CONSTR_1 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TA1 = { asn_DEF_TA1_tags_1, /* Same as above */ sizeof(asn_DEF_TA1_tags_1) /sizeof(asn_DEF_TA1_tags_1[0]), /* 1 */ - &asn_PER_type_TA1_constr_1, + &ASN_PER_TYPE_T_A1_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/TA2.c b/src/core/libs/supl/asn-rrlp/TA2.c index 9d4ba1f9d..f86657377 100644 --- a/src/core/libs/supl/asn-rrlp/TA2.c +++ b/src/core/libs/supl/asn-rrlp/TA2.c @@ -111,7 +111,7 @@ TA2_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TA2_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_T_A2_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, -64, 63 } /* (-64..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TA2 = { asn_DEF_TA2_tags_1, /* Same as above */ sizeof(asn_DEF_TA2_tags_1) /sizeof(asn_DEF_TA2_tags_1[0]), /* 1 */ - &asn_PER_type_TA2_constr_1, + &ASN_PER_TYPE_T_A2_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/TLMReservedBits.c b/src/core/libs/supl/asn-rrlp/TLMReservedBits.c index 5493ac422..cac6e5f46 100644 --- a/src/core/libs/supl/asn-rrlp/TLMReservedBits.c +++ b/src/core/libs/supl/asn-rrlp/TLMReservedBits.c @@ -111,7 +111,7 @@ TLMReservedBits_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TLMReservedBits_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_TLM_RESERVED_BITS_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TLMReservedBits = { asn_DEF_TLMReservedBits_tags_1, /* Same as above */ sizeof(asn_DEF_TLMReservedBits_tags_1) /sizeof(asn_DEF_TLMReservedBits_tags_1[0]), /* 1 */ - &asn_PER_type_TLMReservedBits_constr_1, + &ASN_PER_TYPE_TLM_RESERVED_BITS_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/TLMWord.c b/src/core/libs/supl/asn-rrlp/TLMWord.c index 08495fde8..1bd83baaf 100644 --- a/src/core/libs/supl/asn-rrlp/TLMWord.c +++ b/src/core/libs/supl/asn-rrlp/TLMWord.c @@ -111,7 +111,7 @@ TLMWord_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TLMWord_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_TLM_WORD_CONSTR_1 = { { APC_CONSTRAINED, 14, 14, 0, 16383 } /* (0..16383) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TLMWord = { asn_DEF_TLMWord_tags_1, /* Same as above */ sizeof(asn_DEF_TLMWord_tags_1) /sizeof(asn_DEF_TLMWord_tags_1[0]), /* 1 */ - &asn_PER_type_TLMWord_constr_1, + &ASN_PER_TYPE_TLM_WORD_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/TimeSlot.c b/src/core/libs/supl/asn-rrlp/TimeSlot.c index f879e587c..e9f8728d7 100644 --- a/src/core/libs/supl/asn-rrlp/TimeSlot.c +++ b/src/core/libs/supl/asn-rrlp/TimeSlot.c @@ -111,7 +111,7 @@ TimeSlot_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TimeSlot_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_TIME_SLOT_CONSTR_1 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TimeSlot = { asn_DEF_TimeSlot_tags_1, /* Same as above */ sizeof(asn_DEF_TimeSlot_tags_1) /sizeof(asn_DEF_TimeSlot_tags_1[0]), /* 1 */ - &asn_PER_type_TimeSlot_constr_1, + &ASN_PER_TYPE_TIME_SLOT_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c b/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c index dc0d3ca0f..347b073f7 100644 --- a/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c +++ b/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c @@ -94,7 +94,7 @@ TimeSlotScheme_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TimeSlotScheme_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_TIME_SLOT_SCHEME_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TimeSlotScheme = { asn_DEF_TimeSlotScheme_tags_1, /* Same as above */ sizeof(asn_DEF_TimeSlotScheme_tags_1) /sizeof(asn_DEF_TimeSlotScheme_tags_1[0]), /* 1 */ - &asn_PER_type_TimeSlotScheme_constr_1, + &ASN_PER_TYPE_TIME_SLOT_SCHEME_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_TimeSlotScheme_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/UTCModel.c b/src/core/libs/supl/asn-rrlp/UTCModel.c index 73a0520d6..a8d0557e1 100644 --- a/src/core/libs/supl/asn-rrlp/UTCModel.c +++ b/src/core/libs/supl/asn-rrlp/UTCModel.c @@ -206,42 +206,42 @@ memb_utcDeltaTlsf_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_utcA1_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_A1_CONSTR_2 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_utcA0_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_A0_CONSTR_3 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_utcTot_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_TOT_CONSTR_4 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_utcWNt_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_W_NT_CONSTR_5 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_utcDeltaTls_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_DELTA_TLS_CONSTR_6 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_utcWNlsf_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_W_NLSF_CONSTR_7 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_utcDN_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_DN_CONSTR_8 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_utcDeltaTlsf_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_UTC_DELTA_TLSF_CONSTR_9 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -252,7 +252,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcA1_constraint_1, - &asn_PER_memb_utcA1_constr_2, + &ASN_PER_MEMB_UTC_A1_CONSTR_2, 0, "utcA1" }, @@ -261,7 +261,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcA0_constraint_1, - &asn_PER_memb_utcA0_constr_3, + &ASN_PER_MEMB_UTC_A0_CONSTR_3, 0, "utcA0" }, @@ -270,7 +270,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcTot_constraint_1, - &asn_PER_memb_utcTot_constr_4, + &ASN_PER_MEMB_UTC_TOT_CONSTR_4, 0, "utcTot" }, @@ -279,7 +279,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcWNt_constraint_1, - &asn_PER_memb_utcWNt_constr_5, + &ASN_PER_MEMB_UTC_W_NT_CONSTR_5, 0, "utcWNt" }, @@ -288,7 +288,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcDeltaTls_constraint_1, - &asn_PER_memb_utcDeltaTls_constr_6, + &ASN_PER_MEMB_UTC_DELTA_TLS_CONSTR_6, 0, "utcDeltaTls" }, @@ -297,7 +297,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcWNlsf_constraint_1, - &asn_PER_memb_utcWNlsf_constr_7, + &ASN_PER_MEMB_UTC_W_NLSF_CONSTR_7, 0, "utcWNlsf" }, @@ -306,7 +306,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcDN_constraint_1, - &asn_PER_memb_utcDN_constr_8, + &ASN_PER_MEMB_UTC_DN_CONSTR_8, 0, "utcDN" }, @@ -315,7 +315,7 @@ static asn_TYPE_member_t asn_MBR_UTCModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_utcDeltaTlsf_constraint_1, - &asn_PER_memb_utcDeltaTlsf_constr_9, + &ASN_PER_MEMB_UTC_DELTA_TLSF_CONSTR_9, 0, "utcDeltaTlsf" }, diff --git a/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c b/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c index 9b2c5278c..28d2189fc 100644 --- a/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c +++ b/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c @@ -94,7 +94,7 @@ UlPseudoSegInd_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_UlPseudoSegInd_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_UL_PSEUDO_SEG_IND_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_UlPseudoSegInd = { asn_DEF_UlPseudoSegInd_tags_1, /* Same as above */ sizeof(asn_DEF_UlPseudoSegInd_tags_1) /sizeof(asn_DEF_UlPseudoSegInd_tags_1[0]), /* 1 */ - &asn_PER_type_UlPseudoSegInd_constr_1, + &ASN_PER_TYPE_UL_PSEUDO_SEG_IND_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_UlPseudoSegInd_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c b/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c index 07896a408..c367db368 100644 --- a/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c +++ b/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c @@ -888,152 +888,152 @@ memb_ephemIDot_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_type_ephemE_constr_17 = { +static asn_per_constraints_t ASN_PER_TYPE_EPHEM_E_CONSTR_17 = { { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_type_ephemAPowerHalf_constr_19 = { +static asn_per_constraints_t ASN_PER_TYPE_EPHEM_A_POWER_HALF_CONSTR_19 = { { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemCodeOnL2_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_CODE_ON_L2_CONSTR_2 = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemURA_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_URA_CONSTR_3 = { { APC_CONSTRAINED, 4, 4, 0, 15 } /* (0..15) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemSVhealth_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_S_VHEALTH_CONSTR_4 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemIODC_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_IODC_CONSTR_5 = { { APC_CONSTRAINED, 10, 10, 0, 1023 } /* (0..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemL2Pflag_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_L2_PFLAG_CONSTR_6 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemTgd_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_TGD_CONSTR_8 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemToc_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_TOC_CONSTR_9 = { { APC_CONSTRAINED, 16, 16, 0, 37799 } /* (0..37799) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemAF2_constr_10 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_A_F2_CONSTR_10 = { { APC_CONSTRAINED, 8, 8, -128, 127 } /* (-128..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemAF1_constr_11 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_A_F1_CONSTR_11 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemAF0_constr_12 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_A_F0_CONSTR_12 = { { APC_CONSTRAINED, 22, -1, -2097152, 2097151 } /* (-2097152..2097151) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemCrs_constr_13 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_CRS_CONSTR_13 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemDeltaN_constr_14 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_DELTA_N_CONSTR_14 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemM0_constr_15 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_M0_CONSTR_15 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemCuc_constr_16 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_CUC_CONSTR_16 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemE_constr_17 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_E_CONSTR_17 = { { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemCus_constr_18 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_CUS_CONSTR_18 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemAPowerHalf_constr_19 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_A_POWER_HALF_CONSTR_19 = { { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemToe_constr_20 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_TOE_CONSTR_20 = { { APC_CONSTRAINED, 16, 16, 0, 37799 } /* (0..37799) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemFitFlag_constr_21 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_FIT_FLAG_CONSTR_21 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemAODA_constr_22 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_AODA_CONSTR_22 = { { APC_CONSTRAINED, 5, 5, 0, 31 } /* (0..31) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemCic_constr_23 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_CIC_CONSTR_23 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemOmegaA0_constr_24 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_OMEGA_A0_CONSTR_24 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemCis_constr_25 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_CIS_CONSTR_25 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemI0_constr_26 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_I0_CONSTR_26 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemCrc_constr_27 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_CRC_CONSTR_27 = { { APC_CONSTRAINED, 16, 16, -32768, 32767 } /* (-32768..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemW_constr_28 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_W_CONSTR_28 = { { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemOmegaADot_constr_29 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_OMEGA_A_DOT_CONSTR_29 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ephemIDot_constr_30 = { +static asn_per_constraints_t ASN_PER_MEMB_EPHEM_I_DOT_CONSTR_30 = { { APC_CONSTRAINED, 14, 14, -8192, 8191 } /* (-8192..8191) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -1067,7 +1067,7 @@ asn_TYPE_descriptor_t asn_DEF_ephemE_17 = { asn_DEF_ephemE_tags_17, /* Same as above */ sizeof(asn_DEF_ephemE_tags_17) /sizeof(asn_DEF_ephemE_tags_17[0]), /* 2 */ - &asn_PER_type_ephemE_constr_17, + &ASN_PER_TYPE_EPHEM_E_CONSTR_17, 0, 0, /* No members */ &asn_SPC_ephemE_specs_17 /* Additional specs */ }; @@ -1101,7 +1101,7 @@ asn_TYPE_descriptor_t asn_DEF_ephemAPowerHalf_19 = { asn_DEF_ephemAPowerHalf_tags_19, /* Same as above */ sizeof(asn_DEF_ephemAPowerHalf_tags_19) /sizeof(asn_DEF_ephemAPowerHalf_tags_19[0]), /* 2 */ - &asn_PER_type_ephemAPowerHalf_constr_19, + &ASN_PER_TYPE_EPHEM_A_POWER_HALF_CONSTR_19, 0, 0, /* No members */ &asn_SPC_ephemAPowerHalf_specs_19 /* Additional specs */ }; @@ -1112,7 +1112,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemCodeOnL2_constraint_1, - &asn_PER_memb_ephemCodeOnL2_constr_2, + &ASN_PER_MEMB_EPHEM_CODE_ON_L2_CONSTR_2, 0, "ephemCodeOnL2" }, @@ -1121,7 +1121,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemURA_constraint_1, - &asn_PER_memb_ephemURA_constr_3, + &ASN_PER_MEMB_EPHEM_URA_CONSTR_3, 0, "ephemURA" }, @@ -1130,7 +1130,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemSVhealth_constraint_1, - &asn_PER_memb_ephemSVhealth_constr_4, + &ASN_PER_MEMB_EPHEM_S_VHEALTH_CONSTR_4, 0, "ephemSVhealth" }, @@ -1139,7 +1139,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemIODC_constraint_1, - &asn_PER_memb_ephemIODC_constr_5, + &ASN_PER_MEMB_EPHEM_IODC_CONSTR_5, 0, "ephemIODC" }, @@ -1148,7 +1148,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemL2Pflag_constraint_1, - &asn_PER_memb_ephemL2Pflag_constr_6, + &ASN_PER_MEMB_EPHEM_L2_PFLAG_CONSTR_6, 0, "ephemL2Pflag" }, @@ -1166,7 +1166,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemTgd_constraint_1, - &asn_PER_memb_ephemTgd_constr_8, + &ASN_PER_MEMB_EPHEM_TGD_CONSTR_8, 0, "ephemTgd" }, @@ -1175,7 +1175,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemToc_constraint_1, - &asn_PER_memb_ephemToc_constr_9, + &ASN_PER_MEMB_EPHEM_TOC_CONSTR_9, 0, "ephemToc" }, @@ -1184,7 +1184,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemAF2_constraint_1, - &asn_PER_memb_ephemAF2_constr_10, + &ASN_PER_MEMB_EPHEM_A_F2_CONSTR_10, 0, "ephemAF2" }, @@ -1193,7 +1193,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemAF1_constraint_1, - &asn_PER_memb_ephemAF1_constr_11, + &ASN_PER_MEMB_EPHEM_A_F1_CONSTR_11, 0, "ephemAF1" }, @@ -1202,7 +1202,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemAF0_constraint_1, - &asn_PER_memb_ephemAF0_constr_12, + &ASN_PER_MEMB_EPHEM_A_F0_CONSTR_12, 0, "ephemAF0" }, @@ -1211,7 +1211,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemCrs_constraint_1, - &asn_PER_memb_ephemCrs_constr_13, + &ASN_PER_MEMB_EPHEM_CRS_CONSTR_13, 0, "ephemCrs" }, @@ -1220,7 +1220,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemDeltaN_constraint_1, - &asn_PER_memb_ephemDeltaN_constr_14, + &ASN_PER_MEMB_EPHEM_DELTA_N_CONSTR_14, 0, "ephemDeltaN" }, @@ -1229,7 +1229,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemM0_constraint_1, - &asn_PER_memb_ephemM0_constr_15, + &ASN_PER_MEMB_EPHEM_M0_CONSTR_15, 0, "ephemM0" }, @@ -1238,7 +1238,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemCuc_constraint_1, - &asn_PER_memb_ephemCuc_constr_16, + &ASN_PER_MEMB_EPHEM_CUC_CONSTR_16, 0, "ephemCuc" }, @@ -1247,7 +1247,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_ephemE_17, memb_ephemE_constraint_1, - &asn_PER_memb_ephemE_constr_17, + &ASN_PER_MEMB_EPHEM_E_CONSTR_17, 0, "ephemE" }, @@ -1256,7 +1256,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemCus_constraint_1, - &asn_PER_memb_ephemCus_constr_18, + &ASN_PER_MEMB_EPHEM_CUS_CONSTR_18, 0, "ephemCus" }, @@ -1265,7 +1265,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_ephemAPowerHalf_19, memb_ephemAPowerHalf_constraint_1, - &asn_PER_memb_ephemAPowerHalf_constr_19, + &ASN_PER_MEMB_EPHEM_A_POWER_HALF_CONSTR_19, 0, "ephemAPowerHalf" }, @@ -1274,7 +1274,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemToe_constraint_1, - &asn_PER_memb_ephemToe_constr_20, + &ASN_PER_MEMB_EPHEM_TOE_CONSTR_20, 0, "ephemToe" }, @@ -1283,7 +1283,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemFitFlag_constraint_1, - &asn_PER_memb_ephemFitFlag_constr_21, + &ASN_PER_MEMB_EPHEM_FIT_FLAG_CONSTR_21, 0, "ephemFitFlag" }, @@ -1292,7 +1292,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemAODA_constraint_1, - &asn_PER_memb_ephemAODA_constr_22, + &ASN_PER_MEMB_EPHEM_AODA_CONSTR_22, 0, "ephemAODA" }, @@ -1301,7 +1301,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemCic_constraint_1, - &asn_PER_memb_ephemCic_constr_23, + &ASN_PER_MEMB_EPHEM_CIC_CONSTR_23, 0, "ephemCic" }, @@ -1310,7 +1310,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemOmegaA0_constraint_1, - &asn_PER_memb_ephemOmegaA0_constr_24, + &ASN_PER_MEMB_EPHEM_OMEGA_A0_CONSTR_24, 0, "ephemOmegaA0" }, @@ -1319,7 +1319,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemCis_constraint_1, - &asn_PER_memb_ephemCis_constr_25, + &ASN_PER_MEMB_EPHEM_CIS_CONSTR_25, 0, "ephemCis" }, @@ -1328,7 +1328,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemI0_constraint_1, - &asn_PER_memb_ephemI0_constr_26, + &ASN_PER_MEMB_EPHEM_I0_CONSTR_26, 0, "ephemI0" }, @@ -1337,7 +1337,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemCrc_constraint_1, - &asn_PER_memb_ephemCrc_constr_27, + &ASN_PER_MEMB_EPHEM_CRC_CONSTR_27, 0, "ephemCrc" }, @@ -1346,7 +1346,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemW_constraint_1, - &asn_PER_memb_ephemW_constr_28, + &ASN_PER_MEMB_EPHEM_W_CONSTR_28, 0, "ephemW" }, @@ -1355,7 +1355,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemOmegaADot_constraint_1, - &asn_PER_memb_ephemOmegaADot_constr_29, + &ASN_PER_MEMB_EPHEM_OMEGA_A_DOT_CONSTR_29, 0, "ephemOmegaADot" }, @@ -1364,7 +1364,7 @@ static asn_TYPE_member_t asn_MBR_UncompressedEphemeris_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_ephemIDot_constraint_1, - &asn_PER_memb_ephemIDot_constr_30, + &ASN_PER_MEMB_EPHEM_I_DOT_CONSTR_30, 0, "ephemIDot" }, diff --git a/src/core/libs/supl/asn-rrlp/UseMultipleSets.c b/src/core/libs/supl/asn-rrlp/UseMultipleSets.c index 59c95ffc7..35b9b1164 100644 --- a/src/core/libs/supl/asn-rrlp/UseMultipleSets.c +++ b/src/core/libs/supl/asn-rrlp/UseMultipleSets.c @@ -94,7 +94,7 @@ UseMultipleSets_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_UseMultipleSets_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_USE_MULTIPLE_SETS_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_UseMultipleSets = { asn_DEF_UseMultipleSets_tags_1, /* Same as above */ sizeof(asn_DEF_UseMultipleSets_tags_1) /sizeof(asn_DEF_UseMultipleSets_tags_1[0]), /* 1 */ - &asn_PER_type_UseMultipleSets_constr_1, + &ASN_PER_TYPE_USE_MULTIPLE_SETS_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_UseMultipleSets_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-rrlp/ber_decoder.c b/src/core/libs/supl/asn-rrlp/ber_decoder.c index 601f66c0b..77cb8032e 100644 --- a/src/core/libs/supl/asn-rrlp/ber_decoder.c +++ b/src/core/libs/supl/asn-rrlp/ber_decoder.c @@ -16,7 +16,7 @@ asn_dec_rval_t rval; \ rval.code = _code; \ if(opt_ctx) opt_ctx->step = step; /* Save context */ \ - if(_code == RC_OK || opt_ctx) \ + if((_code) == RC_OK || opt_ctx) \ rval.consumed = consumed_myself; \ else \ rval.consumed = 0; /* Context-free */ \ diff --git a/src/core/libs/supl/asn-rrlp/constr_CHOICE.c b/src/core/libs/supl/asn-rrlp/constr_CHOICE.c index a9eb71941..1bf467254 100644 --- a/src/core/libs/supl/asn-rrlp/constr_CHOICE.c +++ b/src/core/libs/supl/asn-rrlp/constr_CHOICE.c @@ -46,8 +46,8 @@ */ #undef NEXT_PHASE #define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ + (ctx)->phase++; \ + (ctx)->step = 0; \ } while(0) /* @@ -63,8 +63,8 @@ /* * See the definitions. */ -static int _fetch_present_idx(const void *struct_ptr, int off, int size); -static void _set_present_idx(void *sptr, int offset, int size, int pres); +static int _fetch_present_idx(const void *struct_ptr, int pres_offset, int size); +static void _set_present_idx(void *struct_ptr, int offset, int size, int pres); /* * Tags are canonically sorted in the tag to member table. diff --git a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c index db3c92581..aba19bd26 100644 --- a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c +++ b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c @@ -47,10 +47,10 @@ #undef NEXT_PHASE #undef PHASE_OUT #define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ + (ctx)->phase++; \ + (ctx)->step = 0; \ } while(0) -#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) +#define PHASE_OUT(ctx) do { (ctx)->phase = 10; } while(0) /* * Return a standardized complex structure. diff --git a/src/core/libs/supl/asn-rrlp/constr_SET_OF.c b/src/core/libs/supl/asn-rrlp/constr_SET_OF.c index 0bc891abf..8b9c0669a 100644 --- a/src/core/libs/supl/asn-rrlp/constr_SET_OF.c +++ b/src/core/libs/supl/asn-rrlp/constr_SET_OF.c @@ -47,10 +47,10 @@ #undef NEXT_PHASE #undef PHASE_OUT #define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ + (ctx)->phase++; \ + (ctx)->step = 0; \ } while(0) -#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) +#define PHASE_OUT(ctx) do { (ctx)->phase = 10; } while(0) /* * Return a standardized complex structure. diff --git a/src/core/libs/supl/asn-rrlp/converter-sample.c b/src/core/libs/supl/asn-rrlp/converter-sample.c index 13baad2e7..af980a1d6 100644 --- a/src/core/libs/supl/asn-rrlp/converter-sample.c +++ b/src/core/libs/supl/asn-rrlp/converter-sample.c @@ -34,7 +34,7 @@ extern asn_TYPE_descriptor_t *asn_pdu_collection[]; /* * Open file and parse its contens. */ -static void *data_decode_from_file(asn_TYPE_descriptor_t *asnTypeOfPDU, +static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *name, ssize_t suggested_bufsize, int first_pdu); static int write_out(const void *buffer, size_t size, void *key); static FILE *argument_to_file(char *av[], int idx); @@ -774,11 +774,11 @@ static int write_out(const void *buffer, size_t size, void *key) { } static int argument_is_stdin(char *av[], int idx) { - if(strcmp(av[idx], "-")) { + if(strcmp(av[idx], "-") != 0) { return 0; /* Certainly not */ } else { /* This might be , unless `./program -- -` */ - if(strcmp(av[-1], "--")) + if(strcmp(av[-1], "--") != 0) return 1; else return 0; @@ -788,7 +788,7 @@ static int argument_is_stdin(char *av[], int idx) { static FILE *argument_to_file(char *av[], int idx) { return argument_is_stdin(av, idx) ? stdin - : fopen(av[idx], "r"); + : fopen(av[idx], "re"); } static char *argument_to_name(char *av[], int idx) { diff --git a/src/core/libs/supl/asn-rrlp/per_encoder.c b/src/core/libs/supl/asn-rrlp/per_encoder.c index f4bace060..8cf95347d 100644 --- a/src/core/libs/supl/asn-rrlp/per_encoder.c +++ b/src/core/libs/supl/asn-rrlp/per_encoder.c @@ -2,7 +2,7 @@ #include #include -static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); +static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t * /*constraints*/, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); asn_enc_rval_t uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) { diff --git a/src/core/libs/supl/asn-rrlp/per_opentype.c b/src/core/libs/supl/asn-rrlp/per_opentype.c index c749c8c6c..32152e132 100644 --- a/src/core/libs/supl/asn-rrlp/per_opentype.c +++ b/src/core/libs/supl/asn-rrlp/per_opentype.c @@ -7,16 +7,17 @@ #include #include -typedef struct uper_ugot_key { - asn_per_data_t oldpd; /* Old per data source */ - size_t unclaimed; - size_t ot_moved; /* Number of bits moved by OT processing */ - int repeat; +typedef struct uper_ugot_key +{ + asn_per_data_t oldpd; /* Old per data source */ + size_t unclaimed; + size_t ot_moved; /* Number of bits moved by OT processing */ + int repeat; } uper_ugot_key; static int uper_ugot_refill(asn_per_data_t *pd); static int per_skip_bits(asn_per_data_t *pd, int skip_nbits); -static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); +static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t * /*ctx*/, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); int asn_debug_indent; @@ -24,243 +25,272 @@ int asn_debug_indent; * Encode an "open type field". * #10.1, #10.2 */ -int -uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - void *buf; - void *bptr; - ssize_t size; - size_t toGo; +int uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) +{ + void *buf; + void *bptr; + ssize_t size; + size_t toGo; - ASN_DEBUG("Open type put %s ...", td->name); + ASN_DEBUG("Open type put %s ...", td->name); - size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); - if(size <= 0) return -1; + size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); + if (size <= 0) return -1; - for(bptr = buf, toGo = size; toGo;) { - ssize_t maySave = uper_put_length(po, toGo); - if(maySave < 0) break; - if(per_put_many_bits(po, bptr, maySave * 8)) break; - bptr = (char *)bptr + maySave; - toGo -= maySave; - } + for (bptr = buf, toGo = size; toGo;) + { + ssize_t maySave = uper_put_length(po, toGo); + if (maySave < 0) break; + if (per_put_many_bits(po, bptr, maySave * 8)) break; + bptr = (char *)bptr + maySave; + toGo -= maySave; + } - FREEMEM(buf); - if(toGo) return -1; + FREEMEM(buf); + if (toGo) return -1; - ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", - td->name, size); + ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", + td->name, size); - return 0; + return 0; } static asn_dec_rval_t uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; - ssize_t chunk_bytes; - int repeat; - uint8_t *buf = 0; - size_t bufLen = 0; - size_t bufSize = 0; - asn_per_data_t spd; - size_t padding; + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + asn_dec_rval_t rv; + ssize_t chunk_bytes; + int repeat; + uint8_t *buf = 0; + size_t bufLen = 0; + size_t bufSize = 0; + asn_per_data_t spd; + size_t padding; - _ASN_STACK_OVERFLOW_CHECK(ctx); + _ASN_STACK_OVERFLOW_CHECK(ctx); - ASN_DEBUG("Getting open type %s...", td->name); + ASN_DEBUG("Getting open type %s...", td->name); - do { - chunk_bytes = uper_get_length(pd, -1, &repeat); - if(chunk_bytes < 0) { - FREEMEM(buf); - _ASN_DECODE_STARVED; - } - if(bufLen + chunk_bytes > bufSize) { - void *ptr; - bufSize = chunk_bytes + (bufSize << 2); - ptr = REALLOC(buf, bufSize); - if(!ptr) { - FREEMEM(buf); - _ASN_DECODE_FAILED; - } - buf = ptr; - } - if(per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) { - FREEMEM(buf); - _ASN_DECODE_STARVED; - } - bufLen += chunk_bytes; - } while(repeat); + do + { + chunk_bytes = uper_get_length(pd, -1, &repeat); + if (chunk_bytes < 0) + { + FREEMEM(buf); + _ASN_DECODE_STARVED; + } + if (bufLen + chunk_bytes > bufSize) + { + void *ptr; + bufSize = chunk_bytes + (bufSize << 2); + ptr = REALLOC(buf, bufSize); + if (!ptr) + { + FREEMEM(buf); + _ASN_DECODE_FAILED; + } + buf = ptr; + } + if (per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) + { + FREEMEM(buf); + _ASN_DECODE_STARVED; + } + bufLen += chunk_bytes; + } + while (repeat); - ASN_DEBUG("Getting open type %s encoded in %d bytes", td->name, - bufLen); + ASN_DEBUG("Getting open type %s encoded in %d bytes", td->name, + bufLen); - memset(&spd, 0, sizeof(spd)); - spd.buffer = buf; - spd.nbits = bufLen << 3; + memset(&spd, 0, sizeof(spd)); + spd.buffer = buf; + spd.nbits = bufLen << 3; - asn_debug_indent += 4; - rv = td->uper_decoder(ctx, td, constraints, sptr, &spd); - asn_debug_indent -= 4; + asn_debug_indent += 4; + rv = td->uper_decoder(ctx, td, constraints, sptr, &spd); + asn_debug_indent -= 4; - if(rv.code == RC_OK) { - /* Check padding validity */ - padding = spd.nbits - spd.nboff; - if(padding < 8 && per_get_few_bits(&spd, padding) == 0) { - /* Everything is cool */ - FREEMEM(buf); - return rv; - } - FREEMEM(buf); - if(padding >= 8) { - ASN_DEBUG("Too large padding %d in open type", padding); - _ASN_DECODE_FAILED; - } else { - ASN_DEBUG("Non-zero padding"); - _ASN_DECODE_FAILED; - } - } else { - FREEMEM(buf); - /* rv.code could be RC_WMORE, nonsense in this context */ - rv.code = RC_FAIL; /* Noone would give us more */ - } + if (rv.code == RC_OK) + { + /* Check padding validity */ + padding = spd.nbits - spd.nboff; + if (padding < 8 && per_get_few_bits(&spd, padding) == 0) + { + /* Everything is cool */ + FREEMEM(buf); + return rv; + } + FREEMEM(buf); + if (padding >= 8) + { + ASN_DEBUG("Too large padding %d in open type", padding); + _ASN_DECODE_FAILED; + } + else + { + ASN_DEBUG("Non-zero padding"); + _ASN_DECODE_FAILED; + } + } + else + { + FREEMEM(buf); + /* rv.code could be RC_WMORE, nonsense in this context */ + rv.code = RC_FAIL; /* Noone would give us more */ + } - return rv; + return rv; } static asn_dec_rval_t GCC_NOTUSED uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - uper_ugot_key arg; - asn_dec_rval_t rv; - ssize_t padding; + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + uper_ugot_key arg; + asn_dec_rval_t rv; + ssize_t padding; - _ASN_STACK_OVERFLOW_CHECK(ctx); + _ASN_STACK_OVERFLOW_CHECK(ctx); - ASN_DEBUG("Getting open type %s from %s", td->name, - per_data_string(pd)); - arg.oldpd = *pd; - arg.unclaimed = 0; - arg.ot_moved = 0; - arg.repeat = 1; - pd->refill = uper_ugot_refill; - pd->refill_key = &arg; - pd->nbits = pd->nboff; /* 0 good bits at this point, will refill */ - pd->moved = 0; /* This now counts the open type size in bits */ + ASN_DEBUG("Getting open type %s from %s", td->name, + per_data_string(pd)); + arg.oldpd = *pd; + arg.unclaimed = 0; + arg.ot_moved = 0; + arg.repeat = 1; + pd->refill = uper_ugot_refill; + pd->refill_key = &arg; + pd->nbits = pd->nboff; /* 0 good bits at this point, will refill */ + pd->moved = 0; /* This now counts the open type size in bits */ - asn_debug_indent += 4; - rv = td->uper_decoder(ctx, td, constraints, sptr, pd); - asn_debug_indent -= 4; + asn_debug_indent += 4; + rv = td->uper_decoder(ctx, td, constraints, sptr, pd); + asn_debug_indent -= 4; -#define UPDRESTOREPD do { \ - /* buffer and nboff are valid, preserve them. */ \ - pd->nbits = arg.oldpd.nbits - (pd->moved - arg.ot_moved); \ - pd->moved = arg.oldpd.moved + (pd->moved - arg.ot_moved); \ - pd->refill = arg.oldpd.refill; \ - pd->refill_key = arg.oldpd.refill_key; \ - } while(0) +#define UPDRESTOREPD \ + do \ + { \ + /* buffer and nboff are valid, preserve them. */ \ + pd->nbits = arg.oldpd.nbits - (pd->moved - arg.ot_moved); \ + pd->moved = arg.oldpd.moved + (pd->moved - arg.ot_moved); \ + pd->refill = arg.oldpd.refill; \ + pd->refill_key = arg.oldpd.refill_key; \ + } \ + while (0) - if(rv.code != RC_OK) { - UPDRESTOREPD; - return rv; - } + if (rv.code != RC_OK) + { + UPDRESTOREPD; + return rv; + } - ASN_DEBUG("OpenType %s pd%s old%s unclaimed=%d, repeat=%d" - , td->name, - per_data_string(pd), - per_data_string(&arg.oldpd), - arg.unclaimed, arg.repeat); + ASN_DEBUG("OpenType %s pd%s old%s unclaimed=%d, repeat=%d", td->name, + per_data_string(pd), + per_data_string(&arg.oldpd), + arg.unclaimed, arg.repeat); - padding = pd->moved % 8; - if(padding) { - int32_t pvalue; - if(padding > 7) { - ASN_DEBUG("Too large padding %d in open type", - padding); - rv.code = RC_FAIL; - UPDRESTOREPD; - return rv; - } - padding = 8 - padding; - ASN_DEBUG("Getting padding of %d bits", padding); - pvalue = per_get_few_bits(pd, padding); - switch(pvalue) { - case -1: - ASN_DEBUG("Padding skip failed"); - UPDRESTOREPD; - _ASN_DECODE_STARVED; - case 0: break; - default: - ASN_DEBUG("Non-blank padding (%d bits 0x%02x)", - padding, (int)pvalue); - UPDRESTOREPD; - _ASN_DECODE_FAILED; - } - } - if(pd->nboff != pd->nbits) { - ASN_DEBUG("Open type %s overhead pd%s old%s", td->name, - per_data_string(pd), per_data_string(&arg.oldpd)); - if(1) { - UPDRESTOREPD; - _ASN_DECODE_FAILED; - } else { - arg.unclaimed += pd->nbits - pd->nboff; - } - } + padding = pd->moved % 8; + if (padding) + { + int32_t pvalue; + if (padding > 7) + { + ASN_DEBUG("Too large padding %d in open type", + padding); + rv.code = RC_FAIL; + UPDRESTOREPD; + return rv; + } + padding = 8 - padding; + ASN_DEBUG("Getting padding of %d bits", padding); + pvalue = per_get_few_bits(pd, padding); + switch (pvalue) + { + case -1: + ASN_DEBUG("Padding skip failed"); + UPDRESTOREPD; + _ASN_DECODE_STARVED; + case 0: + break; + default: + ASN_DEBUG("Non-blank padding (%d bits 0x%02x)", + padding, (int)pvalue); + UPDRESTOREPD; + _ASN_DECODE_FAILED; + } + } + if (pd->nboff != pd->nbits) + { + ASN_DEBUG("Open type %s overhead pd%s old%s", td->name, + per_data_string(pd), per_data_string(&arg.oldpd)); + if (1) + { + UPDRESTOREPD; + _ASN_DECODE_FAILED; + } + else + { + arg.unclaimed += pd->nbits - pd->nboff; + } + } - /* Adjust pd back so it points to original data */ - UPDRESTOREPD; + /* Adjust pd back so it points to original data */ + UPDRESTOREPD; - /* Skip data not consumed by the decoder */ - if(arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); - if(arg.unclaimed) { - switch(per_skip_bits(pd, arg.unclaimed)) { - case -1: - ASN_DEBUG("Claim of %d failed", arg.unclaimed); - _ASN_DECODE_STARVED; - case 0: - ASN_DEBUG("Got claim of %d", arg.unclaimed); - break; - default: - /* Padding must be blank */ - ASN_DEBUG("Non-blank unconsumed padding"); - _ASN_DECODE_FAILED; - } - arg.unclaimed = 0; - } + /* Skip data not consumed by the decoder */ + if (arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); + if (arg.unclaimed) + { + switch (per_skip_bits(pd, arg.unclaimed)) + { + case -1: + ASN_DEBUG("Claim of %d failed", arg.unclaimed); + _ASN_DECODE_STARVED; + case 0: + ASN_DEBUG("Got claim of %d", arg.unclaimed); + break; + default: + /* Padding must be blank */ + ASN_DEBUG("Non-blank unconsumed padding"); + _ASN_DECODE_FAILED; + } + arg.unclaimed = 0; + } - if(arg.repeat) { - ASN_DEBUG("Not consumed the whole thing"); - rv.code = RC_FAIL; - return rv; - } + if (arg.repeat) + { + ASN_DEBUG("Not consumed the whole thing"); + rv.code = RC_FAIL; + return rv; + } - return rv; + return rv; } asn_dec_rval_t uper_open_type_get(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - - return uper_open_type_get_simple(ctx, td, constraints, - sptr, pd); - + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + return uper_open_type_get_simple(ctx, td, constraints, + sptr, pd); } -int -uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) { - asn_TYPE_descriptor_t s_td; - asn_dec_rval_t rv; +int uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) +{ + asn_TYPE_descriptor_t s_td; + asn_dec_rval_t rv; - s_td.name = ""; - s_td.uper_decoder = uper_sot_suck; + s_td.name = ""; + s_td.uper_decoder = uper_sot_suck; - rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); - if(rv.code != RC_OK) - return -1; - else - return 0; + rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); + if (rv.code != RC_OK) + return -1; + else + return 0; } /* @@ -269,105 +299,122 @@ uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) { static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + asn_dec_rval_t rv; - (void)ctx; - (void)td; - (void)constraints; - (void)sptr; + (void)ctx; + (void)td; + (void)constraints; + (void)sptr; - while(per_get_few_bits(pd, 24) >= 0); + while (per_get_few_bits(pd, 24) >= 0) + ; - rv.code = RC_OK; - rv.consumed = pd->moved; + rv.code = RC_OK; + rv.consumed = pd->moved; - return rv; + return rv; } static int -uper_ugot_refill(asn_per_data_t *pd) { - uper_ugot_key *arg = pd->refill_key; - ssize_t next_chunk_bytes, next_chunk_bits; - ssize_t avail; +uper_ugot_refill(asn_per_data_t *pd) +{ + uper_ugot_key *arg = pd->refill_key; + ssize_t next_chunk_bytes, next_chunk_bits; + ssize_t avail; - asn_per_data_t *oldpd = &arg->oldpd; + asn_per_data_t *oldpd = &arg->oldpd; - ASN_DEBUG("REFILLING pd->moved=%d, oldpd->moved=%d", - pd->moved, oldpd->moved); + ASN_DEBUG("REFILLING pd->moved=%d, oldpd->moved=%d", + pd->moved, oldpd->moved); - /* Advance our position to where pd is */ - oldpd->buffer = pd->buffer; - oldpd->nboff = pd->nboff; - oldpd->nbits -= pd->moved - arg->ot_moved; - oldpd->moved += pd->moved - arg->ot_moved; - arg->ot_moved = pd->moved; + /* Advance our position to where pd is */ + oldpd->buffer = pd->buffer; + oldpd->nboff = pd->nboff; + oldpd->nbits -= pd->moved - arg->ot_moved; + oldpd->moved += pd->moved - arg->ot_moved; + arg->ot_moved = pd->moved; - if(arg->unclaimed) { - /* Refill the container */ - if(per_get_few_bits(oldpd, 1)) - return -1; - if(oldpd->nboff == 0) { - assert(0); - return -1; - } - pd->buffer = oldpd->buffer; - pd->nboff = oldpd->nboff - 1; - pd->nbits = oldpd->nbits; - ASN_DEBUG("UNCLAIMED <- return from (pd->moved=%d)", pd->moved); - return 0; - } + if (arg->unclaimed) + { + /* Refill the container */ + if (per_get_few_bits(oldpd, 1)) + return -1; + if (oldpd->nboff == 0) + { + assert(0); + return -1; + } + pd->buffer = oldpd->buffer; + pd->nboff = oldpd->nboff - 1; + pd->nbits = oldpd->nbits; + ASN_DEBUG("UNCLAIMED <- return from (pd->moved=%d)", pd->moved); + return 0; + } - if(!arg->repeat) { - ASN_DEBUG("Want more but refill doesn't have it"); - return -1; - } + if (!arg->repeat) + { + ASN_DEBUG("Want more but refill doesn't have it"); + return -1; + } - next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); - ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", - next_chunk_bytes, oldpd->moved, arg->repeat); - if(next_chunk_bytes < 0) return -1; - if(next_chunk_bytes == 0) { - pd->refill = 0; /* No more refills, naturally */ - assert(!arg->repeat); /* Implementation guarantee */ - } - next_chunk_bits = next_chunk_bytes << 3; - avail = oldpd->nbits - oldpd->nboff; - if(avail >= next_chunk_bits) { - pd->nbits = oldpd->nboff + next_chunk_bits; - arg->unclaimed = 0; - ASN_DEBUG("!+Parent frame %d bits, alloting %d [%d..%d] (%d)", - next_chunk_bits, oldpd->moved, - oldpd->nboff, oldpd->nbits, - oldpd->nbits - oldpd->nboff); - } else { - pd->nbits = oldpd->nbits; - arg->unclaimed = next_chunk_bits - avail; - ASN_DEBUG("!-Parent frame %d, require %d, will claim %d", avail, next_chunk_bits, arg->unclaimed); - } - pd->buffer = oldpd->buffer; - pd->nboff = oldpd->nboff; - ASN_DEBUG("Refilled pd%s old%s", - per_data_string(pd), per_data_string(oldpd)); - return 0; + next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); + ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", + next_chunk_bytes, oldpd->moved, arg->repeat); + if (next_chunk_bytes < 0) return -1; + if (next_chunk_bytes == 0) + { + pd->refill = 0; /* No more refills, naturally */ + assert(!arg->repeat); /* Implementation guarantee */ + } + next_chunk_bits = next_chunk_bytes << 3; + avail = oldpd->nbits - oldpd->nboff; + if (avail >= next_chunk_bits) + { + pd->nbits = oldpd->nboff + next_chunk_bits; + arg->unclaimed = 0; + ASN_DEBUG("!+Parent frame %d bits, alloting %d [%d..%d] (%d)", + next_chunk_bits, oldpd->moved, + oldpd->nboff, oldpd->nbits, + oldpd->nbits - oldpd->nboff); + } + else + { + pd->nbits = oldpd->nbits; + arg->unclaimed = next_chunk_bits - avail; + ASN_DEBUG("!-Parent frame %d, require %d, will claim %d", avail, next_chunk_bits, arg->unclaimed); + } + pd->buffer = oldpd->buffer; + pd->nboff = oldpd->nboff; + ASN_DEBUG("Refilled pd%s old%s", + per_data_string(pd), per_data_string(oldpd)); + return 0; } static int -per_skip_bits(asn_per_data_t *pd, int skip_nbits) { - int hasNonZeroBits = 0; - while(skip_nbits > 0) { - int skip; - if(skip_nbits < skip) - skip = skip_nbits; - else - skip = 24; - skip_nbits -= skip; +per_skip_bits(asn_per_data_t *pd, int skip_nbits) +{ + int hasNonZeroBits = 0; + while (skip_nbits > 0) + { + int skip = 0; + if (skip_nbits < skip) + skip = skip_nbits; + else + skip = 24; + skip_nbits -= skip; - switch(per_get_few_bits(pd, skip)) { - case -1: return -1; /* Starving */ - case 0: continue; /* Skipped empty space */ - default: hasNonZeroBits = 1; continue; - } - } - return hasNonZeroBits; + switch (per_get_few_bits(pd, skip)) + { + case -1: + return -1; /* Starving */ + case 0: + continue; /* Skipped empty space */ + default: + hasNonZeroBits = 1; + continue; + } + } + return hasNonZeroBits; } diff --git a/src/core/libs/supl/asn-rrlp/xer_decoder.c b/src/core/libs/supl/asn-rrlp/xer_decoder.c index 161dc78ce..ef5f06481 100644 --- a/src/core/libs/supl/asn-rrlp/xer_decoder.c +++ b/src/core/libs/supl/asn-rrlp/xer_decoder.c @@ -181,12 +181,12 @@ xer_check_tag(const void *buf_ptr, int size, const char *need_tag) { #define XER_GOT_BODY(chunk_buf, chunk_size, size) do { \ ssize_t converted_size = body_receiver \ (struct_key, chunk_buf, chunk_size, \ - (size_t)chunk_size < size); \ + (size_t)(chunk_size) < (size)); \ if(converted_size == -1) RETURN(RC_FAIL); \ if(converted_size == 0 \ - && size == (size_t)chunk_size) \ + && (size) == (size_t)(chunk_size)) \ RETURN(RC_WMORE); \ - chunk_size = converted_size; \ + (chunk_size) = converted_size; \ } while(0) #define XER_GOT_EMPTY() do { \ if(body_receiver(struct_key, 0, 0, size > 0) == -1) \ diff --git a/src/core/libs/supl/asn-rrlp/xer_support.c b/src/core/libs/supl/asn-rrlp/xer_support.c index 9e34e6923..cfa30e674 100644 --- a/src/core/libs/supl/asn-rrlp/xer_support.c +++ b/src/core/libs/supl/asn-rrlp/xer_support.c @@ -60,7 +60,7 @@ _charclass[256] = { #define TOKEN_CB_CALL(type, _ns, _current_too, _final) do { \ int _ret; \ pstate_e ns = _ns; \ - ssize_t _sz = (p - chunk_start) + _current_too; \ + ssize_t _sz = (p - chunk_start) + (_current_too); \ if (!_sz) { \ /* Shortcut */ \ state = _ns; \ @@ -68,11 +68,11 @@ _charclass[256] = { } \ _ret = cb(type, chunk_start, _sz, key); \ if(_ret < _sz) { \ - if(_current_too && _ret == -1) \ + if((_current_too) && _ret == -1) \ state = ns; \ goto finish; \ } \ - chunk_start = p + _current_too; \ + chunk_start = p + (_current_too); \ state = ns; \ } while(0) diff --git a/src/core/libs/supl/asn-supl/AltitudeInfo.c b/src/core/libs/supl/asn-supl/AltitudeInfo.c index 70f48f49c..531988546 100644 --- a/src/core/libs/supl/asn-supl/AltitudeInfo.c +++ b/src/core/libs/supl/asn-supl/AltitudeInfo.c @@ -144,17 +144,17 @@ memb_altUncertainty_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_type_altitudeDirection_constr_2 = { +static asn_per_constraints_t ASN_PER_TYPE_ALTITUDE_DIRECTION_CONSTR_2 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_altitude_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_ALTITUDE_CONSTR_5 = { { APC_CONSTRAINED, 15, 15, 0, 32767 } /* (0..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_altUncertainty_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_ALT_UNCERTAINTY_CONSTR_6 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -200,7 +200,7 @@ asn_TYPE_descriptor_t asn_DEF_altitudeDirection_2 = { asn_DEF_altitudeDirection_tags_2, /* Same as above */ sizeof(asn_DEF_altitudeDirection_tags_2) /sizeof(asn_DEF_altitudeDirection_tags_2[0]), /* 2 */ - &asn_PER_type_altitudeDirection_constr_2, + &ASN_PER_TYPE_ALTITUDE_DIRECTION_CONSTR_2, 0, 0, /* Defined elsewhere */ &asn_SPC_altitudeDirection_specs_2 /* Additional specs */ }; @@ -220,7 +220,7 @@ static asn_TYPE_member_t asn_MBR_AltitudeInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_altitude_constraint_1, - &asn_PER_memb_altitude_constr_5, + &ASN_PER_MEMB_ALTITUDE_CONSTR_5, 0, "altitude" }, @@ -229,7 +229,7 @@ static asn_TYPE_member_t asn_MBR_AltitudeInfo_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_altUncertainty_constraint_1, - &asn_PER_memb_altUncertainty_constr_6, + &ASN_PER_MEMB_ALT_UNCERTAINTY_CONSTR_6, 0, "altUncertainty" }, diff --git a/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c b/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c index 0445a22cb..3ccbebf84 100644 --- a/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c +++ b/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c @@ -111,7 +111,7 @@ CPICH_Ec_N0_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_CPICH_Ec_N0_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_CPICH_EC_N0_CONSTR_1 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_CPICH_Ec_N0 = { asn_DEF_CPICH_Ec_N0_tags_1, /* Same as above */ sizeof(asn_DEF_CPICH_Ec_N0_tags_1) /sizeof(asn_DEF_CPICH_Ec_N0_tags_1[0]), /* 1 */ - &asn_PER_type_CPICH_Ec_N0_constr_1, + &ASN_PER_TYPE_CPICH_EC_N0_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/CPICH-RSCP.c b/src/core/libs/supl/asn-supl/CPICH-RSCP.c index 81726e708..92e525704 100644 --- a/src/core/libs/supl/asn-supl/CPICH-RSCP.c +++ b/src/core/libs/supl/asn-supl/CPICH-RSCP.c @@ -111,7 +111,7 @@ CPICH_RSCP_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_CPICH_RSCP_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_CPICH_RSCP_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_CPICH_RSCP = { asn_DEF_CPICH_RSCP_tags_1, /* Same as above */ sizeof(asn_DEF_CPICH_RSCP_tags_1) /sizeof(asn_DEF_CPICH_RSCP_tags_1[0]), /* 1 */ - &asn_PER_type_CPICH_RSCP_constr_1, + &ASN_PER_TYPE_CPICH_RSCP_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/CdmaCellInformation.c b/src/core/libs/supl/asn-supl/CdmaCellInformation.c index d08ecc007..aba676872 100644 --- a/src/core/libs/supl/asn-supl/CdmaCellInformation.c +++ b/src/core/libs/supl/asn-supl/CdmaCellInformation.c @@ -206,42 +206,42 @@ memb_refSeconds_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_refNID_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_NID_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refSID_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_SID_CONSTR_3 = { { APC_CONSTRAINED, 15, 15, 0, 32767 } /* (0..32767) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refBASEID_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_BASEID_CONSTR_4 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refBASELAT_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_BASELAT_CONSTR_5 = { { APC_CONSTRAINED, 22, -1, 0, 4194303 } /* (0..4194303) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_reBASELONG_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_RE_BASELONG_CONSTR_6 = { { APC_CONSTRAINED, 23, -1, 0, 8388607 } /* (0..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refREFPN_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_REFPN_CONSTR_7 = { { APC_CONSTRAINED, 9, 9, 0, 511 } /* (0..511) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refWeekNumber_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_WEEK_NUMBER_CONSTR_8 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refSeconds_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_SECONDS_CONSTR_9 = { { APC_CONSTRAINED, 22, -1, 0, 4194303 } /* (0..4194303) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -252,7 +252,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refNID_constraint_1, - &asn_PER_memb_refNID_constr_2, + &ASN_PER_MEMB_REF_NID_CONSTR_2, 0, "refNID" }, @@ -261,7 +261,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refSID_constraint_1, - &asn_PER_memb_refSID_constr_3, + &ASN_PER_MEMB_REF_SID_CONSTR_3, 0, "refSID" }, @@ -270,7 +270,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refBASEID_constraint_1, - &asn_PER_memb_refBASEID_constr_4, + &ASN_PER_MEMB_REF_BASEID_CONSTR_4, 0, "refBASEID" }, @@ -279,7 +279,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refBASELAT_constraint_1, - &asn_PER_memb_refBASELAT_constr_5, + &ASN_PER_MEMB_REF_BASELAT_CONSTR_5, 0, "refBASELAT" }, @@ -288,7 +288,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_reBASELONG_constraint_1, - &asn_PER_memb_reBASELONG_constr_6, + &ASN_PER_MEMB_RE_BASELONG_CONSTR_6, 0, "reBASELONG" }, @@ -297,7 +297,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refREFPN_constraint_1, - &asn_PER_memb_refREFPN_constr_7, + &ASN_PER_MEMB_REF_REFPN_CONSTR_7, 0, "refREFPN" }, @@ -306,7 +306,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refWeekNumber_constraint_1, - &asn_PER_memb_refWeekNumber_constr_8, + &ASN_PER_MEMB_REF_WEEK_NUMBER_CONSTR_8, 0, "refWeekNumber" }, @@ -315,7 +315,7 @@ static asn_TYPE_member_t asn_MBR_CdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refSeconds_constraint_1, - &asn_PER_memb_refSeconds_constr_9, + &ASN_PER_MEMB_REF_SECONDS_CONSTR_9, 0, "refSeconds" }, diff --git a/src/core/libs/supl/asn-supl/CellInfo.c b/src/core/libs/supl/asn-supl/CellInfo.c index 77eb080ba..469d624c3 100644 --- a/src/core/libs/supl/asn-supl/CellInfo.c +++ b/src/core/libs/supl/asn-supl/CellInfo.c @@ -6,7 +6,7 @@ #include "CellInfo.h" -static asn_per_constraints_t asn_PER_type_CellInfo_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_CELL_INFO_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ asn_TYPE_descriptor_t asn_DEF_CellInfo = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_CellInfo_constr_1, + &ASN_PER_TYPE_CELL_INFO_CONSTR_1, asn_MBR_CellInfo_1, 3, /* Elements count */ &asn_SPC_CellInfo_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/CellMeasuredResults.c b/src/core/libs/supl/asn-supl/CellMeasuredResults.c index 0b1a9f7c1..10760d310 100644 --- a/src/core/libs/supl/asn-supl/CellMeasuredResults.c +++ b/src/core/libs/supl/asn-supl/CellMeasuredResults.c @@ -31,12 +31,12 @@ memb_cellIdentity_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_type_modeSpecificInfo_constr_3 = { +static asn_per_constraints_t ASN_PER_TYPE_MODE_SPECIFIC_INFO_CONSTR_3 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_cellIdentity_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_CELL_IDENTITY_CONSTR_2 = { { APC_CONSTRAINED, 28, -1, 0, 268435455 } /* (0..268435455) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -273,7 +273,7 @@ asn_TYPE_descriptor_t asn_DEF_modeSpecificInfo_3 = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_modeSpecificInfo_constr_3, + &ASN_PER_TYPE_MODE_SPECIFIC_INFO_CONSTR_3, asn_MBR_modeSpecificInfo_3, 2, /* Elements count */ &asn_SPC_modeSpecificInfo_specs_3 /* Additional specs */ @@ -285,7 +285,7 @@ static asn_TYPE_member_t asn_MBR_CellMeasuredResults_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_cellIdentity_constraint_1, - &asn_PER_memb_cellIdentity_constr_2, + &ASN_PER_MEMB_CELL_IDENTITY_CONSTR_2, 0, "cellIdentity" }, diff --git a/src/core/libs/supl/asn-supl/CellMeasuredResultsList.c b/src/core/libs/supl/asn-supl/CellMeasuredResultsList.c index 567dcf35f..ecbb9da57 100644 --- a/src/core/libs/supl/asn-supl/CellMeasuredResultsList.c +++ b/src/core/libs/supl/asn-supl/CellMeasuredResultsList.c @@ -6,7 +6,7 @@ #include "CellMeasuredResultsList.h" -static asn_per_constraints_t asn_PER_type_CellMeasuredResultsList_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_CELL_MEASURED_RESULTS_LIST_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 5, 5, 1, 32 } /* (SIZE(1..32)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_CellMeasuredResultsList = { asn_DEF_CellMeasuredResultsList_tags_1, /* Same as above */ sizeof(asn_DEF_CellMeasuredResultsList_tags_1) /sizeof(asn_DEF_CellMeasuredResultsList_tags_1[0]), /* 1 */ - &asn_PER_type_CellMeasuredResultsList_constr_1, + &ASN_PER_TYPE_CELL_MEASURED_RESULTS_LIST_CONSTR_1, asn_MBR_CellMeasuredResultsList_1, 1, /* Single element */ &asn_SPC_CellMeasuredResultsList_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/CellParametersID.c b/src/core/libs/supl/asn-supl/CellParametersID.c index 4092e8585..8cc4a66b3 100644 --- a/src/core/libs/supl/asn-supl/CellParametersID.c +++ b/src/core/libs/supl/asn-supl/CellParametersID.c @@ -111,7 +111,7 @@ CellParametersID_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_CellParametersID_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_CELL_PARAMETERS_ID_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_CellParametersID = { asn_DEF_CellParametersID_tags_1, /* Same as above */ sizeof(asn_DEF_CellParametersID_tags_1) /sizeof(asn_DEF_CellParametersID_tags_1[0]), /* 1 */ - &asn_PER_type_CellParametersID_constr_1, + &ASN_PER_TYPE_CELL_PARAMETERS_ID_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/EncodingType.c b/src/core/libs/supl/asn-supl/EncodingType.c index ff25bfa80..db0ad1ea7 100644 --- a/src/core/libs/supl/asn-supl/EncodingType.c +++ b/src/core/libs/supl/asn-supl/EncodingType.c @@ -94,7 +94,7 @@ EncodingType_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_EncodingType_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ENCODING_TYPE_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -142,7 +142,7 @@ asn_TYPE_descriptor_t asn_DEF_EncodingType = { asn_DEF_EncodingType_tags_1, /* Same as above */ sizeof(asn_DEF_EncodingType_tags_1) /sizeof(asn_DEF_EncodingType_tags_1[0]), /* 1 */ - &asn_PER_type_EncodingType_constr_1, + &ASN_PER_TYPE_ENCODING_TYPE_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_EncodingType_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/FQDN.c b/src/core/libs/supl/asn-supl/FQDN.c index 84c9d1f0a..1d4f501a2 100644 --- a/src/core/libs/supl/asn-supl/FQDN.c +++ b/src/core/libs/supl/asn-supl/FQDN.c @@ -155,7 +155,7 @@ FQDN_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_FQDN_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_FQDN_CONSTR_1 = { { APC_CONSTRAINED, 6, 6, 45, 122 } /* (45..122) */, { APC_CONSTRAINED, 8, 8, 1, 255 } /* (SIZE(1..255)) */, asn_PER_MAP_FQDN_1_v2c, /* Value to PER code map */ @@ -183,7 +183,7 @@ asn_TYPE_descriptor_t asn_DEF_FQDN = { asn_DEF_FQDN_tags_1, /* Same as above */ sizeof(asn_DEF_FQDN_tags_1) /sizeof(asn_DEF_FQDN_tags_1[0]), /* 1 */ - &asn_PER_type_FQDN_constr_1, + &ASN_PER_TYPE_FQDN_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/FormatIndicator.c b/src/core/libs/supl/asn-supl/FormatIndicator.c index 9a17c684c..61c2ce2b8 100644 --- a/src/core/libs/supl/asn-supl/FormatIndicator.c +++ b/src/core/libs/supl/asn-supl/FormatIndicator.c @@ -94,7 +94,7 @@ FormatIndicator_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_FormatIndicator_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_FORMAT_INDICATOR_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 7 } /* (0..7,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -152,7 +152,7 @@ asn_TYPE_descriptor_t asn_DEF_FormatIndicator = { asn_DEF_FormatIndicator_tags_1, /* Same as above */ sizeof(asn_DEF_FormatIndicator_tags_1) /sizeof(asn_DEF_FormatIndicator_tags_1[0]), /* 1 */ - &asn_PER_type_FormatIndicator_constr_1, + &ASN_PER_TYPE_FORMAT_INDICATOR_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_FormatIndicator_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/FrequencyInfo.c b/src/core/libs/supl/asn-supl/FrequencyInfo.c index 6aa75a010..d0ebd64fb 100644 --- a/src/core/libs/supl/asn-supl/FrequencyInfo.c +++ b/src/core/libs/supl/asn-supl/FrequencyInfo.c @@ -6,7 +6,7 @@ #include "FrequencyInfo.h" -static asn_per_constraints_t asn_PER_type_fmodeSpecificInfo_constr_2 = { +static asn_per_constraints_t ASN_PER_TYPE_FMODE_SPECIFIC_INFO_CONSTR_2 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -63,7 +63,7 @@ asn_TYPE_descriptor_t asn_DEF_fmodeSpecificInfo_2 = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_fmodeSpecificInfo_constr_2, + &ASN_PER_TYPE_FMODE_SPECIFIC_INFO_CONSTR_2, asn_MBR_fmodeSpecificInfo_2, 2, /* Elements count */ &asn_SPC_fmodeSpecificInfo_specs_2 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/GeneralizedTime.c b/src/core/libs/supl/asn-supl/GeneralizedTime.c index 2fd63f262..ec23c6836 100644 --- a/src/core/libs/supl/asn-supl/GeneralizedTime.c +++ b/src/core/libs/supl/asn-supl/GeneralizedTime.c @@ -152,7 +152,7 @@ static ber_tlv_tag_t asn_DEF_GeneralizedTime_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -static asn_per_constraints_t asn_DEF_GeneralizedTime_constraints = { +static asn_per_constraints_t ASN_DEF_GENERALIZED_TIME_CONSTRAINTS = { { APC_CONSTRAINED, 7, 7, 0x20, 0x7e }, /* Value */ { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 @@ -176,7 +176,7 @@ asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = { asn_DEF_GeneralizedTime_tags, sizeof(asn_DEF_GeneralizedTime_tags) / sizeof(asn_DEF_GeneralizedTime_tags[0]), - &asn_DEF_GeneralizedTime_constraints, + &ASN_DEF_GENERALIZED_TIME_CONSTRAINTS, 0, 0, /* No members */ 0 /* No specifics */ }; @@ -369,7 +369,7 @@ asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, int *frac_digits, errno = EINVAL; \ return -1; \ } else { \ - var = var * 10 + (ch - 0x30); \ + (var) = (var) * 10 + (ch - 0x30); \ buf++; \ } \ } while(0) diff --git a/src/core/libs/supl/asn-supl/GeneralizedTime.h b/src/core/libs/supl/asn-supl/GeneralizedTime.h index 9e9583c7a..3867820e3 100644 --- a/src/core/libs/supl/asn-supl/GeneralizedTime.h +++ b/src/core/libs/supl/asn-supl/GeneralizedTime.h @@ -34,22 +34,22 @@ extern "C" * instead of default local one. * On error returns -1 and errno set to EINVAL */ - time_t asn_GT2time(const GeneralizedTime_t *, struct tm *_optional_tm4fill, + time_t asn_GT2time(const GeneralizedTime_t * /*st*/, struct tm *ret_tm, int as_gmt); /* A version of the above function also returning the fractions of seconds */ - time_t asn_GT2time_frac(const GeneralizedTime_t *, + time_t asn_GT2time_frac(const GeneralizedTime_t * /*st*/, int *frac_value, int *frac_digits, /* (value / (10 ^ digits)) */ - struct tm *_optional_tm4fill, int as_gmt); + struct tm *ret_tm, int as_gmt); /* * Another version returning fractions with defined precision * For example, parsing of the time ending with ".1" seconds * with frac_digits=3 (msec) would yield frac_value = 100. */ - time_t asn_GT2time_prec(const GeneralizedTime_t *, + time_t asn_GT2time_prec(const GeneralizedTime_t * /*st*/, int *frac_value, int frac_digits, - struct tm *_optional_tm4fill, int as_gmt); + struct tm *ret_tm, int as_gmt); /* * Convert a struct tm into GeneralizedTime. @@ -58,10 +58,10 @@ extern "C" * into a GMT time zone (encoding ends with a "Z"). * On error, this function returns 0 and sets errno. */ - GeneralizedTime_t *asn_time2GT(GeneralizedTime_t *_optional_gt, - const struct tm *, int force_gmt); - GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *_optional_gt, - const struct tm *, int frac_value, int frac_digits, int force_gmt); + GeneralizedTime_t *asn_time2GT(GeneralizedTime_t *opt_gt, + const struct tm * /*tm*/, int force_gmt); + GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *opt_gt, + const struct tm * /*tm*/, int frac_value, int frac_digits, int force_gmt); #ifdef __cplusplus } diff --git a/src/core/libs/supl/asn-supl/GsmCellInformation.c b/src/core/libs/supl/asn-supl/GsmCellInformation.c index 14aed828a..f43919e0f 100644 --- a/src/core/libs/supl/asn-supl/GsmCellInformation.c +++ b/src/core/libs/supl/asn-supl/GsmCellInformation.c @@ -131,27 +131,27 @@ memb_tA_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_refMCC_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_MCC_CONSTR_2 = { { APC_CONSTRAINED, 10, 10, 0, 999 } /* (0..999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refMNC_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_MNC_CONSTR_3 = { { APC_CONSTRAINED, 10, 10, 0, 999 } /* (0..999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refLAC_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_LAC_CONSTR_4 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refCI_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_CI_CONSTR_5 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_tA_constr_7 = { +static asn_per_constraints_t ASN_PER_MEMB_T_A_CONSTR_7 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -162,7 +162,7 @@ static asn_TYPE_member_t asn_MBR_GsmCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refMCC_constraint_1, - &asn_PER_memb_refMCC_constr_2, + &ASN_PER_MEMB_REF_MCC_CONSTR_2, 0, "refMCC" }, @@ -171,7 +171,7 @@ static asn_TYPE_member_t asn_MBR_GsmCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refMNC_constraint_1, - &asn_PER_memb_refMNC_constr_3, + &ASN_PER_MEMB_REF_MNC_CONSTR_3, 0, "refMNC" }, @@ -180,7 +180,7 @@ static asn_TYPE_member_t asn_MBR_GsmCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refLAC_constraint_1, - &asn_PER_memb_refLAC_constr_4, + &ASN_PER_MEMB_REF_LAC_CONSTR_4, 0, "refLAC" }, @@ -189,7 +189,7 @@ static asn_TYPE_member_t asn_MBR_GsmCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refCI_constraint_1, - &asn_PER_memb_refCI_constr_5, + &ASN_PER_MEMB_REF_CI_CONSTR_5, 0, "refCI" }, @@ -207,7 +207,7 @@ static asn_TYPE_member_t asn_MBR_GsmCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_tA_constraint_1, - &asn_PER_memb_tA_constr_7, + &ASN_PER_MEMB_T_A_CONSTR_7, 0, "tA" }, diff --git a/src/core/libs/supl/asn-supl/Horandveruncert.c b/src/core/libs/supl/asn-supl/Horandveruncert.c index 6df8af075..73ba2b860 100644 --- a/src/core/libs/supl/asn-supl/Horandveruncert.c +++ b/src/core/libs/supl/asn-supl/Horandveruncert.c @@ -8,318 +8,356 @@ static int memb_verdirect_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 1)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 1) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_bearing_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 9)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 9) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_horspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 16)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 16) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_verspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_horuncertspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_veruncertspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_verdirect_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 1, 1 } /* (SIZE(1..1)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_VERDIRECT_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 1, 1} /* (SIZE(1..1)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_bearing_constr_3 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 9, 9 } /* (SIZE(9..9)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_BEARING_CONSTR_3 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 9, 9} /* (SIZE(9..9)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_horspeed_constr_4 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 16, 16 } /* (SIZE(16..16)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_HORSPEED_CONSTR_4 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 16, 16} /* (SIZE(16..16)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_verspeed_constr_5 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_VERSPEED_CONSTR_5 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_horuncertspeed_constr_6 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_HORUNCERTSPEED_CONSTR_6 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_veruncertspeed_constr_7 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_VERUNCERTSPEED_CONSTR_7 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_Horandveruncert_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, verdirect), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_verdirect_constraint_1, - &asn_PER_memb_verdirect_constr_2, - 0, - "verdirect" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, bearing), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_bearing_constraint_1, - &asn_PER_memb_bearing_constr_3, - 0, - "bearing" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, horspeed), - (ASN_TAG_CLASS_CONTEXT | (2 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_horspeed_constraint_1, - &asn_PER_memb_horspeed_constr_4, - 0, - "horspeed" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, verspeed), - (ASN_TAG_CLASS_CONTEXT | (3 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_verspeed_constraint_1, - &asn_PER_memb_verspeed_constr_5, - 0, - "verspeed" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, horuncertspeed), - (ASN_TAG_CLASS_CONTEXT | (4 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_horuncertspeed_constraint_1, - &asn_PER_memb_horuncertspeed_constr_6, - 0, - "horuncertspeed" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, veruncertspeed), - (ASN_TAG_CLASS_CONTEXT | (5 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_veruncertspeed_constraint_1, - &asn_PER_memb_veruncertspeed_constr_7, - 0, - "veruncertspeed" - }, + {ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, verdirect), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_verdirect_constraint_1, + &ASN_PER_MEMB_VERDIRECT_CONSTR_2, + 0, + "verdirect"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, bearing), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_bearing_constraint_1, + &ASN_PER_MEMB_BEARING_CONSTR_3, + 0, + "bearing"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, horspeed), + (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_horspeed_constraint_1, + &ASN_PER_MEMB_HORSPEED_CONSTR_4, + 0, + "horspeed"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, verspeed), + (ASN_TAG_CLASS_CONTEXT | (3 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_verspeed_constraint_1, + &ASN_PER_MEMB_VERSPEED_CONSTR_5, + 0, + "verspeed"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, horuncertspeed), + (ASN_TAG_CLASS_CONTEXT | (4 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_horuncertspeed_constraint_1, + &ASN_PER_MEMB_HORUNCERTSPEED_CONSTR_6, + 0, + "horuncertspeed"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandveruncert, veruncertspeed), + (ASN_TAG_CLASS_CONTEXT | (5 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_veruncertspeed_constraint_1, + &ASN_PER_MEMB_VERUNCERTSPEED_CONSTR_7, + 0, + "veruncertspeed"}, }; static ber_tlv_tag_t asn_DEF_Horandveruncert_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))}; static asn_TYPE_tag2member_t asn_MAP_Horandveruncert_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* verdirect at 251 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* bearing at 252 */ - { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* horspeed at 253 */ - { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* verspeed at 254 */ - { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* horuncertspeed at 255 */ - { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 } /* veruncertspeed at 256 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* verdirect at 251 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0}, /* bearing at 252 */ + {(ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0}, /* horspeed at 253 */ + {(ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0}, /* verspeed at 254 */ + {(ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0}, /* horuncertspeed at 255 */ + {(ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0} /* veruncertspeed at 256 */ }; static asn_SEQUENCE_specifics_t asn_SPC_Horandveruncert_specs_1 = { - sizeof(struct Horandveruncert), - offsetof(struct Horandveruncert, _asn_ctx), - asn_MAP_Horandveruncert_tag2el_1, - 6, /* Count of tags in the map */ - 0, 0, 0, /* Optional elements (not needed) */ - 5, /* Start extensions */ - 7 /* Stop extensions */ + sizeof(struct Horandveruncert), + offsetof(struct Horandveruncert, _asn_ctx), + asn_MAP_Horandveruncert_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + 5, /* Start extensions */ + 7 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_Horandveruncert = { - "Horandveruncert", - "Horandveruncert", - SEQUENCE_free, - SEQUENCE_print, - SEQUENCE_constraint, - SEQUENCE_decode_ber, - SEQUENCE_encode_der, - SEQUENCE_decode_xer, - SEQUENCE_encode_xer, - SEQUENCE_decode_uper, - SEQUENCE_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_Horandveruncert_tags_1, - sizeof(asn_DEF_Horandveruncert_tags_1) - /sizeof(asn_DEF_Horandveruncert_tags_1[0]), /* 1 */ - asn_DEF_Horandveruncert_tags_1, /* Same as above */ - sizeof(asn_DEF_Horandveruncert_tags_1) - /sizeof(asn_DEF_Horandveruncert_tags_1[0]), /* 1 */ - 0, /* No PER visible constraints */ - asn_MBR_Horandveruncert_1, - 6, /* Elements count */ - &asn_SPC_Horandveruncert_specs_1 /* Additional specs */ + "Horandveruncert", + "Horandveruncert", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Horandveruncert_tags_1, + sizeof(asn_DEF_Horandveruncert_tags_1) / sizeof(asn_DEF_Horandveruncert_tags_1[0]), /* 1 */ + asn_DEF_Horandveruncert_tags_1, /* Same as above */ + sizeof(asn_DEF_Horandveruncert_tags_1) / sizeof(asn_DEF_Horandveruncert_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Horandveruncert_1, + 6, /* Elements count */ + &asn_SPC_Horandveruncert_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/Horandvervel.c b/src/core/libs/supl/asn-supl/Horandvervel.c index cfc81cfc9..6f8b3bc5c 100644 --- a/src/core/libs/supl/asn-supl/Horandvervel.c +++ b/src/core/libs/supl/asn-supl/Horandvervel.c @@ -8,226 +8,250 @@ static int memb_verdirect_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 1)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 1) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_bearing_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 9)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 9) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_horspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 16)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 16) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_verspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_verdirect_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 1, 1 } /* (SIZE(1..1)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_VERDIRECT_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 1, 1} /* (SIZE(1..1)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_bearing_constr_3 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 9, 9 } /* (SIZE(9..9)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_BEARING_CONSTR_3 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 9, 9} /* (SIZE(9..9)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_horspeed_constr_4 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 16, 16 } /* (SIZE(16..16)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_HORSPEED_CONSTR_4 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 16, 16} /* (SIZE(16..16)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_verspeed_constr_5 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_VERSPEED_CONSTR_5 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_Horandvervel_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct Horandvervel, verdirect), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_verdirect_constraint_1, - &asn_PER_memb_verdirect_constr_2, - 0, - "verdirect" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandvervel, bearing), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_bearing_constraint_1, - &asn_PER_memb_bearing_constr_3, - 0, - "bearing" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandvervel, horspeed), - (ASN_TAG_CLASS_CONTEXT | (2 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_horspeed_constraint_1, - &asn_PER_memb_horspeed_constr_4, - 0, - "horspeed" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horandvervel, verspeed), - (ASN_TAG_CLASS_CONTEXT | (3 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_verspeed_constraint_1, - &asn_PER_memb_verspeed_constr_5, - 0, - "verspeed" - }, + {ATF_NOFLAGS, 0, offsetof(struct Horandvervel, verdirect), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_verdirect_constraint_1, + &ASN_PER_MEMB_VERDIRECT_CONSTR_2, + 0, + "verdirect"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandvervel, bearing), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_bearing_constraint_1, + &ASN_PER_MEMB_BEARING_CONSTR_3, + 0, + "bearing"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandvervel, horspeed), + (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_horspeed_constraint_1, + &ASN_PER_MEMB_HORSPEED_CONSTR_4, + 0, + "horspeed"}, + {ATF_NOFLAGS, 0, offsetof(struct Horandvervel, verspeed), + (ASN_TAG_CLASS_CONTEXT | (3 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_verspeed_constraint_1, + &ASN_PER_MEMB_VERSPEED_CONSTR_5, + 0, + "verspeed"}, }; static ber_tlv_tag_t asn_DEF_Horandvervel_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))}; static asn_TYPE_tag2member_t asn_MAP_Horandvervel_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* verdirect at 238 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* bearing at 239 */ - { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* horspeed at 240 */ - { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 } /* verspeed at 241 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* verdirect at 238 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0}, /* bearing at 239 */ + {(ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0}, /* horspeed at 240 */ + {(ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0} /* verspeed at 241 */ }; static asn_SEQUENCE_specifics_t asn_SPC_Horandvervel_specs_1 = { - sizeof(struct Horandvervel), - offsetof(struct Horandvervel, _asn_ctx), - asn_MAP_Horandvervel_tag2el_1, - 4, /* Count of tags in the map */ - 0, 0, 0, /* Optional elements (not needed) */ - 3, /* Start extensions */ - 5 /* Stop extensions */ + sizeof(struct Horandvervel), + offsetof(struct Horandvervel, _asn_ctx), + asn_MAP_Horandvervel_tag2el_1, + 4, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + 3, /* Start extensions */ + 5 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_Horandvervel = { - "Horandvervel", - "Horandvervel", - SEQUENCE_free, - SEQUENCE_print, - SEQUENCE_constraint, - SEQUENCE_decode_ber, - SEQUENCE_encode_der, - SEQUENCE_decode_xer, - SEQUENCE_encode_xer, - SEQUENCE_decode_uper, - SEQUENCE_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_Horandvervel_tags_1, - sizeof(asn_DEF_Horandvervel_tags_1) - /sizeof(asn_DEF_Horandvervel_tags_1[0]), /* 1 */ - asn_DEF_Horandvervel_tags_1, /* Same as above */ - sizeof(asn_DEF_Horandvervel_tags_1) - /sizeof(asn_DEF_Horandvervel_tags_1[0]), /* 1 */ - 0, /* No PER visible constraints */ - asn_MBR_Horandvervel_1, - 4, /* Elements count */ - &asn_SPC_Horandvervel_specs_1 /* Additional specs */ + "Horandvervel", + "Horandvervel", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Horandvervel_tags_1, + sizeof(asn_DEF_Horandvervel_tags_1) / sizeof(asn_DEF_Horandvervel_tags_1[0]), /* 1 */ + asn_DEF_Horandvervel_tags_1, /* Same as above */ + sizeof(asn_DEF_Horandvervel_tags_1) / sizeof(asn_DEF_Horandvervel_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Horandvervel_1, + 4, /* Elements count */ + &asn_SPC_Horandvervel_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/Horvel.c b/src/core/libs/supl/asn-supl/Horvel.c index bf9914452..fb8f8502c 100644 --- a/src/core/libs/supl/asn-supl/Horvel.c +++ b/src/core/libs/supl/asn-supl/Horvel.c @@ -8,134 +8,144 @@ static int memb_bearing_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 9)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 9) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_horspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 16)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 16) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_bearing_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 9, 9 } /* (SIZE(9..9)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_BEARING_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 9, 9} /* (SIZE(9..9)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_horspeed_constr_3 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 16, 16 } /* (SIZE(16..16)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_HORSPEED_CONSTR_3 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 16, 16} /* (SIZE(16..16)) */, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_Horvel_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct Horvel, bearing), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_bearing_constraint_1, - &asn_PER_memb_bearing_constr_2, - 0, - "bearing" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horvel, horspeed), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_horspeed_constraint_1, - &asn_PER_memb_horspeed_constr_3, - 0, - "horspeed" - }, + {ATF_NOFLAGS, 0, offsetof(struct Horvel, bearing), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_bearing_constraint_1, + &ASN_PER_MEMB_BEARING_CONSTR_2, + 0, + "bearing"}, + {ATF_NOFLAGS, 0, offsetof(struct Horvel, horspeed), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_horspeed_constraint_1, + &ASN_PER_MEMB_HORSPEED_CONSTR_3, + 0, + "horspeed"}, }; static ber_tlv_tag_t asn_DEF_Horvel_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))}; static asn_TYPE_tag2member_t asn_MAP_Horvel_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* bearing at 233 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* horspeed at 234 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* bearing at 233 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0} /* horspeed at 234 */ }; static asn_SEQUENCE_specifics_t asn_SPC_Horvel_specs_1 = { - sizeof(struct Horvel), - offsetof(struct Horvel, _asn_ctx), - asn_MAP_Horvel_tag2el_1, - 2, /* Count of tags in the map */ - 0, 0, 0, /* Optional elements (not needed) */ - 1, /* Start extensions */ - 3 /* Stop extensions */ + sizeof(struct Horvel), + offsetof(struct Horvel, _asn_ctx), + asn_MAP_Horvel_tag2el_1, + 2, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + 1, /* Start extensions */ + 3 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_Horvel = { - "Horvel", - "Horvel", - SEQUENCE_free, - SEQUENCE_print, - SEQUENCE_constraint, - SEQUENCE_decode_ber, - SEQUENCE_encode_der, - SEQUENCE_decode_xer, - SEQUENCE_encode_xer, - SEQUENCE_decode_uper, - SEQUENCE_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_Horvel_tags_1, - sizeof(asn_DEF_Horvel_tags_1) - /sizeof(asn_DEF_Horvel_tags_1[0]), /* 1 */ - asn_DEF_Horvel_tags_1, /* Same as above */ - sizeof(asn_DEF_Horvel_tags_1) - /sizeof(asn_DEF_Horvel_tags_1[0]), /* 1 */ - 0, /* No PER visible constraints */ - asn_MBR_Horvel_1, - 2, /* Elements count */ - &asn_SPC_Horvel_specs_1 /* Additional specs */ + "Horvel", + "Horvel", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Horvel_tags_1, + sizeof(asn_DEF_Horvel_tags_1) / sizeof(asn_DEF_Horvel_tags_1[0]), /* 1 */ + asn_DEF_Horvel_tags_1, /* Same as above */ + sizeof(asn_DEF_Horvel_tags_1) / sizeof(asn_DEF_Horvel_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Horvel_1, + 2, /* Elements count */ + &asn_SPC_Horvel_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/Horveluncert.c b/src/core/libs/supl/asn-supl/Horveluncert.c index ca12ff352..3e00aee15 100644 --- a/src/core/libs/supl/asn-supl/Horveluncert.c +++ b/src/core/libs/supl/asn-supl/Horveluncert.c @@ -8,180 +8,197 @@ static int memb_bearing_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 9)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 9) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_horspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 16)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 16) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_uncertspeed_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_bearing_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 9, 9 } /* (SIZE(9..9)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_BEARING_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 9, 9} /* (SIZE(9..9)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_horspeed_constr_3 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 16, 16 } /* (SIZE(16..16)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_HORSPEED_CONSTR_3 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 16, 16} /* (SIZE(16..16)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_uncertspeed_constr_4 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_UNCERTSPEED_CONSTR_4 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_Horveluncert_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct Horveluncert, bearing), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_bearing_constraint_1, - &asn_PER_memb_bearing_constr_2, - 0, - "bearing" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horveluncert, horspeed), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_horspeed_constraint_1, - &asn_PER_memb_horspeed_constr_3, - 0, - "horspeed" - }, - { ATF_NOFLAGS, 0, offsetof(struct Horveluncert, uncertspeed), - (ASN_TAG_CLASS_CONTEXT | (2 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_uncertspeed_constraint_1, - &asn_PER_memb_uncertspeed_constr_4, - 0, - "uncertspeed" - }, + {ATF_NOFLAGS, 0, offsetof(struct Horveluncert, bearing), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_bearing_constraint_1, + &ASN_PER_MEMB_BEARING_CONSTR_2, + 0, + "bearing"}, + {ATF_NOFLAGS, 0, offsetof(struct Horveluncert, horspeed), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_horspeed_constraint_1, + &ASN_PER_MEMB_HORSPEED_CONSTR_3, + 0, + "horspeed"}, + {ATF_NOFLAGS, 0, offsetof(struct Horveluncert, uncertspeed), + (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_uncertspeed_constraint_1, + &ASN_PER_MEMB_UNCERTSPEED_CONSTR_4, + 0, + "uncertspeed"}, }; static ber_tlv_tag_t asn_DEF_Horveluncert_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))}; static asn_TYPE_tag2member_t asn_MAP_Horveluncert_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* bearing at 245 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* horspeed at 246 */ - { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* uncertspeed at 247 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* bearing at 245 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0}, /* horspeed at 246 */ + {(ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0} /* uncertspeed at 247 */ }; static asn_SEQUENCE_specifics_t asn_SPC_Horveluncert_specs_1 = { - sizeof(struct Horveluncert), - offsetof(struct Horveluncert, _asn_ctx), - asn_MAP_Horveluncert_tag2el_1, - 3, /* Count of tags in the map */ - 0, 0, 0, /* Optional elements (not needed) */ - 2, /* Start extensions */ - 4 /* Stop extensions */ + sizeof(struct Horveluncert), + offsetof(struct Horveluncert, _asn_ctx), + asn_MAP_Horveluncert_tag2el_1, + 3, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + 2, /* Start extensions */ + 4 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_Horveluncert = { - "Horveluncert", - "Horveluncert", - SEQUENCE_free, - SEQUENCE_print, - SEQUENCE_constraint, - SEQUENCE_decode_ber, - SEQUENCE_encode_der, - SEQUENCE_decode_xer, - SEQUENCE_encode_xer, - SEQUENCE_decode_uper, - SEQUENCE_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_Horveluncert_tags_1, - sizeof(asn_DEF_Horveluncert_tags_1) - /sizeof(asn_DEF_Horveluncert_tags_1[0]), /* 1 */ - asn_DEF_Horveluncert_tags_1, /* Same as above */ - sizeof(asn_DEF_Horveluncert_tags_1) - /sizeof(asn_DEF_Horveluncert_tags_1[0]), /* 1 */ - 0, /* No PER visible constraints */ - asn_MBR_Horveluncert_1, - 3, /* Elements count */ - &asn_SPC_Horveluncert_specs_1 /* Additional specs */ + "Horveluncert", + "Horveluncert", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Horveluncert_tags_1, + sizeof(asn_DEF_Horveluncert_tags_1) / sizeof(asn_DEF_Horveluncert_tags_1[0]), /* 1 */ + asn_DEF_Horveluncert_tags_1, /* Same as above */ + sizeof(asn_DEF_Horveluncert_tags_1) / sizeof(asn_DEF_Horveluncert_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Horveluncert_1, + 3, /* Elements count */ + &asn_SPC_Horveluncert_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/IA5String.c b/src/core/libs/supl/asn-supl/IA5String.c index 02ecd3ee7..c404406d4 100644 --- a/src/core/libs/supl/asn-supl/IA5String.c +++ b/src/core/libs/supl/asn-supl/IA5String.c @@ -12,7 +12,7 @@ static ber_tlv_tag_t asn_DEF_IA5String_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), /* [UNIVERSAL 22] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -static asn_per_constraints_t asn_DEF_IA5String_constraints = { +static asn_per_constraints_t ASN_DEF_I_A5_STRING_CONSTRAINTS = { { APC_CONSTRAINED, 7, 7, 0, 0x7f }, /* Value */ { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 @@ -36,7 +36,7 @@ asn_TYPE_descriptor_t asn_DEF_IA5String = { asn_DEF_IA5String_tags, sizeof(asn_DEF_IA5String_tags) / sizeof(asn_DEF_IA5String_tags[0]), - &asn_DEF_IA5String_constraints, + &ASN_DEF_I_A5_STRING_CONSTRAINTS, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/INTEGER.h b/src/core/libs/supl/asn-supl/INTEGER.h index 2acd13ab9..e389e6b43 100644 --- a/src/core/libs/supl/asn-supl/INTEGER.h +++ b/src/core/libs/supl/asn-supl/INTEGER.h @@ -57,8 +57,8 @@ extern "C" */ int asn_INTEGER2long(const INTEGER_t *i, long *l); int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l); - int asn_long2INTEGER(INTEGER_t *i, long l); - int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l); + int asn_long2INTEGER(INTEGER_t *st, long value); + int asn_ulong2INTEGER(INTEGER_t *st, unsigned long value); /* * Convert the integer value into the corresponding enumeration map entry. diff --git a/src/core/libs/supl/asn-supl/IPAddress.c b/src/core/libs/supl/asn-supl/IPAddress.c index ddbef08c4..1da24fbd8 100644 --- a/src/core/libs/supl/asn-supl/IPAddress.c +++ b/src/core/libs/supl/asn-supl/IPAddress.c @@ -8,125 +8,132 @@ static int memb_ipv4Address_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - size = st->size; - - if((size == 4)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = st->size; + + if (size == 4) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_ipv6Address_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - size = st->size; - - if((size == 16)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = st->size; + + if (size == 16) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_ipv4Address_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 4, 4 } /* (SIZE(4..4)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_IPV4_ADDRESS_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 4, 4} /* (SIZE(4..4)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_ipv6Address_constr_3 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 16, 16 } /* (SIZE(16..16)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_IPV6_ADDRESS_CONSTR_3 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 16, 16} /* (SIZE(16..16)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_type_IPAddress_constr_1 = { - { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_TYPE_IP_ADDRESS_CONSTR_1 = { + {APC_CONSTRAINED, 1, 1, 0, 1} /* (0..1) */, + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_IPAddress_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct IPAddress, choice.ipv4Address), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_OCTET_STRING, - memb_ipv4Address_constraint_1, - &asn_PER_memb_ipv4Address_constr_2, - 0, - "ipv4Address" - }, - { ATF_NOFLAGS, 0, offsetof(struct IPAddress, choice.ipv6Address), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_OCTET_STRING, - memb_ipv6Address_constraint_1, - &asn_PER_memb_ipv6Address_constr_3, - 0, - "ipv6Address" - }, + {ATF_NOFLAGS, 0, offsetof(struct IPAddress, choice.ipv4Address), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_OCTET_STRING, + memb_ipv4Address_constraint_1, + &ASN_PER_MEMB_IPV4_ADDRESS_CONSTR_2, + 0, + "ipv4Address"}, + {ATF_NOFLAGS, 0, offsetof(struct IPAddress, choice.ipv6Address), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_OCTET_STRING, + memb_ipv6Address_constraint_1, + &ASN_PER_MEMB_IPV6_ADDRESS_CONSTR_3, + 0, + "ipv6Address"}, }; static asn_TYPE_tag2member_t asn_MAP_IPAddress_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* ipv4Address at 41 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* ipv6Address at 42 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* ipv4Address at 41 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0} /* ipv6Address at 42 */ }; static asn_CHOICE_specifics_t asn_SPC_IPAddress_specs_1 = { - sizeof(struct IPAddress), - offsetof(struct IPAddress, _asn_ctx), - offsetof(struct IPAddress, present), - sizeof(((struct IPAddress *)0)->present), - asn_MAP_IPAddress_tag2el_1, - 2, /* Count of tags in the map */ - 0, - -1 /* Extensions start */ + sizeof(struct IPAddress), + offsetof(struct IPAddress, _asn_ctx), + offsetof(struct IPAddress, present), + sizeof(((struct IPAddress *)0)->present), + asn_MAP_IPAddress_tag2el_1, + 2, /* Count of tags in the map */ + 0, + -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_IPAddress = { - "IPAddress", - "IPAddress", - CHOICE_free, - CHOICE_print, - CHOICE_constraint, - CHOICE_decode_ber, - CHOICE_encode_der, - CHOICE_decode_xer, - CHOICE_encode_xer, - CHOICE_decode_uper, - CHOICE_encode_uper, - CHOICE_outmost_tag, - 0, /* No effective tags (pointer) */ - 0, /* No effective tags (count) */ - 0, /* No tags (pointer) */ - 0, /* No tags (count) */ - &asn_PER_type_IPAddress_constr_1, - asn_MBR_IPAddress_1, - 2, /* Elements count */ - &asn_SPC_IPAddress_specs_1 /* Additional specs */ + "IPAddress", + "IPAddress", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &ASN_PER_TYPE_IP_ADDRESS_CONSTR_1, + asn_MBR_IPAddress_1, + 2, /* Elements count */ + &asn_SPC_IPAddress_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/KeyIdentity.c b/src/core/libs/supl/asn-supl/KeyIdentity.c index 210eacb06..cb4081683 100644 --- a/src/core/libs/supl/asn-supl/KeyIdentity.c +++ b/src/core/libs/supl/asn-supl/KeyIdentity.c @@ -6,35 +6,42 @@ #include "KeyIdentity.h" -int -KeyIdentity_constraint(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 128)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } +int KeyIdentity_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 128) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } /* @@ -42,110 +49,113 @@ KeyIdentity_constraint(asn_TYPE_descriptor_t *td, const void *sptr, * so here we adjust the DEF accordingly. */ static void -KeyIdentity_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { - td->free_struct = asn_DEF_BIT_STRING.free_struct; - td->print_struct = asn_DEF_BIT_STRING.print_struct; - td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; - td->der_encoder = asn_DEF_BIT_STRING.der_encoder; - td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; - td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; - td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; - td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; - if(!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; - td->elements = asn_DEF_BIT_STRING.elements; - td->elements_count = asn_DEF_BIT_STRING.elements_count; - td->specifics = asn_DEF_BIT_STRING.specifics; +KeyIdentity_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) +{ + td->free_struct = asn_DEF_BIT_STRING.free_struct; + td->print_struct = asn_DEF_BIT_STRING.print_struct; + td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; + td->der_encoder = asn_DEF_BIT_STRING.der_encoder; + td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; + td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; + td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; + td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; + if (!td->per_constraints) + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + td->elements = asn_DEF_BIT_STRING.elements; + td->elements_count = asn_DEF_BIT_STRING.elements_count; + td->specifics = asn_DEF_BIT_STRING.specifics; } -void -KeyIdentity_free(asn_TYPE_descriptor_t *td, - void *struct_ptr, int contents_only) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - td->free_struct(td, struct_ptr, contents_only); +void KeyIdentity_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); } -int -KeyIdentity_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, - int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +int KeyIdentity_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t KeyIdentity_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const void *bufptr, size_t size, int tag_mode) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); + void **structure, const void *bufptr, size_t size, int tag_mode) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t KeyIdentity_encode_der(asn_TYPE_descriptor_t *td, - void *structure, int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t KeyIdentity_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const char *opt_mname, const void *bufptr, size_t size) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); + void **structure, const char *opt_mname, const void *bufptr, size_t size) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t KeyIdentity_encode_xer(asn_TYPE_descriptor_t *td, void *structure, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } asn_dec_rval_t KeyIdentity_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); + asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); } asn_enc_rval_t KeyIdentity_encode_uper(asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, - void *structure, asn_per_outp_t *per_out) { - KeyIdentity_1_inherit_TYPE_descriptor(td); - return td->uper_encoder(td, constraints, structure, per_out); + asn_per_constraints_t *constraints, + void *structure, asn_per_outp_t *per_out) +{ + KeyIdentity_1_inherit_TYPE_descriptor(td); + return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_KeyIdentity_constr_1 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 128, 128 } /* (SIZE(128..128)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_TYPE_KEY_IDENTITY_CONSTR_1 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 128, 128} /* (SIZE(128..128)) */, + 0, 0 /* No PER value map */ }; static ber_tlv_tag_t asn_DEF_KeyIdentity_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))}; asn_TYPE_descriptor_t asn_DEF_KeyIdentity = { - "KeyIdentity", - "KeyIdentity", - KeyIdentity_free, - KeyIdentity_print, - KeyIdentity_constraint, - KeyIdentity_decode_ber, - KeyIdentity_encode_der, - KeyIdentity_decode_xer, - KeyIdentity_encode_xer, - KeyIdentity_decode_uper, - KeyIdentity_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_KeyIdentity_tags_1, - sizeof(asn_DEF_KeyIdentity_tags_1) - /sizeof(asn_DEF_KeyIdentity_tags_1[0]), /* 1 */ - asn_DEF_KeyIdentity_tags_1, /* Same as above */ - sizeof(asn_DEF_KeyIdentity_tags_1) - /sizeof(asn_DEF_KeyIdentity_tags_1[0]), /* 1 */ - &asn_PER_type_KeyIdentity_constr_1, - 0, 0, /* No members */ - 0 /* No specifics */ + "KeyIdentity", + "KeyIdentity", + KeyIdentity_free, + KeyIdentity_print, + KeyIdentity_constraint, + KeyIdentity_decode_ber, + KeyIdentity_encode_der, + KeyIdentity_decode_xer, + KeyIdentity_encode_xer, + KeyIdentity_decode_uper, + KeyIdentity_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_KeyIdentity_tags_1, + sizeof(asn_DEF_KeyIdentity_tags_1) / sizeof(asn_DEF_KeyIdentity_tags_1[0]), /* 1 */ + asn_DEF_KeyIdentity_tags_1, /* Same as above */ + sizeof(asn_DEF_KeyIdentity_tags_1) / sizeof(asn_DEF_KeyIdentity_tags_1[0]), /* 1 */ + &ASN_PER_TYPE_KEY_IDENTITY_CONSTR_1, + 0, 0, /* No members */ + 0 /* No specifics */ }; - diff --git a/src/core/libs/supl/asn-supl/KeyIdentity4.c b/src/core/libs/supl/asn-supl/KeyIdentity4.c index 1a993f1bd..55c90f14e 100644 --- a/src/core/libs/supl/asn-supl/KeyIdentity4.c +++ b/src/core/libs/supl/asn-supl/KeyIdentity4.c @@ -6,35 +6,42 @@ #include "KeyIdentity4.h" -int -KeyIdentity4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 128)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } +int KeyIdentity4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 128) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } /* @@ -42,110 +49,113 @@ KeyIdentity4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, * so here we adjust the DEF accordingly. */ static void -KeyIdentity4_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { - td->free_struct = asn_DEF_BIT_STRING.free_struct; - td->print_struct = asn_DEF_BIT_STRING.print_struct; - td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; - td->der_encoder = asn_DEF_BIT_STRING.der_encoder; - td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; - td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; - td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; - td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; - if(!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; - td->elements = asn_DEF_BIT_STRING.elements; - td->elements_count = asn_DEF_BIT_STRING.elements_count; - td->specifics = asn_DEF_BIT_STRING.specifics; +KeyIdentity4_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) +{ + td->free_struct = asn_DEF_BIT_STRING.free_struct; + td->print_struct = asn_DEF_BIT_STRING.print_struct; + td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; + td->der_encoder = asn_DEF_BIT_STRING.der_encoder; + td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; + td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; + td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; + td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; + if (!td->per_constraints) + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + td->elements = asn_DEF_BIT_STRING.elements; + td->elements_count = asn_DEF_BIT_STRING.elements_count; + td->specifics = asn_DEF_BIT_STRING.specifics; } -void -KeyIdentity4_free(asn_TYPE_descriptor_t *td, - void *struct_ptr, int contents_only) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - td->free_struct(td, struct_ptr, contents_only); +void KeyIdentity4_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); } -int -KeyIdentity4_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, - int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +int KeyIdentity4_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t KeyIdentity4_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const void *bufptr, size_t size, int tag_mode) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); + void **structure, const void *bufptr, size_t size, int tag_mode) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t KeyIdentity4_encode_der(asn_TYPE_descriptor_t *td, - void *structure, int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t KeyIdentity4_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const char *opt_mname, const void *bufptr, size_t size) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); + void **structure, const char *opt_mname, const void *bufptr, size_t size) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t KeyIdentity4_encode_xer(asn_TYPE_descriptor_t *td, void *structure, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } asn_dec_rval_t KeyIdentity4_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); + asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); } asn_enc_rval_t KeyIdentity4_encode_uper(asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, - void *structure, asn_per_outp_t *per_out) { - KeyIdentity4_1_inherit_TYPE_descriptor(td); - return td->uper_encoder(td, constraints, structure, per_out); + asn_per_constraints_t *constraints, + void *structure, asn_per_outp_t *per_out) +{ + KeyIdentity4_1_inherit_TYPE_descriptor(td); + return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_KeyIdentity4_constr_1 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 128, 128 } /* (SIZE(128..128)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_TYPE_KEY_IDENTITY4_CONSTR_1 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 128, 128} /* (SIZE(128..128)) */, + 0, 0 /* No PER value map */ }; static ber_tlv_tag_t asn_DEF_KeyIdentity4_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))}; asn_TYPE_descriptor_t asn_DEF_KeyIdentity4 = { - "KeyIdentity4", - "KeyIdentity4", - KeyIdentity4_free, - KeyIdentity4_print, - KeyIdentity4_constraint, - KeyIdentity4_decode_ber, - KeyIdentity4_encode_der, - KeyIdentity4_decode_xer, - KeyIdentity4_encode_xer, - KeyIdentity4_decode_uper, - KeyIdentity4_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_KeyIdentity4_tags_1, - sizeof(asn_DEF_KeyIdentity4_tags_1) - /sizeof(asn_DEF_KeyIdentity4_tags_1[0]), /* 1 */ - asn_DEF_KeyIdentity4_tags_1, /* Same as above */ - sizeof(asn_DEF_KeyIdentity4_tags_1) - /sizeof(asn_DEF_KeyIdentity4_tags_1[0]), /* 1 */ - &asn_PER_type_KeyIdentity4_constr_1, - 0, 0, /* No members */ - 0 /* No specifics */ + "KeyIdentity4", + "KeyIdentity4", + KeyIdentity4_free, + KeyIdentity4_print, + KeyIdentity4_constraint, + KeyIdentity4_decode_ber, + KeyIdentity4_encode_der, + KeyIdentity4_decode_xer, + KeyIdentity4_encode_xer, + KeyIdentity4_decode_uper, + KeyIdentity4_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_KeyIdentity4_tags_1, + sizeof(asn_DEF_KeyIdentity4_tags_1) / sizeof(asn_DEF_KeyIdentity4_tags_1[0]), /* 1 */ + asn_DEF_KeyIdentity4_tags_1, /* Same as above */ + sizeof(asn_DEF_KeyIdentity4_tags_1) / sizeof(asn_DEF_KeyIdentity4_tags_1[0]), /* 1 */ + &ASN_PER_TYPE_KEY_IDENTITY4_CONSTR_1, + 0, 0, /* No members */ + 0 /* No specifics */ }; - diff --git a/src/core/libs/supl/asn-supl/MAC.c b/src/core/libs/supl/asn-supl/MAC.c index 03ab5da2c..2fe9de455 100644 --- a/src/core/libs/supl/asn-supl/MAC.c +++ b/src/core/libs/supl/asn-supl/MAC.c @@ -6,35 +6,42 @@ #include "MAC.h" -int -MAC_constraint(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 64)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } +int MAC_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 64) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } /* @@ -42,110 +49,113 @@ MAC_constraint(asn_TYPE_descriptor_t *td, const void *sptr, * so here we adjust the DEF accordingly. */ static void -MAC_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { - td->free_struct = asn_DEF_BIT_STRING.free_struct; - td->print_struct = asn_DEF_BIT_STRING.print_struct; - td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; - td->der_encoder = asn_DEF_BIT_STRING.der_encoder; - td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; - td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; - td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; - td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; - if(!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; - td->elements = asn_DEF_BIT_STRING.elements; - td->elements_count = asn_DEF_BIT_STRING.elements_count; - td->specifics = asn_DEF_BIT_STRING.specifics; +MAC_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) +{ + td->free_struct = asn_DEF_BIT_STRING.free_struct; + td->print_struct = asn_DEF_BIT_STRING.print_struct; + td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; + td->der_encoder = asn_DEF_BIT_STRING.der_encoder; + td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; + td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; + td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; + td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; + if (!td->per_constraints) + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + td->elements = asn_DEF_BIT_STRING.elements; + td->elements_count = asn_DEF_BIT_STRING.elements_count; + td->specifics = asn_DEF_BIT_STRING.specifics; } -void -MAC_free(asn_TYPE_descriptor_t *td, - void *struct_ptr, int contents_only) { - MAC_1_inherit_TYPE_descriptor(td); - td->free_struct(td, struct_ptr, contents_only); +void MAC_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) +{ + MAC_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); } -int -MAC_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, - int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { - MAC_1_inherit_TYPE_descriptor(td); - return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +int MAC_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) +{ + MAC_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MAC_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const void *bufptr, size_t size, int tag_mode) { - MAC_1_inherit_TYPE_descriptor(td); - return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); + void **structure, const void *bufptr, size_t size, int tag_mode) +{ + MAC_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MAC_encode_der(asn_TYPE_descriptor_t *td, - void *structure, int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - MAC_1_inherit_TYPE_descriptor(td); - return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) +{ + MAC_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MAC_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const char *opt_mname, const void *bufptr, size_t size) { - MAC_1_inherit_TYPE_descriptor(td); - return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); + void **structure, const char *opt_mname, const void *bufptr, size_t size) +{ + MAC_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MAC_encode_xer(asn_TYPE_descriptor_t *td, void *structure, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - MAC_1_inherit_TYPE_descriptor(td); - return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) +{ + MAC_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } asn_dec_rval_t MAC_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { - MAC_1_inherit_TYPE_descriptor(td); - return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); + asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) +{ + MAC_1_inherit_TYPE_descriptor(td); + return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); } asn_enc_rval_t MAC_encode_uper(asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, - void *structure, asn_per_outp_t *per_out) { - MAC_1_inherit_TYPE_descriptor(td); - return td->uper_encoder(td, constraints, structure, per_out); + asn_per_constraints_t *constraints, + void *structure, asn_per_outp_t *per_out) +{ + MAC_1_inherit_TYPE_descriptor(td); + return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_MAC_constr_1 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 64, 64 } /* (SIZE(64..64)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_TYPE_MAC_CONSTR_1 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 64, 64} /* (SIZE(64..64)) */, + 0, 0 /* No PER value map */ }; static ber_tlv_tag_t asn_DEF_MAC_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))}; asn_TYPE_descriptor_t asn_DEF_MAC = { - "MAC", - "MAC", - MAC_free, - MAC_print, - MAC_constraint, - MAC_decode_ber, - MAC_encode_der, - MAC_decode_xer, - MAC_encode_xer, - MAC_decode_uper, - MAC_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_MAC_tags_1, - sizeof(asn_DEF_MAC_tags_1) - /sizeof(asn_DEF_MAC_tags_1[0]), /* 1 */ - asn_DEF_MAC_tags_1, /* Same as above */ - sizeof(asn_DEF_MAC_tags_1) - /sizeof(asn_DEF_MAC_tags_1[0]), /* 1 */ - &asn_PER_type_MAC_constr_1, - 0, 0, /* No members */ - 0 /* No specifics */ + "MAC", + "MAC", + MAC_free, + MAC_print, + MAC_constraint, + MAC_decode_ber, + MAC_encode_der, + MAC_decode_xer, + MAC_encode_xer, + MAC_decode_uper, + MAC_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_MAC_tags_1, + sizeof(asn_DEF_MAC_tags_1) / sizeof(asn_DEF_MAC_tags_1[0]), /* 1 */ + asn_DEF_MAC_tags_1, /* Same as above */ + sizeof(asn_DEF_MAC_tags_1) / sizeof(asn_DEF_MAC_tags_1[0]), /* 1 */ + &ASN_PER_TYPE_MAC_CONSTR_1, + 0, 0, /* No members */ + 0 /* No specifics */ }; - diff --git a/src/core/libs/supl/asn-supl/MeasuredResultsList.c b/src/core/libs/supl/asn-supl/MeasuredResultsList.c index 1108ef45e..dd653c7a2 100644 --- a/src/core/libs/supl/asn-supl/MeasuredResultsList.c +++ b/src/core/libs/supl/asn-supl/MeasuredResultsList.c @@ -6,7 +6,7 @@ #include "MeasuredResultsList.h" -static asn_per_constraints_t asn_PER_type_MeasuredResultsList_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_MEASURED_RESULTS_LIST_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 3, 3, 1, 8 } /* (SIZE(1..8)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_MeasuredResultsList = { asn_DEF_MeasuredResultsList_tags_1, /* Same as above */ sizeof(asn_DEF_MeasuredResultsList_tags_1) /sizeof(asn_DEF_MeasuredResultsList_tags_1[0]), /* 1 */ - &asn_PER_type_MeasuredResultsList_constr_1, + &ASN_PER_TYPE_MEASURED_RESULTS_LIST_CONSTR_1, asn_MBR_MeasuredResultsList_1, 1, /* Single element */ &asn_SPC_MeasuredResultsList_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/NMR.c b/src/core/libs/supl/asn-supl/NMR.c index f64caffbe..f9fff612e 100644 --- a/src/core/libs/supl/asn-supl/NMR.c +++ b/src/core/libs/supl/asn-supl/NMR.c @@ -6,7 +6,7 @@ #include "NMR.h" -static asn_per_constraints_t asn_PER_type_NMR_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_NMR_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 15 } /* (SIZE(1..15)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_NMR = { asn_DEF_NMR_tags_1, /* Same as above */ sizeof(asn_DEF_NMR_tags_1) /sizeof(asn_DEF_NMR_tags_1[0]), /* 1 */ - &asn_PER_type_NMR_constr_1, + &ASN_PER_TYPE_NMR_CONSTR_1, asn_MBR_NMR_1, 1, /* Single element */ &asn_SPC_NMR_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/NMRelement.c b/src/core/libs/supl/asn-supl/NMRelement.c index 79d122d82..ae64a2e78 100644 --- a/src/core/libs/supl/asn-supl/NMRelement.c +++ b/src/core/libs/supl/asn-supl/NMRelement.c @@ -81,17 +81,17 @@ memb_rxLev_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_aRFCN_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_A_RFCN_CONSTR_2 = { { APC_CONSTRAINED, 10, 10, 0, 1023 } /* (0..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_bSIC_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_B_SIC_CONSTR_3 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_rxLev_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_RX_LEV_CONSTR_4 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -102,7 +102,7 @@ static asn_TYPE_member_t asn_MBR_NMRelement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_aRFCN_constraint_1, - &asn_PER_memb_aRFCN_constr_2, + &ASN_PER_MEMB_A_RFCN_CONSTR_2, 0, "aRFCN" }, @@ -111,7 +111,7 @@ static asn_TYPE_member_t asn_MBR_NMRelement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_bSIC_constraint_1, - &asn_PER_memb_bSIC_constr_3, + &ASN_PER_MEMB_B_SIC_CONSTR_3, 0, "bSIC" }, @@ -120,7 +120,7 @@ static asn_TYPE_member_t asn_MBR_NMRelement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_rxLev_constraint_1, - &asn_PER_memb_rxLev_constr_4, + &ASN_PER_MEMB_RX_LEV_CONSTR_4, 0, "rxLev" }, diff --git a/src/core/libs/supl/asn-supl/Notification.c b/src/core/libs/supl/asn-supl/Notification.c index 7643e9048..c8d4c280e 100644 --- a/src/core/libs/supl/asn-supl/Notification.c +++ b/src/core/libs/supl/asn-supl/Notification.c @@ -58,12 +58,12 @@ memb_clientName_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_requestorId_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_REQUESTOR_ID_CONSTR_4 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 6, 6, 1, 50 } /* (SIZE(1..50)) */, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_clientName_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_CLIENT_NAME_CONSTR_6 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 6, 6, 1, 50 } /* (SIZE(1..50)) */, 0, 0 /* No PER value map */ @@ -92,7 +92,7 @@ static asn_TYPE_member_t asn_MBR_Notification_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, memb_requestorId_constraint_1, - &asn_PER_memb_requestorId_constr_4, + &ASN_PER_MEMB_REQUESTOR_ID_CONSTR_4, 0, "requestorId" }, @@ -110,7 +110,7 @@ static asn_TYPE_member_t asn_MBR_Notification_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, memb_clientName_constraint_1, - &asn_PER_memb_clientName_constr_6, + &ASN_PER_MEMB_CLIENT_NAME_CONSTR_6, 0, "clientName" }, diff --git a/src/core/libs/supl/asn-supl/NotificationType.c b/src/core/libs/supl/asn-supl/NotificationType.c index 8c1178a98..e6b591c40 100644 --- a/src/core/libs/supl/asn-supl/NotificationType.c +++ b/src/core/libs/supl/asn-supl/NotificationType.c @@ -94,7 +94,7 @@ NotificationType_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_NotificationType_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_NOTIFICATION_TYPE_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 4 } /* (0..4,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -146,7 +146,7 @@ asn_TYPE_descriptor_t asn_DEF_NotificationType = { asn_DEF_NotificationType_tags_1, /* Same as above */ sizeof(asn_DEF_NotificationType_tags_1) /sizeof(asn_DEF_NotificationType_tags_1[0]), /* 1 */ - &asn_PER_type_NotificationType_constr_1, + &ASN_PER_TYPE_NOTIFICATION_TYPE_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_NotificationType_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/OCTET_STRING.c b/src/core/libs/supl/asn-supl/OCTET_STRING.c index 584def8b4..98aebb3bf 100644 --- a/src/core/libs/supl/asn-supl/OCTET_STRING.c +++ b/src/core/libs/supl/asn-supl/OCTET_STRING.c @@ -19,7 +19,7 @@ static asn_OCTET_STRING_specifics_t asn_DEF_OCTET_STRING_specs = { offsetof(OCTET_STRING_t, _asn_ctx), ASN_OSUBV_STR }; -static asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = { +static asn_per_constraints_t ASN_DEF_OCTET_STRING_CONSTRAINTS = { { APC_CONSTRAINED, 8, 8, 0, 255 }, { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, 0, 0 @@ -52,9 +52,9 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { #undef NEXT_PHASE #undef PREV_PHASE #define _CH_PHASE(ctx, inc) do { \ - if(ctx->phase == 0) \ - ctx->context = 0; \ - ctx->phase += inc; \ + if((ctx)->phase == 0) \ + (ctx)->context = 0; \ + (ctx)->phase += (inc); \ } while(0) #define NEXT_PHASE(ctx) _CH_PHASE(ctx, +1) #define PREV_PHASE(ctx) _CH_PHASE(ctx, -1) @@ -1351,8 +1351,8 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, cval = &pc->value; csiz = &pc->size; } else { - cval = &asn_DEF_OCTET_STRING_constraints.value; - csiz = &asn_DEF_OCTET_STRING_constraints.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; } switch(specs->subvariant) { @@ -1400,8 +1400,8 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, int inext = per_get_few_bits(pd, 1); if(inext < 0) RETURN(RC_WMORE); if(inext) { - csiz = &asn_DEF_OCTET_STRING_constraints.size; - cval = &asn_DEF_OCTET_STRING_constraints.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; unit_bits = canonical_unit_bits; } } @@ -1526,8 +1526,8 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, cval = &pc->value; csiz = &pc->size; } else { - cval = &asn_DEF_OCTET_STRING_constraints.value; - csiz = &asn_DEF_OCTET_STRING_constraints.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; } ct_extensible = csiz->flags & APC_EXTENSIBLE; @@ -1577,8 +1577,8 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, if((int)sizeinunits < csiz->lower_bound || (int)sizeinunits > csiz->upper_bound) { if(ct_extensible) { - cval = &asn_DEF_OCTET_STRING_constraints.value; - csiz = &asn_DEF_OCTET_STRING_constraints.size; + cval = &ASN_DEF_OCTET_STRING_CONSTRAINTS.value; + csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; unit_bits = canonical_unit_bits; inext = 1; } else diff --git a/src/core/libs/supl/asn-supl/OCTET_STRING.h b/src/core/libs/supl/asn-supl/OCTET_STRING.h index 124fde559..9387a4d4b 100644 --- a/src/core/libs/supl/asn-supl/OCTET_STRING.h +++ b/src/core/libs/supl/asn-supl/OCTET_STRING.h @@ -48,7 +48,7 @@ extern "C" * current contents of the OCTET STRING. * Returns 0 if it was possible to perform operation, -1 otherwise. */ - int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size); + int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int len); /* Handy conversion from the C string into the OCTET STRING. */ #define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1) @@ -59,7 +59,7 @@ extern "C" * empty OCTET STRING. */ OCTET_STRING_t *OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td, - const char *str, int size); + const char *str, int len); /**************************** * Internally useful stuff. * diff --git a/src/core/libs/supl/asn-supl/Pathloss.c b/src/core/libs/supl/asn-supl/Pathloss.c index 3bbec50fb..ddeca35b9 100644 --- a/src/core/libs/supl/asn-supl/Pathloss.c +++ b/src/core/libs/supl/asn-supl/Pathloss.c @@ -111,7 +111,7 @@ Pathloss_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_Pathloss_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_PATHLOSS_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 46, 173 } /* (46..173) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_Pathloss = { asn_DEF_Pathloss_tags_1, /* Same as above */ sizeof(asn_DEF_Pathloss_tags_1) /sizeof(asn_DEF_Pathloss_tags_1[0]), /* 1 */ - &asn_PER_type_Pathloss_constr_1, + &ASN_PER_TYPE_PATHLOSS_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/PosMethod.c b/src/core/libs/supl/asn-supl/PosMethod.c index d65c13b6f..b720df296 100644 --- a/src/core/libs/supl/asn-supl/PosMethod.c +++ b/src/core/libs/supl/asn-supl/PosMethod.c @@ -94,7 +94,7 @@ PosMethod_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_PosMethod_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_POS_METHOD_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 4, 4, 0, 9 } /* (0..9,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -156,7 +156,7 @@ asn_TYPE_descriptor_t asn_DEF_PosMethod = { asn_DEF_PosMethod_tags_1, /* Same as above */ sizeof(asn_DEF_PosMethod_tags_1) /sizeof(asn_DEF_PosMethod_tags_1[0]), /* 1 */ - &asn_PER_type_PosMethod_constr_1, + &ASN_PER_TYPE_POS_METHOD_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_PosMethod_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/PosPayLoad.c b/src/core/libs/supl/asn-supl/PosPayLoad.c index b12f05e74..ebb173c43 100644 --- a/src/core/libs/supl/asn-supl/PosPayLoad.c +++ b/src/core/libs/supl/asn-supl/PosPayLoad.c @@ -84,22 +84,22 @@ memb_rrlpPayload_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_tia801payload_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_TIA801PAYLOAD_CONSTR_2 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 13, 13, 1, 8192 } /* (SIZE(1..8192)) */, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_rrcPayload_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_RRC_PAYLOAD_CONSTR_3 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 13, 13, 1, 8192 } /* (SIZE(1..8192)) */, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_rrlpPayload_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_RRLP_PAYLOAD_CONSTR_4 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 13, 13, 1, 8192 } /* (SIZE(1..8192)) */, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_type_PosPayLoad_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_POS_PAY_LOAD_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -110,7 +110,7 @@ static asn_TYPE_member_t asn_MBR_PosPayLoad_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, memb_tia801payload_constraint_1, - &asn_PER_memb_tia801payload_constr_2, + &ASN_PER_MEMB_TIA801PAYLOAD_CONSTR_2, 0, "tia801payload" }, @@ -119,7 +119,7 @@ static asn_TYPE_member_t asn_MBR_PosPayLoad_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, memb_rrcPayload_constraint_1, - &asn_PER_memb_rrcPayload_constr_3, + &ASN_PER_MEMB_RRC_PAYLOAD_CONSTR_3, 0, "rrcPayload" }, @@ -128,7 +128,7 @@ static asn_TYPE_member_t asn_MBR_PosPayLoad_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, memb_rrlpPayload_constraint_1, - &asn_PER_memb_rrlpPayload_constr_4, + &ASN_PER_MEMB_RRLP_PAYLOAD_CONSTR_4, 0, "rrlpPayload" }, @@ -165,7 +165,7 @@ asn_TYPE_descriptor_t asn_DEF_PosPayLoad = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_PosPayLoad_constr_1, + &ASN_PER_TYPE_POS_PAY_LOAD_CONSTR_1, asn_MBR_PosPayLoad_1, 3, /* Elements count */ &asn_SPC_PosPayLoad_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/PositionEstimate.c b/src/core/libs/supl/asn-supl/PositionEstimate.c index 4b7367af2..ee44b7a11 100644 --- a/src/core/libs/supl/asn-supl/PositionEstimate.c +++ b/src/core/libs/supl/asn-supl/PositionEstimate.c @@ -244,37 +244,37 @@ memb_confidence_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_type_latitudeSign_constr_2 = { +static asn_per_constraints_t ASN_PER_TYPE_LATITUDE_SIGN_CONSTR_2 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_uncertaintySemiMajor_constr_8 = { +static asn_per_constraints_t ASN_PER_MEMB_UNCERTAINTY_SEMI_MAJOR_CONSTR_8 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_uncertaintySemiMinor_constr_9 = { +static asn_per_constraints_t ASN_PER_MEMB_UNCERTAINTY_SEMI_MINOR_CONSTR_9 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_orientationMajorAxis_constr_10 = { +static asn_per_constraints_t ASN_PER_MEMB_ORIENTATION_MAJOR_AXIS_CONSTR_10 = { { APC_CONSTRAINED, 8, 8, 0, 180 } /* (0..180) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_latitude_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_LATITUDE_CONSTR_5 = { { APC_CONSTRAINED, 23, -1, 0, 8388607 } /* (0..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_longitude_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_LONGITUDE_CONSTR_6 = { { APC_CONSTRAINED, 24, -1, -8388608, 8388607 } /* (-8388608..8388607) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_confidence_constr_11 = { +static asn_per_constraints_t ASN_PER_MEMB_CONFIDENCE_CONSTR_11 = { { APC_CONSTRAINED, 7, 7, 0, 100 } /* (0..100) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -320,7 +320,7 @@ asn_TYPE_descriptor_t asn_DEF_latitudeSign_2 = { asn_DEF_latitudeSign_tags_2, /* Same as above */ sizeof(asn_DEF_latitudeSign_tags_2) /sizeof(asn_DEF_latitudeSign_tags_2[0]), /* 2 */ - &asn_PER_type_latitudeSign_constr_2, + &ASN_PER_TYPE_LATITUDE_SIGN_CONSTR_2, 0, 0, /* Defined elsewhere */ &asn_SPC_latitudeSign_specs_2 /* Additional specs */ }; @@ -331,7 +331,7 @@ static asn_TYPE_member_t asn_MBR_uncertainty_7[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_uncertaintySemiMajor_constraint_7, - &asn_PER_memb_uncertaintySemiMajor_constr_8, + &ASN_PER_MEMB_UNCERTAINTY_SEMI_MAJOR_CONSTR_8, 0, "uncertaintySemiMajor" }, @@ -340,7 +340,7 @@ static asn_TYPE_member_t asn_MBR_uncertainty_7[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_uncertaintySemiMinor_constraint_7, - &asn_PER_memb_uncertaintySemiMinor_constr_9, + &ASN_PER_MEMB_UNCERTAINTY_SEMI_MINOR_CONSTR_9, 0, "uncertaintySemiMinor" }, @@ -349,7 +349,7 @@ static asn_TYPE_member_t asn_MBR_uncertainty_7[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_orientationMajorAxis_constraint_7, - &asn_PER_memb_orientationMajorAxis_constr_10, + &ASN_PER_MEMB_ORIENTATION_MAJOR_AXIS_CONSTR_10, 0, "orientationMajorAxis" }, @@ -413,7 +413,7 @@ static asn_TYPE_member_t asn_MBR_PositionEstimate_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_latitude_constraint_1, - &asn_PER_memb_latitude_constr_5, + &ASN_PER_MEMB_LATITUDE_CONSTR_5, 0, "latitude" }, @@ -422,7 +422,7 @@ static asn_TYPE_member_t asn_MBR_PositionEstimate_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_longitude_constraint_1, - &asn_PER_memb_longitude_constr_6, + &ASN_PER_MEMB_LONGITUDE_CONSTR_6, 0, "longitude" }, @@ -440,7 +440,7 @@ static asn_TYPE_member_t asn_MBR_PositionEstimate_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_confidence_constraint_1, - &asn_PER_memb_confidence_constr_11, + &ASN_PER_MEMB_CONFIDENCE_CONSTR_11, 0, "confidence" }, diff --git a/src/core/libs/supl/asn-supl/PrefMethod.c b/src/core/libs/supl/asn-supl/PrefMethod.c index 3949a64ec..e07280a8f 100644 --- a/src/core/libs/supl/asn-supl/PrefMethod.c +++ b/src/core/libs/supl/asn-supl/PrefMethod.c @@ -94,7 +94,7 @@ PrefMethod_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_PrefMethod_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_PREF_METHOD_CONSTR_1 = { { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -140,7 +140,7 @@ asn_TYPE_descriptor_t asn_DEF_PrefMethod = { asn_DEF_PrefMethod_tags_1, /* Same as above */ sizeof(asn_DEF_PrefMethod_tags_1) /sizeof(asn_DEF_PrefMethod_tags_1[0]), /* 1 */ - &asn_PER_type_PrefMethod_constr_1, + &ASN_PER_TYPE_PREF_METHOD_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_PrefMethod_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c b/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c index ea2ce5877..1c7d91177 100644 --- a/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c +++ b/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c @@ -111,7 +111,7 @@ PrimaryCCPCH_RSCP_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_PrimaryCCPCH_RSCP_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_PRIMARY_CCPCH_RSCP_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_PrimaryCCPCH_RSCP = { asn_DEF_PrimaryCCPCH_RSCP_tags_1, /* Same as above */ sizeof(asn_DEF_PrimaryCCPCH_RSCP_tags_1) /sizeof(asn_DEF_PrimaryCCPCH_RSCP_tags_1[0]), /* 1 */ - &asn_PER_type_PrimaryCCPCH_RSCP_constr_1, + &ASN_PER_TYPE_PRIMARY_CCPCH_RSCP_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/PrimaryCPICH-Info.c b/src/core/libs/supl/asn-supl/PrimaryCPICH-Info.c index 62efe3f10..f7afc5b7c 100644 --- a/src/core/libs/supl/asn-supl/PrimaryCPICH-Info.c +++ b/src/core/libs/supl/asn-supl/PrimaryCPICH-Info.c @@ -31,7 +31,7 @@ memb_primaryScramblingCode_constraint_1(asn_TYPE_descriptor_t *td, const void *s } } -static asn_per_constraints_t asn_PER_memb_primaryScramblingCode_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_PRIMARY_SCRAMBLING_CODE_CONSTR_2 = { { APC_CONSTRAINED, 9, 9, 0, 511 } /* (0..511) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_PrimaryCPICH_Info_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_primaryScramblingCode_constraint_1, - &asn_PER_memb_primaryScramblingCode_constr_2, + &ASN_PER_MEMB_PRIMARY_SCRAMBLING_CODE_CONSTR_2, 0, "primaryScramblingCode" }, diff --git a/src/core/libs/supl/asn-supl/QoP.c b/src/core/libs/supl/asn-supl/QoP.c index 5591c9f49..9bc7e6372 100644 --- a/src/core/libs/supl/asn-supl/QoP.c +++ b/src/core/libs/supl/asn-supl/QoP.c @@ -106,22 +106,22 @@ memb_delay_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_horacc_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_HORACC_CONSTR_2 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_veracc_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_VERACC_CONSTR_3 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_maxLocAge_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_MAX_LOC_AGE_CONSTR_4 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_delay_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_DELAY_CONSTR_5 = { { APC_CONSTRAINED, 3, 3, 0, 7 } /* (0..7) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -132,7 +132,7 @@ static asn_TYPE_member_t asn_MBR_QoP_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_horacc_constraint_1, - &asn_PER_memb_horacc_constr_2, + &ASN_PER_MEMB_HORACC_CONSTR_2, 0, "horacc" }, @@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_QoP_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_veracc_constraint_1, - &asn_PER_memb_veracc_constr_3, + &ASN_PER_MEMB_VERACC_CONSTR_3, 0, "veracc" }, @@ -150,7 +150,7 @@ static asn_TYPE_member_t asn_MBR_QoP_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_maxLocAge_constraint_1, - &asn_PER_memb_maxLocAge_constr_4, + &ASN_PER_MEMB_MAX_LOC_AGE_CONSTR_4, 0, "maxLocAge" }, @@ -159,7 +159,7 @@ static asn_TYPE_member_t asn_MBR_QoP_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_delay_constraint_1, - &asn_PER_memb_delay_constr_5, + &ASN_PER_MEMB_DELAY_CONSTR_5, 0, "delay" }, diff --git a/src/core/libs/supl/asn-supl/SETAuthKey.c b/src/core/libs/supl/asn-supl/SETAuthKey.c index 75b01ca3b..7918881de 100644 --- a/src/core/libs/supl/asn-supl/SETAuthKey.c +++ b/src/core/libs/supl/asn-supl/SETAuthKey.c @@ -8,135 +8,148 @@ static int memb_shortKey_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 128)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 128) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_longKey_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 256)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 256) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_shortKey_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 128, 128 } /* (SIZE(128..128)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_SHORT_KEY_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 128, 128} /* (SIZE(128..128)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_longKey_constr_3 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 256, 256 } /* (SIZE(256..256)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_LONG_KEY_CONSTR_3 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 256, 256} /* (SIZE(256..256)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_type_SETAuthKey_constr_1 = { - { APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */, - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_TYPE_SET_AUTH_KEY_CONSTR_1 = { + {APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1} /* (0..1,...) */, + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_SETAuthKey_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct SETAuthKey, choice.shortKey), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_shortKey_constraint_1, - &asn_PER_memb_shortKey_constr_2, - 0, - "shortKey" - }, - { ATF_NOFLAGS, 0, offsetof(struct SETAuthKey, choice.longKey), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_longKey_constraint_1, - &asn_PER_memb_longKey_constr_3, - 0, - "longKey" - }, + {ATF_NOFLAGS, 0, offsetof(struct SETAuthKey, choice.shortKey), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_shortKey_constraint_1, + &ASN_PER_MEMB_SHORT_KEY_CONSTR_2, + 0, + "shortKey"}, + {ATF_NOFLAGS, 0, offsetof(struct SETAuthKey, choice.longKey), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_longKey_constraint_1, + &ASN_PER_MEMB_LONG_KEY_CONSTR_3, + 0, + "longKey"}, }; static asn_TYPE_tag2member_t asn_MAP_SETAuthKey_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* shortKey at 17 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* longKey at 18 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* shortKey at 17 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0} /* longKey at 18 */ }; static asn_CHOICE_specifics_t asn_SPC_SETAuthKey_specs_1 = { - sizeof(struct SETAuthKey), - offsetof(struct SETAuthKey, _asn_ctx), - offsetof(struct SETAuthKey, present), - sizeof(((struct SETAuthKey *)0)->present), - asn_MAP_SETAuthKey_tag2el_1, - 2, /* Count of tags in the map */ - 0, - 2 /* Extensions start */ + sizeof(struct SETAuthKey), + offsetof(struct SETAuthKey, _asn_ctx), + offsetof(struct SETAuthKey, present), + sizeof(((struct SETAuthKey *)0)->present), + asn_MAP_SETAuthKey_tag2el_1, + 2, /* Count of tags in the map */ + 0, + 2 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_SETAuthKey = { - "SETAuthKey", - "SETAuthKey", - CHOICE_free, - CHOICE_print, - CHOICE_constraint, - CHOICE_decode_ber, - CHOICE_encode_der, - CHOICE_decode_xer, - CHOICE_encode_xer, - CHOICE_decode_uper, - CHOICE_encode_uper, - CHOICE_outmost_tag, - 0, /* No effective tags (pointer) */ - 0, /* No effective tags (count) */ - 0, /* No tags (pointer) */ - 0, /* No tags (count) */ - &asn_PER_type_SETAuthKey_constr_1, - asn_MBR_SETAuthKey_1, - 2, /* Elements count */ - &asn_SPC_SETAuthKey_specs_1 /* Additional specs */ + "SETAuthKey", + "SETAuthKey", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &ASN_PER_TYPE_SET_AUTH_KEY_CONSTR_1, + asn_MBR_SETAuthKey_1, + 2, /* Elements count */ + &asn_SPC_SETAuthKey_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/SETId.c b/src/core/libs/supl/asn-supl/SETId.c index 6da7efdf5..ec2936fb5 100644 --- a/src/core/libs/supl/asn-supl/SETId.c +++ b/src/core/libs/supl/asn-supl/SETId.c @@ -6,279 +6,301 @@ #include "SETId.h" -static int check_permitted_alphabet_6(const void *sptr) { - /* The underlying type is IA5String */ - const IA5String_t *st = (const IA5String_t *)sptr; - const uint8_t *ch = st->buf; - const uint8_t *end = ch + st->size; - - for(; ch < end; ch++) { - uint8_t cv = *ch; - if(!(cv <= 127)) return -1; - } - return 0; +static int check_permitted_alphabet_6(const void *sptr) +{ + /* The underlying type is IA5String */ + const IA5String_t *st = (const IA5String_t *)sptr; + const uint8_t *ch = st->buf; + const uint8_t *end = ch + st->size; + + for (; ch < end; ch++) + { + uint8_t cv = *ch; + if (!(cv <= 127)) return -1; + } + return 0; } static int memb_msisdn_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - size = st->size; - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = st->size; + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_mdn_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - size = st->size; - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = st->size; + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_min_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 34)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 34) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_imsi_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - size = st->size; - - if((size == 8)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = st->size; + + if (size == 8) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } static int memb_nai_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const IA5String_t *st = (const IA5String_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - size = st->size; - - if((size >= 1 && size <= 1000) - && !check_permitted_alphabet_6(st)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const IA5String_t *st = (const IA5String_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = st->size; + + if ((size >= 1 && size <= 1000) && !check_permitted_alphabet_6(st)) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_msisdn_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_MSISDN_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_mdn_constr_3 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_MDN_CONSTR_3 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_min_constr_4 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 34, 34 } /* (SIZE(34..34)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_MIN_CONSTR_4 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 34, 34} /* (SIZE(34..34)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_imsi_constr_5 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 8, 8 } /* (SIZE(8..8)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_IMSI_CONSTR_5 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 8, 8} /* (SIZE(8..8)) */, + 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_nai_constr_6 = { - { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, - { APC_CONSTRAINED, 10, 10, 1, 1000 } /* (SIZE(1..1000)) */, - 0, 0 /* No PER character map necessary */ +static asn_per_constraints_t ASN_PER_MEMB_NAI_CONSTR_6 = { + {APC_CONSTRAINED, 7, 7, 0, 127} /* (0..127) */, + {APC_CONSTRAINED, 10, 10, 1, 1000} /* (SIZE(1..1000)) */, + 0, 0 /* No PER character map necessary */ }; -static asn_per_constraints_t asn_PER_type_SETId_constr_1 = { - { APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 5 } /* (0..5,...) */, - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_TYPE_SET_ID_CONSTR_1 = { + {APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 5} /* (0..5,...) */, + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_SETId_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct SETId, choice.msisdn), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_OCTET_STRING, - memb_msisdn_constraint_1, - &asn_PER_memb_msisdn_constr_2, - 0, - "msisdn" - }, - { ATF_NOFLAGS, 0, offsetof(struct SETId, choice.mdn), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_OCTET_STRING, - memb_mdn_constraint_1, - &asn_PER_memb_mdn_constr_3, - 0, - "mdn" - }, - { ATF_NOFLAGS, 0, offsetof(struct SETId, choice.min), - (ASN_TAG_CLASS_CONTEXT | (2 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_BIT_STRING, - memb_min_constraint_1, - &asn_PER_memb_min_constr_4, - 0, - "min" - }, - { ATF_NOFLAGS, 0, offsetof(struct SETId, choice.imsi), - (ASN_TAG_CLASS_CONTEXT | (3 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_OCTET_STRING, - memb_imsi_constraint_1, - &asn_PER_memb_imsi_constr_5, - 0, - "imsi" - }, - { ATF_NOFLAGS, 0, offsetof(struct SETId, choice.nai), - (ASN_TAG_CLASS_CONTEXT | (4 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_IA5String, - memb_nai_constraint_1, - &asn_PER_memb_nai_constr_6, - 0, - "nai" - }, - { ATF_NOFLAGS, 0, offsetof(struct SETId, choice.iPAddress), - (ASN_TAG_CLASS_CONTEXT | (5 << 2)), - +1, /* EXPLICIT tag at current level */ - &asn_DEF_IPAddress, - 0, /* Defer constraints checking to the member type */ - 0, /* No PER visible constraints */ - 0, - "iPAddress" - }, + {ATF_NOFLAGS, 0, offsetof(struct SETId, choice.msisdn), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_OCTET_STRING, + memb_msisdn_constraint_1, + &ASN_PER_MEMB_MSISDN_CONSTR_2, + 0, + "msisdn"}, + {ATF_NOFLAGS, 0, offsetof(struct SETId, choice.mdn), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_OCTET_STRING, + memb_mdn_constraint_1, + &ASN_PER_MEMB_MDN_CONSTR_3, + 0, + "mdn"}, + {ATF_NOFLAGS, 0, offsetof(struct SETId, choice.min), + (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_BIT_STRING, + memb_min_constraint_1, + &ASN_PER_MEMB_MIN_CONSTR_4, + 0, + "min"}, + {ATF_NOFLAGS, 0, offsetof(struct SETId, choice.imsi), + (ASN_TAG_CLASS_CONTEXT | (3 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_OCTET_STRING, + memb_imsi_constraint_1, + &ASN_PER_MEMB_IMSI_CONSTR_5, + 0, + "imsi"}, + {ATF_NOFLAGS, 0, offsetof(struct SETId, choice.nai), + (ASN_TAG_CLASS_CONTEXT | (4 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_IA5String, + memb_nai_constraint_1, + &ASN_PER_MEMB_NAI_CONSTR_6, + 0, + "nai"}, + {ATF_NOFLAGS, 0, offsetof(struct SETId, choice.iPAddress), + (ASN_TAG_CLASS_CONTEXT | (5 << 2)), + +1, /* EXPLICIT tag at current level */ + &asn_DEF_IPAddress, + 0, /* Defer constraints checking to the member type */ + 0, /* No PER visible constraints */ + 0, + "iPAddress"}, }; static asn_TYPE_tag2member_t asn_MAP_SETId_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* msisdn at 22 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* mdn at 23 */ - { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* min at 24 */ - { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* imsi at 25 */ - { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* nai at 26 */ - { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 } /* iPAddress at 27 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* msisdn at 22 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0}, /* mdn at 23 */ + {(ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0}, /* min at 24 */ + {(ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0}, /* imsi at 25 */ + {(ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0}, /* nai at 26 */ + {(ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0} /* iPAddress at 27 */ }; static asn_CHOICE_specifics_t asn_SPC_SETId_specs_1 = { - sizeof(struct SETId), - offsetof(struct SETId, _asn_ctx), - offsetof(struct SETId, present), - sizeof(((struct SETId *)0)->present), - asn_MAP_SETId_tag2el_1, - 6, /* Count of tags in the map */ - 0, - 6 /* Extensions start */ + sizeof(struct SETId), + offsetof(struct SETId, _asn_ctx), + offsetof(struct SETId, present), + sizeof(((struct SETId *)0)->present), + asn_MAP_SETId_tag2el_1, + 6, /* Count of tags in the map */ + 0, + 6 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_SETId = { - "SETId", - "SETId", - CHOICE_free, - CHOICE_print, - CHOICE_constraint, - CHOICE_decode_ber, - CHOICE_encode_der, - CHOICE_decode_xer, - CHOICE_encode_xer, - CHOICE_decode_uper, - CHOICE_encode_uper, - CHOICE_outmost_tag, - 0, /* No effective tags (pointer) */ - 0, /* No effective tags (count) */ - 0, /* No tags (pointer) */ - 0, /* No tags (count) */ - &asn_PER_type_SETId_constr_1, - asn_MBR_SETId_1, - 6, /* Elements count */ - &asn_SPC_SETId_specs_1 /* Additional specs */ + "SETId", + "SETId", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &ASN_PER_TYPE_SET_ID_CONSTR_1, + asn_MBR_SETId_1, + 6, /* Elements count */ + &asn_SPC_SETId_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/SLPAddress.c b/src/core/libs/supl/asn-supl/SLPAddress.c index d123057c7..ece16a747 100644 --- a/src/core/libs/supl/asn-supl/SLPAddress.c +++ b/src/core/libs/supl/asn-supl/SLPAddress.c @@ -6,7 +6,7 @@ #include "SLPAddress.h" -static asn_per_constraints_t asn_PER_type_SLPAddress_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SLP_ADDRESS_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -62,7 +62,7 @@ asn_TYPE_descriptor_t asn_DEF_SLPAddress = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_SLPAddress_constr_1, + &ASN_PER_TYPE_SLP_ADDRESS_CONSTR_1, asn_MBR_SLPAddress_1, 2, /* Elements count */ &asn_SPC_SLPAddress_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/SLPMode.c b/src/core/libs/supl/asn-supl/SLPMode.c index f01e1f89a..79bf7a835 100644 --- a/src/core/libs/supl/asn-supl/SLPMode.c +++ b/src/core/libs/supl/asn-supl/SLPMode.c @@ -94,7 +94,7 @@ SLPMode_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_SLPMode_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SLP_MODE_CONSTR_1 = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_SLPMode = { asn_DEF_SLPMode_tags_1, /* Same as above */ sizeof(asn_DEF_SLPMode_tags_1) /sizeof(asn_DEF_SLPMode_tags_1[0]), /* 1 */ - &asn_PER_type_SLPMode_constr_1, + &ASN_PER_TYPE_SLP_MODE_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_SLPMode_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/SatelliteInfo.c b/src/core/libs/supl/asn-supl/SatelliteInfo.c index b32a55b86..428a1c2a0 100644 --- a/src/core/libs/supl/asn-supl/SatelliteInfo.c +++ b/src/core/libs/supl/asn-supl/SatelliteInfo.c @@ -6,7 +6,7 @@ #include "SatelliteInfo.h" -static asn_per_constraints_t asn_PER_type_SatelliteInfo_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_SATELLITE_INFO_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 5, 5, 1, 31 } /* (SIZE(1..31)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_SatelliteInfo = { asn_DEF_SatelliteInfo_tags_1, /* Same as above */ sizeof(asn_DEF_SatelliteInfo_tags_1) /sizeof(asn_DEF_SatelliteInfo_tags_1[0]), /* 1 */ - &asn_PER_type_SatelliteInfo_constr_1, + &ASN_PER_TYPE_SATELLITE_INFO_CONSTR_1, asn_MBR_SatelliteInfo_1, 1, /* Single element */ &asn_SPC_SatelliteInfo_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/SatelliteInfoElement.c b/src/core/libs/supl/asn-supl/SatelliteInfoElement.c index 0590d6e3b..3580d65e4 100644 --- a/src/core/libs/supl/asn-supl/SatelliteInfoElement.c +++ b/src/core/libs/supl/asn-supl/SatelliteInfoElement.c @@ -56,12 +56,12 @@ memb_iODE_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_satId_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_SAT_ID_CONSTR_2 = { { APC_CONSTRAINED, 6, 6, 0, 63 } /* (0..63) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_iODE_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_I_ODE_CONSTR_3 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -72,7 +72,7 @@ static asn_TYPE_member_t asn_MBR_SatelliteInfoElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_satId_constraint_1, - &asn_PER_memb_satId_constr_2, + &ASN_PER_MEMB_SAT_ID_CONSTR_2, 0, "satId" }, @@ -81,7 +81,7 @@ static asn_TYPE_member_t asn_MBR_SatelliteInfoElement_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_iODE_constraint_1, - &asn_PER_memb_iODE_constr_3, + &ASN_PER_MEMB_I_ODE_CONSTR_3, 0, "iODE" }, diff --git a/src/core/libs/supl/asn-supl/SetSessionID.c b/src/core/libs/supl/asn-supl/SetSessionID.c index 5adf6d09e..11a122d2b 100644 --- a/src/core/libs/supl/asn-supl/SetSessionID.c +++ b/src/core/libs/supl/asn-supl/SetSessionID.c @@ -31,7 +31,7 @@ memb_sessionId_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_sessionId_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_SESSION_ID_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_SetSessionID_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_sessionId_constraint_1, - &asn_PER_memb_sessionId_constr_2, + &ASN_PER_MEMB_SESSION_ID_CONSTR_2, 0, "sessionId" }, diff --git a/src/core/libs/supl/asn-supl/SlpSessionID.c b/src/core/libs/supl/asn-supl/SlpSessionID.c index 173724cd6..aed350daa 100644 --- a/src/core/libs/supl/asn-supl/SlpSessionID.c +++ b/src/core/libs/supl/asn-supl/SlpSessionID.c @@ -8,93 +8,92 @@ static int memb_sessionID_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - size = st->size; - - if((size == 4)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = st->size; + + if (size == 4) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } -static asn_per_constraints_t asn_PER_memb_sessionID_constr_2 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 4, 4 } /* (SIZE(4..4)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_MEMB_SESSION_ID_CONSTR_2 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 4, 4} /* (SIZE(4..4)) */, + 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_SlpSessionID_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct SlpSessionID, sessionID), - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), - -1, /* IMPLICIT tag at current level */ - &asn_DEF_OCTET_STRING, - memb_sessionID_constraint_1, - &asn_PER_memb_sessionID_constr_2, - 0, - "sessionID" - }, - { ATF_NOFLAGS, 0, offsetof(struct SlpSessionID, slpId), - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), - +1, /* EXPLICIT tag at current level */ - &asn_DEF_SLPAddress, - 0, /* Defer constraints checking to the member type */ - 0, /* No PER visible constraints */ - 0, - "slpId" - }, + {ATF_NOFLAGS, 0, offsetof(struct SlpSessionID, sessionID), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_OCTET_STRING, + memb_sessionID_constraint_1, + &ASN_PER_MEMB_SESSION_ID_CONSTR_2, + 0, + "sessionID"}, + {ATF_NOFLAGS, 0, offsetof(struct SlpSessionID, slpId), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + +1, /* EXPLICIT tag at current level */ + &asn_DEF_SLPAddress, + 0, /* Defer constraints checking to the member type */ + 0, /* No PER visible constraints */ + 0, + "slpId"}, }; static ber_tlv_tag_t asn_DEF_SlpSessionID_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))}; static asn_TYPE_tag2member_t asn_MAP_SlpSessionID_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* sessionID at 37 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* slpId at 38 */ + {(ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0}, /* sessionID at 37 */ + {(ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0} /* slpId at 38 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SlpSessionID_specs_1 = { - sizeof(struct SlpSessionID), - offsetof(struct SlpSessionID, _asn_ctx), - asn_MAP_SlpSessionID_tag2el_1, - 2, /* Count of tags in the map */ - 0, 0, 0, /* Optional elements (not needed) */ - -1, /* Start extensions */ - -1 /* Stop extensions */ + sizeof(struct SlpSessionID), + offsetof(struct SlpSessionID, _asn_ctx), + asn_MAP_SlpSessionID_tag2el_1, + 2, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SlpSessionID = { - "SlpSessionID", - "SlpSessionID", - SEQUENCE_free, - SEQUENCE_print, - SEQUENCE_constraint, - SEQUENCE_decode_ber, - SEQUENCE_encode_der, - SEQUENCE_decode_xer, - SEQUENCE_encode_xer, - SEQUENCE_decode_uper, - SEQUENCE_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_SlpSessionID_tags_1, - sizeof(asn_DEF_SlpSessionID_tags_1) - /sizeof(asn_DEF_SlpSessionID_tags_1[0]), /* 1 */ - asn_DEF_SlpSessionID_tags_1, /* Same as above */ - sizeof(asn_DEF_SlpSessionID_tags_1) - /sizeof(asn_DEF_SlpSessionID_tags_1[0]), /* 1 */ - 0, /* No PER visible constraints */ - asn_MBR_SlpSessionID_1, - 2, /* Elements count */ - &asn_SPC_SlpSessionID_specs_1 /* Additional specs */ + "SlpSessionID", + "SlpSessionID", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_SlpSessionID_tags_1, + sizeof(asn_DEF_SlpSessionID_tags_1) / sizeof(asn_DEF_SlpSessionID_tags_1[0]), /* 1 */ + asn_DEF_SlpSessionID_tags_1, /* Same as above */ + sizeof(asn_DEF_SlpSessionID_tags_1) / sizeof(asn_DEF_SlpSessionID_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_SlpSessionID_1, + 2, /* Elements count */ + &asn_SPC_SlpSessionID_specs_1 /* Additional specs */ }; - diff --git a/src/core/libs/supl/asn-supl/Status.c b/src/core/libs/supl/asn-supl/Status.c index 5637fd918..acb84c342 100644 --- a/src/core/libs/supl/asn-supl/Status.c +++ b/src/core/libs/supl/asn-supl/Status.c @@ -94,7 +94,7 @@ Status_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_Status_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_STATUS_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -142,7 +142,7 @@ asn_TYPE_descriptor_t asn_DEF_Status = { asn_DEF_Status_tags_1, /* Same as above */ sizeof(asn_DEF_Status_tags_1) /sizeof(asn_DEF_Status_tags_1[0]), /* 1 */ - &asn_PER_type_Status_constr_1, + &ASN_PER_TYPE_STATUS_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_Status_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/StatusCode.c b/src/core/libs/supl/asn-supl/StatusCode.c index 3edb52a21..e4828f47f 100644 --- a/src/core/libs/supl/asn-supl/StatusCode.c +++ b/src/core/libs/supl/asn-supl/StatusCode.c @@ -94,7 +94,7 @@ StatusCode_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_StatusCode_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_STATUS_CODE_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 5, 5, 0, 19 } /* (0..19,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -176,7 +176,7 @@ asn_TYPE_descriptor_t asn_DEF_StatusCode = { asn_DEF_StatusCode_tags_1, /* Same as above */ sizeof(asn_DEF_StatusCode_tags_1) /sizeof(asn_DEF_StatusCode_tags_1[0]), /* 1 */ - &asn_PER_type_StatusCode_constr_1, + &ASN_PER_TYPE_STATUS_CODE_CONSTR_1, 0, 0, /* Defined elsewhere */ &asn_SPC_StatusCode_specs_1 /* Additional specs */ }; diff --git a/src/core/libs/supl/asn-supl/TGSN.c b/src/core/libs/supl/asn-supl/TGSN.c index 2da645c36..36f840d4e 100644 --- a/src/core/libs/supl/asn-supl/TGSN.c +++ b/src/core/libs/supl/asn-supl/TGSN.c @@ -111,7 +111,7 @@ TGSN_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TGSN_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_TGSN_CONSTR_1 = { { APC_CONSTRAINED, 4, 4, 0, 14 } /* (0..14) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TGSN = { asn_DEF_TGSN_tags_1, /* Same as above */ sizeof(asn_DEF_TGSN_tags_1) /sizeof(asn_DEF_TGSN_tags_1[0]), /* 1 */ - &asn_PER_type_TGSN_constr_1, + &ASN_PER_TYPE_TGSN_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/TimeslotISCP-List.c b/src/core/libs/supl/asn-supl/TimeslotISCP-List.c index cd5e6bd0f..02831de49 100644 --- a/src/core/libs/supl/asn-supl/TimeslotISCP-List.c +++ b/src/core/libs/supl/asn-supl/TimeslotISCP-List.c @@ -6,7 +6,7 @@ #include "TimeslotISCP-List.h" -static asn_per_constraints_t asn_PER_type_TimeslotISCP_List_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_TIMESLOT_ISCP_LIST_CONSTR_1 = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 4, 4, 1, 14 } /* (SIZE(1..14)) */, 0, 0 /* No PER value map */ @@ -49,7 +49,7 @@ asn_TYPE_descriptor_t asn_DEF_TimeslotISCP_List = { asn_DEF_TimeslotISCP_List_tags_1, /* Same as above */ sizeof(asn_DEF_TimeslotISCP_List_tags_1) /sizeof(asn_DEF_TimeslotISCP_List_tags_1[0]), /* 1 */ - &asn_PER_type_TimeslotISCP_List_constr_1, + &ASN_PER_TYPE_TIMESLOT_ISCP_LIST_CONSTR_1, asn_MBR_TimeslotISCP_List_1, 1, /* Single element */ &asn_SPC_TimeslotISCP_List_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/TimeslotISCP.c b/src/core/libs/supl/asn-supl/TimeslotISCP.c index d0a155752..411f73f71 100644 --- a/src/core/libs/supl/asn-supl/TimeslotISCP.c +++ b/src/core/libs/supl/asn-supl/TimeslotISCP.c @@ -111,7 +111,7 @@ TimeslotISCP_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_TimeslotISCP_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_TIMESLOT_ISCP_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_TimeslotISCP = { asn_DEF_TimeslotISCP_tags_1, /* Same as above */ sizeof(asn_DEF_TimeslotISCP_tags_1) /sizeof(asn_DEF_TimeslotISCP_tags_1[0]), /* 1 */ - &asn_PER_type_TimeslotISCP_constr_1, + &ASN_PER_TYPE_TIMESLOT_ISCP_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/UARFCN.c b/src/core/libs/supl/asn-supl/UARFCN.c index 5a703b7ce..96bd38dbd 100644 --- a/src/core/libs/supl/asn-supl/UARFCN.c +++ b/src/core/libs/supl/asn-supl/UARFCN.c @@ -111,7 +111,7 @@ UARFCN_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_UARFCN_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_UARFCN_CONSTR_1 = { { APC_CONSTRAINED, 14, 14, 0, 16383 } /* (0..16383) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_UARFCN = { asn_DEF_UARFCN_tags_1, /* Same as above */ sizeof(asn_DEF_UARFCN_tags_1) /sizeof(asn_DEF_UARFCN_tags_1[0]), /* 1 */ - &asn_PER_type_UARFCN_constr_1, + &ASN_PER_TYPE_UARFCN_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/ULP-PDU.c b/src/core/libs/supl/asn-supl/ULP-PDU.c index 75ac7fab2..a96fee787 100644 --- a/src/core/libs/supl/asn-supl/ULP-PDU.c +++ b/src/core/libs/supl/asn-supl/ULP-PDU.c @@ -31,7 +31,7 @@ memb_length_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_length_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_LENGTH_CONSTR_2 = { { APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -42,7 +42,7 @@ static asn_TYPE_member_t asn_MBR_ULP_PDU_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_length_constraint_1, - &asn_PER_memb_length_constr_2, + &ASN_PER_MEMB_LENGTH_CONSTR_2, 0, "length" }, diff --git a/src/core/libs/supl/asn-supl/UTCTime.c b/src/core/libs/supl/asn-supl/UTCTime.c index 0abe1db74..a3d73e337 100644 --- a/src/core/libs/supl/asn-supl/UTCTime.c +++ b/src/core/libs/supl/asn-supl/UTCTime.c @@ -23,7 +23,7 @@ static ber_tlv_tag_t asn_DEF_UTCTime_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -static asn_per_constraints_t asn_DEF_UTCTime_constraints = { +static asn_per_constraints_t ASN_DEF_UTC_TIME_CONSTRAINTS = { { APC_CONSTRAINED, 7, 7, 0x20, 0x7e }, /* Value */ { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 @@ -47,7 +47,7 @@ asn_TYPE_descriptor_t asn_DEF_UTCTime = { asn_DEF_UTCTime_tags, sizeof(asn_DEF_UTCTime_tags) / sizeof(asn_DEF_UTCTime_tags[0]), - &asn_DEF_UTCTime_constraints, + &ASN_DEF_UTC_TIME_CONSTRAINTS, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/UTCTime.h b/src/core/libs/supl/asn-supl/UTCTime.h index 53517fde6..c8e73785c 100644 --- a/src/core/libs/supl/asn-supl/UTCTime.h +++ b/src/core/libs/supl/asn-supl/UTCTime.h @@ -27,10 +27,10 @@ extern "C" struct tm; /* */ /* See asn_GT2time() in GeneralizedTime.h */ - time_t asn_UT2time(const UTCTime_t *, struct tm *_optional_tm4fill, int as_gmt); + time_t asn_UT2time(const UTCTime_t * /*st*/, struct tm *_tm, int as_gmt); /* See asn_time2GT() in GeneralizedTime.h */ - UTCTime_t *asn_time2UT(UTCTime_t *__opt_ut, const struct tm *, int force_gmt); + UTCTime_t *asn_time2UT(UTCTime_t *__opt_ut, const struct tm * /*tm*/, int force_gmt); #ifdef __cplusplus } diff --git a/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c b/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c index 77b24d619..9c735eee3 100644 --- a/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c +++ b/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c @@ -111,7 +111,7 @@ UTRA_CarrierRSSI_encode_uper(asn_TYPE_descriptor_t *td, return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_UTRA_CarrierRSSI_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_UTRA_CARRIER_RSSI_CONSTR_1 = { { APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -138,7 +138,7 @@ asn_TYPE_descriptor_t asn_DEF_UTRA_CarrierRSSI = { asn_DEF_UTRA_CarrierRSSI_tags_1, /* Same as above */ sizeof(asn_DEF_UTRA_CarrierRSSI_tags_1) /sizeof(asn_DEF_UTRA_CarrierRSSI_tags_1[0]), /* 1 */ - &asn_PER_type_UTRA_CarrierRSSI_constr_1, + &ASN_PER_TYPE_UTRA_CARRIER_RSSI_CONSTR_1, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/UlpMessage.c b/src/core/libs/supl/asn-supl/UlpMessage.c index d27e05d04..8953cf17a 100644 --- a/src/core/libs/supl/asn-supl/UlpMessage.c +++ b/src/core/libs/supl/asn-supl/UlpMessage.c @@ -6,7 +6,7 @@ #include "UlpMessage.h" -static asn_per_constraints_t asn_PER_type_UlpMessage_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_ULP_MESSAGE_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 7 } /* (0..7,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -122,7 +122,7 @@ asn_TYPE_descriptor_t asn_DEF_UlpMessage = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_UlpMessage_constr_1, + &ASN_PER_TYPE_ULP_MESSAGE_CONSTR_1, asn_MBR_UlpMessage_1, 8, /* Elements count */ &asn_SPC_UlpMessage_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/Velocity.c b/src/core/libs/supl/asn-supl/Velocity.c index 67e4e4c66..59d08fb55 100644 --- a/src/core/libs/supl/asn-supl/Velocity.c +++ b/src/core/libs/supl/asn-supl/Velocity.c @@ -6,7 +6,7 @@ #include "Velocity.h" -static asn_per_constraints_t asn_PER_type_Velocity_constr_1 = { +static asn_per_constraints_t ASN_PER_TYPE_VELOCITY_CONSTR_1 = { { APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 3 } /* (0..3,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -82,7 +82,7 @@ asn_TYPE_descriptor_t asn_DEF_Velocity = { 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ - &asn_PER_type_Velocity_constr_1, + &ASN_PER_TYPE_VELOCITY_CONSTR_1, asn_MBR_Velocity_1, 4, /* Elements count */ &asn_SPC_Velocity_specs_1 /* Additional specs */ diff --git a/src/core/libs/supl/asn-supl/Ver.c b/src/core/libs/supl/asn-supl/Ver.c index 664fb9517..13a139987 100644 --- a/src/core/libs/supl/asn-supl/Ver.c +++ b/src/core/libs/supl/asn-supl/Ver.c @@ -6,35 +6,42 @@ #include "Ver.h" -int -Ver_constraint(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; - size_t size; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - if(st->size > 0) { - /* Size in bits */ - size = 8 * st->size - (st->bits_unused & 0x07); - } else { - size = 0; - } - - if((size == 64)) { - /* Constraint check succeeded */ - return 0; - } else { - _ASN_CTFAIL(app_key, td, sptr, - "%s: constraint failed (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } +int Ver_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) +{ + const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; + size_t size; + + if (!sptr) + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if (st->size > 0) + { + /* Size in bits */ + size = 8 * st->size - (st->bits_unused & 0x07); + } + else + { + size = 0; + } + + if (size == 64) + { + /* Constraint check succeeded */ + return 0; + } + else + { + _ASN_CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } } /* @@ -42,110 +49,113 @@ Ver_constraint(asn_TYPE_descriptor_t *td, const void *sptr, * so here we adjust the DEF accordingly. */ static void -Ver_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { - td->free_struct = asn_DEF_BIT_STRING.free_struct; - td->print_struct = asn_DEF_BIT_STRING.print_struct; - td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; - td->der_encoder = asn_DEF_BIT_STRING.der_encoder; - td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; - td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; - td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; - td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; - if(!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; - td->elements = asn_DEF_BIT_STRING.elements; - td->elements_count = asn_DEF_BIT_STRING.elements_count; - td->specifics = asn_DEF_BIT_STRING.specifics; +Ver_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) +{ + td->free_struct = asn_DEF_BIT_STRING.free_struct; + td->print_struct = asn_DEF_BIT_STRING.print_struct; + td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; + td->der_encoder = asn_DEF_BIT_STRING.der_encoder; + td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; + td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; + td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; + td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; + if (!td->per_constraints) + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + td->elements = asn_DEF_BIT_STRING.elements; + td->elements_count = asn_DEF_BIT_STRING.elements_count; + td->specifics = asn_DEF_BIT_STRING.specifics; } -void -Ver_free(asn_TYPE_descriptor_t *td, - void *struct_ptr, int contents_only) { - Ver_1_inherit_TYPE_descriptor(td); - td->free_struct(td, struct_ptr, contents_only); +void Ver_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) +{ + Ver_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); } -int -Ver_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, - int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { - Ver_1_inherit_TYPE_descriptor(td); - return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +int Ver_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) +{ + Ver_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t Ver_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const void *bufptr, size_t size, int tag_mode) { - Ver_1_inherit_TYPE_descriptor(td); - return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); + void **structure, const void *bufptr, size_t size, int tag_mode) +{ + Ver_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t Ver_encode_der(asn_TYPE_descriptor_t *td, - void *structure, int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - Ver_1_inherit_TYPE_descriptor(td); - return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) +{ + Ver_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t Ver_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **structure, const char *opt_mname, const void *bufptr, size_t size) { - Ver_1_inherit_TYPE_descriptor(td); - return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); + void **structure, const char *opt_mname, const void *bufptr, size_t size) +{ + Ver_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t Ver_encode_xer(asn_TYPE_descriptor_t *td, void *structure, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - Ver_1_inherit_TYPE_descriptor(td); - return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) +{ + Ver_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } asn_dec_rval_t Ver_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) { - Ver_1_inherit_TYPE_descriptor(td); - return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); + asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) +{ + Ver_1_inherit_TYPE_descriptor(td); + return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data); } asn_enc_rval_t Ver_encode_uper(asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, - void *structure, asn_per_outp_t *per_out) { - Ver_1_inherit_TYPE_descriptor(td); - return td->uper_encoder(td, constraints, structure, per_out); + asn_per_constraints_t *constraints, + void *structure, asn_per_outp_t *per_out) +{ + Ver_1_inherit_TYPE_descriptor(td); + return td->uper_encoder(td, constraints, structure, per_out); } -static asn_per_constraints_t asn_PER_type_Ver_constr_1 = { - { APC_UNCONSTRAINED, -1, -1, 0, 0 }, - { APC_CONSTRAINED, 0, 0, 64, 64 } /* (SIZE(64..64)) */, - 0, 0 /* No PER value map */ +static asn_per_constraints_t ASN_PER_TYPE_VER_CONSTR_1 = { + {APC_UNCONSTRAINED, -1, -1, 0, 0}, + {APC_CONSTRAINED, 0, 0, 64, 64} /* (SIZE(64..64)) */, + 0, 0 /* No PER value map */ }; static ber_tlv_tag_t asn_DEF_Ver_tags_1[] = { - (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) -}; + (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))}; asn_TYPE_descriptor_t asn_DEF_Ver = { - "Ver", - "Ver", - Ver_free, - Ver_print, - Ver_constraint, - Ver_decode_ber, - Ver_encode_der, - Ver_decode_xer, - Ver_encode_xer, - Ver_decode_uper, - Ver_encode_uper, - 0, /* Use generic outmost tag fetcher */ - asn_DEF_Ver_tags_1, - sizeof(asn_DEF_Ver_tags_1) - /sizeof(asn_DEF_Ver_tags_1[0]), /* 1 */ - asn_DEF_Ver_tags_1, /* Same as above */ - sizeof(asn_DEF_Ver_tags_1) - /sizeof(asn_DEF_Ver_tags_1[0]), /* 1 */ - &asn_PER_type_Ver_constr_1, - 0, 0, /* No members */ - 0 /* No specifics */ + "Ver", + "Ver", + Ver_free, + Ver_print, + Ver_constraint, + Ver_decode_ber, + Ver_encode_der, + Ver_decode_xer, + Ver_encode_xer, + Ver_decode_uper, + Ver_encode_uper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Ver_tags_1, + sizeof(asn_DEF_Ver_tags_1) / sizeof(asn_DEF_Ver_tags_1[0]), /* 1 */ + asn_DEF_Ver_tags_1, /* Same as above */ + sizeof(asn_DEF_Ver_tags_1) / sizeof(asn_DEF_Ver_tags_1[0]), /* 1 */ + &ASN_PER_TYPE_VER_CONSTR_1, + 0, 0, /* No members */ + 0 /* No specifics */ }; - diff --git a/src/core/libs/supl/asn-supl/Version.c b/src/core/libs/supl/asn-supl/Version.c index 3f5d9b753..ebde033d9 100644 --- a/src/core/libs/supl/asn-supl/Version.c +++ b/src/core/libs/supl/asn-supl/Version.c @@ -81,17 +81,17 @@ memb_servind_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_maj_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_MAJ_CONSTR_2 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_min_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_MIN_CONSTR_3 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_servind_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_SERVIND_CONSTR_4 = { { APC_CONSTRAINED, 8, 8, 0, 255 } /* (0..255) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -102,7 +102,7 @@ static asn_TYPE_member_t asn_MBR_Version_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_maj_constraint_1, - &asn_PER_memb_maj_constr_2, + &ASN_PER_MEMB_MAJ_CONSTR_2, 0, "maj" }, @@ -111,7 +111,7 @@ static asn_TYPE_member_t asn_MBR_Version_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_min_constraint_1, - &asn_PER_memb_min_constr_3, + &ASN_PER_MEMB_MIN_CONSTR_3, 0, "min" }, @@ -120,7 +120,7 @@ static asn_TYPE_member_t asn_MBR_Version_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_servind_constraint_1, - &asn_PER_memb_servind_constr_4, + &ASN_PER_MEMB_SERVIND_CONSTR_4, 0, "servind" }, diff --git a/src/core/libs/supl/asn-supl/VisibleString.c b/src/core/libs/supl/asn-supl/VisibleString.c index 3487b6f93..8ef827f35 100644 --- a/src/core/libs/supl/asn-supl/VisibleString.c +++ b/src/core/libs/supl/asn-supl/VisibleString.c @@ -12,7 +12,7 @@ static ber_tlv_tag_t asn_DEF_VisibleString_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -static asn_per_constraints_t asn_DEF_VisibleString_constraints = { +static asn_per_constraints_t ASN_DEF_VISIBLE_STRING_CONSTRAINTS = { { APC_CONSTRAINED, 7, 7, 0x20, 0x7e }, /* Value */ { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 @@ -36,7 +36,7 @@ asn_TYPE_descriptor_t asn_DEF_VisibleString = { asn_DEF_VisibleString_tags, sizeof(asn_DEF_VisibleString_tags) / sizeof(asn_DEF_VisibleString_tags[0]), - &asn_DEF_VisibleString_constraints, + &ASN_DEF_VISIBLE_STRING_CONSTRAINTS, 0, 0, /* No members */ 0 /* No specifics */ }; diff --git a/src/core/libs/supl/asn-supl/WcdmaCellInformation.c b/src/core/libs/supl/asn-supl/WcdmaCellInformation.c index d4561099c..bc5b17d0f 100644 --- a/src/core/libs/supl/asn-supl/WcdmaCellInformation.c +++ b/src/core/libs/supl/asn-supl/WcdmaCellInformation.c @@ -106,22 +106,22 @@ memb_primaryScramblingCode_constraint_1(asn_TYPE_descriptor_t *td, const void *s } } -static asn_per_constraints_t asn_PER_memb_refMCC_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_MCC_CONSTR_2 = { { APC_CONSTRAINED, 10, 10, 0, 999 } /* (0..999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refMNC_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_MNC_CONSTR_3 = { { APC_CONSTRAINED, 10, 10, 0, 999 } /* (0..999) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_refUC_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_REF_UC_CONSTR_4 = { { APC_CONSTRAINED, 28, -1, 0, 268435455 } /* (0..268435455) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_primaryScramblingCode_constr_6 = { +static asn_per_constraints_t ASN_PER_MEMB_PRIMARY_SCRAMBLING_CODE_CONSTR_6 = { { APC_CONSTRAINED, 9, 9, 0, 511 } /* (0..511) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -132,7 +132,7 @@ static asn_TYPE_member_t asn_MBR_WcdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refMCC_constraint_1, - &asn_PER_memb_refMCC_constr_2, + &ASN_PER_MEMB_REF_MCC_CONSTR_2, 0, "refMCC" }, @@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_WcdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refMNC_constraint_1, - &asn_PER_memb_refMNC_constr_3, + &ASN_PER_MEMB_REF_MNC_CONSTR_3, 0, "refMNC" }, @@ -150,7 +150,7 @@ static asn_TYPE_member_t asn_MBR_WcdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_refUC_constraint_1, - &asn_PER_memb_refUC_constr_4, + &ASN_PER_MEMB_REF_UC_CONSTR_4, 0, "refUC" }, @@ -168,7 +168,7 @@ static asn_TYPE_member_t asn_MBR_WcdmaCellInformation_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_primaryScramblingCode_constraint_1, - &asn_PER_memb_primaryScramblingCode_constr_6, + &ASN_PER_MEMB_PRIMARY_SCRAMBLING_CODE_CONSTR_6, 0, "primaryScramblingCode" }, diff --git a/src/core/libs/supl/asn-supl/XNavigationModel.c b/src/core/libs/supl/asn-supl/XNavigationModel.c index 4440f2557..9af4d5b13 100644 --- a/src/core/libs/supl/asn-supl/XNavigationModel.c +++ b/src/core/libs/supl/asn-supl/XNavigationModel.c @@ -106,22 +106,22 @@ memb_toeLimit_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } } -static asn_per_constraints_t asn_PER_memb_gpsWeek_constr_2 = { +static asn_per_constraints_t ASN_PER_MEMB_GPS_WEEK_CONSTR_2 = { { APC_CONSTRAINED, 10, 10, 0, 1023 } /* (0..1023) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_gpsToe_constr_3 = { +static asn_per_constraints_t ASN_PER_MEMB_GPS_TOE_CONSTR_3 = { { APC_CONSTRAINED, 8, 8, 0, 167 } /* (0..167) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_nSAT_constr_4 = { +static asn_per_constraints_t ASN_PER_MEMB_N_SAT_CONSTR_4 = { { APC_CONSTRAINED, 5, 5, 0, 31 } /* (0..31) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; -static asn_per_constraints_t asn_PER_memb_toeLimit_constr_5 = { +static asn_per_constraints_t ASN_PER_MEMB_TOE_LIMIT_CONSTR_5 = { { APC_CONSTRAINED, 4, 4, 0, 10 } /* (0..10) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ @@ -132,7 +132,7 @@ static asn_TYPE_member_t asn_MBR_XNavigationModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_gpsWeek_constraint_1, - &asn_PER_memb_gpsWeek_constr_2, + &ASN_PER_MEMB_GPS_WEEK_CONSTR_2, 0, "gpsWeek" }, @@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_XNavigationModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_gpsToe_constraint_1, - &asn_PER_memb_gpsToe_constr_3, + &ASN_PER_MEMB_GPS_TOE_CONSTR_3, 0, "gpsToe" }, @@ -150,7 +150,7 @@ static asn_TYPE_member_t asn_MBR_XNavigationModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_nSAT_constraint_1, - &asn_PER_memb_nSAT_constr_4, + &ASN_PER_MEMB_N_SAT_CONSTR_4, 0, "nSAT" }, @@ -159,7 +159,7 @@ static asn_TYPE_member_t asn_MBR_XNavigationModel_1[] = { -1, /* IMPLICIT tag at current level */ &asn_DEF_NativeInteger, memb_toeLimit_constraint_1, - &asn_PER_memb_toeLimit_constr_5, + &ASN_PER_MEMB_TOE_LIMIT_CONSTR_5, 0, "toeLimit" }, diff --git a/src/core/libs/supl/asn-supl/asn_codecs_prim.h b/src/core/libs/supl/asn-supl/asn_codecs_prim.h index cb8c37937..6ebaefb87 100644 --- a/src/core/libs/supl/asn-supl/asn_codecs_prim.h +++ b/src/core/libs/supl/asn-supl/asn_codecs_prim.h @@ -41,8 +41,8 @@ extern "C" * Also see xer_decode_general() in xer_decoder.h */ asn_dec_rval_t xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *type_descriptor, - void **struct_ptr, size_t struct_size, + asn_TYPE_descriptor_t *td, + void **sptr, size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size, xer_primitive_body_decoder_f *prim_body_decoder); diff --git a/src/core/libs/supl/asn-supl/ber_decoder.c b/src/core/libs/supl/asn-supl/ber_decoder.c index 601f66c0b..77cb8032e 100644 --- a/src/core/libs/supl/asn-supl/ber_decoder.c +++ b/src/core/libs/supl/asn-supl/ber_decoder.c @@ -16,7 +16,7 @@ asn_dec_rval_t rval; \ rval.code = _code; \ if(opt_ctx) opt_ctx->step = step; /* Save context */ \ - if(_code == RC_OK || opt_ctx) \ + if((_code) == RC_OK || opt_ctx) \ rval.consumed = consumed_myself; \ else \ rval.consumed = 0; /* Context-free */ \ diff --git a/src/core/libs/supl/asn-supl/ber_decoder.h b/src/core/libs/supl/asn-supl/ber_decoder.h index 6a87fc23f..629aff043 100644 --- a/src/core/libs/supl/asn-supl/ber_decoder.h +++ b/src/core/libs/supl/asn-supl/ber_decoder.h @@ -23,7 +23,7 @@ extern "C" asn_dec_rval_t ber_decode(struct asn_codec_ctx_s *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr, /* Pointer to a target structure's pointer */ - const void *buffer, /* Data to be decoded */ + const void *ptr, /* Data to be decoded */ size_t size /* Size of that buffer */ ); @@ -49,7 +49,7 @@ extern "C" */ asn_dec_rval_t ber_check_tags( struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */ - struct asn_TYPE_descriptor_s *type_descriptor, + struct asn_TYPE_descriptor_s *td, asn_struct_ctx_t *opt_ctx, /* saved decoding context */ const void *ptr, size_t size, int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ diff --git a/src/core/libs/supl/asn-supl/ber_tlv_tag.h b/src/core/libs/supl/asn-supl/ber_tlv_tag.h index 31b634345..fa4c7321c 100644 --- a/src/core/libs/supl/asn-supl/ber_tlv_tag.h +++ b/src/core/libs/supl/asn-supl/ber_tlv_tag.h @@ -33,8 +33,8 @@ extern "C" * (i.e. "[PRIVATE 0]"). * Return values correspond to their libc counterparts (if any). */ - ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t buflen); - ssize_t ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *); + ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t size); + ssize_t ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE * /*f*/); char *ber_tlv_tag_string(ber_tlv_tag_t tag); diff --git a/src/core/libs/supl/asn-supl/constr_CHOICE.c b/src/core/libs/supl/asn-supl/constr_CHOICE.c index a9eb71941..1bf467254 100644 --- a/src/core/libs/supl/asn-supl/constr_CHOICE.c +++ b/src/core/libs/supl/asn-supl/constr_CHOICE.c @@ -46,8 +46,8 @@ */ #undef NEXT_PHASE #define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ + (ctx)->phase++; \ + (ctx)->step = 0; \ } while(0) /* @@ -63,8 +63,8 @@ /* * See the definitions. */ -static int _fetch_present_idx(const void *struct_ptr, int off, int size); -static void _set_present_idx(void *sptr, int offset, int size, int pres); +static int _fetch_present_idx(const void *struct_ptr, int pres_offset, int size); +static void _set_present_idx(void *struct_ptr, int offset, int size, int pres); /* * Tags are canonically sorted in the tag to member table. diff --git a/src/core/libs/supl/asn-supl/constr_SEQUENCE.c b/src/core/libs/supl/asn-supl/constr_SEQUENCE.c index db3c92581..aba19bd26 100644 --- a/src/core/libs/supl/asn-supl/constr_SEQUENCE.c +++ b/src/core/libs/supl/asn-supl/constr_SEQUENCE.c @@ -47,10 +47,10 @@ #undef NEXT_PHASE #undef PHASE_OUT #define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ + (ctx)->phase++; \ + (ctx)->step = 0; \ } while(0) -#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) +#define PHASE_OUT(ctx) do { (ctx)->phase = 10; } while(0) /* * Return a standardized complex structure. diff --git a/src/core/libs/supl/asn-supl/constr_SET_OF.c b/src/core/libs/supl/asn-supl/constr_SET_OF.c index 0bc891abf..8b9c0669a 100644 --- a/src/core/libs/supl/asn-supl/constr_SET_OF.c +++ b/src/core/libs/supl/asn-supl/constr_SET_OF.c @@ -47,10 +47,10 @@ #undef NEXT_PHASE #undef PHASE_OUT #define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ + (ctx)->phase++; \ + (ctx)->step = 0; \ } while(0) -#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) +#define PHASE_OUT(ctx) do { (ctx)->phase = 10; } while(0) /* * Return a standardized complex structure. diff --git a/src/core/libs/supl/asn-supl/der_encoder.h b/src/core/libs/supl/asn-supl/der_encoder.h index 3eafbc281..059e83f70 100644 --- a/src/core/libs/supl/asn-supl/der_encoder.h +++ b/src/core/libs/supl/asn-supl/der_encoder.h @@ -53,7 +53,7 @@ extern "C" * Write out leading TL[v] sequence according to the type definition. */ ssize_t der_write_tags( - struct asn_TYPE_descriptor_s *type_descriptor, + struct asn_TYPE_descriptor_s *sd, size_t struct_length, int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ int last_tag_form, /* {0,!0}: prim, constructed */ diff --git a/src/core/libs/supl/asn-supl/per_decoder.h b/src/core/libs/supl/asn-supl/per_decoder.h index a28509464..4e410c5b2 100644 --- a/src/core/libs/supl/asn-supl/per_decoder.h +++ b/src/core/libs/supl/asn-supl/per_decoder.h @@ -20,8 +20,8 @@ extern "C" * On success, this call always returns (.consumed >= 1), as per X.691#10.1.3. */ asn_dec_rval_t uper_decode_complete(struct asn_codec_ctx_s *opt_codec_ctx, - struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */ - void **struct_ptr, /* Pointer to a target structure's pointer */ + struct asn_TYPE_descriptor_s *td, /* Type to decode */ + void **sptr, /* Pointer to a target structure's pointer */ const void *buffer, /* Data to be decoded */ size_t size /* Size of data buffer */ ); @@ -31,8 +31,8 @@ extern "C" * WARNING: This call returns the number of BITS read from the stream. Beware. */ asn_dec_rval_t uper_decode(struct asn_codec_ctx_s *opt_codec_ctx, - struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */ - void **struct_ptr, /* Pointer to a target structure's pointer */ + struct asn_TYPE_descriptor_s *td, /* Type to decode */ + void **sptr, /* Pointer to a target structure's pointer */ const void *buffer, /* Data to be decoded */ size_t size, /* Size of data buffer */ int skip_bits, /* Number of unused leading bits, 0..7 */ diff --git a/src/core/libs/supl/asn-supl/per_encoder.c b/src/core/libs/supl/asn-supl/per_encoder.c index f4bace060..8cf95347d 100644 --- a/src/core/libs/supl/asn-supl/per_encoder.c +++ b/src/core/libs/supl/asn-supl/per_encoder.c @@ -2,7 +2,7 @@ #include #include -static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); +static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t * /*constraints*/, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); asn_enc_rval_t uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) { diff --git a/src/core/libs/supl/asn-supl/per_encoder.h b/src/core/libs/supl/asn-supl/per_encoder.h index 896013095..3f931769d 100644 --- a/src/core/libs/supl/asn-supl/per_encoder.h +++ b/src/core/libs/supl/asn-supl/per_encoder.h @@ -21,8 +21,8 @@ extern "C" * field of the return value. Use the following formula to convert to bytes: * bytes = ((.encoded + 7) / 8) */ - asn_enc_rval_t uper_encode(struct asn_TYPE_descriptor_s *type_descriptor, - void *struct_ptr, /* Structure to be encoded */ + asn_enc_rval_t uper_encode(struct asn_TYPE_descriptor_s *td, + void *sptr, /* Structure to be encoded */ asn_app_consume_bytes_f *consume_bytes_cb, /* Data collector */ void *app_key /* Arbitrary callback argument */ ); @@ -33,8 +33,8 @@ extern "C" * field of the return value. */ asn_enc_rval_t uper_encode_to_buffer( - struct asn_TYPE_descriptor_s *type_descriptor, - void *struct_ptr, /* Structure to be encoded */ + struct asn_TYPE_descriptor_s *td, + void *sptr, /* Structure to be encoded */ void *buffer, /* Pre-allocated buffer */ size_t buffer_size /* Initial buffer size (max) */ ); @@ -47,9 +47,9 @@ extern "C" * encoding of uper_encode() and uper_encode_to_buffer(). */ ssize_t uper_encode_to_new_buffer( - struct asn_TYPE_descriptor_s *type_descriptor, + struct asn_TYPE_descriptor_s *td, asn_per_constraints_t *constraints, - void *struct_ptr, /* Structure to be encoded */ + void *sptr, /* Structure to be encoded */ void **buffer_r /* Buffer allocated and returned */ ); diff --git a/src/core/libs/supl/asn-supl/per_opentype.c b/src/core/libs/supl/asn-supl/per_opentype.c index c749c8c6c..32152e132 100644 --- a/src/core/libs/supl/asn-supl/per_opentype.c +++ b/src/core/libs/supl/asn-supl/per_opentype.c @@ -7,16 +7,17 @@ #include #include -typedef struct uper_ugot_key { - asn_per_data_t oldpd; /* Old per data source */ - size_t unclaimed; - size_t ot_moved; /* Number of bits moved by OT processing */ - int repeat; +typedef struct uper_ugot_key +{ + asn_per_data_t oldpd; /* Old per data source */ + size_t unclaimed; + size_t ot_moved; /* Number of bits moved by OT processing */ + int repeat; } uper_ugot_key; static int uper_ugot_refill(asn_per_data_t *pd); static int per_skip_bits(asn_per_data_t *pd, int skip_nbits); -static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); +static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t * /*ctx*/, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); int asn_debug_indent; @@ -24,243 +25,272 @@ int asn_debug_indent; * Encode an "open type field". * #10.1, #10.2 */ -int -uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - void *buf; - void *bptr; - ssize_t size; - size_t toGo; +int uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) +{ + void *buf; + void *bptr; + ssize_t size; + size_t toGo; - ASN_DEBUG("Open type put %s ...", td->name); + ASN_DEBUG("Open type put %s ...", td->name); - size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); - if(size <= 0) return -1; + size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); + if (size <= 0) return -1; - for(bptr = buf, toGo = size; toGo;) { - ssize_t maySave = uper_put_length(po, toGo); - if(maySave < 0) break; - if(per_put_many_bits(po, bptr, maySave * 8)) break; - bptr = (char *)bptr + maySave; - toGo -= maySave; - } + for (bptr = buf, toGo = size; toGo;) + { + ssize_t maySave = uper_put_length(po, toGo); + if (maySave < 0) break; + if (per_put_many_bits(po, bptr, maySave * 8)) break; + bptr = (char *)bptr + maySave; + toGo -= maySave; + } - FREEMEM(buf); - if(toGo) return -1; + FREEMEM(buf); + if (toGo) return -1; - ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", - td->name, size); + ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", + td->name, size); - return 0; + return 0; } static asn_dec_rval_t uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; - ssize_t chunk_bytes; - int repeat; - uint8_t *buf = 0; - size_t bufLen = 0; - size_t bufSize = 0; - asn_per_data_t spd; - size_t padding; + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + asn_dec_rval_t rv; + ssize_t chunk_bytes; + int repeat; + uint8_t *buf = 0; + size_t bufLen = 0; + size_t bufSize = 0; + asn_per_data_t spd; + size_t padding; - _ASN_STACK_OVERFLOW_CHECK(ctx); + _ASN_STACK_OVERFLOW_CHECK(ctx); - ASN_DEBUG("Getting open type %s...", td->name); + ASN_DEBUG("Getting open type %s...", td->name); - do { - chunk_bytes = uper_get_length(pd, -1, &repeat); - if(chunk_bytes < 0) { - FREEMEM(buf); - _ASN_DECODE_STARVED; - } - if(bufLen + chunk_bytes > bufSize) { - void *ptr; - bufSize = chunk_bytes + (bufSize << 2); - ptr = REALLOC(buf, bufSize); - if(!ptr) { - FREEMEM(buf); - _ASN_DECODE_FAILED; - } - buf = ptr; - } - if(per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) { - FREEMEM(buf); - _ASN_DECODE_STARVED; - } - bufLen += chunk_bytes; - } while(repeat); + do + { + chunk_bytes = uper_get_length(pd, -1, &repeat); + if (chunk_bytes < 0) + { + FREEMEM(buf); + _ASN_DECODE_STARVED; + } + if (bufLen + chunk_bytes > bufSize) + { + void *ptr; + bufSize = chunk_bytes + (bufSize << 2); + ptr = REALLOC(buf, bufSize); + if (!ptr) + { + FREEMEM(buf); + _ASN_DECODE_FAILED; + } + buf = ptr; + } + if (per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) + { + FREEMEM(buf); + _ASN_DECODE_STARVED; + } + bufLen += chunk_bytes; + } + while (repeat); - ASN_DEBUG("Getting open type %s encoded in %d bytes", td->name, - bufLen); + ASN_DEBUG("Getting open type %s encoded in %d bytes", td->name, + bufLen); - memset(&spd, 0, sizeof(spd)); - spd.buffer = buf; - spd.nbits = bufLen << 3; + memset(&spd, 0, sizeof(spd)); + spd.buffer = buf; + spd.nbits = bufLen << 3; - asn_debug_indent += 4; - rv = td->uper_decoder(ctx, td, constraints, sptr, &spd); - asn_debug_indent -= 4; + asn_debug_indent += 4; + rv = td->uper_decoder(ctx, td, constraints, sptr, &spd); + asn_debug_indent -= 4; - if(rv.code == RC_OK) { - /* Check padding validity */ - padding = spd.nbits - spd.nboff; - if(padding < 8 && per_get_few_bits(&spd, padding) == 0) { - /* Everything is cool */ - FREEMEM(buf); - return rv; - } - FREEMEM(buf); - if(padding >= 8) { - ASN_DEBUG("Too large padding %d in open type", padding); - _ASN_DECODE_FAILED; - } else { - ASN_DEBUG("Non-zero padding"); - _ASN_DECODE_FAILED; - } - } else { - FREEMEM(buf); - /* rv.code could be RC_WMORE, nonsense in this context */ - rv.code = RC_FAIL; /* Noone would give us more */ - } + if (rv.code == RC_OK) + { + /* Check padding validity */ + padding = spd.nbits - spd.nboff; + if (padding < 8 && per_get_few_bits(&spd, padding) == 0) + { + /* Everything is cool */ + FREEMEM(buf); + return rv; + } + FREEMEM(buf); + if (padding >= 8) + { + ASN_DEBUG("Too large padding %d in open type", padding); + _ASN_DECODE_FAILED; + } + else + { + ASN_DEBUG("Non-zero padding"); + _ASN_DECODE_FAILED; + } + } + else + { + FREEMEM(buf); + /* rv.code could be RC_WMORE, nonsense in this context */ + rv.code = RC_FAIL; /* Noone would give us more */ + } - return rv; + return rv; } static asn_dec_rval_t GCC_NOTUSED uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - uper_ugot_key arg; - asn_dec_rval_t rv; - ssize_t padding; + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + uper_ugot_key arg; + asn_dec_rval_t rv; + ssize_t padding; - _ASN_STACK_OVERFLOW_CHECK(ctx); + _ASN_STACK_OVERFLOW_CHECK(ctx); - ASN_DEBUG("Getting open type %s from %s", td->name, - per_data_string(pd)); - arg.oldpd = *pd; - arg.unclaimed = 0; - arg.ot_moved = 0; - arg.repeat = 1; - pd->refill = uper_ugot_refill; - pd->refill_key = &arg; - pd->nbits = pd->nboff; /* 0 good bits at this point, will refill */ - pd->moved = 0; /* This now counts the open type size in bits */ + ASN_DEBUG("Getting open type %s from %s", td->name, + per_data_string(pd)); + arg.oldpd = *pd; + arg.unclaimed = 0; + arg.ot_moved = 0; + arg.repeat = 1; + pd->refill = uper_ugot_refill; + pd->refill_key = &arg; + pd->nbits = pd->nboff; /* 0 good bits at this point, will refill */ + pd->moved = 0; /* This now counts the open type size in bits */ - asn_debug_indent += 4; - rv = td->uper_decoder(ctx, td, constraints, sptr, pd); - asn_debug_indent -= 4; + asn_debug_indent += 4; + rv = td->uper_decoder(ctx, td, constraints, sptr, pd); + asn_debug_indent -= 4; -#define UPDRESTOREPD do { \ - /* buffer and nboff are valid, preserve them. */ \ - pd->nbits = arg.oldpd.nbits - (pd->moved - arg.ot_moved); \ - pd->moved = arg.oldpd.moved + (pd->moved - arg.ot_moved); \ - pd->refill = arg.oldpd.refill; \ - pd->refill_key = arg.oldpd.refill_key; \ - } while(0) +#define UPDRESTOREPD \ + do \ + { \ + /* buffer and nboff are valid, preserve them. */ \ + pd->nbits = arg.oldpd.nbits - (pd->moved - arg.ot_moved); \ + pd->moved = arg.oldpd.moved + (pd->moved - arg.ot_moved); \ + pd->refill = arg.oldpd.refill; \ + pd->refill_key = arg.oldpd.refill_key; \ + } \ + while (0) - if(rv.code != RC_OK) { - UPDRESTOREPD; - return rv; - } + if (rv.code != RC_OK) + { + UPDRESTOREPD; + return rv; + } - ASN_DEBUG("OpenType %s pd%s old%s unclaimed=%d, repeat=%d" - , td->name, - per_data_string(pd), - per_data_string(&arg.oldpd), - arg.unclaimed, arg.repeat); + ASN_DEBUG("OpenType %s pd%s old%s unclaimed=%d, repeat=%d", td->name, + per_data_string(pd), + per_data_string(&arg.oldpd), + arg.unclaimed, arg.repeat); - padding = pd->moved % 8; - if(padding) { - int32_t pvalue; - if(padding > 7) { - ASN_DEBUG("Too large padding %d in open type", - padding); - rv.code = RC_FAIL; - UPDRESTOREPD; - return rv; - } - padding = 8 - padding; - ASN_DEBUG("Getting padding of %d bits", padding); - pvalue = per_get_few_bits(pd, padding); - switch(pvalue) { - case -1: - ASN_DEBUG("Padding skip failed"); - UPDRESTOREPD; - _ASN_DECODE_STARVED; - case 0: break; - default: - ASN_DEBUG("Non-blank padding (%d bits 0x%02x)", - padding, (int)pvalue); - UPDRESTOREPD; - _ASN_DECODE_FAILED; - } - } - if(pd->nboff != pd->nbits) { - ASN_DEBUG("Open type %s overhead pd%s old%s", td->name, - per_data_string(pd), per_data_string(&arg.oldpd)); - if(1) { - UPDRESTOREPD; - _ASN_DECODE_FAILED; - } else { - arg.unclaimed += pd->nbits - pd->nboff; - } - } + padding = pd->moved % 8; + if (padding) + { + int32_t pvalue; + if (padding > 7) + { + ASN_DEBUG("Too large padding %d in open type", + padding); + rv.code = RC_FAIL; + UPDRESTOREPD; + return rv; + } + padding = 8 - padding; + ASN_DEBUG("Getting padding of %d bits", padding); + pvalue = per_get_few_bits(pd, padding); + switch (pvalue) + { + case -1: + ASN_DEBUG("Padding skip failed"); + UPDRESTOREPD; + _ASN_DECODE_STARVED; + case 0: + break; + default: + ASN_DEBUG("Non-blank padding (%d bits 0x%02x)", + padding, (int)pvalue); + UPDRESTOREPD; + _ASN_DECODE_FAILED; + } + } + if (pd->nboff != pd->nbits) + { + ASN_DEBUG("Open type %s overhead pd%s old%s", td->name, + per_data_string(pd), per_data_string(&arg.oldpd)); + if (1) + { + UPDRESTOREPD; + _ASN_DECODE_FAILED; + } + else + { + arg.unclaimed += pd->nbits - pd->nboff; + } + } - /* Adjust pd back so it points to original data */ - UPDRESTOREPD; + /* Adjust pd back so it points to original data */ + UPDRESTOREPD; - /* Skip data not consumed by the decoder */ - if(arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); - if(arg.unclaimed) { - switch(per_skip_bits(pd, arg.unclaimed)) { - case -1: - ASN_DEBUG("Claim of %d failed", arg.unclaimed); - _ASN_DECODE_STARVED; - case 0: - ASN_DEBUG("Got claim of %d", arg.unclaimed); - break; - default: - /* Padding must be blank */ - ASN_DEBUG("Non-blank unconsumed padding"); - _ASN_DECODE_FAILED; - } - arg.unclaimed = 0; - } + /* Skip data not consumed by the decoder */ + if (arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); + if (arg.unclaimed) + { + switch (per_skip_bits(pd, arg.unclaimed)) + { + case -1: + ASN_DEBUG("Claim of %d failed", arg.unclaimed); + _ASN_DECODE_STARVED; + case 0: + ASN_DEBUG("Got claim of %d", arg.unclaimed); + break; + default: + /* Padding must be blank */ + ASN_DEBUG("Non-blank unconsumed padding"); + _ASN_DECODE_FAILED; + } + arg.unclaimed = 0; + } - if(arg.repeat) { - ASN_DEBUG("Not consumed the whole thing"); - rv.code = RC_FAIL; - return rv; - } + if (arg.repeat) + { + ASN_DEBUG("Not consumed the whole thing"); + rv.code = RC_FAIL; + return rv; + } - return rv; + return rv; } asn_dec_rval_t uper_open_type_get(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - - return uper_open_type_get_simple(ctx, td, constraints, - sptr, pd); - + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + return uper_open_type_get_simple(ctx, td, constraints, + sptr, pd); } -int -uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) { - asn_TYPE_descriptor_t s_td; - asn_dec_rval_t rv; +int uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) +{ + asn_TYPE_descriptor_t s_td; + asn_dec_rval_t rv; - s_td.name = ""; - s_td.uper_decoder = uper_sot_suck; + s_td.name = ""; + s_td.uper_decoder = uper_sot_suck; - rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); - if(rv.code != RC_OK) - return -1; - else - return 0; + rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); + if (rv.code != RC_OK) + return -1; + else + return 0; } /* @@ -269,105 +299,122 @@ uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) { static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) +{ + asn_dec_rval_t rv; - (void)ctx; - (void)td; - (void)constraints; - (void)sptr; + (void)ctx; + (void)td; + (void)constraints; + (void)sptr; - while(per_get_few_bits(pd, 24) >= 0); + while (per_get_few_bits(pd, 24) >= 0) + ; - rv.code = RC_OK; - rv.consumed = pd->moved; + rv.code = RC_OK; + rv.consumed = pd->moved; - return rv; + return rv; } static int -uper_ugot_refill(asn_per_data_t *pd) { - uper_ugot_key *arg = pd->refill_key; - ssize_t next_chunk_bytes, next_chunk_bits; - ssize_t avail; +uper_ugot_refill(asn_per_data_t *pd) +{ + uper_ugot_key *arg = pd->refill_key; + ssize_t next_chunk_bytes, next_chunk_bits; + ssize_t avail; - asn_per_data_t *oldpd = &arg->oldpd; + asn_per_data_t *oldpd = &arg->oldpd; - ASN_DEBUG("REFILLING pd->moved=%d, oldpd->moved=%d", - pd->moved, oldpd->moved); + ASN_DEBUG("REFILLING pd->moved=%d, oldpd->moved=%d", + pd->moved, oldpd->moved); - /* Advance our position to where pd is */ - oldpd->buffer = pd->buffer; - oldpd->nboff = pd->nboff; - oldpd->nbits -= pd->moved - arg->ot_moved; - oldpd->moved += pd->moved - arg->ot_moved; - arg->ot_moved = pd->moved; + /* Advance our position to where pd is */ + oldpd->buffer = pd->buffer; + oldpd->nboff = pd->nboff; + oldpd->nbits -= pd->moved - arg->ot_moved; + oldpd->moved += pd->moved - arg->ot_moved; + arg->ot_moved = pd->moved; - if(arg->unclaimed) { - /* Refill the container */ - if(per_get_few_bits(oldpd, 1)) - return -1; - if(oldpd->nboff == 0) { - assert(0); - return -1; - } - pd->buffer = oldpd->buffer; - pd->nboff = oldpd->nboff - 1; - pd->nbits = oldpd->nbits; - ASN_DEBUG("UNCLAIMED <- return from (pd->moved=%d)", pd->moved); - return 0; - } + if (arg->unclaimed) + { + /* Refill the container */ + if (per_get_few_bits(oldpd, 1)) + return -1; + if (oldpd->nboff == 0) + { + assert(0); + return -1; + } + pd->buffer = oldpd->buffer; + pd->nboff = oldpd->nboff - 1; + pd->nbits = oldpd->nbits; + ASN_DEBUG("UNCLAIMED <- return from (pd->moved=%d)", pd->moved); + return 0; + } - if(!arg->repeat) { - ASN_DEBUG("Want more but refill doesn't have it"); - return -1; - } + if (!arg->repeat) + { + ASN_DEBUG("Want more but refill doesn't have it"); + return -1; + } - next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); - ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", - next_chunk_bytes, oldpd->moved, arg->repeat); - if(next_chunk_bytes < 0) return -1; - if(next_chunk_bytes == 0) { - pd->refill = 0; /* No more refills, naturally */ - assert(!arg->repeat); /* Implementation guarantee */ - } - next_chunk_bits = next_chunk_bytes << 3; - avail = oldpd->nbits - oldpd->nboff; - if(avail >= next_chunk_bits) { - pd->nbits = oldpd->nboff + next_chunk_bits; - arg->unclaimed = 0; - ASN_DEBUG("!+Parent frame %d bits, alloting %d [%d..%d] (%d)", - next_chunk_bits, oldpd->moved, - oldpd->nboff, oldpd->nbits, - oldpd->nbits - oldpd->nboff); - } else { - pd->nbits = oldpd->nbits; - arg->unclaimed = next_chunk_bits - avail; - ASN_DEBUG("!-Parent frame %d, require %d, will claim %d", avail, next_chunk_bits, arg->unclaimed); - } - pd->buffer = oldpd->buffer; - pd->nboff = oldpd->nboff; - ASN_DEBUG("Refilled pd%s old%s", - per_data_string(pd), per_data_string(oldpd)); - return 0; + next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); + ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", + next_chunk_bytes, oldpd->moved, arg->repeat); + if (next_chunk_bytes < 0) return -1; + if (next_chunk_bytes == 0) + { + pd->refill = 0; /* No more refills, naturally */ + assert(!arg->repeat); /* Implementation guarantee */ + } + next_chunk_bits = next_chunk_bytes << 3; + avail = oldpd->nbits - oldpd->nboff; + if (avail >= next_chunk_bits) + { + pd->nbits = oldpd->nboff + next_chunk_bits; + arg->unclaimed = 0; + ASN_DEBUG("!+Parent frame %d bits, alloting %d [%d..%d] (%d)", + next_chunk_bits, oldpd->moved, + oldpd->nboff, oldpd->nbits, + oldpd->nbits - oldpd->nboff); + } + else + { + pd->nbits = oldpd->nbits; + arg->unclaimed = next_chunk_bits - avail; + ASN_DEBUG("!-Parent frame %d, require %d, will claim %d", avail, next_chunk_bits, arg->unclaimed); + } + pd->buffer = oldpd->buffer; + pd->nboff = oldpd->nboff; + ASN_DEBUG("Refilled pd%s old%s", + per_data_string(pd), per_data_string(oldpd)); + return 0; } static int -per_skip_bits(asn_per_data_t *pd, int skip_nbits) { - int hasNonZeroBits = 0; - while(skip_nbits > 0) { - int skip; - if(skip_nbits < skip) - skip = skip_nbits; - else - skip = 24; - skip_nbits -= skip; +per_skip_bits(asn_per_data_t *pd, int skip_nbits) +{ + int hasNonZeroBits = 0; + while (skip_nbits > 0) + { + int skip = 0; + if (skip_nbits < skip) + skip = skip_nbits; + else + skip = 24; + skip_nbits -= skip; - switch(per_get_few_bits(pd, skip)) { - case -1: return -1; /* Starving */ - case 0: continue; /* Skipped empty space */ - default: hasNonZeroBits = 1; continue; - } - } - return hasNonZeroBits; + switch (per_get_few_bits(pd, skip)) + { + case -1: + return -1; /* Starving */ + case 0: + continue; /* Skipped empty space */ + default: + hasNonZeroBits = 1; + continue; + } + } + return hasNonZeroBits; } diff --git a/src/core/libs/supl/asn-supl/per_support.h b/src/core/libs/supl/asn-supl/per_support.h index c99f12291..7ea76d331 100644 --- a/src/core/libs/supl/asn-supl/per_support.h +++ b/src/core/libs/supl/asn-supl/per_support.h @@ -56,24 +56,24 @@ extern "C" * This function returns -1 if the specified number of bits could not be * extracted due to EOD or other conditions. */ - int32_t per_get_few_bits(asn_per_data_t *per_data, int get_nbits); + int32_t per_get_few_bits(asn_per_data_t *pd, int get_nbits); /* Undo the immediately preceeding "get_few_bits" operation */ - void per_get_undo(asn_per_data_t *per_data, int get_nbits); + void per_get_undo(asn_per_data_t *pd, int get_nbits); /* * Extract a large number of bits from the specified PER data pointer. * This function returns -1 if the specified number of bits could not be * extracted due to EOD or other conditions. */ - int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int right_align, + int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int get_nbits); /* * Get the length "n" from the Unaligned PER stream. */ ssize_t uper_get_length(asn_per_data_t *pd, - int effective_bound_bits, + int ebits, int *repeat); /* @@ -87,7 +87,7 @@ extern "C" ssize_t uper_get_nsnnwn(asn_per_data_t *pd); /* X.691-2008/11, #11.5.6 */ - int uper_get_constrained_whole_number(asn_per_data_t *pd, unsigned long *v, int nbits); + int uper_get_constrained_whole_number(asn_per_data_t *pd, unsigned long *out_value, int nbits); /* Non-thread-safe debugging function, don't use it */ char *per_data_string(asn_per_data_t *pd); @@ -107,7 +107,7 @@ extern "C" } asn_per_outp_t; /* Output a small number of bits (<= 31) */ - int per_put_few_bits(asn_per_outp_t *per_data, uint32_t bits, int obits); + int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits); /* Output a large number of bits */ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int put_nbits); diff --git a/src/core/libs/supl/asn-supl/xer_decoder.c b/src/core/libs/supl/asn-supl/xer_decoder.c index 161dc78ce..ef5f06481 100644 --- a/src/core/libs/supl/asn-supl/xer_decoder.c +++ b/src/core/libs/supl/asn-supl/xer_decoder.c @@ -181,12 +181,12 @@ xer_check_tag(const void *buf_ptr, int size, const char *need_tag) { #define XER_GOT_BODY(chunk_buf, chunk_size, size) do { \ ssize_t converted_size = body_receiver \ (struct_key, chunk_buf, chunk_size, \ - (size_t)chunk_size < size); \ + (size_t)(chunk_size) < (size)); \ if(converted_size == -1) RETURN(RC_FAIL); \ if(converted_size == 0 \ - && size == (size_t)chunk_size) \ + && (size) == (size_t)(chunk_size)) \ RETURN(RC_WMORE); \ - chunk_size = converted_size; \ + (chunk_size) = converted_size; \ } while(0) #define XER_GOT_EMPTY() do { \ if(body_receiver(struct_key, 0, 0, size > 0) == -1) \ diff --git a/src/core/libs/supl/asn-supl/xer_decoder.h b/src/core/libs/supl/asn-supl/xer_decoder.h index 52444af51..02f62a0e1 100644 --- a/src/core/libs/supl/asn-supl/xer_decoder.h +++ b/src/core/libs/supl/asn-supl/xer_decoder.h @@ -18,7 +18,7 @@ extern "C" * The XER decoder of any ASN.1 type. May be invoked by the application. */ asn_dec_rval_t xer_decode(struct asn_codec_ctx_s *opt_codec_ctx, - struct asn_TYPE_descriptor_s *type_descriptor, + struct asn_TYPE_descriptor_s *td, void **struct_ptr, /* Pointer to a target structure's pointer */ const void *buffer, /* Data to be decoded */ size_t size /* Size of data buffer */ diff --git a/src/core/libs/supl/asn-supl/xer_encoder.h b/src/core/libs/supl/asn-supl/xer_encoder.h index 5b640d425..9cbd08102 100644 --- a/src/core/libs/supl/asn-supl/xer_encoder.h +++ b/src/core/libs/supl/asn-supl/xer_encoder.h @@ -25,8 +25,8 @@ extern "C" /* * The XER encoder of any type. May be invoked by the application. */ - asn_enc_rval_t xer_encode(struct asn_TYPE_descriptor_s *type_descriptor, - void *struct_ptr, /* Structure to be encoded */ + asn_enc_rval_t xer_encode(struct asn_TYPE_descriptor_s *td, + void *sptr, /* Structure to be encoded */ enum xer_encoder_flags_e xer_flags, asn_app_consume_bytes_f *consume_bytes_cb, void *app_key /* Arbitrary callback argument */ diff --git a/src/core/libs/supl/asn-supl/xer_support.c b/src/core/libs/supl/asn-supl/xer_support.c index 9e34e6923..cfa30e674 100644 --- a/src/core/libs/supl/asn-supl/xer_support.c +++ b/src/core/libs/supl/asn-supl/xer_support.c @@ -60,7 +60,7 @@ _charclass[256] = { #define TOKEN_CB_CALL(type, _ns, _current_too, _final) do { \ int _ret; \ pstate_e ns = _ns; \ - ssize_t _sz = (p - chunk_start) + _current_too; \ + ssize_t _sz = (p - chunk_start) + (_current_too); \ if (!_sz) { \ /* Shortcut */ \ state = _ns; \ @@ -68,11 +68,11 @@ _charclass[256] = { } \ _ret = cb(type, chunk_start, _sz, key); \ if(_ret < _sz) { \ - if(_current_too && _ret == -1) \ + if((_current_too) && _ret == -1) \ state = ns; \ goto finish; \ } \ - chunk_start = p + _current_too; \ + chunk_start = p + (_current_too); \ state = ns; \ } while(0) diff --git a/src/core/libs/supl/asn-supl/xer_support.h b/src/core/libs/supl/asn-supl/xer_support.h index 13d8bbd06..e28316d59 100644 --- a/src/core/libs/supl/asn-supl/xer_support.h +++ b/src/core/libs/supl/asn-supl/xer_support.h @@ -47,7 +47,7 @@ extern "C" * It will always be lesser than or equal to the specified _size. * The next invocation of this function must account the difference. */ - ssize_t pxml_parse(int *_stateContext, const void *_buf, size_t _size, + ssize_t pxml_parse(int *_stateContext, const void *xmlbuf, size_t _size, pxml_callback_f *cb, void *_key); #ifdef __cplusplus diff --git a/src/core/libs/supl/supl.c b/src/core/libs/supl/supl.c index 021b65327..0184f35ac 100644 --- a/src/core/libs/supl/supl.c +++ b/src/core/libs/supl/supl.c @@ -9,29 +9,29 @@ */ #include "supl.h" -#include +#include #include #include -#include +#include +#include +#include +#include #include #include -#include -#include -#include - #define PARAM_GSM_CELL_CURRENT 1 #define PARAM_GSM_CELL_KNOWN 2 #define PARAM_WCDMA_CELL_CURRENT 4 -#define OPTIONAL_MISSING ((void*)0) +#define OPTIONAL_MISSING ((void *)0) #ifdef SUPL_DEBUG -static struct supl_debug_s { - FILE *log; - int verbose_rrlp, verbose_supl, debug; - int sent,recv, out_msg, in_msg; +static struct supl_debug_s +{ + FILE *log; + int verbose_rrlp, verbose_supl, debug; + int sent, recv, out_msg, in_msg; } debug; #endif @@ -42,521 +42,599 @@ static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp); static int supl_more_rrlp(PDU_t *rrlp); static int supl_response_harvest(supl_ctx_t *ctx, supl_ulp_t *pdu); -int EXPORT supl_ulp_decode(supl_ulp_t *pdu) { - ULP_PDU_t *ulp; - asn_codec_ctx_t ctx; - asn_dec_rval_t rval; +int EXPORT supl_ulp_decode(supl_ulp_t *pdu) +{ + ULP_PDU_t *ulp; + asn_codec_ctx_t ctx; + asn_dec_rval_t rval; - ulp = calloc(1, sizeof(ULP_PDU_t)); - pdu->pdu = ulp; + ulp = calloc(1, sizeof(ULP_PDU_t)); + pdu->pdu = ulp; - ctx.max_stack_size = 0; - rval = uper_decode_complete(&ctx, &asn_DEF_ULP_PDU, (void **)&ulp, pdu->buffer, pdu->size); - if (rval.code == RC_OK) { - return 0; - } + ctx.max_stack_size = 0; + rval = uper_decode_complete(&ctx, &asn_DEF_ULP_PDU, (void **)&ulp, pdu->buffer, pdu->size); + if (rval.code == RC_OK) + { + return 0; + } - free(ulp); - pdu->pdu = 0; + free(ulp); + pdu->pdu = 0; - return E_SUPL_DECODE; + return E_SUPL_DECODE; } -int EXPORT supl_ulp_encode(supl_ulp_t *pdu) { - asn_enc_rval_t ret; - int pdu_len; - ret = uper_encode_to_buffer(&asn_DEF_ULP_PDU, pdu->pdu, pdu->buffer, sizeof(pdu->buffer)); - if (ret.encoded != -1) { - memset(pdu->buffer, 0, sizeof(pdu->buffer)); - - pdu_len = (ret.encoded + 7) >> 3; - ((ULP_PDU_t *)pdu->pdu)->length = pdu_len; +int EXPORT supl_ulp_encode(supl_ulp_t *pdu) +{ + asn_enc_rval_t ret; + int pdu_len; ret = uper_encode_to_buffer(&asn_DEF_ULP_PDU, pdu->pdu, pdu->buffer, sizeof(pdu->buffer)); - if (ret.encoded > 0) { - int len = (ret.encoded + 7) >> 3; + if (ret.encoded != -1) + { + memset(pdu->buffer, 0, sizeof(pdu->buffer)); - if (len == pdu_len) { - pdu->size = pdu_len; - return 0; - } - } - } + pdu_len = (ret.encoded + 7) >> 3; + ((ULP_PDU_t *)pdu->pdu)->length = pdu_len; - return E_SUPL_ENCODE; + ret = uper_encode_to_buffer(&asn_DEF_ULP_PDU, pdu->pdu, pdu->buffer, sizeof(pdu->buffer)); + if (ret.encoded > 0) + { + int len = (ret.encoded + 7) >> 3; + + if (len == pdu_len) + { + pdu->size = pdu_len; + return 0; + } + } + } + + return E_SUPL_ENCODE; } -void EXPORT supl_ulp_free(supl_ulp_t *pdu) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, pdu->pdu, 0); + +void EXPORT supl_ulp_free(supl_ulp_t *pdu) +{ + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, pdu->pdu, 0); } -int EXPORT supl_ulp_send(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int err; + +int EXPORT supl_ulp_send(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int err; #if SUPL_DEBUG - if (debug.verbose_supl) { - fprintf(debug.log, "Send %lu bytes\n", pdu->size); - xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); - } + if (debug.verbose_supl) + { + fprintf(debug.log, "Send %lu bytes\n", pdu->size); + xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); + } #endif - err = SSL_write(ctx->ssl, pdu->buffer, pdu->size); - if (err <= 0) { + err = SSL_write(ctx->ssl, pdu->buffer, pdu->size); + if (err <= 0) + { #if SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "Error: SSL_write error: %s\n", strerror(errno)); + if (debug.debug) fprintf(debug.log, "Error: SSL_write error: %s\n", strerror(errno)); #endif - return E_SUPL_WRITE; - } + return E_SUPL_WRITE; + } #ifdef SUPL_DEBUG - debug.sent += pdu->size; - debug.out_msg++; + debug.sent += pdu->size; + debug.out_msg++; #endif - return 0; -} - -int EXPORT supl_ulp_recv(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int err; - int n; - asn_dec_rval_t rval; - ULP_PDU_t *length; - - err = SSL_read(ctx->ssl, pdu->buffer, sizeof(pdu->buffer)); - if (err <= 0) { -#ifdef SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "Error: SSL_read error: %s\n", strerror(errno)); -#endif - return E_SUPL_READ; - } - n = err; - - length = calloc(1, sizeof(ULP_PDU_t)); - // decode the very first bytes of the ULP_PDU message, just enough to the get message length - rval = uper_decode_complete(0, &asn_DEF_ULP_PDU, (void **)&length, pdu->buffer, n < 6 ? n : 6); - if (rval.code == RC_WMORE) { - // read the missing data - for (n = err; n < length->length; n += err) { -#ifdef SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "SSL_read got %u bytes (total %lu)\n", n, length->length); -#endif - err = SSL_read(ctx->ssl, &pdu->buffer[n], sizeof(pdu->buffer)-n); - if (err <= 0) { -#ifdef SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "Error: SSL_read (again) error: %s\n", strerror(errno)); -#endif - return E_SUPL_READ; - } - } - } - - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, length, 0); - - pdu->size = n; - - if (supl_ulp_decode(pdu)) { - return E_SUPL_DECODE; - } - -#ifdef SUPL_DEBUG - if (debug.verbose_supl) { - fprintf(debug.log, "Recv %lu bytes\n", pdu->size); - xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); - } -#endif - -#ifdef SUPL_DEBUG - debug.recv += err; - debug.in_msg++; -#endif - - return 0; -} - -int EXPORT supl_decode_rrlp(supl_ulp_t *ulp_pdu, PDU_t **ret_rrlp) { - asn_dec_rval_t rval; - OCTET_STRING_t *rrlp_pdu; - PDU_t *rrlp; - ULP_PDU_t *ulp; - - ulp = ulp_pdu->pdu; - - if (!(ulp->message.present == UlpMessage_PR_msSUPLPOS && - ulp->message.choice.msSUPLPOS.posPayLoad.present == PosPayLoad_PR_rrlpPayload)) { return 0; - } - rrlp_pdu = &ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload; +} - rrlp = calloc(1, sizeof(PDU_t)); - rval = uper_decode_complete(0, &asn_DEF_PDU, (void **)&rrlp, rrlp_pdu->buf, rrlp_pdu->size); - switch (rval.code) { - case RC_OK: + +int EXPORT supl_ulp_recv(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int err; + int n; + asn_dec_rval_t rval; + ULP_PDU_t *length; + + err = SSL_read(ctx->ssl, pdu->buffer, sizeof(pdu->buffer)); + if (err <= 0) + { #ifdef SUPL_DEBUG - if (rval.consumed != rrlp_pdu->size) { - if (debug.debug) fprintf(debug.log, "Warning: %lu bytes left over in RRLP decoding\n", rval.consumed); - } + if (debug.debug) fprintf(debug.log, "Error: SSL_read error: %s\n", strerror(errno)); +#endif + return E_SUPL_READ; + } + n = err; + + length = calloc(1, sizeof(ULP_PDU_t)); + // decode the very first bytes of the ULP_PDU message, just enough to the get message length + rval = uper_decode_complete(0, &asn_DEF_ULP_PDU, (void **)&length, pdu->buffer, n < 6 ? n : 6); + if (rval.code == RC_WMORE) + { + // read the missing data + for (n = err; n < length->length; n += err) + { +#ifdef SUPL_DEBUG + if (debug.debug) fprintf(debug.log, "SSL_read got %u bytes (total %lu)\n", n, length->length); +#endif + err = SSL_read(ctx->ssl, &pdu->buffer[n], sizeof(pdu->buffer) - n); + if (err <= 0) + { +#ifdef SUPL_DEBUG + if (debug.debug) fprintf(debug.log, "Error: SSL_read (again) error: %s\n", strerror(errno)); +#endif + return E_SUPL_READ; + } + } + } + + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, length, 0); + + pdu->size = n; + + if (supl_ulp_decode(pdu)) + { + return E_SUPL_DECODE; + } + +#ifdef SUPL_DEBUG + if (debug.verbose_supl) + { + fprintf(debug.log, "Recv %lu bytes\n", pdu->size); + xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); + } +#endif + +#ifdef SUPL_DEBUG + debug.recv += err; + debug.in_msg++; #endif - *ret_rrlp = rrlp; return 0; - - case RC_WMORE: - asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - ret_rrlp = 0; - return E_SUPL_DECODE_RRLP; - - default: - asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - ret_rrlp = 0; - return E_SUPL_DECODE_RRLP; - } - - return E_SUPL_INTERNAL; } - -int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) { - int err; - SSL_METHOD *meth; - SSLeay_add_ssl_algorithms(); - // meth = TLSv1_client_method(); - meth = (SSL_METHOD*)SSLv23_client_method(); - SSL_load_error_strings(); - ctx->ssl_ctx = SSL_CTX_new(meth); - if (!ctx->ssl_ctx) return E_SUPL_CONNECT; - - ctx->ssl = SSL_new(ctx->ssl_ctx); - if (!ctx->ssl) return E_SUPL_CONNECT; - if (server) { - ctx->fd = server_connect(server); - if (ctx->fd == -1) return E_SUPL_CONNECT; - } +int EXPORT supl_decode_rrlp(supl_ulp_t *ulp_pdu, PDU_t **ret_rrlp) +{ + asn_dec_rval_t rval; + OCTET_STRING_t *rrlp_pdu; + PDU_t *rrlp; + ULP_PDU_t *ulp; - SSL_set_fd(ctx->ssl, ctx->fd); - err = SSL_connect(ctx->ssl); - if (err == -1) return E_SUPL_CONNECT; + ulp = ulp_pdu->pdu; + + if (!(ulp->message.present == UlpMessage_PR_msSUPLPOS && + ulp->message.choice.msSUPLPOS.posPayLoad.present == PosPayLoad_PR_rrlpPayload)) + { + return 0; + } + rrlp_pdu = &ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload; + + rrlp = calloc(1, sizeof(PDU_t)); + rval = uper_decode_complete(0, &asn_DEF_PDU, (void **)&rrlp, rrlp_pdu->buf, rrlp_pdu->size); + switch (rval.code) + { + case RC_OK: +#ifdef SUPL_DEBUG + if (rval.consumed != rrlp_pdu->size) + { + if (debug.debug) fprintf(debug.log, "Warning: %lu bytes left over in RRLP decoding\n", rval.consumed); + } +#endif + + *ret_rrlp = rrlp; + return 0; + + case RC_WMORE: + asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + ret_rrlp = 0; + return E_SUPL_DECODE_RRLP; + + default: + asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + ret_rrlp = 0; + return E_SUPL_DECODE_RRLP; + } + + return E_SUPL_INTERNAL; +} + + +int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) +{ + int err; + SSL_METHOD *meth; + + SSLeay_add_ssl_algorithms(); + // meth = TLSv1_client_method(); + meth = (SSL_METHOD *)SSLv23_client_method(); + SSL_load_error_strings(); + ctx->ssl_ctx = SSL_CTX_new(meth); + if (!ctx->ssl_ctx) + { + return E_SUPL_CONNECT; + } + + ctx->ssl = SSL_new(ctx->ssl_ctx); + if (!ctx->ssl) + { + return E_SUPL_CONNECT; + } + + if (server) + { + ctx->fd = server_connect(server); + if (ctx->fd == -1) + { + return E_SUPL_CONNECT; + } + } + + SSL_set_fd(ctx->ssl, ctx->fd); + err = SSL_connect(ctx->ssl); + if (err == -1) + { + return E_SUPL_CONNECT; + } #if 0 { X509 *s_cert = SSL_get_peer_certificate(ctx->ssl); FILE *fp = fopen("/tmp/s_cert.pem", "w"); - if (fp) + if (fp) PEM_write_X509(fp, s_cert); fclose(fp); X509_free(s_cert); } #endif - - return 0; -} -void EXPORT supl_close(supl_ctx_t *ctx) { - SSL_shutdown(ctx->ssl); - SSL_free(ctx->ssl); - SSL_CTX_free(ctx->ssl_ctx); - close(ctx->fd); + return 0; } -static int server_connect(char *server) { - int fd = -1; - struct addrinfo *ailist, *aip; - struct addrinfo hint; - int err; - - memset(&hint, 0, sizeof(struct addrinfo)); - hint.ai_socktype = SOCK_STREAM; - err = getaddrinfo(server, SUPL_PORT, &hint, &ailist); - if (err != 0) { - return -1; - } - - for (aip = ailist; aip; aip = aip->ai_next) { - if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) { - err = errno; - } - if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) { - return -1; - } - break; - } - - return fd; +void EXPORT supl_close(supl_ctx_t *ctx) +{ + SSL_shutdown(ctx->ssl); + SSL_free(ctx->ssl); + SSL_CTX_free(ctx->ssl_ctx); + close(ctx->fd); } -static int pdu_make_ulp_start(supl_ctx_t *ctx, supl_ulp_t *pdu) { - ULP_PDU_t *ulp; - SetSessionID_t *session_id; - int err; - ulp = calloc(1, sizeof(ULP_PDU_t)); - session_id = calloc(1, sizeof(SetSessionID_t)); +static int server_connect(char *server) +{ + int fd = -1; + struct addrinfo *ailist, *aip; + struct addrinfo hint; + int err; - ulp->length = 0; - ulp->version.maj = 1; - ulp->version.min = 0; - ulp->version.servind = 0; + memset(&hint, 0, sizeof(struct addrinfo)); + hint.ai_socktype = SOCK_STREAM; + err = getaddrinfo(server, SUPL_PORT, &hint, &ailist); + if (err != 0) + { + return -1; + } - session_id->sessionId = 1; - // session_id->setId.present = SETId_PR_msisdn; - // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); - session_id->setId.present = SETId_PR_imsi; - (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + for (aip = ailist; aip; aip = aip->ai_next) + { + if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) + { + err = errno; + } + if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) + { + return -1; + } + break; + } - ulp->sessionID.setSessionID = session_id; - ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - - ulp->message.present = UlpMessage_PR_msSUPLSTART; - ulp->message.choice.msSUPLSTART.sETCapabilities.posTechnology.agpsSETBased = 1; - // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_noPreference); - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); - ulp->message.choice.msSUPLSTART.sETCapabilities.posProtocol.rrlp = 1; - - if (ctx->p.set & PARAM_GSM_CELL_CURRENT) { - ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_gsmCell; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; - } else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) { - ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; - } - - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.locationId.status, Status_current); - - ulp->message.choice.msSUPLSTART.qoP = OPTIONAL_MISSING; - - pdu->pdu = ulp; - - err = supl_ulp_encode(pdu); - if (err < 0) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); - return err; - } - - return 0; + return fd; } + +static int pdu_make_ulp_start(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + ULP_PDU_t *ulp; + SetSessionID_t *session_id; + int err; + + ulp = calloc(1, sizeof(ULP_PDU_t)); + session_id = calloc(1, sizeof(SetSessionID_t)); + + ulp->length = 0; + ulp->version.maj = 1; + ulp->version.min = 0; + ulp->version.servind = 0; + + session_id->sessionId = 1; + // session_id->setId.present = SETId_PR_msisdn; + // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); + session_id->setId.present = SETId_PR_imsi; + (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + + ulp->sessionID.setSessionID = session_id; + ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + + ulp->message.present = UlpMessage_PR_msSUPLSTART; + ulp->message.choice.msSUPLSTART.sETCapabilities.posTechnology.agpsSETBased = 1; + // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_noPreference); + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); + ulp->message.choice.msSUPLSTART.sETCapabilities.posProtocol.rrlp = 1; + + if (ctx->p.set & PARAM_GSM_CELL_CURRENT) + { + ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_gsmCell; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; + } + else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) + { + ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; + } + + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.locationId.status, Status_current); + + ulp->message.choice.msSUPLSTART.qoP = OPTIONAL_MISSING; + + pdu->pdu = ulp; + + err = supl_ulp_encode(pdu); + if (err < 0) + { + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); + return err; + } + + return 0; +} + + // get slpSessionID from SUPLRESPONSE pdu if preset -static int supl_response_harvest(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int ret; - ULP_PDU_t *ulp = pdu->pdu; - void *buf; +static int supl_response_harvest(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int ret; + ULP_PDU_t *ulp = pdu->pdu; + void *buf; - ctx->slp_session_id.buf = 0; + ctx->slp_session_id.buf = 0; - ret = uper_encode_to_new_buffer(&asn_DEF_SlpSessionID, 0, (void *)ulp->sessionID.slpSessionID, &buf); - if (ret == -1) return -1; + ret = uper_encode_to_new_buffer(&asn_DEF_SlpSessionID, 0, (void *)ulp->sessionID.slpSessionID, &buf); + if (ret == -1) + { + return -1; + } - ctx->slp_session_id.buf = buf; - ctx->slp_session_id.size = ret; + ctx->slp_session_id.buf = buf; + ctx->slp_session_id.size = ret; - return 0; + return 0; } -static int pdu_make_ulp_pos_init(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int err; - ULP_PDU_t *ulp; - SetSessionID_t *session_id; - RequestedAssistData_t *req_adata; - ulp = calloc(1, sizeof(ULP_PDU_t)); - session_id = calloc(1, sizeof(SetSessionID_t)); - req_adata = calloc(1, sizeof(RequestedAssistData_t)); +static int pdu_make_ulp_pos_init(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int err; + ULP_PDU_t *ulp; + SetSessionID_t *session_id; + RequestedAssistData_t *req_adata; - ulp->length = 0; - ulp->version.maj = 1; - ulp->version.min = 0; - ulp->version.servind = 0; + ulp = calloc(1, sizeof(ULP_PDU_t)); + session_id = calloc(1, sizeof(SetSessionID_t)); + req_adata = calloc(1, sizeof(RequestedAssistData_t)); - session_id->sessionId = 1; - // session_id->setId.present = SETId_PR_msisdn; - // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); - session_id->setId.present = SETId_PR_imsi; - (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + ulp->length = 0; + ulp->version.maj = 1; + ulp->version.min = 0; + ulp->version.servind = 0; - ulp->sessionID.setSessionID = session_id; - // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - if (ctx->slp_session_id.buf) { - (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); - } else { - ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - } + session_id->sessionId = 1; + // session_id->setId.present = SETId_PR_msisdn; + // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); + session_id->setId.present = SETId_PR_imsi; + (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); - ulp->message.present = UlpMessage_PR_msSUPLPOSINIT; - ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posTechnology.agpsSETBased = 1; - // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_noPreference); - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); - ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posProtocol.rrlp = 1; + ulp->sessionID.setSessionID = session_id; + // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + if (ctx->slp_session_id.buf) + { + (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); + } + else + { + ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + } - //GNSS-SDR mod - // Use ctx->p.request to swith between a pre-defined set of assistence data request - // reason: Some SUPL servers do not respond to Acquisition assistance depending on the status of other assistance flags + ulp->message.present = UlpMessage_PR_msSUPLPOSINIT; + ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posTechnology.agpsSETBased = 1; + // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_noPreference); + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); + ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posProtocol.rrlp = 1; - switch (ctx->p.request) - { - case 0: //request almanac, time, and cell positions - req_adata->acquisitionAssistanceRequested = 0; // 1 - req_adata->navigationModelRequested = 0; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 1; //1 - req_adata->ionosphericModelRequested = 1; // 1 - req_adata->referenceLocationRequested = 1; - req_adata->almanacRequested = 1; - req_adata->realTimeIntegrityRequested = 1; // 1 - break; - case 1: // request Navigation Model (Ephemeris) - req_adata->acquisitionAssistanceRequested = 0; // 1 - req_adata->navigationModelRequested = 1; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 0; //1 - req_adata->ionosphericModelRequested = 0; // 1 - req_adata->referenceLocationRequested = 0; - req_adata->almanacRequested = 0; - req_adata->realTimeIntegrityRequested = 0; // 1 - break; - case 2: //request Acquisition assistance (Doppler assistance) - req_adata->acquisitionAssistanceRequested = 1; // 1 - req_adata->navigationModelRequested = 0; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 1; //1 - req_adata->ionosphericModelRequested = 1; // 1 - req_adata->referenceLocationRequested = 1; - req_adata->almanacRequested = 1; - req_adata->realTimeIntegrityRequested = 1; // 1 - break; - default: - req_adata->acquisitionAssistanceRequested = 0; // 1 - req_adata->navigationModelRequested = 0; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 1; //1 - req_adata->ionosphericModelRequested = 1; // 1 - req_adata->referenceLocationRequested = 1; - req_adata->almanacRequested = 1; - req_adata->realTimeIntegrityRequested = 1; // 1 - break; - } + //GNSS-SDR mod + // Use ctx->p.request to swith between a pre-defined set of assistence data request + // reason: Some SUPL servers do not respond to Acquisition assistance depending on the status of other assistance flags - ulp->message.choice.msSUPLPOSINIT.requestedAssistData = req_adata; + switch (ctx->p.request) + { + case 0: //request almanac, time, and cell positions + req_adata->acquisitionAssistanceRequested = 0; // 1 + req_adata->navigationModelRequested = 0; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 1; //1 + req_adata->ionosphericModelRequested = 1; // 1 + req_adata->referenceLocationRequested = 1; + req_adata->almanacRequested = 1; + req_adata->realTimeIntegrityRequested = 1; // 1 + break; + case 1: // request Navigation Model (Ephemeris) + req_adata->acquisitionAssistanceRequested = 0; // 1 + req_adata->navigationModelRequested = 1; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 0; //1 + req_adata->ionosphericModelRequested = 0; // 1 + req_adata->referenceLocationRequested = 0; + req_adata->almanacRequested = 0; + req_adata->realTimeIntegrityRequested = 0; // 1 + break; + case 2: //request Acquisition assistance (Doppler assistance) + req_adata->acquisitionAssistanceRequested = 1; // 1 + req_adata->navigationModelRequested = 0; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 1; //1 + req_adata->ionosphericModelRequested = 1; // 1 + req_adata->referenceLocationRequested = 1; + req_adata->almanacRequested = 1; + req_adata->realTimeIntegrityRequested = 1; // 1 + break; + default: + req_adata->acquisitionAssistanceRequested = 0; // 1 + req_adata->navigationModelRequested = 0; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 1; //1 + req_adata->ionosphericModelRequested = 1; // 1 + req_adata->referenceLocationRequested = 1; + req_adata->almanacRequested = 1; + req_adata->realTimeIntegrityRequested = 1; // 1 + break; + } - if (ctx->p.set & PARAM_GSM_CELL_CURRENT) { - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_gsmCell; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; - } else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) { - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; - } + ulp->message.choice.msSUPLPOSINIT.requestedAssistData = req_adata; - if (ctx->p.set & PARAM_GSM_CELL_KNOWN) { - Position_t *pos = calloc(1, sizeof(Position_t)); - struct tm *tm; - time_t t; + if (ctx->p.set & PARAM_GSM_CELL_CURRENT) + { + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_gsmCell; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; + } + else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) + { + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; + } - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_stale); + if (ctx->p.set & PARAM_GSM_CELL_KNOWN) + { + Position_t *pos = calloc(1, sizeof(Position_t)); + struct tm *tm; + time_t t; - t = time(0); - tm = gmtime(&t); - asn_UT2time(&pos->timestamp, tm ,1); - (void)asn_long2INTEGER(&pos->positionEstimate.latitudeSign, latitudeSign_north); - pos->positionEstimate.latitude = (1 << 23) / 90.0 * ctx->p.known.lat; - pos->positionEstimate.longitude = (1 << 24) / 360.0 * ctx->p.known.lon; - // TODO: set position estimate + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_stale); - ulp->message.choice.msSUPLPOSINIT.position = pos; - } else { - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_current); - ulp->message.choice.msSUPLPOSINIT.position = OPTIONAL_MISSING; - } + t = time(0); + tm = gmtime(&t); + asn_UT2time(&pos->timestamp, tm, 1); + (void)asn_long2INTEGER(&pos->positionEstimate.latitudeSign, latitudeSign_north); + pos->positionEstimate.latitude = (1 << 23) / 90.0 * ctx->p.known.lat; + pos->positionEstimate.longitude = (1 << 24) / 360.0 * ctx->p.known.lon; + // TODO: set position estimate - ulp->message.choice.msSUPLPOSINIT.sUPLPOS = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.position = pos; + } + else + { + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_current); + ulp->message.choice.msSUPLPOSINIT.position = OPTIONAL_MISSING; + } - ulp->message.choice.msSUPLPOSINIT.ver = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.sUPLPOS = OPTIONAL_MISSING; - pdu->pdu = ulp; + ulp->message.choice.msSUPLPOSINIT.ver = OPTIONAL_MISSING; - err = supl_ulp_encode(pdu); - if (err < 0) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); - return err; - } + pdu->pdu = ulp; - return 0; + err = supl_ulp_encode(pdu); + if (err < 0) + { + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); + return err; + } + + return 0; } -static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) { - int err; - PDU_t *rrlp_ack; - ULP_PDU_t *ulp; - SetSessionID_t *session_id; - asn_enc_rval_t ret; - int pdu_len; - char buffer[1024]; - rrlp_ack = calloc(1, sizeof(PDU_t)); +static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) +{ + int err; + PDU_t *rrlp_ack; + ULP_PDU_t *ulp; + SetSessionID_t *session_id; + asn_enc_rval_t ret; + int pdu_len; + char buffer[1024]; - /* create RRLP assistanceDataAck */ + rrlp_ack = calloc(1, sizeof(PDU_t)); - rrlp_ack->referenceNumber = rrlp->referenceNumber; - rrlp_ack->component.present = RRLP_Component_PR_assistanceDataAck; - - ret = uper_encode_to_buffer(&asn_DEF_PDU, rrlp_ack, buffer, sizeof(buffer)); - asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp_ack, 0); - if (ret.encoded == -1) { - return E_SUPL_ENCODE_RRLP; - } - pdu_len = (ret.encoded + 7) >> 3; + /* create RRLP assistanceDataAck */ - /* embedded it in SUPLPOS */ + rrlp_ack->referenceNumber = rrlp->referenceNumber; + rrlp_ack->component.present = RRLP_Component_PR_assistanceDataAck; - ulp = calloc(1, sizeof(ULP_PDU_t)); - session_id = calloc(1, sizeof(SetSessionID_t)); - - ulp->length = 0; - ulp->version.maj = 1; - ulp->version.min = 0; - ulp->version.servind = 0; - - session_id->sessionId = 1; - // session_id->setId.present = SETId_PR_msisdn; - // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); - session_id->setId.present = SETId_PR_imsi; - (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + ret = uper_encode_to_buffer(&asn_DEF_PDU, rrlp_ack, buffer, sizeof(buffer)); + asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp_ack, 0); + if (ret.encoded == -1) + { + return E_SUPL_ENCODE_RRLP; + } + pdu_len = (ret.encoded + 7) >> 3; - ulp->sessionID.setSessionID = session_id; - // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - if (ctx->slp_session_id.buf) { - (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); - } else { - ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - } + /* embedded it in SUPLPOS */ - ulp->message.present = UlpMessage_PR_msSUPLPOS; - ulp->message.choice.msSUPLPOS.posPayLoad.present = PosPayLoad_PR_rrlpPayload; - (void)OCTET_STRING_fromBuf(&ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload, buffer, pdu_len); + ulp = calloc(1, sizeof(ULP_PDU_t)); + session_id = calloc(1, sizeof(SetSessionID_t)); - pdu->pdu = ulp; + ulp->length = 0; + ulp->version.maj = 1; + ulp->version.min = 0; + ulp->version.servind = 0; - err = supl_ulp_encode(pdu); - if (err < 0) { - supl_ulp_free(pdu); - return err; - } + session_id->sessionId = 1; + // session_id->setId.present = SETId_PR_msisdn; + // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); + session_id->setId.present = SETId_PR_imsi; + (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); - return 0; + ulp->sessionID.setSessionID = session_id; + // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + if (ctx->slp_session_id.buf) + { + (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); + } + else + { + ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + } + + ulp->message.present = UlpMessage_PR_msSUPLPOS; + ulp->message.choice.msSUPLPOS.posPayLoad.present = PosPayLoad_PR_rrlpPayload; + (void)OCTET_STRING_fromBuf(&ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload, buffer, pdu_len); + + pdu->pdu = ulp; + + err = supl_ulp_encode(pdu); + if (err < 0) + { + supl_ulp_free(pdu); + return err; + } + + return 0; } /* @@ -564,132 +642,161 @@ static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) ** */ -int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval *t) { - ControlHeader_t *hdr; +int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval *t) +{ + ControlHeader_t *hdr; - if (rrlp->component.present != RRLP_Component_PR_assistanceData) return 0; - if (!rrlp->component.choice.assistanceData.gps_AssistData) return 0; + if (rrlp->component.present != RRLP_Component_PR_assistanceData) + { + return 0; + } + if (!rrlp->component.choice.assistanceData.gps_AssistData) + { + return 0; + } - hdr = &rrlp->component.choice.assistanceData.gps_AssistData->controlHeader; + hdr = &rrlp->component.choice.assistanceData.gps_AssistData->controlHeader; - if (hdr->referenceTime) { - assist->set |= SUPL_RRLP_ASSIST_REFTIME; - assist->time.gps_tow = hdr->referenceTime->gpsTime.gpsTOW23b; - assist->time.gps_week = hdr->referenceTime->gpsTime.gpsWeek; - memcpy(&assist->time.stamp, t, sizeof(struct timeval)); - } + if (hdr->referenceTime) + { + assist->set |= SUPL_RRLP_ASSIST_REFTIME; + assist->time.gps_tow = hdr->referenceTime->gpsTime.gpsTOW23b; + assist->time.gps_week = hdr->referenceTime->gpsTime.gpsWeek; + memcpy(&assist->time.stamp, t, sizeof(struct timeval)); + } - if (hdr->refLocation) { - OCTET_STRING_t *loc; + if (hdr->refLocation) + { + OCTET_STRING_t *loc; - loc = &hdr->refLocation->threeDLocation; - if (loc->size == 14 && loc->buf[0] == 0x90) { - double lat, lon; - long l; + loc = &hdr->refLocation->threeDLocation; + if (loc->size == 14 && loc->buf[0] == 0x90) + { + double lat, lon; + long l; - /* from 3GPP TS 23.032 V4.0.0 (2001-04) */ + /* from 3GPP TS 23.032 V4.0.0 (2001-04) */ - l = (loc->buf[1] & 0x7f) << 16 | - (loc->buf[2] << 8) | - loc->buf[3]; - if (loc->buf[1] & 0x80) l *= -1; - lat = 90.0 / (1 << 23) * l; - - l = (loc->buf[4] << 16) | - (loc->buf[5] << 8) | - loc->buf[6]; - lon = 360.0 / (1 << 24) * l; + l = (loc->buf[1] & 0x7f) << 16 | + (loc->buf[2] << 8) | + loc->buf[3]; + if (loc->buf[1] & 0x80) + { + l *= -1; + } + lat = 90.0 / (1 << 23) * l; - /* max of uncertainty ellipsoid axis */ - /* uncert in meters = 10 * (1.1 ^ l - 1) */ - /* l == 96 => 100 km uncertainty => not usable */ - l = loc->buf[9]; - if (loc->buf[10] > l) l = loc->buf[10]; + l = (loc->buf[4] << 16) | + (loc->buf[5] << 8) | + loc->buf[6]; + lon = 360.0 / (1 << 24) * l; - assist->set |= SUPL_RRLP_ASSIST_REFLOC; - assist->pos.lat = lat; - assist->pos.lon = lon; - assist->pos.uncertainty = l; - } - } - - if (hdr->acquisAssist) { - int n; + /* max of uncertainty ellipsoid axis */ + /* uncert in meters = 10 * (1.1 ^ l - 1) */ + /* l == 96 => 100 km uncertainty => not usable */ + l = loc->buf[9]; + if (loc->buf[10] > l) + { + l = loc->buf[10]; + } - assist->acq_time = hdr->acquisAssist->timeRelation.gpsTOW; + assist->set |= SUPL_RRLP_ASSIST_REFLOC; + assist->pos.lat = lat; + assist->pos.lon = lon; + assist->pos.uncertainty = l; + } + } - for (n = 0; n < hdr->acquisAssist->acquisList.list.count; n++) { - struct AcquisElement *e = hdr->acquisAssist->acquisList.list.array[n]; - int i = assist->cnt_acq++; + if (hdr->acquisAssist) + { + int n; - assist->acq[i].prn = e->svid + 1; - assist->acq[i].parts = 0; - assist->acq[i].doppler0 = e->doppler0; + assist->acq_time = hdr->acquisAssist->timeRelation.gpsTOW; - if (e->addionalDoppler) { - assist->acq[i].parts |= SUPL_ACQUIS_DOPPLER; - assist->acq[i].doppler1 = e->addionalDoppler->doppler1; - assist->acq[i].d_win = e->addionalDoppler->dopplerUncertainty; - } + for (n = 0; n < hdr->acquisAssist->acquisList.list.count; n++) + { + struct AcquisElement *e = hdr->acquisAssist->acquisList.list.array[n]; + int i = assist->cnt_acq++; - assist->acq[i].code_ph = e->codePhase; - assist->acq[i].code_ph_int = e->intCodePhase; - assist->acq[i].bit_num = e->gpsBitNumber; - assist->acq[i].code_ph_win = e->codePhaseSearchWindow; + assist->acq[i].prn = e->svid + 1; + assist->acq[i].parts = 0; + assist->acq[i].doppler0 = e->doppler0; - if (e->addionalAngle) { - assist->acq[i].parts |= SUPL_ACQUIS_ANGLE; - assist->acq[i].az = e->addionalAngle->azimuth; - assist->acq[i].el = e->addionalAngle->elevation; - } - } - } + if (e->addionalDoppler) + { + assist->acq[i].parts |= SUPL_ACQUIS_DOPPLER; + assist->acq[i].doppler1 = e->addionalDoppler->doppler1; + assist->acq[i].d_win = e->addionalDoppler->dopplerUncertainty; + } - if (hdr->almanac) { - int n; + assist->acq[i].code_ph = e->codePhase; + assist->acq[i].code_ph_int = e->intCodePhase; + assist->acq[i].bit_num = e->gpsBitNumber; + assist->acq[i].code_ph_win = e->codePhaseSearchWindow; - for (n = 0; n < hdr->almanac->almanacList.list.count; n++) { - struct AlmanacElement *e = hdr->almanac->almanacList.list.array[n]; - int i = assist->cnt_alm++; + if (e->addionalAngle) + { + assist->acq[i].parts |= SUPL_ACQUIS_ANGLE; + assist->acq[i].az = e->addionalAngle->azimuth; + assist->acq[i].el = e->addionalAngle->elevation; + } + } + } - assist->alm[i].prn = e->satelliteID + 1; - assist->alm[i].e = e->almanacE; - assist->alm[i].toa = e->alamanacToa; // nice touch 3gpp - assist->alm[i].Ksii = e->almanacKsii; - assist->alm[i].OMEGA_dot = e->almanacOmegaDot; - assist->alm[i].A_sqrt = e->almanacAPowerHalf; - assist->alm[i].OMEGA_0 = e->almanacOmega0; - assist->alm[i].w = e->almanacW; - assist->alm[i].M0 = e->almanacM0; - assist->alm[i].AF0 = e->almanacAF0; - assist->alm[i].AF1 = e->almanacAF1; - } - } + if (hdr->almanac) + { + int n; - if (hdr->navigationModel) { - UncompressedEphemeris_t *ue; - int n; + for (n = 0; n < hdr->almanac->almanacList.list.count; n++) + { + struct AlmanacElement *e = hdr->almanac->almanacList.list.array[n]; + int i = assist->cnt_alm++; - for (n = 0; n < hdr->navigationModel->navModelList.list.count; n++) { - struct NavModelElement *e = hdr->navigationModel->navModelList.list.array[n]; - int i = assist->cnt_eph++; + assist->alm[i].prn = e->satelliteID + 1; + assist->alm[i].e = e->almanacE; + assist->alm[i].toa = e->alamanacToa; // nice touch 3gpp + assist->alm[i].Ksii = e->almanacKsii; + assist->alm[i].OMEGA_dot = e->almanacOmegaDot; + assist->alm[i].A_sqrt = e->almanacAPowerHalf; + assist->alm[i].OMEGA_0 = e->almanacOmega0; + assist->alm[i].w = e->almanacW; + assist->alm[i].M0 = e->almanacM0; + assist->alm[i].AF0 = e->almanacAF0; + assist->alm[i].AF1 = e->almanacAF1; + } + } - assist->eph[i].prn = e->satelliteID + 1; + if (hdr->navigationModel) + { + UncompressedEphemeris_t *ue; + int n; - /* what is the difference between these two */ - ue = 0; - if (e->satStatus.present == SatStatus_PR_newNaviModelUC) - ue = &e->satStatus.choice.newNaviModelUC; - if (e->satStatus.present == SatStatus_PR_newSatelliteAndModelUC) - ue = &e->satStatus.choice.newSatelliteAndModelUC; + for (n = 0; n < hdr->navigationModel->navModelList.list.count; n++) + { + struct NavModelElement *e = hdr->navigationModel->navModelList.list.array[n]; + int i = assist->cnt_eph++; - if (ue) { + assist->eph[i].prn = e->satelliteID + 1; + + /* what is the difference between these two */ + ue = 0; + if (e->satStatus.present == SatStatus_PR_newNaviModelUC) + { + ue = &e->satStatus.choice.newNaviModelUC; + } + if (e->satStatus.present == SatStatus_PR_newSatelliteAndModelUC) + { + ue = &e->satStatus.choice.newSatelliteAndModelUC; + } + + if (ue) + { #if 0 assist->eph_x[i].L2P = ue->ephemL2Pflag; assist->eph_x[i].fit = ue->ephemFitFlag; #endif - assist->eph[i].delta_n = ue->ephemDeltaN; - assist->eph[i].M0 = ue->ephemM0; + assist->eph[i].delta_n = ue->ephemDeltaN; + assist->eph[i].M0 = ue->ephemM0; #if 0 // this is needed for asn1c version 0.9.22 { @@ -700,253 +807,288 @@ int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval assist->eph[i].e = v; } #else - assist->eph[i].e = ue->ephemE; - assist->eph[i].A_sqrt = ue->ephemAPowerHalf; + assist->eph[i].e = ue->ephemE; + assist->eph[i].A_sqrt = ue->ephemAPowerHalf; #endif - assist->eph[i].OMEGA_0 = ue->ephemOmegaA0; - assist->eph[i].i0 = ue->ephemI0; - assist->eph[i].w = ue->ephemW; - assist->eph[i].OMEGA_dot = ue->ephemOmegaADot; - assist->eph[i].i_dot = ue->ephemIDot; - assist->eph[i].Cuc = ue->ephemCuc; - assist->eph[i].Cus = ue->ephemCus; - assist->eph[i].Crc = ue->ephemCrc; - assist->eph[i].Crs = ue->ephemCrs; - assist->eph[i].Cic = ue->ephemCic; - assist->eph[i].Cis = ue->ephemCis; - assist->eph[i].toe = ue->ephemToe; - assist->eph[i].IODC = ue->ephemIODC; - assist->eph[i].toc = ue->ephemToc; - assist->eph[i].AF0 = ue->ephemAF0; - assist->eph[i].AF1 = ue->ephemAF1; - assist->eph[i].AF2 = ue->ephemAF2; + assist->eph[i].OMEGA_0 = ue->ephemOmegaA0; + assist->eph[i].i0 = ue->ephemI0; + assist->eph[i].w = ue->ephemW; + assist->eph[i].OMEGA_dot = ue->ephemOmegaADot; + assist->eph[i].i_dot = ue->ephemIDot; + assist->eph[i].Cuc = ue->ephemCuc; + assist->eph[i].Cus = ue->ephemCus; + assist->eph[i].Crc = ue->ephemCrc; + assist->eph[i].Crs = ue->ephemCrs; + assist->eph[i].Cic = ue->ephemCic; + assist->eph[i].Cis = ue->ephemCis; + assist->eph[i].toe = ue->ephemToe; + assist->eph[i].IODC = ue->ephemIODC; + assist->eph[i].toc = ue->ephemToc; + assist->eph[i].AF0 = ue->ephemAF0; + assist->eph[i].AF1 = ue->ephemAF1; + assist->eph[i].AF2 = ue->ephemAF2; - assist->eph[i].nav_model = 1; - assist->eph[i].bits = ue->ephemCodeOnL2; - assist->eph[i].ura = ue->ephemURA; - assist->eph[i].health = ue->ephemSVhealth; - assist->eph[i].AODA = ue->ephemAODA; - assist->eph[i].tgd = ue->ephemTgd; - } - } - } + assist->eph[i].nav_model = 1; + assist->eph[i].bits = ue->ephemCodeOnL2; + assist->eph[i].ura = ue->ephemURA; + assist->eph[i].health = ue->ephemSVhealth; + assist->eph[i].AODA = ue->ephemAODA; + assist->eph[i].tgd = ue->ephemTgd; + } + } + } - if (hdr->ionosphericModel) { - assist->set |= SUPL_RRLP_ASSIST_IONO; - assist->iono.a0 = hdr->ionosphericModel->alfa0; - assist->iono.a1 = hdr->ionosphericModel->alfa1; - assist->iono.a2 = hdr->ionosphericModel->alfa2; - assist->iono.a3 = hdr->ionosphericModel->alfa3; //missed in original supl client - assist->iono.b0 = hdr->ionosphericModel->beta0; - assist->iono.b1 = hdr->ionosphericModel->beta1; - assist->iono.b2 = hdr->ionosphericModel->beta2; - assist->iono.b3 = hdr->ionosphericModel->beta3; - } + if (hdr->ionosphericModel) + { + assist->set |= SUPL_RRLP_ASSIST_IONO; + assist->iono.a0 = hdr->ionosphericModel->alfa0; + assist->iono.a1 = hdr->ionosphericModel->alfa1; + assist->iono.a2 = hdr->ionosphericModel->alfa2; + assist->iono.a3 = hdr->ionosphericModel->alfa3; //missed in original supl client + assist->iono.b0 = hdr->ionosphericModel->beta0; + assist->iono.b1 = hdr->ionosphericModel->beta1; + assist->iono.b2 = hdr->ionosphericModel->beta2; + assist->iono.b3 = hdr->ionosphericModel->beta3; + } - if (hdr->utcModel) { - assist->set |= SUPL_RRLP_ASSIST_UTC; - assist->utc.a0 = hdr->utcModel->utcA0; - assist->utc.a1 = hdr->utcModel->utcA1; - assist->utc.tot = hdr->utcModel->utcTot; - assist->utc.wnt = hdr->utcModel->utcWNt; - assist->utc.delta_tls = hdr->utcModel->utcDeltaTls; - assist->utc.wnlsf = hdr->utcModel->utcWNlsf; - assist->utc.dn = hdr->utcModel->utcDN; - assist->utc.delta_tlsf = hdr->utcModel->utcDeltaTlsf; - } + if (hdr->utcModel) + { + assist->set |= SUPL_RRLP_ASSIST_UTC; + assist->utc.a0 = hdr->utcModel->utcA0; + assist->utc.a1 = hdr->utcModel->utcA1; + assist->utc.tot = hdr->utcModel->utcTot; + assist->utc.wnt = hdr->utcModel->utcWNt; + assist->utc.delta_tls = hdr->utcModel->utcDeltaTls; + assist->utc.wnlsf = hdr->utcModel->utcWNlsf; + assist->utc.dn = hdr->utcModel->utcDN; + assist->utc.delta_tlsf = hdr->utcModel->utcDeltaTlsf; + } - return 1; + return 1; } -int EXPORT supl_ctx_new(supl_ctx_t *ctx) { - memset(ctx, 0, sizeof(supl_ctx_t)); + +int EXPORT supl_ctx_new(supl_ctx_t *ctx) +{ + memset(ctx, 0, sizeof(supl_ctx_t)); #ifdef SUPL_DEBUG - memset(&debug, 0, sizeof(struct supl_debug_s)); + memset(&debug, 0, sizeof(struct supl_debug_s)); #endif - return 0; + return 0; } -int EXPORT supl_ctx_free(supl_ctx_t *ctx) { - if (ctx->slp_session_id.buf) { - free(ctx->slp_session_id.buf); - ctx->slp_session_id.buf = 0; - } - return 0; +int EXPORT supl_ctx_free(supl_ctx_t *ctx) +{ + if (ctx->slp_session_id.buf) + { + free(ctx->slp_session_id.buf); + ctx->slp_session_id.buf = 0; + } + + return 0; } -static int supl_more_rrlp(PDU_t *rrlp) { - long value; - return (rrlp->component.present == RRLP_Component_PR_assistanceData && - rrlp->component.choice.assistanceData.moreAssDataToBeSent && - asn_INTEGER2long((INTEGER_t *)rrlp->component.choice.assistanceData.moreAssDataToBeSent, &value) == 0 && - value == MoreAssDataToBeSent_moreMessagesOnTheWay); +static int supl_more_rrlp(PDU_t *rrlp) +{ + long value; + + return (rrlp->component.present == RRLP_Component_PR_assistanceData && + rrlp->component.choice.assistanceData.moreAssDataToBeSent && + asn_INTEGER2long((INTEGER_t *)rrlp->component.choice.assistanceData.moreAssDataToBeSent, &value) == 0 && + value == MoreAssDataToBeSent_moreMessagesOnTheWay); } -int EXPORT supl_get_assist(supl_ctx_t *ctx, char *server, supl_assist_t *assist) { - supl_ulp_t ulp; - // memcpy(ctx->p.msisdn, "\xde\xad\xbe\xef\xf0\x0b\xaa\x42", 8); - memcpy(ctx->p.msisdn, "\xFF\xFF\x91\x94\x48\x45\x83\x98", 8); +int EXPORT supl_get_assist(supl_ctx_t *ctx, char *server, supl_assist_t *assist) +{ + supl_ulp_t ulp; - /* + // memcpy(ctx->p.msisdn, "\xde\xad\xbe\xef\xf0\x0b\xaa\x42", 8); + memcpy(ctx->p.msisdn, "\xFF\xFF\x91\x94\x48\x45\x83\x98", 8); + + /* ** connect to server */ - if (supl_server_connect(ctx, server) < 0) return E_SUPL_CONNECT; + if (supl_server_connect(ctx, server) < 0) + { + return E_SUPL_CONNECT; + } - /* + /* ** send SUPL_START */ - if (pdu_make_ulp_start(ctx, &ulp) < 0) { - return E_SUPL_ENCODE_START; - } + if (pdu_make_ulp_start(ctx, &ulp) < 0) + { + return E_SUPL_ENCODE_START; + } - (void)supl_ulp_send(ctx, &ulp); - supl_ulp_free(&ulp); + (void)supl_ulp_send(ctx, &ulp); + supl_ulp_free(&ulp); - /* + /* ** should receive SUPL_RESPONSE back */ - if (supl_ulp_recv(ctx, &ulp) < 0) { - return E_SUPL_RECV_RESPONSE; - } + if (supl_ulp_recv(ctx, &ulp) < 0) + { + return E_SUPL_RECV_RESPONSE; + } + + if (ulp.pdu->message.present != UlpMessage_PR_msSUPLRESPONSE) + { + supl_ulp_free(&ulp); + return E_SUPL_SUPLRESPONSE; + } + + // get and copy slpSessionID if present + supl_response_harvest(ctx, &ulp); - if (ulp.pdu->message.present != UlpMessage_PR_msSUPLRESPONSE) { supl_ulp_free(&ulp); - return E_SUPL_SUPLRESPONSE; - } - // get and copy slpSessionID if present - supl_response_harvest(ctx, &ulp); - - supl_ulp_free(&ulp); - - /* + /* ** send SUPL_POS_INIT */ - if (pdu_make_ulp_pos_init(ctx, &ulp) < 0) { - return E_SUPL_ENCODE_POSINIT; - } + if (pdu_make_ulp_pos_init(ctx, &ulp) < 0) + { + return E_SUPL_ENCODE_POSINIT; + } - (void)supl_ulp_send(ctx, &ulp); + (void)supl_ulp_send(ctx, &ulp); - /* + /* ** should get SUPLPOS back - bounce back and forth until all messages have arrived */ - memset(assist, 0, sizeof(supl_assist_t)); + memset(assist, 0, sizeof(supl_assist_t)); - while (1) { - struct timeval t; - PDU_t *rrlp; + while (1) + { + struct timeval t; + PDU_t *rrlp; + + supl_ulp_free(&ulp); + + /* record packet recv time */ + gettimeofday(&t, 0); + + if (supl_ulp_recv(ctx, &ulp) < 0) + { + return E_SUPL_RECV_SUPLPOS; + } + + if (ulp.pdu->message.present == UlpMessage_PR_msSUPLEND) + { + break; + } + + if (ulp.pdu->message.present != UlpMessage_PR_msSUPLPOS) + { + supl_ulp_free(&ulp); + return E_SUPL_SUPLPOS; + } + + /* get the beef, the RRLP payload */ + + if (supl_decode_rrlp(&ulp, &rrlp) < 0) + { + supl_ulp_free(&ulp); + return E_SUPL_DECODE_RRLP; + } + +#ifdef SUPL_DEBUG + if (debug.verbose_rrlp) + { + fprintf(debug.log, "Embedded RRLP message\n"); + xer_fprint(debug.log, &asn_DEF_PDU, rrlp); + } +#endif + + /* remember important stuff from it */ + + supl_collect_rrlp(assist, rrlp, &t); + + if (!supl_more_rrlp(rrlp)) + { + asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + break; + } + + /* More data coming in, send SUPLPOS + RRLP ACK */ + + if (pdu_make_ulp_rrlp_ack(ctx, &ulp, rrlp) < 0) + { + return E_SUPL_RRLP_ACK; + } + + supl_ulp_send(ctx, &ulp); + asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + } supl_ulp_free(&ulp); - /* record packet recv time */ - gettimeofday(&t, 0); - - if (supl_ulp_recv(ctx, &ulp) < 0) { - return E_SUPL_RECV_SUPLPOS; - } - - if (ulp.pdu->message.present == UlpMessage_PR_msSUPLEND) { - break; - } - - if (ulp.pdu->message.present != UlpMessage_PR_msSUPLPOS) { - supl_ulp_free(&ulp); - return E_SUPL_SUPLPOS; - } - - /* get the beef, the RRLP payload */ - - if (supl_decode_rrlp(&ulp, &rrlp) < 0) { - supl_ulp_free(&ulp); - return E_SUPL_DECODE_RRLP; - } - -#ifdef SUPL_DEBUG - if (debug.verbose_rrlp) { - fprintf(debug.log, "Embedded RRLP message\n"); - xer_fprint(debug.log, &asn_DEF_PDU, rrlp); - } -#endif - - /* remember important stuff from it */ - - supl_collect_rrlp(assist, rrlp, &t); - - if (!supl_more_rrlp(rrlp)) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - break; - } - - /* More data coming in, send SUPLPOS + RRLP ACK */ - - if (pdu_make_ulp_rrlp_ack(ctx, &ulp, rrlp) < 0) { - return E_SUPL_RRLP_ACK; - } - - supl_ulp_send(ctx, &ulp); - asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - } - - supl_ulp_free(&ulp); - - /* + /* ** send SUPL_END (but who really cares) */ - supl_close(ctx); + supl_close(ctx); - return 0; + return 0; } -void EXPORT supl_set_gsm_cell(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci) { - ctx->p.set |= PARAM_GSM_CELL_CURRENT; - ctx->p.gsm.mcc = mcc; - ctx->p.gsm.mnc = mns; - ctx->p.gsm.lac = lac; - ctx->p.gsm.ci = ci; +void EXPORT supl_set_gsm_cell(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci) +{ + ctx->p.set |= PARAM_GSM_CELL_CURRENT; + + ctx->p.gsm.mcc = mcc; + ctx->p.gsm.mnc = mns; + ctx->p.gsm.lac = lac; + ctx->p.gsm.ci = ci; } -void EXPORT supl_set_gsm_cell_known(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci, double lat, double lon, int uncert) { - ctx->p.set |= PARAM_GSM_CELL_KNOWN; - ctx->p.known.mcc = mcc; - ctx->p.known.mnc = mns; - ctx->p.known.lac = lac; - ctx->p.known.ci = ci; - ctx->p.known.lat = lat; - ctx->p.known.lon = lon; - ctx->p.known.uncert = uncert; +void EXPORT supl_set_gsm_cell_known(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci, double lat, double lon, int uncert) +{ + ctx->p.set |= PARAM_GSM_CELL_KNOWN; + + ctx->p.known.mcc = mcc; + ctx->p.known.mnc = mns; + ctx->p.known.lac = lac; + ctx->p.known.ci = ci; + ctx->p.known.lat = lat; + ctx->p.known.lon = lon; + ctx->p.known.uncert = uncert; } -void EXPORT supl_set_wcdma_cell(supl_ctx_t *ctx, int mcc, int mns, int uc) { - ctx->p.set |= PARAM_WCDMA_CELL_CURRENT; - ctx->p.wcdma.mcc = mcc; - ctx->p.wcdma.mnc = mns; - ctx->p.wcdma.uc = uc; +void EXPORT supl_set_wcdma_cell(supl_ctx_t *ctx, int mcc, int mns, int uc) +{ + ctx->p.set |= PARAM_WCDMA_CELL_CURRENT; + + ctx->p.wcdma.mcc = mcc; + ctx->p.wcdma.mnc = mns; + ctx->p.wcdma.uc = uc; } -void EXPORT supl_request(supl_ctx_t *ctx, int request) { - ctx->p.request = request; + +void EXPORT supl_request(supl_ctx_t *ctx, int request) +{ + ctx->p.request = request; } -void EXPORT supl_set_debug(FILE *log, int flags) { + +void EXPORT supl_set_debug(FILE *log, int flags) +{ #ifdef SUPL_DEBUG - debug.log = log; - if (flags & SUPL_DEBUG_RRLP) debug.verbose_rrlp = 1; - if (flags & SUPL_DEBUG_SUPL) debug.verbose_supl = 1; - if (flags & SUPL_DEBUG_DEBUG) debug.debug = 1; + debug.log = log; + if (flags & SUPL_DEBUG_RRLP) debug.verbose_rrlp = 1; + if (flags & SUPL_DEBUG_SUPL) debug.verbose_supl = 1; + if (flags & SUPL_DEBUG_DEBUG) debug.debug = 1; #endif } - diff --git a/src/core/libs/supl/supl.h b/src/core/libs/supl/supl.h index 3761eda24..2f997d6f3 100644 --- a/src/core/libs/supl/supl.h +++ b/src/core/libs/supl/supl.h @@ -17,7 +17,7 @@ #else #define EXPORT #endif - +// clang-format off #if USE_OPENSSL_FALLBACK #include #include @@ -31,7 +31,7 @@ #include #include #endif - +// clang-format on #include #include @@ -243,7 +243,7 @@ void supl_set_wcdma_cell(supl_ctx_t *ctx, int mcc, int mns, int uc); void supl_set_gsm_cell_known(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci, double lat, double lon, int uncert); void supl_set_server(supl_ctx_t *ctx, char *server); void supl_set_fd(supl_ctx_t *ctx, int fd); -void supl_request(supl_ctx_t *ctx, int flags); +void supl_request(supl_ctx_t *ctx, int request); int supl_get_assist(supl_ctx_t *ctx, char *server, supl_assist_t *assist); void supl_set_debug(FILE *log, int flags); diff --git a/src/core/monitor/CMakeLists.txt b/src/core/monitor/CMakeLists.txt new file mode 100644 index 000000000..4549006c4 --- /dev/null +++ b/src/core/monitor/CMakeLists.txt @@ -0,0 +1,71 @@ +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . +# + + +set(CORE_MONITOR_LIBS_SOURCES + gnss_synchro_monitor.cc + gnss_synchro_udp_sink.cc +) + +set(CORE_MONITOR_LIBS_HEADERS + gnss_synchro_monitor.h + gnss_synchro_udp_sink.h +) + +list(SORT CORE_MONITOR_LIBS_HEADERS) +list(SORT CORE_MONITOR_LIBS_SOURCES) + +source_group(Headers FILES ${CORE_MONITOR_LIBS_HEADERS}) + +add_library(core_monitor + ${CORE_MONITOR_LIBS_SOURCES} + ${CORE_MONITOR_LIBS_HEADERS} +) + +target_link_libraries(core_monitor + PUBLIC + Boost::serialization + Boost::system + Gnuradio::runtime + core_system_parameters + PRIVATE + Gnuradio::pmt +) + +if(OS_IS_MACOSX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # not AppleClang + target_compile_definitions(core_monitor + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW + ) + endif() +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(core_monitor + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET core_monitor + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/core/monitor/gnss_synchro_monitor.cc b/src/core/monitor/gnss_synchro_monitor.cc new file mode 100644 index 000000000..d52fb10d7 --- /dev/null +++ b/src/core/monitor/gnss_synchro_monitor.cc @@ -0,0 +1,91 @@ +/*! + * \file gnss_synchro_monitor.cc + * \brief Implementation of a receiver monitoring block which allows sending + * a data stream with the receiver internal parameters (Gnss_Synchro objects) + * to local or remote clients over UDP. + * + * \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "gnss_synchro_monitor.h" +#include "gnss_synchro.h" +#include +#include +#include + + +gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int n_channels, + int decimation_factor, + int udp_port, + const std::vector& udp_addresses) +{ + return gnss_synchro_monitor_sptr(new gnss_synchro_monitor(n_channels, + decimation_factor, + udp_port, + udp_addresses)); +} + + +gnss_synchro_monitor::gnss_synchro_monitor(unsigned int n_channels, + int decimation_factor, + int udp_port, + const std::vector& udp_addresses) : gr::sync_block("gnss_synchro_monitor", + gr::io_signature::make(n_channels, n_channels, sizeof(Gnss_Synchro)), + gr::io_signature::make(0, 0, 0)) +{ + d_decimation_factor = decimation_factor; + d_nchannels = n_channels; + + udp_sink_ptr = std::unique_ptr(new Gnss_Synchro_Udp_Sink(udp_addresses, udp_port)); + + count = 0; +} + + +gnss_synchro_monitor::~gnss_synchro_monitor() = default; + + +int gnss_synchro_monitor::work(int noutput_items, gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items __attribute__((unused))) +{ + const auto** in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer + for (int epoch = 0; epoch < noutput_items; epoch++) + { + count++; + if (count >= d_decimation_factor) + { + for (unsigned int i = 0; i < d_nchannels; i++) + { + std::vector stocks; + stocks.push_back(in[i][epoch]); + udp_sink_ptr->write_gnss_synchro(stocks); + } + count = 0; + } + } + return noutput_items; +} diff --git a/src/core/monitor/gnss_synchro_monitor.h b/src/core/monitor/gnss_synchro_monitor.h new file mode 100644 index 000000000..632fa72ed --- /dev/null +++ b/src/core/monitor/gnss_synchro_monitor.h @@ -0,0 +1,85 @@ +/*! + * \file gnss_synchro_monitor.h + * \brief Interface of a receiver monitoring block which allows sending + * a data stream with the receiver internal parameters (Gnss_Synchro objects) + * to local or remote clients over UDP. + * + * \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GNSS_SYNCHRO_MONITOR_H +#define GNSS_SDR_GNSS_SYNCHRO_MONITOR_H + +#include "gnss_synchro_udp_sink.h" +#include +#include +#include +#include + + +class gnss_synchro_monitor; + +using gnss_synchro_monitor_sptr = boost::shared_ptr; + +gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int n_channels, + int decimation_factor, + int udp_port, + const std::vector& udp_addresses); + +/*! + * \brief This class implements a block that computes the PVT solution with Galileo E1 signals + */ +class gnss_synchro_monitor : public gr::sync_block +{ +private: + friend gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int n_channels, + int decimation_factor, + int udp_port, + const std::vector& udp_addresses); + + unsigned int d_nchannels; + + int d_decimation_factor; + + std::unique_ptr udp_sink_ptr; + + int count; + + +public: + gnss_synchro_monitor(unsigned int n_channels, + int decimation_factor, + int udp_port, + const std::vector& udp_addresses); + + ~gnss_synchro_monitor(); //!< Default destructor + + int work(int noutput_items, gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items); +}; + +#endif diff --git a/src/core/monitor/gnss_synchro_udp_sink.cc b/src/core/monitor/gnss_synchro_udp_sink.cc new file mode 100644 index 000000000..2978537ea --- /dev/null +++ b/src/core/monitor/gnss_synchro_udp_sink.cc @@ -0,0 +1,69 @@ +/*! + * \file gnss_synchro_udp_sink.cc + * \brief Implementation of a class that sends serialized Gnss_Synchro + * objects over udp to one or multiple endponits + * \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "gnss_synchro_udp_sink.h" +#include +#include +#include +#include + +Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(std::vector addresses, const uint16_t& port) : socket{io_service} +{ + for (const auto& address : addresses) + { + boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port); + endpoints.push_back(endpoint); + } +} + +bool Gnss_Synchro_Udp_Sink::write_gnss_synchro(const std::vector& stocks) +{ + std::ostringstream archive_stream; + boost::archive::binary_oarchive oa{archive_stream}; + oa << stocks; + std::string outbound_data = archive_stream.str(); + + for (const auto& endpoint : endpoints) + { + socket.open(endpoint.protocol(), error); + socket.connect(endpoint, error); + + try + { + socket.send(boost::asio::buffer(outbound_data)); + } + catch (boost::system::system_error const& e) + { + return false; + } + } + return true; +} diff --git a/src/core/monitor/gnss_synchro_udp_sink.h b/src/core/monitor/gnss_synchro_udp_sink.h new file mode 100644 index 000000000..d72b2f18a --- /dev/null +++ b/src/core/monitor/gnss_synchro_udp_sink.h @@ -0,0 +1,57 @@ +/*! + * \file gnss_synchro_udp_sink.h + * \brief Interface of a class that sends serialized Gnss_Synchro objects + * over udp to one or multiple endponits + * \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GNSS_SYNCHRO_UDP_SINK_H_ +#define GNSS_SDR_GNSS_SYNCHRO_UDP_SINK_H_ + +#include "gnss_synchro.h" +#include +#include +#include +#include + + +class Gnss_Synchro_Udp_Sink +{ +public: + Gnss_Synchro_Udp_Sink(std::vector addresses, const uint16_t& port); + bool write_gnss_synchro(const std::vector& stocks); + +private: + boost::asio::io_service io_service; + boost::asio::ip::udp::socket socket; + boost::system::error_code error; + std::vector endpoints; + std::vector stocks; +}; + + +#endif /* GNSS_SDR_GNSS_SYNCHRO_UDP_SINK_H_ */ diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index 09b24de96..a9225792d 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -18,161 +18,187 @@ set(GNSS_RECEIVER_SOURCES - control_thread.cc - control_message_factory.cc - file_configuration.cc - gnss_block_factory.cc - gnss_flowgraph.cc - in_memory_configuration.cc + control_thread.cc + control_message_factory.cc + file_configuration.cc + gnss_block_factory.cc + gnss_flowgraph.cc + in_memory_configuration.cc + tcp_cmd_interface.cc ) - -if(PC_GNURADIO_RUNTIME_VERSION VERSION_GREATER 3.7.3) - add_definitions(-DMODERN_GNURADIO=1) -endif(PC_GNURADIO_RUNTIME_VERSION VERSION_GREATER 3.7.3) +set(GNSS_RECEIVER_HEADERS + control_thread.h + control_message_factory.h + file_configuration.h + gnss_block_factory.h + gnss_flowgraph.h + in_memory_configuration.h + tcp_cmd_interface.h + concurrent_map.h + concurrent_queue.h + control_message.h +) if(ENABLE_CUDA) - add_definitions(-DCUDA_GPU_ACCEL=1) - set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS}) -endif(ENABLE_CUDA) + set(OPT_RECEIVER_INCLUDE_DIRS + ${OPT_RECEIVER_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS} + ) +endif() + +list(SORT GNSS_RECEIVER_HEADERS) +list(SORT GNSS_RECEIVER_SOURCES) + +set(GNSS_RECEIVER_INTERFACE_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/acquisition_interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/channel_interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/configuration_interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/gnss_block_interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/observables_interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/pvt_interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/telemetry_decoder_interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/tracking_interface.h +) + +list(SORT GNSS_RECEIVER_INTERFACE_HEADERS) + +source_group(Headers FILES ${GNSS_RECEIVER_HEADERS} + ${GNSS_RECEIVER_INTERFACE_HEADERS} +) + +add_library(core_receiver + ${GNSS_RECEIVER_SOURCES} + ${GNSS_RECEIVER_HEADERS} + ${GNSS_RECEIVER_INTERFACE_HEADERS} +) if(ENABLE_FPGA) - add_definitions(-DENABLE_FPGA=1) -endif(ENABLE_FPGA) + target_compile_definitions(core_receiver PUBLIC -DENABLE_FPGA=1) +endif() +if(ENABLE_RAW_UDP) + target_compile_definitions(core_receiver PRIVATE -DRAW_UDP=1) +endif() -if(Boost_VERSION LESS 105000) - add_definitions(-DOLD_BOOST=1) -endif(Boost_VERSION LESS 105000) +if(PC_GNURADIO_RUNTIME_VERSION VERSION_GREATER 3.7.3) + target_compile_definitions(core_receiver PRIVATE -DMODERN_GNURADIO=1) +endif() -if(OPENSSL_FOUND) - add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) -endif(OPENSSL_FOUND) +if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13.4") + target_compile_definitions(core_receiver PRIVATE -DGR_GREATER_38=1) +endif() -if(ENABLE_GN3S) - add_definitions(-DGN3S_DRIVER=1) -endif(ENABLE_GN3S) +if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) + target_compile_definitions(core_receiver PRIVATE -DUHD_DRIVER=1) +endif() -if(ENABLE_ARRAY) - add_definitions(-DRAW_ARRAY_DRIVER=1) -endif(ENABLE_ARRAY) +if(ENABLE_PLUTOSDR) + target_compile_definitions(core_receiver PRIVATE -DPLUTOSDR_DRIVER=1) +endif() -if(ENABLE_FLEXIBAND) - add_definitions(-DFLEXIBAND_DRIVER=1) -endif(ENABLE_FLEXIBAND) +if(ENABLE_FMCOMMS2) + target_compile_definitions(core_receiver PRIVATE -DFMCOMMS2_DRIVER=1) +endif() + +if(ENABLE_AD9361) + target_compile_definitions(core_receiver PRIVATE -DAD9361_DRIVER=1) +endif() if(ENABLE_OSMOSDR) if(GROSMOSDR_FOUND) - add_definitions(-DOSMOSDR_DRIVER=1) - endif(GROSMOSDR_FOUND) -endif(ENABLE_OSMOSDR) + target_compile_definitions(core_receiver PRIVATE -DOSMOSDR_DRIVER=1) + endif() +endif() -if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) - add_definitions(-DUHD_DRIVER=1) -endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) +if(ENABLE_GN3S) + target_compile_definitions(core_receiver PRIVATE -DGN3S_DRIVER=1) +endif() + +if(ENABLE_ARRAY) + target_compile_definitions(core_receiver PRIVATE -DRAW_ARRAY_DRIVER=1) +endif() + +if(ENABLE_FLEXIBAND) + target_compile_definitions(core_receiver PRIVATE -DFLEXIBAND_DRIVER=1) +endif() -#Enable OpenCL if found in the system if(OPENCL_FOUND) - message(STATUS "Adding processing blocks implemented using OpenCL" ) - add_definitions(-DOPENCL_BLOCKS=1) -else(OPENCL_FOUND) - add_definitions(-DOPENCL_BLOCKS=0) -endif(OPENCL_FOUND) + message(STATUS "Adding processing blocks implemented using OpenCL") + target_compile_definitions(core_receiver PRIVATE -DOPENCL_BLOCKS=1) +else() + target_compile_definitions(core_receiver PRIVATE -DOPENCL_BLOCKS=0) +endif() -#enable SDR Hardware based on fmcomms2 -if(ENABLE_PLUTOSDR) - add_definitions(-DPLUTOSDR_DRIVER=1) - set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) -endif(ENABLE_PLUTOSDR) - -if(ENABLE_FMCOMMS2) - add_definitions(-DFMCOMMS2_DRIVER=1) - set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) -endif(ENABLE_FMCOMMS2) - -if(ENABLE_AD9361) - add_definitions(-DAD9361_DRIVER=1) - set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) -endif(ENABLE_AD9361) - -if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) - add_definitions( -DGR_GREATER_38=1 ) -endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) +if(ENABLE_CUDA) + target_compile_definitions(core_receiver PRIVATE -DCUDA_GPU_ACCEL=1) +endif() -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/libs - ${CMAKE_SOURCE_DIR}/src/core/libs/supl - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/channel/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/channel/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/conditioner/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/resampler/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/libs/libswiftcnav - ${CMAKE_SOURCE_DIR}/src/algorithms/observables/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/observables/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib - ${ARMADILLO_INCLUDE_DIRS} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${OPT_RECEIVER_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} +target_link_libraries(core_receiver + PUBLIC + Armadillo::armadillo + Boost::boost + Boost::thread + Gnuradio::runtime + core_libs + core_monitor + PRIVATE + Gflags::gflags + Glog::glog + signal_source_adapters + data_type_adapters + input_filter_adapters + conditioner_adapters + resampler_adapters + acquisition_adapters + tracking_adapters + channel_adapters + telemetry_decoder_adapters + obs_adapters + pvt_adapters ) -file(GLOB GNSS_RECEIVER_HEADERS "*.h") -list(SORT GNSS_RECEIVER_HEADERS) -file(GLOB GNSS_RECEIVER_INTERFACE_HEADERS "../interfaces/*.h") -list(SORT GNSS_RECEIVER_INTERFACE_HEADERS) -add_library(gnss_rx ${GNSS_RECEIVER_SOURCES} ${GNSS_RECEIVER_HEADERS} ${GNSS_RECEIVER_INTERFACE_HEADERS}) -source_group(Headers FILES ${GNSS_RECEIVER_HEADERS} ${GNSS_RECEIVER_INTERFACE_HEADERS}) +if(OS_IS_MACOSX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # not AppleClang + target_compile_definitions(core_receiver + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW + ) + endif() +endif() -target_link_libraries(gnss_rx ${Boost_LIBRARIES} - ${ARMADILLO_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FFT_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - gnss_system_parameters - gnss_sp_libs - signal_source_adapters - datatype_adapters - input_filter_adapters - conditioner_adapters - resampler_adapters - acq_adapters - tracking_adapters - channel_adapters - telemetry_decoder_libswiftcnav - telemetry_decoder_lib - telemetry_decoder_adapters - obs_adapters - pvt_adapters - pvt_lib - rx_core_lib +if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND) + target_link_libraries(core_receiver + PRIVATE + Gnuradio::teleorbit + ) +endif() + +if(ENABLE_GN3S AND GRGN3S_FOUND) + target_link_libraries(core_receiver + PRIVATE + Gnuradio::gn3s + ) +endif() + +if(ENABLE_ARRAY AND GRDBFCTTC_FOUND) + target_link_libraries(core_receiver + PRIVATE + Gnuradio::dbfcttc + ) +endif() + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(core_receiver + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET core_receiver APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ + $ + $ ) diff --git a/src/core/receiver/concurrent_map.h b/src/core/receiver/concurrent_map.h index 7df929b82..af3823bd1 100644 --- a/src/core/receiver/concurrent_map.h +++ b/src/core/receiver/concurrent_map.h @@ -43,7 +43,7 @@ template * \brief This class implements a thread-safe std::map * */ -class concurrent_map +class Concurrent_Map { typedef typename std::map::iterator Data_iterator; // iterator is scope dependent private: @@ -94,11 +94,8 @@ public: lock.unlock(); return true; } - else - { - lock.unlock(); - return false; - } + lock.unlock(); + return false; } }; diff --git a/src/core/receiver/concurrent_queue.h b/src/core/receiver/concurrent_queue.h index 3a4e89190..02c6dd896 100644 --- a/src/core/receiver/concurrent_queue.h +++ b/src/core/receiver/concurrent_queue.h @@ -43,7 +43,7 @@ template * boost_thread to perform MUTEX based on the code available at * http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html */ -class concurrent_queue +class Concurrent_Queue { private: std::queue the_queue; diff --git a/src/core/receiver/control_message_factory.cc b/src/core/receiver/control_message_factory.cc index 2210713c9..435a9a6d6 100644 --- a/src/core/receiver/control_message_factory.cc +++ b/src/core/receiver/control_message_factory.cc @@ -35,11 +35,11 @@ using google::LogMessage; // Constructor -ControlMessageFactory::ControlMessageFactory() {} +ControlMessageFactory::ControlMessageFactory() = default; // Destructor -ControlMessageFactory::~ControlMessageFactory() {} +ControlMessageFactory::~ControlMessageFactory() = default; gr::message::sptr ControlMessageFactory::GetQueueMessage(unsigned int who, unsigned int what) @@ -53,7 +53,7 @@ gr::message::sptr ControlMessageFactory::GetQueueMessage(unsigned int who, unsig } -std::shared_ptr>> ControlMessageFactory::GetControlMessages(gr::message::sptr queue_message) +std::shared_ptr>> ControlMessageFactory::GetControlMessages(const gr::message::sptr queue_message) // NOLINT(performance-unnecessary-value-param) { std::shared_ptr>> control_messages = std::make_shared>>(); unsigned int control_messages_count = queue_message->length() / sizeof(ControlMessage); diff --git a/src/core/receiver/control_message_factory.h b/src/core/receiver/control_message_factory.h index 53339cea5..f8a4666f6 100644 --- a/src/core/receiver/control_message_factory.h +++ b/src/core/receiver/control_message_factory.h @@ -36,7 +36,7 @@ #include //! Message described by who sent it and what it says -typedef struct ControlMessage_ +typedef struct control_message { unsigned int who; unsigned int what; @@ -58,7 +58,7 @@ public: virtual ~ControlMessageFactory(); gr::message::sptr GetQueueMessage(unsigned int who, unsigned int what); - std::shared_ptr>> GetControlMessages(gr::message::sptr queue_message); + std::shared_ptr>> GetControlMessages(const gr::message::sptr queue_message); // NOLINT(performance-unnecessary-value-param) }; #endif /*GNSS_SDR_CONTROL_MESSAGE_FACTORY_H_*/ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 0710da730..4e66f110d 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -33,43 +33,52 @@ */ #include "control_thread.h" -#include "concurrent_queue.h" #include "concurrent_map.h" +#include "concurrent_queue.h" #include "control_message_factory.h" #include "file_configuration.h" -#include "gnss_flowgraph.h" -#include "gnss_sdr_flags.h" +#include "galileo_almanac.h" #include "galileo_ephemeris.h" #include "galileo_iono.h" #include "galileo_utc_model.h" -#include "galileo_almanac.h" +#include "geofunctions.h" +#include "glonass_gnav_ephemeris.h" +#include "glonass_gnav_utc_model.h" +#include "gnss_flowgraph.h" +#include "gnss_sdr_flags.h" +#include "gps_almanac.h" #include "gps_ephemeris.h" #include "gps_iono.h" #include "gps_utc_model.h" -#include "gps_almanac.h" +#include "pvt_interface.h" +#include "rtklib_conversions.h" +#include "rtklib_ephemeris.h" +#include "rtklib_rtkcmn.h" #include -#include #include #include -#include -#include -#include +#include +#include #include #include #include #include #include +#include +#include +#include +#include -extern concurrent_map global_gps_acq_assist_map; -extern concurrent_queue global_gps_acq_assist_queue; +extern Concurrent_Map global_gps_acq_assist_map; +extern Concurrent_Queue global_gps_acq_assist_queue; using google::LogMessage; ControlThread::ControlThread() { - if (!FLAGS_c.compare("-")) + if (FLAGS_c == "-") { configuration_ = std::make_shared(FLAGS_config_file); } @@ -78,372 +87,25 @@ ControlThread::ControlThread() configuration_ = std::make_shared(FLAGS_c); } delete_configuration_ = false; + restart_ = false; init(); } ControlThread::ControlThread(std::shared_ptr configuration) { - configuration_ = configuration; + configuration_ = std::move(configuration); delete_configuration_ = false; + restart_ = false; init(); } -ControlThread::~ControlThread() -{ - // save navigation data to files - // if (save_assistance_to_XML() == true) {} - if (msqid != -1) msgctl(msqid, IPC_RMID, NULL); -} - - -/* - * Runs the control thread that manages the receiver control plane - * - * This is the main loop that reads and process the control messages - * 1- Connect the GNSS receiver flowgraph - * 2- Start the GNSS receiver flowgraph - * while (flowgraph_->running() && !stop)_{ - * 3- Read control messages and process them } - */ -void ControlThread::run() -{ - // Connect the flowgraph - try - { - flowgraph_->connect(); - } - catch (const std::exception e) - { - LOG(ERROR) << e.what(); - return; - } - if (flowgraph_->connected()) - { - LOG(INFO) << "Flowgraph connected"; - } - else - { - LOG(ERROR) << "Unable to connect flowgraph"; - return; - } - // Start the flowgraph - flowgraph_->start(); - if (flowgraph_->running()) - { - LOG(INFO) << "Flowgraph started"; - } - else - { - LOG(ERROR) << "Unable to start flowgraph"; - return; - } - - //launch GNSS assistance process AFTER the flowgraph is running because the GNURadio asynchronous queues must be already running to transport msgs - assist_GNSS(); - // start the keyboard_listener thread - keyboard_thread_ = boost::thread(&ControlThread::keyboard_listener, this); - sysv_queue_thread_ = boost::thread(&ControlThread::sysv_queue_listener, this); - - bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false); - - if (enable_FPGA == true) - { - flowgraph_->start_acquisition_helper(); - } - - // Main loop to read and process the control messages - while (flowgraph_->running() && !stop_) - { - //TODO re-enable the blocking read messages functions and fork the process - read_control_messages(); - if (control_messages_ != 0) process_control_messages(); - } - std::cout << "Stopping GNSS-SDR, please wait!" << std::endl; - flowgraph_->stop(); - stop_ = true; - flowgraph_->disconnect(); - - //Join keyboard thread -#ifdef OLD_BOOST - keyboard_thread_.timed_join(boost::posix_time::seconds(1)); - sysv_queue_thread_.timed_join(boost::posix_time::seconds(1)); -#endif -#ifndef OLD_BOOST - keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); - sysv_queue_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); -#endif - - LOG(INFO) << "Flowgraph stopped"; -} - - -void ControlThread::set_control_queue(gr::msg_queue::sptr control_queue) -{ - if (flowgraph_->running()) - { - LOG(WARNING) << "Unable to set control queue while flowgraph is running"; - return; - } - control_queue_ = control_queue; -} - - -/* - * Returns true if reading was successful - */ -bool ControlThread::read_assistance_from_XML() -{ - // return variable (true == succeeded) - bool ret = false; - // getting names from the config file, if available - std::string eph_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename); - std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model.xml", utc_default_xml_filename); - std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename); - std::string ref_time_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_time_xml", ref_time_default_xml_filename); - std::string ref_location_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_location_xml", ref_location_default_xml_filename); - - std::cout << "SUPL: Try read GPS ephemeris from XML file " << eph_xml_filename << std::endl; - if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) - { - std::map::const_iterator gps_eph_iter; - for (gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.cbegin(); - gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend(); - gps_eph_iter++) - { - std::cout << "SUPL: Read XML Ephemeris for GPS SV " << gps_eph_iter->first << std::endl; - std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - ret = true; - } - else - { - std::cout << "ERROR: SUPL client error reading XML" << std::endl; - std::cout << "Disabling SUPL assistance..." << std::endl; - } - // Only look for {utc, iono, ref time, ref location} if SUPL is enabled - bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); - if (enable_gps_supl_assistance == true) - { - // Try to read UTC model from XML - if (supl_client_acquisition_.load_utc_xml(utc_xml_filename) == true) - { - LOG(INFO) << "SUPL: Read XML UTC model"; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_utc); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - else - { - LOG(INFO) << "SUPL: couldn't read UTC model XML"; - } - - // Try to read Iono model from XML - if (supl_client_acquisition_.load_iono_xml(iono_xml_filename) == true) - { - LOG(INFO) << "SUPL: Read XML IONO model"; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_iono); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - else - { - LOG(INFO) << "SUPL: couldn't read IONO model XML"; - } - - // Try to read Ref Time from XML - if (supl_client_acquisition_.load_ref_time_xml(ref_time_xml_filename) == true) - { - LOG(INFO) << "SUPL: Read XML Ref Time"; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_time); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - else - { - LOG(INFO) << "SUPL: couldn't read Ref Time XML"; - } - - // Try to read Ref Location from XML - if (supl_client_acquisition_.load_ref_location_xml(ref_location_xml_filename) == true) - { - LOG(INFO) << "SUPL: Read XML Ref Location"; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_ref_loc); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - else - { - LOG(INFO) << "SUPL: couldn't read Ref Location XML"; - } - } - - return ret; -} - - -void ControlThread::assist_GNSS() -{ - //######### GNSS Assistance ################################# - // GNSS Assistance configuration - bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); - if (enable_gps_supl_assistance == true) - //SUPL SERVER TEST. Not operational yet! - { - std::cout << "SUPL RRLP GPS assistance enabled!" << std::endl; - std::string default_acq_server = "supl.nokia.com"; - std::string default_eph_server = "supl.google.com"; - supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", default_acq_server); - supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", default_eph_server); - supl_client_ephemeris_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port", 7275); - supl_client_acquisition_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_port", 7275); - supl_mcc = configuration_->property("GNSS-SDR.SUPL_MCC", 244); - supl_mns = configuration_->property("GNSS-SDR.SUPL_MNS", 5); - - std::string default_lac = "0x59e2"; - std::string default_ci = "0x31b0"; - try - { - supl_lac = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_LAC", default_lac)); - } - catch (boost::bad_lexical_cast &) - { - supl_lac = 0x59e2; - } - - try - { - supl_ci = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_CI", default_ci)); - } - catch (boost::bad_lexical_cast &) - { - supl_ci = 0x31b0; - } - - bool SUPL_read_gps_assistance_xml = configuration_->property("GNSS-SDR.SUPL_read_gps_assistance_xml", false); - if (SUPL_read_gps_assistance_xml == true) - { - // read assistance from file - if (read_assistance_from_XML()) - { - std::cout << "GPS assistance data loaded from local XML file." << std::endl; - } - } - else - { - // Request ephemeris from SUPL server - int error; - supl_client_ephemeris_.request = 1; - std::cout << "SUPL: Try to read GPS ephemeris from SUPL server..." << std::endl; - error = supl_client_ephemeris_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); - if (error == 0) - { - std::map::const_iterator gps_eph_iter; - for (gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.cbegin(); - gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend(); - gps_eph_iter++) - { - std::cout << "SUPL: Received Ephemeris for GPS SV " << gps_eph_iter->first << std::endl; - std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - //Save ephemeris to XML file - std::string eph_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename); - if (supl_client_ephemeris_.save_ephemeris_map_xml(eph_xml_filename, supl_client_ephemeris_.gps_ephemeris_map) == true) - { - std::cout << "SUPL: XML Ephemeris file created" << std::endl; - } - else - { - std::cout << "SUPL: Failed to create XML Ephemeris file" << std::endl; - } - } - else - { - std::cout << "ERROR: SUPL client for Ephemeris returned " << error << std::endl; - std::cout << "Please check internet connection and SUPL server configuration" << error << std::endl; - std::cout << "Trying to read ephemeris from XML file" << std::endl; - if (read_assistance_from_XML() == false) - { - std::cout << "ERROR: Could not read Ephemeris file: Disabling SUPL assistance." << std::endl; - } - } - - // Request almanac , IONO and UTC Model - supl_client_ephemeris_.request = 0; - std::cout << "SUPL: Try read Almanac, Iono, Utc Model, Ref Time and Ref Location from SUPL server..." << std::endl; - error = supl_client_ephemeris_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); - if (error == 0) - { - std::map::const_iterator gps_alm_iter; - for (gps_alm_iter = supl_client_ephemeris_.gps_almanac_map.cbegin(); - gps_alm_iter != supl_client_ephemeris_.gps_almanac_map.cend(); - gps_alm_iter++) - { - std::cout << "SUPL: Received Almanac for GPS SV " << gps_alm_iter->first << std::endl; - std::shared_ptr tmp_obj = std::make_shared(gps_alm_iter->second); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - if (supl_client_ephemeris_.gps_iono.valid == true) - { - std::cout << "SUPL: Received GPS Iono" << std::endl; - std::shared_ptr tmp_obj = std::make_shared(supl_client_ephemeris_.gps_iono); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - if (supl_client_ephemeris_.gps_utc.valid == true) - { - std::cout << "SUPL: Received GPS UTC Model" << std::endl; - std::shared_ptr tmp_obj = std::make_shared(supl_client_ephemeris_.gps_utc); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - } - else - { - std::cout << "ERROR: SUPL client for Almanac returned " << error << std::endl; - std::cout << "Please check internet connection and SUPL server configuration" << error << std::endl; - std::cout << "Disabling SUPL assistance." << std::endl; - } - - // Request acquisition assistance - supl_client_acquisition_.request = 2; - std::cout << "SUPL: Try read Acquisition assistance from SUPL server..." << std::endl; - error = supl_client_acquisition_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); - if (error == 0) - { - std::map::const_iterator gps_acq_iter; - for (gps_acq_iter = supl_client_acquisition_.gps_acq_map.cbegin(); - gps_acq_iter != supl_client_acquisition_.gps_acq_map.cend(); - gps_acq_iter++) - { - std::cout << "SUPL: Received Acquisition assistance for GPS SV " << gps_acq_iter->first << std::endl; - global_gps_acq_assist_map.write(gps_acq_iter->second.i_satellite_PRN, gps_acq_iter->second); - } - if (supl_client_acquisition_.gps_ref_loc.valid == true) - { - std::cout << "SUPL: Received Ref Location (Acquisition Assistance)" << std::endl; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_ref_loc); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - if (supl_client_acquisition_.gps_time.valid == true) - { - std::cout << "SUPL: Received Ref Time (Acquisition Assistance)" << std::endl; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_time); - flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); - } - } - else - { - std::cout << "ERROR: SUPL client for Acquisition assistance returned " << error << std::endl; - std::cout << "Please check internet connection and SUPL server configuration" << error << std::endl; - std::cout << "Disabling SUPL assistance.." << std::endl; - } - } - } -} - - void ControlThread::init() { // Instantiates a control queue, a GNSS flowgraph, and a control message factory control_queue_ = gr::msg_queue::make(0); + cmd_interface_.set_msg_queue(control_queue_); //set also the queue pointer for the telecommand thread try { flowgraph_ = std::make_shared(configuration_, control_queue_); @@ -461,6 +123,669 @@ void ControlThread::init() supl_lac = 0; supl_ci = 0; msqid = -1; + agnss_ref_location_ = Agnss_Ref_Location(); + agnss_ref_time_ = Agnss_Ref_Time(); + + std::string empty_string = ""; + std::string ref_location_str = configuration_->property("GNSS-SDR.AGNSS_ref_location", empty_string); + std::string ref_time_str = configuration_->property("GNSS-SDR.AGNSS_ref_utc_time", empty_string); + if (ref_location_str != empty_string) + { + std::vector vect; + std::stringstream ss(ref_location_str); + double d; + while (ss >> d) + { + vect.push_back(d); + if ((ss.peek() == ',') or (ss.peek() == ' ')) + { + ss.ignore(); + } + } + // fill agnss_ref_location_ + if (vect.size() >= 2) + { + if ((vect[0] < 90.0) and (vect[0] > -90) and (vect[1] < 180.0) and (vect[1] > -180.0)) + { + agnss_ref_location_.lat = vect[0]; + agnss_ref_location_.lon = vect[1]; + agnss_ref_location_.valid = true; + } + else + { + std::cerr << "GNSS-SDR.AGNSS_ref_location=" << ref_location_str << " is not a valid position." << std::endl; + agnss_ref_location_.valid = false; + } + } + } + if (ref_time_str == empty_string) + { + // Make an educated guess + time_t rawtime; + time(&rawtime); + agnss_ref_time_.d_tv_sec = rawtime; + agnss_ref_time_.valid = true; + } + else + { + // fill agnss_ref_time_ + struct tm tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + if (strptime(ref_time_str.c_str(), "%d/%m/%Y %H:%M:%S", &tm) != nullptr) + { + agnss_ref_time_.d_tv_sec = timegm(&tm); + if (agnss_ref_time_.d_tv_sec > 0) + { + agnss_ref_time_.valid = true; + } + else + { + std::cerr << "GNSS-SDR.AGNSS_ref_utc_time=" << ref_time_str << " is not well-formed. Please use four digits for the year: DD/MM/YYYY HH:MM:SS" << std::endl; + } + } + else + { + std::cerr << "GNSS-SDR.AGNSS_ref_utc_time=" << ref_time_str << " is not well-formed. Should be DD/MM/YYYY HH:MM:SS in UTC" << std::endl; + agnss_ref_time_.valid = false; + } + } +} + + +ControlThread::~ControlThread() // NOLINT(modernize-use-equals-default) +{ + if (msqid != -1) + { + msgctl(msqid, IPC_RMID, nullptr); + } + + if (sysv_queue_thread_.joinable()) + { + sysv_queue_thread_.join(); + } + + if (cmd_interface_thread_.joinable()) + { + cmd_interface_thread_.detach(); + } +} + + +void ControlThread::telecommand_listener() +{ + bool telecommand_enabled = configuration_->property("GNSS-SDR.telecommand_enabled", false); + if (telecommand_enabled) + { + int tcp_cmd_port = configuration_->property("GNSS-SDR.telecommand_tcp_port", 3333); + cmd_interface_.run_cmd_server(tcp_cmd_port); + } +} + + +/* + * Runs the control thread that manages the receiver control plane + * + * This is the main loop that reads and process the control messages + * 1- Connect the GNSS receiver flowgraph + * 2- Start the GNSS receiver flowgraph + * while (flowgraph_->running() && !stop)_{ + * 3- Read control messages and process them } + */ +int ControlThread::run() +{ + // Connect the flowgraph + try + { + flowgraph_->connect(); + } + catch (const std::exception &e) + { + LOG(ERROR) << e.what(); + return 0; + } + if (flowgraph_->connected()) + { + LOG(INFO) << "Flowgraph connected"; + } + else + { + LOG(ERROR) << "Unable to connect flowgraph"; + return 0; + } + // Start the flowgraph + flowgraph_->start(); + if (flowgraph_->running()) + { + LOG(INFO) << "Flowgraph started"; + } + else + { + LOG(ERROR) << "Unable to start flowgraph"; + return 0; + } + + // launch GNSS assistance process AFTER the flowgraph is running because the GNU Radio asynchronous queues must be already running to transport msgs + assist_GNSS(); + // start the keyboard_listener thread + keyboard_thread_ = std::thread(&ControlThread::keyboard_listener, this); + sysv_queue_thread_ = std::thread(&ControlThread::sysv_queue_listener, this); + + // start the telecommand listener thread + cmd_interface_.set_pvt(flowgraph_->get_pvt()); + cmd_interface_thread_ = std::thread(&ControlThread::telecommand_listener, this); + +#ifdef ENABLE_FPGA + // Create a task for the acquisition such that id doesn't block the flow of the control thread + fpga_helper_thread_ = boost::thread(&GNSSFlowgraph::start_acquisition_helper, + flowgraph_); +#endif + // Main loop to read and process the control messages + while (flowgraph_->running() && !stop_) + { + //TODO re-enable the blocking read messages functions and fork the process + read_control_messages(); + if (control_messages_ != nullptr) + { + process_control_messages(); + } + } + std::cout << "Stopping GNSS-SDR, please wait!" << std::endl; + flowgraph_->stop(); + stop_ = true; + flowgraph_->disconnect(); + + +#ifdef ENABLE_FPGA + // trigger a HW reset + // The HW reset causes any HW accelerator module that is waiting for more samples to complete its calculations + // to trigger an interrupt and finish its signal processing tasks immediately. In this way all SW threads that + // are waiting for interrupts in the HW can exit in a normal way. + flowgraph_->perform_hw_reset(); +#endif + + pthread_t id = keyboard_thread_.native_handle(); + keyboard_thread_.detach(); + pthread_cancel(id); + +#ifdef ENABLE_FPGA + + fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); + +#endif + + LOG(INFO) << "Flowgraph stopped"; + + if (restart_) + { + return 42; // signal the gnss-sdr-harness.sh to restart the receiver program + } + + return 0; // normal shutdown +} + + +void ControlThread::set_control_queue(const gr::msg_queue::sptr control_queue) // NOLINT(performance-unnecessary-value-param) +{ + if (flowgraph_->running()) + { + LOG(WARNING) << "Unable to set control queue while flowgraph is running"; + return; + } + control_queue_ = control_queue; + cmd_interface_.set_msg_queue(control_queue_); +} + + +/* + * Returns true if reading was successful + */ +bool ControlThread::read_assistance_from_XML() +{ + // return variable (true == succeeded) + bool ret = false; + // getting names from the config file, if available + std::string eph_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename); + std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model_xml", utc_default_xml_filename); + std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename); + std::string gal_iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_iono_xml", gal_iono_default_xml_filename); + std::string ref_time_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_time_xml", ref_time_default_xml_filename); + std::string ref_location_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_location_xml", ref_location_default_xml_filename); + std::string eph_gal_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_ephemeris_xml", eph_gal_default_xml_filename); + std::string eph_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename); + std::string gal_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_utc_model_xml", gal_utc_default_xml_filename); + std::string cnav_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_cnav_utc_model_xml", cnav_utc_default_xml_filename); + std::string eph_glo_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename); + std::string glo_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_utc_model_xml", glo_utc_default_xml_filename); + std::string gal_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_almanac_xml", gal_almanac_default_xml_filename); + std::string gps_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_almanac_xml", gps_almanac_default_xml_filename); + + if (configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false) == true) + { + eph_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_ephemeris_xml", eph_default_xml_filename); + utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_utc_model_xml", utc_default_xml_filename); + iono_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_iono_xml", iono_default_xml_filename); + gal_iono_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_iono_xml", gal_iono_default_xml_filename); + ref_time_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_ref_time_xml", ref_time_default_xml_filename); + ref_location_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_ref_location_xml", ref_location_default_xml_filename); + eph_gal_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_ephemeris_xml", eph_gal_default_xml_filename); + eph_cnav_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename); + gal_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_utc_model_xml", gal_utc_default_xml_filename); + cnav_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_cnav_utc_model_xml", cnav_utc_default_xml_filename); + eph_glo_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename); + glo_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_utc_model_xml", glo_utc_default_xml_filename); + gal_almanac_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_almanac_xml", gal_almanac_default_xml_filename); + gps_almanac_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_almanac_xml", gps_almanac_default_xml_filename); + } + + std::cout << "Trying to read GNSS ephemeris from XML file(s)..." << std::endl; + + if (configuration_->property("Channels_1C.count", 0) > 0) + { + if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) + { + std::map::const_iterator gps_eph_iter; + for (gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.cbegin(); + gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend(); + gps_eph_iter++) + { + std::cout << "From XML file: Read NAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_eph_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } + + if (supl_client_acquisition_.load_utc_xml(utc_xml_filename) == true) + { + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_utc); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + std::cout << "From XML file: Read GPS UTC model parameters." << std::endl; + ret = true; + } + + if (supl_client_acquisition_.load_iono_xml(iono_xml_filename) == true) + { + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_iono); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + std::cout << "From XML file: Read GPS ionosphere model parameters." << std::endl; + ret = true; + } + + if (supl_client_ephemeris_.load_gps_almanac_xml(gps_almanac_xml_filename) == true) + { + std::map::const_iterator gps_alm_iter; + for (gps_alm_iter = supl_client_ephemeris_.gps_almanac_map.cbegin(); + gps_alm_iter != supl_client_ephemeris_.gps_almanac_map.cend(); + gps_alm_iter++) + { + std::cout << "From XML file: Read GPS almanac for satellite " << Gnss_Satellite("GPS", gps_alm_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gps_alm_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } + } + + if ((configuration_->property("Channels_1B.count", 0) > 0) or (configuration_->property("Channels_5X.count", 0) > 0)) + { + if (supl_client_ephemeris_.load_gal_ephemeris_xml(eph_gal_xml_filename) == true) + { + std::map::const_iterator gal_eph_iter; + for (gal_eph_iter = supl_client_ephemeris_.gal_ephemeris_map.cbegin(); + gal_eph_iter != supl_client_ephemeris_.gal_ephemeris_map.cend(); + gal_eph_iter++) + { + std::cout << "From XML file: Read ephemeris for satellite " << Gnss_Satellite("Galileo", gal_eph_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gal_eph_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } + + if (supl_client_acquisition_.load_gal_iono_xml(gal_iono_xml_filename) == true) + { + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gal_iono); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + std::cout << "From XML file: Read Galileo ionosphere model parameters." << std::endl; + ret = true; + } + + if (supl_client_acquisition_.load_gal_utc_xml(gal_utc_xml_filename) == true) + { + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gal_utc); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + std::cout << "From XML file: Read Galileo UTC model parameters." << std::endl; + ret = true; + } + + if (supl_client_ephemeris_.load_gal_almanac_xml(gal_almanac_xml_filename) == true) + { + std::map::const_iterator gal_alm_iter; + for (gal_alm_iter = supl_client_ephemeris_.gal_almanac_map.cbegin(); + gal_alm_iter != supl_client_ephemeris_.gal_almanac_map.cend(); + gal_alm_iter++) + { + std::cout << "From XML file: Read Galileo almanac for satellite " << Gnss_Satellite("Galileo", gal_alm_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gal_alm_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } + } + + if ((configuration_->property("Channels_2S.count", 0) > 0) or (configuration_->property("Channels_L5.count", 0) > 0)) + { + if (supl_client_ephemeris_.load_cnav_ephemeris_xml(eph_cnav_xml_filename) == true) + { + std::map::const_iterator gps_cnav_eph_iter; + for (gps_cnav_eph_iter = supl_client_ephemeris_.gps_cnav_ephemeris_map.cbegin(); + gps_cnav_eph_iter != supl_client_ephemeris_.gps_cnav_ephemeris_map.cend(); + gps_cnav_eph_iter++) + { + std::cout << "From XML file: Read CNAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_cnav_eph_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gps_cnav_eph_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } + + if (supl_client_acquisition_.load_cnav_utc_xml(cnav_utc_xml_filename) == true) + { + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_cnav_utc); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + std::cout << "From XML file: Read GPS CNAV UTC model parameters." << std::endl; + ret = true; + } + } + + if ((configuration_->property("Channels_1G.count", 0) > 0) or (configuration_->property("Channels_2G.count", 0) > 0)) + { + if (supl_client_ephemeris_.load_gnav_ephemeris_xml(eph_glo_xml_filename) == true) + { + std::map::const_iterator glo_gnav_eph_iter; + for (glo_gnav_eph_iter = supl_client_ephemeris_.glonass_gnav_ephemeris_map.cbegin(); + glo_gnav_eph_iter != supl_client_ephemeris_.glonass_gnav_ephemeris_map.cend(); + glo_gnav_eph_iter++) + { + std::cout << "From XML file: Read GLONASS GNAV ephemeris for satellite " << Gnss_Satellite("GLONASS", glo_gnav_eph_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(glo_gnav_eph_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } + + if (supl_client_acquisition_.load_glo_utc_xml(glo_utc_xml_filename) == true) + { + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.glo_gnav_utc); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + std::cout << "From XML file: Read GLONASS UTC model parameters." << std::endl; + ret = true; + } + } + + if (ret == false) + { + std::cout << "Error reading XML files" << std::endl; + std::cout << "Disabling GNSS assistance..." << std::endl; + } + + // Only look for {ref time, ref location} if SUPL is enabled + bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); + if (enable_gps_supl_assistance == true) + { + // Try to read Ref Time from XML + if (supl_client_acquisition_.load_ref_time_xml(ref_time_xml_filename) == true) + { + LOG(INFO) << "SUPL: Read XML Ref Time"; + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_time); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + else + { + LOG(INFO) << "SUPL: could not read Ref Time XML"; + } + + // Try to read Ref Location from XML + if (supl_client_acquisition_.load_ref_location_xml(ref_location_xml_filename) == true) + { + LOG(INFO) << "SUPL: Read XML Ref Location"; + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_ref_loc); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + else + { + LOG(INFO) << "SUPL: could not read Ref Location XML"; + } + } + + return ret; +} + + +void ControlThread::assist_GNSS() +{ + //######### GNSS Assistance ################################# + // GNSS Assistance configuration + bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); + bool enable_agnss_xml = configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false); + if ((enable_gps_supl_assistance == true) and (enable_agnss_xml == false)) + { + std::cout << "SUPL RRLP GPS assistance enabled!" << std::endl; + std::string default_acq_server = "supl.google.com"; + std::string default_eph_server = "supl.google.com"; + supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", default_acq_server); + supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", default_eph_server); + supl_client_ephemeris_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port", 7275); + supl_client_acquisition_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_port", 7275); + supl_mcc = configuration_->property("GNSS-SDR.SUPL_MCC", 244); + supl_mns = configuration_->property("GNSS-SDR.SUPL_MNC ", 5); + + std::string default_lac = "0x59e2"; + std::string default_ci = "0x31b0"; + std::string supl_lac_s = configuration_->property("GNSS-SDR.SUPL_LAC", default_lac); + std::string supl_ci_s = configuration_->property("GNSS-SDR.SUPL_CI", default_ci); + try + { + supl_lac = std::stoi(supl_lac_s, nullptr, 0); + } + catch (const std::invalid_argument &ia) + { + std::cerr << "Invalid argument for SUPL LAC: " << ia.what() << '\n'; + supl_lac = -1; + } + try + { + supl_ci = std::stoi(supl_ci_s, nullptr, 0); + } + catch (const std::invalid_argument &ia) + { + std::cerr << "Invalid argument for SUPL CI: " << ia.what() << '\n'; + supl_ci = -1; + } + + if (supl_lac < 0 or supl_lac > 65535) + { + supl_lac = 0x59e2; + } + + if (supl_ci < 0 or supl_ci > 268435455) // 2^16 for GSM and CDMA, 2^28 for UMTS and LTE networks + { + supl_ci = 0x31b0; + } + + bool SUPL_read_gps_assistance_xml = configuration_->property("GNSS-SDR.SUPL_read_gps_assistance_xml", false); + if (SUPL_read_gps_assistance_xml == true) + { + // Read assistance from file + if (read_assistance_from_XML()) + { + std::cout << "GNSS assistance data loaded from local XML file(s)." << std::endl; + std::cout << "No SUPL request has been performed." << std::endl; + } + } + else + { + // Request ephemeris from SUPL server + int error; + supl_client_ephemeris_.request = 1; + std::cout << "SUPL: Try to read GPS ephemeris data from SUPL server..." << std::endl; + error = supl_client_ephemeris_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); + if (error == 0) + { + std::map::const_iterator gps_eph_iter; + for (gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.cbegin(); + gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend(); + gps_eph_iter++) + { + std::cout << "SUPL: Received ephemeris data for satellite " << Gnss_Satellite("GPS", gps_eph_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + // Save ephemeris to XML file + std::string eph_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename); + if (supl_client_ephemeris_.save_ephemeris_map_xml(eph_xml_filename, supl_client_ephemeris_.gps_ephemeris_map) == true) + { + std::cout << "SUPL: XML ephemeris data file created" << std::endl; + } + else + { + std::cout << "SUPL: Failed to create XML ephemeris data file" << std::endl; + } + } + else + { + std::cout << "ERROR: SUPL client request for ephemeris data returned " << error << std::endl; + std::cout << "Please check your network connectivity and SUPL server configuration" << std::endl; + std::cout << "Trying to read AGNSS data from local XML file(s)..." << std::endl; + if (read_assistance_from_XML() == false) + { + std::cout << "ERROR: Could not read XML files: Disabling SUPL assistance." << std::endl; + } + } + + // Request almanac, IONO and UTC Model data + supl_client_ephemeris_.request = 0; + std::cout << "SUPL: Try to read Almanac, Iono, Utc Model, Ref Time and Ref Location data from SUPL server..." << std::endl; + error = supl_client_ephemeris_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); + if (error == 0) + { + std::map::const_iterator gps_alm_iter; + for (gps_alm_iter = supl_client_ephemeris_.gps_almanac_map.cbegin(); + gps_alm_iter != supl_client_ephemeris_.gps_almanac_map.cend(); + gps_alm_iter++) + { + std::cout << "SUPL: Received almanac data for satellite " << Gnss_Satellite("GPS", gps_alm_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gps_alm_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + supl_client_ephemeris_.save_gps_almanac_xml("gps_almanac_map.xml", supl_client_ephemeris_.gps_almanac_map); + if (supl_client_ephemeris_.gps_iono.valid == true) + { + std::cout << "SUPL: Received GPS Ionosphere model parameters" << std::endl; + std::shared_ptr tmp_obj = std::make_shared(supl_client_ephemeris_.gps_iono); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + if (supl_client_ephemeris_.gps_utc.valid == true) + { + std::cout << "SUPL: Received GPS UTC model parameters" << std::endl; + std::shared_ptr tmp_obj = std::make_shared(supl_client_ephemeris_.gps_utc); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + // Save iono and UTC model data to xml file + std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename); + if (supl_client_ephemeris_.save_iono_xml(iono_xml_filename, supl_client_ephemeris_.gps_iono) == true) + { + std::cout << "SUPL: Iono data file created" << std::endl; + } + else + { + std::cout << "SUPL: Failed to create Iono data file" << std::endl; + } + std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model_xml", utc_default_xml_filename); + if (supl_client_ephemeris_.save_utc_xml(utc_xml_filename, supl_client_ephemeris_.gps_utc) == true) + { + std::cout << "SUPL: UTC model data file created" << std::endl; + } + else + { + std::cout << "SUPL: Failed to create UTC model data file" << std::endl; + } + } + else + { + std::cout << "ERROR: SUPL client for almanac data returned " << error << std::endl; + std::cout << "Please check your network connectivity and SUPL server configuration" << std::endl; + } + + // Request acquisition assistance + supl_client_acquisition_.request = 2; + std::cout << "SUPL: Try to read acquisition assistance data from SUPL server..." << std::endl; + error = supl_client_acquisition_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); + if (error == 0) + { + std::map::const_iterator gps_acq_iter; + for (gps_acq_iter = supl_client_acquisition_.gps_acq_map.cbegin(); + gps_acq_iter != supl_client_acquisition_.gps_acq_map.cend(); + gps_acq_iter++) + { + std::cout << "SUPL: Received acquisition assistance data for satellite " << Gnss_Satellite("GPS", gps_acq_iter->second.i_satellite_PRN) << std::endl; + global_gps_acq_assist_map.write(gps_acq_iter->second.i_satellite_PRN, gps_acq_iter->second); + } + if (supl_client_acquisition_.gps_ref_loc.valid == true) + { + std::cout << "SUPL: Received Ref Location data (Acquisition Assistance)" << std::endl; + agnss_ref_location_ = supl_client_acquisition_.gps_ref_loc; + std::shared_ptr tmp_obj = std::make_shared(agnss_ref_location_); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + supl_client_acquisition_.save_ref_location_xml("agnss_ref_location.xml", agnss_ref_location_); + } + if (supl_client_acquisition_.gps_time.valid == true) + { + std::cout << "SUPL: Received Ref Time data (Acquisition Assistance)" << std::endl; + agnss_ref_time_ = supl_client_acquisition_.gps_time; + std::shared_ptr tmp_obj = std::make_shared(agnss_ref_time_); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + supl_client_acquisition_.save_ref_time_xml("agnss_ref_time.xml", agnss_ref_time_); + } + } + else + { + std::cout << "ERROR: SUPL client for acquisition assistance returned " << error << std::endl; + std::cout << "Please check your network connectivity and SUPL server configuration" << std::endl; + std::cout << "Disabling SUPL acquisition assistance." << std::endl; + } + } + } + + if ((enable_gps_supl_assistance == false) and (enable_agnss_xml == true)) + { + // read assistance from file + if (read_assistance_from_XML()) + { + std::cout << "GNSS assistance data loaded from local XML file(s)." << std::endl; + } + } + + // If AGNSS is enabled, make use of it + if ((agnss_ref_location_.valid == true) and ((enable_gps_supl_assistance == true) or (enable_agnss_xml == true))) + { + // Get the list of visible satellites + arma::vec ref_LLH = arma::zeros(3, 1); + ref_LLH(0) = agnss_ref_location_.lat; + ref_LLH(1) = agnss_ref_location_.lon; + time_t ref_rx_utc_time = 0; + if (agnss_ref_time_.valid == true) + { + ref_rx_utc_time = static_cast(agnss_ref_time_.d_tv_sec); + } + + std::vector> visible_sats = get_visible_sats(ref_rx_utc_time, ref_LLH); + // Set the receiver in Standby mode + flowgraph_->apply_action(0, 10); + // Give priority to visible satellites in the search list + flowgraph_->priorize_satellites(visible_sats); + // Hot Start + flowgraph_->apply_action(0, 12); + } } @@ -468,7 +793,7 @@ void ControlThread::read_control_messages() { DLOG(INFO) << "Reading control messages from queue"; gr::message::sptr queue_message = control_queue_->delete_head(); - if (queue_message != 0) + if (queue_message != nullptr) { control_messages_ = control_message_factory_->GetControlMessages(queue_message); } @@ -480,19 +805,25 @@ void ControlThread::read_control_messages() // Apply the corresponding control actions -// TODO: May be it is better to move the apply_action state machine to the control_thread void ControlThread::process_control_messages() { - for (unsigned int i = 0; i < control_messages_->size(); i++) + for (auto &i : *control_messages_) { - if (stop_) break; - if (control_messages_->at(i)->who == 200) + if (stop_) { - apply_action(control_messages_->at(i)->what); + break; + } + if (i->who == 200) + { + apply_action(i->what); } else { - flowgraph_->apply_action(control_messages_->at(i)->who, control_messages_->at(i)->what); + if (i->who == 300) // some TC commands require also actions from control_thread + { + apply_action(i->what); + } + flowgraph_->apply_action(i->who, i->what); } processed_control_messages_++; } @@ -503,20 +834,198 @@ void ControlThread::process_control_messages() void ControlThread::apply_action(unsigned int what) { + std::shared_ptr pvt_ptr; + std::vector> visible_satellites; switch (what) { case 0: - DLOG(INFO) << "Received action STOP"; + LOG(INFO) << "Received action STOP"; stop_ = true; applied_actions_++; break; + case 1: + LOG(INFO) << "Received action RESTART"; + stop_ = true; + restart_ = true; + applied_actions_++; + break; + case 11: + LOG(INFO) << "Receiver action COLDSTART"; + // delete all ephemeris and almanac information from maps (also the PVT map queue) + pvt_ptr = flowgraph_->get_pvt(); + pvt_ptr->clear_ephemeris(); + // todo: reorder the satellite queues to the receiver default startup order. + // This is required to allow repeatability. Otherwise the satellite search order will depend on the last tracked satellites + break; + case 12: + LOG(INFO) << "Receiver action HOTSTART"; + visible_satellites = get_visible_sats(cmd_interface_.get_utc_time(), cmd_interface_.get_LLH()); + // reorder the satellite queue to acquire first those visible satellites + flowgraph_->priorize_satellites(visible_satellites); + // start again the satellite acquisitions (done in chained apply_action to flowgraph) + break; + case 13: + LOG(INFO) << "Receiver action WARMSTART"; + // delete all ephemeris and almanac information from maps (also the PVT map queue) + pvt_ptr = flowgraph_->get_pvt(); + pvt_ptr->clear_ephemeris(); + // load the ephemeris and the almanac from XML files (receiver assistance) + read_assistance_from_XML(); + // call here the function that computes the set of visible satellites and its elevation + // for the date and time specified by the warm start command and the assisted position + get_visible_sats(cmd_interface_.get_utc_time(), cmd_interface_.get_LLH()); + // reorder the satellite queue to acquire first those visible satellites + flowgraph_->priorize_satellites(visible_satellites); + // start again the satellite acquisitions (done in chained apply_action to flowgraph) + break; default: - DLOG(INFO) << "Unrecognized action."; + LOG(INFO) << "Unrecognized action."; break; } } +std::vector> ControlThread::get_visible_sats(time_t rx_utc_time, const arma::vec &LLH) +{ + // 1. Compute rx ECEF position from LLH WGS84 + arma::vec LLH_rad = arma::vec{degtorad(LLH(0)), degtorad(LLH(1)), LLH(2)}; + arma::mat C_tmp = arma::zeros(3, 3); + arma::vec r_eb_e = arma::zeros(3, 1); + arma::vec v_eb_e = arma::zeros(3, 1); + Geo_to_ECEF(LLH_rad, arma::vec{0, 0, 0}, C_tmp, r_eb_e, v_eb_e, C_tmp); + + // 2. Compute rx GPS time from UTC time + gtime_t utc_gtime; + utc_gtime.time = rx_utc_time; + utc_gtime.sec = 0.0; + gtime_t gps_gtime = utc2gpst(utc_gtime); + + // 3. loop through all the available ephemeris or almanac and compute satellite positions and elevations + // store visible satellites in a vector of pairs to associate an elevation to the each satellite + std::vector> available_satellites; + std::vector visible_gps; + std::vector visible_gal; + std::shared_ptr pvt_ptr = flowgraph_->get_pvt(); + struct tm tstruct = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + char buf[80]; + tstruct = *gmtime(&rx_utc_time); + strftime(buf, sizeof(buf), "%d/%m/%Y %H:%M:%S ", &tstruct); + std::string str_time = std::string(buf); + std::cout << "Get visible satellites at " << str_time + << "UTC, assuming RX position " << LLH(0) << " [deg], " << LLH(1) << " [deg], " << LLH(2) << " [m]" << std::endl; + + std::map gps_eph_map = pvt_ptr->get_gps_ephemeris(); + for (auto &it : gps_eph_map) + { + eph_t rtklib_eph = eph_to_rtklib(it.second); + double r_sat[3]; + double clock_bias_s; + double sat_pos_variance_m2; + eph2pos(gps_gtime, &rtklib_eph, &r_sat[0], &clock_bias_s, + &sat_pos_variance_m2); + double Az, El, dist_m; + arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + arma::vec dx = r_sat_eb_e - r_eb_e; + topocent(&Az, &El, &dist_m, r_eb_e, dx); + // push sat + if (El > 0) + { + std::cout << "Using GPS Ephemeris: Sat " << it.second.i_satellite_PRN << " Az: " << Az << " El: " << El << std::endl; + available_satellites.push_back(std::pair(floor(El), + (Gnss_Satellite(std::string("GPS"), it.second.i_satellite_PRN)))); + visible_gps.push_back(it.second.i_satellite_PRN); + } + } + + std::map gal_eph_map = pvt_ptr->get_galileo_ephemeris(); + for (auto &it : gal_eph_map) + { + eph_t rtklib_eph = eph_to_rtklib(it.second); + double r_sat[3]; + double clock_bias_s; + double sat_pos_variance_m2; + eph2pos(gps_gtime, &rtklib_eph, &r_sat[0], &clock_bias_s, + &sat_pos_variance_m2); + double Az, El, dist_m; + arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + arma::vec dx = r_sat_eb_e - r_eb_e; + topocent(&Az, &El, &dist_m, r_eb_e, dx); + // push sat + if (El > 0) + { + std::cout << "Using Galileo Ephemeris: Sat " << it.second.i_satellite_PRN << " Az: " << Az << " El: " << El << std::endl; + available_satellites.push_back(std::pair(floor(El), + (Gnss_Satellite(std::string("Galileo"), it.second.i_satellite_PRN)))); + visible_gal.push_back(it.second.i_satellite_PRN); + } + } + + std::map gps_alm_map = pvt_ptr->get_gps_almanac(); + for (auto &it : gps_alm_map) + { + alm_t rtklib_alm = alm_to_rtklib(it.second); + double r_sat[3]; + double clock_bias_s; + gtime_t aux_gtime; + aux_gtime.time = fmod(utc2gpst(gps_gtime).time + 345600, 604800); + aux_gtime.sec = 0.0; + alm2pos(aux_gtime, &rtklib_alm, &r_sat[0], &clock_bias_s); + double Az, El, dist_m; + arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + arma::vec dx = r_sat_eb_e - r_eb_e; + topocent(&Az, &El, &dist_m, r_eb_e, dx); + // push sat + std::vector::iterator it2; + if (El > 0) + { + it2 = std::find(visible_gps.begin(), visible_gps.end(), it.second.i_satellite_PRN); + if (it2 == visible_gps.end()) + { + std::cout << "Using GPS Almanac: Sat " << it.second.i_satellite_PRN << " Az: " << Az << " El: " << El << std::endl; + available_satellites.push_back(std::pair(floor(El), + (Gnss_Satellite(std::string("GPS"), it.second.i_satellite_PRN)))); + } + } + } + + std::map gal_alm_map = pvt_ptr->get_galileo_almanac(); + for (auto &it : gal_alm_map) + { + alm_t rtklib_alm = alm_to_rtklib(it.second); + double r_sat[3]; + double clock_bias_s; + gtime_t gal_gtime; + gal_gtime.time = fmod(utc2gpst(gps_gtime).time + 345600, 604800); + gal_gtime.sec = 0.0; + alm2pos(gal_gtime, &rtklib_alm, &r_sat[0], &clock_bias_s); + double Az, El, dist_m; + arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + arma::vec dx = r_sat_eb_e - r_eb_e; + topocent(&Az, &El, &dist_m, r_eb_e, dx); + // push sat + std::vector::iterator it2; + if (El > 0) + { + it2 = std::find(visible_gal.begin(), visible_gal.end(), it.second.i_satellite_PRN); + if (it2 == visible_gal.end()) + { + std::cout << "Using Galileo Almanac: Sat " << it.second.i_satellite_PRN << " Az: " << Az << " El: " << El << std::endl; + available_satellites.push_back(std::pair(floor(El), + (Gnss_Satellite(std::string("Galileo"), it.second.i_satellite_PRN)))); + } + } + } + + // sort the visible satellites in ascending order of elevation + std::sort(available_satellites.begin(), available_satellites.end(), [](const std::pair &a, const std::pair &b) { // use lambda. Cleaner and easier to read + return a.first < b.first; + }); + // provide list starting from satellites with higher elevation + std::reverse(available_satellites.begin(), available_satellites.end()); + return available_satellites; +} + + void ControlThread::gps_acq_assist_data_collector() { // ############ 1.bis READ EPHEMERIS/UTC_MODE/IONO QUEUE #################### @@ -525,7 +1034,10 @@ void ControlThread::gps_acq_assist_data_collector() while (stop_ == false) { global_gps_acq_assist_queue.wait_and_pop(gps_acq); - if (gps_acq.i_satellite_PRN == 0) break; + if (gps_acq.i_satellite_PRN == 0) + { + break; + } // DEBUG MESSAGE std::cout << "Acquisition assistance record has arrived from SAT ID " @@ -553,7 +1065,7 @@ void ControlThread::sysv_queue_listener() { typedef struct { - long mtype; // required by SysV queue messaging + long mtype; // NOLINT(google-runtime-int) required by SysV queue messaging double stop_message; } stop_msgbuf; @@ -607,6 +1119,6 @@ void ControlThread::keyboard_listener() } read_keys = false; } - usleep(500000); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index c49ddba53..23ffa877c 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -35,16 +35,20 @@ #ifndef GNSS_SDR_CONTROL_THREAD_H_ #define GNSS_SDR_CONTROL_THREAD_H_ +#include "agnss_ref_location.h" +#include "agnss_ref_time.h" +#include "configuration_interface.h" #include "control_message_factory.h" +#include "gnss_flowgraph.h" +#include "gnss_satellite.h" #include "gnss_sdr_supl_client.h" -#include +#include "tcp_cmd_interface.h" +#include #include #include +#include #include -class GNSSFlowgraph; -class ConfigurationInterface; - /*! * \brief This class represents the main thread of the application, so the name is ControlThread. @@ -82,14 +86,14 @@ public: * * - Read control messages and process them; } */ - void run(); + int run(); /*! * \brief Sets the control_queue * * \param[in] boost::shared_ptr control_queue */ - void set_control_queue(gr::msg_queue::sptr control_queue); + void set_control_queue(const gr::msg_queue::sptr control_queue); // NOLINT(performance-unnecessary-value-param) unsigned int processed_control_messages() @@ -113,9 +117,13 @@ public: } private: + //Telecommand TCP interface + TcpCmdInterface cmd_interface_; + void telecommand_listener(); + std::thread cmd_interface_thread_; //SUPL assistance classes - gnss_sdr_supl_client supl_client_acquisition_; - gnss_sdr_supl_client supl_client_ephemeris_; + Gnss_Sdr_Supl_Client supl_client_acquisition_; + Gnss_Sdr_Supl_Client supl_client_ephemeris_; int supl_mcc; // Current network MCC (Mobile country code), 3 digits. int supl_mns; // Current network MNC (Mobile Network code), 2 or 3 digits. int supl_lac; // Current network LAC (Location area code),16 bits, 1-65520 are valid values. @@ -138,6 +146,12 @@ private: */ void gps_acq_assist_data_collector(); + /* + * Compute elevations for the specified time and position for all the available satellites in ephemeris and almanac queues + * returns a vector filled with the available satellites ordered from high elevation to low elevation angle. + */ + std::vector> get_visible_sats(time_t rx_utc_time, const arma::vec& LLH); + /* * Read initial GNSS assistance from SUPL server or local XML files */ @@ -150,12 +164,20 @@ private: std::shared_ptr control_message_factory_; std::shared_ptr>> control_messages_; bool stop_; + bool restart_; bool delete_configuration_; unsigned int processed_control_messages_; unsigned int applied_actions_; - boost::thread keyboard_thread_; - boost::thread sysv_queue_thread_; - boost::thread gps_acq_assist_data_collector_thread_; + //<<<<<<< HEAD + // boost::thread keyboard_thread_; + // boost::thread sysv_queue_thread_; + // boost::thread gps_acq_assist_data_collector_thread_; + boost::thread fpga_helper_thread_; + //======= + std::thread keyboard_thread_; + std::thread sysv_queue_thread_; + std::thread gps_acq_assist_data_collector_thread_; + //>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 void keyboard_listener(); void sysv_queue_listener(); @@ -167,6 +189,18 @@ private: const std::string iono_default_xml_filename = "./gps_iono.xml"; const std::string ref_time_default_xml_filename = "./gps_ref_time.xml"; const std::string ref_location_default_xml_filename = "./gps_ref_location.xml"; + const std::string eph_gal_default_xml_filename = "./gal_ephemeris.xml"; + const std::string eph_cnav_default_xml_filename = "./gps_cnav_ephemeris.xml"; + const std::string gal_iono_default_xml_filename = "./gal_iono.xml"; + const std::string gal_utc_default_xml_filename = "./gal_utc_model.xml"; + const std::string cnav_utc_default_xml_filename = "./gps_cnav_utc_model.xml"; + const std::string eph_glo_gnav_default_xml_filename = "./glo_gnav_ephemeris.xml"; + const std::string glo_utc_default_xml_filename = "./glo_utc_model.xml"; + const std::string gal_almanac_default_xml_filename = "./gal_almanac.xml"; + const std::string gps_almanac_default_xml_filename = "./gps_almanac.xml"; + + Agnss_Ref_Location agnss_ref_location_; + Agnss_Ref_Time agnss_ref_time_; }; #endif /*GNSS_SDR_CONTROL_THREAD_H_*/ diff --git a/src/core/receiver/file_configuration.cc b/src/core/receiver/file_configuration.cc index 43f177502..62992c074 100644 --- a/src/core/receiver/file_configuration.cc +++ b/src/core/receiver/file_configuration.cc @@ -34,8 +34,8 @@ */ #include "file_configuration.h" -#include "in_memory_configuration.h" #include "INIReader.h" +#include "in_memory_configuration.h" #include "string_converter.h" #include #include @@ -45,7 +45,7 @@ using google::LogMessage; FileConfiguration::FileConfiguration(std::string filename) { - filename_ = filename; + filename_ = std::move(filename); init(); } @@ -69,10 +69,7 @@ std::string FileConfiguration::property(std::string property_name, std::string d { return overrided_->property(property_name, default_value); } - else - { - return ini_reader_->Get("GNSS-SDR", property_name, default_value); - } + return ini_reader_->Get("GNSS-SDR", property_name, default_value); } @@ -82,25 +79,30 @@ bool FileConfiguration::property(std::string property_name, bool default_value) { return overrided_->property(property_name, default_value); } - else - { - std::string empty = ""; - return converter_->convert(property(property_name, empty), default_value); - } + std::string empty; + return converter_->convert(property(property_name, empty), default_value); } -long FileConfiguration::property(std::string property_name, long default_value) +int64_t FileConfiguration::property(std::string property_name, int64_t default_value) { if (overrided_->is_present(property_name)) { return overrided_->property(property_name, default_value); } - else + std::string empty; + return converter_->convert(property(property_name, empty), default_value); +} + + +uint64_t FileConfiguration::property(std::string property_name, uint64_t default_value) +{ + if (overrided_->is_present(property_name)) { - std::string empty = ""; - return converter_->convert(property(property_name, empty), default_value); + return overrided_->property(property_name, default_value); } + std::string empty; + return converter_->convert(property(property_name, empty), default_value); } @@ -110,11 +112,8 @@ int FileConfiguration::property(std::string property_name, int default_value) { return overrided_->property(property_name, default_value); } - else - { - std::string empty = ""; - return converter_->convert(property(property_name, empty), default_value); - } + std::string empty; + return converter_->convert(property(property_name, empty), default_value); } @@ -124,25 +123,30 @@ unsigned int FileConfiguration::property(std::string property_name, unsigned int { return overrided_->property(property_name, default_value); } - else - { - std::string empty = ""; - return converter_->convert(property(property_name, empty), default_value); - } + std::string empty; + return converter_->convert(property(property_name, empty), default_value); } -unsigned short FileConfiguration::property(std::string property_name, unsigned short default_value) +uint16_t FileConfiguration::property(std::string property_name, uint16_t default_value) { if (overrided_->is_present(property_name)) { return overrided_->property(property_name, default_value); } - else + std::string empty; + return converter_->convert(property(property_name, empty), default_value); +} + + +int16_t FileConfiguration::property(std::string property_name, int16_t default_value) +{ + if (overrided_->is_present(property_name)) { - std::string empty = ""; - return converter_->convert(property(property_name, empty), default_value); + return overrided_->property(property_name, default_value); } + std::string empty; + return converter_->convert(property(property_name, empty), default_value); } @@ -152,11 +156,8 @@ float FileConfiguration::property(std::string property_name, float default_value { return overrided_->property(property_name, default_value); } - else - { - std::string empty = ""; - return converter_->convert(property(property_name, empty), default_value); - } + std::string empty; + return converter_->convert(property(property_name, empty), default_value); } @@ -166,11 +167,8 @@ double FileConfiguration::property(std::string property_name, double default_val { return overrided_->property(property_name, default_value); } - else - { - std::string empty = ""; - return converter_->convert(property(property_name, empty), default_value); - } + std::string empty; + return converter_->convert(property(property_name, empty), default_value); } diff --git a/src/core/receiver/file_configuration.h b/src/core/receiver/file_configuration.h index 2484438d8..0e2ccb53e 100644 --- a/src/core/receiver/file_configuration.h +++ b/src/core/receiver/file_configuration.h @@ -37,6 +37,7 @@ #define GNSS_SDR_FILE_CONFIGURATION_H_ #include "configuration_interface.h" +#include #include #include @@ -62,10 +63,12 @@ public: ~FileConfiguration(); std::string property(std::string property_name, std::string default_value); bool property(std::string property_name, bool default_value); - long property(std::string property_name, long default_value); - int property(std::string property_name, int default_value); - unsigned int property(std::string property_name, unsigned int default_value); - unsigned short property(std::string property_name, unsigned short default_value); + int64_t property(std::string property_name, int64_t default_value); + uint64_t property(std::string property_name, uint64_t default_value); + int32_t property(std::string property_name, int32_t default_value); + uint32_t property(std::string property_name, uint32_t default_value); + int16_t property(std::string property_name, int16_t default_value); + uint16_t property(std::string property_name, uint16_t default_value); float property(std::string property_name, float default_value); double property(std::string property_name, double default_value); void set_property(std::string property_name, std::string value); diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 93e4a2d0d..b1e226ca8 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -4,13 +4,14 @@ * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2012. luis(at)epsilon-formacion.com * Javier Arribas, 2011. jarribas(at)cttc.es + * Marc Majoral, 2018. mmajoral(at)cttc.es * * This class encapsulates the complexity behind the instantiation * of GNSS blocks. * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -35,77 +36,93 @@ #include "gnss_block_factory.h" -#include "configuration_interface.h" -#include "in_memory_configuration.h" -#include "gnss_block_interface.h" -#include "pass_through.h" -#include "file_signal_source.h" -#include "nsr_file_signal_source.h" -#include "two_bit_cpx_file_signal_source.h" -#include "spir_file_signal_source.h" -#include "spir_gss6450_file_signal_source.h" -#include "rtl_tcp_signal_source.h" -#include "two_bit_packed_file_signal_source.h" -#include "labsat_signal_source.h" -#include "channel.h" -#include "signal_conditioner.h" #include "array_signal_conditioner.h" +#include "beamformer_filter.h" +#include "beidou_b1i_dll_pll_tracking.h" +#include "beidou_b1i_pcps_acquisition.h" +#include "beidou_b1i_telemetry_decoder.h" #include "byte_to_short.h" -#include "ibyte_to_cbyte.h" -#include "ibyte_to_cshort.h" -#include "ibyte_to_complex.h" -#include "ishort_to_cshort.h" -#include "ishort_to_complex.h" +#include "channel.h" +#include "configuration_interface.h" #include "direct_resampler_conditioner.h" -#include "mmse_resampler_conditioner.h" +#include "file_signal_source.h" #include "fir_filter.h" #include "freq_xlating_fir_filter.h" -#include "beamformer_filter.h" -#include "pulse_blanking_filter.h" -#include "notch_filter.h" -#include "notch_filter_lite.h" -#include "gps_l1_ca_pcps_acquisition.h" -#include "gps_l2_m_pcps_acquisition.h" -#include "gps_l5i_pcps_acquisition.h" -#include "gps_l1_ca_pcps_tong_acquisition.h" -#include "gps_l1_ca_pcps_assisted_acquisition.h" -#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" -#include "gps_l1_ca_pcps_quicksync_acquisition.h" -#include "galileo_e1_pcps_ambiguous_acquisition.h" +#include "galileo_e1_dll_pll_veml_tracking.h" #include "galileo_e1_pcps_8ms_ambiguous_acquisition.h" -#include "galileo_e1_pcps_tong_ambiguous_acquisition.h" +#include "galileo_e1_pcps_ambiguous_acquisition.h" #include "galileo_e1_pcps_cccwsr_ambiguous_acquisition.h" #include "galileo_e1_pcps_quicksync_ambiguous_acquisition.h" +#include "galileo_e1_pcps_tong_ambiguous_acquisition.h" +#include "galileo_e1_tcp_connector_tracking.h" +#include "galileo_e1b_telemetry_decoder.h" +#include "galileo_e5a_dll_pll_tracking.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" #include "galileo_e5a_pcps_acquisition.h" -#include "glonass_l1_ca_pcps_acquisition.h" -#include "glonass_l2_ca_pcps_acquisition.h" -#include "gps_l1_ca_dll_pll_tracking.h" -#include "gps_l1_ca_dll_pll_c_aid_tracking.h" -#include "gps_l1_ca_tcp_connector_tracking.h" -#include "galileo_e1_dll_pll_veml_tracking.h" -#include "galileo_e1_tcp_connector_tracking.h" -#include "galileo_e5a_dll_pll_tracking.h" -#include "gps_l2_m_dll_pll_tracking.h" -#include "glonass_l1_ca_dll_pll_tracking.h" -#include "glonass_l1_ca_dll_pll_c_aid_tracking.h" -#include "glonass_l2_ca_dll_pll_tracking.h" -#include "glonass_l2_ca_dll_pll_c_aid_tracking.h" -#include "gps_l5_dll_pll_tracking.h" -#include "gps_l1_ca_telemetry_decoder.h" -#include "gps_l2c_telemetry_decoder.h" -#include "gps_l5_telemetry_decoder.h" -#include "galileo_e1b_telemetry_decoder.h" #include "galileo_e5a_telemetry_decoder.h" +#include "glonass_l1_ca_dll_pll_c_aid_tracking.h" +#include "glonass_l1_ca_dll_pll_tracking.h" +#include "glonass_l1_ca_pcps_acquisition.h" #include "glonass_l1_ca_telemetry_decoder.h" +#include "glonass_l2_ca_dll_pll_c_aid_tracking.h" +#include "glonass_l2_ca_dll_pll_tracking.h" +#include "glonass_l2_ca_pcps_acquisition.h" #include "glonass_l2_ca_telemetry_decoder.h" -#include "sbas_l1_telemetry_decoder.h" +#include "gnss_block_interface.h" +#include "gps_l1_ca_dll_pll_c_aid_tracking.h" +#include "gps_l1_ca_dll_pll_tracking.h" +#include "gps_l1_ca_kf_tracking.h" +#include "gps_l1_ca_pcps_acquisition.h" +#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" +#include "gps_l1_ca_pcps_assisted_acquisition.h" +#include "gps_l1_ca_pcps_quicksync_acquisition.h" +#include "gps_l1_ca_pcps_tong_acquisition.h" +#include "gps_l1_ca_tcp_connector_tracking.h" +#include "gps_l1_ca_telemetry_decoder.h" +#include "gps_l2_m_dll_pll_tracking.h" +#include "gps_l2_m_pcps_acquisition.h" +#include "gps_l2c_telemetry_decoder.h" +#include "gps_l5_dll_pll_tracking.h" +#include "gps_l5_telemetry_decoder.h" +#include "gps_l5i_pcps_acquisition.h" #include "hybrid_observables.h" +#include "ibyte_to_cbyte.h" +#include "ibyte_to_complex.h" +#include "ibyte_to_cshort.h" +#include "in_memory_configuration.h" +#include "ishort_to_complex.h" +#include "ishort_to_cshort.h" +#include "labsat_signal_source.h" +#include "mmse_resampler_conditioner.h" +#include "notch_filter.h" +#include "notch_filter_lite.h" +#include "nsr_file_signal_source.h" +#include "pass_through.h" +#include "pulse_blanking_filter.h" #include "rtklib_pvt.h" +#include "rtl_tcp_signal_source.h" +#include "sbas_l1_telemetry_decoder.h" +#include "signal_conditioner.h" +#include "spir_file_signal_source.h" +#include "spir_gss6450_file_signal_source.h" +#include "two_bit_cpx_file_signal_source.h" +#include "two_bit_packed_file_signal_source.h" + +#if RAW_UDP +#include "custom_udp_signal_source.h" +#endif #if ENABLE_FPGA -#include "gps_l1_ca_pcps_acquisition_fpga.h" +#include "galileo_e1_dll_pll_veml_tracking_fpga.h" +#include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" +#include "galileo_e5a_dll_pll_tracking_fpga.h" +#include "galileo_e5a_pcps_acquisition_fpga.h" #include "gps_l1_ca_dll_pll_tracking_fpga.h" +#include "gps_l1_ca_pcps_acquisition_fpga.h" +#include "gps_l2_m_dll_pll_tracking_fpga.h" +#include "gps_l2_m_pcps_acquisition_fpga.h" +#include "gps_l5_dll_pll_tracking_fpga.h" +#include "gps_l5i_pcps_acquisition_fpga.h" #endif #if OPENCL_BLOCKS @@ -149,22 +166,23 @@ #endif #include -#include -#include #include +#include +#include +#include using google::LogMessage; -GNSSBlockFactory::GNSSBlockFactory() {} +GNSSBlockFactory::GNSSBlockFactory() = default; -GNSSBlockFactory::~GNSSBlockFactory() {} +GNSSBlockFactory::~GNSSBlockFactory() = default; std::unique_ptr GNSSBlockFactory::GetSignalSource( - std::shared_ptr configuration, gr::msg_queue::sptr queue, int ID) + const std::shared_ptr& configuration, const gr::msg_queue::sptr queue, int ID) // NOLINT(performance-unnecessary-value-param) { std::string default_implementation = "File_Signal_Source"; std::string role = "SignalSource"; //backwards compatibility for old conf files @@ -175,7 +193,7 @@ std::unique_ptr GNSSBlockFactory::GetSignalSource( role = "SignalSource" + std::to_string(ID); } } - catch (const std::exception &e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -186,7 +204,7 @@ std::unique_ptr GNSSBlockFactory::GetSignalSource( std::unique_ptr GNSSBlockFactory::GetSignalConditioner( - std::shared_ptr configuration, int ID) + const std::shared_ptr& configuration, int ID) { std::string default_implementation = "Pass_Through"; //backwards compatibility for old conf files @@ -204,7 +222,7 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( role_resampler = "Resampler" + std::to_string(ID); } } - catch (const std::exception &e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -213,7 +231,7 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( std::string data_type_adapter; std::string input_filter; std::string resampler; - if (signal_conditioner.compare("Pass_Through") == 0) + if (signal_conditioner == "Pass_Through") { data_type_adapter = "Pass_Through"; input_filter = "Pass_Through"; @@ -231,30 +249,28 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( << input_filter << ", and Resampler implementation: " << resampler; - if (signal_conditioner.compare("Array_Signal_Conditioner") == 0) + if (signal_conditioner == "Array_Signal_Conditioner") { //instantiate the array version std::unique_ptr conditioner_(new ArraySignalConditioner(configuration.get(), - std::move(GetBlock(configuration, role_datatypeadapter, data_type_adapter, 1, 1)), - std::move(GetBlock(configuration, role_inputfilter, input_filter, 1, 1)), - std::move(GetBlock(configuration, role_resampler, resampler, 1, 1)), - role_conditioner, "Signal_Conditioner")); - return conditioner_; - } - else - { - //single-antenna version - std::unique_ptr conditioner_(new SignalConditioner(configuration.get(), - std::move(GetBlock(configuration, role_datatypeadapter, data_type_adapter, 1, 1)), - std::move(GetBlock(configuration, role_inputfilter, input_filter, 1, 1)), - std::move(GetBlock(configuration, role_resampler, resampler, 1, 1)), + GetBlock(configuration, role_datatypeadapter, data_type_adapter, 1, 1), + GetBlock(configuration, role_inputfilter, input_filter, 1, 1), + GetBlock(configuration, role_resampler, resampler, 1, 1), role_conditioner, "Signal_Conditioner")); return conditioner_; } + + //single-antenna version + std::unique_ptr conditioner_(new SignalConditioner(configuration.get(), + GetBlock(configuration, role_datatypeadapter, data_type_adapter, 1, 1), + GetBlock(configuration, role_inputfilter, input_filter, 1, 1), + GetBlock(configuration, role_resampler, resampler, 1, 1), + role_conditioner, "Signal_Conditioner")); + return conditioner_; } -std::unique_ptr GNSSBlockFactory::GetObservables(std::shared_ptr configuration) +std::unique_ptr GNSSBlockFactory::GetObservables(const std::shared_ptr& configuration) { std::string default_implementation = "Hybrid_Observables"; std::string implementation = configuration->property("Observables.implementation", default_implementation); @@ -265,19 +281,23 @@ std::unique_ptr GNSSBlockFactory::GetObservables(std::shared GPS_channels += configuration->property("Channels_2S.count", 0); GPS_channels += configuration->property("Channels_L5.count", 0); unsigned int Glonass_channels = configuration->property("Channels_1G.count", 0); + Glonass_channels += configuration->property("Channels_2G.count", 0); + unsigned int Beidou_channels = configuration->property("Channels_B1.count", 0); unsigned int extra_channels = 1; // For monitor channel sample counter return GetBlock(configuration, "Observables", implementation, Galileo_channels + GPS_channels + Glonass_channels + + Beidou_channels + extra_channels, Galileo_channels + GPS_channels + - Glonass_channels); + Glonass_channels + + Beidou_channels); } -std::unique_ptr GNSSBlockFactory::GetPVT(std::shared_ptr configuration) +std::unique_ptr GNSSBlockFactory::GetPVT(const std::shared_ptr& configuration) { std::string default_implementation = "RTKLIB_PVT"; std::string implementation = configuration->property("PVT.implementation", default_implementation); @@ -288,14 +308,17 @@ std::unique_ptr GNSSBlockFactory::GetPVT(std::shared_ptrproperty("Channels_2S.count", 0); GPS_channels += configuration->property("Channels_L5.count", 0); unsigned int Glonass_channels = configuration->property("Channels_1G.count", 0); - return GetBlock(configuration, "PVT", implementation, Galileo_channels + GPS_channels + Glonass_channels, 0); + Glonass_channels += configuration->property("Channels_2G.count", 0); + unsigned int Beidou_channels = configuration->property("Channels_B1.count", 0); + return GetBlock(configuration, "PVT", implementation, + Galileo_channels + GPS_channels + Glonass_channels + Beidou_channels, 0); } //********* GPS L1 C/A CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_1C( - std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue) { //"appendix" is added to the "role" with the aim of Acquisition, Tracking and Telemetry Decoder adapters @@ -306,7 +329,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1C( std::string aux = configuration->property("Acquisition_1C" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; - if (aux.compare("W") != 0) + if (aux != "W") { appendix1 = std::to_string(channel); } @@ -316,7 +339,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1C( } aux = configuration->property("Tracking_1C" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; - if (aux.compare("W") != 0) + if (aux != "W") { appendix2 = std::to_string(channel); } @@ -326,7 +349,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1C( } aux = configuration->property("TelemetryDecoder_1C" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; - if (aux.compare("W") != 0) + if (aux != "W") { appendix3 = std::to_string(channel); } @@ -340,22 +363,21 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1C( std::string default_item_type = "gr_complex"; std::string acq_item_type = configuration->property("Acquisition_1C" + appendix1 + ".item_type", default_item_type); std::string trk_item_type = configuration->property("Tracking_1C" + appendix2 + ".item_type", default_item_type); - if (acq_item_type.compare(trk_item_type)) + if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; } config->set_property("Channel.item_type", acq_item_type); - std::unique_ptr pass_through_ = GetBlock(config, "Channel", "Pass_Through", 1, 1, queue); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_1C" + appendix1, acq, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_1C" + appendix2, trk, 1, 1); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_1C" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(acq_), std::move(trk_), std::move(tlm_), - "Channel", "1C", queue)); + "Channel", "1C", std::move(queue))); return channel_; } @@ -363,15 +385,15 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1C( //********* GPS L2C (M) CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_2S( - std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue) { LOG(INFO) << "Instantiating Channel " << channel << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; std::string aux = configuration->property("Acquisition_2S" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; - if (aux.compare("W") != 0) + if (aux != "W") { appendix1 = std::to_string(channel); } @@ -381,7 +403,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2S( } aux = configuration->property("Tracking_2S" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; - if (aux.compare("W") != 0) + if (aux != "W") { appendix2 = std::to_string(channel); } @@ -391,7 +413,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2S( } aux = configuration->property("TelemetryDecoder_2S" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; - if (aux.compare("W") != 0) + if (aux != "W") { appendix3 = std::to_string(channel); } @@ -405,22 +427,21 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2S( std::string default_item_type = "gr_complex"; std::string acq_item_type = configuration->property("Acquisition_2S" + appendix1 + ".item_type", default_item_type); std::string trk_item_type = configuration->property("Tracking_2S" + appendix2 + ".item_type", default_item_type); - if (acq_item_type.compare(trk_item_type)) + if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; } config->set_property("Channel.item_type", acq_item_type); - std::unique_ptr pass_through_ = GetBlock(configuration, "Channel", "Pass_Through", 1, 1, queue); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_2S" + appendix1, acq, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_2S" + appendix2, trk, 1, 1); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_2S" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(acq_), std::move(trk_), std::move(tlm_), - "Channel", "2S", queue)); + "Channel", "2S", std::move(queue))); return channel_; } @@ -428,8 +449,8 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2S( //********* GALILEO E1 B CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_1B( - std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue) { std::stringstream stream; @@ -439,7 +460,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1B( << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; std::string aux = configuration->property("Acquisition_1B" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; - if (aux.compare("W") != 0) + if (aux != "W") { appendix1 = std::to_string(channel); } @@ -449,7 +470,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1B( } aux = configuration->property("Tracking_1B" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; - if (aux.compare("W") != 0) + if (aux != "W") { appendix2 = std::to_string(channel); } @@ -459,7 +480,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1B( } aux = configuration->property("TelemetryDecoder_1B" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; - if (aux.compare("W") != 0) + if (aux != "W") { appendix3 = std::to_string(channel); } @@ -473,22 +494,21 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1B( std::string default_item_type = "gr_complex"; std::string acq_item_type = configuration->property("Acquisition_1B" + appendix1 + ".item_type", default_item_type); std::string trk_item_type = configuration->property("Tracking_1B" + appendix2 + ".item_type", default_item_type); - if (acq_item_type.compare(trk_item_type)) + if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; } config->set_property("Channel.item_type", acq_item_type); - std::unique_ptr pass_through_ = GetBlock(configuration, "Channel", "Pass_Through", 1, 1, queue); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_1B" + appendix1, acq, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_1B" + appendix2, trk, 1, 1); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_1B" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(acq_), std::move(trk_), std::move(tlm_), - "Channel", "1B", queue)); + "Channel", "1B", std::move(queue))); return channel_; } @@ -496,8 +516,8 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1B( //********* GALILEO E5a CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_5X( - std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue) { std::stringstream stream; @@ -507,7 +527,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_5X( << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; std::string aux = configuration->property("Acquisition_5X" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; - if (aux.compare("W") != 0) + if (aux != "W") { appendix1 = std::to_string(channel); } @@ -517,7 +537,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_5X( } aux = configuration->property("Tracking_5X" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; - if (aux.compare("W") != 0) + if (aux != "W") { appendix2 = std::to_string(channel); } @@ -527,7 +547,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_5X( } aux = configuration->property("TelemetryDecoder_5X" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; - if (aux.compare("W") != 0) + if (aux != "W") { appendix3 = std::to_string(channel); } @@ -541,22 +561,21 @@ std::unique_ptr GNSSBlockFactory::GetChannel_5X( std::string default_item_type = "gr_complex"; std::string acq_item_type = configuration->property("Acquisition_5X" + appendix1 + ".item_type", default_item_type); std::string trk_item_type = configuration->property("Tracking_5X" + appendix2 + ".item_type", default_item_type); - if (acq_item_type.compare(trk_item_type)) + if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; } config->set_property("Channel.item_type", acq_item_type); - std::unique_ptr pass_through_ = GetBlock(configuration, "Channel", "Pass_Through", 1, 1, queue); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_5X" + appendix1, acq, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_5X" + appendix2, trk, 1, 1); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_5X" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(acq_), std::move(trk_), std::move(tlm_), - "Channel", "5X", queue)); + "Channel", "5X", std::move(queue))); return channel_; } @@ -564,8 +583,8 @@ std::unique_ptr GNSSBlockFactory::GetChannel_5X( //********* GLONASS L1 C/A CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_1G( - std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, boost::shared_ptr queue) { std::stringstream stream; @@ -576,7 +595,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1G( std::string aux = configuration->property("Acquisition_1G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; - if (aux.compare("W") != 0) + if (aux != "W") { appendix1 = std::to_string(channel); } @@ -586,7 +605,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1G( } aux = configuration->property("Tracking_1G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; - if (aux.compare("W") != 0) + if (aux != "W") { appendix2 = std::to_string(channel); } @@ -596,7 +615,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1G( } aux = configuration->property("TelemetryDecoder_1G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; - if (aux.compare("W") != 0) + if (aux != "W") { appendix3 = std::to_string(channel); } @@ -610,22 +629,21 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1G( std::string default_item_type = "gr_complex"; std::string acq_item_type = configuration->property("Acquisition_1G" + appendix1 + ".item_type", default_item_type); std::string trk_item_type = configuration->property("Tracking_1G" + appendix2 + ".item_type", default_item_type); - if (acq_item_type.compare(trk_item_type)) + if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; } config->set_property("Channel.item_type", acq_item_type); - std::unique_ptr pass_through_ = GetBlock(config, "Channel", "Pass_Through", 1, 1, queue); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_1G" + appendix1, acq, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_1G" + appendix2, trk, 1, 1); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_1G" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(acq_), std::move(trk_), std::move(tlm_), - "Channel", "1G", queue)); + "Channel", "1G", std::move(queue))); return channel_; } @@ -633,8 +651,8 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1G( //********* GLONASS L2 C/A CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_2G( - std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, boost::shared_ptr queue) { std::stringstream stream; @@ -645,7 +663,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2G( std::string aux = configuration->property("Acquisition_2G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; - if (aux.compare("W") != 0) + if (aux != "W") { appendix1 = std::to_string(channel); } @@ -655,7 +673,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2G( } aux = configuration->property("Tracking_2G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; - if (aux.compare("W") != 0) + if (aux != "W") { appendix2 = std::to_string(channel); } @@ -665,7 +683,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2G( } aux = configuration->property("TelemetryDecoder_2G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; - if (aux.compare("W") != 0) + if (aux != "W") { appendix3 = std::to_string(channel); } @@ -679,22 +697,21 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2G( std::string default_item_type = "gr_complex"; std::string acq_item_type = configuration->property("Acquisition_2G" + appendix1 + ".item_type", default_item_type); std::string trk_item_type = configuration->property("Tracking_2G" + appendix2 + ".item_type", default_item_type); - if (acq_item_type.compare(trk_item_type)) + if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; } config->set_property("Channel.item_type", acq_item_type); - std::unique_ptr pass_through_ = GetBlock(config, "Channel", "Pass_Through", 1, 1, queue); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_2G" + appendix1, acq, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_2G" + appendix2, trk, 1, 1); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_2G" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(acq_), std::move(trk_), std::move(tlm_), - "Channel", "2G", queue)); + "Channel", "2G", std::move(queue))); return channel_; } @@ -702,8 +719,8 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2G( //********* GPS L5 CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_L5( - std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue) { std::stringstream stream; @@ -713,7 +730,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_L5( << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; std::string aux = configuration->property("Acquisition_L5" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; - if (aux.compare("W") != 0) + if (aux != "W") { appendix1 = std::to_string(channel); } @@ -723,7 +740,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_L5( } aux = configuration->property("Tracking_L5" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; - if (aux.compare("W") != 0) + if (aux != "W") { appendix2 = std::to_string(channel); } @@ -733,7 +750,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_L5( } aux = configuration->property("TelemetryDecoder_L5" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; - if (aux.compare("W") != 0) + if (aux != "W") { appendix3 = std::to_string(channel); } @@ -747,29 +764,94 @@ std::unique_ptr GNSSBlockFactory::GetChannel_L5( std::string default_item_type = "gr_complex"; std::string acq_item_type = configuration->property("Acquisition_L5" + appendix1 + ".item_type", default_item_type); std::string trk_item_type = configuration->property("Tracking_L5" + appendix2 + ".item_type", default_item_type); - if (acq_item_type.compare(trk_item_type)) + if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; } config->set_property("Channel.item_type", acq_item_type); - std::unique_ptr pass_through_ = GetBlock(configuration, "Channel", "Pass_Through", 1, 1, queue); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_L5" + appendix1, acq, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_L5" + appendix2, trk, 1, 1); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_L5" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(acq_), std::move(trk_), std::move(tlm_), - "Channel", "L5", queue)); + "Channel", "L5", std::move(queue))); return channel_; } +//********* BeiDou B1I CHANNEL ***************** +std::unique_ptr GNSSBlockFactory::GetChannel_B1( + const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, + gr::msg_queue::sptr queue) +{ + std::stringstream stream; + stream << channel; + std::string id = stream.str(); + LOG(INFO) << "Instantiating Channel " << id << " with Acquisition Implementation: " + << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; + std::string aux = configuration->property("Acquisition_B1" + std::to_string(channel) + ".implementation", std::string("W")); + std::string appendix1; + if (aux != "W") + { + appendix1 = std::to_string(channel); + } + else + { + appendix1 = ""; + } + aux = configuration->property("Tracking_B1" + std::to_string(channel) + ".implementation", std::string("W")); + std::string appendix2; + if (aux != "W") + { + appendix2 = std::to_string(channel); + } + else + { + appendix2 = ""; + } + aux = configuration->property("TelemetryDecoder_B1" + std::to_string(channel) + ".implementation", std::string("W")); + std::string appendix3; + if (aux != "W") + { + appendix3 = std::to_string(channel); + } + else + { + appendix3 = ""; + } + // Automatically detect input data type + std::shared_ptr config; + config = std::make_shared(); + std::string default_item_type = "gr_complex"; + std::string acq_item_type = configuration->property("Acquisition_B1" + appendix1 + ".item_type", default_item_type); + std::string trk_item_type = configuration->property("Tracking_B1" + appendix2 + ".item_type", default_item_type); + if (acq_item_type != trk_item_type) + { + LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; + } + config->set_property("Channel.item_type", acq_item_type); + + std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_B1" + appendix1, acq, 1, 0); + std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_B1" + appendix2, trk, 1, 1); + std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_B1" + appendix3, tlm, 1, 1); + + std::unique_ptr channel_(new Channel(configuration.get(), channel, + std::move(acq_), + std::move(trk_), + std::move(tlm_), + "Channel", "B1", std::move(queue))); + + return channel_; +} + std::unique_ptr>> GNSSBlockFactory::GetChannels( - std::shared_ptr configuration, gr::msg_queue::sptr queue) + const std::shared_ptr& configuration, const gr::msg_queue::sptr queue) // NOLINT(performance-unnecessary-value-param) { std::string default_implementation = "Pass_Through"; std::string tracking_implementation; @@ -785,6 +867,7 @@ std::unique_ptr>> GNSSBlockFacto unsigned int Channels_2S_count = configuration->property("Channels_2S.count", 0); unsigned int Channels_5X_count = configuration->property("Channels_5X.count", 0); unsigned int Channels_L5_count = configuration->property("Channels_L5.count", 0); + unsigned int Channels_B1_count = configuration->property("Channels_B1.count", 0); unsigned int total_channels = Channels_1C_count + Channels_1B_count + @@ -792,7 +875,8 @@ std::unique_ptr>> GNSSBlockFacto Channels_2S_count + Channels_2G_count + Channels_5X_count + - Channels_L5_count; + Channels_L5_count + + Channels_B1_count; std::unique_ptr>> channels(new std::vector>(total_channels)); try @@ -818,12 +902,12 @@ std::unique_ptr>> GNSSBlockFacto telemetry_decoder_implementation); // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_1C(configuration, + channels->at(channel_absolute_id) = GetChannel_1C(configuration, acquisition_implementation_specific, tracking_implementation_specific, telemetry_decoder_implementation_specific, channel_absolute_id, - queue)); + queue); channel_absolute_id++; } @@ -847,12 +931,12 @@ std::unique_ptr>> GNSSBlockFacto telemetry_decoder_implementation); // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_2S(configuration, + channels->at(channel_absolute_id) = GetChannel_2S(configuration, acquisition_implementation_specific, tracking_implementation_specific, telemetry_decoder_implementation_specific, channel_absolute_id, - queue)); + queue); channel_absolute_id++; } @@ -876,12 +960,12 @@ std::unique_ptr>> GNSSBlockFacto telemetry_decoder_implementation); // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_L5(configuration, + channels->at(channel_absolute_id) = GetChannel_L5(configuration, acquisition_implementation_specific, tracking_implementation_specific, telemetry_decoder_implementation_specific, channel_absolute_id, - queue)); + queue); channel_absolute_id++; } @@ -905,12 +989,12 @@ std::unique_ptr>> GNSSBlockFacto telemetry_decoder_implementation); // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_1B(configuration, + channels->at(channel_absolute_id) = GetChannel_1B(configuration, acquisition_implementation_specific, tracking_implementation_specific, telemetry_decoder_implementation_specific, channel_absolute_id, - queue)); + queue); channel_absolute_id++; } @@ -934,12 +1018,12 @@ std::unique_ptr>> GNSSBlockFacto telemetry_decoder_implementation); // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_5X(configuration, + channels->at(channel_absolute_id) = GetChannel_5X(configuration, acquisition_implementation_specific, tracking_implementation_specific, telemetry_decoder_implementation_specific, channel_absolute_id, - queue)); + queue); channel_absolute_id++; } @@ -964,12 +1048,12 @@ std::unique_ptr>> GNSSBlockFacto telemetry_decoder_implementation); // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_1G(configuration, + channels->at(channel_absolute_id) = GetChannel_1G(configuration, acquisition_implementation_specific, tracking_implementation_specific, telemetry_decoder_implementation_specific, channel_absolute_id, - queue)); + queue); channel_absolute_id++; } @@ -994,16 +1078,46 @@ std::unique_ptr>> GNSSBlockFacto telemetry_decoder_implementation); // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_2G(configuration, + channels->at(channel_absolute_id) = GetChannel_2G(configuration, acquisition_implementation_specific, tracking_implementation_specific, telemetry_decoder_implementation_specific, channel_absolute_id, - queue)); + queue); + channel_absolute_id++; + } + + //**************** BEIDOU B1I CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_B1_count << " BEIDOU B1I channels"; + acquisition_implementation = configuration->property("Acquisition_B1.implementation", default_implementation); + tracking_implementation = configuration->property("Tracking_B1.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_B1.implementation", default_implementation); + + for (unsigned int i = 0; i < Channels_B1_count; i++) + { + //(i.e. Acquisition_2G0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_B1" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_2G0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_B1" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_B1" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = GetChannel_B1(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue); channel_absolute_id++; } } - catch (const std::exception &e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -1022,22 +1136,22 @@ std::unique_ptr>> GNSSBlockFacto * (see below) */ std::unique_ptr GNSSBlockFactory::GetBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, - unsigned int out_streams, gr::msg_queue::sptr queue) + const std::shared_ptr& configuration, + const std::string& role, + const std::string& implementation, unsigned int in_streams, + unsigned int out_streams, const gr::msg_queue::sptr queue) // NOLINT(performance-unnecessary-value-param) { std::unique_ptr block; //PASS THROUGH ---------------------------------------------------------------- - if (implementation.compare("Pass_Through") == 0) + if (implementation == "Pass_Through") { std::unique_ptr block_(new Pass_Through(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } // SIGNAL SOURCES ------------------------------------------------------------- - else if (implementation.compare("File_Signal_Source") == 0) + else if (implementation == "File_Signal_Source") { try { @@ -1046,13 +1160,30 @@ std::unique_ptr GNSSBlockFactory::GetBlock( block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } - else if (implementation.compare("Nsr_File_Signal_Source") == 0) +#if RAW_UDP + else if (implementation == "Custom_UDP_Signal_Source") + { + try + { + std::unique_ptr block_(new CustomUDPSignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + + catch (const std::exception& e) + { + std::cout << "GNSS-SDR program ended." << std::endl; + exit(1); + } + } +#endif + else if (implementation == "Nsr_File_Signal_Source") { try { @@ -1060,14 +1191,14 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams, queue)); block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } #if MODERN_GNURADIO - else if (implementation.compare("Two_Bit_Cpx_File_Signal_Source") == 0) + else if (implementation == "Two_Bit_Cpx_File_Signal_Source") { try { @@ -1075,13 +1206,13 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams, queue)); block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } - else if (implementation.compare("Two_Bit_Packed_File_Signal_Source") == 0) + else if (implementation == "Two_Bit_Packed_File_Signal_Source") { try { @@ -1089,14 +1220,14 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams, queue)); block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } #endif - else if (implementation.compare("Spir_File_Signal_Source") == 0) + else if (implementation == "Spir_File_Signal_Source") { try { @@ -1104,13 +1235,13 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams, queue)); block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } - else if (implementation.compare("Spir_GSS6450_File_Signal_Source") == 0) + else if (implementation == "Spir_GSS6450_File_Signal_Source") { try { @@ -1118,13 +1249,13 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams, queue)); block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } - else if (implementation.compare("RtlTcp_Signal_Source") == 0) + else if (implementation == "RtlTcp_Signal_Source") { try { @@ -1132,13 +1263,13 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams, queue)); block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } - else if (implementation.compare("Labsat_Signal_Source") == 0) + else if (implementation == "Labsat_Signal_Source") { try { @@ -1147,14 +1278,14 @@ std::unique_ptr GNSSBlockFactory::GetBlock( block = std::move(block_); } - catch (const std::exception &e) + catch (const std::exception& e) { std::cout << "GNSS-SDR program ended." << std::endl; exit(1); } } #if UHD_DRIVER - else if (implementation.compare("UHD_Signal_Source") == 0) + else if (implementation == "UHD_Signal_Source") { std::unique_ptr block_(new UhdSignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1162,7 +1293,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } #endif #if GN3S_DRIVER - else if (implementation.compare("GN3S_Signal_Source") == 0) + else if (implementation == "GN3S_Signal_Source") { std::unique_ptr block_(new Gn3sSignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1171,7 +1302,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( #endif #if RAW_ARRAY_DRIVER - else if (implementation.compare("Raw_Array_Signal_Source") == 0) + else if (implementation == "Raw_Array_Signal_Source") { std::unique_ptr block_(new RawArraySignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1180,7 +1311,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( #endif #if OSMOSDR_DRIVER - else if (implementation.compare("Osmosdr_Signal_Source") == 0) + else if (implementation == "Osmosdr_Signal_Source") { std::unique_ptr block_(new OsmosdrSignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1189,7 +1320,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( #endif #if PLUTOSDR_DRIVER - else if (implementation.compare("Plutosdr_Signal_Source") == 0) + else if (implementation == "Plutosdr_Signal_Source") { std::unique_ptr block_(new PlutosdrSignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1198,7 +1329,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( #endif #if FMCOMMS2_DRIVER - else if (implementation.compare("Fmcomms2_Signal_Source") == 0) + else if (implementation == "Fmcomms2_Signal_Source") { std::unique_ptr block_(new Fmcomms2SignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1207,7 +1338,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( #endif #if AD9361_DRIVER - else if (implementation.compare("Ad9361_Fpga_Signal_Source") == 0) + else if (implementation == "Ad9361_Fpga_Signal_Source") { std::unique_ptr block_(new Ad9361FpgaSignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1216,7 +1347,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( #endif #if FLEXIBAND_DRIVER - else if (implementation.compare("Flexiband_Signal_Source") == 0) + else if (implementation == "Flexiband_Signal_Source") { std::unique_ptr block_(new FlexibandSignalSource(configuration.get(), role, in_streams, out_streams, queue)); @@ -1225,37 +1356,37 @@ std::unique_ptr GNSSBlockFactory::GetBlock( #endif // DATA TYPE ADAPTER ----------------------------------------------------------- - else if (implementation.compare("Byte_To_Short") == 0) + else if (implementation == "Byte_To_Short") { std::unique_ptr block_(new ByteToShort(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Ibyte_To_Cbyte") == 0) + else if (implementation == "Ibyte_To_Cbyte") { std::unique_ptr block_(new IbyteToCbyte(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Ibyte_To_Cshort") == 0) + else if (implementation == "Ibyte_To_Cshort") { std::unique_ptr block_(new IbyteToCshort(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Ibyte_To_Complex") == 0) + else if (implementation == "Ibyte_To_Complex") { std::unique_ptr block_(new IbyteToComplex(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Ishort_To_Cshort") == 0) + else if (implementation == "Ishort_To_Cshort") { std::unique_ptr block_(new IshortToCshort(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Ishort_To_Complex") == 0) + else if (implementation == "Ishort_To_Complex") { std::unique_ptr block_(new IshortToComplex(configuration.get(), role, in_streams, out_streams)); @@ -1263,37 +1394,37 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } // INPUT FILTER ---------------------------------------------------------------- - else if (implementation.compare("Fir_Filter") == 0) + else if (implementation == "Fir_Filter") { std::unique_ptr block_(new FirFilter(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Freq_Xlating_Fir_Filter") == 0) + else if (implementation == "Freq_Xlating_Fir_Filter") { std::unique_ptr block_(new FreqXlatingFirFilter(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Beamformer_Filter") == 0) + else if (implementation == "Beamformer_Filter") { std::unique_ptr block_(new BeamformerFilter(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Pulse_Blanking_Filter") == 0) + else if (implementation == "Pulse_Blanking_Filter") { std::unique_ptr block_(new PulseBlankingFilter(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Notch_Filter") == 0) + else if (implementation == "Notch_Filter") { std::unique_ptr block_(new NotchFilter(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Notch_Filter_Lite") == 0) + else if (implementation == "Notch_Filter_Lite") { std::unique_ptr block_(new NotchFilterLite(configuration.get(), role, in_streams, out_streams)); @@ -1301,14 +1432,14 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } // RESAMPLER ------------------------------------------------------------------- - else if (implementation.compare("Direct_Resampler") == 0) + else if (implementation == "Direct_Resampler") { std::unique_ptr block_(new DirectResamplerConditioner(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if ((implementation.compare("Fractional_Resampler") == 0) || (implementation.compare("Mmse_Resampler") == 0)) + else if ((implementation == "Fractional_Resampler") || (implementation == "Mmse_Resampler")) { std::unique_ptr block_(new MmseResamplerConditioner(configuration.get(), role, in_streams, out_streams)); @@ -1316,7 +1447,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } // ACQUISITION BLOCKS --------------------------------------------------------- - else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); @@ -1324,20 +1455,20 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } #if ENABLE_FPGA - else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition_Fpga") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fpga") { std::unique_ptr block_(new GpsL1CaPcpsAcquisitionFpga(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #endif - else if (implementation.compare("GPS_L1_CA_PCPS_Assisted_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Assisted_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsAssistedAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L1_CA_PCPS_Tong_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Tong_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsTongAcquisition(configuration.get(), role, in_streams, out_streams)); @@ -1345,7 +1476,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } #if OPENCL_BLOCKS - else if (implementation.compare("GPS_L1_CA_PCPS_OpenCl_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_OpenCl_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsOpenClAcquisition(configuration.get(), role, in_streams, out_streams)); @@ -1353,225 +1484,315 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } #endif - else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") { std::unique_ptr block_(new GpsL1CaPcpsAcquisitionFineDoppler(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L1_CA_PCPS_QuickSync_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_QuickSync_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsQuickSyncAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L2_M_PCPS_Acquisition") == 0) + else if (implementation == "GPS_L2_M_PCPS_Acquisition") { std::unique_ptr block_(new GpsL2MPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L5i_PCPS_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "GPS_L2_M_PCPS_Acquisition_Fpga") + { + std::unique_ptr block_(new GpsL2MPcpsAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "GPS_L5i_PCPS_Acquisition") { std::unique_ptr block_(new GpsL5iPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_Ambiguous_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "GPS_L5i_PCPS_Acquisition_Fpga") + { + std::unique_ptr block_(new GpsL5iPcpsAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga") + { + std::unique_ptr block_(new GalileoE1PcpsAmbiguousAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1Pcps8msAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") == 0) + else if (implementation == "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsTongAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") == 0) + else if (implementation == "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsCccwsrAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_Noncoherent_IQ_Acquisition_CAF") == 0) + else if (implementation == "Galileo_E5a_Noncoherent_IQ_Acquisition_CAF") { std::unique_ptr block_(new GalileoE5aNoncoherentIQAcquisitionCaf(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_Pcps_Acquisition") == 0) + else if (implementation == "Galileo_E5a_Pcps_Acquisition") { std::unique_ptr block_(new GalileoE5aPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E5a_Pcps_Acquisition_Fpga") + { + std::unique_ptr block_(new GalileoE5aPcpsAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsQuickSyncAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L1_CA_PCPS_Acquisition") == 0) + else if (implementation == "GLONASS_L1_CA_PCPS_Acquisition") { std::unique_ptr block_(new GlonassL1CaPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_PCPS_Acquisition") == 0) + else if (implementation == "GLONASS_L2_CA_PCPS_Acquisition") { std::unique_ptr block_(new GlonassL2CaPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } + else if (implementation == "BEIDOU_B1I_PCPS_Acquisition") + { + std::unique_ptr block_(new BeidouB1iPcpsAcquisition(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + // TRACKING BLOCKS ------------------------------------------------------------- - else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") { std::unique_ptr block_(new GpsL1CaDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L1_CA_DLL_PLL_C_Aid_Tracking") == 0) + else if (implementation == "GPS_L1_CA_KF_Tracking") + { + std::unique_ptr block_(new GpsL1CaKfTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_DLL_PLL_C_Aid_Tracking") { std::unique_ptr block_(new GpsL1CaDllPllCAidTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #if ENABLE_FPGA - else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_Fpga") { std::unique_ptr block_(new GpsL1CaDllPllTrackingFpga(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #endif - else if (implementation.compare("GPS_L1_CA_TCP_CONNECTOR_Tracking") == 0) + else if (implementation == "GPS_L1_CA_TCP_CONNECTOR_Tracking") { std::unique_ptr block_(new GpsL1CaTcpConnectorTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") { std::unique_ptr block_(new GpsL2MDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if ((implementation.compare("GPS_L5i_DLL_PLL_Tracking") == 0) or (implementation.compare("GPS_L5_DLL_PLL_Tracking") == 0)) +#if ENABLE_FPGA + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking_Fpga") + { + std::unique_ptr block_(new GpsL2MDllPllTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if ((implementation == "GPS_L5i_DLL_PLL_Tracking") or (implementation == "GPS_L5_DLL_PLL_Tracking")) { std::unique_ptr block_(new GpsL5DllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } +#if ENABLE_FPGA + else if ((implementation == "GPS_L5i_DLL_PLL_Tracking_Fpga") or (implementation == "GPS_L5_DLL_PLL_Tracking_Fpga")) + { + std::unique_ptr block_(new GpsL5DllPllTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif #if CUDA_GPU_ACCEL - else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_GPU") == 0) + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_GPU") { std::unique_ptr block_(new GpsL1CaDllPllTrackingGPU(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #endif - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") { std::unique_ptr block_(new GalileoE1DllPllVemlTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_TCP_CONNECTOR_Tracking") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") + { + std::unique_ptr block_(new GalileoE1DllPllVemlTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "Galileo_E1_TCP_CONNECTOR_Tracking") { std::unique_ptr block_(new GalileoE1TcpConnectorTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking") == 0) + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking") { std::unique_ptr block_(new GalileoE5aDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L1_CA_DLL_PLL_Tracking") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking_Fpga") + { + std::unique_ptr block_(new GalileoE5aDllPllTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "GLONASS_L1_CA_DLL_PLL_Tracking") { std::unique_ptr block_(new GlonassL1CaDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking") == 0) + else if (implementation == "GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking") { std::unique_ptr block_(new GlonassL1CaDllPllCAidTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_Tracking") == 0) + else if (implementation == "GLONASS_L2_CA_DLL_PLL_Tracking") { std::unique_ptr block_(new GlonassL2CaDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") == 0) + else if (implementation == "GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") { std::unique_ptr block_(new GlonassL2CaDllPllCAidTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } + else if (implementation == "BEIDOU_B1I_DLL_PLL_Tracking") + { + std::unique_ptr block_(new BeidouB1iDllPllTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } // TELEMETRY DECODERS ---------------------------------------------------------- - else if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0) + else if (implementation == "GPS_L1_CA_Telemetry_Decoder") { std::unique_ptr block_(new GpsL1CaTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L2C_Telemetry_Decoder") == 0) + else if (implementation == "GPS_L2C_Telemetry_Decoder") { std::unique_ptr block_(new GpsL2CTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L5_Telemetry_Decoder") == 0) + else if (implementation == "GPS_L5_Telemetry_Decoder") { std::unique_ptr block_(new GpsL5TelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1B_Telemetry_Decoder") == 0) + else if (implementation == "Galileo_E1B_Telemetry_Decoder") { std::unique_ptr block_(new GalileoE1BTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("SBAS_L1_Telemetry_Decoder") == 0) + else if (implementation == "SBAS_L1_Telemetry_Decoder") { std::unique_ptr block_(new SbasL1TelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_Telemetry_Decoder") == 0) + else if (implementation == "Galileo_E5a_Telemetry_Decoder") { std::unique_ptr block_(new GalileoE5aTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L1_CA_Telemetry_Decoder") == 0) + else if (implementation == "GLONASS_L1_CA_Telemetry_Decoder") { std::unique_ptr block_(new GlonassL1CaTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_Telemetry_Decoder") == 0) + else if (implementation == "GLONASS_L2_CA_Telemetry_Decoder") { std::unique_ptr block_(new GlonassL2CaTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } + else if (implementation == "BEIDOU_B1I_Telemetry_Decoder") + { + std::unique_ptr block_(new BeidouB1iTelemetryDecoder(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + // OBSERVABLES ----------------------------------------------------------------- - else if ((implementation.compare("Hybrid_Observables") == 0) || (implementation.compare("GPS_L1_CA_Observables") == 0) || (implementation.compare("GPS_L2C_Observables") == 0) || - (implementation.compare("Galileo_E5A_Observables") == 0)) + else if ((implementation == "Hybrid_Observables") || (implementation == "GPS_L1_CA_Observables") || (implementation == "GPS_L2C_Observables") || + (implementation == "Galileo_E5A_Observables")) { std::unique_ptr block_(new HybridObservables(configuration.get(), role, in_streams, out_streams)); @@ -1579,9 +1800,9 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } // PVT ------------------------------------------------------------------------- - else if ((implementation.compare("RTKLIB_PVT") == 0) || (implementation.compare("GPS_L1_CA_PVT") == 0) || (implementation.compare("Galileo_E1_PVT") == 0) || (implementation.compare("Hybrid_PVT") == 0)) + else if ((implementation == "RTKLIB_PVT") || (implementation == "GPS_L1_CA_PVT") || (implementation == "Galileo_E1_PVT") || (implementation == "Hybrid_PVT")) { - std::unique_ptr block_(new RtklibPvt(configuration.get(), role, in_streams, + std::unique_ptr block_(new Rtklib_Pvt(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } @@ -1590,7 +1811,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( // Log fatal. This causes execution to stop. LOG(ERROR) << role << "." << implementation << ": Undefined implementation for block"; } - return std::move(block); + return block; } @@ -1603,34 +1824,34 @@ std::unique_ptr GNSSBlockFactory::GetBlock( */ std::unique_ptr GNSSBlockFactory::GetAcqBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, + const std::shared_ptr& configuration, + const std::string& role, + const std::string& implementation, unsigned int in_streams, unsigned int out_streams) { std::unique_ptr block; // ACQUISITION BLOCKS --------------------------------------------------------- - if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0) + if (implementation == "GPS_L1_CA_PCPS_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #if ENABLE_FPGA - else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition_Fpga") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fpga") { std::unique_ptr block_(new GpsL1CaPcpsAcquisitionFpga(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #endif - else if (implementation.compare("GPS_L1_CA_PCPS_Assisted_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Assisted_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsAssistedAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L1_CA_PCPS_Tong_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Tong_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsTongAcquisition(configuration.get(), role, in_streams, out_streams)); @@ -1638,7 +1859,7 @@ std::unique_ptr GNSSBlockFactory::GetAcqBlock( } #if OPENCL_BLOCKS - else if (implementation.compare("GPS_L1_CA_PCPS_OpenCl_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_OpenCl_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsOpenClAcquisition(configuration.get(), role, in_streams, out_streams)); @@ -1646,261 +1867,353 @@ std::unique_ptr GNSSBlockFactory::GetAcqBlock( } #endif - else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") == 0) + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") { std::unique_ptr block_(new GpsL1CaPcpsAcquisitionFineDoppler(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L1_CA_PCPS_QuickSync_Acquisition") == 0) + else if (implementation == "GPS_L1_CA_PCPS_QuickSync_Acquisition") { std::unique_ptr block_(new GpsL1CaPcpsQuickSyncAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L2_M_PCPS_Acquisition") == 0) + else if (implementation == "GPS_L2_M_PCPS_Acquisition") { std::unique_ptr block_(new GpsL2MPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L5i_PCPS_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "GPS_L2_M_PCPS_Acquisition_Fpga") + { + std::unique_ptr block_(new GpsL2MPcpsAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "GPS_L5i_PCPS_Acquisition") { std::unique_ptr block_(new GpsL5iPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_Ambiguous_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "GPS_L5i_PCPS_Acquisition_Fpga") + { + std::unique_ptr block_(new GpsL5iPcpsAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga") + { + std::unique_ptr block_(new GalileoE1PcpsAmbiguousAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1Pcps8msAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") == 0) + else if (implementation == "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsTongAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") == 0) + else if (implementation == "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsCccwsrAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition") == 0) + else if (implementation == "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition") { std::unique_ptr block_(new GalileoE1PcpsQuickSyncAmbiguousAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_Noncoherent_IQ_Acquisition_CAF") == 0) + else if (implementation == "Galileo_E5a_Noncoherent_IQ_Acquisition_CAF") { std::unique_ptr block_(new GalileoE5aNoncoherentIQAcquisitionCaf(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_Pcps_Acquisition") == 0) + else if (implementation == "Galileo_E5a_Pcps_Acquisition") { std::unique_ptr block_(new GalileoE5aPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L1_CA_PCPS_Acquisition") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E5a_Pcps_Acquisition_Fpga") + { + std::unique_ptr block_(new GalileoE5aPcpsAcquisitionFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "GLONASS_L1_CA_PCPS_Acquisition") { std::unique_ptr block_(new GlonassL1CaPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_PCPS_Acquisition") == 0) + else if (implementation == "GLONASS_L2_CA_PCPS_Acquisition") { std::unique_ptr block_(new GlonassL2CaPcpsAcquisition(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } + else if (implementation == "BEIDOU_B1I_PCPS_Acquisition") + { + std::unique_ptr block_(new BeidouB1iPcpsAcquisition(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + else { // Log fatal. This causes execution to stop. LOG(ERROR) << role << "." << implementation << ": Undefined implementation for block"; } - return std::move(block); + return block; } std::unique_ptr GNSSBlockFactory::GetTrkBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, + const std::shared_ptr& configuration, + const std::string& role, + const std::string& implementation, unsigned int in_streams, unsigned int out_streams) { std::unique_ptr block; // TRACKING BLOCKS ------------------------------------------------------------- - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) + if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") { std::unique_ptr block_(new GpsL1CaDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L1_CA_DLL_PLL_C_Aid_Tracking") == 0) + else if (implementation == "GPS_L1_CA_KF_Tracking") + { + std::unique_ptr block_(new GpsL1CaKfTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_DLL_PLL_C_Aid_Tracking") { std::unique_ptr block_(new GpsL1CaDllPllCAidTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #if ENABLE_FPGA - else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_Fpga") { std::unique_ptr block_(new GpsL1CaDllPllTrackingFpga(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #endif - else if (implementation.compare("GPS_L1_CA_TCP_CONNECTOR_Tracking") == 0) + else if (implementation == "GPS_L1_CA_TCP_CONNECTOR_Tracking") { std::unique_ptr block_(new GpsL1CaTcpConnectorTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") { std::unique_ptr block_(new GalileoE1DllPllVemlTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1_TCP_CONNECTOR_Tracking") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") + { + std::unique_ptr block_(new GalileoE1DllPllVemlTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "Galileo_E1_TCP_CONNECTOR_Tracking") { std::unique_ptr block_(new GalileoE1TcpConnectorTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking") == 0) + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking") { std::unique_ptr block_(new GalileoE5aDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) +#if ENABLE_FPGA + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking_Fpga") + { + std::unique_ptr block_(new GalileoE5aDllPllTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") { std::unique_ptr block_(new GpsL2MDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if ((implementation.compare("GPS_L5i_DLL_PLL_Tracking") == 0) or (implementation.compare("GPS_L5_DLL_PLL_Tracking") == 0)) +#if ENABLE_FPGA + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking_Fpga") + { + std::unique_ptr block_(new GpsL2MDllPllTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif + else if ((implementation == "GPS_L5i_DLL_PLL_Tracking") or (implementation == "GPS_L5_DLL_PLL_Tracking")) { std::unique_ptr block_(new GpsL5DllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } +#if ENABLE_FPGA + else if ((implementation == "GPS_L5i_DLL_PLL_Tracking_Fpga") or (implementation == "GPS_L5_DLL_PLL_Tracking_Fpga")) + { + std::unique_ptr block_(new GpsL5DllPllTrackingFpga(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } +#endif #if CUDA_GPU_ACCEL - else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_GPU") == 0) + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_GPU") { std::unique_ptr block_(new GpsL1CaDllPllTrackingGPU(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } #endif - else if (implementation.compare("GLONASS_L1_CA_DLL_PLL_Tracking") == 0) + else if (implementation == "GLONASS_L1_CA_DLL_PLL_Tracking") { std::unique_ptr block_(new GlonassL1CaDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking") == 0) + else if (implementation == "GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking") { std::unique_ptr block_(new GlonassL1CaDllPllCAidTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_Tracking") == 0) + else if (implementation == "GLONASS_L2_CA_DLL_PLL_Tracking") { std::unique_ptr block_(new GlonassL2CaDllPllTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") == 0) + else if (implementation == "GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") { std::unique_ptr block_(new GlonassL2CaDllPllCAidTracking(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } + else if (implementation == "BEIDOU_B1I_DLL_PLL_Tracking") + { + std::unique_ptr block_(new BeidouB1iDllPllTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + else { // Log fatal. This causes execution to stop. LOG(ERROR) << role << "." << implementation << ": Undefined implementation for block"; } - return std::move(block); + return block; } std::unique_ptr GNSSBlockFactory::GetTlmBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, + const std::shared_ptr& configuration, + const std::string& role, + const std::string& implementation, unsigned int in_streams, unsigned int out_streams) { std::unique_ptr block; // TELEMETRY DECODERS ---------------------------------------------------------- - if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0) + if (implementation == "GPS_L1_CA_Telemetry_Decoder") { std::unique_ptr block_(new GpsL1CaTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E1B_Telemetry_Decoder") == 0) + else if (implementation == "Galileo_E1B_Telemetry_Decoder") { std::unique_ptr block_(new GalileoE1BTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("SBAS_L1_Telemetry_Decoder") == 0) + else if (implementation == "SBAS_L1_Telemetry_Decoder") { std::unique_ptr block_(new SbasL1TelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("Galileo_E5a_Telemetry_Decoder") == 0) + else if (implementation == "Galileo_E5a_Telemetry_Decoder") { std::unique_ptr block_(new GalileoE5aTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L2C_Telemetry_Decoder") == 0) + else if (implementation == "GPS_L2C_Telemetry_Decoder") { std::unique_ptr block_(new GpsL2CTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L1_CA_Telemetry_Decoder") == 0) + else if (implementation == "GLONASS_L1_CA_Telemetry_Decoder") { std::unique_ptr block_(new GlonassL1CaTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GLONASS_L2_CA_Telemetry_Decoder") == 0) + else if (implementation == "GLONASS_L2_CA_Telemetry_Decoder") { std::unique_ptr block_(new GlonassL2CaTelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } - else if (implementation.compare("GPS_L5_Telemetry_Decoder") == 0) + else if (implementation == "GPS_L5_Telemetry_Decoder") { std::unique_ptr block_(new GpsL5TelemetryDecoder(configuration.get(), role, in_streams, out_streams)); block = std::move(block_); } + else if (implementation == "BEIDOU_B1I_Telemetry_Decoder") + { + std::unique_ptr block_(new BeidouB1iTelemetryDecoder(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + + else { // Log fatal. This causes execution to stop. LOG(ERROR) << role << "." << implementation << ": Undefined implementation for block"; } - return std::move(block); + return block; } diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index a66e6917e..2b2acc8b6 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -57,71 +57,75 @@ class GNSSBlockFactory public: GNSSBlockFactory(); virtual ~GNSSBlockFactory(); - std::unique_ptr GetSignalSource(std::shared_ptr configuration, - gr::msg_queue::sptr queue, int ID = -1); + std::unique_ptr GetSignalSource(const std::shared_ptr& configuration, + const gr::msg_queue::sptr queue, int ID = -1); // NOLINT(performance-unnecessary-value-param) - std::unique_ptr GetSignalConditioner(std::shared_ptr configuration, int ID = -1); + std::unique_ptr GetSignalConditioner(const std::shared_ptr& configuration, int ID = -1); - std::unique_ptr GetPVT(std::shared_ptr configuration); + std::unique_ptr GetPVT(const std::shared_ptr& configuration); - std::unique_ptr GetObservables(std::shared_ptr configuration); + std::unique_ptr GetObservables(const std::shared_ptr& configuration); - std::unique_ptr>> GetChannels(std::shared_ptr configuration, - gr::msg_queue::sptr queue); + std::unique_ptr>> GetChannels(const std::shared_ptr& configuration, + const gr::msg_queue::sptr queue); // NOLINT(performance-unnecessary-value-param) /* * \brief Returns the block with the required configuration and implementation */ - std::unique_ptr GetBlock(std::shared_ptr configuration, - std::string role, std::string implementation, + std::unique_ptr GetBlock(const std::shared_ptr& configuration, + const std::string& role, const std::string& implementation, unsigned int in_streams, unsigned int out_streams, - gr::msg_queue::sptr queue = nullptr); + const gr::msg_queue::sptr queue = nullptr); // NOLINT(performance-unnecessary-value-param) private: - std::unique_ptr GetChannel_1C(std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + std::unique_ptr GetChannel_1C(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue); - std::unique_ptr GetChannel_2S(std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + std::unique_ptr GetChannel_2S(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue); - std::unique_ptr GetChannel_1B(std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + std::unique_ptr GetChannel_1B(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue); - std::unique_ptr GetChannel_5X(std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + std::unique_ptr GetChannel_5X(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue); - std::unique_ptr GetChannel_L5(std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + std::unique_ptr GetChannel_L5(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, gr::msg_queue::sptr queue); - std::unique_ptr GetChannel_1G(std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + std::unique_ptr GetChannel_1G(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, boost::shared_ptr queue); - std::unique_ptr GetChannel_2G(std::shared_ptr configuration, - std::string acq, std::string trk, std::string tlm, int channel, + std::unique_ptr GetChannel_2G(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, + boost::shared_ptr queue); + + std::unique_ptr GetChannel_B1(const std::shared_ptr& configuration, + const std::string& acq, const std::string& trk, const std::string& tlm, int channel, boost::shared_ptr queue); std::unique_ptr GetAcqBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, + const std::shared_ptr& configuration, + const std::string& role, + const std::string& implementation, unsigned int in_streams, unsigned int out_streams); std::unique_ptr GetTrkBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, + const std::shared_ptr& configuration, + const std::string& role, + const std::string& implementation, unsigned int in_streams, unsigned int out_streams); std::unique_ptr GetTlmBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, + const std::shared_ptr& configuration, + const std::string& role, + const std::string& implementation, unsigned int in_streams, unsigned int out_streams); }; diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 83ad6807a..8c01a9afc 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -4,10 +4,12 @@ * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2012. luis(at)epsilon-formacion.com * Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es + * Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com + * Javier Arribas, 2018. javiarribas(at)gmail.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -31,29 +33,40 @@ */ #include "gnss_flowgraph.h" -#include "gnss_synchro.h" -#include "configuration_interface.h" -#include "gnss_block_interface.h" +#include "GPS_L1_CA.h" +#include "GPS_L2C.h" +#include "GPS_L5.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "channel.h" #include "channel_interface.h" +#include "configuration_interface.h" #include "gnss_block_factory.h" #include #include #include +#include #include #include #include #include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif #define GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS 8 using google::LogMessage; -GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configuration, gr::msg_queue::sptr queue) +GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configuration, const gr::msg_queue::sptr queue) // NOLINT(performance-unnecessary-value-param) { connected_ = false; running_ = false; - configuration_ = configuration; + configuration_ = std::move(configuration); queue_ = queue; init(); } @@ -110,6 +123,7 @@ void GNSSFlowgraph::connect() return; } +#ifndef ENABLE_FPGA for (int i = 0; i < sources_count_; i++) { if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) @@ -128,6 +142,7 @@ void GNSSFlowgraph::connect() } } + // Signal Source > Signal conditioner > for (unsigned int i = 0; i < sig_conditioner_.size(); i++) { @@ -146,7 +161,7 @@ void GNSSFlowgraph::connect() } } } - +#endif for (unsigned int i = 0; i < channels_count_; i++) { try @@ -192,78 +207,78 @@ void GNSSFlowgraph::connect() int RF_Channels = 0; int signal_conditioner_ID = 0; + +#ifndef ENABLE_FPGA + for (int i = 0; i < sources_count_; i++) { - //FPGA Accelerators do not need signal sources or conditioners - //as the samples are feed directly to the FPGA fabric, so, if enabled, do not connect any source - if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) + try { - try + //TODO: Remove this array implementation and create generic multistream connector + //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") { - //TODO: Remove this array implementation and create generic multistream connector - //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation().compare("Raw_Array_Signal_Source") == 0) + //Multichannel Array + std::cout << "ARRAY MODE" << std::endl; + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) { - //Multichannel Array - std::cout << "ARRAY MODE" << std::endl; - for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) - { - std::cout << "connecting ch " << j << std::endl; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); - } + std::cout << "connecting ch " << j << std::endl; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); } - else + } + else + { + //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + //Include GetRFChannels in the interface to avoid read config parameters here + //read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + + for (int j = 0; j < RF_Channels; j++) { - //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - //Include GetRFChannels in the interface to avoid read config parameters here - //read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + //Connect the multichannel signal source to multiple signal conditioners + // GNURADIO max_streams=-1 means infinite ports! + LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); + LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); - for (int j = 0; j < RF_Channels; j++) + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) { - //Connect the multichannel signal source to multiple signal conditioners - // GNURADIO max_streams=-1 means infinite ports! - LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); - LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); - - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) { - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + // RF_channel 0 backward compatibility with single channel sources + LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } else { - if (j == 0) - { - // RF_channel 0 backward compatibility with single channel sources - LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } - signal_conditioner_ID++; } + signal_conditioner_ID++; } } - catch (const std::exception& e) - { - LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; - LOG(ERROR) << e.what(); - top_block_->disconnect_all(); - return; - } + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; } } DLOG(INFO) << "Signal source connected to signal conditioner"; - bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); + +#endif #if ENABLE_FPGA - if (FPGA_enabled == false) + + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) { //connect the signal source to sample counter //connect the sample counter to Observables @@ -276,7 +291,8 @@ void GNSSFlowgraph::connect() std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); } - ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); + int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); + ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse } @@ -290,21 +306,23 @@ void GNSSFlowgraph::connect() } else { - //create a software-defined 1kHz gnss_synchro pulse for the observables block + //create a hardware-defined gnss_synchro pulse for the observables block try { - //null source - null_source_ = gr::blocks::null_source::make(sizeof(Gnss_Synchro)); - //throttle 1kHz - throttle_ = gr::blocks::throttle::make(sizeof(Gnss_Synchro), 1000); // 1000 samples per second (1kHz) - time_counter_ = gnss_sdr_make_time_counter(); - top_block_->connect(null_source_, 0, throttle_, 0); - top_block_->connect(throttle_, 0, time_counter_, 0); - top_block_->connect(time_counter_, 0, observables_->get_left_block(), channels_count_); + double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); + if (fs == 0.0) + { + LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; + std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; + throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); + } + int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); + ch_out_fpga_sample_counter = gnss_sdr_make_fpga_sample_counter(fs, observable_interval_ms); + top_block_->connect(ch_out_fpga_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse } catch (const std::exception& e) { - LOG(WARNING) << "Can't connect sample counter"; + LOG(WARNING) << "Can't connect FPGA sample counter"; LOG(ERROR) << e.what(); top_block_->disconnect_all(); return; @@ -322,7 +340,9 @@ void GNSSFlowgraph::connect() std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); } - ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); + + int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); + ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse } @@ -334,11 +354,15 @@ void GNSSFlowgraph::connect() return; } #endif + // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) int selected_signal_conditioner_ID = 0; + bool use_acq_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); + uint32_t fs = configuration_->property("GNSS-SDR.internal_fs_sps", 0); for (unsigned int i = 0; i < channels_count_; i++) { - if (FPGA_enabled == false) +#ifndef ENABLE_FPGA + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) { try { @@ -350,8 +374,122 @@ void GNSSFlowgraph::connect() } try { - top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, - channels_.at(i)->get_left_block(), 0); + // Enable automatic resampler for the acquisition, if required + if (use_acq_resampler == true) + { + //create acquisition resamplers if required + double resampler_ratio = 1.0; + double acq_fs = fs; + //find the signal associated to this channel + switch (mapStringValues_[channels_.at(i)->implementation()]) + { + case evGPS_1C: + acq_fs = GPS_L1_CA_OPT_ACQ_FS_HZ; + break; + case evGPS_2S: + acq_fs = GPS_L2C_OPT_ACQ_FS_HZ; + break; + case evGPS_L5: + acq_fs = GPS_L5_OPT_ACQ_FS_HZ; + break; + case evSBAS_1C: + acq_fs = GPS_L1_CA_OPT_ACQ_FS_HZ; + break; + case evGAL_1B: + acq_fs = GALILEO_E1_OPT_ACQ_FS_HZ; + break; + case evGAL_5X: + acq_fs = GALILEO_E5A_OPT_ACQ_FS_HZ; + break; + case evGLO_1G: + acq_fs = fs; + break; + case evGLO_2G: + acq_fs = fs; + break; + case evBDS_B1: + acq_fs = fs; + break; + } + + if (acq_fs < fs) + { + //check if the resampler is already created for the channel system/signal and for the specific RF Channel + std::string map_key = channels_.at(i)->implementation() + std::to_string(selected_signal_conditioner_ID); + resampler_ratio = static_cast(fs) / acq_fs; + int decimation = floor(resampler_ratio); + while (fs % decimation > 0) + { + decimation--; + }; + double acq_fs = static_cast(fs) / static_cast(decimation); + + if (decimation > 1) + { + //create a FIR low pass filter + std::vector taps; + taps = gr::filter::firdes::low_pass(1.0, + fs, + acq_fs / 2.1, + acq_fs / 10, + gr::filter::firdes::win_type::WIN_HAMMING); + + gr::basic_block_sptr fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(decimation, taps); + + std::pair::iterator, bool> ret; + ret = acq_resamplers_.insert(std::pair(map_key, fir_filter_ccf_)); + if (ret.second == true) + { + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + acq_resamplers_.at(map_key), 0); + LOG(INFO) << "Created " + << channels_.at(i)->implementation() + << " acquisition resampler for RF channel " << std::to_string(signal_conditioner_ID) << " with " << taps.size() << " taps and decimation factor of " << decimation; + } + else + { + LOG(INFO) << "Found existing " + << channels_.at(i)->implementation() + << " acquisition resampler for RF channel " << std::to_string(signal_conditioner_ID) << " with " << taps.size() << " taps and decimation factor of " << decimation; + } + + + top_block_->connect(acq_resamplers_.at(map_key), 0, + channels_.at(i)->get_left_block_acq(), 0); + + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block_trk(), 0); + + std::shared_ptr channel_ptr; + channel_ptr = std::dynamic_pointer_cast(channels_.at(i)); + channel_ptr->acquisition()->set_resampler_latency((taps.size() - 1) / 2); + } + else + { + LOG(INFO) << "Disabled acquisition resampler because the input sampling frequency is too low"; + //resampler not required! + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block_acq(), 0); + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block_trk(), 0); + } + } + else + { + LOG(INFO) << "Disabled acquisition resampler because the input sampling frequency is too low"; + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block_acq(), 0); + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block_trk(), 0); + } + } + else + { + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block_acq(), 0); + top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block_trk(), 0); + } } catch (const std::exception& e) { @@ -363,6 +501,7 @@ void GNSSFlowgraph::connect() DLOG(INFO) << "signal conditioner " << selected_signal_conditioner_ID << " connected to channel " << i; } +#endif // Signal Source > Signal conditioner >> Channels >> Observables try { @@ -417,16 +556,70 @@ void GNSSFlowgraph::connect() } if (sat == 0) { - channels_.at(i)->set_signal(search_next_signal(gnss_signal, true)); + channels_.at(i)->set_signal(search_next_signal(gnss_signal, false)); } else { std::string gnss_system; - if ((gnss_signal.compare("1C") == 0) or (gnss_signal.compare("2S") == 0) or (gnss_signal.compare("L5") == 0)) gnss_system = "GPS"; - if ((gnss_signal.compare("1B") == 0) or (gnss_signal.compare("5X") == 0)) gnss_system = "Galileo"; - if ((gnss_signal.compare("1G") == 0) or (gnss_signal.compare("2G") == 0)) gnss_system = "Glonass"; - Gnss_Signal signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); - available_GNSS_signals_.remove(signal_value); + Gnss_Signal signal_value; + switch (mapStringValues_[gnss_signal]) + { + case evGPS_1C: + gnss_system = "GPS"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GPS_1C_signals_.remove(signal_value); + break; + + case evGPS_2S: + gnss_system = "GPS"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GPS_2S_signals_.remove(signal_value); + break; + + case evGPS_L5: + gnss_system = "GPS"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GPS_L5_signals_.remove(signal_value); + break; + + case evGAL_1B: + gnss_system = "Galileo"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GAL_1B_signals_.remove(signal_value); + break; + + case evGAL_5X: + gnss_system = "Galileo"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GAL_5X_signals_.remove(signal_value); + break; + + case evGLO_1G: + gnss_system = "Glonass"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GLO_1G_signals_.remove(signal_value); + break; + + case evGLO_2G: + gnss_system = "Glonass"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GLO_2G_signals_.remove(signal_value); + break; + + case evBDS_B1: + gnss_system = "Beidou"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_BDS_B1_signals_.remove(signal_value); + break; + + default: + LOG(ERROR) << "This should not happen :-("; + gnss_system = "GPS"; + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GPS_1C_signals_.remove(signal_value); + break; + } + channels_.at(i)->set_signal(signal_value); } } @@ -448,16 +641,34 @@ void GNSSFlowgraph::connect() return; } + // GNSS SYNCHRO MONITOR + if (enable_monitor_) + { + try + { + for (unsigned int i = 0; i < channels_count_; i++) + { + top_block_->connect(observables_->get_right_block(), i, GnssSynchroMonitor_, i); + } + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect observables to Monitor block"; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } + } + + +#ifndef ENABLE_FPGA // Activate acquisition in enabled channels for (unsigned int i = 0; i < channels_count_; i++) { LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal(); if (channels_state_[i] == 1) { - if (FPGA_enabled == false) - { - channels_.at(i)->start_acquisition(); - } + channels_.at(i)->start_acquisition(); LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition"; } else @@ -465,6 +676,7 @@ void GNSSFlowgraph::connect() LOG(INFO) << "Channel " << i << " connected to observables in standby mode"; } } +#endif connected_ = true; LOG(INFO) << "Flowgraph connected"; @@ -486,13 +698,73 @@ void GNSSFlowgraph::disconnect() int RF_Channels = 0; int signal_conditioner_ID = 0; + +#ifdef ENABLE_FPGA + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) + { + for (int i = 0; i < sources_count_; i++) + { + try + { + // TODO: Remove this array implementation and create generic multistream connector + // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + + for (int j = 0; j < RF_Channels; j++) + { + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); + top_block_->disconnect_all(); + return; + } + } + } + + +#else + for (int i = 0; i < sources_count_; i++) { try { // TODO: Remove this array implementation and create generic multistream connector // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation().compare("Raw_Array_Signal_Source") == 0) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") { //Multichannel Array for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) @@ -537,10 +809,10 @@ void GNSSFlowgraph::disconnect() return; } } +#endif -#if ENABLE_FPGA - bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); - if (FPGA_enabled == false) +#ifdef ENABLE_FPGA + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) { // disconnect the signal source to sample counter // disconnect the sample counter to Observables @@ -561,13 +833,11 @@ void GNSSFlowgraph::disconnect() { try { - top_block_->disconnect(null_source_, 0, throttle_, 0); - top_block_->disconnect(throttle_, 0, time_counter_, 0); - top_block_->disconnect(time_counter_, 0, observables_->get_left_block(), channels_count_); + top_block_->disconnect(ch_out_fpga_sample_counter, 0, observables_->get_left_block(), channels_count_); } catch (const std::exception& e) { - LOG(WARNING) << "Can't connect sample counter"; + LOG(WARNING) << "Can't connect FPGA sample counter"; LOG(ERROR) << e.what(); top_block_->disconnect_all(); return; @@ -603,10 +873,11 @@ void GNSSFlowgraph::disconnect() top_block_->disconnect_all(); return; } +#ifndef ENABLE_FPGA try { top_block_->disconnect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, - channels_.at(i)->get_left_block(), 0); + channels_.at(i)->get_left_block_trk(), 0); } catch (const std::exception& e) { @@ -614,7 +885,7 @@ void GNSSFlowgraph::disconnect() top_block_->disconnect_all(); return; } - +#endif // Signal Source > Signal conditioner >> Channels >> Observables try { @@ -634,6 +905,10 @@ void GNSSFlowgraph::disconnect() for (unsigned int i = 0; i < channels_count_; i++) { top_block_->disconnect(observables_->get_right_block(), i, pvt_->get_left_block(), i); + if (enable_monitor_) + { + top_block_->disconnect(observables_->get_right_block(), i, GnssSynchroMonitor_, i); + } top_block_->msg_disconnect(channels_.at(i)->get_right_block(), pmt::mp("telemetry"), pvt_->get_left_block(), pmt::mp("telemetry")); } } @@ -728,10 +1003,10 @@ void GNSSFlowgraph::wait() } -bool GNSSFlowgraph::send_telemetry_msg(pmt::pmt_t msg) +bool GNSSFlowgraph::send_telemetry_msg(const pmt::pmt_t& msg) { - //push ephemeris to PVT telemetry msg in port using a channel out port - // it uses the first channel as a message produces (it is already connected to PVT) + // Push ephemeris to PVT telemetry msg in port using a channel out port + // it uses the first channel as a message producer (it is already connected to PVT) channels_.at(0)->get_right_block()->message_port_pub(pmt::mp("telemetry"), msg); return true; } @@ -740,20 +1015,40 @@ bool GNSSFlowgraph::send_telemetry_msg(pmt::pmt_t msg) /* * Applies an action to the flow graph * - * \param[in] who Who generated the action - * \param[in] what What is the action 0: acquisition failed + * \param[in] who Who generated the action: + * -> 0-199 are the channels IDs + * -> 200 is the control_thread dispatched by the control_thread apply_action + * -> 300 is the telecommand system (TC) for receiver control + * -> 400 - 599 is the TC channel control for channels 0-199 + * \param[in] what What is the action: + * --- actions from channels --- + * -> 0 acquisition failed + * -> 1 acquisition succesfull + * -> 2 tracking lost + * --- actions from TC receiver control --- + * -> 10 TC request standby mode + * -> 11 TC request coldstart + * -> 12 TC request hotstart + * -> 13 TC request warmstart + * --- actions from TC channel control --- + * -> 20 stop channel + * -> 21 start channel */ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) { + std::lock_guard lock(signal_list_mutex); DLOG(INFO) << "Received " << what << " from " << who << ". Number of applied actions = " << applied_actions_; unsigned int sat = 0; - try + if (who < 200) { - sat = configuration_->property("Channel" + std::to_string(who) + ".satellite", 0); - } - catch (const std::exception& e) - { - LOG(WARNING) << e.what(); + try + { + sat = configuration_->property("Channel" + std::to_string(who) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } } switch (what) { @@ -761,16 +1056,132 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) DLOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str(); if (sat == 0) { - std::lock_guard lock(signal_list_mutex); - available_GNSS_signals_.push_back(channels_[who]->get_signal()); - channels_[who]->set_signal(search_next_signal(channels_[who]->get_signal().get_signal_str(), true)); + Gnss_Signal gs = channels_[who]->get_signal(); + switch (mapStringValues_[gs.get_signal_str()]) + { + case evGPS_1C: + available_GPS_1C_signals_.remove(gs); + available_GPS_1C_signals_.push_back(gs); + break; + + case evGPS_2S: + available_GPS_2S_signals_.remove(gs); + available_GPS_2S_signals_.push_back(gs); + break; + + case evGPS_L5: + available_GPS_L5_signals_.remove(gs); + available_GPS_L5_signals_.push_back(gs); + break; + + case evGAL_1B: + available_GAL_1B_signals_.remove(gs); + available_GAL_1B_signals_.push_back(gs); + break; + + case evGAL_5X: + available_GAL_5X_signals_.remove(gs); + available_GAL_5X_signals_.push_back(gs); + break; + + case evGLO_1G: + available_GLO_1G_signals_.remove(gs); + available_GLO_1G_signals_.push_back(gs); + break; + + case evGLO_2G: + available_GLO_2G_signals_.remove(gs); + available_GLO_2G_signals_.push_back(gs); + break; + + case evBDS_B1: + available_BDS_B1_signals_.push_back(channels_[who]->get_signal()); + break; + + default: + LOG(ERROR) << "This should not happen :-("; + break; + } + } + channels_state_[who] = 0; + acq_channels_count_--; + for (unsigned int i = 0; i < channels_count_; i++) + { + unsigned int ch_index = (who + i + 1) % channels_count_; + unsigned int sat_ = 0; + try + { + sat_ = configuration_->property("Channel" + std::to_string(ch_index) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + if ((acq_channels_count_ < max_acq_channels_) && (channels_state_[ch_index] == 0)) + { + channels_state_[ch_index] = 1; + if (sat_ == 0) + { + channels_[ch_index]->set_signal(search_next_signal(channels_[ch_index]->get_signal().get_signal_str(), true)); + } + acq_channels_count_++; + DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); + +#ifndef ENABLE_FPGA + channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); + tmp_thread.detach(); +#endif + } + DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; } - DLOG(INFO) << "Channel " << who << " Starting acquisition " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str(); - channels_[who]->start_acquisition(); break; case 1: LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channels_[who]->get_signal().get_satellite(); + + // If the satellite is in the list of available ones, remove it. + switch (mapStringValues_[channels_[who]->get_signal().get_signal_str()]) + { + case evGPS_1C: + available_GPS_1C_signals_.remove(channels_[who]->get_signal()); + break; + + case evGPS_2S: + available_GPS_2S_signals_.remove(channels_[who]->get_signal()); + break; + + case evGPS_L5: + available_GPS_L5_signals_.remove(channels_[who]->get_signal()); + break; + + case evGAL_1B: + available_GAL_1B_signals_.remove(channels_[who]->get_signal()); + break; + + case evGAL_5X: + available_GAL_5X_signals_.remove(channels_[who]->get_signal()); + break; + + case evGLO_1G: + available_GLO_1G_signals_.remove(channels_[who]->get_signal()); + break; + + case evGLO_2G: + available_GLO_2G_signals_.remove(channels_[who]->get_signal()); + break; + + case evBDS_B1: + available_BDS_B1_signals_.remove(channels_[who]->get_signal()); + break; + + default: + LOG(ERROR) << "This should not happen :-("; + break; + } + channels_state_[who] = 2; acq_channels_count_--; for (unsigned int i = 0; i < channels_count_; i++) @@ -784,17 +1195,22 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) { LOG(WARNING) << e.what(); } - if (!available_GNSS_signals_.empty() && (acq_channels_count_ < max_acq_channels_) && (channels_state_[i] == 0)) + if ((acq_channels_count_ < max_acq_channels_) && (channels_state_[i] == 0)) { channels_state_[i] = 1; if (sat_ == 0) { - std::lock_guard lock(signal_list_mutex); - channels_[i]->set_signal(search_next_signal(channels_[i]->get_signal().get_signal_str(), true)); + channels_[i]->set_signal(search_next_signal(channels_[i]->get_signal().get_signal_str(), true, true)); } acq_channels_count_++; DLOG(INFO) << "Channel " << i << " Starting acquisition " << channels_[i]->get_signal().get_satellite() << ", Signal " << channels_[i]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA channels_[i]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[i]); + tmp_thread.detach(); +#endif } DLOG(INFO) << "Channel " << i << " in state " << channels_state_[i]; } @@ -809,7 +1225,13 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_state_[who] = 1; acq_channels_count_++; LOG(INFO) << "Channel " << who << " Starting acquisition " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA channels_[who]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[who]); + tmp_thread.detach(); +#endif } else { @@ -817,20 +1239,268 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) LOG(INFO) << "Channel " << who << " Idle state"; if (sat == 0) { - std::lock_guard lock(signal_list_mutex); - available_GNSS_signals_.push_back(channels_[who]->get_signal()); + switch (mapStringValues_[channels_[who]->get_signal().get_signal_str()]) + { + case evGPS_1C: + available_GPS_1C_signals_.push_back(channels_[who]->get_signal()); + break; + + case evGPS_2S: + available_GPS_2S_signals_.push_back(channels_[who]->get_signal()); + break; + + case evGPS_L5: + available_GPS_L5_signals_.push_back(channels_[who]->get_signal()); + break; + + case evGAL_1B: + available_GAL_1B_signals_.push_back(channels_[who]->get_signal()); + break; + + case evGAL_5X: + available_GAL_5X_signals_.push_back(channels_[who]->get_signal()); + break; + + case evGLO_1G: + available_GLO_1G_signals_.push_back(channels_[who]->get_signal()); + break; + + case evGLO_2G: + available_GLO_2G_signals_.push_back(channels_[who]->get_signal()); + break; + + case evBDS_B1: + available_BDS_B1_signals_.push_back(channels_[who]->get_signal()); + break; + + default: + LOG(ERROR) << "This should not happen :-("; + break; + } } } break; + case 10: // request standby mode + LOG(INFO) << "TC request standby mode"; + for (size_t n = 0; n < channels_.size(); n++) + { + if (channels_state_[n] == 1 or channels_state_[n] == 2) //channel in acquisition or in tracking + { + //recover the satellite assigned + Gnss_Signal gs = channels_[n]->get_signal(); + switch (mapStringValues_[gs.get_signal_str()]) + { + case evGPS_1C: + available_GPS_1C_signals_.remove(gs); + available_GPS_1C_signals_.push_back(gs); + break; + + case evGPS_2S: + available_GPS_2S_signals_.remove(gs); + available_GPS_2S_signals_.push_back(gs); + break; + + case evGPS_L5: + available_GPS_L5_signals_.remove(gs); + available_GPS_L5_signals_.push_back(gs); + break; + + case evGAL_1B: + available_GAL_1B_signals_.remove(gs); + available_GAL_1B_signals_.push_back(gs); + break; + + case evGAL_5X: + available_GAL_5X_signals_.remove(gs); + available_GAL_5X_signals_.push_back(gs); + break; + + case evGLO_1G: + available_GLO_1G_signals_.remove(gs); + available_GLO_1G_signals_.push_back(gs); + break; + + case evGLO_2G: + available_GLO_2G_signals_.remove(gs); + available_GLO_2G_signals_.push_back(gs); + break; + + default: + LOG(ERROR) << "This should not happen :-("; + break; + } + channels_[n]->stop_channel(); //stop the acquisition or tracking operation + channels_state_[n] = 0; + } + } + acq_channels_count_ = 0; // all channels are in standby now + break; + case 11: // request coldstart mode + LOG(INFO) << "TC request flowgraph coldstart"; + //start again the satellite acquisitions + for (unsigned int i = 0; i < channels_count_; i++) + { + unsigned int ch_index = (who + i + 1) % channels_count_; + unsigned int sat_ = 0; + try + { + sat_ = configuration_->property("Channel" + std::to_string(ch_index) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + if ((acq_channels_count_ < max_acq_channels_) && (channels_state_[ch_index] == 0)) + { + channels_state_[ch_index] = 1; + if (sat_ == 0) + { + channels_[ch_index]->set_signal(search_next_signal(channels_[ch_index]->get_signal().get_signal_str(), true)); + } + acq_channels_count_++; + DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA + channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); + tmp_thread.detach(); +#endif + } + DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; + } + break; + case 12: // request hotstart mode + LOG(INFO) << "TC request flowgraph hotstart"; + for (unsigned int i = 0; i < channels_count_; i++) + { + unsigned int ch_index = (who + i + 1) % channels_count_; + unsigned int sat_ = 0; + try + { + sat_ = configuration_->property("Channel" + std::to_string(ch_index) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + if ((acq_channels_count_ < max_acq_channels_) && (channels_state_[ch_index] == 0)) + { + channels_state_[ch_index] = 1; + if (sat_ == 0) + { + channels_[ch_index]->set_signal(search_next_signal(channels_[ch_index]->get_signal().get_signal_str(), true)); + } + acq_channels_count_++; + DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA + channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); + tmp_thread.detach(); +#endif + } + DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; + } + break; + case 13: // request warmstart mode + LOG(INFO) << "TC request flowgraph warmstart"; + //start again the satellite acquisitions + for (unsigned int i = 0; i < channels_count_; i++) + { + unsigned int ch_index = (who + i + 1) % channels_count_; + unsigned int sat_ = 0; + try + { + sat_ = configuration_->property("Channel" + std::to_string(ch_index) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } + if ((acq_channels_count_ < max_acq_channels_) && (channels_state_[ch_index] == 0)) + { + channels_state_[ch_index] = 1; + if (sat_ == 0) + { + channels_[ch_index]->set_signal(search_next_signal(channels_[ch_index]->get_signal().get_signal_str(), true)); + } + acq_channels_count_++; + DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA + channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); + tmp_thread.detach(); +#endif + } + DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; + } + break; default: break; } - DLOG(INFO) << "Number of available signals: " << available_GNSS_signals_.size(); applied_actions_++; } +void GNSSFlowgraph::priorize_satellites(std::vector> visible_satellites) +{ + size_t old_size; + Gnss_Signal gs; + for (auto& visible_satellite : visible_satellites) + { + if (visible_satellite.second.get_system() == "GPS") + { + gs = Gnss_Signal(visible_satellite.second, "1C"); + old_size = available_GPS_1C_signals_.size(); + available_GPS_1C_signals_.remove(gs); + if (old_size > available_GPS_1C_signals_.size()) + { + available_GPS_1C_signals_.push_front(gs); + } + + gs = Gnss_Signal(visible_satellite.second, "2S"); + old_size = available_GPS_2S_signals_.size(); + available_GPS_2S_signals_.remove(gs); + if (old_size > available_GPS_2S_signals_.size()) + { + available_GPS_2S_signals_.push_front(gs); + } + + gs = Gnss_Signal(visible_satellite.second, "L5"); + old_size = available_GPS_L5_signals_.size(); + available_GPS_L5_signals_.remove(gs); + if (old_size > available_GPS_L5_signals_.size()) + { + available_GPS_L5_signals_.push_front(gs); + } + } + else if (visible_satellite.second.get_system() == "Galileo") + { + gs = Gnss_Signal(visible_satellite.second, "1B"); + old_size = available_GAL_1B_signals_.size(); + available_GAL_1B_signals_.remove(gs); + if (old_size > available_GAL_1B_signals_.size()) + { + available_GAL_1B_signals_.push_front(gs); + } + + gs = Gnss_Signal(visible_satellite.second, "5X"); + old_size = available_GAL_5X_signals_.size(); + available_GAL_5X_signals_.remove(gs); + if (old_size > available_GAL_5X_signals_.size()) + { + available_GAL_5X_signals_.push_front(gs); + } + } + } +} + + void GNSSFlowgraph::set_configuration(std::shared_ptr configuration) { if (running_) @@ -842,9 +1512,10 @@ void GNSSFlowgraph::set_configuration(std::shared_ptr co { LOG(WARNING) << "Unable to update configuration while flowgraph connected"; } - configuration_ = configuration; + configuration_ = std::move(configuration); } +#ifdef ENABLE_FPGA void GNSSFlowgraph::start_acquisition_helper() { @@ -858,6 +1529,16 @@ void GNSSFlowgraph::start_acquisition_helper() } +void GNSSFlowgraph::perform_hw_reset() +{ + // a stop acquisition command causes the SW to reset the HW + std::shared_ptr channel_ptr; + channel_ptr = std::dynamic_pointer_cast(channels_.at(0)); + channel_ptr->acquisition()->stop_acquisition(); +} + +#endif + void GNSSFlowgraph::init() { /* @@ -916,8 +1597,8 @@ void GNSSFlowgraph::init() // Mark old implementations as deprecated std::string default_str("Default"); std::string obs_implementation = configuration_->property("Observables.implementation", default_str); - if ((obs_implementation.compare("GPS_L1_CA_Observables") == 0) || (obs_implementation.compare("GPS_L2C_Observables") == 0) || - (obs_implementation.compare("Galileo_E1B_Observables") == 0) || (obs_implementation.compare("Galileo_E5A_Observables") == 0)) + if ((obs_implementation == "GPS_L1_CA_Observables") || (obs_implementation == "GPS_L2C_Observables") || + (obs_implementation == "Galileo_E1B_Observables") || (obs_implementation == "Galileo_E5A_Observables")) { std::cout << "WARNING: Implementation '" << obs_implementation << "' of the Observables block has been replaced by 'Hybrid_Observables'." << std::endl; std::cout << "Please update your configuration file." << std::endl; @@ -926,7 +1607,7 @@ void GNSSFlowgraph::init() pvt_ = block_factory_->GetPVT(configuration_); // Mark old implementations as deprecated std::string pvt_implementation = configuration_->property("PVT.implementation", default_str); - if ((pvt_implementation.compare("GPS_L1_CA_PVT") == 0) || (pvt_implementation.compare("Galileo_E1_PVT") == 0) || (pvt_implementation.compare("Hybrid_PVT") == 0)) + if ((pvt_implementation == "GPS_L1_CA_PVT") || (pvt_implementation == "Galileo_E1_PVT") || (pvt_implementation == "Hybrid_PVT")) { std::cout << "WARNING: Implementation '" << pvt_implementation << "' of the PVT block has been replaced by 'RTKLIB_PVT'." << std::endl; std::cout << "Please update your configuration file." << std::endl; @@ -943,11 +1624,38 @@ void GNSSFlowgraph::init() top_block_ = gr::make_top_block("GNSSFlowgraph"); - // fill the available_GNSS_signals_ queue with the satellites ID's to be searched by the acquisition + mapStringValues_["1C"] = evGPS_1C; + mapStringValues_["2S"] = evGPS_2S; + mapStringValues_["L5"] = evGPS_L5; + mapStringValues_["1B"] = evGAL_1B; + mapStringValues_["5X"] = evGAL_5X; + mapStringValues_["1G"] = evGLO_1G; + mapStringValues_["2G"] = evGLO_2G; + mapStringValues_["B1"] = evBDS_B1; + + // fill the signals queue with the satellites ID's to be searched by the acquisition set_signals_list(); set_channels_state(); applied_actions_ = 0; DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels."; + + /* + * Instantiate the receiver monitor block, if required + */ + enable_monitor_ = configuration_->property("Monitor.enable_monitor", false); + + std::string address_string = configuration_->property("Monitor.client_addresses", std::string("127.0.0.1")); + std::vector udp_addr_vec = split_string(address_string, '_'); + std::sort(udp_addr_vec.begin(), udp_addr_vec.end()); + udp_addr_vec.erase(std::unique(udp_addr_vec.begin(), udp_addr_vec.end()), udp_addr_vec.end()); + + if (enable_monitor_) + { + GnssSynchroMonitor_ = gr::basic_block_sptr(new gnss_synchro_monitor(channels_count_, + configuration_->property("Monitor.decimation_factor", 1), + configuration_->property("Monitor.udp_port", 1234), + udp_addr_vec)); + } } @@ -961,7 +1669,7 @@ void GNSSFlowgraph::set_signals_list() 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}; - std::set available_sbas_prn = {120, 124, 126}; + std::set available_sbas_prn = {123, 131, 135, 136, 138}; std::set available_galileo_prn = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, @@ -970,6 +1678,10 @@ void GNSSFlowgraph::set_signals_list() // Removing satellites sharing same frequency number(1 and 5, 2 and 6, 3 and 7, 4 and 6, 11 and 15, 12 and 16, 14 and 18, 17 and 21 std::set available_glonass_prn = {1, 2, 3, 4, 9, 10, 11, 12, 18, 19, 20, 21, 24}; + std::set available_beidou_prn = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37}; + std::string sv_list = configuration_->property("Galileo.prns", std::string("")); if (sv_list.length() > 0) @@ -980,7 +1692,7 @@ void GNSSFlowgraph::set_signals_list() std::transform(tok.begin(), tok.end(), std::inserter(tmp_set, tmp_set.begin()), boost::lexical_cast); - if (tmp_set.size() > 0) + if (!tmp_set.empty()) { available_galileo_prn = tmp_set; } @@ -996,7 +1708,7 @@ void GNSSFlowgraph::set_signals_list() std::transform(tok.begin(), tok.end(), std::inserter(tmp_set, tmp_set.begin()), boost::lexical_cast); - if (tmp_set.size() > 0) + if (!tmp_set.empty()) { available_gps_prn = tmp_set; } @@ -1012,7 +1724,7 @@ void GNSSFlowgraph::set_signals_list() std::transform(tok.begin(), tok.end(), std::inserter(tmp_set, tmp_set.begin()), boost::lexical_cast); - if (tmp_set.size() > 0) + if (!tmp_set.empty()) { available_sbas_prn = tmp_set; } @@ -1028,22 +1740,37 @@ void GNSSFlowgraph::set_signals_list() std::transform(tok.begin(), tok.end(), std::inserter(tmp_set, tmp_set.begin()), boost::lexical_cast); - if (tmp_set.size() > 0) + if (!tmp_set.empty()) { available_glonass_prn = tmp_set; } } + sv_list = configuration_->property("Beidou.prns", std::string("")); + + + if (sv_list.length() > 0) + { + // Reset the available prns: + std::set tmp_set; + boost::tokenizer<> tok(sv_list); + std::transform(tok.begin(), tok.end(), std::inserter(tmp_set, tmp_set.begin()), + boost::lexical_cast); + + if (!tmp_set.empty()) + { + available_beidou_prn = tmp_set; + } + } + if (configuration_->property("Channels_1C.count", 0) > 0) { - /* - * Loop to create GPS L1 C/A signals - */ + // Loop to create GPS L1 C/A signals for (available_gnss_prn_iter = available_gps_prn.cbegin(); available_gnss_prn_iter != available_gps_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_GPS_1C_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("GPS"), *available_gnss_prn_iter), std::string("1C"))); } @@ -1051,14 +1778,12 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_2S.count", 0) > 0) { - /* - * Loop to create GPS L2C M signals - */ + // Loop to create GPS L2C M signals for (available_gnss_prn_iter = available_gps_prn.cbegin(); available_gnss_prn_iter != available_gps_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_GPS_2S_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("GPS"), *available_gnss_prn_iter), std::string("2S"))); } @@ -1066,14 +1791,12 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_L5.count", 0) > 0) { - /* - * Loop to create GPS L5 signals - */ + // Loop to create GPS L5 signals for (available_gnss_prn_iter = available_gps_prn.cbegin(); available_gnss_prn_iter != available_gps_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_GPS_L5_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("GPS"), *available_gnss_prn_iter), std::string("L5"))); } @@ -1081,14 +1804,12 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_SBAS.count", 0) > 0) { - /* - * Loop to create SBAS L1 C/A signals - */ + // Loop to create SBAS L1 C/A signals for (available_gnss_prn_iter = available_sbas_prn.cbegin(); available_gnss_prn_iter != available_sbas_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_SBAS_1C_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("SBAS"), *available_gnss_prn_iter), std::string("1C"))); } @@ -1096,14 +1817,12 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_1B.count", 0) > 0) { - /* - * Loop to create the list of Galileo E1B signals - */ + // Loop to create the list of Galileo E1B signals for (available_gnss_prn_iter = available_galileo_prn.cbegin(); available_gnss_prn_iter != available_galileo_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_GAL_1B_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("Galileo"), *available_gnss_prn_iter), std::string("1B"))); } @@ -1111,14 +1830,12 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_5X.count", 0) > 0) { - /* - * Loop to create the list of Galileo E5a signals - */ + // Loop to create the list of Galileo E5a signals for (available_gnss_prn_iter = available_galileo_prn.cbegin(); available_gnss_prn_iter != available_galileo_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_GAL_5X_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("Galileo"), *available_gnss_prn_iter), std::string("5X"))); } @@ -1126,14 +1843,12 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_1G.count", 0) > 0) { - /* - * Loop to create the list of GLONASS L1 C/A signals - */ - for (available_gnss_prn_iter = available_glonass_prn.begin(); - available_gnss_prn_iter != available_glonass_prn.end(); + // Loop to create the list of GLONASS L1 C/A signals + for (available_gnss_prn_iter = available_glonass_prn.cbegin(); + available_gnss_prn_iter != available_glonass_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_GLO_1G_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("Glonass"), *available_gnss_prn_iter), std::string("1G"))); } @@ -1141,23 +1856,37 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_2G.count", 0) > 0) { - /* - * Loop to create the list of GLONASS L2 C/A signals - */ - for (available_gnss_prn_iter = available_glonass_prn.begin(); - available_gnss_prn_iter != available_glonass_prn.end(); + // Loop to create the list of GLONASS L2 C/A signals + for (available_gnss_prn_iter = available_glonass_prn.cbegin(); + available_gnss_prn_iter != available_glonass_prn.cend(); available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal( + available_GLO_2G_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("Glonass"), *available_gnss_prn_iter), std::string("2G"))); } } + + if (configuration_->property("Channels_B1.count", 0) > 0) + { + /* + * Loop to create the list of BeiDou B1C signals + */ + for (available_gnss_prn_iter = available_beidou_prn.cbegin(); + available_gnss_prn_iter != available_beidou_prn.cend(); + available_gnss_prn_iter++) + { + available_BDS_B1_signals_.push_back(Gnss_Signal( + Gnss_Satellite(std::string("Beidou"), *available_gnss_prn_iter), + std::string("B1"))); + } + } } void GNSSFlowgraph::set_channels_state() { + std::lock_guard lock(signal_list_mutex); max_acq_channels_ = configuration_->property("Channels.in_acquisition", channels_count_); if (max_acq_channels_ > channels_count_) { @@ -1182,17 +1911,274 @@ void GNSSFlowgraph::set_channels_state() } -Gnss_Signal GNSSFlowgraph::search_next_signal(std::string searched_signal, bool pop) +Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal, bool pop, bool tracked) { - while (searched_signal.compare(available_GNSS_signals_.front().get_signal_str()) != 0) + Gnss_Signal result; + bool untracked_satellite = true; + switch (mapStringValues_[searched_signal]) { - available_GNSS_signals_.push_back(available_GNSS_signals_.front()); - available_GNSS_signals_.pop_front(); - } - Gnss_Signal result = available_GNSS_signals_.front(); - if (pop) - { - available_GNSS_signals_.pop_front(); + case evGPS_1C: + result = available_GPS_1C_signals_.front(); + available_GPS_1C_signals_.pop_front(); + if (!pop) + { + available_GPS_1C_signals_.push_back(result); + } + if (tracked) + { + if ((configuration_->property("Channels_2S.count", 0) > 0) or (configuration_->property("Channels_L5.count", 0) > 0)) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1C")) + { + untracked_satellite = false; + } + } + if (untracked_satellite and configuration_->property("Channels_2S.count", 0) > 0) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "2S"); + available_GPS_2S_signals_.remove(gs); + available_GPS_2S_signals_.push_front(gs); + } + if (untracked_satellite and configuration_->property("Channels_L5.count", 0) > 0) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "L5"); + available_GPS_L5_signals_.remove(gs); + available_GPS_L5_signals_.push_front(gs); + } + } + } + break; + + case evGPS_2S: + result = available_GPS_2S_signals_.front(); + available_GPS_2S_signals_.pop_front(); + if (!pop) + { + available_GPS_2S_signals_.push_back(result); + } + if (tracked) + { + if ((configuration_->property("Channels_1C.count", 0) > 0) or (configuration_->property("Channels_L5.count", 0) > 0)) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2S")) + { + untracked_satellite = false; + } + } + if (untracked_satellite and configuration_->property("Channels_1C.count", 0) > 0) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "1C"); + available_GPS_1C_signals_.remove(gs); + available_GPS_1C_signals_.push_front(gs); + } + if (untracked_satellite and configuration_->property("Channels_L5.count", 0) > 0) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "L5"); + available_GPS_L5_signals_.remove(gs); + available_GPS_L5_signals_.push_front(gs); + } + } + } + break; + + case evGPS_L5: + result = available_GPS_L5_signals_.front(); + available_GPS_L5_signals_.pop_front(); + if (!pop) + { + available_GPS_L5_signals_.push_back(result); + } + if (tracked) + { + if ((configuration_->property("Channels_1C.count", 0) > 0) or (configuration_->property("Channels_2S.count", 0) > 0)) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "L5")) + { + untracked_satellite = false; + } + } + if (untracked_satellite and configuration_->property("Channels_1C.count", 0) > 0) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "1C"); + available_GPS_1C_signals_.remove(gs); + available_GPS_1C_signals_.push_front(gs); + } + if (untracked_satellite and configuration_->property("Channels_2S.count", 0) > 0) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "2S"); + available_GPS_2S_signals_.remove(gs); + available_GPS_2S_signals_.push_front(gs); + } + } + } + break; + + case evGAL_1B: + result = available_GAL_1B_signals_.front(); + available_GAL_1B_signals_.pop_front(); + if (!pop) + { + available_GAL_1B_signals_.push_back(result); + } + if (tracked) + { + if (configuration_->property("Channels_5X.count", 0) > 0) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1B")) + { + untracked_satellite = false; + } + } + if (untracked_satellite) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "5X"); + available_GAL_5X_signals_.remove(gs); + available_GAL_5X_signals_.push_front(gs); + } + } + } + break; + + case evGAL_5X: + result = available_GAL_5X_signals_.front(); + available_GAL_5X_signals_.pop_front(); + if (!pop) + { + available_GAL_5X_signals_.push_back(result); + } + if (tracked) + { + if (configuration_->property("Channels_1B.count", 0) > 0) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "5X")) + { + untracked_satellite = false; + } + } + if (untracked_satellite) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "1B"); + available_GAL_1B_signals_.remove(gs); + available_GAL_1B_signals_.push_front(gs); + } + } + } + break; + + case evGLO_1G: + result = available_GLO_1G_signals_.front(); + available_GLO_1G_signals_.pop_front(); + if (!pop) + { + available_GLO_1G_signals_.push_back(result); + } + if (tracked) + { + if (configuration_->property("Channels_2G.count", 0) > 0) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1G")) + { + untracked_satellite = false; + } + } + if (untracked_satellite) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "2G"); + available_GLO_2G_signals_.remove(gs); + available_GLO_2G_signals_.push_front(gs); + } + } + } + break; + + case evGLO_2G: + result = available_GLO_2G_signals_.front(); + available_GLO_2G_signals_.pop_front(); + if (!pop) + { + available_GLO_2G_signals_.push_back(result); + } + if (tracked) + { + if (configuration_->property("Channels_1G.count", 0) > 0) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2G")) + { + untracked_satellite = false; + } + } + if (untracked_satellite) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "1G"); + available_GLO_1G_signals_.remove(gs); + available_GLO_1G_signals_.push_front(gs); + } + } + } + break; + + case evBDS_B1: + result = available_BDS_B1_signals_.front(); + available_BDS_B1_signals_.pop_front(); + if (!pop) + { + available_BDS_B1_signals_.push_back(result); + } + if (tracked) + { + // In the near future Beidou B2a will be added + // if (configuration_->property("Channels_5C.count", 0) > 0) + // { + // for (unsigned int ch = 0; ch < channels_count_; ch++) + // { + // if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str().compare("5C") != 0)) untracked_satellite = false; + // } + // if (untracked_satellite) + // { + // Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "5C"); + // available_BDS_5C_signals_.remove(gs); + // available_BDS_5C_signals_.push_front(gs); + // } + // } + } + break; + + default: + LOG(ERROR) << "This should not happen :-("; + result = available_GPS_1C_signals_.front(); + if (pop) + { + available_GPS_1C_signals_.pop_front(); + } + break; } return result; } + +std::vector GNSSFlowgraph::split_string(const std::string& s, char delim) +{ + std::vector v; + std::stringstream ss(s); + std::string item; + + while (std::getline(ss, item, delim)) + { + *(std::back_inserter(v)++) = item; + } + + return v; +} diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index ff72eda88..0a95eb60b 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -4,6 +4,7 @@ * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2011. luis(at)epsilon-formacion.com * Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es + * Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com * * It contains a signal source, * a signal conditioner, a set of channels, an observables block and a pvt. @@ -37,13 +38,18 @@ #define GNSS_SDR_GNSS_FLOWGRAPH_H_ #include "GPS_L1_CA.h" -#include "gnss_signal.h" +#include "channel_interface.h" +#include "configuration_interface.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" #include "gnss_sdr_sample_counter.h" -#include +#include "gnss_signal.h" +#include "gnss_synchro_monitor.h" +#include "pvt_interface.h" #include -#include -#include +#include #include +#include #include #include #include @@ -51,13 +57,9 @@ #include #if ENABLE_FPGA -#include "gnss_sdr_time_counter.h" +#include "gnss_sdr_fpga_sample_counter.h" #endif -class GNSSBlockInterface; -class ChannelInterface; -class ConfigurationInterface; -class GNSSBlockFactory; /*! \brief This class represents a GNSS flow graph. * @@ -70,7 +72,7 @@ public: /*! * \brief Constructor that initializes the receiver flow graph */ - GNSSFlowgraph(std::shared_ptr configuration, gr::msg_queue::sptr queue); + GNSSFlowgraph(std::shared_ptr configuration, const gr::msg_queue::sptr queue); // NOLINT(performance-unnecessary-value-param) /*! * \brief Destructor @@ -93,9 +95,11 @@ public: void disconnect(); void wait(); - +#ifdef ENABLE_FPGA void start_acquisition_helper(); + void perform_hw_reset(); +#endif /*! * \brief Applies an action to the flow graph * @@ -106,17 +110,17 @@ public: void set_configuration(std::shared_ptr configuration); - unsigned int applied_actions() + unsigned int applied_actions() const { return applied_actions_; } - bool connected() + bool connected() const { return connected_; } - bool running() + bool running() const { return running_; } @@ -126,14 +130,27 @@ public: * * It is used to assist the receiver with external ephemeris data */ - bool send_telemetry_msg(pmt::pmt_t msg); + bool send_telemetry_msg(const pmt::pmt_t& msg); + + /*! + * \brief Returns a smart pointer to the PVT object + */ + std::shared_ptr get_pvt() + { + return std::dynamic_pointer_cast(pvt_); + } + + /*! + * \brief Priorize visible satellites in the specified vector + */ + void priorize_satellites(std::vector> visible_satellites); private: void init(); // Populates the SV PRN list available for acquisition and tracking void set_signals_list(); void set_channels_state(); // Initializes the channels state (start acquisition or keep standby) // using the configuration parameters (number of channels and max channels in acquisition) - Gnss_Signal search_next_signal(std::string searched_signal, bool pop); + Gnss_Signal search_next_signal(const std::string& searched_signal, bool pop, bool tracked = false); bool connected_; bool running_; int sources_count_; @@ -151,18 +168,44 @@ private: std::shared_ptr observables_; std::shared_ptr pvt_; + std::map acq_resamplers_; std::vector> channels_; gnss_sdr_sample_counter_sptr ch_out_sample_counter; #if ENABLE_FPGA - gnss_sdr_time_counter_sptr time_counter_; + gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter; #endif - gr::blocks::null_source::sptr null_source_; - gr::blocks::throttle::sptr throttle_; gr::top_block_sptr top_block_; gr::msg_queue::sptr queue_; - std::list available_GNSS_signals_; + + std::list available_GPS_1C_signals_; + std::list available_GPS_2S_signals_; + std::list available_GPS_L5_signals_; + std::list available_SBAS_1C_signals_; + std::list available_GAL_1B_signals_; + std::list available_GAL_5X_signals_; + std::list available_GLO_1G_signals_; + std::list available_GLO_2G_signals_; + std::list available_BDS_B1_signals_; + enum StringValue + { + evGPS_1C, + evGPS_2S, + evGPS_L5, + evSBAS_1C, + evGAL_1B, + evGAL_5X, + evGLO_1G, + evGLO_2G, + evBDS_B1 + }; + std::map mapStringValues_; + std::vector channels_state_; std::mutex signal_list_mutex; + + bool enable_monitor_; + gr::basic_block_sptr GnssSynchroMonitor_; + std::vector split_string(const std::string& s, char delim); }; #endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/ diff --git a/src/core/receiver/in_memory_configuration.cc b/src/core/receiver/in_memory_configuration.cc index 6a2ce8bf8..4801d2eb2 100644 --- a/src/core/receiver/in_memory_configuration.cc +++ b/src/core/receiver/in_memory_configuration.cc @@ -50,63 +50,74 @@ InMemoryConfiguration::~InMemoryConfiguration() std::string InMemoryConfiguration::property(std::string property_name, std::string default_value) { - std::map::iterator iter = properties_.find(property_name); + auto iter = properties_.find(property_name); if (iter != properties_.end()) { return iter->second; } - else - { - return default_value; - } + return default_value; } bool InMemoryConfiguration::property(std::string property_name, bool default_value) { - std::string empty = ""; + std::string empty; return converter_->convert(property(property_name, empty), default_value); } -long InMemoryConfiguration::property(std::string property_name, long default_value) +int64_t InMemoryConfiguration::property(std::string property_name, int64_t default_value) { - std::string empty = ""; + std::string empty; return converter_->convert(property(property_name, empty), default_value); } -int InMemoryConfiguration::property(std::string property_name, int default_value) +uint64_t InMemoryConfiguration::property(std::string property_name, uint64_t default_value) { - std::string empty = ""; + std::string empty; return converter_->convert(property(property_name, empty), default_value); } -unsigned int InMemoryConfiguration::property(std::string property_name, unsigned int default_value) +int32_t InMemoryConfiguration::property(std::string property_name, int32_t default_value) { - std::string empty = ""; + std::string empty; return converter_->convert(property(property_name, empty), default_value); } -unsigned short InMemoryConfiguration::property(std::string property_name, unsigned short default_value) +uint32_t InMemoryConfiguration::property(std::string property_name, uint32_t default_value) { - std::string empty = ""; + std::string empty; + return converter_->convert(property(property_name, empty), default_value); +} + + +uint16_t InMemoryConfiguration::property(std::string property_name, uint16_t default_value) +{ + std::string empty; + return converter_->convert(property(property_name, empty), default_value); +} + + +int16_t InMemoryConfiguration::property(std::string property_name, int16_t default_value) +{ + std::string empty; return converter_->convert(property(property_name, empty), default_value); } float InMemoryConfiguration::property(std::string property_name, float default_value) { - std::string empty = ""; + std::string empty; return converter_->convert(property(property_name, empty), default_value); } double InMemoryConfiguration::property(std::string property_name, double default_value) { - std::string empty = ""; + std::string empty; return converter_->convert(property(property_name, empty), default_value); } @@ -117,7 +128,14 @@ void InMemoryConfiguration::set_property(std::string property_name, std::string } -bool InMemoryConfiguration::is_present(std::string property_name) +void InMemoryConfiguration::supersede_property(std::string property_name, std::string value) +{ + properties_.erase(property_name); + properties_.insert(std::make_pair(property_name, value)); +} + + +bool InMemoryConfiguration::is_present(const std::string& property_name) { return (properties_.find(property_name) != properties_.end()); } diff --git a/src/core/receiver/in_memory_configuration.h b/src/core/receiver/in_memory_configuration.h index 1850a9d41..698071a36 100644 --- a/src/core/receiver/in_memory_configuration.h +++ b/src/core/receiver/in_memory_configuration.h @@ -36,6 +36,7 @@ #define GNSS_SDR_IN_MEMORY_CONFIGURATION_H_ #include "configuration_interface.h" +#include #include #include #include @@ -56,14 +57,17 @@ public: virtual ~InMemoryConfiguration(); std::string property(std::string property_name, std::string default_value); bool property(std::string property_name, bool default_value); - long property(std::string property_name, long default_value); - int property(std::string property_name, int default_value); - unsigned int property(std::string property_name, unsigned int default_value); - unsigned short property(std::string property_name, unsigned short default_value); + int64_t property(std::string property_name, int64_t default_value); + uint64_t property(std::string property_name, uint64_t default_value); + int32_t property(std::string property_name, int32_t default_value); + uint32_t property(std::string property_name, uint32_t default_value); + int16_t property(std::string property_name, int16_t default_value); + uint16_t property(std::string property_name, uint16_t default_value); float property(std::string property_name, float default_value); double property(std::string property_name, double default_value); void set_property(std::string property_name, std::string value); - bool is_present(std::string property_name); + void supersede_property(std::string property_name, std::string value); + bool is_present(const std::string& property_name); private: std::map properties_; diff --git a/src/core/receiver/tcp_cmd_interface.cc b/src/core/receiver/tcp_cmd_interface.cc new file mode 100644 index 000000000..0096c26a1 --- /dev/null +++ b/src/core/receiver/tcp_cmd_interface.cc @@ -0,0 +1,399 @@ +/*! + * \file tcp_cmd_interface.cc + * + * \brief Class that implements a TCP/IP telecommand command line interface + * for GNSS-SDR + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "tcp_cmd_interface.h" +#include "control_message_factory.h" +#include +#include +#include + + +TcpCmdInterface::TcpCmdInterface() +{ + register_functions(); + keep_running_ = true; + control_queue_ = nullptr; + rx_latitude_ = 0; + rx_longitude_ = 0; + rx_altitude_ = 0; + receiver_utc_time_ = 0; +} + + +TcpCmdInterface::~TcpCmdInterface() = default; + + +void TcpCmdInterface::register_functions() +{ + functions["status"] = std::bind(&TcpCmdInterface::status, this, std::placeholders::_1); + functions["standby"] = std::bind(&TcpCmdInterface::standby, this, std::placeholders::_1); + functions["reset"] = std::bind(&TcpCmdInterface::reset, this, std::placeholders::_1); + functions["hotstart"] = std::bind(&TcpCmdInterface::hotstart, this, std::placeholders::_1); + functions["warmstart"] = std::bind(&TcpCmdInterface::warmstart, this, std::placeholders::_1); + functions["coldstart"] = std::bind(&TcpCmdInterface::coldstart, this, std::placeholders::_1); + functions["set_ch_satellite"] = std::bind(&TcpCmdInterface::set_ch_satellite, this, std::placeholders::_1); +} + + +void TcpCmdInterface::set_pvt(std::shared_ptr PVT_sptr) +{ + PVT_sptr_ = std::move(PVT_sptr); +} + + +time_t TcpCmdInterface::get_utc_time() +{ + return receiver_utc_time_; +} + + +arma::vec TcpCmdInterface::get_LLH() +{ + return arma::vec{rx_latitude_, rx_longitude_, rx_altitude_}; +} + + +std::string TcpCmdInterface::reset(const std::vector &commandLine __attribute__((unused))) +{ + std::string response; + std::unique_ptr cmf(new ControlMessageFactory()); + if (control_queue_ != nullptr) + { + control_queue_->handle(cmf->GetQueueMessage(200, 1)); //send the restart message (who=200,what=1) + response = "OK\n"; + } + else + { + response = "ERROR\n"; + } + + return response; +} + + +std::string TcpCmdInterface::standby(const std::vector &commandLine __attribute__((unused))) +{ + std::string response; + std::unique_ptr cmf(new ControlMessageFactory()); + if (control_queue_ != nullptr) + { + control_queue_->handle(cmf->GetQueueMessage(300, 10)); //send the standby message (who=300,what=10) + response = "OK\n"; + } + else + { + response = "ERROR\n"; + } + return response; +} + + +std::string TcpCmdInterface::status(const std::vector &commandLine __attribute__((unused))) +{ + std::stringstream str_stream; + //todo: implement the receiver status report + + // str_stream << "-------------------------------------------------------\n"; + // str_stream << "ch | sys | sig | mode | Tlm | Eph | Doppler | CN0 |\n"; + // str_stream << " | | | | | | [Hz] | [dB - Hz] |\n"; + // str_stream << "-------------------------------------------------------\n"; + // int n_ch = 10; + // for (int n = 0; n < n_ch; n++) + // { + // str_stream << n << "GPS | L1CA | TRK | YES | YES | 23412.4 | 44.3 |\n"; + // } + // str_stream << "--------------------------------------------------------\n"; + + double longitude_deg, latitude_deg, height_m, ground_speed_kmh, course_over_ground_deg; + time_t UTC_time; + if (PVT_sptr_->get_latest_PVT(&longitude_deg, + &latitude_deg, + &height_m, + &ground_speed_kmh, + &course_over_ground_deg, + &UTC_time) == true) + { + struct tm tstruct = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + char buf1[80]; + tstruct = *gmtime(&UTC_time); + strftime(buf1, sizeof(buf1), "%d/%m/%Y %H:%M:%S", &tstruct); + std::string str_time = std::string(buf1); + str_stream << "- Receiver UTC Time: " << str_time << std::endl; + str_stream << std::setprecision(9); + str_stream << "- Receiver Position WGS84 [Lat, Long, H]: " + << latitude_deg << ", " + << longitude_deg << ", "; + str_stream << std::setprecision(3); + str_stream << height_m << std::endl; + str_stream << std::setprecision(1); + str_stream << "- Receiver Speed over Ground [km/h]: " << ground_speed_kmh << std::endl; + str_stream << "- Receiver Course over ground [deg]: " << course_over_ground_deg << std::endl; + } + else + { + str_stream << "No PVT information available.\n"; + } + + return str_stream.str(); +} + + +std::string TcpCmdInterface::hotstart(const std::vector &commandLine) +{ + std::string response; + if (commandLine.size() > 5) + { + // Read commandline time parameter + struct tm tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + if (strptime(commandLine.at(1).c_str(), "%d/%m/%Y %H:%M:%S", &tm) == nullptr) + { + response = "ERROR: time parameter malformed\n"; + return response; + } + receiver_utc_time_ = timegm(&tm); + + // Read latitude, longitude, and height + rx_latitude_ = std::stod(commandLine.at(3).c_str()); + rx_longitude_ = std::stod(commandLine.at(4).c_str()); + rx_altitude_ = std::stod(commandLine.at(5).c_str()); + + if (std::isnan(rx_latitude_) || std::isnan(rx_longitude_) || std::isnan(rx_altitude_)) + { + response = "ERROR: position malformed\n"; + } + else + { + std::unique_ptr cmf(new ControlMessageFactory()); + if (control_queue_ != nullptr) + { + control_queue_->handle(cmf->GetQueueMessage(300, 12)); //send the standby message (who=300,what=12) + response = "OK\n"; + } + else + { + response = "ERROR\n"; + } + } + } + else + { + response = "ERROR: time parameter not found, please use hotstart %d/%m/%Y %H:%M:%S Lat Long H\n"; + } + return response; +} + + +std::string TcpCmdInterface::warmstart(const std::vector &commandLine) +{ + std::string response; + if (commandLine.size() > 5) + { + std::string tmp_str; + // Read commandline time parameter + struct tm tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + tmp_str = commandLine.at(1) + commandLine.at(2); + if (strptime(commandLine.at(1).c_str(), "%d/%m/%Y %H:%M:%S", &tm) == nullptr) + { + response = "ERROR: time parameter malformed\n"; + return response; + } + receiver_utc_time_ = timegm(&tm); + + // Read latitude, longitude, and height + rx_latitude_ = std::stod(commandLine.at(3).c_str()); + rx_longitude_ = std::stod(commandLine.at(4).c_str()); + rx_altitude_ = std::stod(commandLine.at(5).c_str()); + if (std::isnan(rx_latitude_) || std::isnan(rx_longitude_) || std::isnan(rx_altitude_)) + { + response = "ERROR: position malformed\n"; + } + else + { + std::unique_ptr cmf(new ControlMessageFactory()); + if (control_queue_ != nullptr) + { + control_queue_->handle(cmf->GetQueueMessage(300, 13)); // send the warmstart message (who=300,what=13) + response = "OK\n"; + } + else + { + response = "ERROR\n"; + } + } + } + else + { + response = "ERROR: time parameter not found, please use warmstart %d/%m/%Y %H:%M:%S Lat Long H\n"; + } + return response; +} + + +std::string TcpCmdInterface::coldstart(const std::vector &commandLine __attribute__((unused))) +{ + std::string response; + std::unique_ptr cmf(new ControlMessageFactory()); + if (control_queue_ != nullptr) + { + control_queue_->handle(cmf->GetQueueMessage(300, 11)); // send the coldstart message (who=300,what=11) + response = "OK\n"; + } + else + { + response = "ERROR\n"; + } + return response; +} + + +std::string TcpCmdInterface::set_ch_satellite(const std::vector &commandLine __attribute__((unused))) +{ + std::string response; + //todo: implement the set satellite command + response = "Not implemented\n"; + return response; +} + + +void TcpCmdInterface::set_msg_queue(gr::msg_queue::sptr control_queue) +{ + control_queue_ = std::move(control_queue); +} + + +void TcpCmdInterface::run_cmd_server(int tcp_port) +{ + // Get the port from the parameters + uint16_t port = tcp_port; + + // Error to not throw exception + boost::system::error_code not_throw; + + // Socket and acceptor + boost::asio::io_service service; + try + { + boost::asio::ip::tcp::acceptor acceptor(service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)); + + while (keep_running_) + { + try + { + std::cout << "TcpCmdInterface: Telecommand TCP interface listening on port " << tcp_port << std::endl; + + boost::asio::ip::tcp::socket socket(service); + acceptor.accept(socket, not_throw); + if (not_throw) + { + std::cout << "TcpCmdInterface: Error when binding the port in the socket" << std::endl; + continue; + } + + // Read a message + boost::system::error_code error = boost::asio::error::eof; + do + { + std::string response; + boost::asio::streambuf b; + boost::asio::read_until(socket, b, '\n', error); + std::istream is(&b); + std::string line; + std::getline(is, line); + std::istringstream iss(line); + std::vector cmd_vector(std::istream_iterator{iss}, + std::istream_iterator()); + + if (!cmd_vector.empty()) + { + try + { + if (cmd_vector.at(0) == "exit") + { + error = boost::asio::error::eof; + // send cmd response + socket.write_some(boost::asio::buffer("OK\n"), not_throw); + } + else + { + response = functions[cmd_vector.at(0)](cmd_vector); + } + } + catch (const std::bad_function_call &ex) + { + response = "ERROR: command not found \n "; + } + catch (const std::exception &ex) + { + response = "ERROR: command execution error: " + std::string(ex.what()) + "\n"; + } + } + else + { + response = "ERROR: empty command\n"; + } + + // send cmd response + socket.write_some(boost::asio::buffer(response), not_throw); + if (not_throw) + { + std::cout << "Error sending(" << not_throw.value() << "): " << not_throw.message() << std::endl; + break; + } + } + while (error != boost::asio::error::eof); + + if (error == boost::asio::error::eof) + { + std::cout << "TcpCmdInterface: EOF detected\n"; + } + else + { + std::cout << "TcpCmdInterface unexpected error: " << error << std::endl; + } + + // Close socket + socket.close(); + } + catch (const boost::exception &e) + { + std::cout << "TcpCmdInterface: Boost exception " << std::endl; + } + catch (const std::exception &ex) + { + std::cout << "TcpCmdInterface: Exception " << ex.what() << std::endl; + } + } + } + catch (const boost::exception &e) + { + std::cout << "TCP Command Interface exception: address already in use" << std::endl; + } +} diff --git a/src/core/receiver/tcp_cmd_interface.h b/src/core/receiver/tcp_cmd_interface.h new file mode 100644 index 000000000..2e75298ec --- /dev/null +++ b/src/core/receiver/tcp_cmd_interface.h @@ -0,0 +1,94 @@ +/*! + * \file tcp_cmd_interface.h + * + * \brief Class that implements a TCP/IP telecommand command line interface + * for GNSS-SDR + * \author Javier Arribas jarribas (at) cttc.es + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ +#ifndef GNSS_SDR_TCP_CMD_INTERFACE_H_ +#define GNSS_SDR_TCP_CMD_INTERFACE_H_ + +#include "pvt_interface.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class TcpCmdInterface +{ +public: + TcpCmdInterface(); + virtual ~TcpCmdInterface(); + void run_cmd_server(int tcp_port); + void set_msg_queue(gr::msg_queue::sptr control_queue); + + /*! + * \brief gets the UTC time parsed from the last TC command issued + */ + time_t get_utc_time(); + + /*! + * \brief gets the Latitude, Longitude and Altitude vector from the last TC command issued + */ + arma::vec get_LLH(); + + void set_pvt(std::shared_ptr PVT_sptr); + +private: + std::unordered_map &)>> + functions; + std::string status(const std::vector &commandLine); + std::string reset(const std::vector &commandLine); + std::string standby(const std::vector &commandLine); + std::string hotstart(const std::vector &commandLine); + std::string warmstart(const std::vector &commandLine); + std::string coldstart(const std::vector &commandLine); + std::string set_ch_satellite(const std::vector &commandLine); + + void register_functions(); + + gr::msg_queue::sptr control_queue_; + bool keep_running_; + + time_t receiver_utc_time_; + + double rx_latitude_; + double rx_longitude_; + double rx_altitude_; + + std::shared_ptr PVT_sptr_; +}; + +#endif /* GNSS_SDR_TCP_CMD_INTERFACE_H_ */ diff --git a/src/core/system_parameters/Beidou_B1I.h b/src/core/system_parameters/Beidou_B1I.h new file mode 100644 index 000000000..b31f470e9 --- /dev/null +++ b/src/core/system_parameters/Beidou_B1I.h @@ -0,0 +1,347 @@ +/*! + * \file beidou_b1I.h + * \brief Defines system parameters for BeiDou B1I signal and DNAV data + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * \author Damian Miralles, 2018. dmiralles2009@gmail.com + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_BEIDOU_B1I_H_ +#define GNSS_SDR_BEIDOU_B1I_H_ + +#include "MATH_CONSTANTS.h" +#include +#include // std::pair +#include + +// Physical constants +const double BEIDOU_C_M_S = 299792458.0; //!< The speed of light, [m/s] +const double BEIDOU_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] +const double BEIDOU_PI = 3.1415926535898; //!< Pi +const double BEIDOU_TWO_PI = 6.283185307179586; //!< 2Pi +const double BEIDOU_OMEGA_EARTH_DOT = 7.2921150e-5; //!< Earth rotation rate, [rad/s] as defined in CGCS2000 +const double BEIDOU_GM = 3.986004418e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] as defined in CGCS2000 +const double BEIDOU_F = -4.442807309e-10; //!< Constant, [s/(m)^(1/2)] F=-2(GM)^.5/C^2 + + +// carrier and code frequencies +const double BEIDOU_B1I_FREQ_HZ = 1.561098e9; //!< b1I [Hz] +const double BEIDOU_B1I_CODE_RATE_HZ = 2.046e6; //!< beidou b1I code rate [chips/s] +const double BEIDOU_B1I_CODE_LENGTH_CHIPS = 2046.0; //!< beidou b1I code length [chips] +const double BEIDOU_B1I_CODE_PERIOD = 0.001; //!< beidou b1I code period [seconds] +const uint32_t BEIDOU_B1I_CODE_PERIOD_MS = 1; //!< beidou b1I L1 C/A code period [ms] +const double BEIDOU_B1I_CHIP_PERIOD = 4.8875e-07; //!< beidou b1I chip period [seconds] +const int32_t BEIDOU_B1I_SECONDARY_CODE_LENGTH = 20; +const std::string BEIDOU_B1I_SECONDARY_CODE = "00000100110101001110"; +const std::string BEIDOU_B1I_SECONDARY_CODE_STR = "00000100110101001110"; +const std::string BEIDOU_B1I_D2_SECONDARY_CODE_STR = "00"; + +/*! + * \brief Maximum Time-Of-Arrival (TOA) difference between satellites for a receiver operated on Earth surface is 20 ms + * + * According to the GPS orbit model described in [1] Pag. 32. + * It should be taken into account to set the buffer size for the PRN start timestamp in the pseudoranges block. + * [1] J. Bao-Yen Tsui, Fundamentals of Global Positioning System Receivers. A Software Approach, John Wiley & Sons, + * Inc., Hoboken, NJ, 2nd edition, 2005. + */ +const double BEIDOU_MAX_TOA_DELAY_MS = 20; //****************** + +//#define NAVIGATION_SOLUTION_RATE_MS 1000 // this cannot go here +const double BEIDOU_STARTOFFSET_MS = 68.802; //**************[ms] Initial sign. travel time (this cannot go here) + + +// OBSERVABLE HISTORY DEEP FOR INTERPOLATION +const int32_t BEIDOU_B1I_HISTORY_DEEP = 100; // **************** + +// NAVIGATION MESSAGE DEMODULATION AND DECODING + +const int32_t BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; +const int32_t BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** +const double BEIDOU_B1I_PREAMBLE_DURATION_S = 0.220; +const int32_t BEIDOU_B1I_PREAMBLE_DURATION_MS = 220; +const int32_t BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] +const int32_t BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT = 20; // ************* +const int32_t BEIDOU_B1I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] +const int32_t BEIDOU_WORD_LENGTH = 4; //**************!< CRC + BEIDOU WORD (-2 -1 0 ... 29) Bits = 4 bytes +const int32_t BEIDOU_SUBFRAME_LENGTH = 40; //**************!< BEIDOU_WORD_LENGTH x 10 = 40 bytes +const int32_t BEIDOU_DNAV_SUBFRAME_DATA_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] +const int32_t BEIDOU_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] +const int32_t BEIDOU_SUBFRAME_MS = 6000; //!< Subframe duration [miliseconds] +const int32_t BEIDOU_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] + +const std::string BEIDOU_DNAV_PREAMBLE = "11100010010"; +const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_BITS = 11; +const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS = 11; // ************** +const uint32_t BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS = 300; +const uint32_t BEIDOU_DNAV_SUBFRAME_SYMBOLS = 300; +const double BEIDOU_DNAV_DATA_BITS = 300; +const double BEIDOU_DNAV_WORDS_SUBFRAME = 10; +const double BEIDOU_DNAV_WORD_LENGTH_BITS = 30; + +const double BEIDOU_D1NAV_SYMBOL_RATE_SPS = 50; +const double BEIDOU_D2NAV_SYMBOL_RATE_SPS = 500; +const double BEIDOU_B1I_PREAMBLE_PERIOD_SYMBOLS = 300; + +// BEIDOU D1 NAVIGATION MESSAGE STRUCTURE +// GENERAL +const std::vector > D1_PRE({{1, 11}}); +const std::vector > D1_FRAID({{16, 3}}); +const std::vector > D1_SOW({{19, 8}, {31, 12}}); +const std::vector > D1_PNUM({{44, 7}}); + +// DNAV SCALE FACTORS +// EPH +const double D1_TOC_LSB = TWO_P3; +const double D1_TGD1_LSB = 0.1e-9; +const double D1_TGD2_LSB = 0.1e-9; +const double D1_ALPHA0_LSB = TWO_N30; +const double D1_ALPHA1_LSB = TWO_N27; +const double D1_ALPHA2_LSB = TWO_N24; +const double D1_ALPHA3_LSB = TWO_N24; +const double D1_BETA0_LSB = TWO_P11; +const double D1_BETA1_LSB = TWO_P14; +const double D1_BETA2_LSB = TWO_P16; +const double D1_BETA3_LSB = TWO_P16; +const double D1_A2_LSB = TWO_N66; +const double D1_A0_LSB = TWO_N33; +const double D1_A1_LSB = TWO_N50; +const double D1_DELTA_N_LSB = PI_TWO_N43; +const double D1_CUC_LSB = TWO_N31; +const double D1_M0_LSB = PI_TWO_N31; +const double D1_E_LSB = TWO_N33; +const double D1_CUS_LSB = TWO_N31; +const double D1_CRC_LSB = TWO_N6; +const double D1_CRS_LSB = TWO_N6; +const double D1_SQRT_A_LSB = TWO_N19; +const double D1_TOE_LSB = TWO_P3; +const double D1_I0_LSB = PI_TWO_N31; +const double D1_CIC_LSB = TWO_N31; +const double D1_OMEGA_DOT_LSB = PI_TWO_N43; +const double D1_CIS_LSB = TWO_N31; +const double D1_IDOT_LSB = PI_TWO_N43; +const double D1_OMEGA0_LSB = PI_TWO_N31; +const double D1_OMEGA_LSB = PI_TWO_N31; +//ALM +const double D1_SQRT_A_ALMANAC_LSB = TWO_N11; +const double D1_A1_ALMANAC_LSB = TWO_N38; +const double D1_A0_ALMANAC_LSB = TWO_N20; +const double D1_OMEGA0_ALMANAC_LSB = PI_TWO_N23; +const double D1_E_ALMANAC_LSB = TWO_N21; +const double D1_DELTA_I_LSB = PI_TWO_N19; +const double D1_TOA_LSB = TWO_P12; +const double D1_OMEGA_DOT_ALMANAC_LSB = PI_TWO_N38; +const double D1_OMEGA_ALMANAC_LSB = PI_TWO_N23; +const double D1_M0_ALMANAC_LSB = PI_TWO_N23; +const double D1_A0GPS_LSB = 0.1e-9; +const double D1_A1GPS_LSB = 0.1e-9; +const double D1_A0GAL_LSB = 0.1e-9; +const double D1_A1GAL_LSB = 0.1e-9; +const double D1_A0GLO_LSB = 0.1e-9; +const double D1_A1GLO_LSB = 0.1e-9; +const double D1_A0UTC_LSB = TWO_N30; +const double D1_A1UTC_LSB = TWO_N50; + +// SUBFRAME 1 +const std::vector > D1_SAT_H1({{43, 1}}); +const std::vector > D1_AODC({{44, 5}}); +const std::vector > D1_URAI({{49, 4}}); +const std::vector > D1_WN({{61, 13}}); +const std::vector > D1_TOC({{74, 9}, {91, 8}}); +const std::vector > D1_TGD1({{99, 10}}); +const std::vector > D1_TGD2({{121, 6}}); +const std::vector > D1_ALPHA0({{127, 8}}); +const std::vector > D1_ALPHA1({{135, 8}}); +const std::vector > D1_ALPHA2({{151, 8}}); +const std::vector > D1_ALPHA3({{159, 8}}); +const std::vector > D1_BETA0({{167, 6}, {181, 2}}); +const std::vector > D1_BETA1({{183, 8}}); +const std::vector > D1_BETA2({{191, 8}}); +const std::vector > D1_BETA3({{199, 4}, {211, 4}}); +const std::vector > D1_A2({{215, 11}}); +const std::vector > D1_A0({{226, 7}, {241, 17}}); +const std::vector > D1_A1({{258, 5}, {271, 17}}); +const std::vector > D1_AODE({{288, 5}}); + +//SUBFRAME 2 +const std::vector > D1_DELTA_N({{43, 10}, {61, 6}}); +const std::vector > D1_CUC({{67, 16}, {91, 2}}); +const std::vector > D1_M0({{93, 20}, {121, 12}}); +const std::vector > D1_E({{133, 10}, {151, 22}}); +const std::vector > D1_CUS({{181, 18}}); +const std::vector > D1_CRC({{199, 4}, {211, 14}}); +const std::vector > D1_CRS({{225, 8}, {241, 10}}); +const std::vector > D1_SQRT_A({{251, 12}, {271, 20}}); +const std::vector > D1_TOE_SF2({{291, 2}}); + +//SUBFRAME 3 +const std::vector > D1_TOE_SF3({{43, 10}, {61, 5}}); +const std::vector > D1_I0({{66, 17}, {91, 15}}); +const std::vector > D1_CIC({{106, 7}, {121, 11}}); +const std::vector > D1_OMEGA_DOT({{132, 11}, {151, 13}}); +const std::vector > D1_CIS({{164, 9}, {181, 9}}); +const std::vector > D1_IDOT({{190, 13}, {211, 1}}); +const std::vector > D1_OMEGA0({{212, 21}, {241, 11}}); +const std::vector > D1_OMEGA({{252, 11}, {271, 21}}); + +//SUBFRAME 4 AND PAGES 1 THROUGH 6 IN SUBFRAME 5 +const std::vector > D1_SQRT_A_ALMANAC({{51, 2}, {61, 22}}); +const std::vector > D1_A1_ALMANAC({{91, 11}}); +const std::vector > D1_A0_ALMANAC({{102, 11}}); +const std::vector > D1_OMEGA0_ALMANAC({{121, 22}, {151, 2}}); +const std::vector > D1_E_ALMANAC({{153, 17}}); +const std::vector > D1_DELTA_I({{170, 3}, {181, 13}}); +const std::vector > D1_TOA({{194, 8}}); +const std::vector > D1_OMEGA_DOT_ALMANAC({{202, 1}, {211, 16}}); +const std::vector > D1_OMEGA_ALMANAC({{227, 6}, {241, 18}}); +const std::vector > D1_M0_ALMANAC({{259, 4}, {271, 20}}); + +//SUBFRAME 5 PAGE 7 +const std::vector > D1_HEA1({{51, 2}, {61, 7}}); +const std::vector > D1_HEA2({{68, 9}}); +const std::vector > D1_HEA3({{77, 6}, {91, 3}}); +const std::vector > D1_HEA4({{94, 9}}); +const std::vector > D1_HEA5({{103, 9}}); +const std::vector > D1_HEA6({{112, 1}, {121, 8}}); +const std::vector > D1_HEA7({{129, 9}}); +const std::vector > D1_HEA8({{138, 5}, {151, 4}}); +const std::vector > D1_HEA9({{155, 9}}); +const std::vector > D1_HEA10({{164, 9}}); +const std::vector > D1_HEA11({{181, 9}}); +const std::vector > D1_HEA12({{190, 9}}); +const std::vector > D1_HEA13({{199, 4}, {211, 5}}); +const std::vector > D1_HEA14({{216, 9}}); +const std::vector > D1_HEA15({{225, 8}, {241, 1}}); +const std::vector > D1_HEA16({{242, 9}}); +const std::vector > D1_HEA17({{251, 9}}); +const std::vector > D1_HEA18({{260, 3}, {271, 6}}); +const std::vector > D1_HEA19({{277, 9}}); + +//SUBFRAME 5 PAGE 8 +const std::vector > D1_HEA20({{51, 2}, {61, 7}}); +const std::vector > D1_HEA21({{68, 9}}); +const std::vector > D1_HEA22({{77, 6}, {91, 3}}); +const std::vector > D1_HEA23({{94, 9}}); +const std::vector > D1_HEA24({{103, 9}}); +const std::vector > D1_HEA25({{112, 1}, {121, 8}}); +const std::vector > D1_HEA26({{129, 9}}); +const std::vector > D1_HEA27({{138, 5}, {151, 4}}); +const std::vector > D1_HEA28({{155, 9}}); +const std::vector > D1_HEA29({{164, 9}}); +const std::vector > D1_HEA30({{181, 9}}); +const std::vector > D1_WNA({{190, 8}}); +const std::vector > D1_TOA2({{198, 5}, {211, 3}}); + +//SUBFRAME 5 PAGE 9 +const std::vector > D1_A0GPS({{97, 14}}); +const std::vector > D1_A1GPS({{111, 2}, {121, 14}}); +const std::vector > D1_A0GAL({{135, 8}, {151, 6}}); +const std::vector > D1_A1GAL({{157, 16}}); +const std::vector > D1_A0GLO({{181, 14}}); +const std::vector > D1_A1GLO({{195, 8}, {211, 8}}); + +//SUBFRAME 5 PAGE 10 +const std::vector > D1_DELTA_T_LS({{51, 2}, {61, 6}}); +const std::vector > D1_DELTA_T_LSF({{67, 8}}); +const std::vector > D1_WN_LSF({{75, 8}}); +const std::vector > D1_A0UTC({{91, 22}, {121, 10}}); +const std::vector > D1_A1UTC({{131, 12}, {151, 12}}); +const std::vector > D1_DN({{163, 8}}); + +// D2 NAV Message Decoding Information +const std::vector > D2_PRE({{1, 11}}); +const std::vector > D2_FRAID({{16, 3}}); +const std::vector > D2_SOW({{19, 8}, {31, 12}}); +const std::vector > D2_PNUM({{43, 4}}); + +// D2 NAV, SUBFRAME 1, PAGE 1 +const std::vector > D2_SAT_H1({{47, 1}}); +const std::vector > D2_AODC({{48, 5}}); +const std::vector > D2_URAI({{61, 4}}); +const std::vector > D2_WN({{65, 13}}); +const std::vector > D2_TOC({{78, 5}, {91, 12}}); +const std::vector > D2_TGD1({{103, 10}}); +const std::vector > D2_TGD2({{121, 10}}); + +// D2 NAV, SUBFRAME 1, PAGE 2 +const std::vector > D2_ALPHA0({{47, 6}, {61, 2}}); +const std::vector > D2_ALPHA1({{63, 8}}); +const std::vector > D2_ALPHA2({{71, 8}}); +const std::vector > D2_ALPHA3({{79, 4}, {91, 4}}); +const std::vector > D2_BETA0({{95, 8}}); +const std::vector > D2_BETA1({{103, 8}}); +const std::vector > D2_BETA2({{111, 2}, {121, 6}}); +const std::vector > D2_BETA3({{127, 8}}); + +// D2 NAV, SUBFRAME 1, PAGE 3 +const std::vector > D2_A0({{101, 12}, {121, 12}}); +const std::vector > D2_A1_MSB({{133, 4}}); +const std::vector > D2_A1_LSB({{47, 6}, {61, 12}}); +const std::vector > D2_A1({{279, 22}}); + +// D2 NAV, SUBFRAME 1, PAGE 4 +const std::vector > D2_A2({{73, 10}, {91, 1}}); +const std::vector > D2_AODE({{92, 5}}); +const std::vector > D2_DELTA_N({{97, 16}}); +const std::vector > D2_CUC_MSB({{121, 14}}); +const std::vector > D2_CUC_LSB({{47, 4}}); +const std::vector > D2_CUC({{283, 18}}); + +// D2 NAV, SUBFRAME 1, PAGE 5 +const std::vector > D2_M0({{51, 2}, {61, 22}, {91, 8}}); +const std::vector > D2_CUS({{99, 14}, {121, 4}}); +const std::vector > D2_E_MSB({{125, 10}}); + +// D2 NAV, SUBFRAME 1, PAGE 6 +const std::vector > D2_E_LSB({{47, 6}, {61, 16}}); +const std::vector > D2_SQRT_A({{77, 6}, {91, 22}, {121, 4}}); +const std::vector > D2_CIC_MSB({{125, 10}}); +const std::vector > D2_CIC_LSB({{47, 6}, {61, 2}}); +const std::vector > D2_CIC({{283, 18}}); + +// D2 NAV, SUBFRAME 1, PAGE 7 +const std::vector > D2_CIS({{63, 18}}); +const std::vector > D2_TOE({{81, 2}, {91, 15}}); +const std::vector > D2_I0_MSB({{106, 7}, {121, 14}}); +const std::vector > D2_I0_LSB({{47, 6}, {61, 5}}); +const std::vector > D2_I0({{269, 32}}); + +// D2 NAV, SUBFRAME 1, PAGE 8 +const std::vector > D2_CRC({{66, 17}, {91, 1}}); +const std::vector > D2_CRS({{92, 18}}); +const std::vector > D2_OMEGA_DOT_MSB({{110, 3}, {121, 16}}); +const std::vector > D2_OMEGA_DOT_LSB({{47, 5}}); +const std::vector > D2_OMEGA_DOT({{277, 24}}); + +// D2 NAV, SUBFRAME 1, PAGE 9 +const std::vector > D2_OMEGA0({{52, 1}, {61, 22}, {91, 9}}); +const std::vector > D2_OMEGA_MSB({{100, 13}, {121, 14}}); +const std::vector > D2_OMEGA_LSB({{47, 5}}); +const std::vector > D2_OMEGA({{269, 32}}); + +// D2 NAV, SUBFRAME 1, PAGE 10 +const std::vector > D2_IDOT({{52, 1}, {61, 13}}); + +#endif /* GNSS_SDR_BEIDOU_B1I_H_ */ diff --git a/src/core/system_parameters/CMakeLists.txt b/src/core/system_parameters/CMakeLists.txt index d8d3971f6..262aab718 100644 --- a/src/core/system_parameters/CMakeLists.txt +++ b/src/core/system_parameters/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -16,50 +16,117 @@ # along with GNSS-SDR. If not, see . # + set(SYSTEM_PARAMETERS_SOURCES - gnss_satellite.cc - gnss_signal.cc - gps_navigation_message.cc - gps_ephemeris.cc - gps_iono.cc - gps_almanac.cc - gps_utc_model.cc - gps_acq_assist.cc - gps_ref_time.cc - gps_ref_location.cc - galileo_utc_model.cc - galileo_ephemeris.cc - galileo_almanac.cc - galileo_iono.cc - galileo_navigation_message.cc - sbas_ephemeris.cc - galileo_fnav_message.cc - gps_cnav_ephemeris.cc - gps_cnav_navigation_message.cc - gps_cnav_iono.cc - gps_cnav_utc_model.cc - rtcm.cc - glonass_gnav_ephemeris.cc - glonass_gnav_almanac.cc - glonass_gnav_utc_model.cc - glonass_gnav_navigation_message.cc + gnss_satellite.cc + gnss_signal.cc + gps_navigation_message.cc + gps_ephemeris.cc + gps_iono.cc + gps_almanac.cc + gps_utc_model.cc + gps_acq_assist.cc + agnss_ref_time.cc + agnss_ref_location.cc + galileo_utc_model.cc + galileo_ephemeris.cc + galileo_almanac.cc + galileo_almanac_helper.cc + galileo_iono.cc + galileo_navigation_message.cc + beidou_dnav_navigation_message.cc + beidou_dnav_ephemeris.cc + beidou_dnav_iono.cc + beidou_dnav_almanac.cc + beidou_dnav_utc_model.cc + sbas_ephemeris.cc + galileo_fnav_message.cc + gps_cnav_ephemeris.cc + gps_cnav_navigation_message.cc + gps_cnav_iono.cc + gps_cnav_utc_model.cc + glonass_gnav_ephemeris.cc + glonass_gnav_almanac.cc + glonass_gnav_utc_model.cc + glonass_gnav_navigation_message.cc ) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib - ${GLOG_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} +set(SYSTEM_PARAMETERS_HEADERS + gnss_satellite.h + gnss_signal.h + gps_navigation_message.h + gps_ephemeris.h + gps_iono.h + gps_almanac.h + gps_utc_model.h + gps_acq_assist.h + agnss_ref_time.h + agnss_ref_location.h + galileo_utc_model.h + galileo_ephemeris.h + galileo_almanac.h + galileo_almanac_helper.h + galileo_iono.h + galileo_navigation_message.h + sbas_ephemeris.h + galileo_fnav_message.h + gps_cnav_ephemeris.h + gps_cnav_navigation_message.h + gps_cnav_iono.h + gps_cnav_utc_model.h + glonass_gnav_ephemeris.h + glonass_gnav_almanac.h + glonass_gnav_utc_model.h + glonass_gnav_navigation_message.h + beidou_dnav_navigation_message.h + beidou_dnav_ephemeris.h + beidou_dnav_iono.h + beidou_dnav_almanac.h + beidou_dnav_utc_model.h + display.h + Galileo_E1.h + Galileo_E5a.h + GLONASS_L1_L2_CA.h + gnss_frequencies.h + gnss_obs_codes.h + gnss_synchro.h + GPS_CNAV.h + GPS_L1_CA.h + GPS_L2C.h + GPS_L5.h + Beidou_B1I.h + MATH_CONSTANTS.h ) -link_directories(${Boost_LIBRARY_DIR}) -file(GLOB SYSTEM_PARAMETERS_HEADERS "*.h") list(SORT SYSTEM_PARAMETERS_HEADERS) -add_library(gnss_system_parameters ${SYSTEM_PARAMETERS_SOURCES} ${SYSTEM_PARAMETERS_HEADERS}) +list(SORT SYSTEM_PARAMETERS_SOURCES) + source_group(Headers FILES ${SYSTEM_PARAMETERS_HEADERS}) -add_dependencies(gnss_system_parameters rtklib_lib glog-${glog_RELEASE}) -target_link_libraries(gnss_system_parameters rtklib_lib ${Boost_LIBRARIES}) + +add_library(core_system_parameters + ${SYSTEM_PARAMETERS_SOURCES} + ${SYSTEM_PARAMETERS_HEADERS} +) + +target_link_libraries(core_system_parameters + PUBLIC + Boost::date_time + Boost::serialization + Glog::glog + PRIVATE + Gflags::gflags +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(core_system_parameters + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET core_system_parameters + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/core/system_parameters/GLONASS_L1_L2_CA.h b/src/core/system_parameters/GLONASS_L1_L2_CA.h index be2564d57..b8c796b4f 100644 --- a/src/core/system_parameters/GLONASS_L1_L2_CA.h +++ b/src/core/system_parameters/GLONASS_L1_L2_CA.h @@ -33,21 +33,22 @@ #ifndef GNSS_SDR_GLONASS_L1_L2_CA_H_ #define GNSS_SDR_GLONASS_L1_L2_CA_H_ -#include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" +#include "gnss_frequencies.h" +#include #include -#include #include // std::pair +#include // Physical constants -const double GLONASS_C_m_s = SPEED_OF_LIGHT; //!< The speed of light, [m/s] -const double GLONASS_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double GLONASS_C_M_S = SPEED_OF_LIGHT; //!< The speed of light, [m/s] +const double GLONASS_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] const double GLONASS_PI = 3.1415926535898; //!< Pi as defined in IS-GPS-200E const double GLONASS_TWO_PI = 6.283185307179586; //!< 2Pi as defined in IS-GPS-200E const double GLONASS_OMEGA_EARTH_DOT = 7.292115e-5; //!< Earth rotation rate, [rad/s] const double GLONASS_GM = 398600.4418e9; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] -const double GLONASS_fM_a = 0.35e9; //!< Gravitational constant of atmosphere [m^3/s^2] +const double GLONASS_F_M_A = 0.35e9; //!< Gravitational constant of atmosphere [m^3/s^2] const double GLONASS_SEMI_MAJOR_AXIS = 6378136; //!< Semi-major axis of Earth [m] const double GLONASS_FLATTENING = 1 / 29825784; //!< Flattening parameter const double GLONASS_GRAVITY = 97803284; //!< Equatorial acceleration of gravity [mGal] @@ -96,7 +97,7 @@ const double GLONASS_L1_CA_CODE_PERIOD = 0.001; //!< GLONASS L1 C/A code const double GLONASS_L1_CA_CHIP_PERIOD = 1.9569e-06; //!< GLONASS L1 C/A chip period [seconds] const double GLONASS_L1_CA_SYMBOL_RATE_BPS = 1000; -const int GLONASS_CA_NBR_SATS = 24; // STRING DATA WITHOUT PREAMBLE +const int32_t GLONASS_CA_NBR_SATS = 24; // STRING DATA WITHOUT PREAMBLE /*! * \brief Record of leap seconds definition for GLOT to GPST conversion and vice versa @@ -125,7 +126,7 @@ const double GLONASS_LEAP_SECONDS[19][7] = { {}}; //!< GLONASS SV's orbital slots PRN = (orbital_slot - 1) -const std::map GLONASS_PRN = { +const std::map GLONASS_PRN = { { 0, 8, @@ -224,10 +225,10 @@ const std::map GLONASS_PRN = { }, //Plane 3 {24, 2}}; //Plane 3 -const double GLONASS_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) +const double GLONASS_STARTOFFSET_MS = 68.802; //[ms] Initial sign. travel time (this cannot go here) // OBSERVABLE HISTORY DEEP FOR INTERPOLATION -const int GLONASS_L1_CA_HISTORY_DEEP = 100; +const int32_t GLONASS_L1_CA_HISTORY_DEEP = 100; // NAVIGATION MESSAGE DEMODULATION AND DECODING #define GLONASS_GNAV_PREAMBLE \ @@ -235,96 +236,96 @@ const int GLONASS_L1_CA_HISTORY_DEEP = 100; 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0 \ } const double GLONASS_GNAV_PREAMBLE_DURATION_S = 0.300; -const int GLONASS_GNAV_PREAMBLE_LENGTH_BITS = 30; -const int GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS = 300; -const int GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS = 2000; -const int GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] -const int GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT = 10; -const int GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT = 10; -const int GLONASS_GNAV_TELEMETRY_RATE_SYMBOLS_SECOND = GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND * GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] -const int GLONASS_GNAV_STRING_SYMBOLS = 2000; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] -const int GLONASS_GNAV_STRING_BITS = 85; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] -const int GLONASS_GNAV_HAMMING_CODE_BITS = 8; //!< Number of bits in hamming code sequence of GNAV message -const int GLONASS_GNAV_DATA_SYMBOLS = 1700; // STRING DATA WITHOUT PREAMBLE +const int32_t GLONASS_GNAV_PREAMBLE_LENGTH_BITS = 30; +const int32_t GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS = 300; +const int32_t GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS = 2000; +const int32_t GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] +const int32_t GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT = 10; +const int32_t GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT = 10; +const int32_t GLONASS_GNAV_TELEMETRY_RATE_SYMBOLS_SECOND = GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND * GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] +const int32_t GLONASS_GNAV_STRING_SYMBOLS = 2000; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] +const int32_t GLONASS_GNAV_STRING_BITS = 85; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] +const int32_t GLONASS_GNAV_HAMMING_CODE_BITS = 8; //!< Number of bits in hamming code sequence of GNAV message +const int32_t GLONASS_GNAV_DATA_SYMBOLS = 1700; // STRING DATA WITHOUT PREAMBLE -const std::vector GLONASS_GNAV_CRC_I_INDEX{9, 10, 12, 13, 15, 17, 19, 20, 22, 24, 26, 28, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84}; -const std::vector GLONASS_GNAV_CRC_J_INDEX{9, 11, 12, 14, 15, 18, 19, 21, 22, 25, 26, 29, 30, 33, 34, 36, 37, 40, 41, 44, 45, 48, 49, 52, 53, 56, 57, 60, 61, 64, 65, 67, 68, 71, 72, 75, 76, 79, 80, 83, 84}; -const std::vector GLONASS_GNAV_CRC_K_INDEX{10, 11, 12, 16, 17, 18, 19, 23, 24, 25, 26, 31, 32, 33, 34, 38, 39, 40, 41, 46, 47, 48, 49, 54, 55, 56, 57, 62, 63, 64, 65, 69, 70, 71, 72, 77, 78, 79, 80, 85}; -const std::vector GLONASS_GNAV_CRC_L_INDEX{13, 14, 15, 16, 17, 18, 19, 27, 28, 29, 30, 31, 32, 33, 34, 42, 43, 44, 45, 46, 47, 48, 49, 58, 59, 60, 61, 62, 63, 64, 65, 73, 74, 75, 76, 77, 78, 79, 80}; -const std::vector GLONASS_GNAV_CRC_M_INDEX{20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 81, 82, 83, 84, 85}; -const std::vector GLONASS_GNAV_CRC_N_INDEX{35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65}; -const std::vector GLONASS_GNAV_CRC_P_INDEX{66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; -const std::vector GLONASS_GNAV_CRC_Q_INDEX{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; +const std::vector GLONASS_GNAV_CRC_I_INDEX{9, 10, 12, 13, 15, 17, 19, 20, 22, 24, 26, 28, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84}; +const std::vector GLONASS_GNAV_CRC_J_INDEX{9, 11, 12, 14, 15, 18, 19, 21, 22, 25, 26, 29, 30, 33, 34, 36, 37, 40, 41, 44, 45, 48, 49, 52, 53, 56, 57, 60, 61, 64, 65, 67, 68, 71, 72, 75, 76, 79, 80, 83, 84}; +const std::vector GLONASS_GNAV_CRC_K_INDEX{10, 11, 12, 16, 17, 18, 19, 23, 24, 25, 26, 31, 32, 33, 34, 38, 39, 40, 41, 46, 47, 48, 49, 54, 55, 56, 57, 62, 63, 64, 65, 69, 70, 71, 72, 77, 78, 79, 80, 85}; +const std::vector GLONASS_GNAV_CRC_L_INDEX{13, 14, 15, 16, 17, 18, 19, 27, 28, 29, 30, 31, 32, 33, 34, 42, 43, 44, 45, 46, 47, 48, 49, 58, 59, 60, 61, 62, 63, 64, 65, 73, 74, 75, 76, 77, 78, 79, 80}; +const std::vector GLONASS_GNAV_CRC_M_INDEX{20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 81, 82, 83, 84, 85}; +const std::vector GLONASS_GNAV_CRC_N_INDEX{35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65}; +const std::vector GLONASS_GNAV_CRC_P_INDEX{66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; +const std::vector GLONASS_GNAV_CRC_Q_INDEX{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; // GLONASS GNAV NAVIGATION MESSAGE STRUCTURE // NAVIGATION MESSAGE FIELDS POSITIONS (from IS-GPS-200E Appendix II) // FRAME 1-4 // COMMON FIELDS -const std::vector> STRING_ID({{2, 4}}); -const std::vector> KX({{78, 8}}); +const std::vector> STRING_ID({{2, 4}}); +const std::vector> KX({{78, 8}}); //STRING 1 -const std::vector> P1({{8, 2}}); -const std::vector> T_K_HR({{10, 5}}); -const std::vector> T_K_MIN({{15, 6}}); -const std::vector> T_K_SEC({{21, 1}}); -const std::vector> X_N_DOT({{22, 24}}); -const std::vector> X_N_DOT_DOT({{46, 5}}); -const std::vector> X_N({{51, 27}}); +const std::vector> P1({{8, 2}}); +const std::vector> T_K_HR({{10, 5}}); +const std::vector> T_K_MIN({{15, 6}}); +const std::vector> T_K_SEC({{21, 1}}); +const std::vector> X_N_DOT({{22, 24}}); +const std::vector> X_N_DOT_DOT({{46, 5}}); +const std::vector> X_N({{51, 27}}); //STRING 2 -const std::vector> B_N({{6, 3}}); -const std::vector> P2({{9, 1}}); -const std::vector> T_B({{10, 7}}); -const std::vector> Y_N_DOT({{22, 24}}); -const std::vector> Y_N_DOT_DOT({{46, 5}}); -const std::vector> Y_N({{51, 27}}); +const std::vector> B_N({{6, 3}}); +const std::vector> P2({{9, 1}}); +const std::vector> T_B({{10, 7}}); +const std::vector> Y_N_DOT({{22, 24}}); +const std::vector> Y_N_DOT_DOT({{46, 5}}); +const std::vector> Y_N({{51, 27}}); //STRING 3 -const std::vector> P3({{6, 1}}); -const std::vector> GAMMA_N({{7, 11}}); -const std::vector> P({{19, 2}}); -const std::vector> EPH_L_N({{21, 1}}); -const std::vector> Z_N_DOT({{22, 24}}); -const std::vector> Z_N_DOT_DOT({{46, 5}}); -const std::vector> Z_N({{51, 27}}); +const std::vector> P3({{6, 1}}); +const std::vector> GAMMA_N({{7, 11}}); +const std::vector> P({{19, 2}}); +const std::vector> EPH_L_N({{21, 1}}); +const std::vector> Z_N_DOT({{22, 24}}); +const std::vector> Z_N_DOT_DOT({{46, 5}}); +const std::vector> Z_N({{51, 27}}); // STRING 4 -const std::vector> TAU_N({{6, 22}}); -const std::vector> DELTA_TAU_N({{28, 5}}); -const std::vector> E_N({{33, 5}}); -const std::vector> P4({{52, 1}}); -const std::vector> F_T({{53, 4}}); -const std::vector> N_T({{60, 11}}); -const std::vector> N({{71, 5}}); -const std::vector> M({{76, 2}}); +const std::vector> TAU_N({{6, 22}}); +const std::vector> DELTA_TAU_N({{28, 5}}); +const std::vector> E_N({{33, 5}}); +const std::vector> P4({{52, 1}}); +const std::vector> F_T({{53, 4}}); +const std::vector> N_T({{60, 11}}); +const std::vector> N({{71, 5}}); +const std::vector> M({{76, 2}}); // STRING 5 -const std::vector> N_A({{6, 11}}); -const std::vector> TAU_C({{17, 32}}); -const std::vector> N_4({{50, 5}}); -const std::vector> TAU_GPS({{55, 22}}); -const std::vector> ALM_L_N({{77, 1}}); +const std::vector> DAY_NUMBER_A({{6, 11}}); +const std::vector> TAU_C({{17, 32}}); +const std::vector> N_4({{50, 5}}); +const std::vector> TAU_GPS({{55, 22}}); +const std::vector> ALM_L_N({{77, 1}}); // STRING 6, 8, 10, 12, 14 -const std::vector> C_N({{6, 1}}); -const std::vector> M_N_A({{7, 2}}); -const std::vector> n_A({{9, 5}}); -const std::vector> TAU_N_A({{14, 10}}); -const std::vector> LAMBDA_N_A({{24, 21}}); -const std::vector> DELTA_I_N_A({{45, 18}}); -const std::vector> EPSILON_N_A({{63, 15}}); +const std::vector> C_N({{6, 1}}); +const std::vector> M_N_A({{7, 2}}); +const std::vector> N_A({{9, 5}}); +const std::vector> TAU_N_A({{14, 10}}); +const std::vector> LAMBDA_N_A({{24, 21}}); +const std::vector> DELTA_I_N_A({{45, 18}}); +const std::vector> EPSILON_N_A({{63, 15}}); //STRING 7, 9, 11, 13, 15 -const std::vector> OMEGA_N_A({{6, 16}}); -const std::vector> T_LAMBDA_N_A({{22, 21}}); -const std::vector> DELTA_T_N_A({{43, 22}}); -const std::vector> DELTA_T_DOT_N_A({{65, 7}}); -const std::vector> H_N_A({{72, 5}}); +const std::vector> OMEGA_N_A({{6, 16}}); +const std::vector> T_LAMBDA_N_A({{22, 21}}); +const std::vector> DELTA_T_N_A({{43, 22}}); +const std::vector> DELTA_T_DOT_N_A({{65, 7}}); +const std::vector> H_N_A({{72, 5}}); // STRING 14 FRAME 5 -const std::vector> B1({{6, 11}}); -const std::vector> B2({{17, 10}}); +const std::vector> B1({{6, 11}}); +const std::vector> B2({{17, 10}}); #endif /* GNSS_SDR_GLONASS_L1_L2_CA_H_ */ diff --git a/src/core/system_parameters/GPS_CNAV.h b/src/core/system_parameters/GPS_CNAV.h index 343ab3f5c..025230930 100644 --- a/src/core/system_parameters/GPS_CNAV.h +++ b/src/core/system_parameters/GPS_CNAV.h @@ -34,8 +34,8 @@ #include "MATH_CONSTANTS.h" #include -#include #include // std::pair +#include // CNAV GPS NAVIGATION MESSAGE STRUCTURE @@ -48,136 +48,136 @@ #define GPS_CNAV_PREAMBLE_STR "10001011" #define GPS_CNAV_INV_PREAMBLE_STR "01110100" -const int GPS_CNAV_DATA_PAGE_BITS = 300; +const int32_t GPS_CNAV_DATA_PAGE_BITS = 300; // common to all messages -const std::vector > CNAV_PRN({{9, 6}}); -const std::vector > CNAV_MSG_TYPE({{15, 6}}); -const std::vector > CNAV_TOW({{21, 17}}); //GPS Time Of Week in seconds -const double CNAV_TOW_LSB = 6.0; -const std::vector > CNAV_ALERT_FLAG({{38, 1}}); +const std::vector > CNAV_PRN({{9, 6}}); +const std::vector > CNAV_MSG_TYPE({{15, 6}}); +const std::vector > CNAV_TOW({{21, 17}}); // GPS Time Of Week in seconds +const int32_t CNAV_TOW_LSB = 6; +const std::vector > CNAV_ALERT_FLAG({{38, 1}}); // MESSAGE TYPE 10 (Ephemeris 1) -const std::vector > CNAV_WN({{39, 13}}); -const std::vector > CNAV_HEALTH({{52, 3}}); -const std::vector > CNAV_TOP1({{55, 11}}); -const double CNAV_TOP1_LSB = 300.0; -const std::vector > CNAV_URA({{66, 5}}); +const std::vector > CNAV_WN({{39, 13}}); +const std::vector > CNAV_HEALTH({{52, 3}}); +const std::vector > CNAV_TOP1({{55, 11}}); +const int32_t CNAV_TOP1_LSB = 300; +const std::vector > CNAV_URA({{66, 5}}); -const std::vector > CNAV_TOE1({{71, 11}}); -const double CNAV_TOE1_LSB = 300.0; +const std::vector > CNAV_TOE1({{71, 11}}); +const int32_t CNAV_TOE1_LSB = 300; -const std::vector > CNAV_DELTA_A({{82, 26}}); //Relative to AREF = 26,559,710 meters +const std::vector > CNAV_DELTA_A({{82, 26}}); // Relative to AREF = 26,559,710 meters const double CNAV_DELTA_A_LSB = TWO_N9; -const std::vector > CNAV_A_DOT({{108, 25}}); +const std::vector > CNAV_A_DOT({{108, 25}}); const double CNAV_A_DOT_LSB = TWO_N21; -const std::vector > CNAV_DELTA_N0({{133, 17}}); -const double CNAV_DELTA_N0_LSB = TWO_N44 * PI; //semi-circles to radians -const std::vector > CNAV_DELTA_N0_DOT({{150, 23}}); +const std::vector > CNAV_DELTA_N0({{133, 17}}); +const double CNAV_DELTA_N0_LSB = TWO_N44 * PI; // semi-circles to radians +const std::vector > CNAV_DELTA_N0_DOT({{150, 23}}); const double CNAV_DELTA_N0_DOT_LSB = TWO_N57 * PI; //semi-circles to radians -const std::vector > CNAV_M0({{173, 33}}); -const double CNAV_M0_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_E_ECCENTRICITY({{206, 33}}); +const std::vector > CNAV_M0({{173, 33}}); +const double CNAV_M0_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_E_ECCENTRICITY({{206, 33}}); const double CNAV_E_ECCENTRICITY_LSB = TWO_N34; -const std::vector > CNAV_OMEGA({{239, 33}}); -const double CNAV_OMEGA_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_INTEGRITY_FLAG({{272, 1}}); -const std::vector > CNAV_L2_PHASING_FLAG({{273, 1}}); +const std::vector > CNAV_OMEGA({{239, 33}}); +const double CNAV_OMEGA_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_INTEGRITY_FLAG({{272, 1}}); +const std::vector > CNAV_L2_PHASING_FLAG({{273, 1}}); // MESSAGE TYPE 11 (Ephemeris 2) -const std::vector > CNAV_TOE2({{39, 11}}); -const double CNAV_TOE2_LSB = 300.0; -const std::vector > CNAV_OMEGA0({{50, 33}}); -const double CNAV_OMEGA0_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_I0({{83, 33}}); -const double CNAV_I0_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_DELTA_OMEGA_DOT({{116, 17}}); //Relative to REF = -2.6 x 10-9 semi-circles/second. -const double CNAV_DELTA_OMEGA_DOT_LSB = TWO_N44 * PI; //semi-circles to radians -const std::vector > CNAV_I0_DOT({{133, 15}}); -const double CNAV_I0_DOT_LSB = TWO_N44 * PI; //semi-circles to radians -const std::vector > CNAV_CIS({{148, 16}}); +const std::vector > CNAV_TOE2({{39, 11}}); +const int32_t CNAV_TOE2_LSB = 300; +const std::vector > CNAV_OMEGA0({{50, 33}}); +const double CNAV_OMEGA0_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_I0({{83, 33}}); +const double CNAV_I0_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_DELTA_OMEGA_DOT({{116, 17}}); // Relative to REF = -2.6 x 10-9 semi-circles/second. +const double CNAV_DELTA_OMEGA_DOT_LSB = TWO_N44 * PI; // semi-circles to radians +const std::vector > CNAV_I0_DOT({{133, 15}}); +const double CNAV_I0_DOT_LSB = TWO_N44 * PI; // semi-circles to radians +const std::vector > CNAV_CIS({{148, 16}}); const double CNAV_CIS_LSB = TWO_N30; -const std::vector > CNAV_CIC({{164, 16}}); +const std::vector > CNAV_CIC({{164, 16}}); const double CNAV_CIC_LSB = TWO_N30; -const std::vector > CNAV_CRS({{180, 24}}); +const std::vector > CNAV_CRS({{180, 24}}); const double CNAV_CRS_LSB = TWO_N8; -const std::vector > CNAV_CRC({{204, 24}}); +const std::vector > CNAV_CRC({{204, 24}}); const double CNAV_CRC_LSB = TWO_N8; -const std::vector > CNAV_CUS({{228, 21}}); +const std::vector > CNAV_CUS({{228, 21}}); const double CNAV_CUS_LSB = TWO_N30; -const std::vector > CNAV_CUC({{249, 21}}); +const std::vector > CNAV_CUC({{249, 21}}); const double CNAV_CUC_LSB = TWO_N30; // MESSAGE TYPE 30 (CLOCK, IONO, GRUP DELAY) -const std::vector > CNAV_TOP2({{39, 11}}); -const double CNAV_TOP2_LSB = 300.0; -const std::vector > CNAV_URA_NED0({{50, 5}}); -const std::vector > CNAV_URA_NED1({{55, 3}}); -const std::vector > CNAV_URA_NED2({{58, 3}}); -const std::vector > CNAV_TOC({{61, 11}}); -const double CNAV_TOC_LSB = 300.0; -const std::vector > CNAV_AF0({{72,26}}); +const std::vector > CNAV_TOP2({{39, 11}}); +const int32_t CNAV_TOP2_LSB = 300; +const std::vector > CNAV_URA_NED0({{50, 5}}); +const std::vector > CNAV_URA_NED1({{55, 3}}); +const std::vector > CNAV_URA_NED2({{58, 3}}); +const std::vector > CNAV_TOC({{61, 11}}); +const int32_t CNAV_TOC_LSB = 300; +const std::vector > CNAV_AF0({{72, 26}}); const double CNAV_AF0_LSB = TWO_N35; -const std::vector > CNAV_AF1({{98,20}}); +const std::vector > CNAV_AF1({{98, 20}}); const double CNAV_AF1_LSB = TWO_N48; -const std::vector > CNAV_AF2({{118,10}}); +const std::vector > CNAV_AF2({{118, 10}}); const double CNAV_AF2_LSB = TWO_N60; -const std::vector > CNAV_TGD({{128,13}}); +const std::vector > CNAV_TGD({{128, 13}}); const double CNAV_TGD_LSB = TWO_N35; -const std::vector > CNAV_ISCL1({{141, 13}}); +const std::vector > CNAV_ISCL1({{141, 13}}); const double CNAV_ISCL1_LSB = TWO_N35; -const std::vector > CNAV_ISCL2({{154, 13}}); +const std::vector > CNAV_ISCL2({{154, 13}}); const double CNAV_ISCL2_LSB = TWO_N35; -const std::vector > CNAV_ISCL5I({{167, 13}}); +const std::vector > CNAV_ISCL5I({{167, 13}}); const double CNAV_ISCL5I_LSB = TWO_N35; -const std::vector > CNAV_ISCL5Q({{180, 13}}); +const std::vector > CNAV_ISCL5Q({{180, 13}}); const double CNAV_ISCL5Q_LSB = TWO_N35; -//Ionospheric parameters -const std::vector > CNAV_ALPHA0({{193, 8}}); +// Ionospheric parameters +const std::vector > CNAV_ALPHA0({{193, 8}}); const double CNAV_ALPHA0_LSB = TWO_N30; -const std::vector > CNAV_ALPHA1({{201, 8}}); +const std::vector > CNAV_ALPHA1({{201, 8}}); const double CNAV_ALPHA1_LSB = TWO_N27; -const std::vector > CNAV_ALPHA2({{209, 8}}); +const std::vector > CNAV_ALPHA2({{209, 8}}); const double CNAV_ALPHA2_LSB = TWO_N24; -const std::vector > CNAV_ALPHA3({{217, 8}}); +const std::vector > CNAV_ALPHA3({{217, 8}}); const double CNAV_ALPHA3_LSB = TWO_N24; -const std::vector > CNAV_BETA0({{225, 8}}); +const std::vector > CNAV_BETA0({{225, 8}}); const double CNAV_BETA0_LSB = TWO_P11; -const std::vector > CNAV_BETA1({{233, 8}}); +const std::vector > CNAV_BETA1({{233, 8}}); const double CNAV_BETA1_LSB = TWO_P14; -const std::vector > CNAV_BETA2({{241, 8}}); +const std::vector > CNAV_BETA2({{241, 8}}); const double CNAV_BETA2_LSB = TWO_P16; -const std::vector > CNAV_BETA3({{249, 8}}); +const std::vector > CNAV_BETA3({{249, 8}}); const double CNAV_BETA3_LSB = TWO_P16; -const std::vector > CNAV_WNOP({{257, 8}}); +const std::vector > CNAV_WNOP({{257, 8}}); // MESSAGE TYPE 33 (CLOCK and UTC) -const std::vector > CNAV_A0({{128, 16}}); +const std::vector > CNAV_A0({{128, 16}}); const double CNAV_A0_LSB = TWO_N35; -const std::vector > CNAV_A1({{144, 13}}); +const std::vector > CNAV_A1({{144, 13}}); const double CNAV_A1_LSB = TWO_N51; -const std::vector > CNAV_A2({{157, 7}}); +const std::vector > CNAV_A2({{157, 7}}); const double CNAV_A2_LSB = TWO_N68; -const std::vector > CNAV_DELTA_TLS({{164, 8}}); -const double CNAV_DELTA_TLS_LSB = 1; -const std::vector > CNAV_TOT({{172, 16}}); -const double CNAV_TOT_LSB = TWO_P4; -const std::vector > CNAV_WN_OT({{188, 13}}); -const double CNAV_WN_OT_LSB = 1; -const std::vector > CNAV_WN_LSF({{201, 13}}); -const double CNAV_WN_LSF_LSB = 1; -const std::vector > CNAV_DN({{214, 4}}); -const double CNAV_DN_LSB = 1; -const std::vector > CNAV_DELTA_TLSF({{218, 8}}); -const double CNAV_DELTA_TLSF_LSB = 1; +const std::vector > CNAV_DELTA_TLS({{164, 8}}); +const int32_t CNAV_DELTA_TLS_LSB = 1; +const std::vector > CNAV_TOT({{172, 16}}); +const int32_t CNAV_TOT_LSB = TWO_P4; +const std::vector > CNAV_WN_OT({{188, 13}}); +const int32_t CNAV_WN_OT_LSB = 1; +const std::vector > CNAV_WN_LSF({{201, 13}}); +const int32_t CNAV_WN_LSF_LSB = 1; +const std::vector > CNAV_DN({{214, 4}}); +const int32_t CNAV_DN_LSB = 1; +const std::vector > CNAV_DELTA_TLSF({{218, 8}}); +const int32_t CNAV_DELTA_TLSF_LSB = 1; // TODO: Add more frames (Almanac, etc...) diff --git a/src/core/system_parameters/GPS_L1_CA.h b/src/core/system_parameters/GPS_L1_CA.h index f26e92f59..ee81a18e8 100644 --- a/src/core/system_parameters/GPS_L1_CA.h +++ b/src/core/system_parameters/GPS_L1_CA.h @@ -32,15 +32,16 @@ #ifndef GNSS_SDR_GPS_L1_CA_H_ #define GNSS_SDR_GPS_L1_CA_H_ -#include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" -#include +#include "gnss_frequencies.h" +#include #include // std::pair +#include // Physical constants -const double GPS_C_m_s = SPEED_OF_LIGHT; //!< The speed of light, [m/s] -const double GPS_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double GPS_C_M_S = SPEED_OF_LIGHT; //!< The speed of light, [m/s] +const double GPS_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] const double GPS_PI = 3.1415926535898; //!< Pi as defined in IS-GPS-200E const double GPS_TWO_PI = 6.283185307179586; //!< 2Pi as defined in IS-GPS-200E const double OMEGA_EARTH_DOT = DEFAULT_OMEGA_EARTH_DOT; //!< Earth rotation rate, [rad/s] @@ -53,9 +54,12 @@ const double GPS_L1_FREQ_HZ = FREQ1; //!< L1 [Hz] const double GPS_L1_CA_CODE_RATE_HZ = 1.023e6; //!< GPS L1 C/A code rate [chips/s] const double GPS_L1_CA_CODE_LENGTH_CHIPS = 1023.0; //!< GPS L1 C/A code length [chips] const double GPS_L1_CA_CODE_PERIOD = 0.001; //!< GPS L1 C/A code period [seconds] -const unsigned int GPS_L1_CA_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms] +const uint32_t GPS_L1_CA_CODE_PERIOD_MS = 1U; //!< GPS L1 C/A code period [ms] const double GPS_L1_CA_CHIP_PERIOD = 9.7752e-07; //!< GPS L1 C/A chip period [seconds] +//optimum parameters +const uint32_t GPS_L1_CA_OPT_ACQ_FS_HZ = 1000000; //!< Sampling frequncy that maximizes the acquisition SNR while using a non-multiple of chip rate + /*! * \brief Maximum Time-Of-Arrival (TOA) difference between satellites for a receiver operated on Earth surface is 20 ms * @@ -67,11 +71,11 @@ const double GPS_L1_CA_CHIP_PERIOD = 9.7752e-07; //!< GPS L1 C/A chip period const double MAX_TOA_DELAY_MS = 20; //#define NAVIGATION_SOLUTION_RATE_MS 1000 // this cannot go here -const double GPS_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) - +//const double GPS_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) +const double GPS_STARTOFFSET_MS = 60.0; // OBSERVABLE HISTORY DEEP FOR INTERPOLATION -const int GPS_L1_CA_HISTORY_DEEP = 100; +const int32_t GPS_L1_CA_HISTORY_DEEP = 100; // NAVIGATION MESSAGE DEMODULATION AND DECODING @@ -79,171 +83,172 @@ const int GPS_L1_CA_HISTORY_DEEP = 100; { \ 1, 0, 0, 0, 1, 0, 1, 1 \ } -const int GPS_CA_PREAMBLE_LENGTH_BITS = 8; -const int GPS_CA_PREAMBLE_LENGTH_SYMBOLS = 160; +const int32_t GPS_CA_PREAMBLE_LENGTH_BITS = 8; +const int32_t GPS_CA_PREAMBLE_LENGTH_SYMBOLS = 160; const double GPS_CA_PREAMBLE_DURATION_S = 0.160; -const int GPS_CA_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] -const int GPS_CA_TELEMETRY_SYMBOLS_PER_BIT = 20; -const int GPS_CA_TELEMETRY_RATE_SYMBOLS_SECOND = GPS_CA_TELEMETRY_RATE_BITS_SECOND * GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] -const int GPS_WORD_LENGTH = 4; //!< CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes -const int GPS_SUBFRAME_LENGTH = 40; //!< GPS_WORD_LENGTH x 10 = 40 bytes -const int GPS_SUBFRAME_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] -const int GPS_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] -const int GPS_SUBFRAME_MS = 6000; //!< Subframe duration [seconds] -const int GPS_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] +const int32_t GPS_CA_PREAMBLE_DURATION_MS = 160; +const int32_t GPS_CA_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] +const int32_t GPS_CA_TELEMETRY_SYMBOLS_PER_BIT = 20; +const int32_t GPS_CA_TELEMETRY_RATE_SYMBOLS_SECOND = GPS_CA_TELEMETRY_RATE_BITS_SECOND * GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] +const int32_t GPS_WORD_LENGTH = 4; //!< CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes +const int32_t GPS_SUBFRAME_LENGTH = 40; //!< GPS_WORD_LENGTH x 10 = 40 bytes +const int32_t GPS_SUBFRAME_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] +const int32_t GPS_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] +const int32_t GPS_SUBFRAME_MS = 6000; //!< Subframe duration [seconds] +const int32_t GPS_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] // GPS NAVIGATION MESSAGE STRUCTURE // NAVIGATION MESSAGE FIELDS POSITIONS (from IS-GPS-200E Appendix II) // SUBFRAME 1-5 (TLM and HOW) -const std::vector> TOW({{31, 17}}); -const std::vector> INTEGRITY_STATUS_FLAG({{23, 1}}); -const std::vector> ALERT_FLAG({{48, 1}}); -const std::vector> ANTI_SPOOFING_FLAG({{49, 1}}); -const std::vector> SUBFRAME_ID({{50, 3}}); +const std::vector> TOW({{31, 17}}); +const std::vector> INTEGRITY_STATUS_FLAG({{23, 1}}); +const std::vector> ALERT_FLAG({{48, 1}}); +const std::vector> ANTI_SPOOFING_FLAG({{49, 1}}); +const std::vector> SUBFRAME_ID({{50, 3}}); // SUBFRAME 1 -const std::vector> GPS_WEEK({{61, 10}}); -const std::vector> CA_OR_P_ON_L2({{71, 2}}); //* -const std::vector> SV_ACCURACY({{73, 4}}); -const std::vector> SV_HEALTH({{77, 6}}); -const std::vector> L2_P_DATA_FLAG({{91, 1}}); -const std::vector> T_GD({{197, 8}}); +const std::vector> GPS_WEEK({{61, 10}}); +const std::vector> CA_OR_P_ON_L2({{71, 2}}); //* +const std::vector> SV_ACCURACY({{73, 4}}); +const std::vector> SV_HEALTH({{77, 6}}); +const std::vector> L2_P_DATA_FLAG({{91, 1}}); +const std::vector> T_GD({{197, 8}}); const double T_GD_LSB = TWO_N31; -const std::vector> IODC({{83, 2}, {211, 8}}); -const std::vector> T_OC({{219, 16}}); -const double T_OC_LSB = TWO_P4; -const std::vector> A_F2({{241, 8}}); +const std::vector> IODC({{83, 2}, {211, 8}}); +const std::vector> T_OC({{219, 16}}); +const int32_t T_OC_LSB = static_cast(TWO_P4); +const std::vector> A_F2({{241, 8}}); const double A_F2_LSB = TWO_N55; -const std::vector> A_F1({{249, 16}}); +const std::vector> A_F1({{249, 16}}); const double A_F1_LSB = TWO_N43; -const std::vector> A_F0({{271, 22}}); +const std::vector> A_F0({{271, 22}}); const double A_F0_LSB = TWO_N31; // SUBFRAME 2 -const std::vector> IODE_SF2({{61, 8}}); -const std::vector> C_RS({{69, 16}}); +const std::vector> IODE_SF2({{61, 8}}); +const std::vector> C_RS({{69, 16}}); const double C_RS_LSB = TWO_N5; -const std::vector> DELTA_N({{91, 16}}); +const std::vector> DELTA_N({{91, 16}}); const double DELTA_N_LSB = PI_TWO_N43; -const std::vector> M_0({{107, 8}, {121, 24}}); +const std::vector> M_0({{107, 8}, {121, 24}}); const double M_0_LSB = PI_TWO_N31; -const std::vector> C_UC({{151, 16}}); +const std::vector> C_UC({{151, 16}}); const double C_UC_LSB = TWO_N29; -const std::vector> E({{167, 8}, {181, 24}}); +const std::vector> E({{167, 8}, {181, 24}}); const double E_LSB = TWO_N33; -const std::vector> C_US({{211, 16}}); +const std::vector> C_US({{211, 16}}); const double C_US_LSB = TWO_N29; -const std::vector> SQRT_A({{227, 8}, {241, 24}}); +const std::vector> SQRT_A({{227, 8}, {241, 24}}); const double SQRT_A_LSB = TWO_N19; -const std::vector> T_OE({{271, 16}}); -const double T_OE_LSB = TWO_P4; -const std::vector> FIT_INTERVAL_FLAG({{271, 1}}); -const std::vector> AODO({{272, 5}}); -const int AODO_LSB = 900; +const std::vector> T_OE({{271, 16}}); +const int32_t T_OE_LSB = static_cast(TWO_P4); +const std::vector> FIT_INTERVAL_FLAG({{271, 1}}); +const std::vector> AODO({{272, 5}}); +const int32_t AODO_LSB = 900; // SUBFRAME 3 -const std::vector> C_IC({{61, 16}}); +const std::vector> C_IC({{61, 16}}); const double C_IC_LSB = TWO_N29; -const std::vector> OMEGA_0({{77, 8}, {91, 24}}); +const std::vector> OMEGA_0({{77, 8}, {91, 24}}); const double OMEGA_0_LSB = PI_TWO_N31; -const std::vector> C_IS({{121, 16}}); +const std::vector> C_IS({{121, 16}}); const double C_IS_LSB = TWO_N29; -const std::vector> I_0({{137, 8}, {151, 24}}); +const std::vector> I_0({{137, 8}, {151, 24}}); const double I_0_LSB = PI_TWO_N31; -const std::vector> C_RC({{181, 16}}); +const std::vector> C_RC({{181, 16}}); const double C_RC_LSB = TWO_N5; -const std::vector> OMEGA({{197, 8}, {211, 24}}); +const std::vector> OMEGA({{197, 8}, {211, 24}}); const double OMEGA_LSB = PI_TWO_N31; -const std::vector> OMEGA_DOT({{241, 24}}); +const std::vector> OMEGA_DOT({{241, 24}}); const double OMEGA_DOT_LSB = PI_TWO_N43; -const std::vector> IODE_SF3({{271, 8}}); -const std::vector> I_DOT({{279, 14}}); +const std::vector> IODE_SF3({{271, 8}}); +const std::vector> I_DOT({{279, 14}}); const double I_DOT_LSB = PI_TWO_N43; // SUBFRAME 4-5 -const std::vector> SV_DATA_ID({{61, 2}}); -const std::vector> SV_PAGE({{63, 6}}); +const std::vector> SV_DATA_ID({{61, 2}}); +const std::vector> SV_PAGE({{63, 6}}); // SUBFRAME 4 //! \todo read all pages of subframe 4 // Page 18 - Ionospheric and UTC data -const std::vector> ALPHA_0({{69, 8}}); +const std::vector> ALPHA_0({{69, 8}}); const double ALPHA_0_LSB = TWO_N30; -const std::vector> ALPHA_1({{77, 8}}); +const std::vector> ALPHA_1({{77, 8}}); const double ALPHA_1_LSB = TWO_N27; -const std::vector> ALPHA_2({{91, 8}}); +const std::vector> ALPHA_2({{91, 8}}); const double ALPHA_2_LSB = TWO_N24; -const std::vector> ALPHA_3({{99, 8}}); +const std::vector> ALPHA_3({{99, 8}}); const double ALPHA_3_LSB = TWO_N24; -const std::vector> BETA_0({{107, 8}}); +const std::vector> BETA_0({{107, 8}}); const double BETA_0_LSB = TWO_P11; -const std::vector> BETA_1({{121, 8}}); +const std::vector> BETA_1({{121, 8}}); const double BETA_1_LSB = TWO_P14; -const std::vector> BETA_2({{129, 8}}); +const std::vector> BETA_2({{129, 8}}); const double BETA_2_LSB = TWO_P16; -const std::vector> BETA_3({{137, 8}}); +const std::vector> BETA_3({{137, 8}}); const double BETA_3_LSB = TWO_P16; -const std::vector> A_1({{151, 24}}); +const std::vector> A_1({{151, 24}}); const double A_1_LSB = TWO_N50; -const std::vector> A_0({{181, 24}, {211, 8}}); +const std::vector> A_0({{181, 24}, {211, 8}}); const double A_0_LSB = TWO_N30; -const std::vector> T_OT({{219, 8}}); +const std::vector> T_OT({{219, 8}}); const double T_OT_LSB = TWO_P12; -const std::vector> WN_T({{227, 8}}); +const std::vector> WN_T({{227, 8}}); const double WN_T_LSB = 1; -const std::vector> DELTAT_LS({{241, 8}}); +const std::vector> DELTAT_LS({{241, 8}}); const double DELTAT_LS_LSB = 1; -const std::vector> WN_LSF({{249, 8}}); +const std::vector> WN_LSF({{249, 8}}); const double WN_LSF_LSB = 1; -const std::vector> DN({{257, 8}}); +const std::vector> DN({{257, 8}}); const double DN_LSB = 1; -const std::vector> DELTAT_LSF({{271, 8}}); +const std::vector> DELTAT_LSF({{271, 8}}); const double DELTAT_LSF_LSB = 1; // Page 25 - Antispoofing, SV config and SV health (PRN 25 -32) -const std::vector> HEALTH_SV25({{229, 6}}); -const std::vector> HEALTH_SV26({{241, 6}}); -const std::vector> HEALTH_SV27({{247, 6}}); -const std::vector> HEALTH_SV28({{253, 6}}); -const std::vector> HEALTH_SV29({{259, 6}}); -const std::vector> HEALTH_SV30({{271, 6}}); -const std::vector> HEALTH_SV31({{277, 6}}); -const std::vector> HEALTH_SV32({{283, 6}}); +const std::vector> HEALTH_SV25({{229, 6}}); +const std::vector> HEALTH_SV26({{241, 6}}); +const std::vector> HEALTH_SV27({{247, 6}}); +const std::vector> HEALTH_SV28({{253, 6}}); +const std::vector> HEALTH_SV29({{259, 6}}); +const std::vector> HEALTH_SV30({{271, 6}}); +const std::vector> HEALTH_SV31({{277, 6}}); +const std::vector> HEALTH_SV32({{283, 6}}); // SUBFRAME 5 //! \todo read all pages of subframe 5 // page 25 - Health (PRN 1 - 24) -const std::vector> T_OA({{69, 8}}); -const double T_OA_LSB = TWO_P12; -const std::vector> WN_A({{77, 8}}); -const std::vector> HEALTH_SV1({{91, 6}}); -const std::vector> HEALTH_SV2({{97, 6}}); -const std::vector> HEALTH_SV3({{103, 6}}); -const std::vector> HEALTH_SV4({{109, 6}}); -const std::vector> HEALTH_SV5({{121, 6}}); -const std::vector> HEALTH_SV6({{127, 6}}); -const std::vector> HEALTH_SV7({{133, 6}}); -const std::vector> HEALTH_SV8({{139, 6}}); -const std::vector> HEALTH_SV9({{151, 6}}); -const std::vector> HEALTH_SV10({{157, 6}}); -const std::vector> HEALTH_SV11({{163, 6}}); -const std::vector> HEALTH_SV12({{169, 6}}); -const std::vector> HEALTH_SV13({{181, 6}}); -const std::vector> HEALTH_SV14({{187, 6}}); -const std::vector> HEALTH_SV15({{193, 6}}); -const std::vector> HEALTH_SV16({{199, 6}}); -const std::vector> HEALTH_SV17({{211, 6}}); -const std::vector> HEALTH_SV18({{217, 6}}); -const std::vector> HEALTH_SV19({{223, 6}}); -const std::vector> HEALTH_SV20({{229, 6}}); -const std::vector> HEALTH_SV21({{241, 6}}); -const std::vector> HEALTH_SV22({{247, 6}}); -const std::vector> HEALTH_SV23({{253, 6}}); -const std::vector> HEALTH_SV24({{259, 6}}); +const std::vector> T_OA({{69, 8}}); +const int32_t T_OA_LSB = TWO_P12; +const std::vector> WN_A({{77, 8}}); +const std::vector> HEALTH_SV1({{91, 6}}); +const std::vector> HEALTH_SV2({{97, 6}}); +const std::vector> HEALTH_SV3({{103, 6}}); +const std::vector> HEALTH_SV4({{109, 6}}); +const std::vector> HEALTH_SV5({{121, 6}}); +const std::vector> HEALTH_SV6({{127, 6}}); +const std::vector> HEALTH_SV7({{133, 6}}); +const std::vector> HEALTH_SV8({{139, 6}}); +const std::vector> HEALTH_SV9({{151, 6}}); +const std::vector> HEALTH_SV10({{157, 6}}); +const std::vector> HEALTH_SV11({{163, 6}}); +const std::vector> HEALTH_SV12({{169, 6}}); +const std::vector> HEALTH_SV13({{181, 6}}); +const std::vector> HEALTH_SV14({{187, 6}}); +const std::vector> HEALTH_SV15({{193, 6}}); +const std::vector> HEALTH_SV16({{199, 6}}); +const std::vector> HEALTH_SV17({{211, 6}}); +const std::vector> HEALTH_SV18({{217, 6}}); +const std::vector> HEALTH_SV19({{223, 6}}); +const std::vector> HEALTH_SV20({{229, 6}}); +const std::vector> HEALTH_SV21({{241, 6}}); +const std::vector> HEALTH_SV22({{247, 6}}); +const std::vector> HEALTH_SV23({{253, 6}}); +const std::vector> HEALTH_SV24({{259, 6}}); #endif /* GNSS_SDR_GPS_L1_CA_H_ */ diff --git a/src/core/system_parameters/GPS_L2C.h b/src/core/system_parameters/GPS_L2C.h index 67a467192..95542e2e2 100644 --- a/src/core/system_parameters/GPS_L2C.h +++ b/src/core/system_parameters/GPS_L2C.h @@ -33,36 +33,39 @@ #define GNSS_SDR_GPS_L2C_H_ -#include "gnss_frequencies.h" #include "GPS_CNAV.h" #include "MATH_CONSTANTS.h" +#include "gnss_frequencies.h" #include -#include #include // std::pair +#include // Physical constants -const double GPS_L2_C_m_s = 299792458.0; //!< The speed of light, [m/s] -const double GPS_L2_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double GPS_L2_C_M_S = 299792458.0; //!< The speed of light, [m/s] +const double GPS_L2_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] const double GPS_L2_PI = 3.1415926535898; //!< Pi as defined in IS-GPS-200E const double GPS_L2_TWO_PI = 6.283185307179586; //!< 2Pi as defined in IS-GPS-200E const double GPS_L2_OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Earth rotation rate, [rad/s] const double GPS_L2_GM = 3.986005e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] const double GPS_L2_F = -4.442807633e-10; //!< Constant, [s/(m)^(1/2)] - // carrier and code frequencies const double GPS_L2_FREQ_HZ = FREQ2; //!< L2 [Hz] -const double GPS_L2_M_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 M code rate [chips/s] -const int GPS_L2_M_CODE_LENGTH_CHIPS = 10230; //!< GPS L2 M code length [chips] -const double GPS_L2_M_PERIOD = 0.02; //!< GPS L2 M code period [seconds] +const double GPS_L2_M_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 M code rate [chips/s] +const int32_t GPS_L2_M_CODE_LENGTH_CHIPS = 10230; //!< GPS L2 M code length [chips] +const double GPS_L2_M_PERIOD = 0.02; //!< GPS L2 M code period [seconds] -const double GPS_L2_L_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 L code rate [chips/s] -const int GPS_L2_L_CODE_LENGTH_CHIPS = 767250; //!< GPS L2 L code length [chips] -const double GPS_L2_L_PERIOD = 1.5; //!< GPS L2 L code period [seconds] +const double GPS_L2_L_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 L code rate [chips/s] +const int32_t GPS_L2_L_CODE_LENGTH_CHIPS = 767250; //!< GPS L2 L code length [chips] +const double GPS_L2_L_PERIOD = 1.5; //!< GPS L2 L code period [seconds] + +const int32_t GPS_L2C_HISTORY_DEEP = 5; + +//optimum parameters +const uint32_t GPS_L2C_OPT_ACQ_FS_HZ = 1000000; //!< Sampling frequncy that maximizes the acquisition SNR while using a non-multiple of chip rate -const int GPS_L2C_HISTORY_DEEP = 5; const int32_t GPS_L2C_M_INIT_REG[115] = {0742417664, 0756014035, 0002747144, 0066265724, // 1:4 @@ -79,9 +82,9 @@ const int32_t GPS_L2C_M_INIT_REG[115] = 0047457275, 0266333164, 0713167356, 0060546335, 0355173035, 0617201036, 0157465571, 0767360553, 0023127030, 0431343777, 0747317317, 0045706125, - 0002744276, 0060036467, 0217744147, 0603340174, //57:60 - 0326616775, 0063240065, 0111460621, //61:63 - 0604055104, 0157065232, 0013305707, 0603552017, //159:162 + 0002744276, 0060036467, 0217744147, 0603340174, // 57:60 + 0326616775, 0063240065, 0111460621, // 61:63 + 0604055104, 0157065232, 0013305707, 0603552017, // 159:162 0230461355, 0603653437, 0652346475, 0743107103, 0401521277, 0167335110, 0014013575, 0362051132, 0617753265, 0216363634, 0755561123, 0365304033, @@ -95,10 +98,10 @@ const int32_t GPS_L2C_M_INIT_REG[115] = 0706202440, 0705056276, 0020373522, 0746013617, 0132720621, 0434015513, 0566721727, 0140633660}; -const int GPS_L2_CNAV_DATA_PAGE_BITS = 300; //!< GPS L2 CNAV page length, including preamble and CRC [bits] -const int GPS_L2_SYMBOLS_PER_BIT = 2; -const int GPS_L2_SAMPLES_PER_SYMBOL = 1; -const int GPS_L2_CNAV_DATA_PAGE_SYMBOLS = 600; -const int GPS_L2_CNAV_DATA_PAGE_DURATION_S = 12; +const int32_t GPS_L2_CNAV_DATA_PAGE_BITS = 300; //!< GPS L2 CNAV page length, including preamble and CRC [bits] +const int32_t GPS_L2_SYMBOLS_PER_BIT = 2; +const int32_t GPS_L2_SAMPLES_PER_SYMBOL = 1; +const int32_t GPS_L2_CNAV_DATA_PAGE_SYMBOLS = 600; +const int32_t GPS_L2_CNAV_DATA_PAGE_DURATION_S = 12; #endif /* GNSS_SDR_GPS_L2C_H_ */ diff --git a/src/core/system_parameters/GPS_L5.h b/src/core/system_parameters/GPS_L5.h index 5a919820d..d2fa25db3 100644 --- a/src/core/system_parameters/GPS_L5.h +++ b/src/core/system_parameters/GPS_L5.h @@ -32,38 +32,42 @@ #ifndef GNSS_SDR_GPS_L5_H_ #define GNSS_SDR_GPS_L5_H_ -#include "gnss_frequencies.h" #include "GPS_CNAV.h" #include "MATH_CONSTANTS.h" +#include "gnss_frequencies.h" #include #include // Physical constants -const double GPS_L5_C_m_s = 299792458.0; //!< The speed of light, [m/s] -const double GPS_L5_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double GPS_L5_C_M_S = 299792458.0; //!< The speed of light, [m/s] +const double GPS_L5_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] const double GPS_L5_PI = 3.1415926535898; //!< Pi as defined in IS-GPS-200E const double GPS_L5_TWO_PI = 6.283185307179586; //!< 2Pi as defined in IS-GPS-200E const double GPS_L5_OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Earth rotation rate, [rad/s] const double GPS_L5_GM = 3.986005e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] const double GPS_L5_F = -4.442807633e-10; //!< Constant, [s/(m)^(1/2)] - // carrier and code frequencies const double GPS_L5_FREQ_HZ = FREQ5; //!< L5 [Hz] -const double GPS_L5i_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] -const int GPS_L5i_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] -const double GPS_L5i_PERIOD = 0.001; //!< GPS L5 code period [seconds] -const double GPS_L5i_SYMBOL_PERIOD = 0.01; //!< GPS L5 symbol period [seconds] +const double GPS_L5I_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] +const int32_t GPS_L5I_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] +const double GPS_L5I_PERIOD = 0.001; //!< GPS L5 code period [seconds] +const int32_t GPS_L5I_PERIOD_MS = 1; //!< GPS L5 code period [ms] +const double GPS_L5I_SYMBOL_PERIOD = 0.01; //!< GPS L5 symbol period [seconds] +const int32_t GPS_L5I_SYMBOL_PERIOD_MS = 10; //!< GPS L5 symbol period [ms] -const double GPS_L5q_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] -const int GPS_L5q_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] -const double GPS_L5q_PERIOD = 0.001; //!< GPS L5 code period [seconds] +const double GPS_L5Q_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] +const int32_t GPS_L5Q_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] +const double GPS_L5Q_PERIOD = 0.001; //!< GPS L5 code period [seconds] -const int GPS_L5_HISTORY_DEEP = 5; +const int32_t GPS_L5_HISTORY_DEEP = 5; -const int32_t GPS_L5i_INIT_REG[210] = +//optimum parameters +const uint32_t GPS_L5_OPT_ACQ_FS_HZ = 10000000; //!< Sampling frequncy that maximizes the acquisition SNR while using a non-multiple of chip rate + +const int32_t GPS_L5I_INIT_REG[210] = {266, 365, 804, 1138, 1509, 1559, 1756, 2084, 2170, 2303, 2527, 2687, @@ -120,7 +124,7 @@ const int32_t GPS_L5i_INIT_REG[210] = 5950, 5521, 1515}; -const int32_t GPS_L5q_INIT_REG[210] = +const int32_t GPS_L5Q_INIT_REG[210] = { 1701, 323, 5292, 2020, 5429, 7136, 1041, 5947, @@ -177,16 +181,16 @@ const int32_t GPS_L5q_INIT_REG[210] = 2765, 37, 1943, 7977, 2512, 4451, 4071}; -const int GPS_L5_CNAV_DATA_PAGE_BITS = 300; //!< GPS L5 CNAV page length, including preamble and CRC [bits] -const int GPS_L5_SYMBOLS_PER_BIT = 2; -const int GPS_L5_SAMPLES_PER_SYMBOL = 10; -const int GPS_L5_CNAV_DATA_PAGE_SYMBOLS = 600; -const int GPS_L5_CNAV_DATA_PAGE_DURATION_S = 6; -const int GPS_L5i_NH_CODE_LENGTH = 10; -const int GPS_L5i_NH_CODE[10] = {0, 0, 0, 0, 1, 1, 0, 1, 0, 1}; -const std::string GPS_L5i_NH_CODE_STR = "0000110101"; -const int GPS_L5q_NH_CODE_LENGTH = 20; -const int GPS_L5q_NH_CODE[20] = {0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}; -const std::string GPS_L5q_NH_CODE_STR = "00000100110101001110"; +const int32_t GPS_L5_CNAV_DATA_PAGE_BITS = 300; //!< GPS L5 CNAV page length, including preamble and CRC [bits] +const int32_t GPS_L5_SYMBOLS_PER_BIT = 2; +const int32_t GPS_L5_SAMPLES_PER_SYMBOL = 10; +const int32_t GPS_L5_CNAV_DATA_PAGE_SYMBOLS = 600; +const int32_t GPS_L5_CNAV_DATA_PAGE_DURATION_S = 6; +const int32_t GPS_L5I_NH_CODE_LENGTH = 10; +const int32_t GPS_L5I_NH_CODE[10] = {0, 0, 0, 0, 1, 1, 0, 1, 0, 1}; +const std::string GPS_L5I_NH_CODE_STR = "0000110101"; +const int32_t GPS_L5Q_NH_CODE_LENGTH = 20; +const int32_t GPS_L5Q_NH_CODE[20] = {0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}; +const std::string GPS_L5Q_NH_CODE_STR = "00000100110101001110"; #endif /* GNSS_SDR_GPS_L5_H_ */ diff --git a/src/core/system_parameters/Galileo_E1.h b/src/core/system_parameters/Galileo_E1.h index 951612e02..ee5fc3896 100644 --- a/src/core/system_parameters/Galileo_E1.h +++ b/src/core/system_parameters/Galileo_E1.h @@ -33,11 +33,12 @@ #ifndef GNSS_SDR_GALILEO_E1_H_ #define GNSS_SDR_GALILEO_E1_H_ -#include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" +#include "gnss_frequencies.h" +#include #include -#include #include // std::pair +#include // Physical constants @@ -45,261 +46,263 @@ const double GALILEO_PI = 3.1415926535898; //!< Pi as defined in G const double GALILEO_TWO_PI = 6.283185307179600; //!< 2*Pi as defined in GALILEO ICD const double GALILEO_GM = 3.986004418e14; //!< Geocentric gravitational constant[m^3/s^2] const double GALILEO_OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Mean angular velocity of the Earth [rad/s] -const double GALILEO_C_m_s = 299792458.0; //!< The speed of light, [m/s] -const double GALILEO_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double GALILEO_C_M_S = 299792458.0; //!< The speed of light, [m/s] +const double GALILEO_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] const double GALILEO_F = -4.442807309e-10; //!< Constant, [s/(m)^(1/2)] // carrier and code frequencies -const double Galileo_E1_FREQ_HZ = FREQ1; //!< Galileo E1 carrier frequency [Hz] -const double Galileo_E1_CODE_CHIP_RATE_HZ = 1.023e6; //!< Galileo E1 code rate [chips/s] -const double Galileo_E1_CODE_PERIOD = 0.004; //!< Galileo E1 code period [s] -const int Galileo_E1_CODE_PERIOD_MS = 4; //!< Galileo E1 code period [ms] -const double Galileo_E1_SUB_CARRIER_A_RATE_HZ = 1.023e6; //!< Galileo E1 sub-carrier 'a' rate [Hz] -const double Galileo_E1_SUB_CARRIER_B_RATE_HZ = 6.138e6; //!< Galileo E1 sub-carrier 'b' rate [Hz] -const double Galileo_E1_B_CODE_LENGTH_CHIPS = 4092.0; //!< Galileo E1-B code length [chips] -const double Galileo_E1_B_SYMBOL_RATE_BPS = 250.0; //!< Galileo E1-B symbol rate [bits/second] -const int Galileo_E1_C_SECONDARY_CODE_LENGTH = 25; //!< Galileo E1-C secondary code length [chips] -const int Galileo_E1_NUMBER_OF_CODES = 50; +const double GALILEO_E1_FREQ_HZ = FREQ1; //!< Galileo E1 carrier frequency [Hz] +const double GALILEO_E1_CODE_CHIP_RATE_HZ = 1.023e6; //!< Galileo E1 code rate [chips/s] +const double GALILEO_E1_CODE_PERIOD = 0.004; //!< Galileo E1 code period [s] +const int32_t GALILEO_E1_CODE_PERIOD_MS = 4; //!< Galileo E1 code period [ms] +const double GALILEO_E1_SUB_CARRIER_A_RATE_HZ = 1.023e6; //!< Galileo E1 sub-carrier 'a' rate [Hz] +const double GALILEO_E1_SUB_CARRIER_B_RATE_HZ = 6.138e6; //!< Galileo E1 sub-carrier 'b' rate [Hz] +const double GALILEO_E1_B_CODE_LENGTH_CHIPS = 4092.0; //!< Galileo E1-B code length [chips] +const double GALILEO_E1_B_SYMBOL_RATE_BPS = 250.0; //!< Galileo E1-B symbol rate [bits/second] +const int32_t GALILEO_E1_B_SAMPLES_PER_SYMBOL = 1; //!< (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS) / Galileo_E1_B_SYMBOL_RATE_BPS +const int32_t GALILEO_E1_C_SECONDARY_CODE_LENGTH = 25; //!< Galileo E1-C secondary code length [chips] +const int32_t GALILEO_E1_NUMBER_OF_CODES = 50; -const double GALILEO_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) + +//optimum parameters +const uint32_t GALILEO_E1_OPT_ACQ_FS_HZ = 2000000; //!< Sampling frequncy that maximizes the acquisition SNR while using a non-multiple of chip rate + + +const double GALILEO_STARTOFFSET_MS = 68.802; //[ms] Initial sign. travel time (this cannot go here) // OBSERVABLE HISTORY DEEP FOR INTERPOLATION -const int GALILEO_E1_HISTORY_DEEP = 100; +const int32_t GALILEO_E1_HISTORY_DEEP = 100; // Galileo INAV Telemetry structure -#define GALILEO_INAV_PREAMBLE \ - { \ - 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 \ - } +const std::string GALILEO_INAV_PREAMBLE = {"0101100000"}; -const int GALILEO_INAV_PREAMBLE_LENGTH_BITS = 10; -const double GALILEO_INAV_PAGE_PART_WITH_PREABLE_SECONDS = 2.0 + GALILEO_INAV_PREAMBLE_LENGTH_BITS * Galileo_E1_CODE_PERIOD; -const int GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS = 250; -const int GALILEO_INAV_PAGE_PART_SYMBOLS = 250; //!< Each Galileo INAV pages are composed of two parts (even and odd) each of 250 symbols, including preamble. See Galileo ICD 4.3.2 -const int GALILEO_INAV_PAGE_SYMBOLS = 500; //!< The complete Galileo INAV page length -const int GALILEO_INAV_PAGE_PART_SECONDS = 1; // a page part last 1 sec -const int GALILEO_INAV_PAGE_SECONDS = 2; // a full page last 2 sec -const int GALILEO_INAV_INTERLEAVER_ROWS = 8; -const int GALILEO_INAV_INTERLEAVER_COLS = 30; -const int GALILEO_TELEMETRY_RATE_BITS_SECOND = 250; //bps -const int GALILEO_PAGE_TYPE_BITS = 6; -const int GALILEO_DATA_JK_BITS = 128; -const int GALILEO_DATA_FRAME_BITS = 196; -const int GALILEO_DATA_FRAME_BYTES = 25; -const double GALILEO_E1_CODE_PERIOD = 0.004; +const int32_t GALILEO_INAV_PREAMBLE_LENGTH_BITS = 10; +const double GALILEO_INAV_PAGE_PART_WITH_PREABLE_SECONDS = 2.0 + GALILEO_INAV_PREAMBLE_LENGTH_BITS * GALILEO_E1_CODE_PERIOD; +const int32_t GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS = 250; +const int32_t GALILEO_INAV_PAGE_PART_SYMBOLS = 250; //!< Each Galileo INAV pages are composed of two parts (even and odd) each of 250 symbols, including preamble. See Galileo ICD 4.3.2 +const int32_t GALILEO_INAV_PAGE_SYMBOLS = 500; //!< The complete Galileo INAV page length +const int32_t GALILEO_INAV_PAGE_PART_SECONDS = 1; // a page part last 1 sec +const int32_t GALILEO_INAV_PAGE_PART_MS = 1000; // a page part last 1 sec +const int32_t GALILEO_INAV_PAGE_SECONDS = 2; // a full page last 2 sec +const int32_t GALILEO_INAV_INTERLEAVER_ROWS = 8; +const int32_t GALILEO_INAV_INTERLEAVER_COLS = 30; +const int32_t GALILEO_TELEMETRY_RATE_BITS_SECOND = 250; //bps +const int32_t GALILEO_PAGE_TYPE_BITS = 6; +const int32_t GALILEO_DATA_JK_BITS = 128; +const int32_t GALILEO_DATA_FRAME_BITS = 196; +const int32_t GALILEO_DATA_FRAME_BYTES = 25; -const std::vector> type({{1, 6}}); -const std::vector> PAGE_TYPE_bit({{1, 6}}); -; +const std::vector> TYPE({{1, 6}}); +const std::vector> PAGE_TYPE_BIT({{1, 6}}); /*Page 1 - Word type 1: Ephemeris (1/4)*/ -const std::vector> IOD_nav_1_bit({{7, 10}}); -const std::vector> T0E_1_bit({{17, 14}}); -const double t0e_1_LSB = 60; -const std::vector> M0_1_bit({{31, 32}}); +const std::vector> IOD_NAV_1_BIT({{7, 10}}); +const std::vector> T0_E_1_BIT({{17, 14}}); +const int32_t T0E_1_LSB = 60; +const std::vector> M0_1_BIT({{31, 32}}); const double M0_1_LSB = PI_TWO_N31; -const std::vector> e_1_bit({{63, 32}}); -const double e_1_LSB = TWO_N33; -const std::vector> A_1_bit({{95, 32}}); -const double A_1_LSB_gal = TWO_N19; +const std::vector> E_1_BIT({{63, 32}}); +const double E_1_LSB = TWO_N33; +const std::vector> A_1_BIT({{95, 32}}); +const double A_1_LSB_GAL = TWO_N19; //last two bits are reserved /*Page 2 - Word type 2: Ephemeris (2/4)*/ -const std::vector> IOD_nav_2_bit({{7, 10}}); -const std::vector> OMEGA_0_2_bit({{17, 32}}); +const std::vector> IOD_NAV_2_BIT({{7, 10}}); +const std::vector> OMEGA_0_2_BIT({{17, 32}}); const double OMEGA_0_2_LSB = PI_TWO_N31; -const std::vector> i_0_2_bit({{49, 32}}); -const double i_0_2_LSB = PI_TWO_N31; -const std::vector> omega_2_bit({{81, 32}}); -const double omega_2_LSB = PI_TWO_N31; -const std::vector> iDot_2_bit({{113, 14}}); -const double iDot_2_LSB = PI_TWO_N43; +const std::vector> I_0_2_BIT({{49, 32}}); +const double I_0_2_LSB = PI_TWO_N31; +const std::vector> OMEGA_2_BIT({{81, 32}}); +const double OMEGA_2_LSB = PI_TWO_N31; +const std::vector> I_DOT_2_BIT({{113, 14}}); +const double I_DOT_2_LSB = PI_TWO_N43; //last two bits are reserved /*Word type 3: Ephemeris (3/4) and SISA*/ -const std::vector> IOD_nav_3_bit({{7, 10}}); -const std::vector> OMEGA_dot_3_bit({{17, 24}}); -const double OMEGA_dot_3_LSB = PI_TWO_N43; -const std::vector> delta_n_3_bit({{41, 16}}); -const double delta_n_3_LSB = PI_TWO_N43; -const std::vector> C_uc_3_bit({{57, 16}}); -const double C_uc_3_LSB = TWO_N29; -const std::vector> C_us_3_bit({{73, 16}}); -const double C_us_3_LSB = TWO_N29; -const std::vector> C_rc_3_bit({{89, 16}}); -const double C_rc_3_LSB = TWO_N5; -const std::vector> C_rs_3_bit({{105, 16}}); -const double C_rs_3_LSB = TWO_N5; -const std::vector> SISA_3_bit({{121, 8}}); +const std::vector> IOD_NAV_3_BIT({{7, 10}}); +const std::vector> OMEGA_DOT_3_BIT({{17, 24}}); +const double OMEGA_DOT_3_LSB = PI_TWO_N43; +const std::vector> DELTA_N_3_BIT({{41, 16}}); +const double DELTA_N_3_LSB = PI_TWO_N43; +const std::vector> C_UC_3_BIT({{57, 16}}); +const double C_UC_3_LSB = TWO_N29; +const std::vector> C_US_3_BIT({{73, 16}}); +const double C_US_3_LSB = TWO_N29; +const std::vector> C_RC_3_BIT({{89, 16}}); +const double C_RC_3_LSB = TWO_N5; +const std::vector> C_RS_3_BIT({{105, 16}}); +const double C_RS_3_LSB = TWO_N5; +const std::vector> SISA_3_BIT({{121, 8}}); /*Word type 4: Ephemeris (4/4) and Clock correction parameters*/ -const std::vector> IOD_nav_4_bit({{7, 10}}); -const std::vector> SV_ID_PRN_4_bit({{17, 6}}); -const std::vector> C_ic_4_bit({{23, 16}}); -const double C_ic_4_LSB = TWO_N29; -const std::vector> C_is_4_bit({{39, 16}}); -const double C_is_4_LSB = TWO_N29; -const std::vector> t0c_4_bit({{55, 14}}); // -const double t0c_4_LSB = 60; -const std::vector> af0_4_bit({{69, 31}}); // -const double af0_4_LSB = TWO_N34; -const std::vector> af1_4_bit({{100, 21}}); // -const double af1_4_LSB = TWO_N46; -const std::vector> af2_4_bit({{121, 6}}); -const double af2_4_LSB = TWO_N59; -const std::vector> spare_4_bit({{127, 2}}); +const std::vector> IOD_NAV_4_BIT({{7, 10}}); +const std::vector> SV_ID_PRN_4_BIT({{17, 6}}); +const std::vector> C_IC_4_BIT({{23, 16}}); +const double C_IC_4_LSB = TWO_N29; +const std::vector> C_IS_4_BIT({{39, 16}}); +const double C_IS_4_LSB = TWO_N29; +const std::vector> T0C_4_BIT({{55, 14}}); // +const int32_t T0C_4_LSB = 60; +const std::vector> AF0_4_BIT({{69, 31}}); // +const double AF0_4_LSB = TWO_N34; +const std::vector> AF1_4_BIT({{100, 21}}); // +const double AF1_4_LSB = TWO_N46; +const std::vector> AF2_4_BIT({{121, 6}}); +const double AF2_4_LSB = TWO_N59; +const std::vector> SPARE_4_BIT({{127, 2}}); //last two bits are reserved /*Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST*/ /*Ionospheric correction*/ /*Az*/ -const std::vector> ai0_5_bit({{7, 11}}); // -const double ai0_5_LSB = TWO_N2; -const std::vector> ai1_5_bit({{18, 11}}); // -const double ai1_5_LSB = TWO_N8; -const std::vector> ai2_5_bit({{29, 14}}); // -const double ai2_5_LSB = TWO_N15; +const std::vector> AI0_5_BIT({{7, 11}}); // +const double AI0_5_LSB = TWO_N2; +const std::vector> AI1_5_BIT({{18, 11}}); // +const double AI1_5_LSB = TWO_N8; +const std::vector> AI2_5_BIT({{29, 14}}); // +const double AI2_5_LSB = TWO_N15; /*Ionospheric disturbance flag*/ -const std::vector> Region1_5_bit({{43, 1}}); // -const std::vector> Region2_5_bit({{44, 1}}); // -const std::vector> Region3_5_bit({{45, 1}}); // -const std::vector> Region4_5_bit({{46, 1}}); // -const std::vector> Region5_5_bit({{47, 1}}); // -const std::vector> BGD_E1E5a_5_bit({{48, 10}}); // -const double BGD_E1E5a_5_LSB = TWO_N32; -const std::vector> BGD_E1E5b_5_bit({{58, 10}}); // -const double BGD_E1E5b_5_LSB = TWO_N32; -const std::vector> E5b_HS_5_bit({{68, 2}}); // -const std::vector> E1B_HS_5_bit({{70, 2}}); // -const std::vector> E5b_DVS_5_bit({{72, 1}}); // -const std::vector> E1B_DVS_5_bit({{73, 1}}); // +const std::vector> REGION1_5_BIT({{43, 1}}); // +const std::vector> REGION2_5_BIT({{44, 1}}); // +const std::vector> REGION3_5_BIT({{45, 1}}); // +const std::vector> REGION4_5_BIT({{46, 1}}); // +const std::vector> REGION5_5_BIT({{47, 1}}); // +const std::vector> BGD_E1_E5A_5_BIT({{48, 10}}); // +const double BGD_E1_E5A_5_LSB = TWO_N32; +const std::vector> BGD_E1_E5B_5_BIT({{58, 10}}); // +const double BGD_E1_E5B_5_LSB = TWO_N32; +const std::vector> E5B_HS_5_BIT({{68, 2}}); // +const std::vector> E1_B_HS_5_BIT({{70, 2}}); // +const std::vector> E5B_DVS_5_BIT({{72, 1}}); // +const std::vector> E1_B_DVS_5_BIT({{73, 1}}); // /*GST*/ -const std::vector> WN_5_bit({{74, 12}}); -const std::vector> TOW_5_bit({{86, 20}}); -const std::vector> spare_5_bit({{106, 23}}); +const std::vector> WN_5_BIT({{74, 12}}); +const std::vector> TOW_5_BIT({{86, 20}}); +const std::vector> SPARE_5_BIT({{106, 23}}); /* Page 6 */ -const std::vector> A0_6_bit({{7, 32}}); +const std::vector> A0_6_BIT({{7, 32}}); const double A0_6_LSB = TWO_N30; -const std::vector> A1_6_bit({{39, 24}}); +const std::vector> A1_6_BIT({{39, 24}}); const double A1_6_LSB = TWO_N50; -const std::vector> Delta_tLS_6_bit({{63, 8}}); -const std::vector> t0t_6_bit({{71, 8}}); -const double t0t_6_LSB = 3600; -const std::vector> WNot_6_bit({{79, 8}}); -const std::vector> WN_LSF_6_bit({{87, 8}}); -const std::vector> DN_6_bit({{95, 3}}); -const std::vector> Delta_tLSF_6_bit({{98, 8}}); -const std::vector> TOW_6_bit({{106, 20}}); +const std::vector> DELTA_T_LS_6_BIT({{63, 8}}); +const std::vector> T0T_6_BIT({{71, 8}}); +const int32_t T0T_6_LSB = 3600; +const std::vector> W_NOT_6_BIT({{79, 8}}); +const std::vector> WN_LSF_6_BIT({{87, 8}}); +const std::vector> DN_6_BIT({{95, 3}}); +const std::vector> DELTA_T_LSF_6_BIT({{98, 8}}); +const std::vector> TOW_6_BIT({{106, 20}}); /* Page 7 */ -const std::vector> IOD_a_7_bit({{7, 4}}); -const std::vector> WN_a_7_bit({{11, 2}}); -const std::vector> t0a_7_bit({{13, 10}}); -const double t0a_7_LSB = 600; -const std::vector> SVID1_7_bit({{23, 6}}); -const std::vector> DELTA_A_7_bit({{29, 13}}); +const std::vector> IOD_A_7_BIT({{7, 4}}); +const std::vector> WN_A_7_BIT({{11, 2}}); +const std::vector> T0A_7_BIT({{13, 10}}); +const int32_t T0A_7_LSB = 600; +const std::vector> SVI_D1_7_BIT({{23, 6}}); +const std::vector> DELTA_A_7_BIT({{29, 13}}); const double DELTA_A_7_LSB = TWO_N9; -const std::vector> e_7_bit({{42, 11}}); -const double e_7_LSB = TWO_N16; -const std::vector> omega_7_bit({{53, 16}}); -const double omega_7_LSB = TWO_N15; -const std::vector> delta_i_7_bit({{69, 11}}); -const double delta_i_7_LSB = TWO_N14; -const std::vector> Omega0_7_bit({{80, 16}}); -const double Omega0_7_LSB = TWO_N15; -const std::vector> Omega_dot_7_bit({{96, 11}}); -const double Omega_dot_7_LSB = TWO_N33; -const std::vector> M0_7_bit({{107, 16}}); +const std::vector> E_7_BIT({{42, 11}}); +const double E_7_LSB = TWO_N16; +const std::vector> OMEGA_7_BIT({{53, 16}}); +const double OMEGA_7_LSB = TWO_N15; +const std::vector> DELTA_I_7_BIT({{69, 11}}); +const double DELTA_I_7_LSB = TWO_N14; +const std::vector> OMEGA0_7_BIT({{80, 16}}); +const double OMEGA0_7_LSB = TWO_N15; +const std::vector> OMEGA_DOT_7_BIT({{96, 11}}); +const double OMEGA_DOT_7_LSB = TWO_N33; +const std::vector> M0_7_BIT({{107, 16}}); const double M0_7_LSB = TWO_N15; /* Page 8 */ -const std::vector> IOD_a_8_bit({{7, 4}}); -const std::vector> af0_8_bit({{11, 16}}); -const double af0_8_LSB = TWO_N19; -const std::vector> af1_8_bit({{27, 13}}); -const double af1_8_LSB = TWO_N38; -const std::vector> E5b_HS_8_bit({{40, 2}}); -const std::vector> E1B_HS_8_bit({{42, 2}}); -const std::vector> SVID2_8_bit({{44, 6}}); -const std::vector> DELTA_A_8_bit({{50, 13}}); +const std::vector> IOD_A_8_BIT({{7, 4}}); +const std::vector> AF0_8_BIT({{11, 16}}); +const double AF0_8_LSB = TWO_N19; +const std::vector> AF1_8_BIT({{27, 13}}); +const double AF1_8_LSB = TWO_N38; +const std::vector> E5B_HS_8_BIT({{40, 2}}); +const std::vector> E1_B_HS_8_BIT({{42, 2}}); +const std::vector> SVI_D2_8_BIT({{44, 6}}); +const std::vector> DELTA_A_8_BIT({{50, 13}}); const double DELTA_A_8_LSB = TWO_N9; -const std::vector> e_8_bit({{63, 11}}); -const double e_8_LSB = TWO_N16; -const std::vector> omega_8_bit({{74, 16}}); -const double omega_8_LSB = TWO_N15; -const std::vector> delta_i_8_bit({{90, 11}}); -const double delta_i_8_LSB = TWO_N14; -const std::vector> Omega0_8_bit({{101, 16}}); -const double Omega0_8_LSB = TWO_N15; -const std::vector> Omega_dot_8_bit({{117, 11}}); -const double Omega_dot_8_LSB = TWO_N33; +const std::vector> E_8_BIT({{63, 11}}); +const double E_8_LSB = TWO_N16; +const std::vector> OMEGA_8_BIT({{74, 16}}); +const double OMEGA_8_LSB = TWO_N15; +const std::vector> DELTA_I_8_BIT({{90, 11}}); +const double DELTA_I_8_LSB = TWO_N14; +const std::vector> OMEGA0_8_BIT({{101, 16}}); +const double OMEGA0_8_LSB = TWO_N15; +const std::vector> OMEGA_DOT_8_BIT({{117, 11}}); +const double OMEGA_DOT_8_LSB = TWO_N33; /* Page 9 */ -const std::vector> IOD_a_9_bit({{7, 4}}); -const std::vector> WN_a_9_bit({{11, 2}}); -const std::vector> t0a_9_bit({{13, 10}}); -const double t0a_9_LSB = 600; -const std::vector> M0_9_bit({{23, 16}}); +const std::vector> IOD_A_9_BIT({{7, 4}}); +const std::vector> WN_A_9_BIT({{11, 2}}); +const std::vector> T0A_9_BIT({{13, 10}}); +const int32_t T0A_9_LSB = 600; +const std::vector> M0_9_BIT({{23, 16}}); const double M0_9_LSB = TWO_N15; -const std::vector> af0_9_bit({{39, 16}}); -const double af0_9_LSB = TWO_N19; -const std::vector> af1_9_bit({{55, 13}}); -const double af1_9_LSB = TWO_N38; -const std::vector> E5b_HS_9_bit({{68, 2}}); -const std::vector> E1B_HS_9_bit({{70, 2}}); -const std::vector> SVID3_9_bit({{72, 6}}); -const std::vector> DELTA_A_9_bit({{78, 13}}); +const std::vector> AF0_9_BIT({{39, 16}}); +const double AF0_9_LSB = TWO_N19; +const std::vector> AF1_9_BIT({{55, 13}}); +const double AF1_9_LSB = TWO_N38; +const std::vector> E5B_HS_9_BIT({{68, 2}}); +const std::vector> E1_B_HS_9_BIT({{70, 2}}); +const std::vector> SVI_D3_9_BIT({{72, 6}}); +const std::vector> DELTA_A_9_BIT({{78, 13}}); const double DELTA_A_9_LSB = TWO_N9; -const std::vector> e_9_bit({{91, 11}}); -const double e_9_LSB = TWO_N16; -const std::vector> omega_9_bit({{102, 16}}); -const double omega_9_LSB = TWO_N15; -const std::vector> delta_i_9_bit({{118, 11}}); -const double delta_i_9_LSB = TWO_N14; +const std::vector> E_9_BIT({{91, 11}}); +const double E_9_LSB = TWO_N16; +const std::vector> OMEGA_9_BIT({{102, 16}}); +const double OMEGA_9_LSB = TWO_N15; +const std::vector> DELTA_I_9_BIT({{118, 11}}); +const double DELTA_I_9_LSB = TWO_N14; /* Page 10 */ -const std::vector> IOD_a_10_bit({{7, 4}}); -const std::vector> Omega0_10_bit({{11, 16}}); -const double Omega0_10_LSB = TWO_N15; -const std::vector> Omega_dot_10_bit({{27, 11}}); -const double Omega_dot_10_LSB = TWO_N33; -const std::vector> M0_10_bit({{38, 16}}); +const std::vector> IOD_A_10_BIT({{7, 4}}); +const std::vector> OMEGA0_10_BIT({{11, 16}}); +const double OMEGA0_10_LSB = TWO_N15; +const std::vector> OMEGA_DOT_10_BIT({{27, 11}}); +const double OMEGA_DOT_10_LSB = TWO_N33; +const std::vector> M0_10_BIT({{38, 16}}); const double M0_10_LSB = TWO_N15; -const std::vector> af0_10_bit({{54, 16}}); -const double af0_10_LSB = TWO_N19; -const std::vector> af1_10_bit({{70, 13}}); -const double af1_10_LSB = TWO_N38; -const std::vector> E5b_HS_10_bit({{83, 2}}); -const std::vector> E1B_HS_10_bit({{85, 2}}); -const std::vector> A_0G_10_bit({{87, 16}}); +const std::vector> AF0_10_BIT({{54, 16}}); +const double AF0_10_LSB = TWO_N19; +const std::vector> AF1_10_BIT({{70, 13}}); +const double AF1_10_LSB = TWO_N38; +const std::vector> E5B_HS_10_BIT({{83, 2}}); +const std::vector> E1_B_HS_10_BIT({{85, 2}}); +const std::vector> A_0_G_10_BIT({{87, 16}}); const double A_0G_10_LSB = TWO_N35; -const std::vector> A_1G_10_bit({{103, 12}}); +const std::vector> A_1_G_10_BIT({{103, 12}}); const double A_1G_10_LSB = TWO_N51; -const std::vector> t_0G_10_bit({{115, 8}}); -const double t_0G_10_LSB = 3600; -const std::vector> WN_0G_10_bit({{123, 6}}); +const std::vector> T_0_G_10_BIT({{115, 8}}); +const int32_t T_0_G_10_LSB = 3600; +const std::vector> WN_0_G_10_BIT({{123, 6}}); /* Page 0 */ -const std::vector> Time_0_bit({{7, 2}}); -const std::vector> WN_0_bit({{97, 12}}); -const std::vector> TOW_0_bit({{109, 20}}); +const std::vector> TIME_0_BIT({{7, 2}}); +const std::vector> WN_0_BIT({{97, 12}}); +const std::vector> TOW_0_BIT({{109, 20}}); // Galileo E1 primary codes -const std::string Galileo_E1_B_PRIMARY_CODE[Galileo_E1_NUMBER_OF_CODES] = { +const std::string GALILEO_E1_B_PRIMARY_CODE[GALILEO_E1_NUMBER_OF_CODES] = { "F5D710130573541B9DBD4FD9E9B20A0D59D144C54BC7935539D2E75810FB51E494093A0A19DD79C70C5A98E5657AA578097777E86BCC4651CC72F2F974DC766E07AEA3D0B557EF42FF57E6A58E805358CE9257669133B18F80FDBDFB38C5524C7FB1DE079842482990DF58F72321D9201F8979EAB159B2679C9E95AA6D53456C0DF75C2B4316D1E2309216882854253A1FA60CA2C94ECE013E2A8C943341E7D9E5A8464B3AD407E0AE465C3E3DD1BE60A8C3D50F831536401E776BE02A6042FC4A27AF653F0CFC4D4D013F115310788D68CAEAD3ECCCC5330587EB3C22A1459FC8E6FCCE9CDE849A5205E70C6D66D125814D698DD0EEBFEAE52CC65C5C84EEDF207379000E169D318426516AC5D1C31F2E18A65E07AE6E33FDD724B13098B3A444688389EFBBB5EEAB588742BB083B679D42FB26FF77919EAB21DE0389D9997498F967AE05AF0F4C7E177416E18C4D5E6987ED3590690AD127D872F14A8F4903A12329732A9768F82F295BEE391879293E3A97D51435A7F03ED7FBE275F102A83202DC3DE94AF4C712E9D006D182693E9632933E6EB773880CF147B922E74539E4582F79E39723B4C80E42EDCE4C08A8D02221BAE6D17734817D5B531C0D3C1AE723911F3FFF6AAC02E97FEA69E376AF4761E6451CA61FDB2F9187642EFCD63A09AAB680770C1593EEDD4FF4293BFFD6DD2C3367E85B14A654C834B6699421A", // 01 "96B856A629F581D1344FEF597835FE60434625D077ECF0D95FBE1155EA0431979E5AFF544AF591A332FDAEF98AB1EDD847A73F3AF15AAEE7E9A05C9D82C59EC325EF4CF264B8ADF2A8E8BA459354CB4B415CC50BF239ADBC31B3A9C87B0843CF3B9E6D646BA43F866276B053826F3A2334CC5E2EFB9F8F195B382E75EEA63F58A06B3F82A3B5C77C1800FD9498F803E524435B321210BB84690BED0BBBE16D363B3A90656A73720E27008852FB7DACC8284411B177728D9527C560859084A395A6F11A96AD9DB6B43E00642B000ED12BFD967868EAB1108552CD4FC89FBC408ACE7678C381EC91DD000319124EB5D5EF52C4CAC9AADEE2FA045C16CE492D7F43743CA77924C78696FCBF2F9F7F36D8E623752200C6FCBBD71ABBB6877F3C5D6E6740AB0389458A6B66440858B2D383244E853646FE2714211DEA9E6196252815BB704A20BFE556AC474F8998944E0CABBBE21A6400B87BFDCF937D12B2821D59298AF4AD378F0F42BD8C41693B8D993CF37C8B478F3BB5D33AD2A9FA24AD7B8FA895FDBC04964192F7BA3FF74E0E3A435B5DFE042E3115CACF29624C0645E9C917534A2EBC1F5665E4E1B1BC56208DBCD8A27CCB6474D5D0E20CA4072C960E5ACE41BDA3770DF3B681F2B318F6F8E1CB17C2857350FB6009AED665E13B2780D79217F73FAC7A8A48048DB0FB8A8A5007CDDC9A7B2DA8257C99F1CB605A18204", "E57DE19A3E4A8C122FCB1DD6584B3D2DAE364D800F9C5A9E957B38F624CBD3ACC58FA3ED070B5E44857CCB813FBC0BB83B5D157C6C562422E5963CC4DD753C45B0264F8E136A0F1774D77A543E44D51EF8C6B9408B6E3B5CEE1347A94F13ECDC94DC764976E5A50B4CB0AE7557553B47EDFE03EC2CD32EA8D125A341E1EDFC77E75330D6E7B23DC838EBCE7E5567F5B8C80C3D15E7404B4E10F0BEB0C69626A814AF91334199864FC77E0FF548DC2A6FA6A71C3C0561F2B085CC05E8512E27B9DBA60B93D114B87935776C8E9A67905C429D48BF3AB1B0A56FAFBFD5D9C8D8C8A9E5918BFF273CF5E8664FF2B90314BDBFDAD5AB8C22A0E45C104ECE75EA43FE9BDCE306A5A28AE464628163D249D8056005F1A900951808CC8620F81768153436F741667A8E271DD986C7A1E5046FCC74C7CEBBF9A1296D6CF0B2FF85BE412D87214BB368DFF462AD649D7324A117252311C664D33E4DAFBD830FBCEB6EFBDD7391D4BADA7A775FD1949D981F619655DB3C22BAC34E5AE41222905C0C7E80D6EA28471EC0468756531C09A471EDBE200472E78F1701FEE96E5769A9893C0F11E7906B064442E06E21ED8B0D70AF288690C532A2D03B373E1E0085F62F7AAA658B569C5184E3DDC40ECAA88B887118601691892F9F55E2DE79E49DFF11D434C2BA3AA6447522A7C99DC215CAD2ED0114ED62CBDAE9D315E48AE14D2014B7F8E", @@ -352,7 +355,7 @@ const std::string Galileo_E1_B_PRIMARY_CODE[Galileo_E1_NUMBER_OF_CODES] = { "97051FC67ACA30E8AEE73D3A8CF38BB13524D4E0EBD9BE68398C7C16227CABB1D0B0A0ABE7B6384ABA02905BA0C3C7363599D059C7B4C99DB165CD14FA12FA7912449CA7DD5E346D8010C85A757382270DAD15BA3CE36A76EF55F81A1E80BF366B37FE3A88EC722028C25E234E624040450A99CD808F942568AA7133981D72E7F2928894670AD5399482DF1B90E7E64062F830B736C79C30F36281495C76699CD48404673FA334F042F9E0E67DD7F3853BF71ABEAF6A9A5546855E840CE42B224D8F6490C6CE5FC02EBAF4FFC390107058F54CD635D4A7F2878099C1EF495750E6921BE2F39AD808C4210F287319F811A254CEF8CF153FC50AB2F3D694A530949E5F578D075DB96DDCF2BB90ED3DE09D9CA8E08662FD8982741DE1CE0A6B64C3D3D5004B5C04B2B0DFD976A20FACC94D1762D41EE03B40D2CF367612812EF4CC41D1BFE9CEB51AE3A22AF1BE7B85A057D3048D0E73FA0FDAF1119EFD76F0A41BE63128B22D64A5553E9549D411483BBCA1483EF30CF6A6D317AD2C7973EFA6D4C1121F703D2F48FCDA3177AD450D75D2A28D2C244AEA13F0E60AEED8ACBAB444D400DF5E280DB799B2D9A984DF1E2567D39D1DE58EF78CA6B4D8BC172B07DCB02D156CA96EEFAC69E556CFCE0AAB617C7FBB8C34871C1D35E74B7BD307D3F2E424C7A9AD676A1A69E0FE735EA50887A1DFAE6CA2FE4460FC7EF323ADE493020" // 50 }; -const std::string Galileo_E1_C_PRIMARY_CODE[Galileo_E1_NUMBER_OF_CODES] = { +const std::string GALILEO_E1_C_PRIMARY_CODE[GALILEO_E1_NUMBER_OF_CODES] = { "B39340CA1C817D81EF4FAE4E95BF3504A7709089FB48560E9E3EF802180E85EB2194E05902C6C4C52021FEB7EC64FD416BCEBC8E39D64A4B5EE345291911AB8204A888C25B1CD3D9342A56C538636D3EAB957037D09E879AE5F3A39834FBB84A3D8D5090D7814246B62E9CA68533D2EC403B4FB9488467FF9758B0D15A8CEF89187A1D5897880040B6C3C5244E85A2AD14BCF2F5ABC44A7B1D4A87E8BDA05766218773ED4F70F8D1D07CBB1E8CA6298E64EE6DC5886D37495BA2EDB3E0B0B68AD9F300310B88898DDEEFD484538C31A9BCAA76ECAD0C16607D32189058B0862EE9D70CEA9D304755CE8037BA4C46C2573181748A212E4B2BDD04F9BC240518273DC17CBAFF21A03E9120FA7DCA18D56DD1D9A7E510C90CF219104385F531F2EFAFD185ECB6B911F9B7809D98D86F15516FFDDBE9BD1CF8662EB777C3F94EA3F962D7B79449FAAD39935429E92CAE5637E9BCF4E94D413D27934952409AB536BE4055AFBC4330CD1E4B5509EFE5F8EFC9ECBE9EF377DE7E37C479BB9D3EE7745E4609B0A6D2C5D92EB3C9E2278C1F2221FF907596AA5E096ACF8990EBA907E43AD320F8019CB6355A2BA8670EE5A4F463E8E56F8F1D3E7F4922510FB668E32C4CF23AD8496399638B095B47833E0CBB34977EB3E4242EAF870D86660D6A73F83E45D6E8A41EDCA3815079649544597C5C43B6C93FEBAD5700D22EDAF431FD340", "A64F94BB47BD4033C76D4924305907EC1F618B43C7535F3CFC093E5AF5DDD5C4339F3BB6D835B5C2C2053CD3D5693368D4E1A7CAC59425D1FD96809C67285CFD3FC05B01053CB0773221D7205778022F487BF99D1650566BE287FD7AE882AA8E8F52E5D4E3C0C2F971C9FF70AA378691EBD8ADE45CF213822D09FD05243F9726F6C69893845E57C37A7643E16B770E26F431FF69D437271905D270EB85D8D229D7D87662121F0BEEB1E895ED9589A9CF5833408A04197AC9025D8570AD9B75DB7E192EA0A089504996E9DC652975D83633619CFF80667D8B519536B3475248BA8213C8A4C66DE69B4B3774BF9142425C57F34A27B1E288119E3FFCC6AF6A21087F9394F09DDFBD42F32D059B8CD4104A519BA640765D5CDE490E62F10E695FBFD33CBC9D2208A532C8EC25DA28B8CC1B6850AB43D9B5C00B6E74B7A148791AB07B328D347058C7E6233E18C5ED172C9F9E9ACF29D913E2A1614BFC0893D4967ED033B2B9AE6B51F908F1CED57C14FEEA85CD4D9711216BE7F79FA6721B7DCCA033C80127AC6E5FCF58EB4005EC24CB4886D787355362D5E7031B9B2AC2A86D730AD734181E723A811FF510A4DF868001973FE83288D78E6F9B9441DAF5BE2974A2848FD917C3BCD346A431922246EC852E4AAD467E60C15D61DD3BF4A207BB57DB45DCADEFE3210BE74B9DACC918A394469F2E2C95AD1E211947948FE24F5E4", "FD1F6976002C39C87187C44E3D224ED4DF0B67750105944C651A5E57798F168A136AC0FB5979C4E847A82B20A2E6C45DB42EF2B930A80D3257BCCC53EDA966F5DCD9AD47CFB226EED9B62A874E9F6404D4087798A1005F4131171D3A47907A3CD602B83DABE094D2CB031867DF4595F3ED59FD8C4D76EDEEE59E422CE5C7D0A5F720BE94FA24DF05F758348EADD5EFE9197C6BB2292E2B14DB8C6DB24AA94C5FF0F5106D2B566058D32C58B63A150784F7B02478D9973DD4CFD2E84059AE0F4F1320754B7EE83F04A51C67EFFC2EB1C301C0C58DBAEBE95474E3484A76500103C14C40BB0B7D3A04D8BDABB605C1EF9FD4A6564934DEC50BD5878243AEE80F9796EED70CE1B1E8B55725DF76472D12D4A7A487989F42E6705818B1F7E149E97153A7B05A82FA3FBE51763E61171A4E12931472E94CCBA74CC09483DF93623FC60945070FDDF3A00B561650427E4BD64D675B1EB398B35EF057A66FD0B48EDBABBDCD57C32ABAE46F5CDD0CB1FCF17765258236F3DE40BD5D0A3C5C978D81DEB07367AB20B2CAA9834B9576161C4F20FB9C184A01DC9021A4E92B71333354E05BBEA9015E5AC4C66312E8B79F0B92279AC7EF1936BCC30802B83DB3D113BEF64452CAD7ACF6674FDA44023A661019841A101BE80FDA4E3210AE774E433A9ABD97F2755259AECE21F7A8C3B1A3D471F874D2EEC85B9B21BC0C2E2EC9016F847C6", @@ -404,6 +407,6 @@ const std::string Galileo_E1_C_PRIMARY_CODE[Galileo_E1_NUMBER_OF_CODES] = { "CD7AAC98501F29507EA4E0183E8A40D2E5117E47BB5D18D01A3732DE4C821DFE86521CBEA7DB29BE1148BD544ECC681689BCD1B41EAF755310B7659342F8EE11CB41550CC30E566E192796B66C1A83C0B28BACCFA6C393043A0A2CB89712BC1CCB174DE58E66896AF39C1CEED1E05B0435F8CF6FD920D100F51584FE24879987399481DBF27DDB6286B6353919E552E669290CE02AB4CD5113D7F484229F379C7332767EC69E4336439B05DE1C1E3563DD303A4F580BFF20A40E49CB0822F715ED0221EBCDB5DBAD751124B1715E82F37488265135B6C8BBCF4F801ECC4D3525FF189493AD4EFF0C042B070C4CA8FB1FDF43D79F06A6E4E3D35D7B07D4B728D5DC54EEDACBBBA1EDDCDC07ADF7DFCFEF835E44DF1FF66DAF2A7BAEBE218AC3B15E183044D6A8A89B3C101B40BED97ED5DF93BBC1B84931D56B8C822A6D058AC74CFA4C85D8B456698E82D5B7574C17B041E5F4BEED09F75012355CBC322B822C63F10C18A8F279E9A0E18E1FEF183D23E13894E31F6D046956FE8A647558228F6D4D6910151EC03937876B6ED7A078D33DAEB3F2239353BB8181E62B286BBC41588DE10F478A5CE5B508F205A41820356767B0A0ED4B8DB9EFE348362E9A90D6C30218B295B338B51C09239D02FC8A1E7DAAAB60AC37F5E67CFC88EEF69567B5C81A03B449F4ED38B9D295A36AA3503173F6F6F66D93CE72D753076040FACDE", "ADDCEDB50E907D20E826E6E8A0D30C20C74B2DF204EA784BAE9F618CAE33A3C937729DF9CB10BA2A4C33E0182A37200C0CC509729D828B8A2A20F283AC4F9306596684EA3FB5492A4C9F2DB459E7531C9F9C0950E7D9E93B3EE5912AE7E39AC8F4EC14B18F24E325003F477E347C5AC1B67CDB11AF3BBBBCD0AC3703024B5767AA67A208254F798684BFD1D3EACD757EEC77254950A146620400DB95E694574F739A991EBA771EBBDFF1056BB39A77DBE0636A032E17141332F951C57C6C90F348F165E3ABDD60D429D5D6BEC7E3E3463806F819EB2D212B3528A5EDE51F235AD100A35E890955F8A1DC51FDCB53EABCA2540997DD054C1F5B29462995B876B44D085904E55E1B838BEF600A992EB49CE078DF75AF3D0F137685AC0D07F0BE1EB87B63A41E74DDE869C8A683BDE60AF5D77FF18F7137495BCEFD0ED28F62F9C3E25D332B5F861D999FCDC0B4851A984A4DBB53401FD40351ADA4335C702BCC8D900C737507B990BDDBE91D201E3A0946DC968D43FD10D04B0B76667FF5B4291C2124B0124C6B710A6D1BCFAEB016B9DEEB0F7A4FE044CA4EA0CCD84B7682617C3A545071EC295B0663B3F577D562DE1D9DD80DE6A1EFD6D5991EB5246F1597B86D0E9A90CF6DB0EB2B8E7BAE9431E567F01AA98502C773742246467ABF911A91A51F6C1B9E0C3233DC1A37D17DB91A5F0F661B0EB5886964456C7818601BD0C"}; -const std::string Galileo_E1_C_SECONDARY_CODE = "0011100000001010110110010"; +const std::string GALILEO_E1_C_SECONDARY_CODE = "0011100000001010110110010"; #endif /* GNSS_SDR_GALILEO_E1_H_ */ diff --git a/src/core/system_parameters/Galileo_E5a.h b/src/core/system_parameters/Galileo_E5a.h index 79ad94f81..19122372c 100644 --- a/src/core/system_parameters/Galileo_E5a.h +++ b/src/core/system_parameters/Galileo_E5a.h @@ -31,198 +31,202 @@ #ifndef GNSS_SDR_GALILEO_E5A_H_ #define GNSS_SDR_GALILEO_E5A_H_ -#include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" +#include "gnss_frequencies.h" +#include #include -#include #include // std::pair +#include // Carrier and code frequencies -const double Galileo_E5a_FREQ_HZ = FREQ5; //!< Galileo E5a carrier frequency [Hz] -const double Galileo_E5a_CODE_CHIP_RATE_HZ = 1.023e7; //!< Galileo E5a code rate [chips/s] -const double Galileo_E5a_I_TIERED_CODE_PERIOD = 0.020; //!< Galileo E5a-I tiered code period [s] -const double Galileo_E5a_Q_TIERED_CODE_PERIOD = 0.100; //!< Galileo E5a-Q tiered code period [s] -const int Galileo_E5a_CODE_LENGTH_CHIPS = 10230; //!< Galileo E5a primary code length [chips] -const int Galileo_E5a_I_SECONDARY_CODE_LENGTH = 20; //!< Galileo E5a-I secondary code length [chips] -const int Galileo_E5a_Q_SECONDARY_CODE_LENGTH = 100; //!< Galileo E5a-Q secondary code length [chips] -const double GALILEO_E5a_CODE_PERIOD = 0.001; //!< Galileo E1 primary code period [s] -const int GALILEO_E5a_CODE_PERIOD_MS = 1; //!< Galileo E1 primary code period [ms] -const int Galileo_E5a_SYMBOL_RATE_BPS = 50; //!< Galileo E5a symbol rate [bits/second] -const int Galileo_E5a_NUMBER_OF_CODES = 50; +const double GALILEO_E5A_FREQ_HZ = FREQ5; //!< Galileo E5a carrier frequency [Hz] +const double GALILEO_E5A_CODE_CHIP_RATE_HZ = 1.023e7; //!< Galileo E5a code rate [chips/s] +const double GALILEO_E5A_I_TIERED_CODE_PERIOD = 0.020; //!< Galileo E5a-I tiered code period [s] +const double GALILEO_E5A_Q_TIERED_CODE_PERIOD = 0.100; //!< Galileo E5a-Q tiered code period [s] +const int32_t GALILEO_E5A_CODE_LENGTH_CHIPS = 10230; //!< Galileo E5a primary code length [chips] +const int32_t GALILEO_E5A_I_SECONDARY_CODE_LENGTH = 20; //!< Galileo E5a-I secondary code length [chips] +const int32_t GALILEO_E5A_Q_SECONDARY_CODE_LENGTH = 100; //!< Galileo E5a-Q secondary code length [chips] +const double GALILEO_E5A_CODE_PERIOD = 0.001; //!< Galileo E1 primary code period [s] +const int32_t GALILEO_E5A_CODE_PERIOD_MS = 1; //!< Galileo E1 primary code period [ms] +const int32_t GALILEO_E5A_SYMBOL_RATE_BPS = 50; //!< Galileo E5a symbol rate [bits/second] +const int32_t GALILEO_E5A_NUMBER_OF_CODES = 50; // OBSERVABLE HISTORY DEEP FOR INTERPOLATION AND CRC ERROR LIMIT -const int GALILEO_E5A_HISTORY_DEEP = 20; -const int GALILEO_E5A_CRC_ERROR_LIMIT = 6; +const int32_t GALILEO_E5A_HISTORY_DEEP = 20; +const int32_t GALILEO_E5A_CRC_ERROR_LIMIT = 6; + +//optimum parameters +const uint32_t GALILEO_E5A_OPT_ACQ_FS_HZ = 10000000; //!< Sampling frequncy that maximizes the acquisition SNR while using a non-multiple of chip rate // F/NAV message structure -const int GALILEO_FNAV_PREAMBLE_LENGTH_BITS = 12; +const int32_t GALILEO_FNAV_PREAMBLE_LENGTH_BITS = 12; const std::string GALILEO_FNAV_PREAMBLE = {"101101110000"}; -const int GALILEO_FNAV_CODES_PER_SYMBOL = 20; // (chip rate/ code length)/telemetry bps -const int GALILEO_FNAV_CODES_PER_PREAMBLE = 240; // bits preamble * codes/symbol -const int GALILEO_FNAV_SYMBOLS_PER_PAGE = 500; //Total symbols per page including preamble. See Galileo ICD 4.2.2 -const int GALILEO_FNAV_SECONDS_PER_PAGE = 10; -const int GALILEO_FNAV_CODES_PER_PAGE = 10000; // symbols * codes/symbol, where code stands for primary code +const int32_t GALILEO_FNAV_CODES_PER_SYMBOL = 20; // (chip rate/ code length)/telemetry bps +const int32_t GALILEO_FNAV_CODES_PER_PREAMBLE = 240; // bits preamble * codes/symbol +const int32_t GALILEO_FNAV_SYMBOLS_PER_PAGE = 500; // Total symbols per page including preamble. See Galileo ICD 4.2.2 +const int32_t GALILEO_FNAV_SECONDS_PER_PAGE = 10; +const int32_t GALILEO_FNAV_CODES_PER_PAGE = 10000; // symbols * codes/symbol, where code stands for primary code -const int GALILEO_FNAV_INTERLEAVER_ROWS = 8; -const int GALILEO_FNAV_INTERLEAVER_COLS = 61; -const int GALILEO_FNAV_PAGE_TYPE_BITS = 6; +const int32_t GALILEO_FNAV_INTERLEAVER_ROWS = 8; +const int32_t GALILEO_FNAV_INTERLEAVER_COLS = 61; +const int32_t GALILEO_FNAV_PAGE_TYPE_BITS = 6; -const int GALILEO_FNAV_DATA_FRAME_BITS = 214; -const int GALILEO_FNAV_DATA_FRAME_BYTES = 27; +const int32_t GALILEO_FNAV_DATA_FRAME_BITS = 214; +const int32_t GALILEO_FNAV_DATA_FRAME_BYTES = 27; -const std::vector> FNAV_PAGE_TYPE_bit({{1, 6}}); +const std::vector> FNAV_PAGE_TYPE_BIT({{1, 6}}); /* WORD 1 iono corrections. FNAV (Galileo E5a message)*/ -const std::vector> FNAV_SV_ID_PRN_1_bit({{7, 6}}); -const std::vector> FNAV_IODnav_1_bit({{13, 10}}); -const std::vector> FNAV_t0c_1_bit({{23, 14}}); -const double FNAV_t0c_1_LSB = 60; -const std::vector> FNAV_af0_1_bit({{37, 31}}); -const double FNAV_af0_1_LSB = TWO_N34; -const std::vector> FNAV_af1_1_bit({{68, 21}}); -const double FNAV_af1_1_LSB = TWO_N46; -const std::vector> FNAV_af2_1_bit({{89, 6}}); -const double FNAV_af2_1_LSB = TWO_N59; -const std::vector> FNAV_SISA_1_bit({{95, 8}}); -const std::vector> FNAV_ai0_1_bit({{103, 11}}); -const double FNAV_ai0_1_LSB = TWO_N2; -const std::vector> FNAV_ai1_1_bit({{114, 11}}); -const double FNAV_ai1_1_LSB = TWO_N8; -const std::vector> FNAV_ai2_1_bit({{125, 14}}); -const double FNAV_ai2_1_LSB = TWO_N15; -const std::vector> FNAV_region1_1_bit({{139, 1}}); -const std::vector> FNAV_region2_1_bit({{140, 1}}); -const std::vector> FNAV_region3_1_bit({{141, 1}}); -const std::vector> FNAV_region4_1_bit({{142, 1}}); -const std::vector> FNAV_region5_1_bit({{143, 1}}); -const std::vector> FNAV_BGD_1_bit({{144, 10}}); +const std::vector> FNAV_SV_ID_PRN_1_BIT({{7, 6}}); +const std::vector> FNAV_IO_DNAV_1_BIT({{13, 10}}); +const std::vector> FNAV_T0C_1_BIT({{23, 14}}); +const int32_t FNAV_T0C_1_LSB = 60; +const std::vector> FNAV_AF0_1_BIT({{37, 31}}); +const double FNAV_AF0_1_LSB = TWO_N34; +const std::vector> FNAV_AF1_1_BIT({{68, 21}}); +const double FNAV_AF1_1_LSB = TWO_N46; +const std::vector> FNAV_AF2_1_BIT({{89, 6}}); +const double FNAV_AF2_1_LSB = TWO_N59; +const std::vector> FNAV_SISA_1_BIT({{95, 8}}); +const std::vector> FNAV_AI0_1_BIT({{103, 11}}); +const double FNAV_AI0_1_LSB = TWO_N2; +const std::vector> FNAV_AI1_1_BIT({{114, 11}}); +const double FNAV_AI1_1_LSB = TWO_N8; +const std::vector> FNAV_AI2_1_BIT({{125, 14}}); +const double FNAV_AI2_1_LSB = TWO_N15; +const std::vector> FNAV_REGION1_1_BIT({{139, 1}}); +const std::vector> FNAV_REGION2_1_BIT({{140, 1}}); +const std::vector> FNAV_REGION3_1_BIT({{141, 1}}); +const std::vector> FNAV_REGION4_1_BIT({{142, 1}}); +const std::vector> FNAV_REGION5_1_BIT({{143, 1}}); +const std::vector> FNAV_BGD_1_BIT({{144, 10}}); const double FNAV_BGD_1_LSB = TWO_N32; -const std::vector> FNAV_E5ahs_1_bit({{154, 2}}); -const std::vector> FNAV_WN_1_bit({{156, 12}}); -const std::vector> FNAV_TOW_1_bit({{168, 20}}); -const std::vector> FNAV_E5advs_1_bit({{188, 1}}); +const std::vector> FNAV_E5AHS_1_BIT({{154, 2}}); +const std::vector> FNAV_WN_1_BIT({{156, 12}}); +const std::vector> FNAV_TOW_1_BIT({{168, 20}}); +const std::vector> FNAV_E5ADVS_1_BIT({{188, 1}}); // WORD 2 Ephemeris (1/3) -const std::vector> FNAV_IODnav_2_bit({{7, 10}}); -const std::vector> FNAV_M0_2_bit({{17, 32}}); +const std::vector> FNAV_IO_DNAV_2_BIT({{7, 10}}); +const std::vector> FNAV_M0_2_BIT({{17, 32}}); const double FNAV_M0_2_LSB = PI_TWO_N31; -const std::vector> FNAV_omegadot_2_bit({{49, 24}}); -const double FNAV_omegadot_2_LSB = PI_TWO_N43; -const std::vector> FNAV_e_2_bit({{73, 32}}); -const double FNAV_e_2_LSB = TWO_N33; -const std::vector> FNAV_a12_2_bit({{105, 32}}); -const double FNAV_a12_2_LSB = TWO_N19; -const std::vector> FNAV_omega0_2_bit({{137, 32}}); -const double FNAV_omega0_2_LSB = PI_TWO_N31; -const std::vector> FNAV_idot_2_bit({{169, 14}}); -const double FNAV_idot_2_LSB = PI_TWO_N43; -const std::vector> FNAV_WN_2_bit({{183, 12}}); -const std::vector> FNAV_TOW_2_bit({{195, 20}}); +const std::vector> FNAV_OMEGADOT_2_BIT({{49, 24}}); +const double FNAV_OMEGADOT_2_LSB = PI_TWO_N43; +const std::vector> FNAV_E_2_BIT({{73, 32}}); +const double FNAV_E_2_LSB = TWO_N33; +const std::vector> FNAV_A12_2_BIT({{105, 32}}); +const double FNAV_A12_2_LSB = TWO_N19; +const std::vector> FNAV_OMEGA0_2_BIT({{137, 32}}); +const double FNAV_OMEGA0_2_LSB = PI_TWO_N31; +const std::vector> FNAV_IDOT_2_BIT({{169, 14}}); +const double FNAV_IDOT_2_LSB = PI_TWO_N43; +const std::vector> FNAV_WN_2_BIT({{183, 12}}); +const std::vector> FNAV_TOW_2_BIT({{195, 20}}); // WORD 3 Ephemeris (2/3) -const std::vector> FNAV_IODnav_3_bit({{7, 10}}); -const std::vector> FNAV_i0_3_bit({{17, 32}}); -const double FNAV_i0_3_LSB = PI_TWO_N31; -const std::vector> FNAV_w_3_bit({{49, 32}}); -const double FNAV_w_3_LSB = PI_TWO_N31; -const std::vector> FNAV_deltan_3_bit({{81, 16}}); -const double FNAV_deltan_3_LSB = PI_TWO_N43; -const std::vector> FNAV_Cuc_3_bit({{97, 16}}); -const double FNAV_Cuc_3_LSB = TWO_N29; -const std::vector> FNAV_Cus_3_bit({{113, 16}}); -const double FNAV_Cus_3_LSB = TWO_N29; -const std::vector> FNAV_Crc_3_bit({{129, 16}}); -const double FNAV_Crc_3_LSB = TWO_N5; -const std::vector> FNAV_Crs_3_bit({{145, 16}}); -const double FNAV_Crs_3_LSB = TWO_N5; -const std::vector> FNAV_t0e_3_bit({{161, 14}}); -const double FNAV_t0e_3_LSB = 60; -const std::vector> FNAV_WN_3_bit({{175, 12}}); -const std::vector> FNAV_TOW_3_bit({{187, 20}}); +const std::vector> FNAV_IO_DNAV_3_BIT({{7, 10}}); +const std::vector> FNAV_I0_3_BIT({{17, 32}}); +const double FNAV_I0_3_LSB = PI_TWO_N31; +const std::vector> FNAV_W_3_BIT({{49, 32}}); +const double FNAV_W_3_LSB = PI_TWO_N31; +const std::vector> FNAV_DELTAN_3_BIT({{81, 16}}); +const double FNAV_DELTAN_3_LSB = PI_TWO_N43; +const std::vector> FNAV_CUC_3_BIT({{97, 16}}); +const double FNAV_CUC_3_LSB = TWO_N29; +const std::vector> FNAV_CUS_3_BIT({{113, 16}}); +const double FNAV_CUS_3_LSB = TWO_N29; +const std::vector> FNAV_CRC_3_BIT({{129, 16}}); +const double FNAV_CRC_3_LSB = TWO_N5; +const std::vector> FNAV_CRS_3_BIT({{145, 16}}); +const double FNAV_CRS_3_LSB = TWO_N5; +const std::vector> FNAV_T0E_3_BIT({{161, 14}}); +const int32_t FNAV_T0E_3_LSB = 60; +const std::vector> FNAV_WN_3_BIT({{175, 12}}); +const std::vector> FNAV_TOW_3_BIT({{187, 20}}); // WORD 4 Ephemeris (3/3) -const std::vector> FNAV_IODnav_4_bit({{7, 10}}); -const std::vector> FNAV_Cic_4_bit({{17, 16}}); -const double FNAV_Cic_4_LSB = TWO_N29; -const std::vector> FNAV_Cis_4_bit({{33, 16}}); -const double FNAV_Cis_4_LSB = TWO_N29; -const std::vector> FNAV_A0_4_bit({{49, 32}}); +const std::vector> FNAV_IO_DNAV_4_BIT({{7, 10}}); +const std::vector> FNAV_CIC_4_BIT({{17, 16}}); +const double FNAV_CIC_4_LSB = TWO_N29; +const std::vector> FNAV_CIS_4_BIT({{33, 16}}); +const double FNAV_CIS_4_LSB = TWO_N29; +const std::vector> FNAV_A0_4_BIT({{49, 32}}); const double FNAV_A0_4_LSB = TWO_N30; -const std::vector> FNAV_A1_4_bit({{81, 24}}); +const std::vector> FNAV_A1_4_BIT({{81, 24}}); const double FNAV_A1_4_LSB = TWO_N50; -const std::vector> FNAV_deltatls_4_bit({{105, 8}}); -const std::vector> FNAV_t0t_4_bit({{113, 8}}); -const double FNAV_t0t_4_LSB = 3600; -const std::vector> FNAV_WNot_4_bit({{121, 8}}); -const std::vector> FNAV_WNlsf_4_bit({{129, 8}}); -const std::vector> FNAV_DN_4_bit({{137, 3}}); -const std::vector> FNAV_deltatlsf_4_bit({{140, 8}}); -const std::vector> FNAV_t0g_4_bit({{148, 8}}); -const double FNAV_t0g_4_LSB = 3600; -const std::vector> FNAV_A0g_4_bit({{156, 16}}); -const double FNAV_A0g_4_LSB = TWO_N35; -const std::vector> FNAV_A1g_4_bit({{172, 12}}); -const double FNAV_A1g_4_LSB = TWO_N51; -const std::vector> FNAV_WN0g_4_bit({{184, 6}}); -const std::vector> FNAV_TOW_4_bit({{190, 20}}); +const std::vector> FNAV_DELTATLS_4_BIT({{105, 8}}); +const std::vector> FNAV_T0T_4_BIT({{113, 8}}); +const int32_t FNAV_T0T_4_LSB = 3600; +const std::vector> FNAV_W_NOT_4_BIT({{121, 8}}); +const std::vector> FNAV_W_NLSF_4_BIT({{129, 8}}); +const std::vector> FNAV_DN_4_BIT({{137, 3}}); +const std::vector> FNAV_DELTATLSF_4_BIT({{140, 8}}); +const std::vector> FNAV_T0G_4_BIT({{148, 8}}); +const int32_t FNAV_T0G_4_LSB = 3600; +const std::vector> FNAV_A0G_4_BIT({{156, 16}}); +const double FNAV_A0G_4_LSB = TWO_N35; +const std::vector> FNAV_A1G_4_BIT({{172, 12}}); +const double FNAV_A1G_4_LSB = TWO_N51; +const std::vector> FNAV_W_N0G_4_BIT({{184, 6}}); +const std::vector> FNAV_TOW_4_BIT({{190, 20}}); // WORD 5 Almanac SVID1 SVID2(1/2) -const std::vector> FNAV_IODa_5_bit({{7, 4}}); -const std::vector> FNAV_WNa_5_bit({{11, 2}}); -const std::vector> FNAV_t0a_5_bit({{13, 10}}); -const double FNAV_t0a_5_LSB = 600; -const std::vector> FNAV_SVID1_5_bit({{23, 6}}); -const std::vector> FNAV_Deltaa12_1_5_bit({{29, 13}}); -const double FNAV_Deltaa12_5_LSB = TWO_N9; -const std::vector> FNAV_e_1_5_bit({{42, 11}}); -const double FNAV_e_5_LSB = TWO_N16; -const std::vector> FNAV_w_1_5_bit({{53, 16}}); -const double FNAV_w_5_LSB = TWO_N15; -const std::vector> FNAV_deltai_1_5_bit({{69, 11}}); -const double FNAV_deltai_5_LSB = TWO_N14; -const std::vector> FNAV_Omega0_1_5_bit({{80, 16}}); -const double FNAV_Omega0_5_LSB = TWO_N15; -const std::vector> FNAV_Omegadot_1_5_bit({{96, 11}}); -const double FNAV_Omegadot_5_LSB = TWO_N33; -const std::vector> FNAV_M0_1_5_bit({{107, 16}}); +const std::vector> FNAV_IO_DA_5_BIT({{7, 4}}); +const std::vector> FNAV_W_NA_5_BIT({{11, 2}}); +const std::vector> FNAV_T0A_5_BIT({{13, 10}}); +const int32_t FNAV_T0A_5_LSB = 600; +const std::vector> FNAV_SVI_D1_5_BIT({{23, 6}}); +const std::vector> FNAV_DELTAA12_1_5_BIT({{29, 13}}); +const double FNAV_DELTAA12_5_LSB = TWO_N9; +const std::vector> FNAV_E_1_5_BIT({{42, 11}}); +const double FNAV_E_5_LSB = TWO_N16; +const std::vector> FNAV_W_1_5_BIT({{53, 16}}); +const double FNAV_W_5_LSB = TWO_N15; +const std::vector> FNAV_DELTAI_1_5_BIT({{69, 11}}); +const double FNAV_DELTAI_5_LSB = TWO_N14; +const std::vector> FNAV_OMEGA0_1_5_BIT({{80, 16}}); +const double FNAV_OMEGA0_5_LSB = TWO_N15; +const std::vector> FNAV_OMEGADOT_1_5_BIT({{96, 11}}); +const double FNAV_OMEGADOT_5_LSB = TWO_N33; +const std::vector> FNAV_M0_1_5_BIT({{107, 16}}); const double FNAV_M0_5_LSB = TWO_N15; -const std::vector> FNAV_af0_1_5_bit({{123, 16}}); -const double FNAV_af0_5_LSB = TWO_N19; -const std::vector> FNAV_af1_1_5_bit({{139, 13}}); -const double FNAV_af1_5_LSB = TWO_N38; -const std::vector> FNAV_E5ahs_1_5_bit({{152, 2}}); -const std::vector> FNAV_SVID2_5_bit({{154, 6}}); -const std::vector> FNAV_Deltaa12_2_5_bit({{160, 13}}); -const std::vector> FNAV_e_2_5_bit({{173, 11}}); -const std::vector> FNAV_w_2_5_bit({{184, 16}}); -const std::vector> FNAV_deltai_2_5_bit({{200, 11}}); +const std::vector> FNAV_AF0_1_5_BIT({{123, 16}}); +const double FNAV_AF0_5_LSB = TWO_N19; +const std::vector> FNAV_AF1_1_5_BIT({{139, 13}}); +const double FNAV_AF1_5_LSB = TWO_N38; +const std::vector> FNAV_E5AHS_1_5_BIT({{152, 2}}); +const std::vector> FNAV_SVI_D2_5_BIT({{154, 6}}); +const std::vector> FNAV_DELTAA12_2_5_BIT({{160, 13}}); +const std::vector> FNAV_E_2_5_BIT({{173, 11}}); +const std::vector> FNAV_W_2_5_BIT({{184, 16}}); +const std::vector> FNAV_DELTAI_2_5_BIT({{200, 11}}); //const std::vector> FNAV_Omega012_2_5_bit({{210,4}}); // WORD 6 Almanac SVID2(1/2) SVID3 -const std::vector> FNAV_IODa_6_bit({{7, 4}}); +const std::vector> FNAV_IO_DA_6_BIT({{7, 4}}); //const std::vector> FNAV_Omega022_2_6_bit({{10,12}}); -const std::vector> FNAV_Omegadot_2_6_bit({{23, 11}}); -const std::vector> FNAV_M0_2_6_bit({{34, 16}}); -const std::vector> FNAV_af0_2_6_bit({{50, 16}}); -const std::vector> FNAV_af1_2_6_bit({{66, 13}}); -const std::vector> FNAV_E5ahs_2_6_bit({{79, 2}}); -const std::vector> FNAV_SVID3_6_bit({{81, 6}}); -const std::vector> FNAV_Deltaa12_3_6_bit({{87, 13}}); -const std::vector> FNAV_e_3_6_bit({{100, 11}}); -const std::vector> FNAV_w_3_6_bit({{111, 16}}); -const std::vector> FNAV_deltai_3_6_bit({{127, 11}}); -const std::vector> FNAV_Omega0_3_6_bit({{138, 16}}); -const std::vector> FNAV_Omegadot_3_6_bit({{154, 11}}); -const std::vector> FNAV_M0_3_6_bit({{165, 16}}); -const std::vector> FNAV_af0_3_6_bit({{181, 16}}); -const std::vector> FNAV_af1_3_6_bit({{197, 13}}); -const std::vector> FNAV_E5ahs_3_6_bit({{210, 2}}); +const std::vector> FNAV_OMEGADOT_2_6_BIT({{23, 11}}); +const std::vector> FNAV_M0_2_6_BIT({{34, 16}}); +const std::vector> FNAV_AF0_2_6_BIT({{50, 16}}); +const std::vector> FNAV_AF1_2_6_BIT({{66, 13}}); +const std::vector> FNAV_E5AHS_2_6_BIT({{79, 2}}); +const std::vector> FNAV_SVI_D3_6_BIT({{81, 6}}); +const std::vector> FNAV_DELTAA12_3_6_BIT({{87, 13}}); +const std::vector> FNAV_E_3_6_BIT({{100, 11}}); +const std::vector> FNAV_W_3_6_BIT({{111, 16}}); +const std::vector> FNAV_DELTAI_3_6_BIT({{127, 11}}); +const std::vector> FNAV_OMEGA0_3_6_BIT({{138, 16}}); +const std::vector> FNAV_OMEGADOT_3_6_BIT({{154, 11}}); +const std::vector> FNAV_M0_3_6_BIT({{165, 16}}); +const std::vector> FNAV_AF0_3_6_BIT({{181, 16}}); +const std::vector> FNAV_AF1_3_6_BIT({{197, 13}}); +const std::vector> FNAV_E5AHS_3_6_BIT({{210, 2}}); // Galileo E5a-I primary codes -const std::string Galileo_E5a_I_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { +const std::string GALILEO_E5A_I_PRIMARY_CODE[GALILEO_E5A_NUMBER_OF_CODES] = { "3CEA9DA7B07B13A6CC0AE53DAD1EE2A0FCC70009338C08AC0EE457F76A1690815C3C940AB722487CC8F3D1F4C428828E7FD2A21230E42A3BBDF1E792165F644D0E0335F95EBDC93D6005CC0C680DB7B0E1B8C4946B7974319F9816141DB9E01011E4F20DA8F1B8E15A6F618CF599C3F5C1A1B276D51318ED4119BCE0ACD0332F3DD8F88EC5215AB311C51FF4987DA93B09A43BA84CF08032F6CB28F43043C54586811D870AD6FA27AA63785345C8BCDD3DA26A0134738BC7E08461D5409FF0B791D8574CE797FC5EF7821055028CB4AF92AE1088F8806CD55F0E5FDFCD8D74ED801B2B44AD5D79D1924D41DDC6AB2070B5360CB64CCF487FE517420348CC39BF50BDF78BE7DA91542FEAB689457B3EE69E43C75FADC303F31032FD96B7DC70A88C3B7BAC7322B285D9CFB3A93AC8B890165F23848FAD8477DBDD3D0AA4CB3CD73A48000B6D134DA2DA70B56E590A101AEE78864DA0C64A7BCC6B37CD6F31E9AFF10CA4D47630752D253944632DF6EC60AECDCD223F29399CDA3B74D1DFA5471277EE6C814464A8C55D3C0B83B36B6AC9FA90CE876ACDF65E3EA3FD61D309EB71ED29A3D510B2F4C0B6D6C5B57EC9060CFBE48389DCB17CBB2284E7F578565B91503B06F49CF3E8534870AEB6AD9707265A9A1E6E2E5E6DF6DAA367239A96EF5B02C19A4543D537EB4D9D73966C09E9B52B4706F57B3E0987885EB84DEA26F7823D895F62015188ED38C04CC6714F797FDB0BC713E3D0208462F9A68E3872A167BF1BF9791AEE8BB73CF527C50975B55C4E5C2F2E95B677F833ECC878D1764839608CC1108A75EE9E58FFCFE4CB52884E7AF15EE0632E0729DA1CF5B7A227028CFE1E08F8B881E1A743D52DD27BED33DE0EE75DC031B4864CF192DFEAF64F726D73321363A233F81C57232432D2B0A5A4C44F4320847A9C143F378F204185D2B571482FE45D6BCA152E6EA7223BFC6DCE06CEF90CE9114623EAB9B1EC789B2051B4AB711DABF5B16FCD970F437B8860313B4F1F14D384EE3976B7E55D2FDCB7E1BD9BE18B722E37C853ADC7E1CC2870A02881F95B78487780E1D1C296415109CF07AB63D0782A9F451CBEB3E8B919917AEDBCA8A8E563AD3784639793E0F25CC9CC62240FA04B2F141E71BF5C84EAC56431159556B8BCE077A51469A87737D3D6F06D97DD479FCC35129F4499C19EF98BDCEA9D4941B3756CDE1997C3AFCAE62B6D9E23341E11CD05A7FFF52F5814011A84D737E1264109006BEF5F19E3C6A9C7521B44741A8282755A8F0DC2FA0E1F6CA4FB34D8CD5FAA27E18808868725B9634376137C1BBC46934F83958112D03082DDD6148F353BD1DD24B9F8FD7AD89C40DA0A92A8DBE3608038CD56FFC4ACA35241D76FAC4CAE1211AAD9D73D51C81C59BCE05F71C345730D3A2C670F8F533A950EF24B00EFE6A3F1354694ABCC6FD9EC4E74DDE1F287AD4F847A297ECCCC39AF029EFCDDDB19932D906B9CEDFCBE0D422CEE305DD05E407340F28EEEA866664D60AF293A45D5D6D5C0000B05F79463DB513ED488DE7BD4EC9EACFEF973B23CE4E9539EFCB797456CF5FD1EC54FDCEE80B39063C48B91A5C2D2BEBC81B9B46D0AD6503BE5AACED2BA5EBE81F630B4E07510356E8229F7FC5EA532B8729CDB819E066A15379AC6942CD4BC5E97C6791E098105C323A3A3DA3880D5EE5562ABBA2BDC9906F4486B51ACF8AA4405E9D7A63DB9E3058782DD9AF3995FFB3D34AEF98234A0B3DC62C339325B60706C068F0198BD8FA658396D06931B069155217690C7F88FD230CDB38E3E48530BD47722FC", "9D8CF144C4B667345D44F765622A956CAC4E097AB1CAB05CFBCC6BB68C709503AD9DB09C09C983D46A04A05B6F7EB26DB4D46F868C10E112828B1AEDB3C0074BE0DE3C9B7821BABB4F8B8E24F69869CCD981B09A783BF6A95F39ECFAF25DED6B16F89EA09D3A8413CCEBB545651B363DD385D12BB72420440C40E804FA27DE029A1E08629BAAB598C035DC58FDD309844F3BEBDE40FCC231F38605DED06572ADD85DC51D3D8B89B4480143D0B75283522354330E5CCF4DE1A6E68047D5B8D45D835A891F2D40C9DB8A76CEB1D18FE2BC38D080A8D97064CC87D692DF21184ABFDDA7642D0BD6F3209D06B4AE7600F7DDDB71DA751120599117ECCE645FD109CCA2EC7DB98F4177F14DB854FEB314B5D7CDC3385AD203464EADEAFF4AD08DFEF3D21240BFB8EFCAAC1356C72A0F5C61BE03CD2A21A7D756FA9003D562FC4A49A6BE788EC8D80054ACA881DFFF72C2966EECD09F185EDD11218C6696DB14E05FFF3644D11E508F4F1E9C5AB3074FB1C3FB21092A1C8D5AE05688FA4A9226C3C30D0BC3981933DC8648240F8CB67085F53AC5295428DC8447A1E5A46C2BA86796982C4C6CC647FD8079BC4024BB69E2B226E6F3D0F8A90B4D36DA2AED4C6BB60D318AA7479FDC2031143C67CB4381C27072E12935001524C7BECEDAA9954BCC2AA218E9EC2C95498FD8DF655C015896D9ED42CE7F91CBBA2CC4A7920038EBB5F5CE638F969F8B179E72AE252BE7E826E5CB53C2E85AAF1E1F1AD8D534F78A681928818AC3154651FFC583DEB0A6A1F40B98771ACC528AAF80D210ADAF83597869968D499ADE9A19BAF341E8CBA20F0E1473BDD898C24C7A5466F9924EC7EE992A2086AF295BEE1F6D0F8843D91180BF2C981C11FD978B23B6BAF7786BD526B458B76A87C31D7C52DFA43F3D362C8EEFFFB3FE5FB3F6E5F34B1FEC7EF1031146F3F609B32677F148F7DEBCF3526BB45582436A3092408193D6312626E46ECFA96FEAD12A234CACE10FAF9DE75EE2D238088146328E10E9ECDBB0B018ECDF2725415CF5A06AAB857403BBF6CBFC350903A982864827988BC805A3484A31FECF7A40D4FE251BC7E487613B9D3A48D3C7DAEFDC49C4B7E625F868DB53A798515A61050978552699EF2A5BF2F13BDD444EADC9B60B479FDD4633EB4C1062AA78BEF06692DED203819D3160310FD7F2343732156A9CBCB0B50BA9A8F93E339B702670E54BFA6DB2E2E773202C690FB71EB03671AB0B1B02B2F189BD99061ADD23F75F4914067AE638C9A29DD3661C28AE272CE692CBDE6AE880FBCF272E548342372CBAF6370C7E3AE9648341CE7310BE1C534B5702B0611AF65868F840B6B7613FDAEA21DEFB4F2024487023B02B8B58C9E9F27AA787EE775249EFC40913CBBD69C38538F239B203815F00F7B9CB30DC79E6A0C3E069D109E4A1BAEEE36D354C3D0121F1342F1F4AC504A68D69DEC158D54B04BE8164B48F31BC0827A0379C5237070B6F963741AD9ED4F3865698FB8233D7F49ED4E0EEF3AD927CBAF4FAE183252BC56AE4CDE3E329B1D9C87C6C11429B15B8EE589213CFAC208A12AA01B4F1F7CC35CD0AEAE217471B3DAC1C279F353DC61994FC45FEDBBE0005D8EC729385645864EF98A3A417E62F1EACA7E60D4E773BB2E4024D62830F103A7988733DD7BBCF3AB0CD0049006FE2F7EB3821724BEC37EAE44681A9699A025D212724CD98CA3415FE2BD09FADC02F1501FA38A6083427B662DDCBD0460E12A09072698EC8966C47B8A640AC79C1B7722E78A6C28680F4BB77BBA477BE0A6FAB959B9753217C5708", "45D1C8FF162EE106CC87C3EBF6A837930F8CC797EC7A446E8A213ABD239582350636B19B5BE428A9C13F980B7AF5CD7F32630AFE8693CDF0EC0BC2C84F2472F5B86576E8C43136C14717A24705953D392BAC96C1055B782C7941D82FEA357E5FDEFF772FB9F3DF248455CADEAC4CBA2EBA9C91184006D1680E000D59E4BC8FBE2C2F7CC2E78BFA5B60EB292F244E6CF497D5A287432F2520B31B9D9FEC1210923299EDFF043CE077195509E92372F5959AAB4666AE486DEFA400D81463C388CD05C677BFD4953D2627105B0A776960FEE916C75D53981D30DC689581B7E8E0723D65949662ECFAA6FCC9F0CE8892E367721718F906207663F9AD450AE98D75DF004080FC15DC2CD7A1DCE013A0E547ADDC29A397ECB9E7FA02035327AC40240E2091098708D424563AB7C5867F3F2D78EE3EF5B658FDDBD49435060CA2EA3D559CDE957B7E48B98DB41CF875F7B3D9EBDF6547B4EDD98DF4B747B0793152FA8CC07C6D9EE5A2002464566D86466C2EDE54A2BF4BBE823049E57364C127A14BFE1B88ECF70EFB81EB831BBF50F6AE124E5F6A775F3F2620E91D489CCF24811C0890EF905E9E2ACD399E13DC81333A54BDD295B872EB74E412E2FB654A9874854FBC3A68C73434C5FC5CED27534B2B13C316205FF4E432FAFC13A7B5B7A7FFA9FEEDB5AE69036F8F2955DA124CE5856E8C53F24E609F7D3386DC5212B2E78B5AA23B59D45FE98AA08E9CFAA9D52ED260A36AF07522C047ED43808A39D7019E444EDF84D885A9AC84092A0F6BFED562F3E0D79FB5CF62F98E67EF219FA3F5AEB7D4E344642D3D4B1A7EEA18464F6CE8D4CB3181D9EBF6F4122751B54D0D7F3FC470A91B547148AAB1CA0DF59872120190640555A7561B0F2C11280768F74B1A56674FD5480B0F510491431810D99CECBC6DB85888BACBE2B020FB8B3D78039773229714156494EAEC3A2D0A59E718F72205747D69C05DDF1C678E2E154A1F84EF0CA2E24DC4A6A996F0850A396D2432596EAE84AEC0935B8C25D5C65B52A32722F01D281C4F753EE03EB10020E9FA02462CA303DA39560669637532D381EB78AE5EC0F6DBF6273EC979442E6243F65FC51F26C6C9554C6C0E3EFF33BC4EAB6A27CAB9383BE7DDDE4218C4998033B47919503E1C9A789711EBEAAD6C0298B3DC563F54D28675260F6D896F1B8D4FD0001C429210398E9544B3DAA12C31F7EE82EF4D2234E26F873610B76756DDACD24B6132BCFFE735FE75513ED527DD04D7DC6D24059F85706679DCD1474A9DB9571426BE17E6DEBA58B33B708567697F471CA8B78E8FA73B0E18CB6F88BF9E4F442F0FC21FAB89305484828F18B65F9D373A6A2B380D73F5924F80DA234C1DD87416D025E4E663C96F287B0C83DC92C2164D81830781B715209FD11A65E64962D805389BAAA91DFBB990D3511E506A8EC101131C5B7284252F861D047DB2C2027DBAAD487ABFE429CA21CBEA7671350618E441F4D62F2D579CAE29D97023A8873869B553293D9F54D4A929E252AF132325A6E3BCBF7B36D0DAFA1E56A39A5D801FD0D5A41111017BF62AAF8346C7D424FE007C32B437ADE60AAA9540AA5078FE6C3C3CCEA53EE863086646C976FE6C79434A0AA4F53B2E9E2C3B4CF9C9C4015391E27CDFF5C1FCCCC00BBF5B99715A1265F591E294D530DB14DFD485AD34BBCEA32E5B5D0EED15F88BF5D96D058E6D70BB1A232597E35A625E5E8C2EF5E7031A71F70309019A0591BA0A50E87C839498255A3602C0FAE53166BE5E49E29D24AEC47002B698F80FC49E718B66A8959259ACC540", @@ -274,8 +278,9 @@ const std::string Galileo_E5a_I_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { "84D5B404488AFCC35CFC6EF1CF7A848EE5EE527B7D2D2081EBD8FA8432414FCCB271A43FD618EF95CAF1CEF445B50F02AFDC6B41D5C1F1FF4B6B8F2AB94F90F259383F44246B2D400C3012FD76E2980827C9B5476C4651293CBE9FAA77EFC53E369B94F51BE480EEAA389D88AE421E75EC67C76E30A6FA7EF02500372E4C9AB875EBA1C357C003938B979859B0A914D58F21B3BF1BE8C33A1AF079C5A0A4EA532F93A10F6D96D0A63F3C99E6F06CBC072CC5D71A517FFF40BC260A26E3A46688E79E733E1E2F0010846937689E2998BC769186E0B977AE0A1689245D255AE7D5F34715AD526E824838B62546D9569009A191BA5192535E23142236F4035C90D1405C8530A57B402118FDED2A5DA4B40635D2F95AC7CEAA370686F0AB23AB31DED369BEFB066909B76F2C04039E49FF0CFD323628D03C26F0BD4054C127F21355C33B49F86895D5354C3BBD2C0D38ECD169289F7D8403AA1753B393AC06C887F98315324DBD78F9BFD1AD8880D41D4EA98956EC89BBDAD08F7CFEBF26988EB5AB01D4E49AA8273CAB6AFDFA1CC1C95EDF85284E6570332A0B8242FBA495D87A01A945E61CD36E865CD4F430F04A3B3EE74CE0486B5676F7A938B18E1DB2DAE2FE1C04B3D56892C7394D0B07C5A2F7698D196711DC83FFF6ABDD4E8131E1106EBA23245FB0E2A696E440FB6B0B1CB4DD22C9720AC76F09863711647A7E369FDE5D6911A5FCF987470B8C06C4EF7063B08A8320B4371866789147E9D7C5D477A662A501627F91E95C6E2CB6814651E9DFACD67CA0B1FE62F44081E3BDDB964C1E5ADDC093AD185F0203B4C0F7E3E96811F14C79BC54F2919FCE5B653F6845CF1AC34DA9E4CF52EBA626B739246E25204F9EF2CCF4F5ADBFC53CD8F629FDB82186CB52BEB7136F105D3CFF9CCCC2610BF2C8F943DF5BD03877ED7AFA25CA81C4063E1B97452A937FCF77F1AA068FE2A26F6ECDF662ACDF18391AF7D627C2AA07CF5597B5F33AA0ED4DAC98AA73C8321EBF6918EE568ADEB1A823527AD75CD5BF7ED3EB5633A4EDC8C59DB0A91DA79C248D6894CAF9CB411F302635BEEF1A1C7916C7545B8BE7C577692245E285D32B4FD18E1478F88F8373E22A5CEC6D22EACAD2A41612F05AB2C54A1C03C0512359B0F9C5F91615EF2EA80DE97230480F489FEDA38D52FC84E2F1258CB20FF0E850639B31C2958BA6C064D0D0F4AAEFF313E43C65EFFFBB47CF09F2A122D15F76E8B704DA8F2B8C71449AA49774EBB7B2DC97CF6004D2FF6D37B9C689261189B85CFD50C20C961F22A644F51497377426556B956DB8C899045B175A8B9CB22EFDE535CF487E9D958281E0467539853054FC3475D2E142D58F9201C1DC6B2C1A12B2878F9366E2216405069B7D03852AB37EE83112EF2EE172F4E5317A41653A656A06F6633AF59062A47263A9977A50B9115456A58F9C3424FE7E0CC57DA70FEE0411C1479B4CC2E6E720B01432CFB3C503983B37FFBE38C92E50D6C5795443F73244F6D28AE6270E27D46A25621F86A2BC4259DE6C04CCAA657FE656C640833B290F00A1660329A3F09FFE60152A23925F4D8B0933AC016B5802CA863F66F8CEB5C8383B1180A515AE6C51B5F56597C3A004F8D25F8A6235C97B4DE38468B63E3B859A487AFC4320598EB6D143E5C914409D25F6DFF6E957D575C71D3ECBC6743CCCC03E5F34791744637A994F3ADF86966B4FE911C06F7BA1A6C20A2971D82B64E49721A530D9D5A2319D5BE0F47B8119C5A835CABEC735A935E23CB439970437C6F4CCDE2525EF0D7B1555CBE70280D5E760", "A5029C9EB4623226D321FF78D3C4EAB1F672A8B2B24A09CAEF21F561A851323C05A3C5E136A2DA7104ED19FBFFCAC3FC49B6D598F3060E93552EA6C700B837F7CE04721919B9C96A57B42AA1D832307C7A847091848066CB84947BE5F6B54654479E39F654819D3EF7AF4939FB9F4C9B20CA7F83DA0FDA2F171FDB72455B7ED0D43206992520CDD86B29C48BCC687573AAC4217D0B7DCF852811ADC3ECADDB2B34B4572675CCAEFDAAA01F83561E6E240878F229698185A80E6FECEE89455A72A377C24CE3FECAEC2A34B9CA98D288596D1C769CDEAB06871316CA7D1DDC5862E6282DECE33F362C64A73E57AB266715068932ECC31E62AD2ECFF7C6FBFE213384DA086ADF49E30F432EE2C715D9AC4DEF53A7B09B0D722CAC560FE8CF0059B80428458282F7E81717647D72E321A3E4BEF16FAEF76009BD98B8D9822B771EB62F1D0748E462FB7F3BEE9B12AA86D9629085AEDF8E43E1252EE59970CFF66A6F865C7651EF83F8FE10EB0E2615BF8F5C7F12FC601B0CF795C0D8B7057F54408BEFF86747C0F6F23EF212A9086EADD464A25341AB71FBA4ADED8F599C38FC15E790A5B86E64977C5AC718DD0B47C1A476AC9D7369396144F6288E84F7FFBDE02EC00EEAE8ED415C84648364ECBEC42164514D3E26BFD3187E0641C216FFC57E00DD752CDA581686916221DCD1AF07582391C5FBEF047FD1B7B956B458DE925C02A756FE197233E0304D0E034FF9A176B5B3F5FB683AB41D2691E13F97B3F4EB33238851331197C49C60233232DA0E2610430461876FF6F77FF3CCAF1BB2424B8B347588667B48480476D40BD9E487468CD5AFEB597C750A5E665B4E7C4C169ED08ADFC731FEA928052C4FB85B3064EC07B0CB988E324893B3F084291D964403F0350B7E1B06DFB73362C38318B762A972972BFB76CC5C08B5D47DBA0F3A2473D7749DE9F49F50C4C1620A9EE9FE56296124D72906497411DB87D4D8EC4E1F79BEF27232008A2299F5317FC1A6F455F1B827F1712BC01814F0B9D0CC162B25B804278B9C7BC5FC5616B317F2050234A7AF92FE35A59E22C959C7163DFA5F142022BE5CC4D5EF16D218216C57C2E29DA926436C00DCB82E68E16CA5A07158D8B8864D38A765D14E82175114A28CD97D11D564C8C7B87411589A4FBD49F9900D08939B7A73B5E6466B6F607F8AD22120A559A02BFCEF6456E7AECE8C9B7C9D2B322D2197124C05363B2CBFA58B74CD88877F22A5E5C202FC2C33531125F1518F4F0F38FA788E5E6B3307A75EC73E545391CEA200243DD6D25A5B8654A00B82BA57437BF0ACCB0ED37ED2FED221E54EC12B93AFA6E3939223596075F4C47340355D7222A8234A1F65EDDA42FFF5D19F7FACBF09AA77E7962F4CFBF61A0F26FB18E31A504B371714048874BEB286AFF71B43E4739A17E8AC25FA77121ABBE6E99754AF42F1D0021EA1E3FF088D0734BB191F91A520C96E22B4A28F9A2BD7DF81E8079EE5D0DDCBD517046F12098FAF6920E0EBA10DE8CFB391C63C60D62C1F4BB26BF8B6E421A830575731F67D306CEB5D6FF04637144790EC4AA2F435906320114CB81EB40C22B271FBB065474687AA5880F1DBAAA1744AB3E9B831A932A9208BEA9F5D526C52F5FDA56320E123CFB553E2B71A595DDED2ECBBD6E890B0421D765D2E9FD0D3995DF2A9523A65FE2040710DF16F2A83F510DCA08493DC138541E5681B51EE87D84C9AC11612EB5C06F5A63E22BD6275E35216766D79B215DBD087E9CADA0CEB09BFE435DF9B7809A76DE323B373682B8C58CB4F08D9C708EB050DEC", }; + // Galileo E5a-Q primary codes -const std::string Galileo_E5a_Q_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { +const std::string GALILEO_E5A_Q_PRIMARY_CODE[GALILEO_E5A_NUMBER_OF_CODES] = { "515537AD5E5F4216C16046FB0AC50DCDBE5CEE7E3CBB51B6ABB4E87A407B90E0EFD49DE1DE5ED29184E7FF0DC31F75FBB94F46FF6586B36C7771E5A68D060A965ACCF8D640C6B6E4530FDF19DD2491BCAB69ACBCFD3EC7281CCC31253A471B652E21C4CB0B43613EC542266460F0A6199B436BEFD95572DEBEE920A915FD854D17FFD0DF8C74E23B21B28493A0927709709B07C65878C43B69DC501E9D0AA21061ECF173876CAE708C764435832D9D6FCFE62DDF2543016D6325A56D9BF1007886E62E8A832BC32063CB0717D723C5E8C5F0C0EB3960577D364C93060B64EE04A539B7601CC3113E0AEC53CF21AFAD0154DC5CCECF038474E0F4004A65B1EE2801F81968B88C3D35E87CBB126C02D770CC3D32A552883D351DEF47847391484F80646728221F993921BFC14126EE3D9527DE607152724C6D2DD305D3FEA0AAAEDF6509A2FE3248494A54FDA8E3CE7E6BBCE234E4686BA5A19724BA2CB78CFE71A6AF45532EFB286C5BB47BC3C1EEF4E4A8C757786AE974F30A86CD60EBCBFDF5502AA8F643819CBA4301E731ADBA1345B61C0B444FE7B817EA86F8DD749C451AE7D24A68D914F26C918238953E8AE61CC8553213DD6856C7863F9F6BAB1B4C84B225911E7B92BFFC12AC211B2B2CD905877FE976E07057963D47C437FE47D89648053F81AC39E8FD2F3A726866F6693E503CB6F0C3F0AA9B3EE2EA3BCDB16D726E1C6D8B073AA15F64EB68D53B1F8CDAC19C7AC33361226E81F1C793BF188755A3FE1BAC38B91ABBD4F077F7A28983EAFADC346CB941D49492625893453B364D07FE06FE42B160C16FE0462AB6366FFDEE54DC9CE4DCCA21E4E4AE5E92C872D1E4EC6FF6D3063C98A5AA5EE72481A0BDF15152E2A5425AB722101474D0E1EC8401273EA1BE1DAF7403190A94305BD1C7DFBE1F35F65D5CB97E82B7A297047507FFA0012FB73360FB8719C174E78A989A96E60A9184B3F3A8188DE100AB361921D38E8142859C8F0F7D441DB1B2E9687BBD1086643987C83DEE0BE8CED4C83BCC82B62B45311CE4F13ABC55BF5EB1ECDF15F5A07F8B2C42F07FACE0E299E87727E2D534FEBF7B9C3894CC3E2E4127A294B9FA2A671273B174DBB81D247CD2846116500A072DC3962C65FFECD0C0B46DC2AF52882058259C26FDE50BEB319AEECFA1FABA34C069680B9EBAA9D96EEBD7EA30E748213E1283396A2AFC63527624641D4E1F1022A973B1898BD4CEF4D712B49371A51D60E08F42ED1EA90AC49EEFBCC53E7F9E899DD1AA4056F11462DF1A4C81620A73C831CEB897430A22252B901EC3D6F3DF58EF26422F796EA31AA4E0E9CE5B4A9C312A22305E298FEB3B3628283D405EDF726937327D90C542434BA3B60684584A9DB244839D2ACBCD7EF147A541E35687B5B8F5F07764973112D20D1ED75DC31F6A938542B42EFAAEE0F11B0583AA4925C3132356200E8D6BDB3127B975F4115A7A8A1C471836E3C5450B501A24D4A1308BB319AA827222B550F253F64B6F7D2322C6A2D3012FEC265A66A60102A3340CBDAB900DFDB36693D41DAD8DDB8875F8C3BE76AD5355DD81D67AAEBFFFE9458E522BE0312E60F63DD92F25C0D7CF82F223AEC0BD7456752CBD5151FEB5368F8857EAFAA90E8C7499B75D46EC4CA20BA8A24C90C016B5BD2CD7864828C6140E98EDB9509AD1194F56D49675D077DE92CD481B469E3A37F7DF0D5392DA4CE4CB282530F1C73482CC0926B877B00B0CE49FAD21E4C26194C7E950E0078F3854EF88755E08E9380165C584A3DBF1ECEF6A31B224FC321326B93797BFE8", "D67539AFB80711A0BA3CD67D963BAD346BA813D35A2EEA104D36AAAB863C656A07AD61BA60598C07744D32ED01EFCE928346C09EAAC2D392E5655F0FEBC486815AE30A38014DD8520F73CCBB71D9D42636328A50998A2A3BED3E4B34D0DCD65B94807064E2EF0C420898DB96E3B99EA9A0AD91C63857DEAEDDA5E644E62212B23D72FEDBBAA78C6581C677B10689C4AF387626DAC55F4EBE1893D52D28D20EA365702448A64A0C553ED337C3BB911DDAE2A91727299D8064BEC880183064574B5E3631E70A0590210143F4079C572BD5E2F7634C2D53B1FB1DABE79C484799E7075EFF98F033F5B2EC66C373825335D883911CEC9CFBBE2E38129B7E03D9646A7E513D5069043BC62AF4C524F12D8F98D8C9DAC5D8642DFFF48CF6737AFBBCBE965925F55F03BBD5123C9DB47AAC780301DE91FBED3C01D03E6464C2C2915BFA187A4BD93E20C24574FB91F0358CBE0921DCC8D6B7E9976763A1D2158511861EFF5D1C0B71F608E7ADE91D9DCFF5640B55BC9BD1BB322C879C7EB5C06EB2601D06241D09CFB1BC1695DFA55FA044E0E2E4BC86EFBF6A55740C4640512DDD6CA069940BC0FE1738FD376C68BA8AF7CCBA7D89F7966B29355538836372EF418D149EBF3AC104919D91BCA2F13E79A7CF7684A4DC0AC556A2843E041A71F97C94B859FE009659F593EFFEBAA6F6C1C57A5BF22752613AFB26379C42AC25804AEDAE22D63B230FCB858F496B8EA6F37104D0890525DBDE06AD988BA0287B0938572F14A98EC9E60E973FD693DB1F2AFF671AB03FB12B729D0867938DF6B60EC69790C992C6C33A531FE56D0ECC1465F65E3E57FC9E45F0F65A1061CE6D3190B6C1B8708A8A5A47222369AE889D26499CDE8F0548B8D7071F2D4DF6C0F2418BE449552327981CB0B54F792F29A71E30DE257CE1B3A7553A22275E4C8B9FAC3B8D4E9912BB22B0A899E7337513C7ACBEDA15FAD3D6919FDDD941CA659D78B74FD39E2E2F622691B89CA82FFE602DB2578A20D4665184456F32DF4DD6CBC412EC7C6914CA427CEE02F6D9810AAE1406DD68ED3869BD8E3947A2B3A803E875FF82005D853E3F43A6BF936030744C34C8B71B7722BE0AD3F475E531C9249A42671D5F3A5C77C4C28DE29AE953EBFB572578B17B636F8365FC755C22871E7D53A1F1561C92909305C9FD36AAF79E8844B63370B800B25CC1355211D9919B830A988926829F808DD2C66400279E6AC14F8EECBBE8B6E9ABFA3BDBB38A49535F64F719EF48C5FE6B2738DC6F71AACD70274FD40A29BFCAA594AC3E7D0C3C522E406BA6392444C9F362339E8FF34BE330911DC7EB11A47FF3A62A46CDE961A40CD5B24020909E5B034F45FE96CB156FFE8E2FDBC12A7C12D60D24BFBE596544E4F03AF26F086A5A667496B7DF302E4DCFC568C7ABD665EA7EAD8A7F5A000DAD9F43E68C4D8A14742E050769B3CB270E3856D7E8F4E827046D3E55A52F0E02C883881914DE87AE3C24D93E61A94919B40398D3EABB1B5142431AB919208A9785962D05061EDC951C83C73FBF6AE8DD6FF839E631C9FCF6635FA053DBCF932E359F83FBB3EE310281569741E3A8975FAAD1E573E0EC3207F6DBCDB8CC90DCA1CE517C8DFC1D31AE4841F87A5157792738DAEE7C29240DAE26C6C3E9D8A899D2271B0C374BD2EE846C6625E31B2F8379A96F601323039D281608A01A1844E5D1D20CF1D92C52107CDA71BB3B7EC4DEA958CFD7A79F71868116CD1DD2B2E66BB94D1373B733F324BE489DA51BE72B01A8572880AE1E61650B839D03B0192D290D5B36A9CF93B304", "58B2E58A13D4D5F84F37A389E6B01DFA66DBC6A25338B2884EF08056BF0A9124DA29254AA79CDF1B0944DDED4BC7FE683EF7A3C7A1C359E61E959471E30F9D534F43EEF274AC6535C616ADC7455BFBFF43ABF268F7C995CE020CEC73BDBD04007562F2710498AD1A324F25A6233B2DF2D9A429F1C39943E45F934986D1979D293F90CFBEBE01665C98C0D72D09A382348136980B31F5D4696B85C3F42D5C445996804159CD4C4CE7547C4A3FB718AB62D9E9826D05C44C6BD21D708CABB01F46514F29FBE7352866EDBFABD0ADBB6093E1A519D0E11E27737239A07866752B6D864686AF1E308481C53C635046C0756E8008D3CD26DB970C5D6EF8CB9DE6BC4339EE9F88EA45D11B74A1525E2F1B9F91567A78E403F7ECD47A99E95C098870B928E1B0DAA984CCECA13C6857F350E808BBF66AB4EDFB0F369F6F009268D19DEEB377F7D0C4ED6414EF6D23A0A5F37A25AAD3CD62C2115CB70409049CF0CE6D4DBCC5C96767614C6FAF73E9A76C7550BB970AB3D3ACE0C07FAA9F36F1935DFCD5228427BBEB5FC7A2F951D9210A5BC32ACCA7E78AFD5FD460CE2A79348714E5542BF2D453680B070E85F3244E8A6B4EB6ED49F803E60B8A383C8BE6283B1C4DF79E0C4A23D5DAFCB26DFC5DF1D1520FB6CDA23A05A1513F751EBD0143C2B9F5494BAA74F9F95F189C5767C6F5623559D9F20CC9B9C9ADFE285FA4E1BBDA481A52ABAB36A5393370091A49A59B968CFAE89BEAF33BCA5C2A9BCC1758CEEFC2D0A175C8A5CAD5C7E3FA706C2FEA55F4971A7B8A0C5D1F22A26D7DA9A70603AC34566E4929AE78C8F1926239950EC0A6E1B37D919E24431E53FB08B2F7DCDCA2EF4177BD7D2F81BFC784FBEA0471831CDCBB9E11D60C53D0E062E8BB8D98B8EE5A40960EBE10FA642751B96E1407B38A024DC64D5C2005E71198EF394673A4A0097187D2475CF27B3EAA7955AD9F412A89B36AFB27FDF7FE699B2CC8C03F7FA40549178DF8A3C1A39441EAE869BBC89D583ECB18E310885F33B95B719045CA6955720CA75D5CF0B29E5F1B9E9EAC5EC92980B2D37EF6509CCA6E67544A8116494AC7EB9032E1E8CDB053B5AC0F60DE59BBFB78E3491D50C7ADED95042A8885FE284E90C04FFC0370B92B68379B2E7D52392A42FEB26B2419CC64412BFFC036C01109B9EAEC5FAF485F0D61C37A703EAD02127611F9D25E4EC515CABE21247156F0779CAB57C35581646BB71E87941AB5D06FB3C06C423E9E83E0C07E611C89CB000344AF49498EF5C30305DDC8958F45A45E1218837269DEEDBB0AE51D2AD8B41BE425EB7AB798856911B6F0DC721756A8154B9D1CCD61092D16A3E9E1CD5E1D7C2C45D236C9B21A0ED64AD4C0660FE42FC0B543A34FB545B0D88D42F696D53BF54A1A259486846E81B44C16EF146310AEFB3933BA9F9D4497E74AFE1449D69105B9F295DB24B4563C3FC0166CB70F104B3360BC0998EFEBABC6276F570F7679865036DB59B51AD2F91C0CCD3BCF5C07492765D480494AB5B87E83FD04B75A35F88656D3329AA5FD550DBF493B0CD2C19DEBE4358661C72A71FB17C812F75BEB61302AAAA1F757288C1D8626461F4162A2EC6296B3CCABE21B4F0695F2D2CB02B86035251FC9C5F2FB5BBF28237417DC56471629B3B4C25AFEDC4C9CD108ADAD9DB1330AB680E4998C5B3D99BCE8F08156B630A63EF36A51C813CE22A6B178683EDA389ACF58653582BC2AE8170ADEC4BE03C04CBA603C0E4572A74BD9599A8442E894EB504F7703F2353A8A3525EC5535E750303AC07E08D952755F97AF236014", @@ -327,10 +332,12 @@ const std::string Galileo_E5a_Q_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { "71BB1B2E833793D854F8A9A81E6A6947057B9571F2BA99380DDB25D878D6B48F09ED7DBFACE92B6B82F413E038128F6128AF3BC467E9A4DF2861DAAC674B6D948A10F28F7D43657FEE26577AF438A2F4422186930702EBC6C9173E661D59CE7594DF95B861F9D12EB060FCD3BA43159C9A1BDC1EF13E04893E411267331588CF4831978469FF569C1A738C54001BB5CF4FABD289075A165EDE0A58F6CF6D215D306A7840CBECD0E87E3AD186F7A67A967373551E13D2956E5C578A7F5BD50E2D570F9B914848D46A640913EBED2E2ABFB86916BC34EEB3E8A671AD771F6D3780B6FEC143E26F53B02977255314BAE9A2CD9E5BA2B49C73226FDC724A859F8BAD3A9FACA1B0E5F2DFE7E1E45DB6D4BE2B76535A817F94594A4541C01BB62AA83A690B6D84FC13B632972C61D940F2C9D32837413AF8E42045ECA3072CD044B2183400CE63C418879D13FD281A8D0835256DDD2BC3C9750C1D44CF1037FD7264B7716398FCF1D31CFFD0B7C52C6370E4CE6FC163B40436490A757465B20B8890C3B5C0AFB971ABFD01796569E3BC73C13D1E4B1FBC1CDCE59D21B6B110272E5770C589603FE67779A49AD0EC66910A2BF4D8C8ECC18A32EF92F502126A5DC3DE618233B9914A9608B2F17E5161115D9A3BEF1D5701A9D465A1437DE24371C9179800CB5728A7F3D734A2A706BC64D356BDF591389970B6CC139AC510A98E3C75F20120450CE45373AAEA6A279BBD17221BCD32ECF82C11B4C1CEE0A44792CF56978D3D2399F7ECDE9F8D9217F8BA22770E210D0F1AA852178B872E296762873765A73DEC08873C04ED69C995C5751B97DEC23B94CA674FE3F66211317B074D8203EC530A20B6E6DD21AB55895BEE1CBD0876183D652F4A0D2EFC95749F8F192F860BEA534598FD709B396C209CEAE4D9190980733E7E98C8ABE52A53C68D86053B56BA6FCAB5C827292D729CB8BFD1FC8CAFCDE15E4527B604018F28AA16C1E913F55461AF87C9A7BE1A742002E52B3A14EC30B259DDE7BB892CEAF77D25B7670B339B334878F697C00CE6740117AE7C67DF3F8A7BEAC89D4872682C47F368F835AFD7ECF0D8471AD01468B7BBB0A974EC469A8F79ECF8D379DC13685D2A8F6F19CE102C3DE34B11422AFB42E894C8D00F606296DABA7123FCE039ED27324D60E853BA94DC638454088281335D437A954333FF1A8D08E2A4D25CB3BA0D08BF6625E25EAD3C1EBFA2666AA49550578D3763ECDCE81303B53F18B00C8900AF4E0532C5ECBC94513DD9F50BE511CFE4D3DDBB3F112AE148DB062B2EADDB901CDA6AB6BF59D37F356AB34AF97D3DAAAA417642E87C9B95AA546C682ED641214605F82A4F486C9C72576106F76D7152615EC8E77187D4485071CFC6B0AE44880442790696E057A3AE20C860691353B3F6BEC5F1C2DA07563B423BC01E0334099571158A432441256D7C409B7B6EF26442075ED17E2BE37F8EBC049CFBE0FA89CDA7A58DD32C417B34E899FBE86E2FAB8D30846DA17144A6A66AAE1C24FCFABDA5B573FD2D6337226B5E49BB031B4D2B455B6DB871076F67AC03C3A73CEC01BD0B1EC42ABD177127E62A66FE8E475B982B4490F0877466EEFC7317A703C5C07937340ED4B53E5DE5325197FA31B8C8E05AA2222064EE5D7C06D4A1EB53151F75C94A2E259688CA0716548465C5C255D81FF10BACC2C13098ED8CF7F5B15193EE14FB5D258E95EDCC93E9796FA823892C705A5771D561787C12592D269D657FBB71F021F365B7453D50C35F748FB2B7F36DF28769B81EF12A26A237FB0239C173559540", "53DA0E7B84741AA9E225483630169ACBCC03EB8CDA28B7BDA685C756D66B14488A2D0AEF7E6CB2D80F2726327257B7284B93EA1B56AB80FAE668C04FA49FCD658D896A997685E1EDB4DDF85456B37F32FC8CDE50882EF0F09BE4ED4AB9A425806A49E8347A42A50B38FA8D1DA2FD2C9438618B6701DEE159060C186D50170F24F38E07B185E3272EAEA4A0A7CA41A69C69E9D95E271287D3AB8284146A58440EA131A7F47D73CB2BCF40FE3A58E1B998C2E5EF9CEEC8EA2F8467BB7757C03A99FC8F014EE933A7080CD46625A2A7A251B7A37E4208956A8C9BD35E6F8674BC06FCAA5DD04A2558C9665C7985014D3AD95ED256FAFA358962EF5BB26AE2FCE899392DF858F99303E2417BCA7672E991FEB891F5DFCA2D461148367C5C0DE1460BF557194533DAF01A5E8E0E43D57B825AF7EEFF163DAA23B9F95C063A26B3D213459D885AA96023715CD21DFA2A2250F7610B78A77123443BD06EFB7DC85D1F16D0019D2937C3DEC4DE6389485ABB21642B6E41ADD43CE96F228C08DF6288A647EC2FE96032B6DCD651FF950B72964EE08FC2030272E3F601DB7F7E770E655389CA6CFA2F9B87CE76FB0E0CDCA4EEE5E80FC756BE46CC09F84BDB34ADA2AFC024ABDE0066ED939F8EBC236CB3F577C1BFD741F9D101A038EC86AB0A85462BAFB2E484D6722499A6310FA449D979030B2A21206D44225800BE2228FA00AE6D92C8DA652E1B003BD2734D30557B735CC2A591E090394DB791245C22B4D29E706476593B6F90C694C5B87BBB0FA2C479E292A768A9687A713336A21D1199186F852C41F586E9BBC64004D8BB6814BFE739834C99923177AAF87B926D56A7AFC0879C027332A60951C84E9314380A5A78E1196D094F15D856AA36742825D2B397156BCAD8ABE7291FB41DB4365AAE49CA82CA066D3B4366D3122ABBC00F05559DAFEBA9F98361DDAEF068D60B18265E7184C4D6BC9C3619CFF5C758090FF6398CCCEB78176D2A8A2A4B9854C4ACF5CB614DC1CA0E15E7E85442241D48FD3D6E851A5D3947FA769560928948FA26FA16EFBD2159994BD92B3D6B0C62818C91D4724413A7F40B2A2D67F4FC97B5DF6A7E3CEC03158E201D6643F402D3DD6995A42900D46C2881198CAD28A27489F5116ECEC3E38D999B2020E0C381DB3B8230811270D75950D9BB61548802DBBCB68ED8C7BCCB50D606BE400BECF873498621E66ABD2AA179B3E90E055C3719CE2FE047F815B95B065BA086B467AF4124E276F8CEAD000BCA5499D36217B250009A7B43E81CB3F8B1A3238EE436FE61F2F942796DBCBE570BB4FC783B35C3CA31BDD432B33AD75B08107253E8F910EFE0D0B5453A8A055D884892278688B3ECA612452B590AF38DBDD9A7070C5610E7A3CA6C91D24438E7F45E7A2A330F164AEDFFF1789D5E875EEF121298DB79C77278ABFEC3FE3DF843C46F40E847272EB2669BABA808C38E31F13516D5066AF4DFCDE6EDB2FF0B0A4CE9FA9B4101F6F144B02384868617CD39175852E065473D6F566CD18D7403FFD24DD33ADDB52C7CC22167E49102C46DC369A92CE2D2FCB81B4D1F14B7CD2F80A65D8FBD20FDAA23219873ACB8CF934E68D6F8FED6B41193CFAB1F44CE4BFC7C67DE1E8804B47DFD7E8AE281E19846AEB6FF94AE7E7CF6FFAB46242843811E6C5BDB78157C76DF4F92FD3653D7FA5978316EB055059C6A2B6306C957418860A88F63355E76D96F4727128D9B3EB98501AF5B093F2C314F98EA2CDB89468E1BD51138CBF25E8B911C26B97DCCA47F1A1D6C1CD415A5079A756B8A8715DD3164", }; + // Galileo E5a-I secondary code -const std::string Galileo_E5a_I_SECONDARY_CODE = "10000100001011101001"; +const std::string GALILEO_E5A_I_SECONDARY_CODE = "10000100001011101001"; + // Galileo E5a-Q secondary codes -const std::string Galileo_E5a_Q_SECONDARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { +const std::string GALILEO_E5A_Q_SECONDARY_CODE[GALILEO_E5A_NUMBER_OF_CODES] = { "1000001111110110111101101001110110001111011011100001010101000001000111111011100011001001101100011100", "0110011001010101100010111101001111001110000011000111011110010010111010000011001101010000010100100101", "0101100110100000001001011010100111000001101011110000011001010001101101110111100110101000001110000001", diff --git a/src/core/system_parameters/MATH_CONSTANTS.h b/src/core/system_parameters/MATH_CONSTANTS.h index 62090dd6e..3e7fa3c16 100644 --- a/src/core/system_parameters/MATH_CONSTANTS.h +++ b/src/core/system_parameters/MATH_CONSTANTS.h @@ -31,7 +31,7 @@ #ifndef GNSS_SDR_MATH_CONSTANTS_H_ #define GNSS_SDR_MATH_CONSTANTS_H_ -#include +#include /* Constants for scaling the ephemeris found in the data message the format is the following: TWO_N5 -> 2^-5, TWO_P4 -> 2^4, PI_TWO_N43 -> Pi*2^-43, etc etc @@ -46,6 +46,7 @@ const double PI = 3.1415926535897932; //!< pi const double PI_2 = 2.0 * PI; //!< 2 * pi +const double TWO_P3 = (8); //!< 2^3 const double TWO_P4 = (16); //!< 2^4 const double TWO_P11 = (2048); //!< 2^11 const double TWO_P12 = (4096); //!< 2^12 @@ -91,13 +92,14 @@ const double TWO_N44 = (5.684341886080802e-14); //!< 2^-44 const double TWO_N46 = (1.4210854715202e-014); //!< 2^-46 const double TWO_N48 = (3.552713678800501e-15); //!< 2^-46 -const double TWO_N50 = (8.881784197001252e-016); //!< 2^-50 -const double TWO_N51 = (4.44089209850063e-016); //!< 2^-51 -const double TWO_N55 = (2.775557561562891e-017); //!< 2^-55 -const double TWO_N57 = (6.938893903907228e-18); //!< 2^-57 -const double TWO_N59 = (1.73472347597681e-018); //!< 2^-59 -const double TWO_N60 = (8.673617379884036e-19); //!< 2^-60 -const double TWO_N68 = (3.388131789017201e-21); //!< 2^-68 +const double TWO_N50 = (8.881784197001252e-016); //!< 2^-50 +const double TWO_N51 = (4.44089209850063e-016); //!< 2^-51 +const double TWO_N55 = (2.775557561562891e-017); //!< 2^-55 +const double TWO_N57 = (6.938893903907228e-18); //!< 2^-57 +const double TWO_N59 = (1.73472347597681e-018); //!< 2^-59 +const double TWO_N60 = (8.673617379884036e-19); //!< 2^-60 +const double TWO_N66 = (1.3552527156068805425093160010874271392822265625e-20); //!< 2^-66 +const double TWO_N68 = (3.388131789017201e-21); //!< 2^-68 const double PI_TWO_N19 = (5.992112452678286e-006); //!< Pi*2^-19 diff --git a/src/core/system_parameters/gps_ref_location.cc b/src/core/system_parameters/agnss_ref_location.cc similarity index 86% rename from src/core/system_parameters/gps_ref_location.cc rename to src/core/system_parameters/agnss_ref_location.cc index a72d42da3..c59f8fbc4 100644 --- a/src/core/system_parameters/gps_ref_location.cc +++ b/src/core/system_parameters/agnss_ref_location.cc @@ -1,6 +1,6 @@ /*! - * \file gps_ref_location.cc - * \brief Interface of a GPS REFERENCE LOCATION storage + * \file agnss_ref_location.cc + * \brief Interface of an Assisted GNSS REFERENCE LOCATION storage * * \author Javier Arribas, 2013. jarribas(at)cttc.es * @@ -29,9 +29,9 @@ * ------------------------------------------------------------------------- */ -#include "gps_ref_location.h" +#include "agnss_ref_location.h" -Gps_Ref_Location::Gps_Ref_Location() +Agnss_Ref_Location::Agnss_Ref_Location() { valid = false; lat = 0.0; diff --git a/src/core/system_parameters/gps_ref_location.h b/src/core/system_parameters/agnss_ref_location.h similarity index 86% rename from src/core/system_parameters/gps_ref_location.h rename to src/core/system_parameters/agnss_ref_location.h index f00448ce2..083305987 100644 --- a/src/core/system_parameters/gps_ref_location.h +++ b/src/core/system_parameters/agnss_ref_location.h @@ -1,6 +1,6 @@ /*! - * \file gps_ref_location.h - * \brief Interface of a GPS REFERENCE LOCATION storage + * \file agnss_ref_location.h + * \brief Interface of an Assisted GNSS REFERENCE LOCATION storage * \author Javier Arribas, 2013. jarribas(at)cttc.es * * ------------------------------------------------------------------------- @@ -29,18 +29,18 @@ */ -#ifndef GNSS_SDR_GPS_REF_LOCATION_H_ -#define GNSS_SDR_GPS_REF_LOCATION_H_ +#ifndef GNSS_SDR_AGNSS_REF_LOCATION_H_ +#define GNSS_SDR_AGNSS_REF_LOCATION_H_ #include #include /*! - * \brief Interface of a GPS REFERENCE LOCATION storage + * \brief Interface of an Assisted GNSS REFERENCE LOCATION storage * */ -class Gps_Ref_Location +class Agnss_Ref_Location { public: bool valid; @@ -50,7 +50,7 @@ public: /*! * Default constructor */ - Gps_Ref_Location(); + Agnss_Ref_Location(); template diff --git a/src/core/system_parameters/gps_ref_time.cc b/src/core/system_parameters/agnss_ref_time.cc similarity index 88% rename from src/core/system_parameters/gps_ref_time.cc rename to src/core/system_parameters/agnss_ref_time.cc index b663abab7..0d1e8c687 100644 --- a/src/core/system_parameters/gps_ref_time.cc +++ b/src/core/system_parameters/agnss_ref_time.cc @@ -1,6 +1,6 @@ /*! - * \file gps_ref_time.cc - * \brief Interface of a GPS REFERENCE TIME storage + * \file agnss_ref_time.cc + * \brief Interface of an Assisted GNSS REFERENCE TIME storage * * \author Javier Arribas, 2013. jarribas(at)cttc.es * @@ -29,9 +29,9 @@ * ------------------------------------------------------------------------- */ -#include "gps_ref_time.h" +#include "agnss_ref_time.h" -Gps_Ref_Time::Gps_Ref_Time() +Agnss_Ref_Time::Agnss_Ref_Time() { valid = false; d_TOW = 0.0; diff --git a/src/core/system_parameters/gps_ref_time.h b/src/core/system_parameters/agnss_ref_time.h similarity index 87% rename from src/core/system_parameters/gps_ref_time.h rename to src/core/system_parameters/agnss_ref_time.h index 84af6d973..574d9106a 100644 --- a/src/core/system_parameters/gps_ref_time.h +++ b/src/core/system_parameters/agnss_ref_time.h @@ -1,6 +1,6 @@ /*! - * \file gps_ref_time.h - * \brief Interface of a GPS REFERENCE TIME storage + * \file agnss_ref_time.h + * \brief Interface of an Assisted GNSS REFERENCE TIME storage * \author Javier Arribas, 2013. jarribas(at)cttc.es * * ------------------------------------------------------------------------- @@ -29,18 +29,18 @@ */ -#ifndef GNSS_SDR_GPS_REF_TIME_H_ -#define GNSS_SDR_GPS_REF_TIME_H_ +#ifndef GNSS_SDR_AGNSS_REF_TIME_H_ +#define GNSS_SDR_AGNSS_REF_TIME_H_ #include #include /*! - * \brief Interface of a GPS REFERENCE TIME storage + * \brief Interface of an Assisted GNSS REFERENCE TIME storage * */ -class Gps_Ref_Time +class Agnss_Ref_Time { public: bool valid; @@ -51,7 +51,7 @@ public: /*! * Default constructor */ - Gps_Ref_Time(); + Agnss_Ref_Time(); template diff --git a/src/core/system_parameters/beidou_dnav_almanac.cc b/src/core/system_parameters/beidou_dnav_almanac.cc new file mode 100644 index 000000000..2e2b33526 --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_almanac.cc @@ -0,0 +1,49 @@ +/*! + * \file beidou_dnav_almanac.cc + * \brief Interface of a Beidou DNAV Almanac storage + * + * See http://www.gps.gov/technical/icwg/IS-GPS-200E.pdf Appendix II + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_dnav_almanac.h" + +Beidou_Dnav_Almanac::Beidou_Dnav_Almanac() +{ + i_satellite_PRN = 0; + d_Delta_i = 0.0; + d_Toa = 0.0; + d_M_0 = 0.0; + d_e_eccentricity = 0.0; + d_sqrt_A = 0.0; + d_OMEGA0 = 0.0; + d_OMEGA = 0.0; + d_OMEGA_DOT = 0.0; + i_SV_health = 0; + d_A_f0 = 0.0; + d_A_f1 = 0.0; +} diff --git a/src/core/system_parameters/beidou_dnav_almanac.h b/src/core/system_parameters/beidou_dnav_almanac.h new file mode 100644 index 000000000..5c31df3f6 --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_almanac.h @@ -0,0 +1,88 @@ +/*! + * \file beidou_dnav_almanac.h + * \brief Interface of a Beidou DNAV Almanac storage + * + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_BEIDOU_DNAV_ALMANAC_H_ +#define GNSS_SDR_BEIDOU_DNAV_ALMANAC_H_ + +#include +#include + + +/*! + * \brief This class is a storage for the BeiDou D1 almanac + */ +class Beidou_Dnav_Almanac +{ +public: + unsigned int i_satellite_PRN; //!< SV PRN NUMBER + double d_Delta_i; + double d_Toa; //!< Almanac data reference time of week [s] + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + double d_e_eccentricity; //!< Eccentricity [dimensionless] + double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] + double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + double d_OMEGA; //!< Argument of Perigee [semi-cicles] + double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] + int i_SV_health; // SV Health + double d_A_f0; //!< Coefficient 0 of code phase offset model [s] + double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] + + /*! + * Default constructor + */ + Beidou_Dnav_Almanac(); + + template + + void serialize(Archive& ar, const unsigned int version) + { + if (version) + { + }; + ar& BOOST_SERIALIZATION_NVP(i_satellite_PRN); + ar& BOOST_SERIALIZATION_NVP(d_Delta_i); + ar& BOOST_SERIALIZATION_NVP(d_Toa); + //ar& BOOST_SERIALIZATION_NVP(i_WNa); + ar& BOOST_SERIALIZATION_NVP(d_M_0); + ar& BOOST_SERIALIZATION_NVP(d_e_eccentricity); + ar& BOOST_SERIALIZATION_NVP(d_sqrt_A); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA0); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA_DOT); + ar& BOOST_SERIALIZATION_NVP(i_SV_health); + //ar& BOOST_SERIALIZATION_NVP(i_AS_status); + ar& BOOST_SERIALIZATION_NVP(d_A_f0); + ar& BOOST_SERIALIZATION_NVP(d_A_f1); + } +}; + +#endif diff --git a/src/core/system_parameters/beidou_dnav_ephemeris.cc b/src/core/system_parameters/beidou_dnav_ephemeris.cc new file mode 100644 index 000000000..5081daa6a --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_ephemeris.cc @@ -0,0 +1,281 @@ +/*! + * \file beidou_dnav_ephemeris.cc + * \brief Interface of a BeiDou EPHEMERIS storage and orbital model functions + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_dnav_ephemeris.h" +#include "Beidou_B1I.h" +#include "gnss_satellite.h" +#include + +Beidou_Dnav_Ephemeris::Beidou_Dnav_Ephemeris() +{ + i_satellite_PRN = 0; + d_TOW = 0; + d_Crs = 0; + d_Delta_n = 0; + d_M_0 = 0; + d_Cuc = 0; + d_eccentricity = 0; + d_Cus = 0; + d_sqrt_A = 0; + d_Toe = 0; + d_Toc = 0; + d_Cic = 0; + d_OMEGA0 = 0; + d_Cis = 0; + d_i_0 = 0; + d_Crc = 0; + d_OMEGA = 0; + d_OMEGA_DOT = 0; + d_IDOT = 0; + i_BEIDOU_week = 0; + i_SV_accuracy = 0; + i_SV_health = 0; + d_AODE = 0; + d_TGD1 = 0; + d_TGD2 = 0; + d_AODC = 0; // Issue of Data, Clock + i_AODO = 0; // Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + d_AODC = 0; + b_fit_interval_flag = false; // indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. + d_spare1 = 0; + d_spare2 = 0; + + i_sig_type = 0; + i_nav_type = 0; + + d_A_f0 = 0; // Coefficient 0 of code phase offset model [s] + d_A_f1 = 0; // Coefficient 1 of code phase offset model [s/s] + d_A_f2 = 0; // Coefficient 2 of code phase offset model [s/s^2] + + b_integrity_status_flag = false; + b_alert_flag = false; // If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. + b_antispoofing_flag = false; // If true, the AntiSpoofing mode is ON in that SV + + auto gnss_sat = Gnss_Satellite(); + std::string _system("Beidou"); + for (unsigned int i = 1; i < 36; i++) + { + satelliteBlock[i] = gnss_sat.what_block(_system, i); + } + + d_satClkDrift = 0.0; + d_dtr = 0.0; + d_satpos_X = 0.0; + d_satpos_Y = 0.0; + d_satpos_Z = 0.0; + d_satvel_X = 0.0; + d_satvel_Y = 0.0; + d_satvel_Z = 0.0; +} + + +double Beidou_Dnav_Ephemeris::check_t(double time) +{ + double corrTime; + double half_week = 302400.0; // seconds + corrTime = time; + if (time > half_week) + { + corrTime = time - 2.0 * half_week; + } + else if (time < -half_week) + { + corrTime = time + 2.0 * half_week; + } + return corrTime; +} + + +// 20.3.3.3.3.1 User Algorithm for SV Clock Correction. +double Beidou_Dnav_Ephemeris::sv_clock_drift(double transmitTime) +{ + double dt; + dt = check_t(transmitTime - d_Toc); + + for (int i = 0; i < 2; i++) + { + dt -= d_A_f0 + d_A_f1 * dt + d_A_f2 * (dt * dt); + } + d_satClkDrift = d_A_f0 + d_A_f1 * dt + d_A_f2 * (dt * dt); + + return d_satClkDrift; +} + + +// compute the relativistic correction term +double Beidou_Dnav_Ephemeris::sv_clock_relativistic_term(double transmitTime) +{ + double tk; + double a; + double n; + double n0; + double E; + double E_old; + double dE; + double M; + + // Restore semi-major axis + a = d_sqrt_A * d_sqrt_A; + + // Time from ephemeris reference epoch + tk = check_t(transmitTime - d_Toe); + + // Computed mean motion + n0 = sqrt(BEIDOU_GM / (a * a * a)); + // Corrected mean motion + n = n0 + d_Delta_n; + // Mean anomaly + M = d_M_0 + n * tk; + + // Reduce mean anomaly to between 0 and 2pi + M = fmod((M + 2.0 * BEIDOU_PI), (2.0 * BEIDOU_PI)); + + // Initial guess of eccentric anomaly + E = M; + + // --- Iteratively compute eccentric anomaly ---------------------------- + for (int ii = 1; ii < 20; ii++) + { + E_old = E; + E = M + d_eccentricity * sin(E); + dE = fmod(E - E_old, 2.0 * BEIDOU_PI); + if (fabs(dE) < 1e-12) + { + //Necessary precision is reached, exit from the loop + break; + } + } + + // Compute relativistic correction term + d_dtr = BEIDOU_F * d_eccentricity * d_sqrt_A * sin(E); + return d_dtr; +} + + +double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) +{ + double tk; + double a; + double n; + double n0; + double M; + double E; + double E_old; + double dE; + double nu; + double phi; + double u; + double r; + double i; + double Omega; + + // Find satellite's position ---------------------------------------------- + + // Restore semi-major axis + a = d_sqrt_A * d_sqrt_A; + + // Time from ephemeris reference epoch + tk = check_t(transmitTime - d_Toe); + + // Computed mean motion + n0 = sqrt(BEIDOU_GM / (a * a * a)); + + // Corrected mean motion + n = n0 + d_Delta_n; + + // Mean anomaly + M = d_M_0 + n * tk; + + // Reduce mean anomaly to between 0 and 2pi + M = fmod((M + 2.0 * BEIDOU_PI), (2.0 * BEIDOU_PI)); + + // Initial guess of eccentric anomaly + E = M; + + // --- Iteratively compute eccentric anomaly ---------------------------- + for (int ii = 1; ii < 20; ii++) + { + E_old = E; + E = M + d_eccentricity * sin(E); + dE = fmod(E - E_old, 2.0 * BEIDOU_PI); + if (fabs(dE) < 1e-12) + { + //Necessary precision is reached, exit from the loop + break; + } + } + + // Compute the true anomaly + double tmp_Y = sqrt(1.0 - d_eccentricity * d_eccentricity) * sin(E); + double tmp_X = cos(E) - d_eccentricity; + nu = atan2(tmp_Y, tmp_X); + + // Compute angle phi (argument of Latitude) + phi = nu + d_OMEGA; + + // Reduce phi to between 0 and 2*pi rad + phi = fmod((phi), (2.0 * BEIDOU_PI)); + + // Correct argument of latitude + u = phi + d_Cuc * cos(2.0 * phi) + d_Cus * sin(2.0 * phi); + + // Correct radius + r = a * (1.0 - d_eccentricity * cos(E)) + d_Crc * cos(2.0 * phi) + d_Crs * sin(2.0 * phi); + + // Correct inclination + i = d_i_0 + d_IDOT * tk + d_Cic * cos(2.0 * phi) + d_Cis * sin(2.0 * phi); + + // Compute the angle between the ascending node and the Greenwich meridian + Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT) * tk - BEIDOU_OMEGA_EARTH_DOT * d_Toe; + + // Reduce to between 0 and 2*pi rad + Omega = fmod((Omega + 2.0 * BEIDOU_PI), (2.0 * BEIDOU_PI)); + + // --- Compute satellite coordinates in Earth-fixed coordinates + d_satpos_X = cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega); + d_satpos_Y = cos(u) * r * sin(Omega) + sin(u) * r * cos(i) * cos(Omega); + d_satpos_Z = sin(u) * r * sin(i); + + // Satellite's velocity. Can be useful for Vector Tracking loops + double Omega_dot = d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT; + d_satvel_X = -Omega_dot * (cos(u) * r + sin(u) * r * cos(i)) + d_satpos_X * cos(Omega) - d_satpos_Y * cos(i) * sin(Omega); + d_satvel_Y = Omega_dot * (cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega)) + d_satpos_X * sin(Omega) + d_satpos_Y * cos(i) * cos(Omega); + d_satvel_Z = d_satpos_Y * sin(i); + + // Time from ephemeris reference clock + tk = check_t(transmitTime - d_Toc); + + double dtr_s = d_A_f0 + d_A_f1 * tk + d_A_f2 * tk * tk; + + /* relativity correction */ + dtr_s -= 2.0 * sqrt(BEIDOU_GM * a) * d_eccentricity * sin(E) / (BEIDOU_C_M_S * BEIDOU_C_M_S); + + return dtr_s; +} diff --git a/src/core/system_parameters/beidou_dnav_ephemeris.h b/src/core/system_parameters/beidou_dnav_ephemeris.h new file mode 100644 index 000000000..2cdfcfe61 --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_ephemeris.h @@ -0,0 +1,206 @@ +/*! + * \file beidou_dnav_ephemeris.h + * \brief Interface of a BEIDOU EPHEMERIS storage + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_BEIDOU_DNAV_EPHEMERIS_H_ +#define GNSS_SDR_BEIDOU_DNAV_EPHEMERIS_H_ + +#include +#include +#include + + +/*! + * \brief This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-GPS-200E + * + * See http://www.gps.gov/technical/icwg/IS-GPS-200E.pdf Appendix II + */ +class Beidou_Dnav_Ephemeris +{ +private: + /* + * Accounts for the beginning or end of week crossover + * + * See paragraph 20.3.3.3.3.1 (IS-GPS-200E) + * \param[in] - time in seconds + * \param[out] - corrected time, in seconds + */ + double check_t(double time); + +public: + unsigned int i_satellite_PRN; // SV PRN NUMBER + double d_TOW; //!< Time of BEIDOU Week of the ephemeris set (taken from subframes TOW) [s] + double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] + double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + double d_eccentricity; //!< Eccentricity [dimensionless] + double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] + double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] + double d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] + double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + double d_Cis; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] + double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] + double d_Crc; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] + double d_OMEGA; //!< Argument of Perigee [semi-cicles] + double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] + double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] + int i_BEIDOU_week; //!< BEIDOU week number, aka WN [week] + int i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) + int i_SV_health; + double d_TGD1; //!< Estimated Group Delay Differential on B1I [s] + double d_TGD2; //!< Estimated Group Delay Differential on B2I [s] + double d_AODC; //!< Age of Data, Clock + double d_AODE; //!< Age of Data, Ephemeris + int i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + + int i_sig_type; //!< BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q) */ + int i_nav_type; //!< BDS: nav type (0:unknown,1:IGSO/MEO,2:GEO) */ + + bool b_fit_interval_flag; //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. + double d_spare1; + double d_spare2; + + double d_A_f0; //!< Coefficient 0 of code phase offset model [s] + double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] + double d_A_f2; //!< Coefficient 2 of code phase offset model [s/s^2] + + /*! \brief If true, enhanced level of integrity assurance. + * + * If false, indicates that the conveying signal is provided with the legacy level of integrity assurance. + * That is, the probability that the instantaneous URE of the conveying signal exceeds 4.42 times the upper bound + * value of the current broadcast URA index, for more than 5.2 seconds, without an accompanying alert, is less + * than 1E-5 per hour. If true, indicates that the conveying signal is provided with an enhanced level of + * integrity assurance. That is, the probability that the instantaneous URE of the conveying signal exceeds 5.73 + * times the upper bound value of the current broadcast URA index, for more than 5.2 seconds, without an + * accompanying alert, is less than 1E-8 per hour. + */ + bool b_integrity_status_flag; + bool b_alert_flag; //!< If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. + bool b_antispoofing_flag; //!< If true, the AntiSpoofing mode is ON in that SV + + // clock terms derived from ephemeris data + double d_satClkDrift; //!< GPS clock error + double d_dtr; //!< relativistic clock correction term + + // satellite positions + double d_satpos_X; //!< Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and the plane passing through the origin and normal to the Z-axis. + double d_satpos_Y; //!< Earth-fixed coordinate y of the satellite [m]. Completes a right-handed, Earth-Centered, Earth-Fixed orthogonal coordinate system. + double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). + + // Satellite velocity + double d_satvel_X; //!< Earth-fixed velocity coordinate x of the satellite [m] + double d_satvel_Y; //!< Earth-fixed velocity coordinate y of the satellite [m] + double d_satvel_Z; //!< Earth-fixed velocity coordinate z of the satellite [m] + + std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + + template + + /*! + * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. + */ + void serialize(Archive& archive, const unsigned int version) + { + using boost::serialization::make_nvp; + if (version) + { + }; + + archive& make_nvp("i_satellite_PRN", i_satellite_PRN); // SV PRN NUMBER + archive& make_nvp("d_TOW", d_TOW); //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] + archive& make_nvp("d_AODE", d_AODE); + archive& make_nvp("d_Crs", d_Crs); //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] + archive& make_nvp("d_Delta_n", d_Delta_n); //!< Mean Motion Difference From Computed Value [semi-circles/s] + archive& make_nvp("d_M_0", d_M_0); //!< Mean Anomaly at Reference Time [semi-circles] + archive& make_nvp("d_Cuc", d_Cuc); //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + archive& make_nvp("d_e_eccentricity", d_eccentricity); //!< Eccentricity [dimensionless] + archive& make_nvp("d_Cus", d_Cus); //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] + archive& make_nvp("d_sqrt_A", d_sqrt_A); //!< Square Root of the Semi-Major Axis [sqrt(m)] + archive& make_nvp("d_Toe", d_Toe); //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + archive& make_nvp("d_Toc", d_Toe); //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + archive& make_nvp("d_Cic", d_Cic); //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] + archive& make_nvp("d_OMEGA0", d_OMEGA0); //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + archive& make_nvp("d_Cis", d_Cis); //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] + archive& make_nvp("d_i_0", d_i_0); //!< Inclination Angle at Reference Time [semi-circles] + archive& make_nvp("d_Crc", d_Crc); //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] + archive& make_nvp("d_OMEGA", d_OMEGA); //!< Argument of Perigee [semi-cicles] + archive& make_nvp("d_OMEGA_DOT", d_OMEGA_DOT); //!< Rate of Right Ascension [semi-circles/s] + archive& make_nvp("d_IDOT", d_IDOT); //!< Rate of Inclination Angle [semi-circles/s] + archive& make_nvp("i_BEIDOU_week", i_BEIDOU_week); //!< GPS week number, aka WN [week] + archive& make_nvp("i_SV_accuracy", i_SV_accuracy); //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) + archive& make_nvp("i_SV_health", i_SV_health); + archive& make_nvp("d_AODC", d_AODC); //!< Issue of Data, Clock + archive& make_nvp("d_TGD1", d_TGD1); //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + archive& make_nvp("d_TGD2", d_TGD2); //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + archive& make_nvp("i_AODO", i_AODO); //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + + archive& make_nvp("b_fit_interval_flag", b_fit_interval_flag); //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. + archive& make_nvp("d_spare1", d_spare1); + archive& make_nvp("d_spare2", d_spare2); + + archive& make_nvp("d_A_f0", d_A_f0); //!< Coefficient 0 of code phase offset model [s] + archive& make_nvp("d_A_f1", d_A_f1); //!< Coefficient 1 of code phase offset model [s/s] + archive& make_nvp("d_A_f2", d_A_f2); //!< Coefficient 2 of code phase offset model [s/s^2] + + archive& make_nvp("b_integrity_status_flag", b_integrity_status_flag); + archive& make_nvp("b_alert_flag", b_alert_flag); //!< If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. + archive& make_nvp("b_antispoofing_flag", b_antispoofing_flag); //!< If true, the AntiSpoofing mode is ON in that SV + } + + /*! + * \brief Compute the ECEF SV coordinates and ECEF velocity + * Implementation of Table 20-IV (IS-GPS-200E) + * and compute the clock bias term including relativistic effect (return value) + */ + double satellitePosition(double transmitTime); + + /*! + * \brief Sets (\a d_satClkDrift)and returns the clock drift in seconds according to the User Algorithm for SV Clock Correction + * (IS-GPS-200E, 20.3.3.3.3.1) + */ + double sv_clock_drift(double transmitTime); + + /*! + * \brief Sets (\a d_dtr) and returns the clock relativistic correction term in seconds according to the User Algorithm for SV Clock Correction + * (IS-GPS-200E, 20.3.3.3.3.1) + */ + double sv_clock_relativistic_term(double transmitTime); + + + /*! + * Default constructor + */ + Beidou_Dnav_Ephemeris(); +}; + +#endif diff --git a/src/core/system_parameters/beidou_dnav_iono.cc b/src/core/system_parameters/beidou_dnav_iono.cc new file mode 100644 index 000000000..a0a20743b --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_iono.cc @@ -0,0 +1,44 @@ +/*! + * \file beidou_dnav_iono.cc + * \brief Interface of a BEIDOU IONOSPHERIC MODEL storage + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_dnav_iono.h" + +Beidou_Dnav_Iono::Beidou_Dnav_Iono() +{ + valid = false; + d_alpha0 = 0.0; + d_alpha1 = 0.0; + d_alpha2 = 0.0; + d_alpha3 = 0.0; + d_beta0 = 0.0; + d_beta1 = 0.0; + d_beta2 = 0.0; + d_beta3 = 0.0; +} diff --git a/src/core/system_parameters/beidou_dnav_iono.h b/src/core/system_parameters/beidou_dnav_iono.h new file mode 100644 index 000000000..2349360bc --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_iono.h @@ -0,0 +1,80 @@ +/*! + * \file beidou_dnav_iono.h + * \brief Interface of a BEIDOU IONOSPHERIC MODEL storage + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_BEIDOU_DNAV_IONO_H_ +#define GNSS_SDR_BEIDOU_DNAV_IONO_H_ + +#include + + +/*! + * \brief This class is a storage for the BEIDOU IONOSPHERIC data as described in ICD v2.1 + * + */ +class Beidou_Dnav_Iono +{ +public: + bool valid; //!< Valid flag + // Ionospheric parameters + double d_alpha0; //!< Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s] + double d_alpha1; //!< Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle] + double d_alpha2; //!< Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2] + double d_alpha3; //!< Coefficient 3 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^3] + double d_beta0; //!< Coefficient 0 of a cubic equation representing the period of the model [s] + double d_beta1; //!< Coefficient 1 of a cubic equation representing the period of the model [s/semi-circle] + double d_beta2; //!< Coefficient 2 of a cubic equation representing the period of the model [s(semi-circle)^2] + double d_beta3; //!< Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3] + + Beidou_Dnav_Iono(); //!< Default constructor + + template + + /*! + * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. + */ + void serialize(Archive& archive, const unsigned int version) + { + using boost::serialization::make_nvp; + if (version) + { + }; + archive& make_nvp("d_alpha0", d_alpha0); + archive& make_nvp("d_alpha1", d_alpha1); + archive& make_nvp("d_alpha2", d_alpha2); + archive& make_nvp("d_alpha3", d_alpha3); + archive& make_nvp("d_beta0", d_beta0); + archive& make_nvp("d_beta1", d_beta1); + archive& make_nvp("d_beta2", d_beta2); + archive& make_nvp("d_beta3", d_beta3); + } +}; + +#endif diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.cc b/src/core/system_parameters/beidou_dnav_navigation_message.cc new file mode 100644 index 000000000..e280d07f8 --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_navigation_message.cc @@ -0,0 +1,1244 @@ +/*! + * \file beidou_dnav_navigation_message.cc + * \brief Implementation of a BeiDou D1 NAV Data message decoder as described + * in BeiDou ICD Version 2.1 + * + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * \author Damian Miralles, 2018. dmiralles2009@gmail.com + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_dnav_navigation_message.h" +#include "gnss_satellite.h" +#include // for boost::crc_basic, boost::crc_optimal +#include +#include +#include +#include +#include +#include + + +void Beidou_Dnav_Navigation_Message::reset() +{ + // Control variable for message decoding + flag_eph_valid = false; + flag_iono_valid = false; + flag_utc_model_valid = false; + flag_crc_test = false; + + flag_d1_sf1 = false; + flag_d1_sf2 = false; + flag_d1_sf3 = false; + flag_d1_sf4 = false; + flag_d1_sf5 = false; + flag_d1_sf5_p7 = false; + flag_d1_sf5_p8 = false; + flag_d1_sf5_p9 = false; + flag_d1_sf5_p10 = false; + flag_new_SOW_available = false; + d_previous_aode = 0.0; + + flag_sf1_p1 = false; + flag_sf1_p2 = false; + flag_sf1_p3 = false; + flag_sf1_p4 = false; + flag_sf1_p5 = false; + flag_sf1_p6 = false; + flag_sf1_p7 = false; + flag_sf1_p8 = false; + flag_sf1_p9 = false; + flag_sf1_p10 = false; + + // D2 NAV Decoding UNique Attributes + d_A_f1_msb_bits = 0; + d_A_f1_lsb_bits = 0; + d_Cuc_msb_bits = 0; + d_Cuc_lsb_bits = 0; + d_eccentricity_msb_bits = 0; + d_eccentricity_lsb_bits = 0; + d_Cic_msb_bits = 0; + d_Cic_lsb_bits = 0; + d_i_0_msb_bits = 0; + d_i_0_lsb_bits = 0; + d_OMEGA_msb_bits = 0; + d_OMEGA_lsb_bits = 0; + d_OMEGA_DOT_msb_bits = 0; + d_OMEGA_DOT_lsb_bits = 0; + + // D2 NAV Decoding UNique Attributes + d_eccentricity_msb = 0; + d_eccentricity_lsb = 0; + + d_SOW = 0.0; + d_SOW_SF1 = 0.0; + d_SOW_SF2 = 0.0; + d_SOW_SF3 = 0.0; + d_SOW_SF4 = 0.0; + d_SOW_SF5 = 0.0; + d_AODE = 0.0; + d_Crs = 0.0; + d_Delta_n = 0.0; + d_M_0 = 0.0; + d_Cuc = 0.0; + d_eccentricity = 0.0; + d_Cus = 0.0; + d_sqrt_A = 0.0; + d_Toe_sf2 = 0.0; + d_Toe_sf3 = 0.0; + d_Toe = 0.0; + d_Toc = 0.0; + d_Cic = 0.0; + d_OMEGA0 = 0.0; + d_Cis = 0.0; + d_i_0 = 0.0; + d_Crc = 0.0; + d_OMEGA = 0.0; + d_OMEGA_DOT = 0.0; + d_IDOT = 0.0; + i_BEIDOU_week = 0; + i_SV_accuracy = 0; + i_SV_health = 0; + d_TGD1 = 0.0; + d_TGD2 = 0.0; + d_AODC = -1.0; + // i_AODO = 0; + + b_fit_interval_flag = false; + d_spare1 = 0.0; + d_spare2 = 0.0; + + d_A_f0 = 0.0; + d_A_f1 = 0.0; + d_A_f2 = 0.0; + + //clock terms + //d_master_clock=0; + d_dtr = 0.0; + d_satClkCorr = 0.0; + d_satClkDrift = 0.0; + + // satellite positions + d_satpos_X = 0.0; + d_satpos_Y = 0.0; + d_satpos_Z = 0.0; + + // info + i_channel_ID = 0; + i_satellite_PRN = 0; + + // time synchro + d_subframe_timestamp_ms = 0.0; + + // flags + b_alert_flag = false; + b_integrity_status_flag = false; + b_antispoofing_flag = false; + + // Ionosphere and UTC + flag_iono_valid = false; + flag_utc_model_valid = false; + d_alpha0 = 0.0; + d_alpha1 = 0.0; + d_alpha2 = 0.0; + d_alpha3 = 0.0; + d_beta0 = 0.0; + d_beta1 = 0.0; + d_beta2 = 0.0; + d_beta3 = 0.0; + d_A1UTC = 0.0; + d_A0UTC = 0.0; + d_DeltaT_LS = 0.0; + i_WN_LSF = 0; + i_DN = 0; + d_DeltaT_LSF = 0.0; + + //Almanac + d_Toa = 0.0; + i_WN_A = 0; + for (int32_t i = 1; i < 36; i++) + { + almanacHealth[i] = 0; + } + + // Satellite velocity + d_satvel_X = 0.0; + d_satvel_Y = 0.0; + d_satvel_Z = 0.0; + d_A1GPS = 0.0; + d_A0GPS = 0.0; + d_A1GAL = 0.0; + d_A0GAL = 0.0; + d_A1GLO = 0.0; + d_A0GLO = 0.0; + d_SQRT_A_ALMANAC = 0.0; + d_A1_ALMANAC = 0.0; + d_A0_ALMANAC = 0.0; + d_OMEGA0_ALMANAC = 0.0; + d_E_ALMANAC = 0.0; + d_DELTA_I = 0.0; + d_TOA = 0.0; + d_OMEGA_DOT_ALMANAC = 0.0; + d_OMEGA_ALMANAC = 0.0; + d_M0_ALMANAC = 0.0; + almanac_WN = 0; + d_toa2 = 0.0; + d_A_f0 = 0.0; + d_A_f1 = 0.0; + d_A_f2 = 0.0; + + auto gnss_sat = Gnss_Satellite(); + std::string _system("Beidou"); + for (uint32_t i = 1; i < 36; i++) + { + satelliteBlock[i] = gnss_sat.what_block(_system, i); + } +} + + +Beidou_Dnav_Navigation_Message::Beidou_Dnav_Navigation_Message() +{ + reset(); +} + + +void Beidou_Dnav_Navigation_Message::print_beidou_word_bytes(uint32_t BEIDOU_word) +{ + std::cout << " Word ="; + std::cout << std::bitset<32>(BEIDOU_word); + std::cout << std::endl; +} + + +bool Beidou_Dnav_Navigation_Message::read_navigation_bool( + std::bitset bits, + const std::vector>& parameter) +{ + bool value; + + if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first] == 1) + { + value = true; + } + else + { + value = false; + } + return value; +} + + +uint64_t Beidou_Dnav_Navigation_Message::read_navigation_unsigned( + std::bitset bits, + const std::vector>& parameter) +{ + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) + { + value <<= 1; // shift left + if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) + { + value += 1; // insert the bit + } + } + } + return value; +} + + +int64_t Beidou_Dnav_Navigation_Message::read_navigation_signed( + std::bitset bits, + const std::vector>& parameter) +{ + int64_t value = 0; + int32_t num_of_slices = parameter.size(); + // Discriminate between 64 bits and 32 bits compiler + int32_t long_int_size_bytes = sizeof(int64_t); + if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system + { + // read the MSB and perform the sign extension + if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first] == 1) + { + value ^= 0xFFFFFFFFFFFFFFFF; // 64 bits variable + } + else + { + value &= 0; + } + + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) + { + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) + if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) + { + value += 1; // insert the bit + } + } + } + } + else // we assume we are in a 32 bits system + { + // read the MSB and perform the sign extension + if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first] == 1) + { + value ^= 0xFFFFFFFF; + } + else + { + value &= 0; + } + + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) + { + value <<= 1; // shift left + value &= 0xFFFFFFFE; // reset the corresponding bit + if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) + { + value += 1; // insert the bit + } + } + } + } + return value; +} + + +double Beidou_Dnav_Navigation_Message::check_t(double time) +{ + double corrTime; + double half_week = 302400; // seconds + corrTime = time; + if (time > half_week) + { + corrTime = time - 2 * half_week; + } + else if (time < -half_week) + { + corrTime = time + 2 * half_week; + } + return corrTime; +} + + +double Beidou_Dnav_Navigation_Message::sv_clock_correction(double transmitTime) +{ + double dt; + dt = check_t(transmitTime - d_Toc); + d_satClkCorr = (d_A_f2 * dt + d_A_f1) * dt + d_A_f0 + d_dtr; + double correctedTime = transmitTime - d_satClkCorr; + return correctedTime; +} + + +void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) +{ + double tk; + double a; + double n; + double n0; + double M; + double E; + double E_old; + double dE; + double nu; + double phi; + double u; + double r; + double i; + double Omega; + + // Find satellite's position ---------------------------------------------- + + // Restore semi-major axis + a = d_sqrt_A * d_sqrt_A; + + // Time from ephemeris reference epoch + tk = check_t(transmitTime - d_Toe_sf2); + + // Computed mean motion + n0 = sqrt(BEIDOU_GM / (a * a * a)); + + // Corrected mean motion + n = n0 + d_Delta_n; + + // Mean anomaly + M = d_M_0 + n * tk; + + // Reduce mean anomaly to between 0 and 2pi + M = fmod((M + 2 * BEIDOU_PI), (2 * BEIDOU_PI)); + + // Initial guess of eccentric anomaly + E = M; + + // --- Iteratively compute eccentric anomaly ---------------------------- + for (int32_t ii = 1; ii < 20; ii++) + { + E_old = E; + E = M + d_eccentricity * sin(E); + dE = fmod(E - E_old, 2 * BEIDOU_PI); + if (fabs(dE) < 1e-12) + { + //Necessary precision is reached, exit from the loop + break; + } + } + + // Compute relativistic correction term + d_dtr = BEIDOU_F * d_eccentricity * d_sqrt_A * sin(E); + + // Compute the true anomaly + double tmp_Y = sqrt(1.0 - d_eccentricity * d_eccentricity) * sin(E); + double tmp_X = cos(E) - d_eccentricity; + nu = atan2(tmp_Y, tmp_X); + + // Compute angle phi (argument of Latitude) + phi = nu + d_OMEGA; + + // Reduce phi to between 0 and 2*pi rad + phi = fmod((phi), (2 * BEIDOU_PI)); + + // Correct argument of latitude + u = phi + d_Cuc * cos(2 * phi) + d_Cus * sin(2 * phi); + + // Correct radius + r = a * (1 - d_eccentricity * cos(E)) + d_Crc * cos(2 * phi) + d_Crs * sin(2 * phi); + + // Correct inclination + i = d_i_0 + d_IDOT * tk + d_Cic * cos(2 * phi) + d_Cis * sin(2 * phi); + + // Compute the angle between the ascending node and the Greenwich meridian + Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT) * tk - BEIDOU_OMEGA_EARTH_DOT * d_Toe_sf2; + + // Reduce to between 0 and 2*pi rad + Omega = fmod((Omega + 2 * BEIDOU_PI), (2 * BEIDOU_PI)); + + // --- Compute satellite coordinates in Earth-fixed coordinates + d_satpos_X = cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega); + d_satpos_Y = cos(u) * r * sin(Omega) + sin(u) * r * cos(i) * cos(Omega); + d_satpos_Z = sin(u) * r * sin(i); + + // Satellite's velocity. Can be useful for Vector Tracking loops + double Omega_dot = d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT; + d_satvel_X = -Omega_dot * (cos(u) * r + sin(u) * r * cos(i)) + d_satpos_X * cos(Omega) - d_satpos_Y * cos(i) * sin(Omega); + d_satvel_Y = Omega_dot * (cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega)) + d_satpos_X * sin(Omega) + d_satpos_Y * cos(i) * cos(Omega); + d_satvel_Z = d_satpos_Y * sin(i); +} + + +int32_t Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& subframe) +{ + int32_t subframe_ID = 0; + std::bitset subframe_bits(subframe); + + subframe_ID = static_cast(read_navigation_unsigned(subframe_bits, D1_FRAID)); + + // Perform crc computtaion (tbd) + flag_crc_test = true; + + // Decode all 5 sub-frames + switch (subframe_ID) + { + case 1: // --- It is subframe 1 --- + d_SOW_SF1 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); + d_SOW = d_SOW_SF1; // Set transmission time + + i_SV_health = static_cast(read_navigation_unsigned(subframe_bits, D1_SAT_H1)); + + d_AODC = static_cast(read_navigation_unsigned(subframe_bits, D1_AODC)); + i_SV_accuracy = static_cast(read_navigation_unsigned(subframe_bits, D1_URAI)); // (20.3.3.3.1.3) + + i_BEIDOU_week = static_cast(read_navigation_unsigned(subframe_bits, D1_WN)); + + d_Toc = static_cast(read_navigation_unsigned(subframe_bits, D1_TOC)); + d_Toc = d_Toc * D1_TOC_LSB; + + d_TGD1 = static_cast(read_navigation_signed(subframe_bits, D1_TGD1)); + d_TGD1 = d_TGD1 * D1_TGD1_LSB; + + d_TGD2 = static_cast(read_navigation_signed(subframe_bits, D1_TGD2)); + d_TGD2 = d_TGD2 * D1_TGD2_LSB; + + d_alpha0 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA0)); + d_alpha0 = d_alpha0 * D1_ALPHA0_LSB; + + d_alpha1 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA1)); + d_alpha1 = d_alpha1 * D1_ALPHA1_LSB; + d_alpha2 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA2)); + d_alpha2 = d_alpha2 * D1_ALPHA2_LSB; + d_alpha3 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA3)); + d_alpha3 = d_alpha3 * D1_ALPHA3_LSB; + d_beta0 = static_cast(read_navigation_signed(subframe_bits, D1_BETA0)); + d_beta0 = d_beta0 * D1_BETA0_LSB; + d_beta1 = static_cast(read_navigation_signed(subframe_bits, D1_BETA1)); + d_beta1 = d_beta1 * D1_BETA1_LSB; + d_beta2 = static_cast(read_navigation_signed(subframe_bits, D1_BETA2)); + d_beta2 = d_beta2 * D1_BETA2_LSB; + d_beta3 = static_cast(read_navigation_signed(subframe_bits, D1_BETA3)); + d_beta3 = d_beta3 * D1_BETA3_LSB; + + d_A_f2 = static_cast(read_navigation_signed(subframe_bits, D1_A2)); + d_A_f2 = d_A_f2 * D1_A2_LSB; + d_A_f0 = static_cast(read_navigation_signed(subframe_bits, D1_A0)); + d_A_f0 = d_A_f0 * D1_A0_LSB; + d_A_f1 = static_cast(read_navigation_signed(subframe_bits, D1_A1)); + d_A_f1 = d_A_f1 * D1_A1_LSB; + + d_AODE = static_cast(read_navigation_unsigned(subframe_bits, D1_AODE)); + + // Set system flags for message reception + flag_d1_sf1 = true; + flag_iono_valid = true; + flag_new_SOW_available = true; + + break; + + case 2: // --- It is subframe 2 --- + d_SOW_SF2 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); + d_SOW = d_SOW_SF2; // Set transmission time + + d_Cuc = static_cast(read_navigation_signed(subframe_bits, D1_CUC)); + d_Cuc = d_Cuc * D1_CUC_LSB; + + d_M_0 = static_cast(read_navigation_signed(subframe_bits, D1_M0)); + d_M_0 = d_M_0 * D1_M0_LSB; + + d_eccentricity = static_cast(read_navigation_unsigned(subframe_bits, D1_E)); + d_eccentricity = d_eccentricity * D1_E_LSB; + + d_Cus = static_cast(read_navigation_signed(subframe_bits, D1_CUS)); + d_Cus = d_Cus * D1_CUS_LSB; + + d_Crc = static_cast(read_navigation_signed(subframe_bits, D1_CRC)); + d_Crc = d_Crc * D1_CRC_LSB; + + d_Crs = static_cast(read_navigation_signed(subframe_bits, D1_CRS)); + d_Crs = d_Crs * D1_CRS_LSB; + + d_sqrt_A = static_cast(read_navigation_unsigned(subframe_bits, D1_SQRT_A)); + d_sqrt_A = d_sqrt_A * D1_SQRT_A_LSB; + + d_Toe_sf2 = static_cast(read_navigation_unsigned(subframe_bits, D1_TOE_SF2)); + d_Toe_sf2 = static_cast((static_cast(d_Toe_sf2) << 15)); + + // Set system flags for message reception + flag_d1_sf2 = true; + flag_new_SOW_available = true; + + break; + + case 3: // --- It is subframe 3 --- + d_SOW_SF3 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); + d_SOW = d_SOW_SF3; // Set transmission time + + d_Toe_sf3 = static_cast(read_navigation_unsigned(subframe_bits, D1_TOE_SF3)); + + d_i_0 = static_cast(read_navigation_signed(subframe_bits, D1_I0)); + d_i_0 = d_i_0 * D1_I0_LSB; + + d_Cic = static_cast(read_navigation_signed(subframe_bits, D1_CIC)); + d_Cic = d_Cic * D1_CIC_LSB; + + d_OMEGA_DOT = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA_DOT)); + d_OMEGA_DOT = d_OMEGA_DOT * D1_OMEGA_DOT_LSB; + + d_Cis = static_cast(read_navigation_signed(subframe_bits, D1_CIS)); + d_Cis = d_Cis * D1_CIS_LSB; + + d_IDOT = static_cast(read_navigation_signed(subframe_bits, D1_IDOT)); + d_IDOT = d_IDOT * D1_IDOT_LSB; + + d_OMEGA0 = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA0)); + d_OMEGA0 = d_OMEGA0 * D1_OMEGA0_LSB; + + d_OMEGA = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA)); + d_OMEGA = d_OMEGA * D1_OMEGA_LSB; + + // Set system flags for message reception + flag_d1_sf3 = true; + flag_new_SOW_available = true; + + break; + + case 4: // --- It is subframe 4 --- + d_SOW_SF4 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); + d_SOW = d_SOW_SF4; // Set transmission time + + d_SQRT_A_ALMANAC = static_cast(read_navigation_unsigned(subframe_bits, D1_SQRT_A_ALMANAC)); + d_SQRT_A_ALMANAC = d_SQRT_A_ALMANAC * D1_SQRT_A_ALMANAC_LSB; + + d_A1_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_A1_ALMANAC)); + d_A1_ALMANAC = d_A1_ALMANAC * D1_A1_ALMANAC_LSB; + + d_A0_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_A0_ALMANAC)); + d_A0_ALMANAC = d_A0_ALMANAC * D1_A0_ALMANAC_LSB; + + d_OMEGA0_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA0_ALMANAC)); + d_OMEGA0_ALMANAC = d_OMEGA0_ALMANAC * D1_OMEGA0_ALMANAC_LSB; + + d_E_ALMANAC = static_cast(read_navigation_unsigned(subframe_bits, D1_E)); + d_E_ALMANAC = d_E_ALMANAC * D1_E_ALMANAC_LSB; + + d_DELTA_I = static_cast(read_navigation_signed(subframe_bits, D1_DELTA_I)); + d_DELTA_I = D1_DELTA_I_LSB; + + d_TOA = static_cast(read_navigation_unsigned(subframe_bits, D1_TOA)); + d_TOA = d_TOA * D1_TOA_LSB; + + d_OMEGA_DOT_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA_DOT_ALMANAC)); + d_OMEGA_DOT_ALMANAC = D1_OMEGA_DOT_ALMANAC_LSB; + + d_OMEGA_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA_ALMANAC)); + d_OMEGA_ALMANAC = d_OMEGA_ALMANAC * D1_OMEGA_ALMANAC_LSB; + + d_M0_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_M0)); + d_M0_ALMANAC = d_M0_ALMANAC * D1_M0_ALMANAC_LSB; + + // Set system flags for message reception + flag_d1_sf4 = true; + flag_new_SOW_available = true; + + break; + + case 5: // --- It is subframe 5 --- + int32_t SV_page_5; + d_SOW_SF5 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); + d_SOW = d_SOW_SF5; // Set transmission time + + SV_page_5 = static_cast(read_navigation_unsigned(subframe_bits, D1_PNUM)); + + if (SV_page_5 < 7) + { + d_SOW_SF4 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); + d_SQRT_A_ALMANAC = static_cast(read_navigation_unsigned(subframe_bits, D1_SQRT_A_ALMANAC)); + d_SQRT_A_ALMANAC = d_SQRT_A_ALMANAC * D1_SQRT_A_ALMANAC_LSB; + + d_A1_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_A1_ALMANAC)); + d_A1_ALMANAC = d_A1_ALMANAC * D1_A1_ALMANAC_LSB; + + d_A0_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_A0_ALMANAC)); + d_A0_ALMANAC = d_A0_ALMANAC * D1_A0_ALMANAC_LSB; + + d_OMEGA0_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA0_ALMANAC)); + d_OMEGA0_ALMANAC = d_OMEGA0_ALMANAC * D1_OMEGA0_ALMANAC_LSB; + + d_E_ALMANAC = static_cast(read_navigation_unsigned(subframe_bits, D1_E)); + d_E_ALMANAC = d_E_ALMANAC * D1_E_ALMANAC_LSB; + + d_DELTA_I = static_cast(read_navigation_signed(subframe_bits, D1_DELTA_I)); + d_DELTA_I = D1_DELTA_I_LSB; + + d_TOA = static_cast(read_navigation_unsigned(subframe_bits, D1_TOA)); + d_TOA = d_TOA * D1_TOA_LSB; + + d_OMEGA_DOT_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA_DOT_ALMANAC)); + d_OMEGA_DOT_ALMANAC = D1_OMEGA_DOT_ALMANAC_LSB; + + d_OMEGA_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_OMEGA_ALMANAC)); + d_OMEGA_ALMANAC = d_OMEGA_ALMANAC * D1_OMEGA_ALMANAC_LSB; + + d_M0_ALMANAC = static_cast(read_navigation_signed(subframe_bits, D1_M0)); + d_M0_ALMANAC = d_M0_ALMANAC * D1_M0_ALMANAC_LSB; + } + + if (SV_page_5 == 7) + { + almanacHealth[1] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA1)); + almanacHealth[2] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA2)); + almanacHealth[3] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA3)); + almanacHealth[4] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA4)); + almanacHealth[5] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA5)); + almanacHealth[6] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA6)); + almanacHealth[7] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA7)); + almanacHealth[8] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA8)); + almanacHealth[9] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA9)); + almanacHealth[10] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA10)); + almanacHealth[11] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA11)); + almanacHealth[12] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA12)); + almanacHealth[13] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA13)); + almanacHealth[14] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA14)); + almanacHealth[15] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA15)); + almanacHealth[16] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA16)); + almanacHealth[17] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA17)); + almanacHealth[18] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA18)); + almanacHealth[19] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA19)); + } + if (SV_page_5 == 8) + { + almanacHealth[20] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA20)); + almanacHealth[21] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA21)); + almanacHealth[22] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA22)); + almanacHealth[23] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA23)); + almanacHealth[24] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA24)); + almanacHealth[25] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA25)); + almanacHealth[26] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA26)); + almanacHealth[27] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA27)); + almanacHealth[28] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA28)); + almanacHealth[29] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA29)); + almanacHealth[30] = static_cast(read_navigation_unsigned(subframe_bits, D1_HEA30)); + almanac_WN = static_cast(read_navigation_unsigned(subframe_bits, D1_WNA)); + d_toa2 = static_cast(read_navigation_unsigned(subframe_bits, D1_TOA2)); + } + + if (SV_page_5 == 9) + { + d_A0GPS = static_cast(read_navigation_signed(subframe_bits, D1_A0GPS)) * D1_A0GPS_LSB; + d_A1GPS = static_cast(read_navigation_signed(subframe_bits, D1_A1GPS)) * D1_A1GPS_LSB; + d_A0GAL = static_cast(read_navigation_signed(subframe_bits, D1_A0GAL)) * D1_A0GAL_LSB; + d_A1GAL = static_cast(read_navigation_signed(subframe_bits, D1_A1GAL)) * D1_A1GAL_LSB; + d_A0GLO = static_cast(read_navigation_signed(subframe_bits, D1_A0GLO)) * D1_A0GLO_LSB; + d_A1GLO = static_cast(read_navigation_signed(subframe_bits, D1_A1GLO)) * D1_A1GLO_LSB; + + flag_d1_sf5_p9 = true; + } + if (SV_page_5 == 10) + { + d_DeltaT_LS = static_cast(read_navigation_signed(subframe_bits, D1_DELTA_T_LS)); + d_DeltaT_LSF = static_cast(read_navigation_signed(subframe_bits, D1_DELTA_T_LSF)); + i_WN_LSF = static_cast(read_navigation_signed(subframe_bits, D1_WN_LSF)); + d_A0UTC = static_cast(read_navigation_signed(subframe_bits, D1_A0UTC)); + d_A0UTC = d_A0GPS * D1_A0GPS_LSB; + d_A1UTC = static_cast(read_navigation_signed(subframe_bits, D1_A1UTC)); + d_A1UTC = d_A1UTC * D1_A1UTC_LSB; + + flag_d1_sf5_p10 = true; + } + + // Set system flags for message reception + flag_d1_sf5 = true; + flag_new_SOW_available = true; + + break; + + default: + break; + } // switch subframeID ... + + return subframe_ID; +} + + +int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& subframe) +{ + int32_t subframe_ID = 0; + int32_t page_ID = 0; + + std::bitset subframe_bits(subframe); + + subframe_ID = static_cast(read_navigation_unsigned(subframe_bits, D2_FRAID)); + page_ID = static_cast(read_navigation_unsigned(subframe_bits, D2_PNUM)); + + // Perform crc computtaion (tbd) + flag_crc_test = true; + + // Decode all 5 sub-frames + switch (subframe_ID) + { + //--- Decode the sub-frame id ------------------------------------------ + case 1: + + switch (page_ID) + { + case 1: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + i_SV_health = static_cast(read_navigation_unsigned(subframe_bits, D2_SAT_H1)); + d_AODC = static_cast(read_navigation_unsigned(subframe_bits, D2_AODC)); + i_SV_accuracy = static_cast(read_navigation_unsigned(subframe_bits, D2_URAI)); // (20.3.3.3.1.3) + i_BEIDOU_week = static_cast(read_navigation_unsigned(subframe_bits, D2_WN)); + d_Toc = static_cast(read_navigation_unsigned(subframe_bits, D2_TOC)) * D1_TOC_LSB; + d_TGD1 = static_cast(read_navigation_signed(subframe_bits, D2_TGD1)) * D1_TGD1_LSB; + + // Set system flags for message reception + flag_sf1_p1 = true; + flag_new_SOW_available = true; + + break; + case 2: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_alpha0 = static_cast(read_navigation_signed(subframe_bits, D2_ALPHA0)) * D1_ALPHA0_LSB; + d_alpha1 = static_cast(read_navigation_signed(subframe_bits, D2_ALPHA1)) * D1_ALPHA1_LSB; + d_alpha2 = static_cast(read_navigation_signed(subframe_bits, D2_ALPHA2)) * D1_ALPHA2_LSB; + d_alpha3 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA3)) * D1_ALPHA3_LSB; + d_beta0 = static_cast(read_navigation_signed(subframe_bits, D2_BETA0)) * D1_BETA0_LSB; + d_beta1 = static_cast(read_navigation_signed(subframe_bits, D2_BETA1)) * D1_BETA1_LSB; + d_beta2 = static_cast(read_navigation_signed(subframe_bits, D2_BETA2)) * D1_BETA2_LSB; + d_beta3 = static_cast(read_navigation_signed(subframe_bits, D2_BETA3)) * D1_BETA3_LSB; + + // Set system flags for message reception + flag_sf1_p2 = true; + flag_iono_valid = true; + flag_new_SOW_available = true; + + break; + case 3: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_A_f0 = static_cast(read_navigation_signed(subframe_bits, D2_A0)) * D1_A0_LSB; + d_A_f1_msb_bits = (read_navigation_unsigned(subframe_bits, D2_A1_MSB)); + // Adjust for lsb in next page + d_A_f1_msb_bits = d_A_f1_msb_bits << 18; + + // Set system flags for message reception + flag_sf1_p3 = true; + flag_new_SOW_available = true; + + break; + case 4: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_A_f1_lsb_bits = (read_navigation_unsigned(subframe_bits, D2_A1_LSB)); + d_A_f2 = static_cast(read_navigation_signed(subframe_bits, D1_A2)) * D1_A2_LSB; + d_AODE = static_cast(read_navigation_unsigned(subframe_bits, D2_AODE)); + d_Delta_n = static_cast(read_navigation_signed(subframe_bits, D2_DELTA_N)) * D1_DELTA_N_LSB; + d_Cuc_msb_bits = (read_navigation_unsigned(subframe_bits, D2_CUC_MSB)); + // Adjust for lsb in next page + d_Cuc_msb_bits = d_Cuc_msb_bits << 4; + + // Set system flags for message reception + flag_sf1_p4 = true; + flag_new_SOW_available = true; + + break; + case 5: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_Cuc_lsb_bits = (read_navigation_unsigned(subframe_bits, D2_CUC_LSB)); + d_M_0 = static_cast(read_navigation_signed(subframe_bits, D2_M0)) * D1_M0_LSB; + d_Cus = static_cast(read_navigation_signed(subframe_bits, D2_CUS)) * D1_CUS_LSB; + d_eccentricity_msb = static_cast(read_navigation_unsigned(subframe_bits, D2_E_MSB)); + d_eccentricity_msb_bits = (read_navigation_unsigned(subframe_bits, D2_E_MSB)); + // Adjust for lsb in next page (shift number of lsb to the left) + d_eccentricity_msb = d_eccentricity_msb << 22; + d_eccentricity_msb_bits = d_eccentricity_msb_bits << 22; + + // Set system flags for message reception + flag_sf1_p5 = true; + flag_new_SOW_available = true; + + break; + case 6: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_eccentricity_lsb = static_cast(read_navigation_unsigned(subframe_bits, D2_E_LSB)); + d_eccentricity_lsb_bits = (read_navigation_unsigned(subframe_bits, D2_E_LSB)); + d_sqrt_A = static_cast(read_navigation_unsigned(subframe_bits, D2_SQRT_A)) * D1_SQRT_A_LSB; + d_Cic_msb_bits = (read_navigation_unsigned(subframe_bits, D2_CIC_MSB)); + // Adjust for lsb in next page (shift number of lsb to the left) + d_Cic_msb_bits = d_Cic_msb_bits << 8; + + // Set system flags for message reception + flag_sf1_p6 = true; + flag_new_SOW_available = true; + + break; + case 7: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_Cic_lsb_bits = (read_navigation_unsigned(subframe_bits, D2_CIC_LSB)); + d_Cis = static_cast(read_navigation_signed(subframe_bits, D2_CIS)) * D1_CIS_LSB; + d_Toe = static_cast(read_navigation_unsigned(subframe_bits, D2_TOE)) * D1_TOE_LSB; + d_i_0_msb_bits = (read_navigation_unsigned(subframe_bits, D2_I0_MSB)); + // Adjust for lsb in next page (shift number of lsb to the left) + d_i_0_msb_bits = d_i_0_msb_bits << 11; + + // Set system flags for message reception + flag_sf1_p7 = true; + flag_new_SOW_available = true; + + break; + case 8: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_i_0_lsb_bits = (read_navigation_unsigned(subframe_bits, D2_I0_LSB)); + d_Crc = static_cast(read_navigation_signed(subframe_bits, D2_CRC)) * D1_CRC_LSB; + d_Crs = static_cast(read_navigation_signed(subframe_bits, D2_CRS)) * D1_CRS_LSB; + d_OMEGA_DOT_msb_bits = (read_navigation_unsigned(subframe_bits, D2_OMEGA_DOT_MSB)); + // Adjust for lsb in next page (shift number of lsb to the left) + d_OMEGA_DOT_msb_bits = d_OMEGA_DOT_msb_bits << 5; + + // Set system flags for message reception + flag_sf1_p8 = true; + flag_new_SOW_available = true; + + break; + case 9: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_OMEGA_DOT_lsb_bits = (read_navigation_unsigned(subframe_bits, D2_OMEGA_DOT_LSB)); + d_OMEGA0 = static_cast(read_navigation_signed(subframe_bits, D2_OMEGA0)) * D1_OMEGA0_LSB; + d_OMEGA_msb_bits = (read_navigation_unsigned(subframe_bits, D2_OMEGA_MSB)); + // Adjust for lsb in next page (shift number of lsb to the left) + d_OMEGA_msb_bits = d_OMEGA_msb_bits << 5; + + // Set system flags for message reception + flag_sf1_p9 = true; + flag_new_SOW_available = true; + + break; + case 10: + d_SOW = static_cast(read_navigation_unsigned(subframe_bits, D2_SOW)); + d_OMEGA_lsb_bits = (read_navigation_unsigned(subframe_bits, D2_OMEGA_LSB)); + d_IDOT = static_cast(read_navigation_signed(subframe_bits, D2_IDOT)) * D1_IDOT_LSB; + + // Set system flags for message reception + flag_sf1_p10 = true; + flag_new_SOW_available = true; + + break; + default: + break; + } + + break; + + case 2: //--- It is subframe 2 ------------------- + + break; + + case 3: // --- It is subframe 3 ------------------------------------- + + break; + + case 4: // --- It is subframe 4 ---------- Almanac, ionospheric model, UTC parameters, SV health (PRN: 25-32) + + break; + + case 5: //--- It is subframe 5 -----------------almanac health (PRN: 1-24) and Almanac reference week number and time. + + break; + + default: + break; + } // switch subframeID ... + + return subframe_ID; +} + + +double Beidou_Dnav_Navigation_Message::utc_time(const double beidoutime_corrected) const +{ + double t_utc; + double t_utc_daytime; + double Delta_t_UTC = d_DeltaT_LS + d_A0UTC + d_A1UTC * (beidoutime_corrected); + + // Determine if the effectivity time of the leap second event is in the past + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_BEIDOU_week; + + if ((weeksToLeapSecondEvent) >= 0) // is not in the past + { + //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + if (weeksToLeapSecondEvent > 0) + { + t_utc_daytime = fmod(beidoutime_corrected - Delta_t_UTC, 86400); + } + else //we are in the same week than the leap second event + { + if ((beidoutime_corrected - secondOfLeapSecondEvent) < (2 / 3) * 24 * 60 * 60) + { + t_utc_daytime = fmod(beidoutime_corrected - Delta_t_UTC, 86400); + } + else + { + if ((beidoutime_corrected - secondOfLeapSecondEvent) < (5 / 4) * 24 * 60 * 60) + { + int32_t W = fmod(beidoutime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); + } + else + { + t_utc_daytime = fmod(beidoutime_corrected - Delta_t_UTC, 86400); + } + } + } + } + else // the effectivity time is in the past + { + t_utc_daytime = fmod(beidoutime_corrected - Delta_t_UTC, 86400); + } + + double secondsOfWeekBeforeToday = 43200 * floor(beidoutime_corrected / 43200); + t_utc = secondsOfWeekBeforeToday + t_utc_daytime; + return t_utc; +} + + +Beidou_Dnav_Ephemeris Beidou_Dnav_Navigation_Message::get_ephemeris() +{ + Beidou_Dnav_Ephemeris eph; + + if (i_satellite_PRN > 0 and i_satellite_PRN < 6) + { + std::bitset subframe_bits; + + // Order as given by eph_t in rtklib + eph.i_satellite_PRN = i_satellite_PRN; + eph.d_AODC = d_AODC; + eph.d_AODE = d_AODE; + eph.i_SV_accuracy = i_SV_accuracy; + eph.i_SV_health = i_SV_health; + eph.i_BEIDOU_week = i_BEIDOU_week; + eph.i_sig_type = 1; + eph.i_nav_type = 2; + + eph.d_TOW = d_SOW; + eph.d_Toe = d_Toe; + eph.d_Toc = d_Toc; + + eph.d_sqrt_A = d_sqrt_A; + eph.d_eccentricity = (d_eccentricity_msb + d_eccentricity_lsb) * D1_E_LSB; + subframe_bits = std::bitset(d_i_0_msb_bits + d_i_0_lsb_bits); + eph.d_i_0 = static_cast(read_navigation_signed(subframe_bits, D2_I0)) * D1_I0_LSB; + eph.d_OMEGA0 = d_OMEGA0; + subframe_bits = std::bitset(d_OMEGA_msb_bits + d_OMEGA_lsb_bits); + eph.d_OMEGA = static_cast(read_navigation_signed(subframe_bits, D2_OMEGA)) * D1_OMEGA_LSB; + eph.d_M_0 = d_M_0; + eph.d_Delta_n = d_Delta_n; + + subframe_bits = std::bitset(d_OMEGA_DOT_msb_bits + d_OMEGA_DOT_lsb_bits); + eph.d_OMEGA_DOT = static_cast(read_navigation_signed(subframe_bits, D2_OMEGA_DOT)) * D1_OMEGA_DOT_LSB; + eph.d_IDOT = d_IDOT; + + eph.d_Crc = d_Crc; + eph.d_Crs = d_Crs; + subframe_bits = std::bitset(d_Cuc_msb_bits + d_Cuc_lsb_bits); + eph.d_Cuc = static_cast(read_navigation_signed(subframe_bits, D2_CUC)) * D1_CUC_LSB; + eph.d_Cus = d_Cus; + subframe_bits = std::bitset(d_Cic_msb_bits + d_Cic_lsb_bits); + eph.d_Cic = static_cast(read_navigation_signed(subframe_bits, D2_CIC)) * D1_CIC_LSB; + eph.d_Cis = d_Cis; + + eph.d_A_f0 = d_A_f0; + subframe_bits = std::bitset(d_A_f1_msb_bits + d_A_f1_lsb_bits); + eph.d_A_f1 = static_cast(read_navigation_signed(subframe_bits, D2_A1)) * D1_A1_LSB; + eph.d_A_f2 = d_A_f2; + + + eph.d_TGD1 = d_TGD1; + eph.d_TGD2 = d_TGD2; + } + else + { + eph.i_satellite_PRN = i_satellite_PRN; + eph.d_AODC = d_AODC; + eph.d_AODE = d_AODE; + eph.i_SV_accuracy = i_SV_accuracy; + eph.i_SV_health = i_SV_health; + eph.i_BEIDOU_week = i_BEIDOU_week; + eph.i_sig_type = 1; + eph.i_nav_type = 1; // MEO/IGSO + + eph.d_TOW = d_SOW; + eph.d_Toe = ((d_Toe_sf2 + d_Toe_sf3) * D1_TOE_LSB); + eph.d_Toc = d_Toc; + + eph.d_sqrt_A = d_sqrt_A; + eph.d_eccentricity = d_eccentricity; + eph.d_i_0 = d_i_0; + eph.d_OMEGA0 = d_OMEGA0; + eph.d_OMEGA = d_OMEGA; + eph.d_M_0 = d_M_0; + eph.d_Delta_n = d_Delta_n; + eph.d_OMEGA_DOT = d_OMEGA_DOT; + eph.d_IDOT = d_IDOT; + + eph.d_Crc = d_Crc; + eph.d_Crs = d_Crs; + eph.d_Cuc = d_Cuc; + eph.d_Cus = d_Cus; + eph.d_Cic = d_Cic; + eph.d_Cis = d_Cis; + + eph.d_A_f0 = d_A_f0; + eph.d_A_f1 = d_A_f1; + eph.d_A_f2 = d_A_f2; + + eph.d_TGD1 = d_TGD1; + eph.d_TGD2 = d_TGD2; + } + + return eph; +} + + +Beidou_Dnav_Iono Beidou_Dnav_Navigation_Message::get_iono() +{ + Beidou_Dnav_Iono iono; + iono.d_alpha0 = d_alpha0; + iono.d_alpha1 = d_alpha1; + iono.d_alpha2 = d_alpha2; + iono.d_alpha3 = d_alpha3; + iono.d_beta0 = d_beta0; + iono.d_beta1 = d_beta1; + iono.d_beta2 = d_beta2; + iono.d_beta3 = d_beta3; + iono.valid = flag_iono_valid; + //WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue + flag_iono_valid = false; + return iono; +} + + +Beidou_Dnav_Utc_Model Beidou_Dnav_Navigation_Message::get_utc_model() +{ + Beidou_Dnav_Utc_Model utc_model; + utc_model.valid = flag_utc_model_valid; + // UTC parameters + utc_model.d_A1_UTC = d_A1UTC; + utc_model.d_A0_UTC = d_A0UTC; + utc_model.d_DeltaT_LS = d_DeltaT_LS; + utc_model.i_WN_LSF = i_WN_LSF; + utc_model.i_DN = i_DN; + utc_model.d_DeltaT_LSF = d_DeltaT_LSF; + + utc_model.d_A0_GPS = d_A0GPS; + utc_model.d_A1_GPS = d_A1GPS; + utc_model.d_A0_GAL = d_A0GAL; + utc_model.d_A1_GAL = d_A1GAL; + utc_model.d_A0_GLO = d_A0GLO; + utc_model.d_A1_GLO = d_A1GLO; + + // warning: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue + flag_utc_model_valid = false; + return utc_model; +} + + +bool Beidou_Dnav_Navigation_Message::have_new_ephemeris() // Check if we have a new ephemeris stored in the galileo navigation class +{ + if (i_satellite_PRN > 0 and i_satellite_PRN < 6) + { + if ((flag_sf1_p1 == true) and (flag_sf1_p2 == true) and (flag_sf1_p3 == true) and + (flag_sf1_p4 == true) and (flag_sf1_p5 == true) and (flag_sf1_p6 == true) and + (flag_sf1_p7 == true) and (flag_sf1_p8 == true) and (flag_sf1_p9 == true) and + (flag_sf1_p10 == true)) + { + // if all ephemeris pages have the same IOD, then they belong to the same block + if (d_previous_aode != d_AODE) + { + // Clear flags for all received pages + flag_sf1_p1 = false; + flag_sf1_p2 = false; + flag_sf1_p3 = false; + flag_sf1_p4 = false; + flag_sf1_p5 = false; + flag_sf1_p6 = false; + flag_sf1_p7 = false; + flag_sf1_p8 = false; + flag_sf1_p9 = false; + flag_sf1_p10 = false; + + flag_eph_valid = true; + // Update the time of ephemeris information + d_previous_aode = d_AODE; + + return true; + } + } + } + else + { + if ((flag_d1_sf1 == true) and (flag_d1_sf2 == true) and (flag_d1_sf3 == true)) + { + // if all ephemeris pages have the same IOD, then they belong to the same block + if (d_previous_aode != d_AODE) + { + // Clear flags for all received subframes + flag_d1_sf1 = false; + flag_d1_sf2 = false; + flag_d1_sf3 = false; + + flag_eph_valid = true; + // Update the time of ephemeris information + d_previous_aode = d_AODE; + + return true; + } + } + } + return false; +} + + +bool Beidou_Dnav_Navigation_Message::have_new_iono() +{ + // the condition on flag_utc_model is added to have a time stamp for iono + if (flag_iono_valid == true) + { + return true; + } + + return false; +} + + +bool Beidou_Dnav_Navigation_Message::have_new_utc_model() +{ + if (flag_d1_sf5_p9 == true and flag_d1_sf5_p10 == true) + { + flag_d1_sf5_p9 = false; + flag_d1_sf5_p10 = false; + flag_utc_model_valid = true; + + return true; + } + + return false; +} + + +bool Beidou_Dnav_Navigation_Message::have_new_almanac() +{ + if ((flag_d1_sf4 == true) and (flag_d1_sf5 == true)) + { + // All almanac have been received + flag_d1_sf4 = false; + flag_d1_sf5 = false; + + return true; + } + + return false; +} + + +bool Beidou_Dnav_Navigation_Message::satellite_validation() +{ + bool flag_data_valid = false; + flag_eph_valid = false; + + // First Step: + // check Issue Of Ephemeris Data (AODE AODC..) to find a possible interrupted reception + // and check if the data have been filled (!=0) + if (d_SOW_SF1 != 0 and d_SOW_SF2 != 0 and d_SOW_SF3 != 0) + { + if (d_AODC != -1) + { + flag_data_valid = true; + flag_eph_valid = true; + } + } + return flag_data_valid; +} diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.h b/src/core/system_parameters/beidou_dnav_navigation_message.h new file mode 100644 index 000000000..93c1c9a24 --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_navigation_message.h @@ -0,0 +1,328 @@ +/*! + * \file beidou_dnav_navigation_message.h + * \brief Interface of a BeiDou DNAV Data message decoder + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * \author Damian Miralles, 2018. dmiralles2009@gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_BEIDOU_DNAV_NAVIGATION_MESSAGE_H_ +#define GNSS_SDR_BEIDOU_DNAV_NAVIGATION_MESSAGE_H_ + + +#include "Beidou_B1I.h" +#include "beidou_dnav_almanac.h" +#include "beidou_dnav_ephemeris.h" +#include "beidou_dnav_iono.h" +#include "beidou_dnav_utc_model.h" +#include +#include +#include +#include +#include + + +/*! + * \brief This class decodes a BeiDou D1 NAV Data message as described in IS-GPS-200E + * + * See http://www.gps.gov/technical/icwg/IS-GPS-200E.pdf Appendix II + */ +class Beidou_Dnav_Navigation_Message +{ +private: + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector>& parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector>& parameter); + bool read_navigation_bool(std::bitset bits, const std::vector>& parameter); + void print_beidou_word_bytes(uint32_t BEIDOU_word); + /* + * Accounts for the beginning or end of week crossover + * + * See paragraph 20.3.3.3.3.1 (IS-GPS-200E) + * \param[in] - time in seconds + * \param[out] - corrected time, in seconds + */ + double check_t(double time); + +public: + // System flags for data processing + bool flag_eph_valid; + bool flag_utc_model_valid; + bool flag_iono_valid; + bool flag_d1_sf1; + bool flag_d1_sf2; + bool flag_d1_sf3; + bool flag_d1_sf4; + bool flag_d1_sf5; + bool flag_new_SOW_available; + bool flag_crc_test; + double d_previous_aode; + + bool flag_d1_sf5_p7; //!< D1 NAV Message, Subframe 5, Page 09 decoded indicator + bool flag_d1_sf5_p8; //!< D1 NAV Message, Subframe 5, Page 09 decoded indicator + bool flag_d1_sf5_p9; //!< D1 NAV Message, Subframe 5, Page 09 decoded indicator + bool flag_d1_sf5_p10; //!< D1 NAV Message, Subframe 5, Page 10 decoded indicator + + + bool flag_sf1_p1; //!< D2 NAV Message, Subframe 1, Page 1 decoded indicator + bool flag_sf1_p2; //!< D2 NAV Message, Subframe 1, Page 2 decoded indicator + bool flag_sf1_p3; //!< D2 NAV Message, Subframe 1, Page 3 decoded indicator + bool flag_sf1_p4; //!< D2 NAV Message, Subframe 1, Page 4 decoded indicator + bool flag_sf1_p5; //!< D2 NAV Message, Subframe 1, Page 5 decoded indicator + bool flag_sf1_p6; //!< D2 NAV Message, Subframe 1, Page 6 decoded indicator + bool flag_sf1_p7; //!< D2 NAV Message, Subframe 1, Page 7 decoded indicator + bool flag_sf1_p8; //!< D2 NAV Message, Subframe 1, Page 8 decoded indicator + bool flag_sf1_p9; //!< D2 NAV Message, Subframe 1, Page 9 decoded indicator + bool flag_sf1_p10; //!< D2 NAV Message, Subframe 1, Page 10 decoded indicator + + //broadcast orbit 1 + double d_SOW; //!< Time of BeiDou Week of the ephemeris set (taken from subframes SOW) [s] + double d_SOW_SF1; //!< Time of BeiDou Week from HOW word of Subframe 1 [s] + double d_SOW_SF2; //!< Time of BeiDou Week from HOW word of Subframe 2 [s] + double d_SOW_SF3; //!< Time of BeiDou Week from HOW word of Subframe 3 [s] + double d_SOW_SF4; //!< Time of BeiDou Week from HOW word of Subframe 4 [s] + double d_SOW_SF5; //!< Time of BeiDou Week from HOW word of Subframe 5 [s] + + double d_AODE; + double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] + double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + //broadcast orbit 2 + double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + double d_eccentricity; //!< Eccentricity [dimensionless] + double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] + double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] + //broadcast orbit 3 + double d_Toe_sf2; //!< Ephemeris data reference time of week in subframe 2, D1 Message + double d_Toe_sf3; //!< Ephemeris data reference time of week in subframe 3, D1 Message + double d_Toe; //!< Ephemeris data reference time of week in subframe 1, D2 Message + double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] + double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + double d_Cis; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] + //broadcast orbit 4 + double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] + double d_Crc; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] + double d_OMEGA; //!< Argument of Perigee [semi-cicles] + double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] + //broadcast orbit 5 + double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] + int32_t i_BEIDOU_week; //!< BeiDou week number, aka WN [week] + //broadcast orbit 6 + int32_t i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV + int32_t i_SV_health; + double d_TGD1; //!< Estimated Group Delay Differential in B1 [s] + double d_TGD2; //!< Estimated Group Delay Differential in B2 [s] + double d_AODC; //!< Age of Data, Clock + //broadcast orbit 7 + // int32_t i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + + bool b_fit_interval_flag; //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. + double d_spare1; + double d_spare2; + + double d_A_f0; //!< Clock correction parameters. Coefficient 0 of code phase offset model [s] + double d_A_f1; //!< Clock correction parameters. Coefficient 1 of code phase offset model [s/s] + double d_A_f2; //!< Clock correction parameters. Coefficient 2 of code phase offset model [s/s^2] + + // D2 NAV Message Decoding + uint64_t d_A_f1_msb_bits; //!< Clock correction parameters, D2 NAV MSB + uint64_t d_A_f1_lsb_bits; //!< Clock correction parameters, D2 NAV LSB + uint64_t d_Cuc_msb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_Cuc_lsb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_eccentricity_msb; //!< Eccentricity [dimensionless] + uint64_t d_eccentricity_lsb; //!< Eccentricity [dimensionless] + uint64_t d_Cic_msb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_Cic_lsb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_eccentricity_msb_bits; //!< Eccentricity [dimensionless] + uint64_t d_eccentricity_lsb_bits; + uint64_t d_i_0_msb_bits; //!< Inclination Angle at Reference Time [semi-circles] + uint64_t d_i_0_lsb_bits; //!< Inclination Angle at Reference Time [semi-circles] + uint64_t d_OMEGA_msb_bits; //!< Argument of Perigee [semi-cicles] + uint64_t d_OMEGA_lsb_bits; //!< Argument of Perigee [semi-cicles] + uint64_t d_OMEGA_DOT_msb_bits; //!< Rate of Right Ascension [semi-circles/s] + uint64_t d_OMEGA_DOT_lsb_bits; //!< Rate of Right Ascension [semi-circles/s] + + // Almanac + double d_Toa; //!< Almanac reference time [s] + int32_t i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced + std::map almanacHealth; //!< Map that stores the health information stored in the almanac + + std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + + // Flags + + /*! \brief If true, enhanced level of integrity assurance. + * + * If false, indicates that the conveying signal is provided with the legacy level of integrity assurance. + * That is, the probability that the instantaneous URE of the conveying signal exceeds 4.42 times the upper bound + * value of the current broadcast URA index, for more than 5.2 seconds, without an accompanying alert, is less + * than 1E-5 per hour. If true, indicates that the conveying signal is provided with an enhanced level of + * integrity assurance. That is, the probability that the instantaneous URE of the conveying signal exceeds 5.73 + * times the upper bound value of the current broadcast URA index, for more than 5.2 seconds, without an + * accompanying alert, is less than 1E-8 per hour. + */ + bool b_integrity_status_flag; + bool b_alert_flag; //!< If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. + bool b_antispoofing_flag; //!< If true, the AntiSpoofing mode is ON in that SV + + // clock terms + //double d_master_clock; // GPS transmission time + double d_satClkCorr; // GPS clock error + double d_dtr; // relativistic clock correction term + double d_satClkDrift; + + // satellite positions + double d_satpos_X; //!< Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and the plane passing through the origin and normal to the Z-axis. + double d_satpos_Y; //!< Earth-fixed coordinate y of the satellite [m]. Completes a right-handed, Earth-Centered, Earth-Fixed orthogonal coordinate system. + double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). + + // satellite identification info + int32_t i_channel_ID; + uint32_t i_satellite_PRN; + + // time synchro + double d_subframe_timestamp_ms; //[ms] + + // Ionospheric parameters + double d_alpha0; //!< Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s] + double d_alpha1; //!< Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle] + double d_alpha2; //!< Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2] + double d_alpha3; //!< Coefficient 3 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^3] + double d_beta0; //!< Coefficient 0 of a cubic equation representing the period of the model [s] + double d_beta1; //!< Coefficient 1 of a cubic equation representing the period of the model [s/semi-circle] + double d_beta2; //!< Coefficient 2 of a cubic equation representing the period of the model [s(semi-circle)^2] + double d_beta3; //!< Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3] + + // UTC parameters + double d_A1UTC; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] + double d_A0UTC; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] + double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] + double d_A1GPS; + double d_A0GPS; + double d_A1GAL; + double d_A0GAL; + double d_A1GLO; + double d_A0GLO; + + double d_SQRT_A_ALMANAC; + double d_A1_ALMANAC; + double d_A0_ALMANAC; + double d_OMEGA0_ALMANAC; + double d_E_ALMANAC; + double d_DELTA_I; + double d_TOA; + double d_OMEGA_DOT_ALMANAC; + double d_OMEGA_ALMANAC; + double d_M0_ALMANAC; + int32_t almanac_WN; + double d_toa2; + + // Satellite velocity + double d_satvel_X; //!< Earth-fixed velocity coordinate x of the satellite [m] + double d_satvel_Y; //!< Earth-fixed velocity coordinate y of the satellite [m] + double d_satvel_Z; //!< Earth-fixed velocity coordinate z of the satellite [m] + + + // public functions + void reset(); + + /*! + * \brief Obtain a GPS SV Ephemeris class filled with current SV data + */ + Beidou_Dnav_Ephemeris get_ephemeris(); + + /*! + * \brief Obtain a GPS ionospheric correction parameters class filled with current SV data + */ + Beidou_Dnav_Iono get_iono(); + + /*! + * \brief Obtain a GPS UTC model parameters class filled with current SV data + */ + Beidou_Dnav_Utc_Model get_utc_model(); + + + /*! + * \brief Decodes the BDS D1 NAV message + */ + int32_t d1_subframe_decoder(std::string const& subframe); + + /*! + * \brief Decodes the BDS D2 NAV message + */ + int32_t d2_subframe_decoder(std::string const& subframe); + + /*! + * \brief Computes the position of the satellite + * + * Implementation of Table 20-IV (IS-GPS-200E) + */ + void satellitePosition(double transmitTime); + + /*! + * \brief Sets (\a d_satClkCorr) according to the User Algorithm for SV Clock Correction + * and returns the corrected clock (IS-GPS-200E, 20.3.3.3.3.1) + */ + double sv_clock_correction(double transmitTime); + + /*! + * \brief Computes the Coordinated Universal Time (UTC) and + * returns it in [s] (IS-GPS-200E, 20.3.3.5.2.4) + */ + double utc_time(const double beidoutime_corrected) const; + + bool satellite_validation(); + + /* + * \brief Returns true if new Ephemeris has arrived. The flag is set to false when the function is executed + */ + bool have_new_ephemeris(); + + /* + * \brief Returns true if new Iono model has arrived. The flag is set to false when the function is executed + */ + bool have_new_iono(); + + /* + * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed + */ + bool have_new_utc_model(); + + /* + * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed + */ + bool have_new_almanac(); + /*! + * Default constructor + */ + Beidou_Dnav_Navigation_Message(); +}; + +#endif diff --git a/src/core/system_parameters/beidou_dnav_utc_model.cc b/src/core/system_parameters/beidou_dnav_utc_model.cc new file mode 100644 index 000000000..1997f9276 --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_utc_model.cc @@ -0,0 +1,51 @@ +/*! + * \file beidou_dnav_utc_model.cc + * \brief Interface of a BeiDou UTC Model storage + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "beidou_dnav_utc_model.h" + + +Beidou_Dnav_Utc_Model::Beidou_Dnav_Utc_Model() +{ + valid = false; + d_A1_UTC = 0; + d_A0_UTC = 0; + d_DeltaT_LS = 0; + i_WN_LSF = 0; + i_DN = 0; + d_DeltaT_LSF = 0; + + d_A0_GPS = 0; + d_A1_GPS = 0; + d_A0_GAL = 0; + d_A1_GAL = 0; + d_A0_GLO = 0; + d_A1_GLO = 0; +} diff --git a/src/core/system_parameters/beidou_dnav_utc_model.h b/src/core/system_parameters/beidou_dnav_utc_model.h new file mode 100644 index 000000000..8ca6a1929 --- /dev/null +++ b/src/core/system_parameters/beidou_dnav_utc_model.h @@ -0,0 +1,97 @@ +/*! + * \file beidou_dnav_utc_model.h + * \brief Interface of a BeiDou UTC MODEL storage + * \author Damian Miralles, 2018. dmiralles2009@gmail.com + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_BEIDOU_DNAV_UTC_MODEL_H_ +#define GNSS_SDR_BEIDOU_DNAV_UTC_MODEL_H_ + +#include + + +/*! + * \brief This class is a storage for the BeiDou DNAV UTC Model. + * \details Implementation follows the interface described in the Open Service Signal (Version 2.1) + * + */ +class Beidou_Dnav_Utc_Model +{ +public: + bool valid; + + // BeiDou UTC parameters + double d_A0_UTC; //!< BDT clock bias relative to UTC [s] + double d_A1_UTC; //!< BDT clock rate relative to UTC [s/s] + double d_DeltaT_LS; //!< Delta time due to leap seconds before the new leap second effective + int i_WN_LSF; //!< Week number of the new leap second + int i_DN; //!< Day number of week of the new leap second + double d_DeltaT_LSF; //!< Delta time due to leap seconds after the new leap second effective [s] + + // BeiDou to GPS time corrections + double d_A0_GPS; //!< BDT clock bias relative to GPS time [s] + double d_A1_GPS; //!< BDT clock rate relative to GPS time [s/s] + + // BeiDou to Galileo time corrections + double d_A0_GAL; //!< BDT clock bias relative to GAL time [s] + double d_A1_GAL; //!< BDT clock rate relative to GAL time [s/s] + + // BeiDou to GLONASS time corrections + double d_A0_GLO; //!< BDT clock bias relative to GLO time [s] + double d_A1_GLO; //!< BDT clock rate relative to GLO time [s/s] + + Beidou_Dnav_Utc_Model(); + + template + /* + * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. + */ + inline void serialize(Archive& archive, const unsigned int version) + { + using boost::serialization::make_nvp; + if (version) + { + }; + archive& make_nvp("valid", valid); + archive& make_nvp("d_A1", d_A1_UTC); + archive& make_nvp("d_A0", d_A0_UTC); + archive& make_nvp("d_DeltaT_LS", d_DeltaT_LS); + archive& make_nvp("i_WN_LSF", i_WN_LSF); + archive& make_nvp("i_DN", i_DN); + archive& make_nvp("d_DeltaT_LSF", d_DeltaT_LSF); + archive& make_nvp("d_A0_GPS", d_A0_GPS); + archive& make_nvp("d_A0_GPS", d_A1_GPS); + archive& make_nvp("d_A0_GPS", d_A0_GAL); + archive& make_nvp("d_A0_GPS", d_A1_GAL); + archive& make_nvp("d_A0_GPS", d_A0_GLO); + archive& make_nvp("d_A0_GPS", d_A1_GLO); + } +}; + +#endif diff --git a/src/core/system_parameters/galileo_almanac.cc b/src/core/system_parameters/galileo_almanac.cc index bce27a9aa..6dbc7b25e 100644 --- a/src/core/system_parameters/galileo_almanac.cc +++ b/src/core/system_parameters/galileo_almanac.cc @@ -1,7 +1,7 @@ /*! * \file galileo_almanac.cc - * \brief Implementation of a Galileo ALMANAC storage - * \author Javier Arribas, 2013. jarribas(at)cttc.es + * \brief Interface of a Galileo ALMANAC storage + * \author Carles Fernandez, 2018. cfernandez(at)cttc.cat * * ------------------------------------------------------------------------- * @@ -30,66 +30,23 @@ #include "galileo_almanac.h" + Galileo_Almanac::Galileo_Almanac() { - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ - IOD_a_7 = 0; - WN_a_7 = 0.0; - t0a_7 = 0.0; - SVID1_7 = 0; - DELTA_A_7 = 0.0; - e_7 = 0.0; - omega_7 = 0.0; - delta_i_7 = 0.0; - Omega0_7 = 0.0; - Omega_dot_7 = 0.0; - M0_7 = 0.0; - - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ - IOD_a_8 = 0; - af0_8 = 0.0; - af1_8 = 0.0; - E5b_HS_8 = 0.0; - E1B_HS_8 = 0.0; - E5a_HS_8 = 0.0; - SVID2_8 = 0; - DELTA_A_8 = 0.0; - e_8 = 0.0; - omega_8 = 0.0; - delta_i_8 = 0.0; - Omega0_8 = 0.0; - Omega_dot_8 = 0.0; - - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ - IOD_a_9 = 0; - WN_a_9 = 0.0; - t0a_9 = 0.0; - M0_9 = 0.0; - af0_9 = 0.0; - af1_9 = 0.0; - E5b_HS_9 = 0.0; - E1B_HS_9 = 0.0; - E5a_HS_9 = 0.0; - SVID3_9 = 0; - DELTA_A_9 = 0.0; - e_9 = 0.0; - omega_9 = 0.0; - delta_i_9 = 0.0; - - /*Word type 10: Almanac for SVID3 (2/2)*/ - IOD_a_10 = 0; - Omega0_10 = 0.0; - Omega_dot_10 = 0.0; - M0_10 = 0.0; - af0_10 = 0.0; - af1_10 = 0.0; - E5b_HS_10 = 0.0; - E1B_HS_10 = 0.0; - E5a_HS_10 = 0.0; - - /*GPS to Galileo GST conversion parameters*/ - A_0G_10 = 0.0; - A_1G_10 = 0.0; - t_0G_10 = 0.0; - WN_0G_10 = 0.0; + i_satellite_PRN = 0U; + i_Toa = 0; + i_WNa = 0; + i_IODa = 0; + d_Delta_i = 0.0; + d_M_0 = 0.0; + d_e_eccentricity = 0.0; + d_Delta_sqrt_A = 0.0; + d_OMEGA0 = 0.0; + d_OMEGA = 0.0; + d_OMEGA_DOT = 0.0; + d_A_f0 = 0.0; + d_A_f1 = 0.0; + E5b_HS = 0; + E1B_HS = 0; + E5a_HS = 0; } diff --git a/src/core/system_parameters/galileo_almanac.h b/src/core/system_parameters/galileo_almanac.h index 3744ed87d..022d778be 100644 --- a/src/core/system_parameters/galileo_almanac.h +++ b/src/core/system_parameters/galileo_almanac.h @@ -1,8 +1,8 @@ /*! * \file galileo_almanac.h * \brief Interface of a Galileo ALMANAC storage - * \author Javier Arribas, 2013. jarribas(at)cttc.es - * \author Mara Branzanti 2013. mara.branzanti(at)gmail.com + * \author Carles Fernandez, 2018. cfernandez(at)cttc.cat + * * ------------------------------------------------------------------------- * * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) @@ -28,80 +28,65 @@ * ------------------------------------------------------------------------- */ + #ifndef GNSS_SDR_GALILEO_ALMANAC_H_ #define GNSS_SDR_GALILEO_ALMANAC_H_ +#include +#include /*! - * \brief This class is a storage for the GALILEO ALMANAC data as described in GALILEO ICD - * - * See https://www.gsc-europa.eu/system/files/galileo_documents/Galileo_OS_SIS_ICD.pdf paragraph 5.1.10 + * \brief This class is a storage for the Galileo SV ALMANAC data */ class Galileo_Almanac { public: - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ - int IOD_a_7; - double WN_a_7; - double t0a_7; - int SVID1_7; - double DELTA_A_7; - double e_7; - double omega_7; - double delta_i_7; - double Omega0_7; - double Omega_dot_7; - double M0_7; + uint32_t i_satellite_PRN; //!< SV PRN NUMBER + int32_t i_Toa; + int32_t i_WNa; + int32_t i_IODa; + double d_Delta_i; //!< Inclination at reference time relative to i0 = 56º [semi-circles] + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + double d_e_eccentricity; //!< Eccentricity [dimensionless] + double d_Delta_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] + double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + double d_OMEGA; //!< Argument of Perigee [semi-cicles] + double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] + double d_A_f0; //!< Coefficient 0 of code phase offset model [s] + double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] + int32_t E5b_HS; + int32_t E1B_HS; + int32_t E5a_HS; - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ - int IOD_a_8; - double af0_8; - double af1_8; - double E5b_HS_8; - double E1B_HS_8; - double E5a_HS_8; - int SVID2_8; - double DELTA_A_8; - double e_8; - double omega_8; - double delta_i_8; - double Omega0_8; - double Omega_dot_8; + /*! + * Default constructor + */ + Galileo_Almanac(); - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ - int IOD_a_9; - double WN_a_9; - double t0a_9; - double M0_9; - double af0_9; - double af1_9; - double E5b_HS_9; - double E1B_HS_9; - double E5a_HS_9; - int SVID3_9; - double DELTA_A_9; - double e_9; - double omega_9; - double delta_i_9; + template - /*Word type 10: Almanac for SVID3 (2/2)*/ - int IOD_a_10; - double Omega0_10; - double Omega_dot_10; - double M0_10; - double af0_10; - double af1_10; - double E5b_HS_10; - double E1B_HS_10; - double E5a_HS_10; - - /*GPS to Galileo GST conversion parameters*/ - double A_0G_10; - double A_1G_10; - double t_0G_10; - double WN_0G_10; - - Galileo_Almanac(); //!< Default constructor + void serialize(Archive& ar, const unsigned int version) + { + if (version) + { + }; + ar& BOOST_SERIALIZATION_NVP(i_satellite_PRN); + ar& BOOST_SERIALIZATION_NVP(i_Toa); + ar& BOOST_SERIALIZATION_NVP(i_WNa); + ar& BOOST_SERIALIZATION_NVP(i_IODa); + ar& BOOST_SERIALIZATION_NVP(d_Delta_i); + ar& BOOST_SERIALIZATION_NVP(d_M_0); + ar& BOOST_SERIALIZATION_NVP(d_e_eccentricity); + ar& BOOST_SERIALIZATION_NVP(d_Delta_sqrt_A); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA0); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA_DOT); + ar& BOOST_SERIALIZATION_NVP(d_A_f0); + ar& BOOST_SERIALIZATION_NVP(d_A_f1); + ar& BOOST_SERIALIZATION_NVP(E5b_HS); + ar& BOOST_SERIALIZATION_NVP(E1B_HS); + ar& BOOST_SERIALIZATION_NVP(E5a_HS); + } }; #endif diff --git a/src/core/system_parameters/galileo_almanac_helper.cc b/src/core/system_parameters/galileo_almanac_helper.cc new file mode 100644 index 000000000..2fbd3e689 --- /dev/null +++ b/src/core/system_parameters/galileo_almanac_helper.cc @@ -0,0 +1,156 @@ +/*! + * \file galileo_almanac_helper.cc + * \brief Implementation of a Galileo ALMANAC storage helper + * \author Javier Arribas, 2013. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "galileo_almanac_helper.h" + +Galileo_Almanac_Helper::Galileo_Almanac_Helper() +{ + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number + IOD_a_7 = 0; + WN_a_7 = 0; + t0a_7 = 0; + SVID1_7 = 0; + DELTA_A_7 = 0.0; + e_7 = 0.0; + omega_7 = 0.0; + delta_i_7 = 0.0; + Omega0_7 = 0.0; + Omega_dot_7 = 0.0; + M0_7 = 0.0; + + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) + IOD_a_8 = 0; + af0_8 = 0.0; + af1_8 = 0.0; + E5b_HS_8 = 0; + E1B_HS_8 = 0; + E5a_HS_8 = 0; + SVID2_8 = 0; + DELTA_A_8 = 0.0; + e_8 = 0.0; + omega_8 = 0.0; + delta_i_8 = 0.0; + Omega0_8 = 0.0; + Omega_dot_8 = 0.0; + + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) + IOD_a_9 = 0; + WN_a_9 = 0; + t0a_9 = 0; + M0_9 = 0.0; + af0_9 = 0.0; + af1_9 = 0.0; + E5b_HS_9 = 0; + E1B_HS_9 = 0; + E5a_HS_9 = 0; + SVID3_9 = 0; + DELTA_A_9 = 0.0; + e_9 = 0.0; + omega_9 = 0.0; + delta_i_9 = 0.0; + + // Word type 10: Almanac for SVID3 (2/2) + IOD_a_10 = 0; + Omega0_10 = 0.0; + Omega_dot_10 = 0.0; + M0_10 = 0.0; + af0_10 = 0.0; + af1_10 = 0.0; + E5b_HS_10 = 0; + E1B_HS_10 = 0; + E5a_HS_10 = 0; +} + +Galileo_Almanac Galileo_Almanac_Helper::get_almanac(int i) +{ + Galileo_Almanac galileo_almanac; + switch (i) + { + case 1: + galileo_almanac.i_satellite_PRN = this->SVID1_7; + galileo_almanac.i_Toa = this->t0a_7; + galileo_almanac.i_WNa = this->WN_a_7; + galileo_almanac.i_IODa = this->IOD_a_7; + galileo_almanac.d_Delta_i = this->delta_i_7; + galileo_almanac.d_M_0 = this->M0_7; + galileo_almanac.d_e_eccentricity = this->e_7; + galileo_almanac.d_Delta_sqrt_A = this->DELTA_A_7; + galileo_almanac.d_OMEGA0 = this->Omega0_7; + galileo_almanac.d_OMEGA = this->omega_7; + galileo_almanac.d_OMEGA_DOT = this->Omega_dot_7; + galileo_almanac.d_A_f0 = this->af0_8; + galileo_almanac.d_A_f1 = this->af1_8; + galileo_almanac.E5b_HS = this->E5b_HS_8; + galileo_almanac.E1B_HS = this->E1B_HS_8; + galileo_almanac.E5a_HS = this->E5a_HS_8; + break; + + case 2: + galileo_almanac.i_satellite_PRN = this->SVID2_8; + galileo_almanac.i_Toa = this->t0a_9; + galileo_almanac.i_WNa = this->WN_a_9; + galileo_almanac.i_IODa = this->IOD_a_9; + galileo_almanac.d_Delta_i = this->delta_i_8; + galileo_almanac.d_M_0 = this->M0_9; + galileo_almanac.d_e_eccentricity = this->e_8; + galileo_almanac.d_Delta_sqrt_A = this->DELTA_A_8; + galileo_almanac.d_OMEGA0 = this->Omega0_8; + galileo_almanac.d_OMEGA = this->omega_8; + galileo_almanac.d_OMEGA_DOT = this->Omega_dot_8; + galileo_almanac.d_A_f0 = this->af0_9; + galileo_almanac.d_A_f1 = this->af1_9; + galileo_almanac.E1B_HS = this->E1B_HS_9; + galileo_almanac.E5a_HS = this->E5a_HS_9; + break; + + case 3: + galileo_almanac.i_satellite_PRN = this->SVID3_9; + galileo_almanac.i_Toa = this->t0a_9; + galileo_almanac.i_WNa = this->WN_a_9; + galileo_almanac.i_IODa = this->IOD_a_10; + galileo_almanac.d_Delta_i = this->delta_i_9; + galileo_almanac.d_M_0 = this->M0_10; + galileo_almanac.d_e_eccentricity = this->e_9; + galileo_almanac.d_Delta_sqrt_A = this->DELTA_A_9; + galileo_almanac.d_OMEGA0 = this->Omega0_10; + galileo_almanac.d_OMEGA = this->omega_9; + galileo_almanac.d_OMEGA_DOT = this->Omega_dot_10; + galileo_almanac.d_A_f0 = this->af0_10; + galileo_almanac.d_A_f1 = this->af1_10; + galileo_almanac.E5b_HS = this->E5b_HS_10; + galileo_almanac.E1B_HS = this->E1B_HS_10; + galileo_almanac.E5a_HS = this->E5a_HS_10; + break; + + default: + break; + } + return galileo_almanac; +} diff --git a/src/core/system_parameters/galileo_almanac_helper.h b/src/core/system_parameters/galileo_almanac_helper.h new file mode 100644 index 000000000..960ccd09e --- /dev/null +++ b/src/core/system_parameters/galileo_almanac_helper.h @@ -0,0 +1,104 @@ +/*! + * \file galileo_almanac_helper.h + * \brief Interface of a Galileo ALMANAC storage helper + * \author Javier Arribas, 2013. jarribas(at)cttc.es + * \author Mara Branzanti 2013. mara.branzanti(at)gmail.com + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GALILEO_ALMANAC_HELPER_H_ +#define GNSS_SDR_GALILEO_ALMANAC_HELPER_H_ + +#include "galileo_almanac.h" +#include + +/*! + * \brief This class is a storage for the GALILEO ALMANAC data as described in GALILEO ICD + * + * See https://www.gsc-europa.eu/system/files/galileo_documents/Galileo_OS_SIS_ICD.pdf paragraph 5.1.10 + */ +class Galileo_Almanac_Helper +{ +public: + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number + int32_t IOD_a_7; + int32_t WN_a_7; + int32_t t0a_7; + int32_t SVID1_7; + double DELTA_A_7; + double e_7; + double omega_7; + double delta_i_7; + double Omega0_7; + double Omega_dot_7; + double M0_7; + + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) + int32_t IOD_a_8; + double af0_8; + double af1_8; + int32_t E5b_HS_8; + int32_t E1B_HS_8; + int32_t E5a_HS_8; + int32_t SVID2_8; + double DELTA_A_8; + double e_8; + double omega_8; + double delta_i_8; + double Omega0_8; + double Omega_dot_8; + + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) + int32_t IOD_a_9; + int32_t WN_a_9; + int32_t t0a_9; + double M0_9; + double af0_9; + double af1_9; + int32_t E5b_HS_9; + int32_t E1B_HS_9; + int32_t E5a_HS_9; + int32_t SVID3_9; + double DELTA_A_9; + double e_9; + double omega_9; + double delta_i_9; + + // Word type 10: Almanac for SVID3 (2/2) + int32_t IOD_a_10; + double Omega0_10; + double Omega_dot_10; + double M0_10; + double af0_10; + double af1_10; + int32_t E5b_HS_10; + int32_t E1B_HS_10; + int32_t E5a_HS_10; + + Galileo_Almanac_Helper(); //!< Default constructor + Galileo_Almanac get_almanac(int i); +}; + +#endif diff --git a/src/core/system_parameters/galileo_ephemeris.cc b/src/core/system_parameters/galileo_ephemeris.cc index 926257933..a606b2d20 100644 --- a/src/core/system_parameters/galileo_ephemeris.cc +++ b/src/core/system_parameters/galileo_ephemeris.cc @@ -39,40 +39,43 @@ Galileo_Ephemeris::Galileo_Ephemeris() IOD_ephemeris = 0; IOD_nav_1 = 0; SV_ID_PRN_4 = 0; - M0_1 = 0; // Mean anomaly at reference time [semi-circles] - delta_n_3 = 0; // Mean motion difference from computed value [semi-circles/sec] - e_1 = 0; // Eccentricity - A_1 = 0; // Square root of the semi-major axis [meters^1/2] - OMEGA_0_2 = 0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] - i_0_2 = 0; // Inclination angle at reference time [semi-circles] - omega_2 = 0; // Argument of perigee [semi-circles] - OMEGA_dot_3 = 0; // Rate of right ascension [semi-circles/sec] - iDot_2 = 0; // Rate of inclination angle [semi-circles/sec] - C_uc_3 = 0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] - C_us_3 = 0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] - C_rc_3 = 0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] - C_rs_3 = 0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] - C_ic_4 = 0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] - C_is_4 = 0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] - t0e_1 = 0; // Ephemeris reference time [s] - /*Clock correction parameters*/ - t0c_4 = 0; // Clock correction data reference Time of Week [sec] - af0_4 = 0; // SV clock bias correction coefficient [s] - af1_4 = 0; // SV clock drift correction coefficient [s/s] - af2_4 = 0; // SV clock drift rate correction coefficient [s/s^2] - /*GST*/ + M0_1 = 0.0; // Mean anomaly at reference time [semi-circles] + delta_n_3 = 0.0; // Mean motion difference from computed value [semi-circles/sec] + e_1 = 0.0; // Eccentricity + A_1 = 0.0; // Square root of the semi-major axis [meters^1/2] + OMEGA_0_2 = 0.0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] + i_0_2 = 0.0; // Inclination angle at reference time [semi-circles] + omega_2 = 0.0; // Argument of perigee [semi-circles] + OMEGA_dot_3 = 0.0; // Rate of right ascension [semi-circles/sec] + iDot_2 = 0.0; // Rate of inclination angle [semi-circles/sec] + C_uc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] + C_us_3 = 0.0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] + C_rc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] + C_rs_3 = 0.0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] + C_ic_4 = 0.0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] + C_is_4 = 0.0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] + t0e_1 = 0; // Ephemeris reference time [s] + + // Clock correction parameters + t0c_4 = 0; // Clock correction data reference Time of Week [sec] + af0_4 = 0.0; // SV clock bias correction coefficient [s] + af1_4 = 0.0; // SV clock drift correction coefficient [s/s] + af2_4 = 0.0; // SV clock drift rate correction coefficient [s/s^2] + + // GST WN_5 = 0; TOW_5 = 0; + // SV status SISA_3 = 0; E5a_HS = 0; E5b_HS_5 = 0; E1B_HS_5 = 0; E5a_DVS = false; - E5b_DVS_5 = 0; - E1B_DVS_5 = 0; - BGD_E1E5a_5 = 0; // E1-E5a Broadcast Group Delay [s] - BGD_E1E5b_5 = 0; // E1-E5b Broadcast Group Delay [s] + E5b_DVS_5 = false; + E1B_DVS_5 = false; + BGD_E1E5a_5 = 0.0; // E1-E5a Broadcast Group Delay [s] + BGD_E1E5b_5 = 0.0; // E1-E5b Broadcast Group Delay [s] Galileo_satClkDrift = 0.0; Galileo_dtr = 0.0; @@ -81,12 +84,13 @@ Galileo_Ephemeris::Galileo_Ephemeris() d_satpos_X = 0.0; d_satpos_Y = 0.0; d_satpos_Z = 0.0; + // Satellite velocity d_satvel_X = 0.0; d_satvel_Y = 0.0; d_satvel_Z = 0.0; - i_satellite_PRN = 0; + i_satellite_PRN = 0U; } @@ -170,7 +174,7 @@ double Galileo_Ephemeris::sv_clock_relativistic_term(double transmitTime) // Sa E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + e_1 * sin(E); @@ -230,7 +234,7 @@ void Galileo_Ephemeris::satellitePosition(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + e_1 * sin(E); diff --git a/src/core/system_parameters/galileo_ephemeris.h b/src/core/system_parameters/galileo_ephemeris.h index 6704499b5..42e4288a4 100644 --- a/src/core/system_parameters/galileo_ephemeris.h +++ b/src/core/system_parameters/galileo_ephemeris.h @@ -33,8 +33,8 @@ #ifndef GNSS_SDR_GALILEO_EPHEMERIS_H_ #define GNSS_SDR_GALILEO_EPHEMERIS_H_ -#include #include +#include /*! @@ -48,9 +48,9 @@ public: /* Galileo ephemeris are 16 parameters and here are reported following the ICD order, paragraph 5.1.1. The number in the name after underscore (_1, _2, _3 and so on) refers to the page were we can find that parameter */ bool flag_all_ephemeris; - int IOD_ephemeris; - int IOD_nav_1; - int SV_ID_PRN_4; + int32_t IOD_ephemeris; + int32_t IOD_nav_1; + int32_t SV_ID_PRN_4; double M0_1; //!< Mean anomaly at reference time [semi-circles] double delta_n_3; //!< Mean motion difference from computed value [semi-circles/sec] double e_1; //!< Eccentricity @@ -66,29 +66,29 @@ public: double C_rs_3; //!< Amplitude of the sine harmonic correction term to the orbit radius [meters] double C_ic_4; //!< Amplitude of the cosine harmonic correction term to the angle of inclination [radians] double C_is_4; //!< Amplitude of the sine harmonic correction term to the angle of inclination [radians] - double t0e_1; //!< Ephemeris reference time [s] + int32_t t0e_1; //!< Ephemeris reference time [s] /*Clock correction parameters*/ - double t0c_4; //!< Clock correction data reference Time of Week [sec] - double af0_4; //!< SV clock bias correction coefficient [s] - double af1_4; //!< SV clock drift correction coefficient [s/s] - double af2_4; //!< SV clock drift rate correction coefficient [s/s^2] + int32_t t0c_4; //!< Clock correction data reference Time of Week [sec] + double af0_4; //!< SV clock bias correction coefficient [s] + double af1_4; //!< SV clock drift correction coefficient [s/s] + double af2_4; //!< SV clock drift rate correction coefficient [s/s^2] /*GST*/ - //Not belong to ephemeris set (page 1 to 4) - double WN_5; //!< Week number - double TOW_5; //!< Time of Week + // Not belong to ephemeris set (page 1 to 4) + int32_t WN_5; //!< Week number + int32_t TOW_5; //!< Time of Week double Galileo_satClkDrift; double Galileo_dtr; //!< relativistic clock correction term // SV status - double SISA_3; - unsigned int E5a_HS; //!< E5a Signal Health Status - double E5b_HS_5; //!< E5b Signal Health Status - double E1B_HS_5; //!< E1B Signal Health Status - bool E5a_DVS; //!< E5a Data Validity Status - double E5b_DVS_5; //!< E5b Data Validity Status - double E1B_DVS_5; //!< E1B Data Validity Status + int32_t SISA_3; + int32_t E5a_HS; //!< E5a Signal Health Status + int32_t E5b_HS_5; //!< E5b Signal Health Status + int32_t E1B_HS_5; //!< E1B Signal Health Status + bool E5a_DVS; //!< E5a Data Validity Status + bool E5b_DVS_5; //!< E5b Data Validity Status + bool E1B_DVS_5; //!< E1B Data Validity Status double BGD_E1E5a_5; //!< E1-E5a Broadcast Group Delay [s] double BGD_E1E5b_5; //!< E1-E5b Broadcast Group Delay [s] @@ -103,7 +103,7 @@ public: double d_satvel_Y; //!< Earth-fixed velocity coordinate y of the satellite [m] double d_satvel_Z; //!< Earth-fixed velocity coordinate z of the satellite [m] - unsigned int i_satellite_PRN; //!< SV PRN NUMBER + uint32_t i_satellite_PRN; //!< SV PRN NUMBER void satellitePosition(double transmitTime); //!< Computes the ECEF SV coordinates and ECEF velocity double Galileo_System_Time(double WN, double TOW); //!< Galileo System Time (GST), ICD paragraph 5.1.2 @@ -116,32 +116,55 @@ public: /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { - using boost::serialization::make_nvp; if (version) { }; - archive& make_nvp("i_satellite_PRN", i_satellite_PRN); - archive& make_nvp("M0_1", M0_1); - archive& make_nvp("e_1", e_1); - archive& make_nvp("A_1", A_1); - archive& make_nvp("OMEGA_0_2", OMEGA_0_2); - archive& make_nvp("i_0_2", i_0_2); - archive& make_nvp("omega_2", omega_2); - archive& make_nvp("OMEGA_dot_3", OMEGA_dot_3); - archive& make_nvp("iDot_2", iDot_2); - archive& make_nvp("C_uc_3", C_uc_3); - archive& make_nvp("C_us_3", C_us_3); - archive& make_nvp("C_rc_3", C_rc_3); - archive& make_nvp("C_rs_3", C_rs_3); - archive& make_nvp("C_ic_4", C_ic_4); - archive& make_nvp("C_is_4", C_is_4); - archive& make_nvp("t0e_1", t0e_1); - archive& make_nvp("t0c_4", t0c_4); - archive& make_nvp("af0_4", af0_4); - archive& make_nvp("af1_4", af1_4); - archive& make_nvp("af2_4", af2_4); + + archive& BOOST_SERIALIZATION_NVP(i_satellite_PRN); + + archive& BOOST_SERIALIZATION_NVP(M0_1); + archive& BOOST_SERIALIZATION_NVP(delta_n_3); + archive& BOOST_SERIALIZATION_NVP(e_1); + archive& BOOST_SERIALIZATION_NVP(A_1); + archive& BOOST_SERIALIZATION_NVP(OMEGA_0_2); + archive& BOOST_SERIALIZATION_NVP(i_0_2); + archive& BOOST_SERIALIZATION_NVP(omega_2); + archive& BOOST_SERIALIZATION_NVP(OMEGA_dot_3); + archive& BOOST_SERIALIZATION_NVP(iDot_2); + archive& BOOST_SERIALIZATION_NVP(C_uc_3); + archive& BOOST_SERIALIZATION_NVP(C_us_3); + archive& BOOST_SERIALIZATION_NVP(C_rc_3); + archive& BOOST_SERIALIZATION_NVP(C_rs_3); + archive& BOOST_SERIALIZATION_NVP(C_ic_4); + archive& BOOST_SERIALIZATION_NVP(C_is_4); + archive& BOOST_SERIALIZATION_NVP(t0e_1); + + archive& BOOST_SERIALIZATION_NVP(t0c_4); + archive& BOOST_SERIALIZATION_NVP(af0_4); + archive& BOOST_SERIALIZATION_NVP(af1_4); + archive& BOOST_SERIALIZATION_NVP(af2_4); + + archive& BOOST_SERIALIZATION_NVP(WN_5); + archive& BOOST_SERIALIZATION_NVP(TOW_5); + archive& BOOST_SERIALIZATION_NVP(Galileo_satClkDrift); + archive& BOOST_SERIALIZATION_NVP(Galileo_dtr); + + archive& BOOST_SERIALIZATION_NVP(flag_all_ephemeris); + archive& BOOST_SERIALIZATION_NVP(IOD_ephemeris); + archive& BOOST_SERIALIZATION_NVP(IOD_nav_1); + + archive& BOOST_SERIALIZATION_NVP(SISA_3); + archive& BOOST_SERIALIZATION_NVP(E5a_HS); + archive& BOOST_SERIALIZATION_NVP(E5b_HS_5); + archive& BOOST_SERIALIZATION_NVP(E1B_HS_5); + archive& BOOST_SERIALIZATION_NVP(E5a_DVS); + archive& BOOST_SERIALIZATION_NVP(E5b_DVS_5); + archive& BOOST_SERIALIZATION_NVP(E1B_DVS_5); + + archive& BOOST_SERIALIZATION_NVP(BGD_E1E5a_5); + archive& BOOST_SERIALIZATION_NVP(BGD_E1E5b_5); } }; diff --git a/src/core/system_parameters/galileo_fnav_message.cc b/src/core/system_parameters/galileo_fnav_message.cc index b0c17fa7d..918b7e9c7 100644 --- a/src/core/system_parameters/galileo_fnav_message.cc +++ b/src/core/system_parameters/galileo_fnav_message.cc @@ -41,7 +41,7 @@ #include -typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> CRC_Galileo_FNAV_type; +using CRC_Galileo_FNAV_type = boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false>; void Galileo_Fnav_Message::reset() { @@ -66,60 +66,60 @@ void Galileo_Fnav_Message::reset() IOD_ephemeris = 0; page_type = 0; - /* WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal - * health and Data validity status*/ + // WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal + // health and Data validity status FNAV_SV_ID_PRN_1 = 0; FNAV_IODnav_1 = -1; FNAV_t0c_1 = 0; - FNAV_af0_1 = 0; - FNAV_af1_1 = 0; - FNAV_af2_1 = 0; + FNAV_af0_1 = 0.0; + FNAV_af1_1 = 0.0; + FNAV_af2_1 = 0.0; FNAV_SISA_1 = 0; - FNAV_ai0_1 = 0; - FNAV_ai1_1 = 0; - FNAV_ai2_1 = 0; - FNAV_region1_1 = 0; - FNAV_region2_1 = 0; - FNAV_region3_1 = 0; - FNAV_region4_1 = 0; - FNAV_region5_1 = 0; - FNAV_BGD_1 = 0; + FNAV_ai0_1 = 0.0; + FNAV_ai1_1 = 0.0; + FNAV_ai2_1 = 0.0; + FNAV_region1_1 = false; + FNAV_region2_1 = false; + FNAV_region3_1 = false; + FNAV_region4_1 = false; + FNAV_region5_1 = false; + FNAV_BGD_1 = 0.0; FNAV_E5ahs_1 = 0; FNAV_WN_1 = 0; FNAV_TOW_1 = 0; - FNAV_E5advs_1 = 0; + FNAV_E5advs_1 = false; // WORD 2 Ephemeris (1/3) and GST FNAV_IODnav_2 = -2; - FNAV_M0_2 = 0; - FNAV_omegadot_2 = 0; - FNAV_e_2 = 0; - FNAV_a12_2 = 0; - FNAV_omega0_2 = 0; - FNAV_idot_2 = 0; + FNAV_M0_2 = 0.0; + FNAV_omegadot_2 = 0.0; + FNAV_e_2 = 0.0; + FNAV_a12_2 = 0.0; + FNAV_omega0_2 = 0.0; + FNAV_idot_2 = 0.0; FNAV_WN_2 = 0; FNAV_TOW_2 = 0; // WORD 3 Ephemeris (2/3) and GST FNAV_IODnav_3 = -3; - FNAV_i0_3 = 0; - FNAV_w_3 = 0; - FNAV_deltan_3 = 0; - FNAV_Cuc_3 = 0; - FNAV_Cus_3 = 0; - FNAV_Crc_3 = 0; - FNAV_Crs_3 = 0; + FNAV_i0_3 = 0.0; + FNAV_w_3 = 0.0; + FNAV_deltan_3 = 0.0; + FNAV_Cuc_3 = 0.0; + FNAV_Cus_3 = 0.0; + FNAV_Crc_3 = 0.0; + FNAV_Crs_3 = 0.0; FNAV_t0e_3 = 0; FNAV_WN_3 = 0; FNAV_TOW_3 = 0; - /* WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. - Note that the clock is repeated in this page type*/ + // WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. + // Note that the clock is repeated in this page type FNAV_IODnav_4 = -4; - FNAV_Cic_4 = 0; - FNAV_Cis_4 = 0; - FNAV_A0_4 = 0; - FNAV_A1_4 = 0; + FNAV_Cic_4 = 0.0; + FNAV_Cis_4 = 0.0; + FNAV_A0_4 = 0.0; + FNAV_A1_4 = 0.0; FNAV_deltatls_4 = 0; FNAV_t0t_4 = 0; FNAV_WNot_4 = 0; @@ -127,8 +127,8 @@ void Galileo_Fnav_Message::reset() FNAV_DN_4 = 0; FNAV_deltatlsf_4 = 0; FNAV_t0g_4 = 0; - FNAV_A0g_4 = 0; - FNAV_A1g_4 = 0; + FNAV_A0g_4 = 0.0; + FNAV_A1g_4 = 0.0; FNAV_WN0g_4 = 0; FNAV_TOW_4 = 0; @@ -137,62 +137,51 @@ void Galileo_Fnav_Message::reset() FNAV_WNa_5 = 0; FNAV_t0a_5 = 0; FNAV_SVID1_5 = 0; - FNAV_Deltaa12_1_5 = 0; - FNAV_e_1_5 = 0; - FNAV_w_1_5 = 0; - FNAV_deltai_1_5 = 0; - FNAV_Omega0_1_5 = 0; - FNAV_Omegadot_1_5 = 0; - FNAV_M0_1_5 = 0; - FNAV_af0_1_5 = 0; - FNAV_af1_1_5 = 0; - FNAV_E5ahs_1_5 = 0; + FNAV_Deltaa12_1_5 = 0.0; + FNAV_e_1_5 = 0.0; + FNAV_w_1_5 = 0.0; + FNAV_deltai_1_5 = 0.0; + FNAV_Omega0_1_5 = 0.0; + FNAV_Omegadot_1_5 = 0.0; + FNAV_M0_1_5 = 0.0; + FNAV_af0_1_5 = 0.0; + FNAV_af1_1_5 = 0.0; + FNAV_E5ahs_1_5 = 0U; FNAV_SVID2_5 = 0; FNAV_Deltaa12_2_5 = 0; - FNAV_e_2_5 = 0; - FNAV_w_2_5 = 0; - FNAV_deltai_2_5 = 0; + FNAV_e_2_5 = 0.0; + FNAV_w_2_5 = 0.0; + FNAV_deltai_2_5 = 0.0; // WORD 6 Almanac (SVID2(2/2) and SVID3) FNAV_IODa_6 = 0; - FNAV_Omega0_2_6 = 0; - FNAV_Omegadot_2_6 = 0; - FNAV_M0_2_6 = 0; - FNAV_af0_2_6 = 0; - FNAV_af1_2_6 = 0; + FNAV_Omega0_2_6 = 0.0; + FNAV_Omegadot_2_6 = 0.0; + FNAV_M0_2_6 = 0.0; + FNAV_af0_2_6 = 0.0; + FNAV_af1_2_6 = 0.0; FNAV_E5ahs_2_6 = 0; FNAV_SVID3_6 = 0; - FNAV_Deltaa12_3_6 = 0; - FNAV_e_3_6 = 0; - FNAV_w_3_6 = 0; - FNAV_deltai_3_6 = 0; - FNAV_Omega0_3_6 = 0; - FNAV_Omegadot_3_6 = 0; - FNAV_M0_3_6 = 0; - FNAV_af0_3_6 = 0; - FNAV_af1_3_6 = 0; + FNAV_Deltaa12_3_6 = 0.0; + FNAV_e_3_6 = 0.0; + FNAV_w_3_6 = 0.0; + FNAV_deltai_3_6 = 0.0; + FNAV_Omega0_3_6 = 0.0; + FNAV_Omegadot_3_6 = 0.0; + FNAV_M0_3_6 = 0.0; + FNAV_af0_3_6 = 0.0; + FNAV_af1_3_6 = 0.0; FNAV_E5ahs_3_6 = 0; } + Galileo_Fnav_Message::Galileo_Fnav_Message() { reset(); } -//int Galileo_Fnav_Message::toInt(std::string bitString) -//{ -// int tempInt; -// int num=0; -// int sLength = bitString.length(); -// for(int i=0; i bits, boost::uint32_t checksum) +bool Galileo_Fnav_Message::_CRC_test(std::bitset bits, uint32_t checksum) { CRC_Galileo_FNAV_type CRC_Galileo; - boost::uint32_t crc_computed; + uint32_t crc_computed; // Galileo FNAV frame for CRC is not an integer multiple of bytes // it needs to be filled with zeroes at the start of the frame. // This operation is done in the transformation from bits to bytes // using boost::dynamic_bitset. // ToDo: Use boost::dynamic_bitset for all the bitset operations in this class - boost::dynamic_bitset frame_bits(std::string(bits.to_string())); + boost::dynamic_bitset frame_bits(std::string(bits.to_string())); - std::vector bytes; + std::vector bytes; boost::to_block_range(frame_bits, std::back_inserter(bytes)); std::reverse(bytes.begin(), bytes.end()); @@ -235,214 +224,205 @@ bool Galileo_Fnav_Message::_CRC_test(std::bitset b { return true; } - else - { - return false; - } + + return false; } -void Galileo_Fnav_Message::decode_page(std::string data) +void Galileo_Fnav_Message::decode_page(const std::string& data) { std::bitset data_bits(data); - page_type = read_navigation_unsigned(data_bits, FNAV_PAGE_TYPE_bit); + page_type = read_navigation_unsigned(data_bits, FNAV_PAGE_TYPE_BIT); switch (page_type) { case 1: // SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal health and Data validity status - FNAV_SV_ID_PRN_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_SV_ID_PRN_1_bit)); - FNAV_IODnav_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_1_bit)); - FNAV_t0c_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_t0c_1_bit)); - FNAV_t0c_1 *= FNAV_t0c_1_LSB; - FNAV_af0_1 = static_cast(read_navigation_signed(data_bits, FNAV_af0_1_bit)); - FNAV_af0_1 *= FNAV_af0_1_LSB; - FNAV_af1_1 = static_cast(read_navigation_signed(data_bits, FNAV_af1_1_bit)); - FNAV_af1_1 *= FNAV_af1_1_LSB; - FNAV_af2_1 = static_cast(read_navigation_signed(data_bits, FNAV_af2_1_bit)); - FNAV_af2_1 *= FNAV_af2_1_LSB; - FNAV_SISA_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_SISA_1_bit)); - FNAV_ai0_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_ai0_1_bit)); - FNAV_ai0_1 *= FNAV_ai0_1_LSB; - FNAV_ai1_1 = static_cast(read_navigation_signed(data_bits, FNAV_ai1_1_bit)); - FNAV_ai1_1 *= FNAV_ai1_1_LSB; - FNAV_ai2_1 = static_cast(read_navigation_signed(data_bits, FNAV_ai2_1_bit)); - FNAV_ai2_1 *= FNAV_ai2_1_LSB; - FNAV_region1_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_region1_1_bit)); - FNAV_region2_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_region2_1_bit)); - FNAV_region3_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_region3_1_bit)); - FNAV_region4_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_region4_1_bit)); - FNAV_region5_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_region5_1_bit)); - FNAV_BGD_1 = static_cast(read_navigation_signed(data_bits, FNAV_BGD_1_bit)); + FNAV_SV_ID_PRN_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_SV_ID_PRN_1_BIT)); + FNAV_IODnav_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_IO_DNAV_1_BIT)); + FNAV_t0c_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_T0C_1_BIT)); + FNAV_t0c_1 *= FNAV_T0C_1_LSB; + FNAV_af0_1 = static_cast(read_navigation_signed(data_bits, FNAV_AF0_1_BIT)); + FNAV_af0_1 *= FNAV_AF0_1_LSB; + FNAV_af1_1 = static_cast(read_navigation_signed(data_bits, FNAV_AF1_1_BIT)); + FNAV_af1_1 *= FNAV_AF1_1_LSB; + FNAV_af2_1 = static_cast(read_navigation_signed(data_bits, FNAV_AF2_1_BIT)); + FNAV_af2_1 *= FNAV_AF2_1_LSB; + FNAV_SISA_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_SISA_1_BIT)); + FNAV_ai0_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_AI0_1_BIT)); + FNAV_ai0_1 *= FNAV_AI0_1_LSB; + FNAV_ai1_1 = static_cast(read_navigation_signed(data_bits, FNAV_AI1_1_BIT)); + FNAV_ai1_1 *= FNAV_AI1_1_LSB; + FNAV_ai2_1 = static_cast(read_navigation_signed(data_bits, FNAV_AI2_1_BIT)); + FNAV_ai2_1 *= FNAV_AI2_1_LSB; + FNAV_region1_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_REGION1_1_BIT)); + FNAV_region2_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_REGION2_1_BIT)); + FNAV_region3_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_REGION3_1_BIT)); + FNAV_region4_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_REGION4_1_BIT)); + FNAV_region5_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_REGION5_1_BIT)); + FNAV_BGD_1 = static_cast(read_navigation_signed(data_bits, FNAV_BGD_1_BIT)); FNAV_BGD_1 *= FNAV_BGD_1_LSB; - FNAV_E5ahs_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_1_bit)); - FNAV_WN_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_1_bit)); - FNAV_TOW_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_1_bit)); - FNAV_E5advs_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5advs_1_bit)); - + FNAV_E5ahs_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5AHS_1_BIT)); + FNAV_WN_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_1_BIT)); + FNAV_TOW_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_1_BIT)); + FNAV_E5advs_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ADVS_1_BIT)); flag_TOW_1 = true; flag_TOW_set = true; - flag_iono_and_GST = true; //set to false externally + flag_iono_and_GST = true; // set to false externally break; case 2: // Ephemeris (1/3) and GST - FNAV_IODnav_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_2_bit)); - FNAV_M0_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_M0_2_bit)); + FNAV_IODnav_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_IO_DNAV_2_BIT)); + FNAV_M0_2 = static_cast(read_navigation_signed(data_bits, FNAV_M0_2_BIT)); FNAV_M0_2 *= FNAV_M0_2_LSB; - FNAV_omegadot_2 = static_cast(read_navigation_signed(data_bits, FNAV_omegadot_2_bit)); - FNAV_omegadot_2 *= FNAV_omegadot_2_LSB; - FNAV_e_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_e_2_bit)); - FNAV_e_2 *= FNAV_e_2_LSB; - FNAV_a12_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_a12_2_bit)); - FNAV_a12_2 *= FNAV_a12_2_LSB; - FNAV_omega0_2 = static_cast(read_navigation_signed(data_bits, FNAV_omega0_2_bit)); - FNAV_omega0_2 *= FNAV_omega0_2_LSB; - FNAV_idot_2 = static_cast(read_navigation_signed(data_bits, FNAV_idot_2_bit)); - FNAV_idot_2 *= FNAV_idot_2_LSB; - FNAV_WN_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_2_bit)); - FNAV_TOW_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_2_bit)); - + FNAV_omegadot_2 = static_cast(read_navigation_signed(data_bits, FNAV_OMEGADOT_2_BIT)); + FNAV_omegadot_2 *= FNAV_OMEGADOT_2_LSB; + FNAV_e_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_E_2_BIT)); + FNAV_e_2 *= FNAV_E_2_LSB; + FNAV_a12_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_A12_2_BIT)); + FNAV_a12_2 *= FNAV_A12_2_LSB; + FNAV_omega0_2 = static_cast(read_navigation_signed(data_bits, FNAV_OMEGA0_2_BIT)); + FNAV_omega0_2 *= FNAV_OMEGA0_2_LSB; + FNAV_idot_2 = static_cast(read_navigation_signed(data_bits, FNAV_IDOT_2_BIT)); + FNAV_idot_2 *= FNAV_IDOT_2_LSB; + FNAV_WN_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_2_BIT)); + FNAV_TOW_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_2_BIT)); flag_TOW_2 = true; flag_TOW_set = true; flag_ephemeris_1 = true; break; case 3: // Ephemeris (2/3) and GST - FNAV_IODnav_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_3_bit)); - FNAV_i0_3 = static_cast(read_navigation_signed(data_bits, FNAV_i0_3_bit)); - FNAV_i0_3 *= FNAV_i0_3_LSB; - FNAV_w_3 = static_cast(read_navigation_signed(data_bits, FNAV_w_3_bit)); - FNAV_w_3 *= FNAV_w_3_LSB; - FNAV_deltan_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_deltan_3_bit)); - FNAV_deltan_3 *= FNAV_deltan_3_LSB; - FNAV_Cuc_3 = static_cast(read_navigation_signed(data_bits, FNAV_Cuc_3_bit)); - FNAV_Cuc_3 *= FNAV_Cuc_3_LSB; - FNAV_Cus_3 = static_cast(read_navigation_signed(data_bits, FNAV_Cus_3_bit)); - FNAV_Cus_3 *= FNAV_Cus_3_LSB; - FNAV_Crc_3 = static_cast(read_navigation_signed(data_bits, FNAV_Crc_3_bit)); - FNAV_Crc_3 *= FNAV_Crc_3_LSB; - FNAV_Crs_3 = static_cast(read_navigation_signed(data_bits, FNAV_Crs_3_bit)); - FNAV_Crs_3 *= FNAV_Crs_3_LSB; - FNAV_t0e_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_t0e_3_bit)); - FNAV_t0e_3 *= FNAV_t0e_3_LSB; - FNAV_WN_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_3_bit)); - FNAV_TOW_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_3_bit)); - + FNAV_IODnav_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_IO_DNAV_3_BIT)); + FNAV_i0_3 = static_cast(read_navigation_signed(data_bits, FNAV_I0_3_BIT)); + FNAV_i0_3 *= FNAV_I0_3_LSB; + FNAV_w_3 = static_cast(read_navigation_signed(data_bits, FNAV_W_3_BIT)); + FNAV_w_3 *= FNAV_W_3_LSB; + FNAV_deltan_3 = static_cast(read_navigation_signed(data_bits, FNAV_DELTAN_3_BIT)); + FNAV_deltan_3 *= FNAV_DELTAN_3_LSB; + FNAV_Cuc_3 = static_cast(read_navigation_signed(data_bits, FNAV_CUC_3_BIT)); + FNAV_Cuc_3 *= FNAV_CUC_3_LSB; + FNAV_Cus_3 = static_cast(read_navigation_signed(data_bits, FNAV_CUS_3_BIT)); + FNAV_Cus_3 *= FNAV_CUS_3_LSB; + FNAV_Crc_3 = static_cast(read_navigation_signed(data_bits, FNAV_CRC_3_BIT)); + FNAV_Crc_3 *= FNAV_CRC_3_LSB; + FNAV_Crs_3 = static_cast(read_navigation_signed(data_bits, FNAV_CRS_3_BIT)); + FNAV_Crs_3 *= FNAV_CRS_3_LSB; + FNAV_t0e_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_T0E_3_BIT)); + FNAV_t0e_3 *= FNAV_T0E_3_LSB; + FNAV_WN_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_3_BIT)); + FNAV_TOW_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_3_BIT)); flag_TOW_3 = true; flag_TOW_set = true; flag_ephemeris_2 = true; break; case 4: // Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW - FNAV_IODnav_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_4_bit)); - FNAV_Cic_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_Cic_4_bit)); - FNAV_Cic_4 *= FNAV_Cic_4_LSB; - FNAV_Cis_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_Cis_4_bit)); - FNAV_Cis_4 *= FNAV_Cis_4_LSB; - FNAV_A0_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_A0_4_bit)); + FNAV_IODnav_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_IO_DNAV_4_BIT)); + FNAV_Cic_4 = static_cast(read_navigation_signed(data_bits, FNAV_CIC_4_BIT)); + FNAV_Cic_4 *= FNAV_CIC_4_LSB; + FNAV_Cis_4 = static_cast(read_navigation_signed(data_bits, FNAV_CIS_4_BIT)); + FNAV_Cis_4 *= FNAV_CIS_4_LSB; + FNAV_A0_4 = static_cast(read_navigation_signed(data_bits, FNAV_A0_4_BIT)); FNAV_A0_4 *= FNAV_A0_4_LSB; - FNAV_A1_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_A1_4_bit)); + FNAV_A1_4 = static_cast(read_navigation_signed(data_bits, FNAV_A1_4_BIT)); FNAV_A1_4 *= FNAV_A1_4_LSB; - FNAV_deltatls_4 = static_cast(read_navigation_signed(data_bits, FNAV_deltatls_4_bit)); - FNAV_t0t_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_t0t_4_bit)); - FNAV_t0t_4 *= FNAV_t0t_4_LSB; - FNAV_WNot_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_WNot_4_bit)); - FNAV_WNlsf_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_WNlsf_4_bit)); - FNAV_DN_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_DN_4_bit)); - FNAV_deltatlsf_4 = static_cast(read_navigation_signed(data_bits, FNAV_deltatlsf_4_bit)); - FNAV_t0g_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_t0g_4_bit)); - FNAV_t0g_4 *= FNAV_t0g_4_LSB; - FNAV_A0g_4 = static_cast(read_navigation_signed(data_bits, FNAV_A0g_4_bit)); - FNAV_A0g_4 *= FNAV_A0g_4_LSB; - FNAV_A1g_4 = static_cast(read_navigation_signed(data_bits, FNAV_A1g_4_bit)); - FNAV_A1g_4 *= FNAV_A1g_4_LSB; - FNAV_WN0g_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN0g_4_bit)); - FNAV_TOW_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_4_bit)); - + FNAV_deltatls_4 = static_cast(read_navigation_signed(data_bits, FNAV_DELTATLS_4_BIT)); + FNAV_t0t_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_T0T_4_BIT)); + FNAV_t0t_4 *= FNAV_T0T_4_LSB; + FNAV_WNot_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_W_NOT_4_BIT)); + FNAV_WNlsf_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_W_NLSF_4_BIT)); + FNAV_DN_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_DN_4_BIT)); + FNAV_deltatlsf_4 = static_cast(read_navigation_signed(data_bits, FNAV_DELTATLSF_4_BIT)); + FNAV_t0g_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_T0G_4_BIT)); + FNAV_t0g_4 *= FNAV_T0G_4_LSB; + FNAV_A0g_4 = static_cast(read_navigation_signed(data_bits, FNAV_A0G_4_BIT)); + FNAV_A0g_4 *= FNAV_A0G_4_LSB; + FNAV_A1g_4 = static_cast(read_navigation_signed(data_bits, FNAV_A1G_4_BIT)); + FNAV_A1g_4 *= FNAV_A1G_4_LSB; + FNAV_WN0g_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_W_N0G_4_BIT)); + FNAV_TOW_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_4_BIT)); flag_TOW_4 = true; flag_TOW_set = true; flag_ephemeris_3 = true; - flag_utc_model = true; //set to false externally + flag_utc_model = true; // set to false externally break; case 5: // Almanac (SVID1 and SVID2(1/2)), Week Number and almanac reference time - FNAV_IODa_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODa_5_bit)); - FNAV_WNa_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_WNa_5_bit)); - FNAV_t0a_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_t0a_5_bit)); - FNAV_t0a_5 *= FNAV_t0a_5_LSB; - FNAV_SVID1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID1_5_bit)); - FNAV_Deltaa12_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_Deltaa12_1_5_bit)); - FNAV_Deltaa12_1_5 *= FNAV_Deltaa12_5_LSB; - FNAV_e_1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_e_1_5_bit)); - FNAV_e_1_5 *= FNAV_e_5_LSB; - FNAV_w_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_w_1_5_bit)); - FNAV_w_1_5 *= FNAV_w_5_LSB; - FNAV_deltai_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_deltai_1_5_bit)); - FNAV_deltai_1_5 *= FNAV_deltai_5_LSB; - FNAV_Omega0_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_Omega0_1_5_bit)); - FNAV_Omega0_1_5 *= FNAV_Omega0_5_LSB; - FNAV_Omegadot_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_Omegadot_1_5_bit)); - FNAV_Omegadot_1_5 *= FNAV_Omegadot_5_LSB; - FNAV_M0_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_M0_1_5_bit)); + FNAV_IODa_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_IO_DA_5_BIT)); + FNAV_WNa_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_W_NA_5_BIT)); + FNAV_t0a_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_T0A_5_BIT)); + FNAV_t0a_5 *= FNAV_T0A_5_LSB; + FNAV_SVID1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVI_D1_5_BIT)); + FNAV_Deltaa12_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_DELTAA12_1_5_BIT)); + FNAV_Deltaa12_1_5 *= FNAV_DELTAA12_5_LSB; + FNAV_e_1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_E_1_5_BIT)); + FNAV_e_1_5 *= FNAV_E_5_LSB; + FNAV_w_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_W_1_5_BIT)); + FNAV_w_1_5 *= FNAV_W_5_LSB; + FNAV_deltai_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_DELTAI_1_5_BIT)); + FNAV_deltai_1_5 *= FNAV_DELTAI_5_LSB; + FNAV_Omega0_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_OMEGA0_1_5_BIT)); + FNAV_Omega0_1_5 *= FNAV_OMEGA0_5_LSB; + FNAV_Omegadot_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_OMEGADOT_1_5_BIT)); + FNAV_Omegadot_1_5 *= FNAV_OMEGADOT_5_LSB; + FNAV_M0_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_M0_1_5_BIT)); FNAV_M0_1_5 *= FNAV_M0_5_LSB; - FNAV_af0_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_af0_1_5_bit)); - FNAV_af0_1_5 *= FNAV_af0_5_LSB; - FNAV_af1_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_af1_1_5_bit)); - FNAV_af1_1_5 *= FNAV_af1_5_LSB; - FNAV_E5ahs_1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_1_5_bit)); - FNAV_SVID2_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID2_5_bit)); - FNAV_Deltaa12_2_5 = static_cast(read_navigation_signed(data_bits, FNAV_Deltaa12_2_5_bit)); - FNAV_Deltaa12_2_5 *= FNAV_Deltaa12_5_LSB; - FNAV_e_2_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_e_2_5_bit)); - FNAV_e_2_5 *= FNAV_e_5_LSB; - FNAV_w_2_5 = static_cast(read_navigation_signed(data_bits, FNAV_w_2_5_bit)); - FNAV_w_2_5 *= FNAV_w_5_LSB; - FNAV_deltai_2_5 = static_cast(read_navigation_signed(data_bits, FNAV_deltai_2_5_bit)); - FNAV_deltai_2_5 *= FNAV_deltai_5_LSB; + FNAV_af0_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_AF0_1_5_BIT)); + FNAV_af0_1_5 *= FNAV_AF0_5_LSB; + FNAV_af1_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_AF1_1_5_BIT)); + FNAV_af1_1_5 *= FNAV_AF1_5_LSB; + FNAV_E5ahs_1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5AHS_1_5_BIT)); + FNAV_SVID2_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVI_D2_5_BIT)); + FNAV_Deltaa12_2_5 = static_cast(read_navigation_signed(data_bits, FNAV_DELTAA12_2_5_BIT)); + FNAV_Deltaa12_2_5 *= FNAV_DELTAA12_5_LSB; + FNAV_e_2_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_E_2_5_BIT)); + FNAV_e_2_5 *= FNAV_E_5_LSB; + FNAV_w_2_5 = static_cast(read_navigation_signed(data_bits, FNAV_W_2_5_BIT)); + FNAV_w_2_5 *= FNAV_W_5_LSB; + FNAV_deltai_2_5 = static_cast(read_navigation_signed(data_bits, FNAV_DELTAI_2_5_BIT)); + FNAV_deltai_2_5 *= FNAV_DELTAI_5_LSB; //TODO check this // Omega0_2 must be decoded when the two pieces are joined omega0_1 = data.substr(210, 4); //omega_flag=true; // //FNAV_Omega012_2_5=static_cast(read_navigation_signed(data_bits, FNAV_Omega012_2_5_bit); - flag_almanac_1 = true; break; case 6: // Almanac (SVID2(2/2) and SVID3) - FNAV_IODa_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODa_6_bit)); - - /* Don't worry about omega pieces. If page 5 has not been received, all_ephemeris - * flag will be set to false and the data won't be recorded.*/ + FNAV_IODa_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_IO_DA_6_BIT)); + // Don't worry about omega pieces. If page 5 has not been received, all_ephemeris + // flag will be set to false and the data won't be recorded.*/ std::string omega0_2 = data.substr(10, 12); std::string Omega0 = omega0_1 + omega0_2; std::bitset omega_bits(Omega0); - const std::vector> om_bit({{0, 12}}); + const std::vector> om_bit({{0, 12}}); FNAV_Omega0_2_6 = static_cast(read_navigation_signed(omega_bits, om_bit)); - FNAV_Omega0_2_6 *= FNAV_Omega0_5_LSB; - // - FNAV_Omegadot_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_Omegadot_2_6_bit)); - FNAV_Omegadot_2_6 *= FNAV_Omegadot_5_LSB; - FNAV_M0_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_M0_2_6_bit)); + FNAV_Omega0_2_6 *= FNAV_OMEGA0_5_LSB; + FNAV_Omegadot_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_OMEGADOT_2_6_BIT)); + FNAV_Omegadot_2_6 *= FNAV_OMEGADOT_5_LSB; + FNAV_M0_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_M0_2_6_BIT)); FNAV_M0_2_6 *= FNAV_M0_5_LSB; - FNAV_af0_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_af0_2_6_bit)); - FNAV_af0_2_6 *= FNAV_af0_5_LSB; - FNAV_af1_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_af1_2_6_bit)); - FNAV_af1_2_6 *= FNAV_af1_5_LSB; - FNAV_E5ahs_2_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_2_6_bit)); - FNAV_SVID3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID3_6_bit)); - FNAV_Deltaa12_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_Deltaa12_3_6_bit)); - FNAV_Deltaa12_3_6 *= FNAV_Deltaa12_5_LSB; - FNAV_e_3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_e_3_6_bit)); - FNAV_e_3_6 *= FNAV_e_5_LSB; - FNAV_w_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_w_3_6_bit)); - FNAV_w_3_6 *= FNAV_w_5_LSB; - FNAV_deltai_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_deltai_3_6_bit)); - FNAV_deltai_3_6 *= FNAV_deltai_5_LSB; - FNAV_Omega0_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_Omega0_3_6_bit)); - FNAV_Omega0_3_6 *= FNAV_Omega0_5_LSB; - FNAV_Omegadot_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_Omegadot_3_6_bit)); - FNAV_Omegadot_3_6 *= FNAV_Omegadot_5_LSB; - FNAV_M0_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_M0_3_6_bit)); + FNAV_af0_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_AF0_2_6_BIT)); + FNAV_af0_2_6 *= FNAV_AF0_5_LSB; + FNAV_af1_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_AF1_2_6_BIT)); + FNAV_af1_2_6 *= FNAV_AF1_5_LSB; + FNAV_E5ahs_2_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5AHS_2_6_BIT)); + FNAV_SVID3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVI_D3_6_BIT)); + FNAV_Deltaa12_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_DELTAA12_3_6_BIT)); + FNAV_Deltaa12_3_6 *= FNAV_DELTAA12_5_LSB; + FNAV_e_3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_E_3_6_BIT)); + FNAV_e_3_6 *= FNAV_E_5_LSB; + FNAV_w_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_W_3_6_BIT)); + FNAV_w_3_6 *= FNAV_W_5_LSB; + FNAV_deltai_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_DELTAI_3_6_BIT)); + FNAV_deltai_3_6 *= FNAV_DELTAI_5_LSB; + FNAV_Omega0_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_OMEGA0_3_6_BIT)); + FNAV_Omega0_3_6 *= FNAV_OMEGA0_5_LSB; + FNAV_Omegadot_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_OMEGADOT_3_6_BIT)); + FNAV_Omegadot_3_6 *= FNAV_OMEGADOT_5_LSB; + FNAV_M0_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_M0_3_6_BIT)); FNAV_M0_3_6 *= FNAV_M0_5_LSB; - FNAV_af0_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_af0_3_6_bit)); - FNAV_af0_3_6 *= FNAV_af0_5_LSB; - FNAV_af1_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_af1_3_6_bit)); - FNAV_af1_3_6 *= FNAV_af1_5_LSB; - FNAV_E5ahs_3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_3_6_bit)); + FNAV_af0_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_AF0_3_6_BIT)); + FNAV_af0_3_6 *= FNAV_AF0_5_LSB; + FNAV_af1_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_AF1_3_6_BIT)); + FNAV_af1_3_6 *= FNAV_AF1_5_LSB; + FNAV_E5ahs_3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5AHS_3_6_BIT)); flag_almanac_2 = true; break; @@ -450,16 +430,16 @@ void Galileo_Fnav_Message::decode_page(std::string data) } -unsigned long int Galileo_Fnav_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +uint64_t Galileo_Fnav_Message::read_navigation_unsigned(std::bitset bits, const std::vector>& parameter) { - unsigned long int value = 0; + uint64_t value = 0ULL; int num_of_slices = parameter.size(); for (int i = 0; i < num_of_slices; i++) { for (int j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1) + value <<= 1; // shift left + if (static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j]) == 1) { value += 1; // insert the bit } @@ -469,59 +449,30 @@ unsigned long int Galileo_Fnav_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +int64_t Galileo_Fnav_Message::read_navigation_signed(std::bitset bits, const std::vector>& parameter) { - signed long int value = 0; + int64_t value = 0LL; int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(signed long int); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } + // read the MSB and perform the sign extension + if (static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first]) == 1) + { + value ^= 0x0FFFFFFFFFFFFFFF; // 64 bits variable } - else // we assume we are in a 32 bits system + else { - // read the MSB and perform the sign extension - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } + value &= 0; + } - for (int i = 0; i < num_of_slices; i++) + for (int i = 0; i < num_of_slices; i++) + { + for (int j = 0; j < parameter[i].second; j++) { - for (int j = 0; j < parameter[i].second; j++) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) + if (static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j]) == 1) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value += 1; // insert the bit } } } @@ -529,11 +480,11 @@ signed long int Galileo_Fnav_Message::read_navigation_signed(std::bitset // for boost::uint16_t #include +#include #include -#include #include +#include /*! * \brief This class handles the Galileo F/NAV Data message, as described in the @@ -57,18 +57,7 @@ class Galileo_Fnav_Message { public: - // void Galileo_Fnav_Message::split_page(std::string page_string); - // void Galileo_Fnav_Message::reset(); - // bool Galileo_Fnav_Message::have_new_ephemeris(); - // bool Galileo_Fnav_Message::have_new_iono_and_GST(); - // bool Galileo_Fnav_Message::have_new_utc_model(); - // bool Galileo_Fnav_Message::have_new_almanac(); - // Galileo_Ephemeris Galileo_Fnav_Message::get_ephemeris(); - // Galileo_Iono Galileo_Fnav_Message::get_iono(); - // Galileo_Utc_Model Galileo_Fnav_Message::get_utc_model(); - // Galileo_Almanac Galileo_Fnav_Message::get_almanac(); - // - void split_page(std::string page_string); + void split_page(const std::string& page_string); void reset(); bool have_new_ephemeris(); bool have_new_iono_and_GST(); @@ -77,7 +66,7 @@ public: Galileo_Ephemeris get_ephemeris(); Galileo_Iono get_iono(); Galileo_Utc_Model get_utc_model(); - Galileo_Almanac get_almanac(); + Galileo_Almanac_Helper get_almanac(); Galileo_Fnav_Message(); @@ -99,18 +88,18 @@ public: bool flag_almanac_1; //!< Flag indicating that almanac 1/2 (word 5) have been received bool flag_almanac_2; //!< Flag indicating that almanac 2/2 (word 6) have been received - int IOD_ephemeris; + int32_t IOD_ephemeris; - int page_type; - /* WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal - * health and Data validity status*/ - int FNAV_SV_ID_PRN_1; - int FNAV_IODnav_1; - double FNAV_t0c_1; + int32_t page_type; + // WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal + // health and Data validity status + int32_t FNAV_SV_ID_PRN_1; + int32_t FNAV_IODnav_1; + int32_t FNAV_t0c_1; double FNAV_af0_1; double FNAV_af1_1; double FNAV_af2_1; - double FNAV_SISA_1; + int32_t FNAV_SISA_1; double FNAV_ai0_1; double FNAV_ai1_1; double FNAV_ai2_1; @@ -120,24 +109,24 @@ public: bool FNAV_region4_1; bool FNAV_region5_1; double FNAV_BGD_1; - double FNAV_E5ahs_1; - double FNAV_WN_1; - double FNAV_TOW_1; + int32_t FNAV_E5ahs_1; + int32_t FNAV_WN_1; + int32_t FNAV_TOW_1; bool FNAV_E5advs_1; // WORD 2 Ephemeris (1/3) and GST - int FNAV_IODnav_2; + int32_t FNAV_IODnav_2; double FNAV_M0_2; double FNAV_omegadot_2; double FNAV_e_2; double FNAV_a12_2; double FNAV_omega0_2; double FNAV_idot_2; - double FNAV_WN_2; - double FNAV_TOW_2; + int32_t FNAV_WN_2; + int32_t FNAV_TOW_2; // WORD 3 Ephemeris (2/3) and GST - int FNAV_IODnav_3; + int32_t FNAV_IODnav_3; double FNAV_i0_3; double FNAV_w_3; double FNAV_deltan_3; @@ -145,34 +134,34 @@ public: double FNAV_Cus_3; double FNAV_Crc_3; double FNAV_Crs_3; - double FNAV_t0e_3; - double FNAV_WN_3; - double FNAV_TOW_3; + int32_t FNAV_t0e_3; + int32_t FNAV_WN_3; + int32_t FNAV_TOW_3; - /* WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. - Note that the clock is repeated in this page type*/ - int FNAV_IODnav_4; + // WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. + // Note that the clock is repeated in this page type + int32_t FNAV_IODnav_4; double FNAV_Cic_4; double FNAV_Cis_4; double FNAV_A0_4; double FNAV_A1_4; - double FNAV_deltatls_4; - double FNAV_t0t_4; - double FNAV_WNot_4; - double FNAV_WNlsf_4; - double FNAV_DN_4; - double FNAV_deltatlsf_4; - double FNAV_t0g_4; + int32_t FNAV_deltatls_4; + int32_t FNAV_t0t_4; + int32_t FNAV_WNot_4; + int32_t FNAV_WNlsf_4; + int32_t FNAV_DN_4; + int32_t FNAV_deltatlsf_4; + int32_t FNAV_t0g_4; double FNAV_A0g_4; double FNAV_A1g_4; - double FNAV_WN0g_4; - double FNAV_TOW_4; + int32_t FNAV_WN0g_4; + int32_t FNAV_TOW_4; // WORD 5 Almanac (SVID1 and SVID2(1/2)), Week Number and almanac reference time - int FNAV_IODa_5; - double FNAV_WNa_5; - double FNAV_t0a_5; - int FNAV_SVID1_5; + int32_t FNAV_IODa_5; + int32_t FNAV_WNa_5; + int32_t FNAV_t0a_5; + int32_t FNAV_SVID1_5; double FNAV_Deltaa12_1_5; double FNAV_e_1_5; double FNAV_w_1_5; @@ -182,22 +171,22 @@ public: double FNAV_M0_1_5; double FNAV_af0_1_5; double FNAV_af1_1_5; - unsigned int FNAV_E5ahs_1_5; - int FNAV_SVID2_5; + uint32_t FNAV_E5ahs_1_5; + int32_t FNAV_SVID2_5; double FNAV_Deltaa12_2_5; double FNAV_e_2_5; double FNAV_w_2_5; double FNAV_deltai_2_5; // WORD 6 Almanac (SVID2(2/2) and SVID3) - int FNAV_IODa_6; + int32_t FNAV_IODa_6; double FNAV_Omega0_2_6; double FNAV_Omegadot_2_6; double FNAV_M0_2_6; double FNAV_af0_2_6; double FNAV_af1_2_6; - double FNAV_E5ahs_2_6; - int FNAV_SVID3_6; + int32_t FNAV_E5ahs_2_6; + int32_t FNAV_SVID3_6; double FNAV_Deltaa12_3_6; double FNAV_e_3_6; double FNAV_w_3_6; @@ -207,14 +196,13 @@ public: double FNAV_M0_3_6; double FNAV_af0_3_6; double FNAV_af1_3_6; - double FNAV_E5ahs_3_6; - + int32_t FNAV_E5ahs_3_6; private: - bool _CRC_test(std::bitset bits, boost::uint32_t checksum); - void decode_page(std::string data); - unsigned long int read_navigation_unsigned(std::bitset bits, const std::vector> parameter); - signed long int read_navigation_signed(std::bitset bits, const std::vector> parameter); + bool _CRC_test(std::bitset bits, uint32_t checksum); + void decode_page(const std::string& data); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector>& parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector>& parameter); std::string omega0_1; //std::string omega0_2; diff --git a/src/core/system_parameters/galileo_iono.cc b/src/core/system_parameters/galileo_iono.cc index 4a8eb35b0..440abbc44 100644 --- a/src/core/system_parameters/galileo_iono.cc +++ b/src/core/system_parameters/galileo_iono.cc @@ -33,12 +33,12 @@ Galileo_Iono::Galileo_Iono() { - /* Ionospheric correction */ - ai0_5 = 0; // Effective Ionisation Level 1st order parameter [sfu] - ai1_5 = 0; // Effective Ionisation Level 2st order parameter [sfu/degree] - ai2_5 = 0; // Effective Ionisation Level 3st order parameter [sfu/degree] + // Ionospheric correction + ai0_5 = 0.0; // Effective Ionisation Level 1st order parameter [sfu] + ai1_5 = 0.0; // Effective Ionisation Level 2st order parameter [sfu/degree] + ai2_5 = 0.0; // Effective Ionisation Level 3st order parameter [sfu/degree] - /* Ionospheric disturbance flag */ + // Ionospheric disturbance flag Region1_flag_5 = false; // Ionospheric Disturbance Flag for region 1 Region2_flag_5 = false; // Ionospheric Disturbance Flag for region 2 Region3_flag_5 = false; // Ionospheric Disturbance Flag for region 3 diff --git a/src/core/system_parameters/galileo_iono.h b/src/core/system_parameters/galileo_iono.h index 1c3278ed7..ab36199c0 100644 --- a/src/core/system_parameters/galileo_iono.h +++ b/src/core/system_parameters/galileo_iono.h @@ -32,6 +32,7 @@ #ifndef GNSS_SDR_GALILEO_IONO_H_ #define GNSS_SDR_GALILEO_IONO_H_ +#include /*! * \brief This class is a storage for the GALILEO IONOSPHERIC data as described in Galileo ICD paragraph 5.1.6 @@ -41,26 +42,50 @@ class Galileo_Iono { public: - /*Ionospheric correction*/ + // Ionospheric correction double ai0_5; //!< Effective Ionisation Level 1st order parameter [sfu] double ai1_5; //!< Effective Ionisation Level 2st order parameter [sfu/degree] double ai2_5; //!< Effective Ionisation Level 3st order parameter [sfu/degree] - /*Ionospheric disturbance flag*/ + // Ionospheric disturbance flag bool Region1_flag_5; //!< Ionospheric Disturbance Flag for region 1 bool Region2_flag_5; //!< Ionospheric Disturbance Flag for region 2 bool Region3_flag_5; //!< Ionospheric Disturbance Flag for region 3 bool Region4_flag_5; //!< Ionospheric Disturbance Flag for region 4 bool Region5_flag_5; //!< Ionospheric Disturbance Flag for region 5 - /*from page 5 (UTC) to have a timestamp*/ - double TOW_5; //!< UTC data reference Time of Week [s] - double WN_5; //!< UTC data reference Week number [week] + // from page 5 (UTC) to have a timestamp + int32_t TOW_5; //!< UTC data reference Time of Week [s] + int32_t WN_5; //!< UTC data reference Week number [week] /*! * Default constructor */ Galileo_Iono(); + + template + + /*! + * \brief Serialize is a boost standard method to be called by the boost XML serialization. + Here is used to save the iono data on disk file. + */ + inline void serialize(Archive& archive, const unsigned int version) + { + using boost::serialization::make_nvp; + if (version) + { + }; + archive& make_nvp("ai0_5", ai0_5); + archive& make_nvp("ai1_5", ai1_5); + archive& make_nvp("ai2_5", ai2_5); + archive& make_nvp("Region1_flag_5", Region1_flag_5); + archive& make_nvp("Region2_flag_5", Region2_flag_5); + archive& make_nvp("Region3_flag_5", Region3_flag_5); + archive& make_nvp("Region4_flag_5", Region4_flag_5); + archive& make_nvp("Region5_flag_5", Region5_flag_5); + archive& make_nvp("TOW_5", TOW_5); + archive& make_nvp("WN_5", WN_5); + } }; #endif diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index 95edb4bd5..ea3e7889b 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -37,7 +37,7 @@ #include -typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> CRC_Galileo_INAV_type; +using CRC_Galileo_INAV_type = boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false>; void Galileo_Navigation_Message::reset() @@ -61,7 +61,7 @@ void Galileo_Navigation_Message::reset() flag_almanac_3 = false; // flag indicating that almanac 3/4 (word 9) have been received flag_almanac_4 = false; // flag indicating that almanac 4/4 (word 10) have been received - flag_TOW_5 = 0; + flag_TOW_5 = false; flag_TOW_set = false; flag_GGTO = false; @@ -71,70 +71,71 @@ void Galileo_Navigation_Message::reset() flag_GGTO_4 = false; IOD_ephemeris = 0; - /*Word type 1: Ephemeris (1/4)*/ + + // Word type 1: Ephemeris (1/4) IOD_nav_1 = 0; t0e_1 = 0; - M0_1 = 0; - e_1 = 0; - A_1 = 0; + M0_1 = 0.0; + e_1 = 0.0; + A_1 = 0.0; - /*Word type 2: Ephemeris (2/4)*/ - IOD_nav_2 = 0; // IOD_nav page 2 - OMEGA_0_2 = 0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] - i_0_2 = 0; // Inclination angle at reference time [semi-circles] - omega_2 = 0; // Argument of perigee [semi-circles] - iDot_2 = 0; // Rate of inclination angle [semi-circles/sec] + // Word type 2: Ephemeris (2/4) + IOD_nav_2 = 0; // IOD_nav page 2 + OMEGA_0_2 = 0.0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] + i_0_2 = 0.0; // Inclination angle at reference time [semi-circles] + omega_2 = 0.0; // Argument of perigee [semi-circles] + iDot_2 = 0.0; // Rate of inclination angle [semi-circles/sec] + // Word type 3: Ephemeris (3/4) and SISA + IOD_nav_3 = 0; + OMEGA_dot_3 = 0.0; // Rate of right ascension [semi-circles/sec] + delta_n_3 = 0.0; // Mean motion difference from computed value [semi-circles/sec] + C_uc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] + C_us_3 = 0.0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] + C_rc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] + C_rs_3 = 0.0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] + SISA_3 = 0; // - /*Word type 3: Ephemeris (3/4) and SISA*/ - IOD_nav_3 = 0; // - OMEGA_dot_3 = 0; // Rate of right ascension [semi-circles/sec] - delta_n_3 = 0; // Mean motion difference from computed value [semi-circles/sec] - C_uc_3 = 0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] - C_us_3 = 0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] - C_rc_3 = 0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] - C_rs_3 = 0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] - SISA_3 = 0; // + // Word type 4: Ephemeris (4/4) and Clock correction parameter/ + IOD_nav_4 = 0; + SV_ID_PRN_4 = 0; + C_ic_4 = 0.0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] + C_is_4 = 0.0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] + // Clock correction parameters + t0c_4 = 0; + af0_4 = 0.0; + af1_4 = 0.0; + af2_4 = 0.0; + spare_4 = 0.0; - /*Word type 4: Ephemeris (4/4) and Clock correction parameters*/ - IOD_nav_4 = 0; // - SV_ID_PRN_4 = 0; // - C_ic_4 = 0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] - C_is_4 = 0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] - /*Clock correction parameters*/ - t0c_4 = 0; // - af0_4 = 0; // - af1_4 = 0; // - af2_4 = 0; // - spare_4 = 0; + // Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST + // Ionospheric correction + ai0_5 = 0.0; + ai1_5 = 0.0; + ai2_5 = 0.0; - /*Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST*/ - /*Ionospheric correction*/ - /*Az*/ - ai0_5 = 0; // - ai1_5 = 0; // - ai2_5 = 0; // - /*Ionospheric disturbance flag*/ - Region1_flag_5 = 0; // Region1_flag_5; - Region2_flag_5 = 0; // - Region3_flag_5 = 0; // - Region4_flag_5 = 0; // - Region5_flag_5 = 0; // - BGD_E1E5a_5 = 0; // - BGD_E1E5b_5 = 0; // + // Ionospheric disturbance flag + Region1_flag_5 = false; // Region1_flag_5; + Region2_flag_5 = false; + Region3_flag_5 = false; + Region4_flag_5 = false; + Region5_flag_5 = false; + BGD_E1E5a_5 = 0.0; + BGD_E1E5b_5 = 0.0; E5b_HS_5 = 0; E1B_HS_5 = 0; - E5b_DVS_5 = 0; // - E1B_DVS_5 = 0; // - /*GST*/ + E5b_DVS_5 = false; + E1B_DVS_5 = false; + + // GST WN_5 = 0; TOW_5 = 0; - spare_5 = 0; + spare_5 = 0.0; - /*Word type 6: GST-UTC conversion parameters*/ - A0_6 = 0; - A1_6 = 0; + // Word type 6: GST-UTC conversion parameters + A0_6 = 0.0; + A1_6 = 0.0; Delta_tLS_6 = 0; t0t_6 = 0; WNot_6 = 0; @@ -143,64 +144,65 @@ void Galileo_Navigation_Message::reset() Delta_tLSF_6 = 0; TOW_6 = 0; - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number IOD_a_7 = 0; WN_a_7 = 0; t0a_7 = 0; SVID1_7 = 0; - DELTA_A_7 = 0; - e_7 = 0; - omega_7 = 0; - delta_i_7 = 0; - Omega0_7 = 0; - Omega_dot_7 = 0; - M0_7 = 0; + DELTA_A_7 = 0.0; + e_7 = 0.0; + omega_7 = 0.0; + delta_i_7 = 0.0; + Omega0_7 = 0.0; + Omega_dot_7 = 0.0; + M0_7 = 0.0; - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) IOD_a_8 = 0; - af0_8 = 0; - af1_8 = 0; + af0_8 = 0.0; + af1_8 = 0.0; E5b_HS_8 = 0; E1B_HS_8 = 0; SVID2_8 = 0; - DELTA_A_8 = 0; - e_8 = 0; - omega_8 = 0; - delta_i_8 = 0; - Omega0_8 = 0; - Omega_dot_8 = 0; + DELTA_A_8 = 0.0; + e_8 = 0.0; + omega_8 = 0.0; + delta_i_8 = 0.0; + Omega0_8 = 0.0; + Omega_dot_8 = 0.0; - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) IOD_a_9 = 0; WN_a_9 = 0; t0a_9 = 0; - M0_9 = 0; - af0_9 = 0; - af1_9 = 0; + M0_9 = 0.0; + af0_9 = 0.0; + af1_9 = 0.0; E5b_HS_9 = 0; E1B_HS_9 = 0; SVID3_9 = 0; - DELTA_A_9 = 0; - e_9 = 0; - omega_9 = 0; - delta_i_9 = 0; + DELTA_A_9 = 0.0; + e_9 = 0.0; + omega_9 = 0.0; + delta_i_9 = 0.0; - /*Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters*/ + // Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters IOD_a_10 = 0; - Omega0_10 = 0; - Omega_dot_10 = 0; - M0_10 = 0; - af0_10 = 0; - af1_10 = 0; + Omega0_10 = 0.0; + Omega_dot_10 = 0.0; + M0_10 = 0.0; + af0_10 = 0.0; + af1_10 = 0.0; E5b_HS_10 = 0; E1B_HS_10 = 0; - //GST-GPS - A_0G_10 = 0; - A_1G_10 = 0; + + // GST-GPS + A_0G_10 = 0.0; + A_1G_10 = 0.0; t_0G_10 = 0; WN_0G_10 = 0; - /*Word type 0: I/NAV Spare Word*/ + // Word type 0: I/NAV Spare Word Time_0 = 0; WN_0 = 0; TOW_0 = 0; @@ -227,11 +229,11 @@ Galileo_Navigation_Message::Galileo_Navigation_Message() } -bool Galileo_Navigation_Message::CRC_test(std::bitset bits, boost::uint32_t checksum) +bool Galileo_Navigation_Message::CRC_test(std::bitset bits, uint32_t checksum) { CRC_Galileo_INAV_type CRC_Galileo; - boost::uint32_t crc_computed; + uint32_t crc_computed; // Galileo INAV frame for CRC is not an integer multiple of bytes // it needs to be filled with zeroes at the start of the frame. // This operation is done in the transformation from bits to bytes @@ -251,25 +253,72 @@ bool Galileo_Navigation_Message::CRC_test(std::bitset b { return true; } + return false; +} + + +uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector >& parameter) +{ + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) + { + value <<= 1; // shift left + if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[i].first - j]) == 1) + { + value += 1; // insert the bit + } + } + } + return value; +} + + +uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset bits, const std::vector >& parameter) +{ + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) + { + value <<= 1; // shift left + if (static_cast(bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j]) == 1) + { + value += 1ULL; // insert the bit + } + } + } + return value; +} + + +int64_t Galileo_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector >& parameter) +{ + int64_t value = 0LL; + int32_t num_of_slices = parameter.size(); + + // read the MSB and perform the sign extension + if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[0].first]) == 1) + { + value ^= 0xFFFFFFFFFFFFFFFFLL; // 64 bits variable + } else { - return false; + value &= 0LL; } -} - -unsigned long int Galileo_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector > parameter) -{ - unsigned long int value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left - if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) + if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[i].first - j]) == 1) { - value += 1; // insert the bit + value += 1LL; // insert the bit } } } @@ -277,89 +326,10 @@ unsigned long int Galileo_Navigation_Message::read_navigation_unsigned(std::bits } -unsigned long int Galileo_Navigation_Message::read_page_type_unsigned(std::bitset bits, const std::vector > parameter) -{ - unsigned long int value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - if (bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } - return value; -} - - -signed long int Galileo_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector > parameter) -{ - signed long int value = 0; - int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(signed long int); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } - - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } - } - else // we assume we are in a 32 bits system - { - // read the MSB and perform the sign extension - if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } - - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } - } - return value; -} - - -bool Galileo_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector > parameter) +bool Galileo_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector >& parameter) { bool value; - if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) + if (static_cast(static_cast(bits[GALILEO_DATA_JK_BITS - parameter[0].first])) == 1) { value = true; } @@ -371,20 +341,20 @@ bool Galileo_Navigation_Message::read_navigation_bool(std::bitset page_type_bits(page_number_bits); // from string to bitset - Page_type = static_cast(read_page_type_unsigned(page_type_bits, type)); + Page_type = static_cast(read_page_type_unsigned(page_type_bits, TYPE)); Page_type_time_stamp = Page_type; std::string Data_jk_ephemeris = Data_k + Data_j; page_jk_decoder(Data_jk_ephemeris.c_str()); @@ -452,11 +422,11 @@ void Galileo_Navigation_Message::split_page(std::string page_string, int flag_ev } -bool Galileo_Navigation_Message::have_new_ephemeris() //Check if we have a new ephemeris stored in the galileo navigation class +bool Galileo_Navigation_Message::have_new_ephemeris() // Check if we have a new ephemeris stored in the galileo navigation class { if ((flag_ephemeris_1 == true) and (flag_ephemeris_2 == true) and (flag_ephemeris_3 == true) and (flag_ephemeris_4 == true) and (flag_iono_and_GST == true)) { - //if all ephemeris pages have the same IOD, then they belong to the same block + // if all ephemeris pages have the same IOD, then they belong to the same block if ((IOD_nav_1 == IOD_nav_2) and (IOD_nav_3 == IOD_nav_4) and (IOD_nav_1 == IOD_nav_3)) { std::cout << "Ephemeris (1, 2, 3, 4) have been received and belong to the same batch" << std::endl; @@ -469,25 +439,20 @@ bool Galileo_Navigation_Message::have_new_ephemeris() //Check if we have a new std::cout << "Batch number: " << IOD_ephemeris << std::endl; return true; } - else - { - return false; - } } - else - return false; + return false; } -bool Galileo_Navigation_Message::have_new_iono_and_GST() //Check if we have a new iono data set stored in the galileo navigation class +bool Galileo_Navigation_Message::have_new_iono_and_GST() // Check if we have a new iono data set stored in the galileo navigation class { - if ((flag_iono_and_GST == true) and (flag_utc_model == true)) //the condition on flag_utc_model is added to have a time stamp for iono + if ((flag_iono_and_GST == true) and (flag_utc_model == true)) // the condition on flag_utc_model is added to have a time stamp for iono { flag_iono_and_GST = false; // clear the flag return true; } - else - return false; + + return false; } @@ -498,16 +463,16 @@ bool Galileo_Navigation_Message::have_new_utc_model() // Check if we have a new flag_utc_model = false; // clear the flag return true; } - else - return false; + + return false; } -bool Galileo_Navigation_Message::have_new_almanac() //Check if we have a new almanac data set stored in the galileo navigation class +bool Galileo_Navigation_Message::have_new_almanac() // Check if we have a new almanac data set stored in the galileo navigation class { if ((flag_almanac_1 == true) and (flag_almanac_2 == true) and (flag_almanac_3 == true) and (flag_almanac_4 == true)) { - //All almanac have been received + // All almanac have been received flag_almanac_1 = false; flag_almanac_2 = false; flag_almanac_3 = false; @@ -515,8 +480,8 @@ bool Galileo_Navigation_Message::have_new_almanac() //Check if we have a new al flag_all_almanac = true; return true; } - else - return false; + + return false; } @@ -544,13 +509,13 @@ Galileo_Ephemeris Galileo_Navigation_Message::get_ephemeris() ephemeris.C_is_4 = C_is_4; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] ephemeris.t0e_1 = t0e_1; // Ephemeris reference time [s] - /*Clock correction parameters*/ + // Clock correction parameters ephemeris.t0c_4 = t0c_4; // Clock correction data reference Time of Week [sec] ephemeris.af0_4 = af0_4; // SV clock bias correction coefficient [s] ephemeris.af1_4 = af1_4; // SV clock drift correction coefficient [s/s] ephemeris.af2_4 = af2_4; // SV clock drift rate correction coefficient [s/s^2] - /*GST*/ + // GST ephemeris.WN_5 = WN_5; // Week number ephemeris.TOW_5 = TOW_5; // Time of Week @@ -572,20 +537,19 @@ Galileo_Ephemeris Galileo_Navigation_Message::get_ephemeris() Galileo_Iono Galileo_Navigation_Message::get_iono() { Galileo_Iono iono; - /*Ionospheric correction*/ - /*Az*/ + // Ionospheric correction iono.ai0_5 = ai0_5; // Effective Ionisation Level 1st order parameter [sfu] iono.ai1_5 = ai1_5; // Effective Ionisation Level 2st order parameter [sfu/degree] iono.ai2_5 = ai2_5; // Effective Ionisation Level 3st order parameter [sfu/degree] - /*Ionospheric disturbance flag*/ + // Ionospheric disturbance flag iono.Region1_flag_5 = Region1_flag_5; // Ionospheric Disturbance Flag for region 1 iono.Region2_flag_5 = Region2_flag_5; // Ionospheric Disturbance Flag for region 2 iono.Region3_flag_5 = Region3_flag_5; // Ionospheric Disturbance Flag for region 3 iono.Region4_flag_5 = Region4_flag_5; // Ionospheric Disturbance Flag for region 4 iono.Region5_flag_5 = Region5_flag_5; // Ionospheric Disturbance Flag for region 5 - /*GST*/ + // GST // This is the ONLY page containing the Week Number (WN) iono.TOW_5 = TOW_5; iono.WN_5 = WN_5; @@ -596,8 +560,7 @@ Galileo_Iono Galileo_Navigation_Message::get_iono() Galileo_Utc_Model Galileo_Navigation_Message::get_utc_model() { Galileo_Utc_Model utc_model; - //Gal_utc_model.valid = flag_utc_model_valid; - /*Word type 6: GST-UTC conversion parameters*/ + // Word type 6: GST-UTC conversion parameters utc_model.A0_6 = A0_6; utc_model.A1_6 = A1_6; utc_model.Delta_tLS_6 = Delta_tLS_6; @@ -607,17 +570,19 @@ Galileo_Utc_Model Galileo_Navigation_Message::get_utc_model() utc_model.DN_6 = DN_6; utc_model.Delta_tLSF_6 = Delta_tLSF_6; utc_model.flag_utc_model = flag_utc_model; - /*GST*/ - //utc_model.WN_5 = WN_5; //Week number - //utc_model.TOW_5 = WN_5; //Time of Week + // GPS to Galileo GST conversion parameters + utc_model.A_0G_10 = A_0G_10; + utc_model.A_1G_10 = A_1G_10; + utc_model.t_0G_10 = t_0G_10; + utc_model.WN_0G_10 = WN_0G_10; return utc_model; } -Galileo_Almanac Galileo_Navigation_Message::get_almanac() +Galileo_Almanac_Helper Galileo_Navigation_Message::get_almanac() { - Galileo_Almanac almanac; - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ + Galileo_Almanac_Helper almanac; + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number almanac.IOD_a_7 = IOD_a_7; almanac.WN_a_7 = WN_a_7; almanac.t0a_7 = t0a_7; @@ -630,7 +595,7 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.Omega_dot_7 = Omega_dot_7; almanac.M0_7 = M0_7; - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) almanac.IOD_a_8 = IOD_a_8; almanac.af0_8 = af0_8; almanac.af1_8 = af1_8; @@ -644,7 +609,7 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.Omega0_8 = Omega0_8; almanac.Omega_dot_8 = Omega_dot_8; - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) almanac.IOD_a_9 = IOD_a_9; almanac.WN_a_9 = WN_a_9; almanac.t0a_9 = t0a_9; @@ -659,7 +624,7 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.omega_9 = omega_9; almanac.delta_i_9 = delta_i_9; - /*Word type 10: Almanac for SVID3 (2/2)*/ + // Word type 10: Almanac for SVID3 (2/2) almanac.IOD_a_10 = IOD_a_10; almanac.Omega0_10 = Omega0_10; almanac.Omega_dot_10 = Omega_dot_10; @@ -669,360 +634,352 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.E5b_HS_10 = E5b_HS_10; almanac.E1B_HS_10 = E1B_HS_10; - /*GPS to Galileo GST conversion parameters*/ - almanac.A_0G_10 = A_0G_10; - almanac.A_1G_10 = A_1G_10; - almanac.t_0G_10 = t_0G_10; - almanac.WN_0G_10 = WN_0G_10; - return almanac; } -int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) +int32_t Galileo_Navigation_Message::page_jk_decoder(const char* data_jk) { - int page_number = 0; + int32_t page_number = 0; std::string data_jk_string = data_jk; std::bitset data_jk_bits(data_jk_string); - //DLOG(INFO) << "Data_jk_bits (bitset) "<< endl << data_jk_bits << endl; - page_number = static_cast(read_navigation_unsigned(data_jk_bits, PAGE_TYPE_bit)); + page_number = static_cast(read_navigation_unsigned(data_jk_bits, PAGE_TYPE_BIT)); LOG(INFO) << "Page number = " << page_number; switch (page_number) { - case 1: /*Word type 1: Ephemeris (1/4)*/ - IOD_nav_1 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_1_bit)); + case 1: // Word type 1: Ephemeris (1/4) + IOD_nav_1 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_NAV_1_BIT)); DLOG(INFO) << "IOD_nav_1= " << IOD_nav_1; - t0e_1 = static_cast(read_navigation_unsigned(data_jk_bits, T0E_1_bit)); - t0e_1 = t0e_1 * t0e_1_LSB; + t0e_1 = static_cast(read_navigation_unsigned(data_jk_bits, T0_E_1_BIT)); + t0e_1 = t0e_1 * T0E_1_LSB; DLOG(INFO) << "t0e_1= " << t0e_1; - M0_1 = static_cast(read_navigation_signed(data_jk_bits, M0_1_bit)); + M0_1 = static_cast(read_navigation_signed(data_jk_bits, M0_1_BIT)); M0_1 = M0_1 * M0_1_LSB; DLOG(INFO) << "M0_1= " << M0_1; - e_1 = static_cast(read_navigation_unsigned(data_jk_bits, e_1_bit)); - e_1 = e_1 * e_1_LSB; + e_1 = static_cast(read_navigation_unsigned(data_jk_bits, E_1_BIT)); + e_1 = e_1 * E_1_LSB; DLOG(INFO) << "e_1= " << e_1; - A_1 = static_cast(read_navigation_unsigned(data_jk_bits, A_1_bit)); - A_1 = A_1 * A_1_LSB_gal; + A_1 = static_cast(read_navigation_unsigned(data_jk_bits, A_1_BIT)); + A_1 = A_1 * A_1_LSB_GAL; DLOG(INFO) << "A_1= " << A_1; flag_ephemeris_1 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 2: /*Word type 2: Ephemeris (2/4)*/ - IOD_nav_2 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_2_bit)); + case 2: // Word type 2: Ephemeris (2/4) + IOD_nav_2 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_NAV_2_BIT)); DLOG(INFO) << "IOD_nav_2= " << IOD_nav_2; - OMEGA_0_2 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_0_2_bit)); + OMEGA_0_2 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_0_2_BIT)); OMEGA_0_2 = OMEGA_0_2 * OMEGA_0_2_LSB; DLOG(INFO) << "OMEGA_0_2= " << OMEGA_0_2; - i_0_2 = static_cast(read_navigation_signed(data_jk_bits, i_0_2_bit)); - i_0_2 = i_0_2 * i_0_2_LSB; + i_0_2 = static_cast(read_navigation_signed(data_jk_bits, I_0_2_BIT)); + i_0_2 = i_0_2 * I_0_2_LSB; DLOG(INFO) << "i_0_2= " << i_0_2; - omega_2 = static_cast(read_navigation_signed(data_jk_bits, omega_2_bit)); - omega_2 = omega_2 * omega_2_LSB; + omega_2 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_2_BIT)); + omega_2 = omega_2 * OMEGA_2_LSB; DLOG(INFO) << "omega_2= " << omega_2; - iDot_2 = static_cast(read_navigation_signed(data_jk_bits, iDot_2_bit)); - iDot_2 = iDot_2 * iDot_2_LSB; + iDot_2 = static_cast(read_navigation_signed(data_jk_bits, I_DOT_2_BIT)); + iDot_2 = iDot_2 * I_DOT_2_LSB; DLOG(INFO) << "iDot_2= " << iDot_2; flag_ephemeris_2 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 3: /*Word type 3: Ephemeris (3/4) and SISA*/ - IOD_nav_3 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_3_bit)); + case 3: // Word type 3: Ephemeris (3/4) and SISA + IOD_nav_3 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_NAV_3_BIT)); DLOG(INFO) << "IOD_nav_3= " << IOD_nav_3; - OMEGA_dot_3 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_dot_3_bit)); - OMEGA_dot_3 = OMEGA_dot_3 * OMEGA_dot_3_LSB; + OMEGA_dot_3 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_DOT_3_BIT)); + OMEGA_dot_3 = OMEGA_dot_3 * OMEGA_DOT_3_LSB; DLOG(INFO) << "OMEGA_dot_3= " << OMEGA_dot_3; - delta_n_3 = static_cast(read_navigation_signed(data_jk_bits, delta_n_3_bit)); - delta_n_3 = delta_n_3 * delta_n_3_LSB; + delta_n_3 = static_cast(read_navigation_signed(data_jk_bits, DELTA_N_3_BIT)); + delta_n_3 = delta_n_3 * DELTA_N_3_LSB; DLOG(INFO) << "delta_n_3= " << delta_n_3; - C_uc_3 = static_cast(read_navigation_signed(data_jk_bits, C_uc_3_bit)); - C_uc_3 = C_uc_3 * C_uc_3_LSB; + C_uc_3 = static_cast(read_navigation_signed(data_jk_bits, C_UC_3_BIT)); + C_uc_3 = C_uc_3 * C_UC_3_LSB; DLOG(INFO) << "C_uc_3= " << C_uc_3; - C_us_3 = static_cast(read_navigation_signed(data_jk_bits, C_us_3_bit)); - C_us_3 = C_us_3 * C_us_3_LSB; + C_us_3 = static_cast(read_navigation_signed(data_jk_bits, C_US_3_BIT)); + C_us_3 = C_us_3 * C_US_3_LSB; DLOG(INFO) << "C_us_3= " << C_us_3; - C_rc_3 = static_cast(read_navigation_signed(data_jk_bits, C_rc_3_bit)); - C_rc_3 = C_rc_3 * C_rc_3_LSB; + C_rc_3 = static_cast(read_navigation_signed(data_jk_bits, C_RC_3_BIT)); + C_rc_3 = C_rc_3 * C_RC_3_LSB; DLOG(INFO) << "C_rc_3= " << C_rc_3; - C_rs_3 = static_cast(read_navigation_signed(data_jk_bits, C_rs_3_bit)); - C_rs_3 = C_rs_3 * C_rs_3_LSB; + C_rs_3 = static_cast(read_navigation_signed(data_jk_bits, C_RS_3_BIT)); + C_rs_3 = C_rs_3 * C_RS_3_LSB; DLOG(INFO) << "C_rs_3= " << C_rs_3; - SISA_3 = static_cast(read_navigation_unsigned(data_jk_bits, SISA_3_bit)); + SISA_3 = static_cast(read_navigation_unsigned(data_jk_bits, SISA_3_BIT)); DLOG(INFO) << "SISA_3= " << SISA_3; flag_ephemeris_3 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 4: /* Word type 4: Ephemeris (4/4) and Clock correction parameters*/ - IOD_nav_4 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_4_bit)); + case 4: // Word type 4: Ephemeris (4/4) and Clock correction parameters + IOD_nav_4 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_NAV_4_BIT)); DLOG(INFO) << "IOD_nav_4= " << IOD_nav_4; - SV_ID_PRN_4 = static_cast(read_navigation_unsigned(data_jk_bits, SV_ID_PRN_4_bit)); + SV_ID_PRN_4 = static_cast(read_navigation_unsigned(data_jk_bits, SV_ID_PRN_4_BIT)); DLOG(INFO) << "SV_ID_PRN_4= " << SV_ID_PRN_4; - C_ic_4 = static_cast(read_navigation_signed(data_jk_bits, C_ic_4_bit)); - C_ic_4 = C_ic_4 * C_ic_4_LSB; + C_ic_4 = static_cast(read_navigation_signed(data_jk_bits, C_IC_4_BIT)); + C_ic_4 = C_ic_4 * C_IC_4_LSB; DLOG(INFO) << "C_ic_4= " << C_ic_4; - C_is_4 = static_cast(read_navigation_signed(data_jk_bits, C_is_4_bit)); - C_is_4 = C_is_4 * C_is_4_LSB; + C_is_4 = static_cast(read_navigation_signed(data_jk_bits, C_IS_4_BIT)); + C_is_4 = C_is_4 * C_IS_4_LSB; DLOG(INFO) << "C_is_4= " << C_is_4; - /*Clock correction parameters*/ - t0c_4 = static_cast(read_navigation_unsigned(data_jk_bits, t0c_4_bit)); - t0c_4 = t0c_4 * t0c_4_LSB; + // Clock correction parameters + t0c_4 = static_cast(read_navigation_unsigned(data_jk_bits, T0C_4_BIT)); + t0c_4 = t0c_4 * T0C_4_LSB; DLOG(INFO) << "t0c_4= " << t0c_4; - af0_4 = static_cast(read_navigation_signed(data_jk_bits, af0_4_bit)); - af0_4 = af0_4 * af0_4_LSB; + af0_4 = static_cast(read_navigation_signed(data_jk_bits, AF0_4_BIT)); + af0_4 = af0_4 * AF0_4_LSB; DLOG(INFO) << "af0_4 = " << af0_4; - af1_4 = static_cast(read_navigation_signed(data_jk_bits, af1_4_bit)); - af1_4 = af1_4 * af1_4_LSB; + af1_4 = static_cast(read_navigation_signed(data_jk_bits, AF1_4_BIT)); + af1_4 = af1_4 * AF1_4_LSB; DLOG(INFO) << "af1_4 = " << af1_4; - af2_4 = static_cast(read_navigation_signed(data_jk_bits, af2_4_bit)); - af2_4 = af2_4 * af2_4_LSB; + af2_4 = static_cast(read_navigation_signed(data_jk_bits, AF2_4_BIT)); + af2_4 = af2_4 * AF2_4_LSB; DLOG(INFO) << "af2_4 = " << af2_4; - spare_4 = static_cast(read_navigation_unsigned(data_jk_bits, spare_4_bit)); + spare_4 = static_cast(read_navigation_unsigned(data_jk_bits, SPARE_4_BIT)); DLOG(INFO) << "spare_4 = " << spare_4; flag_ephemeris_4 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 5: /*Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST*/ - /*Ionospheric correction*/ - /*Az*/ - ai0_5 = static_cast(read_navigation_unsigned(data_jk_bits, ai0_5_bit)); - ai0_5 = ai0_5 * ai0_5_LSB; + case 5: // Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST + // Ionospheric correction + ai0_5 = static_cast(read_navigation_unsigned(data_jk_bits, AI0_5_BIT)); + ai0_5 = ai0_5 * AI0_5_LSB; DLOG(INFO) << "ai0_5= " << ai0_5; - ai1_5 = static_cast(read_navigation_signed(data_jk_bits, ai1_5_bit)); - ai1_5 = ai1_5 * ai1_5_LSB; + ai1_5 = static_cast(read_navigation_signed(data_jk_bits, AI1_5_BIT)); + ai1_5 = ai1_5 * AI1_5_LSB; DLOG(INFO) << "ai1_5= " << ai1_5; - ai2_5 = static_cast(read_navigation_signed(data_jk_bits, ai2_5_bit)); - ai2_5 = ai2_5 * ai2_5_LSB; + ai2_5 = static_cast(read_navigation_signed(data_jk_bits, AI2_5_BIT)); + ai2_5 = ai2_5 * AI2_5_LSB; DLOG(INFO) << "ai2_5= " << ai2_5; - /*Ionospheric disturbance flag*/ - Region1_flag_5 = static_cast(read_navigation_bool(data_jk_bits, Region1_5_bit)); + // Ionospheric disturbance flag + Region1_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION1_5_BIT)); DLOG(INFO) << "Region1_flag_5= " << Region1_flag_5; - Region2_flag_5 = static_cast(read_navigation_bool(data_jk_bits, Region2_5_bit)); + Region2_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION2_5_BIT)); DLOG(INFO) << "Region2_flag_5= " << Region2_flag_5; - Region3_flag_5 = static_cast(read_navigation_bool(data_jk_bits, Region3_5_bit)); + Region3_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION3_5_BIT)); DLOG(INFO) << "Region3_flag_5= " << Region3_flag_5; - Region4_flag_5 = static_cast(read_navigation_bool(data_jk_bits, Region4_5_bit)); + Region4_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION4_5_BIT)); DLOG(INFO) << "Region4_flag_5= " << Region4_flag_5; - Region5_flag_5 = static_cast(read_navigation_bool(data_jk_bits, Region5_5_bit)); + Region5_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION5_5_BIT)); DLOG(INFO) << "Region5_flag_5= " << Region5_flag_5; - BGD_E1E5a_5 = static_cast(read_navigation_signed(data_jk_bits, BGD_E1E5a_5_bit)); - BGD_E1E5a_5 = BGD_E1E5a_5 * BGD_E1E5a_5_LSB; + BGD_E1E5a_5 = static_cast(read_navigation_signed(data_jk_bits, BGD_E1_E5A_5_BIT)); + BGD_E1E5a_5 = BGD_E1E5a_5 * BGD_E1_E5A_5_LSB; DLOG(INFO) << "BGD_E1E5a_5= " << BGD_E1E5a_5; - BGD_E1E5b_5 = static_cast(read_navigation_signed(data_jk_bits, BGD_E1E5b_5_bit)); - BGD_E1E5b_5 = BGD_E1E5b_5 * BGD_E1E5b_5_LSB; + BGD_E1E5b_5 = static_cast(read_navigation_signed(data_jk_bits, BGD_E1_E5B_5_BIT)); + BGD_E1E5b_5 = BGD_E1E5b_5 * BGD_E1_E5B_5_LSB; DLOG(INFO) << "BGD_E1E5b_5= " << BGD_E1E5b_5; - E5b_HS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E5b_HS_5_bit)); + E5b_HS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E5B_HS_5_BIT)); DLOG(INFO) << "E5b_HS_5= " << E5b_HS_5; - E1B_HS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E1B_HS_5_bit)); + E1B_HS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E1_B_HS_5_BIT)); DLOG(INFO) << "E1B_HS_5= " << E1B_HS_5; - E5b_DVS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E5b_DVS_5_bit)); + E5b_DVS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E5B_DVS_5_BIT)); DLOG(INFO) << "E5b_DVS_5= " << E5b_DVS_5; - E1B_DVS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E1B_DVS_5_bit)); + E1B_DVS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E1_B_DVS_5_BIT)); DLOG(INFO) << "E1B_DVS_5= " << E1B_DVS_5; - /*GST*/ - WN_5 = static_cast(read_navigation_unsigned(data_jk_bits, WN_5_bit)); + // GST + WN_5 = static_cast(read_navigation_unsigned(data_jk_bits, WN_5_BIT)); DLOG(INFO) << "WN_5= " << WN_5; - TOW_5 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_5_bit)); + TOW_5 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_5_BIT)); DLOG(INFO) << "TOW_5= " << TOW_5; - flag_TOW_5 = true; //set to false externally - spare_5 = static_cast(read_navigation_unsigned(data_jk_bits, spare_5_bit)); + flag_TOW_5 = true; // set to false externally + spare_5 = static_cast(read_navigation_unsigned(data_jk_bits, SPARE_5_BIT)); DLOG(INFO) << "spare_5= " << spare_5; - flag_iono_and_GST = true; //set to false externally - flag_TOW_set = true; //set to false externally + flag_iono_and_GST = true; // set to false externally + flag_TOW_set = true; // set to false externally DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 6: /*Word type 6: GST-UTC conversion parameters*/ - A0_6 = static_cast(read_navigation_signed(data_jk_bits, A0_6_bit)); + case 6: // Word type 6: GST-UTC conversion parameters + A0_6 = static_cast(read_navigation_signed(data_jk_bits, A0_6_BIT)); A0_6 = A0_6 * A0_6_LSB; DLOG(INFO) << "A0_6= " << A0_6; - A1_6 = static_cast(read_navigation_signed(data_jk_bits, A1_6_bit)); + A1_6 = static_cast(read_navigation_signed(data_jk_bits, A1_6_BIT)); A1_6 = A1_6 * A1_6_LSB; DLOG(INFO) << "A1_6= " << A1_6; - Delta_tLS_6 = static_cast(read_navigation_signed(data_jk_bits, Delta_tLS_6_bit)); + Delta_tLS_6 = static_cast(read_navigation_signed(data_jk_bits, DELTA_T_LS_6_BIT)); DLOG(INFO) << "Delta_tLS_6= " << Delta_tLS_6; - t0t_6 = static_cast(read_navigation_unsigned(data_jk_bits, t0t_6_bit)); - t0t_6 = t0t_6 * t0t_6_LSB; + t0t_6 = static_cast(read_navigation_unsigned(data_jk_bits, T0T_6_BIT)); + t0t_6 = t0t_6 * T0T_6_LSB; DLOG(INFO) << "t0t_6= " << t0t_6; - WNot_6 = static_cast(read_navigation_unsigned(data_jk_bits, WNot_6_bit)); + WNot_6 = static_cast(read_navigation_unsigned(data_jk_bits, W_NOT_6_BIT)); DLOG(INFO) << "WNot_6= " << WNot_6; - WN_LSF_6 = static_cast(read_navigation_unsigned(data_jk_bits, WN_LSF_6_bit)); + WN_LSF_6 = static_cast(read_navigation_unsigned(data_jk_bits, WN_LSF_6_BIT)); DLOG(INFO) << "WN_LSF_6= " << WN_LSF_6; - DN_6 = static_cast(read_navigation_unsigned(data_jk_bits, DN_6_bit)); + DN_6 = static_cast(read_navigation_unsigned(data_jk_bits, DN_6_BIT)); DLOG(INFO) << "DN_6= " << DN_6; - Delta_tLSF_6 = static_cast(read_navigation_signed(data_jk_bits, Delta_tLSF_6_bit)); + Delta_tLSF_6 = static_cast(read_navigation_signed(data_jk_bits, DELTA_T_LSF_6_BIT)); DLOG(INFO) << "Delta_tLSF_6= " << Delta_tLSF_6; - TOW_6 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_6_bit)); + TOW_6 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_6_BIT)); DLOG(INFO) << "TOW_6= " << TOW_6; - flag_TOW_6 = true; //set to false externally - flag_utc_model = true; //set to false externally - flag_TOW_set = true; //set to false externally + flag_TOW_6 = true; // set to false externally + flag_utc_model = true; // set to false externally + flag_TOW_set = true; // set to false externally DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 7: /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ - IOD_a_7 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_7_bit)); + case 7: // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number + IOD_a_7 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_A_7_BIT)); DLOG(INFO) << "IOD_a_7= " << IOD_a_7; - WN_a_7 = static_cast(read_navigation_unsigned(data_jk_bits, WN_a_7_bit)); + WN_a_7 = static_cast(read_navigation_unsigned(data_jk_bits, WN_A_7_BIT)); DLOG(INFO) << "WN_a_7= " << WN_a_7; - t0a_7 = static_cast(read_navigation_unsigned(data_jk_bits, t0a_7_bit)); - t0a_7 = t0a_7 * t0a_7_LSB; + t0a_7 = static_cast(read_navigation_unsigned(data_jk_bits, T0A_7_BIT)); + t0a_7 = t0a_7 * T0A_7_LSB; DLOG(INFO) << "t0a_7= " << t0a_7; - SVID1_7 = static_cast(read_navigation_unsigned(data_jk_bits, SVID1_7_bit)); + SVID1_7 = static_cast(read_navigation_unsigned(data_jk_bits, SVI_D1_7_BIT)); DLOG(INFO) << "SVID1_7= " << SVID1_7; - DELTA_A_7 = static_cast(read_navigation_signed(data_jk_bits, DELTA_A_7_bit)); + DELTA_A_7 = static_cast(read_navigation_signed(data_jk_bits, DELTA_A_7_BIT)); DELTA_A_7 = DELTA_A_7 * DELTA_A_7_LSB; DLOG(INFO) << "DELTA_A_7= " << DELTA_A_7; - e_7 = static_cast(read_navigation_unsigned(data_jk_bits, e_7_bit)); - e_7 = e_7 * e_7_LSB; + e_7 = static_cast(read_navigation_unsigned(data_jk_bits, E_7_BIT)); + e_7 = e_7 * E_7_LSB; DLOG(INFO) << "e_7= " << e_7; - omega_7 = static_cast(read_navigation_signed(data_jk_bits, omega_7_bit)); - omega_7 = omega_7 * omega_7_LSB; + omega_7 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_7_BIT)); + omega_7 = omega_7 * OMEGA_7_LSB; DLOG(INFO) << "omega_7= " << omega_7; - delta_i_7 = static_cast(read_navigation_signed(data_jk_bits, delta_i_7_bit)); - delta_i_7 = delta_i_7 * delta_i_7_LSB; + delta_i_7 = static_cast(read_navigation_signed(data_jk_bits, DELTA_I_7_BIT)); + delta_i_7 = delta_i_7 * DELTA_I_7_LSB; DLOG(INFO) << "delta_i_7= " << delta_i_7; - Omega0_7 = static_cast(read_navigation_signed(data_jk_bits, Omega0_7_bit)); - Omega0_7 = Omega0_7 * Omega0_7_LSB; + Omega0_7 = static_cast(read_navigation_signed(data_jk_bits, OMEGA0_7_BIT)); + Omega0_7 = Omega0_7 * OMEGA0_7_LSB; DLOG(INFO) << "Omega0_7= " << Omega0_7; - Omega_dot_7 = static_cast(read_navigation_signed(data_jk_bits, Omega_dot_7_bit)); - Omega_dot_7 = Omega_dot_7 * Omega_dot_7_LSB; + Omega_dot_7 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_DOT_7_BIT)); + Omega_dot_7 = Omega_dot_7 * OMEGA_DOT_7_LSB; DLOG(INFO) << "Omega_dot_7= " << Omega_dot_7; - M0_7 = static_cast(read_navigation_signed(data_jk_bits, M0_7_bit)); + M0_7 = static_cast(read_navigation_signed(data_jk_bits, M0_7_BIT)); M0_7 = M0_7 * M0_7_LSB; DLOG(INFO) << "M0_7= " << M0_7; flag_almanac_1 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 8: /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ - IOD_a_8 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_8_bit)); + case 8: // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ + IOD_a_8 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_A_8_BIT)); DLOG(INFO) << "IOD_a_8= " << IOD_a_8; - af0_8 = static_cast(read_navigation_signed(data_jk_bits, af0_8_bit)); - af0_8 = af0_8 * af0_8_LSB; + af0_8 = static_cast(read_navigation_signed(data_jk_bits, AF0_8_BIT)); + af0_8 = af0_8 * AF0_8_LSB; DLOG(INFO) << "af0_8= " << af0_8; - af1_8 = static_cast(read_navigation_signed(data_jk_bits, af1_8_bit)); - af1_8 = af1_8 * af1_8_LSB; + af1_8 = static_cast(read_navigation_signed(data_jk_bits, AF1_8_BIT)); + af1_8 = af1_8 * AF1_8_LSB; DLOG(INFO) << "af1_8= " << af1_8; - E5b_HS_8 = static_cast(read_navigation_unsigned(data_jk_bits, E5b_HS_8_bit)); + E5b_HS_8 = static_cast(read_navigation_unsigned(data_jk_bits, E5B_HS_8_BIT)); DLOG(INFO) << "E5b_HS_8= " << E5b_HS_8; - E1B_HS_8 = static_cast(read_navigation_unsigned(data_jk_bits, E1B_HS_8_bit)); + E1B_HS_8 = static_cast(read_navigation_unsigned(data_jk_bits, E1_B_HS_8_BIT)); DLOG(INFO) << "E1B_HS_8= " << E1B_HS_8; - SVID2_8 = static_cast(read_navigation_unsigned(data_jk_bits, SVID2_8_bit)); + SVID2_8 = static_cast(read_navigation_unsigned(data_jk_bits, SVI_D2_8_BIT)); DLOG(INFO) << "SVID2_8= " << SVID2_8; - DELTA_A_8 = static_cast(read_navigation_signed(data_jk_bits, DELTA_A_8_bit)); + DELTA_A_8 = static_cast(read_navigation_signed(data_jk_bits, DELTA_A_8_BIT)); DELTA_A_8 = DELTA_A_8 * DELTA_A_8_LSB; DLOG(INFO) << "DELTA_A_8= " << DELTA_A_8; - e_8 = static_cast(read_navigation_unsigned(data_jk_bits, e_8_bit)); - e_8 = e_8 * e_8_LSB; + e_8 = static_cast(read_navigation_unsigned(data_jk_bits, E_8_BIT)); + e_8 = e_8 * E_8_LSB; DLOG(INFO) << "e_8= " << e_8; - omega_8 = static_cast(read_navigation_signed(data_jk_bits, omega_8_bit)); - omega_8 = omega_8 * omega_8_LSB; + omega_8 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_8_BIT)); + omega_8 = omega_8 * OMEGA_8_LSB; DLOG(INFO) << "omega_8= " << omega_8; - delta_i_8 = static_cast(read_navigation_signed(data_jk_bits, delta_i_8_bit)); - delta_i_8 = delta_i_8 * delta_i_8_LSB; + delta_i_8 = static_cast(read_navigation_signed(data_jk_bits, DELTA_I_8_BIT)); + delta_i_8 = delta_i_8 * DELTA_I_8_LSB; DLOG(INFO) << "delta_i_8= " << delta_i_8; - Omega0_8 = static_cast(read_navigation_signed(data_jk_bits, Omega0_8_bit)); - Omega0_8 = Omega0_8 * Omega0_8_LSB; + Omega0_8 = static_cast(read_navigation_signed(data_jk_bits, OMEGA0_8_BIT)); + Omega0_8 = Omega0_8 * OMEGA0_8_LSB; DLOG(INFO) << "Omega0_8= " << Omega0_8; - Omega_dot_8 = static_cast(read_navigation_signed(data_jk_bits, Omega_dot_8_bit)); - Omega_dot_8 = Omega_dot_8 * Omega_dot_8_LSB; + Omega_dot_8 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_DOT_8_BIT)); + Omega_dot_8 = Omega_dot_8 * OMEGA_DOT_8_LSB; DLOG(INFO) << "Omega_dot_8= " << Omega_dot_8; flag_almanac_2 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 9: /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ - IOD_a_9 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_9_bit)); + case 9: // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) + IOD_a_9 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_A_9_BIT)); DLOG(INFO) << "IOD_a_9= " << IOD_a_9; - WN_a_9 = static_cast(read_navigation_unsigned(data_jk_bits, WN_a_9_bit)); + WN_a_9 = static_cast(read_navigation_unsigned(data_jk_bits, WN_A_9_BIT)); DLOG(INFO) << "WN_a_9= " << WN_a_9; - t0a_9 = static_cast(read_navigation_unsigned(data_jk_bits, t0a_9_bit)); - t0a_9 = t0a_9 * t0a_9_LSB; + t0a_9 = static_cast(read_navigation_unsigned(data_jk_bits, T0A_9_BIT)); + t0a_9 = t0a_9 * T0A_9_LSB; DLOG(INFO) << "t0a_9= " << t0a_9; - M0_9 = static_cast(read_navigation_signed(data_jk_bits, M0_9_bit)); + M0_9 = static_cast(read_navigation_signed(data_jk_bits, M0_9_BIT)); M0_9 = M0_9 * M0_9_LSB; DLOG(INFO) << "M0_9= " << M0_9; - af0_9 = static_cast(read_navigation_signed(data_jk_bits, af0_9_bit)); - af0_9 = af0_9 * af0_9_LSB; + af0_9 = static_cast(read_navigation_signed(data_jk_bits, AF0_9_BIT)); + af0_9 = af0_9 * AF0_9_LSB; DLOG(INFO) << "af0_9= " << af0_9; - af1_9 = static_cast(read_navigation_signed(data_jk_bits, af1_9_bit)); - af1_9 = af1_9 * af1_9_LSB; + af1_9 = static_cast(read_navigation_signed(data_jk_bits, AF1_9_BIT)); + af1_9 = af1_9 * AF1_9_LSB; DLOG(INFO) << "af1_9= " << af1_9; - E5b_HS_9 = static_cast(read_navigation_unsigned(data_jk_bits, E5b_HS_9_bit)); + E5b_HS_9 = static_cast(read_navigation_unsigned(data_jk_bits, E5B_HS_9_BIT)); DLOG(INFO) << "E5b_HS_9= " << E5b_HS_9; - E1B_HS_9 = static_cast(read_navigation_unsigned(data_jk_bits, E1B_HS_9_bit)); + E1B_HS_9 = static_cast(read_navigation_unsigned(data_jk_bits, E1_B_HS_9_BIT)); DLOG(INFO) << "E1B_HS_9= " << E1B_HS_9; - SVID3_9 = static_cast(read_navigation_unsigned(data_jk_bits, SVID3_9_bit)); + SVID3_9 = static_cast(read_navigation_unsigned(data_jk_bits, SVI_D3_9_BIT)); DLOG(INFO) << "SVID3_9= " << SVID3_9; - DELTA_A_9 = static_cast(read_navigation_signed(data_jk_bits, DELTA_A_9_bit)); + DELTA_A_9 = static_cast(read_navigation_signed(data_jk_bits, DELTA_A_9_BIT)); DELTA_A_9 = DELTA_A_9 * DELTA_A_9_LSB; DLOG(INFO) << "DELTA_A_9= " << DELTA_A_9; - e_9 = static_cast(read_navigation_unsigned(data_jk_bits, e_9_bit)); - e_9 = e_9 * e_9_LSB; + e_9 = static_cast(read_navigation_unsigned(data_jk_bits, E_9_BIT)); + e_9 = e_9 * E_9_LSB; DLOG(INFO) << "e_9= " << e_9; - omega_9 = static_cast(read_navigation_signed(data_jk_bits, omega_9_bit)); - omega_9 = omega_9 * omega_9_LSB; + omega_9 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_9_BIT)); + omega_9 = omega_9 * OMEGA_9_LSB; DLOG(INFO) << "omega_9= " << omega_9; - delta_i_9 = static_cast(read_navigation_signed(data_jk_bits, delta_i_9_bit)); - delta_i_9 = delta_i_9 * delta_i_9_LSB; + delta_i_9 = static_cast(read_navigation_signed(data_jk_bits, DELTA_I_9_BIT)); + delta_i_9 = delta_i_9 * DELTA_I_9_LSB; DLOG(INFO) << "delta_i_9= " << delta_i_9; flag_almanac_3 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 10: /*Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters*/ - IOD_a_10 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_10_bit)); + case 10: // Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters + IOD_a_10 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_A_10_BIT)); DLOG(INFO) << "IOD_a_10= " << IOD_a_10; - Omega0_10 = static_cast(read_navigation_signed(data_jk_bits, Omega0_10_bit)); - Omega0_10 = Omega0_10 * Omega0_10_LSB; + Omega0_10 = static_cast(read_navigation_signed(data_jk_bits, OMEGA0_10_BIT)); + Omega0_10 = Omega0_10 * OMEGA0_10_LSB; DLOG(INFO) << "Omega0_10= " << Omega0_10; - Omega_dot_10 = static_cast(read_navigation_signed(data_jk_bits, Omega_dot_10_bit)); - Omega_dot_10 = Omega_dot_10 * Omega_dot_10_LSB; + Omega_dot_10 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_DOT_10_BIT)); + Omega_dot_10 = Omega_dot_10 * OMEGA_DOT_10_LSB; DLOG(INFO) << "Omega_dot_10= " << Omega_dot_10; - M0_10 = static_cast(read_navigation_signed(data_jk_bits, M0_10_bit)); + M0_10 = static_cast(read_navigation_signed(data_jk_bits, M0_10_BIT)); M0_10 = M0_10 * M0_10_LSB; DLOG(INFO) << "M0_10= " << M0_10; - af0_10 = static_cast(read_navigation_signed(data_jk_bits, af0_10_bit)); - af0_10 = af0_10 * af0_10_LSB; + af0_10 = static_cast(read_navigation_signed(data_jk_bits, AF0_10_BIT)); + af0_10 = af0_10 * AF0_10_LSB; DLOG(INFO) << "af0_10= " << af0_10; - af1_10 = static_cast(read_navigation_signed(data_jk_bits, af1_10_bit)); - af1_10 = af1_10 * af1_10_LSB; + af1_10 = static_cast(read_navigation_signed(data_jk_bits, AF1_10_BIT)); + af1_10 = af1_10 * AF1_10_LSB; DLOG(INFO) << "af1_10= " << af1_10; - E5b_HS_10 = static_cast(read_navigation_unsigned(data_jk_bits, E5b_HS_10_bit)); + E5b_HS_10 = static_cast(read_navigation_unsigned(data_jk_bits, E5B_HS_10_BIT)); DLOG(INFO) << "E5b_HS_10= " << E5b_HS_10; - E1B_HS_10 = static_cast(read_navigation_unsigned(data_jk_bits, E1B_HS_10_bit)); + E1B_HS_10 = static_cast(read_navigation_unsigned(data_jk_bits, E1_B_HS_10_BIT)); DLOG(INFO) << "E1B_HS_10= " << E1B_HS_10; - A_0G_10 = static_cast(read_navigation_signed(data_jk_bits, A_0G_10_bit)); + A_0G_10 = static_cast(read_navigation_signed(data_jk_bits, A_0_G_10_BIT)); A_0G_10 = A_0G_10 * A_0G_10_LSB; flag_GGTO_1 = true; DLOG(INFO) << "A_0G_10= " << A_0G_10; - A_1G_10 = static_cast(read_navigation_signed(data_jk_bits, A_1G_10_bit)); + A_1G_10 = static_cast(read_navigation_signed(data_jk_bits, A_1_G_10_BIT)); A_1G_10 = A_1G_10 * A_1G_10_LSB; flag_GGTO_2 = true; DLOG(INFO) << "A_1G_10= " << A_1G_10; - t_0G_10 = static_cast(read_navigation_unsigned(data_jk_bits, t_0G_10_bit)); - t_0G_10 = t_0G_10 * t_0G_10_LSB; + t_0G_10 = static_cast(read_navigation_unsigned(data_jk_bits, T_0_G_10_BIT)); + t_0G_10 = t_0G_10 * T_0_G_10_LSB; flag_GGTO_3 = true; DLOG(INFO) << "t_0G_10= " << t_0G_10; - WN_0G_10 = static_cast(read_navigation_unsigned(data_jk_bits, WN_0G_10_bit)); + WN_0G_10 = static_cast(read_navigation_unsigned(data_jk_bits, WN_0_G_10_BIT)); flag_GGTO_4 = true; DLOG(INFO) << "WN_0G_10= " << WN_0G_10; flag_almanac_4 = true; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 0: /*Word type 0: I/NAV Spare Word*/ - Time_0 = static_cast(read_navigation_unsigned(data_jk_bits, Time_0_bit)); + case 0: // Word type 0: I/NAV Spare Word + Time_0 = static_cast(read_navigation_unsigned(data_jk_bits, TIME_0_BIT)); DLOG(INFO) << "Time_0= " << Time_0; - WN_0 = static_cast(read_navigation_unsigned(data_jk_bits, WN_0_bit)); + WN_0 = static_cast(read_navigation_unsigned(data_jk_bits, WN_0_BIT)); DLOG(INFO) << "WN_0= " << WN_0; - TOW_0 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_0_bit)); + TOW_0 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_0_BIT)); DLOG(INFO) << "TOW_0= " << TOW_0; DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; diff --git a/src/core/system_parameters/galileo_navigation_message.h b/src/core/system_parameters/galileo_navigation_message.h index 2108a1568..cf1eb0a0f 100644 --- a/src/core/system_parameters/galileo_navigation_message.h +++ b/src/core/system_parameters/galileo_navigation_message.h @@ -33,13 +33,13 @@ #ifndef GNSS_SDR_GALILEO_NAVIGATION_MESSAGE_H_ #define GNSS_SDR_GALILEO_NAVIGATION_MESSAGE_H_ +#include "Galileo_E1.h" +#include "galileo_almanac_helper.h" #include "galileo_ephemeris.h" #include "galileo_iono.h" -#include "galileo_almanac.h" #include "galileo_utc_model.h" -#include "Galileo_E1.h" -#include // for boost::uint32_t #include +#include #include #include #include @@ -54,16 +54,15 @@ class Galileo_Navigation_Message { private: - bool CRC_test(std::bitset bits, boost::uint32_t checksum); - bool read_navigation_bool(std::bitset bits, const std::vector > parameter); - //void print_galileo_word_bytes(unsigned int GPS_word); - unsigned long int read_navigation_unsigned(std::bitset bits, const std::vector > parameter); - unsigned long int read_page_type_unsigned(std::bitset bits, const std::vector > parameter); - signed long int read_navigation_signed(std::bitset bits, const std::vector > parameter); + bool CRC_test(std::bitset bits, uint32_t checksum); + bool read_navigation_bool(std::bitset bits, const std::vector >& parameter); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector >& parameter); + uint64_t read_page_type_unsigned(std::bitset bits, const std::vector >& parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector >& parameter); public: - int Page_type_time_stamp; - int flag_even_word; + int32_t Page_type_time_stamp; + int32_t flag_even_word; std::string page_Even; bool flag_CRC_test; bool flag_all_ephemeris; //!< Flag indicating that all words containing ephemeris have been received @@ -84,7 +83,7 @@ public: bool flag_almanac_3; //!< Flag indicating that almanac 3/4 (word 9) have been received bool flag_almanac_4; //!< Flag indicating that almanac 4/4 (word 10) have been received - int IOD_ephemeris; + int32_t IOD_ephemeris; bool flag_GGTO; bool flag_GGTO_1; @@ -92,49 +91,50 @@ public: bool flag_GGTO_3; bool flag_GGTO_4; - /*Word type 1: Ephemeris (1/4)*/ - int IOD_nav_1; //!< IOD_nav page 1 - double t0e_1; //!< Ephemeris reference time [s] - double M0_1; //!< Mean anomaly at reference time [semi-circles] - double e_1; //!< Eccentricity - double A_1; //!< Square root of the semi-major axis [meters^1/2] + // Word type 1: Ephemeris (1/4) + int32_t IOD_nav_1; //!< IOD_nav page 1 + int32_t t0e_1; //!< Ephemeris reference time [s] + double M0_1; //!< Mean anomaly at reference time [semi-circles] + double e_1; //!< Eccentricity + double A_1; //!< Square root of the semi-major axis [meters^1/2] - /*Word type 2: Ephemeris (2/4)*/ - int IOD_nav_2; //!< IOD_nav page 2 - double OMEGA_0_2; //!< Longitude of ascending node of orbital plane at weekly epoch [semi-circles] - double i_0_2; //!< Inclination angle at reference time [semi-circles] - double omega_2; //!< Argument of perigee [semi-circles] - double iDot_2; //!< Rate of inclination angle [semi-circles/sec] + // Word type 2: Ephemeris (2/4) + int32_t IOD_nav_2; //!< IOD_nav page 2 + double OMEGA_0_2; //!< Longitude of ascending node of orbital plane at weekly epoch [semi-circles] + double i_0_2; //!< Inclination angle at reference time [semi-circles] + double omega_2; //!< Argument of perigee [semi-circles] + double iDot_2; //!< Rate of inclination angle [semi-circles/sec] - /*Word type 3: Ephemeris (3/4) and SISA*/ - int IOD_nav_3; // + // Word type 3: Ephemeris (3/4) and SISA + int32_t IOD_nav_3; // double OMEGA_dot_3; //!< Rate of right ascension [semi-circles/sec] double delta_n_3; //!< Mean motion difference from computed value [semi-circles/sec] double C_uc_3; //!< Amplitude of the cosine harmonic correction term to the argument of latitude [radians] double C_us_3; //!< Amplitude of the sine harmonic correction term to the argument of latitude [radians] double C_rc_3; //!< Amplitude of the cosine harmonic correction term to the orbit radius [meters] double C_rs_3; //!< Amplitude of the sine harmonic correction term to the orbit radius [meters] - double SISA_3; + int32_t SISA_3; - /*Word type 4: Ephemeris (4/4) and Clock correction parameters*/ - int IOD_nav_4; // - int SV_ID_PRN_4; // - double C_ic_4; //!= 0) // is not in the past { - //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s + // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s int secondOfLeapSecondEvent = DN_6 * 24 * 60 * 60; if (std::abs(t_e - secondOfLeapSecondEvent) > 21600) { @@ -74,7 +79,7 @@ double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int WN) { /* 5.1.7b GST->UTC case b * Whenever the user's current time falls within the time span of six hours - * prior to the leap second adjustment to six hours after the adjustment time, , + * prior to the leap second adjustment to six hours after the adjustment time, * the effective time is computed according to the following equations: */ Delta_t_Utc = Delta_tLS_6 + A0_6 + A1_6 * (t_e - t0t_6 + 604800 * static_cast((WN % 256) - WNot_6)); diff --git a/src/core/system_parameters/galileo_utc_model.h b/src/core/system_parameters/galileo_utc_model.h index 00822c44c..7e9e328b0 100644 --- a/src/core/system_parameters/galileo_utc_model.h +++ b/src/core/system_parameters/galileo_utc_model.h @@ -33,6 +33,8 @@ #ifndef GNSS_SDR_GALILEO_UTC_MODEL_H_ #define GNSS_SDR_GALILEO_UTC_MODEL_H_ +#include +#include /*! * \brief This class is a storage for the GALILEO UTC MODEL data as described in Galileo ICD @@ -42,22 +44,52 @@ class Galileo_Utc_Model { public: - /*Word type 6: GST-UTC conversion parameters*/ + // Word type 6: GST-UTC conversion parameters double A0_6; double A1_6; - double Delta_tLS_6; - double t0t_6; //!< UTC data reference Time of Week [s] - double WNot_6; //!< UTC data reference Week number [week] - double WN_LSF_6; - double DN_6; - double Delta_tLSF_6; + int32_t Delta_tLS_6; + int32_t t0t_6; //!< UTC data reference Time of Week [s] + int32_t WNot_6; //!< UTC data reference Week number [week] + int32_t WN_LSF_6; + int32_t DN_6; + int32_t Delta_tLSF_6; bool flag_utc_model; + + // GPS to Galileo GST conversion parameters + double A_0G_10; + double A_1G_10; + int32_t t_0G_10; + int32_t WN_0G_10; + //double TOW_6; - double GST_to_UTC_time(double t_e, int WN); //!< GST-UTC Conversion Algorithm and Parameters + double GST_to_UTC_time(double t_e, int32_t WN); //!< GST-UTC Conversion Algorithm and Parameters /*! * Default constructor */ Galileo_Utc_Model(); + + template + + /*! + * \brief Serialize is a boost standard method to be called by the boost XML serialization. + Here is used to save the UTC data on disk file. + */ + inline void serialize(Archive& archive, const unsigned int version) + { + using boost::serialization::make_nvp; + if (version) + { + }; + archive& make_nvp("A0_6", A0_6); + archive& make_nvp("A1_6", A1_6); + archive& make_nvp("Delta_tLS_6", Delta_tLS_6); + archive& make_nvp("t0t_6", t0t_6); + archive& make_nvp("WNot_6", WNot_6); + archive& make_nvp("WN_LSF_6", WN_LSF_6); + archive& make_nvp("DN_6", DN_6); + archive& make_nvp("Delta_tLSF_6", Delta_tLSF_6); + archive& make_nvp("flag_utc_model", flag_utc_model); + } }; #endif diff --git a/src/core/system_parameters/glonass_gnav_almanac.cc b/src/core/system_parameters/glonass_gnav_almanac.cc index 0ed27cb6f..e89d31f64 100644 --- a/src/core/system_parameters/glonass_gnav_almanac.cc +++ b/src/core/system_parameters/glonass_gnav_almanac.cc @@ -35,8 +35,8 @@ Glonass_Gnav_Almanac::Glonass_Gnav_Almanac() { i_satellite_freq_channel = 0; - i_satellite_PRN = 0; - i_satellite_slot_number = 0; + i_satellite_PRN = 0U; + i_satellite_slot_number = 0U; d_n_A = 0.0; d_H_n_A = 0.0; diff --git a/src/core/system_parameters/glonass_gnav_almanac.h b/src/core/system_parameters/glonass_gnav_almanac.h index f36fdfbb0..37927bc6b 100644 --- a/src/core/system_parameters/glonass_gnav_almanac.h +++ b/src/core/system_parameters/glonass_gnav_almanac.h @@ -35,6 +35,7 @@ #define GNSS_SDR_GLONASS_ALMANAC_H_ #include +#include /*! * \brief This class is a storage for the GLONASS SV ALMANAC data as described GLONASS ICD (Edition 5.1) @@ -60,15 +61,15 @@ public: bool d_l_n; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is helthy, ln = 1 indicates malfunction of this nth satellite [dimensionless] // Satellite Identification Information - int i_satellite_freq_channel; //!< SV Frequency Channel Number - unsigned int i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS - unsigned int i_satellite_slot_number; //!< SV Slot Number + int32_t i_satellite_freq_channel; //!< SV Frequency Channel Number + uint32_t i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS + uint32_t i_satellite_slot_number; //!< SV Slot Number template /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the almanac data on disk file. */ - void serialize(Archive& archive, const unsigned int version) + void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/glonass_gnav_ephemeris.cc b/src/core/system_parameters/glonass_gnav_ephemeris.cc index 2a6ea3eb0..1e0941dd7 100644 --- a/src/core/system_parameters/glonass_gnav_ephemeris.cc +++ b/src/core/system_parameters/glonass_gnav_ephemeris.cc @@ -31,8 +31,8 @@ */ #include "glonass_gnav_ephemeris.h" -#include "gnss_satellite.h" #include "GLONASS_L1_L2_CA.h" +#include "gnss_satellite.h" #include @@ -69,8 +69,8 @@ Glonass_Gnav_Ephemeris::Glonass_Gnav_Ephemeris() // Satellite Identification Information i_satellite_freq_channel = 0; //!< SV Frequency Channel Number - i_satellite_PRN = 0; //!< SV PRN Number, equivalent to slot number for compatibility with GPS - i_satellite_slot_number = 0; //!< SV Slot Number + i_satellite_PRN = 0U; //!< SV PRN Number, equivalent to slot number for compatibility with GPS + i_satellite_slot_number = 0U; //!< SV Slot Number d_yr = 1972; //!< Current year, defaults to 1972 (UTC Epoch with leap seconds) d_satClkDrift = 0.0; //!< GLONASS clock error d_dtr = 0.0; //!< relativistic clock correction term diff --git a/src/core/system_parameters/glonass_gnav_ephemeris.h b/src/core/system_parameters/glonass_gnav_ephemeris.h index ef375ab2e..6f53a992f 100644 --- a/src/core/system_parameters/glonass_gnav_ephemeris.h +++ b/src/core/system_parameters/glonass_gnav_ephemeris.h @@ -35,9 +35,9 @@ #define GNSS_SDR_GLONASS_GNAV_EPHEMERIS_H_ -#include #include - +#include +#include /*! * \brief This class is a storage and orbital model functions for the GLONASS SV ephemeris data as described in GLONASS ICD (Edition 5.1) @@ -86,26 +86,26 @@ public: bool d_l3rd_n; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is healthy, ln = 1 indicates malfunction of this nth satellite [dimensionless] bool d_l5th_n; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is healthy, ln = 1 indicates malfunction of this nth satellite [dimensionless] - // Inmediate deliverables of ephemeris information + // Immediate deliverables of ephemeris information // Satellite Identification Information - int i_satellite_freq_channel; //!< SV Frequency Channel Number - unsigned int i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS - unsigned int i_satellite_slot_number; //!< SV Slot Number - double d_yr; //!< Current year - double d_satClkDrift; //!< GLONASS clock error - double d_dtr; //!< relativistic clock correction term - double d_iode; //!< Issue of data, ephemeris (Bit 0-6 of tb) - double d_tau_c; //!< GLONASST 2 UTC correction (todo) may be eliminated - double d_TOW; //!< GLONASST IN GPST seconds of week - double d_WN; //!< GLONASST IN GPST week number of the start of frame - double d_tod; //!< Time of Day since ephemeris where decoded + int32_t i_satellite_freq_channel; //!< SV Frequency Channel Number + uint32_t i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS + uint32_t i_satellite_slot_number; //!< SV Slot Number + double d_yr; //!< Current year + double d_satClkDrift; //!< GLONASS clock error + double d_dtr; //!< relativistic clock correction term + double d_iode; //!< Issue of data, ephemeris (Bit 0-6 of tb) + double d_tau_c; //!< GLONASST 2 UTC correction (todo) may be eliminated + double d_TOW; //!< GLONASST IN GPST seconds of week + double d_WN; //!< GLONASST IN GPST week number of the start of frame + double d_tod; //!< Time of Day since ephemeris where decoded template /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - void serialize(Archive& archive, const unsigned int version) + void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index 469c42ae3..4433efc8a 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -38,8 +38,8 @@ void Glonass_Gnav_Navigation_Message::reset() { // Satellite Identification - i_satellite_PRN = 0; - i_alm_satellite_slot_number = 0; //!< SV Orbit Slot Number + i_satellite_PRN = 0U; + i_alm_satellite_slot_number = 0; // SV Orbit Slot Number flag_update_slot_number = false; // Ephmeris Flags @@ -63,17 +63,17 @@ void Glonass_Gnav_Navigation_Message::reset() flag_almanac_str_15 = false; // UTC and System Clocks Flags - flag_utc_model_valid = false; //!< If set, it indicates that the UTC model parameters are filled - flag_utc_model_str_5 = false; //!< Clock info send in string 5 of navigation data - flag_utc_model_str_15 = false; //!< Clock info send in string 15 of frame 5 of navigation data + flag_utc_model_valid = false; // If set, it indicates that the UTC model parameters are filled + flag_utc_model_str_5 = false; // Clock info send in string 5 of navigation data + flag_utc_model_str_15 = false; // Clock info send in string 15 of frame 5 of navigation data // broadcast orbit 1 flag_TOW_set = false; flag_TOW_new = false; flag_CRC_test = false; - d_frame_ID = 0; - d_string_ID = 0; + d_frame_ID = 0U; + d_string_ID = 0U; i_channel_ID = 0; // Clock terms @@ -83,15 +83,17 @@ void Glonass_Gnav_Navigation_Message::reset() // Data update information d_previous_tb = 0.0; - for (unsigned int i = 0; i < GLONASS_CA_NBR_SATS; i++) - d_previous_Na[i] = 0.0; + for (double& i : d_previous_Na) + { + i = 0.0; + } - std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + std::map satelliteBlock; // Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus auto gnss_sat = Gnss_Satellite(); std::string _system("GLONASS"); //TODO SHould number of channels be hardcoded? - for (unsigned int i = 1; i < 14; i++) + for (uint32_t i = 1; i < 14; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); } @@ -106,113 +108,111 @@ Glonass_Gnav_Navigation_Message::Glonass_Gnav_Navigation_Message() bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset bits) { - int sum_bits = 0; - int sum_hamming = 0; - int C1 = 0; - int C2 = 0; - int C3 = 0; - int C4 = 0; - int C5 = 0; - int C6 = 0; - int C7 = 0; - int C_Sigma = 0; - std::vector string_bits(GLONASS_GNAV_STRING_BITS); + int32_t sum_bits = 0; + int32_t sum_hamming = 0; + int32_t C1 = 0; + int32_t C2 = 0; + int32_t C3 = 0; + int32_t C4 = 0; + int32_t C5 = 0; + int32_t C6 = 0; + int32_t C7 = 0; + int32_t C_Sigma = 0; + std::vector string_bits(GLONASS_GNAV_STRING_BITS); - //!< Populate data and hamming code vectors - for (int i = 0; i < static_cast(GLONASS_GNAV_STRING_BITS); i++) + // Populate data and hamming code vectors + for (int32_t i = 0; i < static_cast(GLONASS_GNAV_STRING_BITS); i++) { - string_bits[i] = static_cast(bits[i]); + string_bits[i] = static_cast(bits[i]); } - //!< Compute C1 term + // Compute C1 term sum_bits = 0; - for (int i = 0; i < static_cast(GLONASS_GNAV_CRC_I_INDEX.size()); i++) + for (int i : GLONASS_GNAV_CRC_I_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_I_INDEX[i] - 1]; + sum_bits += string_bits[i - 1]; } C1 = string_bits[0] ^ (sum_bits % 2); - //!< Compute C2 term + // Compute C2 term sum_bits = 0; - for (int j = 0; j < static_cast(GLONASS_GNAV_CRC_J_INDEX.size()); j++) + for (int j : GLONASS_GNAV_CRC_J_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_J_INDEX[j] - 1]; + sum_bits += string_bits[j - 1]; } C2 = (string_bits[1]) ^ (sum_bits % 2); - //!< Compute C3 term + // Compute C3 term sum_bits = 0; - for (int k = 0; k < static_cast(GLONASS_GNAV_CRC_K_INDEX.size()); k++) + for (int k : GLONASS_GNAV_CRC_K_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_K_INDEX[k] - 1]; + sum_bits += string_bits[k - 1]; } C3 = string_bits[2] ^ (sum_bits % 2); - //!< Compute C4 term + // Compute C4 term sum_bits = 0; - for (int l = 0; l < static_cast(GLONASS_GNAV_CRC_L_INDEX.size()); l++) + for (int l : GLONASS_GNAV_CRC_L_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_L_INDEX[l] - 1]; + sum_bits += string_bits[l - 1]; } C4 = string_bits[3] ^ (sum_bits % 2); - //!< Compute C5 term + // Compute C5 term sum_bits = 0; - for (int m = 0; m < static_cast(GLONASS_GNAV_CRC_M_INDEX.size()); m++) + for (int m : GLONASS_GNAV_CRC_M_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_M_INDEX[m] - 1]; + sum_bits += string_bits[m - 1]; } C5 = string_bits[4] ^ (sum_bits % 2); - //!< Compute C6 term + // Compute C6 term sum_bits = 0; - for (int n = 0; n < static_cast(GLONASS_GNAV_CRC_N_INDEX.size()); n++) + for (int n : GLONASS_GNAV_CRC_N_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_N_INDEX[n] - 1]; + sum_bits += string_bits[n - 1]; } C6 = string_bits[5] ^ (sum_bits % 2); - //!< Compute C7 term + // Compute C7 term sum_bits = 0; - for (int p = 0; p < static_cast(GLONASS_GNAV_CRC_P_INDEX.size()); p++) + for (int p : GLONASS_GNAV_CRC_P_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_P_INDEX[p] - 1]; + sum_bits += string_bits[p - 1]; } C7 = string_bits[6] ^ (sum_bits % 2); - //!< Compute C_Sigma term + // Compute C_Sigma term sum_bits = 0; sum_hamming = 0; - for (int q = 0; q < static_cast(GLONASS_GNAV_CRC_Q_INDEX.size()); q++) + for (int q : GLONASS_GNAV_CRC_Q_INDEX) { - sum_bits += string_bits[GLONASS_GNAV_CRC_Q_INDEX[q] - 1]; + sum_bits += string_bits[q - 1]; } - for (int q = 0; q < 8; q++) + for (int32_t q = 0; q < 8; q++) { sum_hamming += string_bits[q]; } C_Sigma = (sum_hamming % 2) ^ (sum_bits % 2); - //!< Verification of the data + // Verification of the data // (a-i) All checksums (C1,...,C7 and C_Sigma) are equal to zero if ((C1 + C2 + C3 + C4 + C5 + C6 + C7 + C_Sigma) == 0) { return true; } // (a-ii) Only one of the checksums (C1,...,C7) is equal to zero but C_Sigma = 1 - else if (C_Sigma == 1 && C1 + C2 + C3 + C4 + C5 + C6 + C7 == 6) + if (C_Sigma == 1 && C1 + C2 + C3 + C4 + C5 + C6 + C7 == 6) { return true; } - else - // All other conditions are assumed errors. TODO: Add correction for case B - { - return false; - } + + // All other conditions are assumed errors. TODO: Add correction for case B + return false; } -bool Glonass_Gnav_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) +bool Glonass_Gnav_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector>& parameter) { bool value; @@ -228,18 +228,18 @@ bool Glonass_Gnav_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) +uint64_t Glonass_Gnav_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector>& parameter) { - unsigned long int value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left + value <<= 1; // shift left if (bits[GLONASS_GNAV_STRING_BITS - parameter[i].first - j] == 1) { - value += 1; // insert the bit + value += 1ULL; // insert the bit } } } @@ -247,28 +247,28 @@ unsigned long int Glonass_Gnav_Navigation_Message::read_navigation_unsigned(std: } -signed long int Glonass_Gnav_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector> parameter) +int64_t Glonass_Gnav_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector>& parameter) { - signed long int value = 0; - signed long int sign = 0; - int num_of_slices = parameter.size(); + int64_t value = 0LL; + int64_t sign = 0LL; + int32_t num_of_slices = parameter.size(); // read the MSB and perform the sign extension if (bits[GLONASS_GNAV_STRING_BITS - parameter[0].first] == 1) { - sign = -1; + sign = -1LL; } else { - sign = 1; + sign = 1LL; } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 1; j < parameter[i].second; j++) + for (int32_t j = 1; j < parameter[i].second; j++) { - value <<= 1; //shift left + value <<= 1; // shift left if (bits[GLONASS_GNAV_STRING_BITS - parameter[i].first - j] == 1) { - value += 1; // insert the bit + value += 1LL; // insert the bit } } } @@ -276,45 +276,45 @@ signed long int Glonass_Gnav_Navigation_Message::read_navigation_signed(std::bit } -unsigned int Glonass_Gnav_Navigation_Message::get_frame_number(unsigned int satellite_slot_number) +uint32_t Glonass_Gnav_Navigation_Message::get_frame_number(uint32_t satellite_slot_number) { - unsigned int frame_ID = 0; + uint32_t frame_ID = 0U; if (satellite_slot_number >= 1 and satellite_slot_number <= 5) { - frame_ID = 1; + frame_ID = 1U; } else if (satellite_slot_number >= 6 and satellite_slot_number <= 10) { - frame_ID = 2; + frame_ID = 2U; } else if (satellite_slot_number >= 11 and satellite_slot_number <= 15) { - frame_ID = 3; + frame_ID = 3U; } else if (satellite_slot_number >= 16 and satellite_slot_number <= 20) { - frame_ID = 4; + frame_ID = 4U; } else if (satellite_slot_number >= 21 and satellite_slot_number <= 24) { - frame_ID = 5; + frame_ID = 5U; } else { LOG(WARNING) << "GLONASS GNAV: Invalid Satellite Slot Number"; - frame_ID = 0; + frame_ID = 0U; } return frame_ID; } -int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) +int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame_string) { - int J = 0; - d_string_ID = 0; - d_frame_ID = 0; + int32_t J = 0; + d_string_ID = 0U; + d_frame_ID = 0U; // Unpack bytes to bits std::bitset string_bits(frame_string); @@ -322,14 +322,16 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // Perform data verification and exit code if error in bit sequence flag_CRC_test = CRC_test(string_bits); if (flag_CRC_test == false) - return 0; + { + return 0; + } // Decode all 15 string messages - d_string_ID = static_cast(read_navigation_unsigned(string_bits, STRING_ID)); + d_string_ID = static_cast(read_navigation_unsigned(string_bits, STRING_ID)); switch (d_string_ID) { case 1: - //--- It is string 1 ----------------------------------------------- + // --- It is string 1 ----------------------------------------------- gnav_ephemeris.d_P_1 = (static_cast(read_navigation_unsigned(string_bits, P1)) + 1) * 15; gnav_ephemeris.d_t_k = static_cast(read_navigation_unsigned(string_bits, T_K_HR)) * 3600 + static_cast(read_navigation_unsigned(string_bits, T_K_MIN)) * 60 + @@ -343,7 +345,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) break; case 2: - //--- It is string 2 ----------------------------------------------- + // --- It is string 2 ----------------------------------------------- if (flag_ephemeris_str_1 == true) { gnav_ephemeris.d_B_n = static_cast(read_navigation_unsigned(string_bits, B_N)); @@ -391,8 +393,8 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // Fill in ephemeris deliverables in the code flag_update_slot_number = true; - gnav_ephemeris.i_satellite_slot_number = static_cast(gnav_ephemeris.d_n); - gnav_ephemeris.i_satellite_PRN = static_cast(gnav_ephemeris.d_n); + gnav_ephemeris.i_satellite_slot_number = static_cast(gnav_ephemeris.d_n); + gnav_ephemeris.i_satellite_PRN = static_cast(gnav_ephemeris.d_n); flag_ephemeris_str_4 = true; } @@ -403,7 +405,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // --- It is string 5 ---------------------------------------------- if (flag_ephemeris_str_4 == true) { - gnav_utc_model.d_N_A = static_cast(read_navigation_unsigned(string_bits, N_A)); + gnav_utc_model.d_N_A = static_cast(read_navigation_unsigned(string_bits, DAY_NUMBER_A)); gnav_utc_model.d_tau_c = static_cast(read_navigation_signed(string_bits, TAU_C)) * TWO_N31; gnav_utc_model.d_N_4 = static_cast(read_navigation_unsigned(string_bits, N_4)); gnav_utc_model.d_tau_gps = static_cast(read_navigation_signed(string_bits, TAU_GPS)) * TWO_N30; @@ -449,15 +451,17 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 6: // --- It is string 6 ---------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, N_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; gnav_almanac[i_alm_satellite_slot_number - 1].d_lambda_n_A = static_cast(read_navigation_signed(string_bits, LAMBDA_N_A)) * TWO_N20 * GLONASS_PI; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_i_n_A = static_cast(read_navigation_signed(string_bits, DELTA_I_N_A)) * TWO_N20 * GLONASS_PI; @@ -497,15 +501,17 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 8: // --- It is string 8 ---------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, N_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; gnav_almanac[i_alm_satellite_slot_number - 1].d_lambda_n_A = static_cast(read_navigation_signed(string_bits, LAMBDA_N_A)) * TWO_N20 * GLONASS_PI; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_i_n_A = static_cast(read_navigation_signed(string_bits, DELTA_I_N_A)) * TWO_N20 * GLONASS_PI; @@ -540,15 +546,17 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 10: // --- It is string 10 --------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, N_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; gnav_almanac[i_alm_satellite_slot_number - 1].d_lambda_n_A = static_cast(read_navigation_signed(string_bits, LAMBDA_N_A)) * TWO_N20 * GLONASS_PI; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_i_n_A = static_cast(read_navigation_signed(string_bits, DELTA_I_N_A)) * TWO_N20 * GLONASS_PI; @@ -583,14 +591,16 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 12: // --- It is string 12 --------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, N_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; gnav_almanac[i_alm_satellite_slot_number - 1].d_lambda_n_A = static_cast(read_navigation_signed(string_bits, LAMBDA_N_A)) * TWO_N20 * GLONASS_PI; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_i_n_A = static_cast(read_navigation_signed(string_bits, DELTA_I_N_A)) * TWO_N20 * GLONASS_PI; @@ -632,14 +642,16 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) } else { - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, N_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; gnav_almanac[i_alm_satellite_slot_number - 1].d_lambda_n_A = static_cast(read_navigation_signed(string_bits, LAMBDA_N_A)) * TWO_N20 * GLONASS_PI; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_i_n_A = static_cast(read_navigation_signed(string_bits, DELTA_I_N_A)) * TWO_N20 * GLONASS_PI; @@ -694,7 +706,7 @@ Glonass_Gnav_Utc_Model Glonass_Gnav_Navigation_Message::get_utc_model() } -Glonass_Gnav_Almanac Glonass_Gnav_Navigation_Message::get_almanac(unsigned int satellite_slot_number) +Glonass_Gnav_Almanac Glonass_Gnav_Navigation_Message::get_almanac(uint32_t satellite_slot_number) { return gnav_almanac[satellite_slot_number - 1]; } @@ -733,19 +745,19 @@ bool Glonass_Gnav_Navigation_Message::have_new_utc_model() // Check if we have flag_utc_model_str_5 = false; // clear the flag return true; } - else - return false; + + return false; } -bool Glonass_Gnav_Navigation_Message::have_new_almanac() //Check if we have a new almanac data set stored in the galileo navigation class +bool Glonass_Gnav_Navigation_Message::have_new_almanac() // Check if we have a new almanac data set stored in the galileo navigation class { bool new_alm = false; if ((flag_almanac_str_6 == true) and (flag_almanac_str_7 == true)) { if (d_previous_Na[i_alm_satellite_slot_number] != gnav_utc_model.d_N_A) { - //All almanac have been received for this satellite + // All almanac have been received for this satellite flag_almanac_str_6 = false; flag_almanac_str_7 = false; new_alm = true; diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.h b/src/core/system_parameters/glonass_gnav_navigation_message.h index 54fe5219b..6f1f92312 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.h +++ b/src/core/system_parameters/glonass_gnav_navigation_message.h @@ -35,11 +35,12 @@ #define GNSS_SDR_GLONASS_GNAV_NAVIGATION_MESSAGE_H_ -#include "glonass_gnav_ephemeris.h" -#include "glonass_gnav_almanac.h" -#include "glonass_gnav_utc_model.h" #include "GLONASS_L1_L2_CA.h" +#include "glonass_gnav_almanac.h" +#include "glonass_gnav_ephemeris.h" +#include "glonass_gnav_utc_model.h" #include +#include /*! @@ -50,18 +51,18 @@ class Glonass_Gnav_Navigation_Message { private: - unsigned long int read_navigation_unsigned(std::bitset bits, const std::vector> parameter); - signed long int read_navigation_signed(std::bitset bits, const std::vector> parameter); - bool read_navigation_bool(std::bitset bits, const std::vector> parameter); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector>& parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector>& parameter); + bool read_navigation_bool(std::bitset bits, const std::vector>& parameter); public: bool flag_CRC_test; - unsigned int d_frame_ID; - unsigned int d_string_ID; + uint32_t d_frame_ID; + uint32_t d_string_ID; bool flag_update_slot_number; - int i_channel_ID; - unsigned int i_satellite_PRN; + int32_t i_channel_ID; + uint32_t i_satellite_PRN; Glonass_Gnav_Ephemeris gnav_ephemeris; //!< Ephemeris information decoded Glonass_Gnav_Utc_Model gnav_utc_model; //!< UTC model information @@ -75,18 +76,18 @@ public: bool flag_ephemeris_str_4; //!< Flag indicating that ephemeris 4/4 (string 4) have been received // Almanac Flags - bool flag_all_almanac; //!< Flag indicating that all almanac have been received - bool flag_almanac_str_6; //!< Flag indicating that almanac of string 6 have been received - bool flag_almanac_str_7; //!< Flag indicating that almanac of string 7 have been received - bool flag_almanac_str_8; //!< Flag indicating that almanac of string 8 have been received - bool flag_almanac_str_9; //!< Flag indicating that almanac of string 9 have been received - bool flag_almanac_str_10; //!< Flag indicating that almanac of string 10 have been received - bool flag_almanac_str_11; //!< Flag indicating that almanac of string 11 have been received - bool flag_almanac_str_12; //!< Flag indicating that almanac of string 12 have been received - bool flag_almanac_str_13; //!< Flag indicating that almanac of string 13 have been received - bool flag_almanac_str_14; //!< Flag indicating that almanac of string 14 have been received - bool flag_almanac_str_15; //!< Flag indicating that almanac of string 15 have been received - unsigned int i_alm_satellite_slot_number; //!< SV Orbit Slot Number + bool flag_all_almanac; //!< Flag indicating that all almanac have been received + bool flag_almanac_str_6; //!< Flag indicating that almanac of string 6 have been received + bool flag_almanac_str_7; //!< Flag indicating that almanac of string 7 have been received + bool flag_almanac_str_8; //!< Flag indicating that almanac of string 8 have been received + bool flag_almanac_str_9; //!< Flag indicating that almanac of string 9 have been received + bool flag_almanac_str_10; //!< Flag indicating that almanac of string 10 have been received + bool flag_almanac_str_11; //!< Flag indicating that almanac of string 11 have been received + bool flag_almanac_str_12; //!< Flag indicating that almanac of string 12 have been received + bool flag_almanac_str_13; //!< Flag indicating that almanac of string 13 have been received + bool flag_almanac_str_14; //!< Flag indicating that almanac of string 14 have been received + bool flag_almanac_str_15; //!< Flag indicating that almanac of string 15 have been received + uint32_t i_alm_satellite_slot_number; //!< SV Orbit Slot Number // UTC and System Clocks Flags bool flag_utc_model_valid; //!< If set, it indicates that the UTC model parameters are filled @@ -114,7 +115,7 @@ public: * \param satellite_slot_number [in] Satellite slot number identifier * \returns Frame number being decoded, 0 if operation was not successful. */ - unsigned int get_frame_number(unsigned int satellite_slot_number); + uint32_t get_frame_number(uint32_t satellite_slot_number); /*! * \brief Reset GLONASS GNAV Navigation Information @@ -136,7 +137,7 @@ public: * \param satellite_slot_number Slot number identifier for the satellite * \returns Returns the Glonass_Gnav_Almanac object for the input slot number */ - Glonass_Gnav_Almanac get_almanac(unsigned int satellite_slot_number); + Glonass_Gnav_Almanac get_almanac(uint32_t satellite_slot_number); /*! * \brief Returns true if a new Glonass_Gnav_Ephemeris object has arrived. @@ -158,7 +159,7 @@ public: * \param frame_string [in] is the string message within the parsed frame * \returns Returns the ID of the decoded string */ - int string_decoder(std::string frame_string); + int32_t string_decoder(const std::string& frame_string); /*! * Default constructor diff --git a/src/core/system_parameters/glonass_gnav_utc_model.cc b/src/core/system_parameters/glonass_gnav_utc_model.cc index ceea01529..5450d1581 100644 --- a/src/core/system_parameters/glonass_gnav_utc_model.cc +++ b/src/core/system_parameters/glonass_gnav_utc_model.cc @@ -49,7 +49,7 @@ double Glonass_Gnav_Utc_Model::utc_time(double glonass_time_corrected) double t_utc; // GLONASS Time is relative to UTC Moscow, so we simply add its time difference - t_utc = glonass_time_corrected + 3 * 3600 + d_tau_c; + t_utc = glonass_time_corrected + 3.0 * 3600.0 + d_tau_c; return t_utc; } diff --git a/src/core/system_parameters/glonass_gnav_utc_model.h b/src/core/system_parameters/glonass_gnav_utc_model.h index 8d76d90e2..5a082cb7e 100644 --- a/src/core/system_parameters/glonass_gnav_utc_model.h +++ b/src/core/system_parameters/glonass_gnav_utc_model.h @@ -34,8 +34,8 @@ #ifndef GNSS_SDR_GLONASS_GNAV_UTC_MODEL_H_ #define GNSS_SDR_GLONASS_GNAV_UTC_MODEL_H_ -#include #include +#include /*! * \brief This class is a storage for the GLONASS GNAV UTC MODEL data as described in GLONASS ICD (Edition 5.1) @@ -58,7 +58,7 @@ public: /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the almanac data on disk file. */ - void serialize(Archive& archive, const unsigned int version) + void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/gnss_obs_codes.h b/src/core/system_parameters/gnss_obs_codes.h index a28329760..b1e772466 100644 --- a/src/core/system_parameters/gnss_obs_codes.h +++ b/src/core/system_parameters/gnss_obs_codes.h @@ -33,64 +33,65 @@ #ifndef GNSS_SDR_GNSS_OBS_CODES_H_ #define GNSS_SDR_GNSS_OBS_CODES_H_ +#include -const unsigned int CODE_NONE = 0; //!< obs code: none or unknown -const unsigned int CODE_L1C = 1; //!< obs code: L1C/A,G1C/A,E1C (GPS,GLO,GAL,QZS,SBS) -const unsigned int CODE_L1P = 2; //!< obs code: L1P,G1P (GPS,GLO) -const unsigned int CODE_L1W = 3; //!< obs code: L1 Z-track (GPS) -const unsigned int CODE_L1Y = 4; //!< obs code: L1Y (GPS) -const unsigned int CODE_L1M = 5; //!< obs code: L1M (GPS) -const unsigned int CODE_L1N = 6; //!< obs code: L1codeless (GPS) -const unsigned int CODE_L1S = 7; //!< obs code: L1C(D) (GPS,QZS) -const unsigned int CODE_L1L = 8; //!< obs code: L1C(P) (GPS,QZS) -const unsigned int CODE_L1E = 9; //!< (not used) -const unsigned int CODE_L1A = 10; //!< obs code: E1A (GAL) -const unsigned int CODE_L1B = 11; //!< obs code: E1B (GAL) -const unsigned int CODE_L1X = 12; //!< obs code: E1B+C,L1C(D+P) (GAL,QZS) -const unsigned int CODE_L1Z = 13; //!< obs code: E1A+B+C,L1SAIF (GAL,QZS) -const unsigned int CODE_L2C = 14; //!< obs code: L2C/A,G1C/A (GPS,GLO) -const unsigned int CODE_L2D = 15; //!< obs code: L2 L1C/A-(P2-P1) (GPS) -const unsigned int CODE_L2S = 16; //!< obs code: L2C(M) (GPS,QZS) -const unsigned int CODE_L2L = 17; //!< obs code: L2C(L) (GPS,QZS) -const unsigned int CODE_L2X = 18; //!< obs code: L2C(M+L),B1I+Q (GPS,QZS,BDS) -const unsigned int CODE_L2P = 19; //!< obs code: L2P,G2P (GPS,GLO) -const unsigned int CODE_L2W = 20; //!< obs code: L2 Z-track (GPS) -const unsigned int CODE_L2Y = 21; //!< obs code: L2Y (GPS) -const unsigned int CODE_L2M = 22; //!< obs code: L2M (GPS) -const unsigned int CODE_L2N = 23; //!< obs code: L2codeless (GPS) -const unsigned int CODE_L5I = 24; //!< obs code: L5/E5aI (GPS,GAL,QZS,SBS) -const unsigned int CODE_L5Q = 25; //!< obs code: L5/E5aQ (GPS,GAL,QZS,SBS) -const unsigned int CODE_L5X = 26; //!< obs code: L5/E5aI+Q/L5B+C (GPS,GAL,QZS,IRN,SBS) -const unsigned int CODE_L7I = 27; //!< obs code: E5bI,B2I (GAL,BDS) -const unsigned int CODE_L7Q = 28; //!< obs code: E5bQ,B2Q (GAL,BDS) -const unsigned int CODE_L7X = 29; //!< obs code: E5bI+Q,B2I+Q (GAL,BDS) -const unsigned int CODE_L6A = 30; //!< obs code: E6A (GAL) -const unsigned int CODE_L6B = 31; //!< obs code: E6B (GAL) -const unsigned int CODE_L6C = 32; //!< obs code: E6C (GAL) -const unsigned int CODE_L6X = 33; //!< obs code: E6B+C,LEXS+L,B3I+Q (GAL,QZS,BDS) -const unsigned int CODE_L6Z = 34; //!< obs code: E6A+B+C (GAL) -const unsigned int CODE_L6S = 35; //!< obs code: LEXS (QZS) -const unsigned int CODE_L6L = 36; //!< obs code: LEXL (QZS) -const unsigned int CODE_L8I = 37; //!< obs code: E5(a+b)I (GAL) -const unsigned int CODE_L8Q = 38; //!< obs code: E5(a+b)Q (GAL) -const unsigned int CODE_L8X = 39; //!< obs code: E5(a+b)I+Q (GAL) -const unsigned int CODE_L2I = 40; //!< obs code: B1I (BDS) -const unsigned int CODE_L2Q = 41; //!< obs code: B1Q (BDS) -const unsigned int CODE_L6I = 42; //!< obs code: B3I (BDS) -const unsigned int CODE_L6Q = 43; //!< obs code: B3Q (BDS) -const unsigned int CODE_L3I = 44; //!< obs code: G3I (GLO) -const unsigned int CODE_L3Q = 45; //!< obs code: G3Q (GLO) -const unsigned int CODE_L3X = 46; //!< obs code: G3I+Q (GLO) -const unsigned int CODE_L1I = 47; //!< obs code: B1I (BDS) -const unsigned int CODE_L1Q = 48; //!< obs code: B1Q (BDS) -const unsigned int CODE_L5A = 49; //!< obs code: L5A SPS (IRN) -const unsigned int CODE_L5B = 50; //!< obs code: L5B RS(D) (IRN) -const unsigned int CODE_L5C = 51; //!< obs code: L5C RS(P) (IRN) -const unsigned int CODE_L9A = 52; //!< obs code: SA SPS (IRN) -const unsigned int CODE_L9B = 53; //!< obs code: SB RS(D) (IRN) -const unsigned int CODE_L9C = 54; //!< obs code: SC RS(P) (IRN) -const unsigned int CODE_L9X = 55; //!< obs code: SB+C (IRN) -const int MAXCODE = 55; //!< max number of obs code +const uint32_t CODE_NONE = 0; //!< obs code: none or unknown +const uint32_t CODE_L1C = 1; //!< obs code: L1C/A,G1C/A,E1C (GPS,GLO,GAL,QZS,SBS) +const uint32_t CODE_L1P = 2; //!< obs code: L1P,G1P (GPS,GLO) +const uint32_t CODE_L1W = 3; //!< obs code: L1 Z-track (GPS) +const uint32_t CODE_L1Y = 4; //!< obs code: L1Y (GPS) +const uint32_t CODE_L1M = 5; //!< obs code: L1M (GPS) +const uint32_t CODE_L1N = 6; //!< obs code: L1codeless (GPS) +const uint32_t CODE_L1S = 7; //!< obs code: L1C(D) (GPS,QZS) +const uint32_t CODE_L1L = 8; //!< obs code: L1C(P) (GPS,QZS) +const uint32_t CODE_L1E = 9; //!< (not used) +const uint32_t CODE_L1A = 10; //!< obs code: E1A (GAL) +const uint32_t CODE_L1B = 11; //!< obs code: E1B (GAL) +const uint32_t CODE_L1X = 12; //!< obs code: E1B+C,L1C(D+P) (GAL,QZS) +const uint32_t CODE_L1Z = 13; //!< obs code: E1A+B+C,L1SAIF (GAL,QZS) +const uint32_t CODE_L2C = 14; //!< obs code: L2C/A,G1C/A (GPS,GLO) +const uint32_t CODE_L2D = 15; //!< obs code: L2 L1C/A-(P2-P1) (GPS) +const uint32_t CODE_L2S = 16; //!< obs code: L2C(M) (GPS,QZS) +const uint32_t CODE_L2L = 17; //!< obs code: L2C(L) (GPS,QZS) +const uint32_t CODE_L2X = 18; //!< obs code: L2C(M+L),B1I+Q (GPS,QZS,BDS) +const uint32_t CODE_L2P = 19; //!< obs code: L2P,G2P (GPS,GLO) +const uint32_t CODE_L2W = 20; //!< obs code: L2 Z-track (GPS) +const uint32_t CODE_L2Y = 21; //!< obs code: L2Y (GPS) +const uint32_t CODE_L2M = 22; //!< obs code: L2M (GPS) +const uint32_t CODE_L2N = 23; //!< obs code: L2codeless (GPS) +const uint32_t CODE_L5I = 24; //!< obs code: L5/E5aI (GPS,GAL,QZS,SBS) +const uint32_t CODE_L5Q = 25; //!< obs code: L5/E5aQ (GPS,GAL,QZS,SBS) +const uint32_t CODE_L5X = 26; //!< obs code: L5/E5aI+Q/L5B+C (GPS,GAL,QZS,IRN,SBS) +const uint32_t CODE_L7I = 27; //!< obs code: E5bI,B2I (GAL,BDS) +const uint32_t CODE_L7Q = 28; //!< obs code: E5bQ,B2Q (GAL,BDS) +const uint32_t CODE_L7X = 29; //!< obs code: E5bI+Q,B2I+Q (GAL,BDS) +const uint32_t CODE_L6A = 30; //!< obs code: E6A (GAL) +const uint32_t CODE_L6B = 31; //!< obs code: E6B (GAL) +const uint32_t CODE_L6C = 32; //!< obs code: E6C (GAL) +const uint32_t CODE_L6X = 33; //!< obs code: E6B+C,LEXS+L,B3I+Q (GAL,QZS,BDS) +const uint32_t CODE_L6Z = 34; //!< obs code: E6A+B+C (GAL) +const uint32_t CODE_L6S = 35; //!< obs code: LEXS (QZS) +const uint32_t CODE_L6L = 36; //!< obs code: LEXL (QZS) +const uint32_t CODE_L8I = 37; //!< obs code: E5(a+b)I (GAL) +const uint32_t CODE_L8Q = 38; //!< obs code: E5(a+b)Q (GAL) +const uint32_t CODE_L8X = 39; //!< obs code: E5(a+b)I+Q (GAL) +const uint32_t CODE_L2I = 40; //!< obs code: B1I (BDS) +const uint32_t CODE_L2Q = 41; //!< obs code: B1Q (BDS) +const uint32_t CODE_L6I = 42; //!< obs code: B3I (BDS) +const uint32_t CODE_L6Q = 43; //!< obs code: B3Q (BDS) +const uint32_t CODE_L3I = 44; //!< obs code: G3I (GLO) +const uint32_t CODE_L3Q = 45; //!< obs code: G3Q (GLO) +const uint32_t CODE_L3X = 46; //!< obs code: G3I+Q (GLO) +const uint32_t CODE_L1I = 47; //!< obs code: B1I (BDS) +const uint32_t CODE_L1Q = 48; //!< obs code: B1Q (BDS) +const uint32_t CODE_L5A = 49; //!< obs code: L5A SPS (IRN) +const uint32_t CODE_L5B = 50; //!< obs code: L5B RS(D) (IRN) +const uint32_t CODE_L5C = 51; //!< obs code: L5C RS(P) (IRN) +const uint32_t CODE_L9A = 52; //!< obs code: SA SPS (IRN) +const uint32_t CODE_L9B = 53; //!< obs code: SB RS(D) (IRN) +const uint32_t CODE_L9C = 54; //!< obs code: SC RS(P) (IRN) +const uint32_t CODE_L9X = 55; //!< obs code: SB+C (IRN) +const int32_t MAXCODE = 55; //!< max number of obs code #endif diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index bb9655bc1..0252ef8f8 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -38,7 +38,7 @@ Gnss_Satellite::Gnss_Satellite() } -Gnss_Satellite::Gnss_Satellite(const std::string& system_, unsigned int PRN_) +Gnss_Satellite::Gnss_Satellite(const std::string& system_, uint32_t PRN_) { Gnss_Satellite::reset(); Gnss_Satellite::set_system(system_); @@ -47,9 +47,7 @@ Gnss_Satellite::Gnss_Satellite(const std::string& system_, unsigned int PRN_) } -Gnss_Satellite::~Gnss_Satellite() -{ -} +Gnss_Satellite::~Gnss_Satellite() = default; void Gnss_Satellite::reset() @@ -69,10 +67,16 @@ void Gnss_Satellite::reset() std::ostream& operator<<(std::ostream& out, const Gnss_Satellite& sat) // output { - std::string tag(""); - std::string tag2(""); - if (sat.get_system().compare("Galileo") == 0) tag = "E"; - if (sat.get_PRN() < 10) tag2 = "0"; + std::string tag; + std::string tag2; + if (sat.get_system() == "Galileo") + { + tag = "E"; + } + if (sat.get_PRN() < 10) + { + tag2 = "0"; + } out << sat.get_system() << " PRN " << tag << tag2 << sat.get_PRN() << " (Block " << sat.get_block() << ")"; return out; } @@ -81,9 +85,9 @@ std::ostream& operator<<(std::ostream& out, const Gnss_Satellite& sat) // outpu bool operator==(const Gnss_Satellite& sat1, const Gnss_Satellite& sat2) { bool equal = false; - if (sat1.get_system().compare(sat2.get_system()) == 0) + if (sat1.get_system() == sat2.get_system()) { - if (sat1.get_PRN() == (sat2.get_PRN())) + if (sat1.get_PRN() == sat2.get_PRN()) { equal = true; } @@ -98,9 +102,9 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite &rhs) { if (this != &rhs) { // Deallocate, allocate new space, copy values... const std::string system_ = rhs.get_system(); - const unsigned int PRN_ = rhs.get_PRN(); + const uint32_t PRN_ = rhs.get_PRN(); const std::string block_ = rhs.get_block(); - // const signed int rf_link_ = 0; + // const int32_t rf_link_ = 0; this->set_system(system_); this->set_PRN(PRN_); this->set_block(system_, PRN_); @@ -113,7 +117,7 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite &rhs) { void Gnss_Satellite::set_system(const std::string& system_) { // Set the satellite system {"GPS", "Glonass", "SBAS", "Galileo", "Compass"} - std::set::iterator it = system_set.find(system_); + auto it = system_set.find(system_); if (it != system_set.cend()) { @@ -127,9 +131,9 @@ void Gnss_Satellite::set_system(const std::string& system_) } -void Gnss_Satellite::update_PRN(unsigned int PRN_) +void Gnss_Satellite::update_PRN(uint32_t PRN_) { - if (system.compare("Glonass") != 0) + if (system != "Glonass") { DLOG(INFO) << "Trying to update PRN for not GLONASS system"; PRN = 0; @@ -150,15 +154,15 @@ void Gnss_Satellite::update_PRN(unsigned int PRN_) } -void Gnss_Satellite::set_PRN(unsigned int PRN_) +void Gnss_Satellite::set_PRN(uint32_t PRN_) { // Set satellite's PRN - if (system.compare("") == 0) + if (system.empty()) { DLOG(INFO) << "Trying to define PRN while system is not defined"; PRN = 0; } - if (system.compare("GPS") == 0) + if (system == "GPS") { if (PRN_ < 1 or PRN_ > 32) { @@ -170,7 +174,7 @@ void Gnss_Satellite::set_PRN(unsigned int PRN_) PRN = PRN_; } } - else if (system.compare("Glonass") == 0) + else if (system == "Glonass") { if (PRN_ < 1 or PRN_ > 24) { @@ -182,35 +186,39 @@ void Gnss_Satellite::set_PRN(unsigned int PRN_) PRN = PRN_; } } - else if (system.compare("SBAS") == 0) + else if (system == "SBAS") { - if (PRN_ == 122) + if (PRN_ == 120) { PRN = PRN_; - } // WAAS Inmarsat 3F4 (AOR-W) - else if (PRN_ == 134) + } // EGNOS Test Platform.Inmarsat 3-F2 (Atlantic Ocean Region-East) + else if (PRN_ == 123) { PRN = PRN_; - } // WAAS Inmarsat 3F3 (POR) - else if (PRN_ == 120) + } // EGNOS Operational Platform. Astra 5B + else if (PRN_ == 131) { PRN = PRN_; - } // EGNOS AOR-E Broadcast satellite http://www.egnos-pro.esa.int/index.html - else if (PRN_ == 124) + } // WAAS Eutelsat 117 West B + else if (PRN_ == 135) { PRN = PRN_; - } // EGNOS ESA ARTEMIS used for EGNOS Operations - else if (PRN_ == 126) + } // WAAS Galaxy 15 + else if (PRN_ == 136) { PRN = PRN_; - } // EGNOS IOR-W currently used by Industry to perform various tests on the system. + } // EGNOS Operational Platform. SES-5 (a.k.a. Sirius 5 or Astra 4B) + else if (PRN_ == 138) + { + PRN = PRN_; + } // WAAS Anik F1R else { DLOG(INFO) << "This PRN is not defined"; PRN = 0; } } - else if (system.compare("Galileo") == 0) + else if (system == "Galileo") { if (PRN_ < 1 or PRN_ > 36) { @@ -222,6 +230,19 @@ void Gnss_Satellite::set_PRN(unsigned int PRN_) PRN = PRN_; } } + else if (system == "Beidou") + { + if (PRN_ < 1 or PRN_ > 37) + { + DLOG(INFO) << "This PRN is not defined"; + PRN = 0; + } + else + { + PRN = PRN_; + } + } + else { DLOG(INFO) << "System " << system << " is not defined"; @@ -230,19 +251,19 @@ void Gnss_Satellite::set_PRN(unsigned int PRN_) } -signed int Gnss_Satellite::get_rf_link() const +int32_t Gnss_Satellite::get_rf_link() const { // Get satellite's rf link. Identifies the GLONASS Frequency Channel - signed int rf_link_; + int32_t rf_link_; rf_link_ = rf_link; return rf_link_; } -unsigned int Gnss_Satellite::get_PRN() const +uint32_t Gnss_Satellite::get_PRN() const { // Get satellite's PRN - unsigned int PRN_; + uint32_t PRN_; PRN_ = PRN; return PRN_; } @@ -273,10 +294,10 @@ std::string Gnss_Satellite::get_block() const } -std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int PRN_) +std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_) { std::string block_ = "Unknown"; - if (system_.compare("GPS") == 0) + if (system_ == "GPS") { // info from https://www.navcen.uscg.gov/?Do=constellationStatus switch (PRN_) @@ -382,7 +403,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int } } - if (system_.compare("Glonass") == 0) + if (system_ == "Glonass") { // Info from http://www.sdcm.ru/smglo/grupglo?version=eng&site=extern // See also http://www.glonass-center.ru/en/GLONASS/ @@ -488,30 +509,33 @@ std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int block_ = std::string("Unknown"); } } - if (system_.compare("SBAS") == 0) + if (system_ == "SBAS") { switch (PRN_) { - case 122: - block_ = std::string("WAAS"); // WAAS Inmarsat 3F4 (AOR-W) - break; - case 134: - block_ = std::string("WAAS"); // WAAS Inmarsat 3F3 (POR) - break; case 120: - block_ = std::string("EGNOS"); // EGNOS AOR-E Broadcast satellite http://www.egnos-pro.esa.int/index.html + block_ = std::string("EGNOS Test Platform"); // Inmarsat 3-F2 (Atlantic Ocean Region-East) break; - case 124: - block_ = std::string("EGNOS"); // EGNOS ESA ARTEMIS used for EGNOS Operations + case 123: + block_ = std::string("EGNOS"); // EGNOS Operational Platform. Astra 5B break; - case 126: - block_ = std::string("EGNOS"); // EGNOS IOR-W currently used by Industry to perform various tests on the system. + case 131: + block_ = std::string("WAAS"); // WAAS Eutelsat 117 West B + break; + case 135: + block_ = std::string("WAAS"); // WAAS Galaxy 15 + break; + case 136: + block_ = std::string("EGNOS"); // EGNOS Operational Platform. SES-5 (a.k.a. Sirius 5 or Astra 4B) + break; + case 138: + block_ = std::string("WAAS"); // WAAS Anik F1R break; default: block_ = std::string("Unknown"); } } - if (system_.compare("Galileo") == 0) + if (system_ == "Galileo") { // Check http://en.wikipedia.org/wiki/List_of_Galileo_satellites and https://www.gsc-europa.eu/system-status/Constellation-Information switch (PRN_) @@ -546,9 +570,15 @@ std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int case 12: block_ = std::string("IOV-FM2"); // Galileo In-Orbit Validation (IOV) satellite FM2 (Flight Model 2) also known as GSAT0102, from French Guiana at 10:30 GMT on October 21, 2011. break; + case 13: + block_ = std::string("FOC-FM20"); // Galileo Full Operational Capability (FOC) satellite FM20 / GSAT0220, launched on Jul. 25, 2018. UNDER COMMISSIONING. + break; case 14: block_ = std::string("FOC-FM2*"); // Galileo Full Operational Capability (FOC) satellite FM2 / GSAT0202, launched into incorrect orbit on August 22, 2014. Moved to usable orbit in March, 2015. UNDER TESTING. break; + case 15: + block_ = std::string("FOC-FM21"); // Galileo Full Operational Capability (FOC) satellite FM21 / GSAT0221, launched on Jul. 25, 2018. UNDER COMMISSIONING. + break; case 18: block_ = std::string("FOC-FM1*"); // Galileo Full Operational Capability (FOC) satellite FM1 / GSAT0201, launched into incorrect orbit on August 22, 2014. Moved to usable orbit in December, 2014. UNDER TESTING. break; @@ -582,6 +612,63 @@ std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int case 31: block_ = std::string("FOC-FM18"); // Galileo Full Operational Capability (FOC) satellite FM18 / GSAT0218, launched on Dec. 12, 2017. UNDER COMMISSIONING. break; + case 33: + block_ = std::string("FOC-FM22"); // Galileo Full Operational Capability (FOC) satellite FM22 / GSAT0222, launched on Jul. 25, 2018. UNDER COMMISSIONING. + break; + case 36: + block_ = std::string("FOC-FM19"); // Galileo Full Operational Capability (FOC) satellite FM19 / GSAT0219, launched on Jul. 25, 2018. UNDER COMMISSIONING. + break; + default: + block_ = std::string("Unknown(Simulated)"); + } + } + if (system_ == "Beidou") + { + // Check https://en.wikipedia.org/wiki/List_of_BeiDou_satellites + switch (PRN_) + { + case 19: + block_ = std::string("BEIDOU-3 M1"); //! -#include +#include #include +#include +#include /*! @@ -46,28 +47,29 @@ class Gnss_Satellite { public: - Gnss_Satellite(); //!< Default Constructor. - Gnss_Satellite(const std::string& system_, unsigned int PRN_); //!< Concrete GNSS satellite Constructor. - ~Gnss_Satellite(); //!< Default Destructor. - void update_PRN(unsigned int PRN); //!< Updates the PRN Number when information is decoded, only applies to GLONASS GNAV messages - unsigned int get_PRN() const; //!< Gets satellite's PRN - signed int get_rf_link() const; //!< Gets the satellite's rf link - std::string get_system() const; //!< Gets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Beidou"} - std::string get_system_short() const; //!< Gets the satellite system {"G", "R", "SBAS", "E", "C"} - std::string get_block() const; //!< Gets the satellite block. If GPS, returns {"IIA", "IIR", "IIR-M", "IIF"} - std::string what_block(const std::string& system_, unsigned int PRN_); //!< Gets the block of a given satellite - friend bool operator==(const Gnss_Satellite&, const Gnss_Satellite&); //!< operator== for comparison - friend std::ostream& operator<<(std::ostream&, const Gnss_Satellite&); //!< operator<< for pretty printing + Gnss_Satellite(); //!< Default Constructor. + Gnss_Satellite(const std::string& system_, uint32_t PRN_); //!< Concrete GNSS satellite Constructor. + ~Gnss_Satellite(); //!< Default Destructor. + void update_PRN(uint32_t PRN); //!< Updates the PRN Number when information is decoded, only applies to GLONASS GNAV messages + uint32_t get_PRN() const; //!< Gets satellite's PRN + int32_t get_rf_link() const; //!< Gets the satellite's rf link + std::string get_system() const; //!< Gets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Beidou"} + std::string get_system_short() const; //!< Gets the satellite system {"G", "R", "SBAS", "E", "C"} + std::string get_block() const; //!< Gets the satellite block. If GPS, returns {"IIA", "IIR", "IIR-M", "IIF"} + std::string what_block(const std::string& system_, uint32_t PRN_); //!< Gets the block of a given satellite + + friend bool operator==(const Gnss_Satellite& /*sat1*/, const Gnss_Satellite& /*sat2*/); //!< operator== for comparison + friend std::ostream& operator<<(std::ostream& /*out*/, const Gnss_Satellite& /*sat*/); //!< operator<< for pretty printing //Gnss_Satellite& operator=(const Gnss_Satellite &); private: - unsigned int PRN; + uint32_t PRN; std::string system; std::map satelliteSystem; std::string block; - signed int rf_link; + int32_t rf_link; void set_system(const std::string& system); // Sets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Beidou"}. - void set_PRN(unsigned int PRN); // Sets satellite's PRN - void set_block(const std::string& system_, unsigned int PRN_); + void set_PRN(uint32_t PRN); // Sets satellite's PRN + void set_block(const std::string& system_, uint32_t PRN_); std::set system_set; // = {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"}; void reset(); }; diff --git a/src/core/system_parameters/gnss_signal.cc b/src/core/system_parameters/gnss_signal.cc index 882b5d231..0c25a7841 100644 --- a/src/core/system_parameters/gnss_signal.cc +++ b/src/core/system_parameters/gnss_signal.cc @@ -36,11 +36,13 @@ Gnss_Signal::Gnss_Signal() this->signal = ""; } + Gnss_Signal::Gnss_Signal(const std::string& signal_) { this->signal = signal_; } + Gnss_Signal::Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_) { this->satellite = satellite_; @@ -48,9 +50,7 @@ Gnss_Signal::Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& si } -Gnss_Signal::~Gnss_Signal() -{ -} +Gnss_Signal::~Gnss_Signal() = default; std::string Gnss_Signal::get_signal_str() const @@ -78,7 +78,7 @@ bool operator==(const Gnss_Signal& sig1, const Gnss_Signal& sig2) if (sig1.get_satellite() == sig2.get_satellite()) { - if (sig1.get_signal_str().compare(sig1.get_signal_str()) == 0) + if (sig1.get_signal_str() == sig1.get_signal_str()) { equal = true; } diff --git a/src/core/system_parameters/gnss_signal.h b/src/core/system_parameters/gnss_signal.h index f857042e8..a2abc773f 100644 --- a/src/core/system_parameters/gnss_signal.h +++ b/src/core/system_parameters/gnss_signal.h @@ -52,10 +52,11 @@ public: Gnss_Signal(const std::string& signal_); Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_); ~Gnss_Signal(); - std::string get_signal_str() const; //!< Get the satellite signal {"1C" for GPS L1 C/A, "2S" for GPS L2C (M), "L5" for GPS L5, "1G" for GLONASS L1 C/A, "1B" for Galileo E1B, "5X" for Galileo E5a. - Gnss_Satellite get_satellite() const; //!< Get the Gnss_Satellite associated to the signal - friend bool operator==(const Gnss_Signal&, const Gnss_Signal&); //!< operator== for comparison - friend std::ostream& operator<<(std::ostream&, const Gnss_Signal&); //!< operator<< for pretty printing + std::string get_signal_str() const; //!< Get the satellite signal {"1C" for GPS L1 C/A, "2S" for GPS L2C (M), "L5" for GPS L5, "1G" for GLONASS L1 C/A, "1B" for Galileo E1B, "5X" for Galileo E5a. + Gnss_Satellite get_satellite() const; //!< Get the Gnss_Satellite associated to the signal + + friend bool operator==(const Gnss_Signal& /*sig1*/, const Gnss_Signal& /*sig2*/); //!< operator== for comparison + friend std::ostream& operator<<(std::ostream& /*out*/, const Gnss_Signal& /*sig*/); //!< operator<< for pretty printing }; #endif diff --git a/src/core/system_parameters/gnss_synchro.h b/src/core/system_parameters/gnss_synchro.h index 7d572dffa..117bdda7e 100644 --- a/src/core/system_parameters/gnss_synchro.h +++ b/src/core/system_parameters/gnss_synchro.h @@ -4,6 +4,7 @@ * \author * Luis Esteve, 2012. luis(at)epsilon-formacion.com * Javier Arribas, 2012. jarribas(at)cttc.es + * Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com * ------------------------------------------------------------------------- * * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) @@ -28,11 +29,13 @@ * * ------------------------------------------------------------------------- */ + #ifndef GNSS_SDR_GNSS_SYNCHRO_H_ #define GNSS_SDR_GNSS_SYNCHRO_H_ #include "gnss_signal.h" - +#include +#include /*! * \brief This is the class that contains the information that is shared @@ -42,36 +45,82 @@ class Gnss_Synchro { public: // Satellite and signal info - char System; //!< Set by Channel::set_signal(Gnss_Signal gnss_signal) - char Signal[3]; //!< Set by Channel::set_signal(Gnss_Signal gnss_signal) - unsigned int PRN; //!< Set by Channel::set_signal(Gnss_Signal gnss_signal) - int Channel_ID; //!< Set by Channel constructor + char System; //!< Set by Channel::set_signal(Gnss_Signal gnss_signal) + char Signal[3]; //!< Set by Channel::set_signal(Gnss_Signal gnss_signal) + uint32_t PRN; //!< Set by Channel::set_signal(Gnss_Signal gnss_signal) + int32_t Channel_ID; //!< Set by Channel constructor + // Acquisition - double Acq_delay_samples; //!< Set by Acquisition processing block - double Acq_doppler_hz; //!< Set by Acquisition processing block - unsigned long int Acq_samplestamp_samples; //!< Set by Acquisition processing block - bool Flag_valid_acquisition; //!< Set by Acquisition processing block - //Tracking - long int fs; //!< Set by Tracking processing block - double Prompt_I; //!< Set by Tracking processing block - double Prompt_Q; //!< Set by Tracking processing block - double CN0_dB_hz; //!< Set by Tracking processing block - double Carrier_Doppler_hz; //!< Set by Tracking processing block - double Carrier_phase_rads; //!< Set by Tracking processing block - double Code_phase_samples; //!< Set by Tracking processing block - unsigned long int Tracking_sample_counter; //!< Set by Tracking processing block + double Acq_delay_samples; //!< Set by Acquisition processing block + double Acq_doppler_hz; //!< Set by Acquisition processing block + uint64_t Acq_samplestamp_samples; //!< Set by Acquisition processing block + uint32_t Acq_doppler_step; //!< Set by Acquisition processing block + bool Flag_valid_acquisition; //!< Set by Acquisition processing block - bool Flag_valid_symbol_output; //!< Set by Tracking processing block - int correlation_length_ms; //!< Set by Tracking processing block + // Tracking + int64_t fs; //!< Set by Tracking processing block + double Prompt_I; //!< Set by Tracking processing block + double Prompt_Q; //!< Set by Tracking processing block + double CN0_dB_hz; //!< Set by Tracking processing block + double Carrier_Doppler_hz; //!< Set by Tracking processing block + double Carrier_phase_rads; //!< Set by Tracking processing block + double Code_phase_samples; //!< Set by Tracking processing block + uint64_t Tracking_sample_counter; //!< Set by Tracking processing block + bool Flag_valid_symbol_output; //!< Set by Tracking processing block + int32_t correlation_length_ms; //!< Set by Tracking processing block - //Telemetry Decoder - bool Flag_valid_word; //!< Set by Telemetry Decoder processing block - double TOW_at_current_symbol_s; //!< Set by Telemetry Decoder processing block + // Telemetry Decoder + bool Flag_valid_word; //!< Set by Telemetry Decoder processing block + uint32_t TOW_at_current_symbol_ms; //!< Set by Telemetry Decoder processing block // Observables double Pseudorange_m; //!< Set by Observables processing block double RX_time; //!< Set by Observables processing block bool Flag_valid_pseudorange; //!< Set by Observables processing block + double interp_TOW_ms; //!< Set by Observables processing block + + /*! + * \brief This member function serializes and restores + * Gnss_Synchro objects from a byte stream. + */ + template + + void serialize(Archive& ar, const unsigned int version) + { + if (version) + { + }; + // Satellite and signal info + ar& BOOST_SERIALIZATION_NVP(System); + ar& BOOST_SERIALIZATION_NVP(Signal); + ar& BOOST_SERIALIZATION_NVP(PRN); + ar& BOOST_SERIALIZATION_NVP(Channel_ID); + // Acquisition + ar& BOOST_SERIALIZATION_NVP(Acq_delay_samples); + ar& BOOST_SERIALIZATION_NVP(Acq_doppler_hz); + ar& BOOST_SERIALIZATION_NVP(Acq_samplestamp_samples); + ar& BOOST_SERIALIZATION_NVP(Acq_doppler_step); + ar& BOOST_SERIALIZATION_NVP(Flag_valid_acquisition); + // Tracking + ar& BOOST_SERIALIZATION_NVP(fs); + ar& BOOST_SERIALIZATION_NVP(Prompt_I); + ar& BOOST_SERIALIZATION_NVP(Prompt_Q); + ar& BOOST_SERIALIZATION_NVP(CN0_dB_hz); + ar& BOOST_SERIALIZATION_NVP(Carrier_Doppler_hz); + ar& BOOST_SERIALIZATION_NVP(Carrier_phase_rads); + ar& BOOST_SERIALIZATION_NVP(Code_phase_samples); + ar& BOOST_SERIALIZATION_NVP(Tracking_sample_counter); + ar& BOOST_SERIALIZATION_NVP(Flag_valid_symbol_output); + ar& BOOST_SERIALIZATION_NVP(correlation_length_ms); + // Telemetry Decoder + ar& BOOST_SERIALIZATION_NVP(Flag_valid_word); + ar& BOOST_SERIALIZATION_NVP(TOW_at_current_symbol_ms); + // Observables + ar& BOOST_SERIALIZATION_NVP(Pseudorange_m); + ar& BOOST_SERIALIZATION_NVP(RX_time); + ar& BOOST_SERIALIZATION_NVP(Flag_valid_pseudorange); + ar& BOOST_SERIALIZATION_NVP(interp_TOW_ms); + } }; #endif diff --git a/src/core/system_parameters/gps_acq_assist.cc b/src/core/system_parameters/gps_acq_assist.cc index 5b4510560..128772316 100644 --- a/src/core/system_parameters/gps_acq_assist.cc +++ b/src/core/system_parameters/gps_acq_assist.cc @@ -34,7 +34,7 @@ Gps_Acq_Assist::Gps_Acq_Assist() { - i_satellite_PRN = 0; + i_satellite_PRN = 0U; d_TOW = 0.0; d_Doppler0 = 0.0; d_Doppler1 = 0.0; diff --git a/src/core/system_parameters/gps_acq_assist.h b/src/core/system_parameters/gps_acq_assist.h index c84d0b730..5083aca44 100644 --- a/src/core/system_parameters/gps_acq_assist.h +++ b/src/core/system_parameters/gps_acq_assist.h @@ -32,6 +32,7 @@ #ifndef GNSS_SDR_GPS_ACQ_ASSIST_H_ #define GNSS_SDR_GPS_ACQ_ASSIST_H_ +#include /*! * \brief This class is a storage for the GPS GSM RRLL acquisition assistance data as described in @@ -44,17 +45,17 @@ class Gps_Acq_Assist { public: - unsigned int i_satellite_PRN; //!< SV PRN NUMBER - double d_TOW; //!< Time Of Week assigned to the acquisition data - double d_Doppler0; //!< Doppler (0 order term) [Hz] - double d_Doppler1; //!< Doppler (1 order term) [Hz] - double dopplerUncertainty; //!< Doppler Uncertainty [Hz] - double Code_Phase; //!< Code phase [chips] - double Code_Phase_int; //!< Integer Code Phase [1 C/A code period] - double GPS_Bit_Number; //!< GPS Bit Number - double Code_Phase_window; //!< Code Phase search window [chips] - double Azimuth; //!< Satellite Azimuth [deg] - double Elevation; //!< Satellite Elevation [deg] + uint32_t i_satellite_PRN; //!< SV PRN NUMBER + double d_TOW; //!< Time Of Week assigned to the acquisition data + double d_Doppler0; //!< Doppler (0 order term) [Hz] + double d_Doppler1; //!< Doppler (1 order term) [Hz] + double dopplerUncertainty; //!< Doppler Uncertainty [Hz] + double Code_Phase; //!< Code phase [chips] + double Code_Phase_int; //!< Integer Code Phase [1 C/A code period] + double GPS_Bit_Number; //!< GPS Bit Number + double Code_Phase_window; //!< Code Phase search window [chips] + double Azimuth; //!< Satellite Azimuth [deg] + double Elevation; //!< Satellite Elevation [deg] /*! * Default constructor diff --git a/src/core/system_parameters/gps_almanac.cc b/src/core/system_parameters/gps_almanac.cc index 5c7747d0a..ec0bd828a 100644 --- a/src/core/system_parameters/gps_almanac.cc +++ b/src/core/system_parameters/gps_almanac.cc @@ -34,9 +34,10 @@ Gps_Almanac::Gps_Almanac() { - i_satellite_PRN = 0; + i_satellite_PRN = 0U; d_Delta_i = 0.0; - d_Toa = 0.0; + i_Toa = 0; + i_WNa = 0; d_M_0 = 0.0; d_e_eccentricity = 0.0; d_sqrt_A = 0.0; @@ -44,6 +45,7 @@ Gps_Almanac::Gps_Almanac() d_OMEGA = 0.0; d_OMEGA_DOT = 0.0; i_SV_health = 0; + i_AS_status = 0; d_A_f0 = 0.0; d_A_f1 = 0.0; } diff --git a/src/core/system_parameters/gps_almanac.h b/src/core/system_parameters/gps_almanac.h index d3e31db80..71175a8bd 100644 --- a/src/core/system_parameters/gps_almanac.h +++ b/src/core/system_parameters/gps_almanac.h @@ -32,6 +32,8 @@ #ifndef GNSS_SDR_GPS_ALMANAC_H_ #define GNSS_SDR_GPS_ALMANAC_H_ +#include +#include /*! * \brief This class is a storage for the GPS SV ALMANAC data as described in IS-GPS-200E @@ -41,23 +43,48 @@ class Gps_Almanac { public: - unsigned int i_satellite_PRN; //!< SV PRN NUMBER - double d_Delta_i; - double d_Toa; //!< Almanac data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] - double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] - double d_e_eccentricity; //!< Eccentricity [dimensionless] - double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] - double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] - double d_OMEGA; //!< Argument of Perigee [semi-cicles] - double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] - int i_SV_health; // SV Health - double d_A_f0; //!< Coefficient 0 of code phase offset model [s] - double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] + uint32_t i_satellite_PRN; //!< SV PRN NUMBER + double d_Delta_i; //!< Inclination Angle at Reference Time (relative to i_0 = 0.30 semi-circles) + int32_t i_Toa; //!< Almanac data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + int32_t i_WNa; //!< Almanac week number + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + double d_e_eccentricity; //!< Eccentricity [dimensionless] + double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] + double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + double d_OMEGA; //!< Argument of Perigee [semi-cicles] + double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] + int32_t i_SV_health; //!< SV Health + int32_t i_AS_status; //!< Anti-Spoofing Flags and SV Configuration + double d_A_f0; //!< Coefficient 0 of code phase offset model [s] + double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] /*! * Default constructor */ Gps_Almanac(); + + template + + void serialize(Archive& ar, const unsigned int version) + { + if (version) + { + }; + ar& BOOST_SERIALIZATION_NVP(i_satellite_PRN); + ar& BOOST_SERIALIZATION_NVP(d_Delta_i); + ar& BOOST_SERIALIZATION_NVP(i_Toa); + ar& BOOST_SERIALIZATION_NVP(i_WNa); + ar& BOOST_SERIALIZATION_NVP(d_M_0); + ar& BOOST_SERIALIZATION_NVP(d_e_eccentricity); + ar& BOOST_SERIALIZATION_NVP(d_sqrt_A); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA0); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA); + ar& BOOST_SERIALIZATION_NVP(d_OMEGA_DOT); + ar& BOOST_SERIALIZATION_NVP(i_SV_health); + ar& BOOST_SERIALIZATION_NVP(i_AS_status); + ar& BOOST_SERIALIZATION_NVP(d_A_f0); + ar& BOOST_SERIALIZATION_NVP(d_A_f1); + } }; #endif diff --git a/src/core/system_parameters/gps_cnav_ephemeris.cc b/src/core/system_parameters/gps_cnav_ephemeris.cc index 574196813..cb96a8a73 100644 --- a/src/core/system_parameters/gps_cnav_ephemeris.cc +++ b/src/core/system_parameters/gps_cnav_ephemeris.cc @@ -35,34 +35,34 @@ Gps_CNAV_Ephemeris::Gps_CNAV_Ephemeris() { - i_satellite_PRN = 0; + i_satellite_PRN = 0U; d_Toe1 = -1; d_Toe2 = -1; d_TOW = 0; - d_Crs = 0; - d_M_0 = 0; - d_Cuc = 0; - d_e_eccentricity = 0; - d_Cus = 0; + d_Crs = 0.0; + d_M_0 = 0.0; + d_Cuc = 0.0; + d_e_eccentricity = 0.0; + d_Cus = 0.0; d_Toc = 0; - d_Cic = 0; - d_OMEGA0 = 0; - d_Cis = 0; - d_i_0 = 0; - d_Crc = 0; - d_OMEGA = 0; - d_IDOT = 0; + d_Cic = 0.0; + d_OMEGA0 = 0.0; + d_Cis = 0.0; + d_i_0 = 0.0; + d_Crc = 0.0; + d_OMEGA = 0.0; + d_IDOT = 0.0; i_GPS_week = 0; - d_TGD = 0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + d_TGD = 0.0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] - d_A_f0 = 0; // Coefficient 0 of code phase offset model [s] - d_A_f1 = 0; // Coefficient 1 of code phase offset model [s/s] - d_A_f2 = 0; // Coefficient 2 of code phase offset model [s/s^2] + d_A_f0 = 0.0; // Coefficient 0 of code phase offset model [s] + d_A_f1 = 0.0; // Coefficient 1 of code phase offset model [s/s] + d_A_f2 = 0.0; // Coefficient 2 of code phase offset model [s/s^2] b_integrity_status_flag = false; b_alert_flag = false; // If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. @@ -79,7 +79,7 @@ Gps_CNAV_Ephemeris::Gps_CNAV_Ephemeris() i_URA = 0; i_signal_health = 0; - d_Top = 0.0; + d_Top = 0; d_DELTA_A = 0.0; d_A_DOT = 0.0; d_Delta_n = 0.0; @@ -95,6 +95,7 @@ Gps_CNAV_Ephemeris::Gps_CNAV_Ephemeris() b_l2c_phasing_flag = false; } + double Gps_CNAV_Ephemeris::check_t(double time) { double corrTime; @@ -162,7 +163,7 @@ double Gps_CNAV_Ephemeris::sv_clock_relativistic_term(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); @@ -232,7 +233,7 @@ double Gps_CNAV_Ephemeris::satellitePosition(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); diff --git a/src/core/system_parameters/gps_cnav_ephemeris.h b/src/core/system_parameters/gps_cnav_ephemeris.h index 97c90a272..5f39454ea 100644 --- a/src/core/system_parameters/gps_cnav_ephemeris.h +++ b/src/core/system_parameters/gps_cnav_ephemeris.h @@ -48,13 +48,13 @@ private: double check_t(double time); public: - unsigned int i_satellite_PRN; // SV PRN NUMBER + uint32_t i_satellite_PRN; // SV PRN NUMBER - //Message Types 10 and 11 Parameters (1 of 2) - int i_GPS_week; //!< GPS week number, aka WN [week] - int i_URA; //!< ED Accuracy Index - int i_signal_health; //!< Signal health (L1/L2/L5) - double d_Top; //!< Data predict time of week + // Message Types 10 and 11 Parameters (1 of 2) + int32_t i_GPS_week; //!< GPS week number, aka WN [week] + int32_t i_URA; //!< ED Accuracy Index + int32_t i_signal_health; //!< Signal health (L1/L2/L5) + int32_t d_Top; //!< Data predict time of week double d_DELTA_A; //!< Semi-major axis difference at reference time double d_A_DOT; //!< Change rate in semi-major axis double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] @@ -63,8 +63,8 @@ public: double d_e_eccentricity; //!< Eccentricity double d_OMEGA; //!< Argument of Perigee [semi-cicles] double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-cicles] - double d_Toe1; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] - double d_Toe2; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + int32_t d_Toe1; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + int32_t d_Toe2; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] double d_DELTA_OMEGA_DOT; //!< Rate of Right Ascension difference [semi-circles/s] double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] @@ -75,8 +75,8 @@ public: double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - //Clock Correction and Accuracy Parameters - double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + // Clock Correction and Accuracy Parameters + int32_t d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] double d_A_f0; //!< Coefficient 0 of code phase offset model [s] double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] double d_A_f2; //!< Coefficient 2 of code phase offset model [s/s^2] @@ -85,17 +85,14 @@ public: double d_URA1; //! bits, const std::vector> parameter) +bool Gps_CNAV_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector>& parameter) { bool value; - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1) + if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first]) == 1) { value = true; } @@ -88,18 +88,18 @@ bool Gps_CNAV_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) +uint64_t Gps_CNAV_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector>& parameter) { - unsigned long int value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1) + value <<= 1; // shift left + if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j]) == 1) { - value += 1; // insert the bit + value += 1ULL; // insert the bit } } } @@ -107,59 +107,30 @@ unsigned long int Gps_CNAV_Navigation_Message::read_navigation_unsigned(std::bit } -signed long int Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector> parameter) +int64_t Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector>& parameter) { - signed long int value = 0; - int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(signed long int); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } + int64_t value = 0LL; + int32_t num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } + // read the MSB and perform the sign extension + if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first]) == 1) + { + value ^= 0xFFFFFFFFFFFFFFFFLL; // 64 bits variable } - else // we assume we are in a 32 bits system + else { - // read the MSB and perform the sign extension - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } + value &= 0LL; + } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) { - for (int j = 0; j < parameter[i].second; j++) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFELL; // reset the corresponding bit (for the 64 bits variable) + if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j]) == 1) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value += 1LL; // insert the bit } } } @@ -169,33 +140,32 @@ signed long int Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset< void Gps_CNAV_Navigation_Message::decode_page(std::bitset data_bits) { - int PRN; - int page_type; - + int32_t PRN; + int32_t page_type; bool alert_flag; // common to all messages - PRN = static_cast(read_navigation_unsigned(data_bits, CNAV_PRN)); + PRN = static_cast(read_navigation_unsigned(data_bits, CNAV_PRN)); ephemeris_record.i_satellite_PRN = PRN; - d_TOW = static_cast(read_navigation_unsigned(data_bits, CNAV_TOW)); + d_TOW = static_cast(read_navigation_unsigned(data_bits, CNAV_TOW)); d_TOW *= CNAV_TOW_LSB; ephemeris_record.d_TOW = d_TOW; alert_flag = static_cast(read_navigation_bool(data_bits, CNAV_ALERT_FLAG)); ephemeris_record.b_alert_flag = alert_flag; - page_type = static_cast(read_navigation_unsigned(data_bits, CNAV_MSG_TYPE)); + page_type = static_cast(read_navigation_unsigned(data_bits, CNAV_MSG_TYPE)); switch (page_type) { case 10: // Ephemeris 1/2 - ephemeris_record.i_GPS_week = static_cast(read_navigation_unsigned(data_bits, CNAV_WN)); - ephemeris_record.i_signal_health = static_cast(read_navigation_unsigned(data_bits, CNAV_HEALTH)); - ephemeris_record.d_Top = static_cast(read_navigation_unsigned(data_bits, CNAV_TOP1)); + ephemeris_record.i_GPS_week = static_cast(read_navigation_unsigned(data_bits, CNAV_WN)); + ephemeris_record.i_signal_health = static_cast(read_navigation_unsigned(data_bits, CNAV_HEALTH)); + ephemeris_record.d_Top = static_cast(read_navigation_unsigned(data_bits, CNAV_TOP1)); ephemeris_record.d_Top *= CNAV_TOP1_LSB; ephemeris_record.d_URA0 = static_cast(read_navigation_signed(data_bits, CNAV_URA)); - ephemeris_record.d_Toe1 = static_cast(read_navigation_unsigned(data_bits, CNAV_TOE1)); + ephemeris_record.d_Toe1 = static_cast(read_navigation_unsigned(data_bits, CNAV_TOE1)); ephemeris_record.d_Toe1 *= CNAV_TOE1_LSB; ephemeris_record.d_DELTA_A = static_cast(read_navigation_signed(data_bits, CNAV_DELTA_A)); ephemeris_record.d_DELTA_A *= CNAV_DELTA_A_LSB; @@ -218,7 +188,7 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_unsigned(data_bits, CNAV_TOE2)); + ephemeris_record.d_Toe2 = static_cast(read_navigation_unsigned(data_bits, CNAV_TOE2)); ephemeris_record.d_Toe2 *= CNAV_TOE2_LSB; ephemeris_record.d_OMEGA0 = static_cast(read_navigation_signed(data_bits, CNAV_OMEGA0)); ephemeris_record.d_OMEGA0 *= CNAV_OMEGA0_LSB; @@ -244,7 +214,7 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_unsigned(data_bits, CNAV_TOC)); + ephemeris_record.d_Toc = static_cast(read_navigation_unsigned(data_bits, CNAV_TOC)); ephemeris_record.d_Toc *= CNAV_TOC_LSB; ephemeris_record.d_URA0 = static_cast(read_navigation_signed(data_bits, CNAV_URA_NED0)); ephemeris_record.d_URA1 = static_cast(read_navigation_unsigned(data_bits, CNAV_URA_NED1)); @@ -256,7 +226,7 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_signed(data_bits, CNAV_AF2)); ephemeris_record.d_A_f2 *= CNAV_AF2_LSB; //group delays - //Check if the grup delay values are not available. See IS-GPS-200, Table 30-IV. + // Check if the grup delay values are not available. See IS-GPS-200, Table 30-IV. //Bit string "1000000000000" is -4096 in 2 complement ephemeris_record.d_TGD = static_cast(read_navigation_signed(data_bits, CNAV_TGD)); if (ephemeris_record.d_TGD < -4095.9) @@ -312,9 +282,9 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_unsigned(data_bits, CNAV_TOP1)); + ephemeris_record.d_Top = static_cast(read_navigation_unsigned(data_bits, CNAV_TOP1)); ephemeris_record.d_Top = ephemeris_record.d_Top * CNAV_TOP1_LSB; - ephemeris_record.d_Toc = static_cast(read_navigation_unsigned(data_bits, CNAV_TOC)); + ephemeris_record.d_Toc = static_cast(read_navigation_unsigned(data_bits, CNAV_TOC)); ephemeris_record.d_Toc = ephemeris_record.d_Toc * CNAV_TOC_LSB; ephemeris_record.d_A_f0 = static_cast(read_navigation_signed(data_bits, CNAV_AF0)); ephemeris_record.d_A_f0 = ephemeris_record.d_A_f0 * CNAV_AF0_LSB; @@ -330,23 +300,22 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_signed(data_bits, CNAV_A2)); utc_model_record.d_A2 = utc_model_record.d_A2 * CNAV_A2_LSB; - - utc_model_record.d_DeltaT_LS = static_cast(read_navigation_signed(data_bits, CNAV_DELTA_TLS)); + utc_model_record.d_DeltaT_LS = static_cast(read_navigation_signed(data_bits, CNAV_DELTA_TLS)); utc_model_record.d_DeltaT_LS = utc_model_record.d_DeltaT_LS * CNAV_DELTA_TLS_LSB; - utc_model_record.d_t_OT = static_cast(read_navigation_signed(data_bits, CNAV_TOT)); + utc_model_record.d_t_OT = static_cast(read_navigation_signed(data_bits, CNAV_TOT)); utc_model_record.d_t_OT = utc_model_record.d_t_OT * CNAV_TOT_LSB; - utc_model_record.i_WN_T = static_cast(read_navigation_signed(data_bits, CNAV_WN_OT)); + utc_model_record.i_WN_T = static_cast(read_navigation_signed(data_bits, CNAV_WN_OT)); utc_model_record.i_WN_T = utc_model_record.i_WN_T * CNAV_WN_OT_LSB; - utc_model_record.i_WN_LSF = static_cast(read_navigation_signed(data_bits, CNAV_WN_LSF)); + utc_model_record.i_WN_LSF = static_cast(read_navigation_signed(data_bits, CNAV_WN_LSF)); utc_model_record.i_WN_LSF = utc_model_record.i_WN_LSF * CNAV_WN_LSF_LSB; - utc_model_record.i_DN = static_cast(read_navigation_signed(data_bits, CNAV_DN)); + utc_model_record.i_DN = static_cast(read_navigation_signed(data_bits, CNAV_DN)); utc_model_record.i_DN = utc_model_record.i_DN * CNAV_DN_LSB; - utc_model_record.d_DeltaT_LSF = static_cast(read_navigation_signed(data_bits, CNAV_DELTA_TLSF)); + utc_model_record.d_DeltaT_LSF = static_cast(read_navigation_signed(data_bits, CNAV_DELTA_TLSF)); utc_model_record.d_DeltaT_LSF = utc_model_record.d_DeltaT_LSF * CNAV_DELTA_TLSF_LSB; b_flag_utc_valid = true; break; @@ -356,27 +325,20 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset +#include #include #include -#include #include +#include //TODO: Create GPS CNAV almanac //#include "gps_almanac.h" @@ -55,22 +56,22 @@ class Gps_CNAV_Navigation_Message { private: - unsigned long int read_navigation_unsigned(std::bitset bits, const std::vector> parameter); - signed long int read_navigation_signed(std::bitset bits, const std::vector> parameter); - bool read_navigation_bool(std::bitset bits, const std::vector> parameter); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector>& parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector>& parameter); + bool read_navigation_bool(std::bitset bits, const std::vector>& parameter); Gps_CNAV_Ephemeris ephemeris_record; Gps_CNAV_Iono iono_record; Gps_CNAV_Utc_Model utc_model_record; public: - double d_TOW; + int32_t d_TOW; bool b_flag_ephemeris_1; bool b_flag_ephemeris_2; bool b_flag_iono_valid; //!< If set, it indicates that the ionospheric parameters are filled and are not yet read by the get_iono bool b_flag_utc_valid; //!< If set, it indicates that the utc parameters are filled and are not yet read by the get_utc_model - std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus // satellite positions double d_satpos_X; //!< Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and the plane passing through the origin and normal to the Z-axis. @@ -78,8 +79,8 @@ public: double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). // satellite identification info - int i_channel_ID; - unsigned int i_satellite_PRN; + int32_t i_channel_ID; + uint32_t i_satellite_PRN; // Satellite velocity double d_satvel_X; //!< Earth-fixed velocity coordinate x of the satellite [m] @@ -90,14 +91,17 @@ public: void reset(); void decode_page(std::bitset data_bits); + /*! * \brief Obtain a GPS SV Ephemeris class filled with current SV data */ Gps_CNAV_Ephemeris get_ephemeris(); + /*! * \brief Check if we have a new iono record stored in the GPS ephemeris class */ bool have_new_iono(); + /*! * \brief Obtain a GPS ionospheric correction parameters class filled with current SV data */ diff --git a/src/core/system_parameters/gps_cnav_utc_model.cc b/src/core/system_parameters/gps_cnav_utc_model.cc index a705566da..673329f31 100644 --- a/src/core/system_parameters/gps_cnav_utc_model.cc +++ b/src/core/system_parameters/gps_cnav_utc_model.cc @@ -34,9 +34,9 @@ Gps_CNAV_Utc_Model::Gps_CNAV_Utc_Model() { valid = false; - d_A2 = 0; - d_A1 = 0; - d_A0 = 0; + d_A2 = 0.0; + d_A1 = 0.0; + d_A0 = 0.0; d_t_OT = 0; i_WN_T = 0; d_DeltaT_LS = 0; @@ -45,24 +45,25 @@ Gps_CNAV_Utc_Model::Gps_CNAV_Utc_Model() d_DeltaT_LSF = 0; } -double Gps_CNAV_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) + +double Gps_CNAV_Utc_Model::utc_time(double gpstime_corrected, int32_t i_GPS_week) { double t_utc; double t_utc_daytime; double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); // Determine if the effectivity time of the leap second event is in the past - int weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; if (weeksToLeapSecondEvent >= 0) // is not in the past { - //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; if (weeksToLeapSecondEvent > 0) { t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); } - else //we are in the same week than the leap second event + else // we are in the same week than the leap second event { if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) { @@ -83,9 +84,9 @@ double Gps_CNAV_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) * proper accommodation of the leap second event with a possible week number * transition is provided by the following expression for UTC: */ - int W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + int32_t W = static_cast(fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400)) + 43200; t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); - //implement something to handle a leap second event! + // implement something to handle a leap second event! } if ((gpstime_corrected - secondOfLeapSecondEvent) > 21600) { diff --git a/src/core/system_parameters/gps_cnav_utc_model.h b/src/core/system_parameters/gps_cnav_utc_model.h index 42a26839a..555c7c640 100644 --- a/src/core/system_parameters/gps_cnav_utc_model.h +++ b/src/core/system_parameters/gps_cnav_utc_model.h @@ -34,7 +34,7 @@ #include #include - +#include /*! * \brief This class is a storage for the GPS UTC MODEL data as described in in IS-GPS-200H @@ -46,15 +46,15 @@ class Gps_CNAV_Utc_Model public: bool valid; // UTC parameters - double d_A2; //!< 2nd order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s/s] - double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s/s] - double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s] - double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200H) [s] - int i_WN_T; //!< UTC reference week number [weeks] - double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] - double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] + double d_A2; //!< 2nd order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s/s] + double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s/s] + double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s] + int32_t d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200H) [s] + int32_t i_WN_T; //!< UTC reference week number [weeks] + int32_t d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] /*! * Default constructor @@ -65,13 +65,13 @@ public: * \brief Computes the Coordinated Universal Time (UTC) and * returns it in [s] (IS-GPS-200E, 20.3.3.5.2.4 + 30.3.3.6.2) */ - double utc_time(double gpstime_corrected, int i_GPS_week); + double utc_time(double gpstime_corrected, int32_t i_GPS_week); template /* * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/gps_ephemeris.cc b/src/core/system_parameters/gps_ephemeris.cc index 3ee9ed42a..e6b5b10ae 100644 --- a/src/core/system_parameters/gps_ephemeris.cc +++ b/src/core/system_parameters/gps_ephemeris.cc @@ -31,31 +31,31 @@ */ #include "gps_ephemeris.h" -#include "gnss_satellite.h" #include "GPS_L1_CA.h" +#include "gnss_satellite.h" #include Gps_Ephemeris::Gps_Ephemeris() { - i_satellite_PRN = 0; + i_satellite_PRN = 0U; d_TOW = 0; - d_Crs = 0; - d_Delta_n = 0; - d_M_0 = 0; - d_Cuc = 0; - d_e_eccentricity = 0; - d_Cus = 0; - d_sqrt_A = 0; + d_Crs = 0.0; + d_Delta_n = 0.0; + d_M_0 = 0.0; + d_Cuc = 0.0; + d_e_eccentricity = 0.0; + d_Cus = 0.0; + d_sqrt_A = 0.0; d_Toe = 0; d_Toc = 0; - d_Cic = 0; - d_OMEGA0 = 0; - d_Cis = 0; - d_i_0 = 0; - d_Crc = 0; - d_OMEGA = 0; - d_OMEGA_DOT = 0; - d_IDOT = 0; + d_Cic = 0.0; + d_OMEGA0 = 0.0; + d_Cis = 0.0; + d_i_0 = 0.0; + d_Crc = 0.0; + d_OMEGA = 0.0; + d_OMEGA_DOT = 0.0; + d_IDOT = 0.0; i_code_on_L2 = 0; i_GPS_week = 0; b_L2_P_data_flag = false; @@ -63,17 +63,17 @@ Gps_Ephemeris::Gps_Ephemeris() i_SV_health = 0; d_IODE_SF2 = 0; d_IODE_SF3 = 0; - d_TGD = 0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] - d_IODC = 0; // Issue of Data, Clock - i_AODO = 0; // Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + d_TGD = 0.0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + d_IODC = 0; // Issue of Data, Clock + i_AODO = 0; // Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] b_fit_interval_flag = false; // indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. - d_spare1 = 0; - d_spare2 = 0; + d_spare1 = 0.0; + d_spare2 = 0.0; - d_A_f0 = 0; // Coefficient 0 of code phase offset model [s] - d_A_f1 = 0; // Coefficient 1 of code phase offset model [s/s] - d_A_f2 = 0; // Coefficient 2 of code phase offset model [s/s^2] + d_A_f0 = 0.0; // Coefficient 0 of code phase offset model [s] + d_A_f1 = 0.0; // Coefficient 1 of code phase offset model [s/s] + d_A_f2 = 0.0; // Coefficient 2 of code phase offset model [s/s^2] b_integrity_status_flag = false; b_alert_flag = false; // If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. @@ -81,7 +81,7 @@ Gps_Ephemeris::Gps_Ephemeris() auto gnss_sat = Gnss_Satellite(); std::string _system("GPS"); - for (unsigned int i = 1; i < 33; i++) + for (uint32_t i = 1; i < 33; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); } @@ -120,7 +120,7 @@ double Gps_Ephemeris::sv_clock_drift(double transmitTime) // double dt; // dt = check_t(transmitTime - d_Toc); // - // for (int i = 0; i < 2; i++) + // for (int32_t i = 0; i < 2; i++) // { // dt -= d_A_f0 + d_A_f1 * dt + d_A_f2 * (dt * dt); // } @@ -169,7 +169,7 @@ double Gps_Ephemeris::sv_clock_relativistic_term(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); @@ -228,7 +228,7 @@ double Gps_Ephemeris::satellitePosition(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); @@ -283,7 +283,7 @@ double Gps_Ephemeris::satellitePosition(double transmitTime) double dtr_s = d_A_f0 + d_A_f1 * tk + d_A_f2 * tk * tk; /* relativity correction */ - dtr_s -= 2.0 * sqrt(GM * a) * d_e_eccentricity * sin(E) / (GPS_C_m_s * GPS_C_m_s); + dtr_s -= 2.0 * sqrt(GM * a) * d_e_eccentricity * sin(E) / (GPS_C_M_S * GPS_C_M_S); return dtr_s; } diff --git a/src/core/system_parameters/gps_ephemeris.h b/src/core/system_parameters/gps_ephemeris.h index d13ad4893..683eb9135 100644 --- a/src/core/system_parameters/gps_ephemeris.h +++ b/src/core/system_parameters/gps_ephemeris.h @@ -34,8 +34,9 @@ #include -#include #include +#include +#include #include #include @@ -58,35 +59,35 @@ private: double check_t(double time); public: - unsigned int i_satellite_PRN; // SV PRN NUMBER - double d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] - double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] - double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] - double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] - double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - double d_e_eccentricity; //!< Eccentricity [dimensionless] - double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] - double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] - double d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] - double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] - double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] - double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] - double d_Cis; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] - double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] - double d_Crc; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] - double d_OMEGA; //!< Argument of Perigee [semi-cicles] - double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] - double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] - int i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; - int i_GPS_week; //!< GPS week number, aka WN [week] - bool b_L2_P_data_flag; //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel - int i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) - int i_SV_health; - double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] - double d_IODC; //!< Issue of Data, Clock - double d_IODE_SF2; //!< Issue of Data, Ephemeris (IODE), subframe 2 - double d_IODE_SF3; //!< Issue of Data, Ephemeris(IODE), subframe 3 - int i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + uint32_t i_satellite_PRN; // SV PRN NUMBER + int32_t d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] + double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] + double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + double d_e_eccentricity; //!< Eccentricity [dimensionless] + double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] + double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] + int32_t d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + int32_t d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] + double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + double d_Cis; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] + double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] + double d_Crc; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] + double d_OMEGA; //!< Argument of Perigee [semi-cicles] + double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] + double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] + int32_t i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; + int32_t i_GPS_week; //!< GPS week number, aka WN [week] + bool b_L2_P_data_flag; //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel + int32_t i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) + int32_t i_SV_health; + double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + int32_t d_IODC; //!< Issue of Data, Clock + int32_t d_IODE_SF2; //!< Issue of Data, Ephemeris (IODE), subframe 2 + int32_t d_IODE_SF3; //!< Issue of Data, Ephemeris(IODE), subframe 3 + int32_t i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] bool b_fit_interval_flag; //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. double d_spare1; @@ -110,7 +111,7 @@ public: */ bool b_integrity_status_flag; bool b_alert_flag; //!< If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. - bool b_antispoofing_flag; //!< If true, the AntiSpoofing mode is ON in that SV + bool b_antispoofing_flag; //!< If true, the AntiSpoofing mode is ON in that SV // clock terms derived from ephemeris data double d_satClkDrift; //!< GPS clock error @@ -133,7 +134,7 @@ public: /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) @@ -152,7 +153,7 @@ public: archive& make_nvp("d_Cus", d_Cus); //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] archive& make_nvp("d_sqrt_A", d_sqrt_A); //!< Square Root of the Semi-Major Axis [sqrt(m)] archive& make_nvp("d_Toe", d_Toe); //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] - archive& make_nvp("d_Toc", d_Toe); //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + archive& make_nvp("d_Toc", d_Toc); //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] archive& make_nvp("d_Cic", d_Cic); //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] archive& make_nvp("d_OMEGA0", d_OMEGA0); //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] archive& make_nvp("d_Cis", d_Cis); //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc index 7d7fd298f..e551551dc 100644 --- a/src/core/system_parameters/gps_navigation_message.cc +++ b/src/core/system_parameters/gps_navigation_message.cc @@ -39,7 +39,7 @@ m * \file gps_navigation_message.cc void Gps_Navigation_Message::reset() { b_valid_ephemeris_set_flag = false; - d_TOW = 0.0; + d_TOW = 0; d_TOW_SF1 = 0; d_TOW_SF2 = 0; d_TOW_SF3 = 0; @@ -47,57 +47,57 @@ void Gps_Navigation_Message::reset() d_TOW_SF5 = 0; d_IODE_SF2 = 0; d_IODE_SF3 = 0; - d_Crs = 0; - d_Delta_n = 0; - d_M_0 = 0; - d_Cuc = 0; - d_e_eccentricity = 0; - d_Cus = 0; - d_sqrt_A = 0; + d_Crs = 0.0; + d_Delta_n = 0.0; + d_M_0 = 0.0; + d_Cuc = 0.0; + d_e_eccentricity = 0.0; + d_Cus = 0.0; + d_sqrt_A = 0.0; d_Toe = 0; d_Toc = 0; - d_Cic = 0; - d_OMEGA0 = 0; - d_Cis = 0; - d_i_0 = 0; - d_Crc = 0; - d_OMEGA = 0; - d_OMEGA_DOT = 0; - d_IDOT = 0; + d_Cic = 0.0; + d_OMEGA0 = 0.0; + d_Cis = 0.0; + d_i_0 = 0.0; + d_Crc = 0.0; + d_OMEGA = 0.0; + d_OMEGA_DOT = 0.0; + d_IDOT = 0.0; i_code_on_L2 = 0; i_GPS_week = 0; b_L2_P_data_flag = false; i_SV_accuracy = 0; i_SV_health = 0; - d_TGD = 0; - d_IODC = -1.0; + d_TGD = 0.0; + d_IODC = -1; i_AODO = 0; b_fit_interval_flag = false; - d_spare1 = 0; - d_spare2 = 0; + d_spare1 = 0.0; + d_spare2 = 0.0; - d_A_f0 = 0; - d_A_f1 = 0; - d_A_f2 = 0; + d_A_f0 = 0.0; + d_A_f1 = 0.0; + d_A_f2 = 0.0; //clock terms //d_master_clock=0; - d_dtr = 0; - d_satClkCorr = 0; - d_satClkDrift = 0; + d_dtr = 0.0; + d_satClkCorr = 0.0; + d_satClkDrift = 0.0; // satellite positions - d_satpos_X = 0; - d_satpos_Y = 0; - d_satpos_Z = 0; + d_satpos_X = 0.0; + d_satpos_Y = 0.0; + d_satpos_Z = 0.0; // info i_channel_ID = 0; - i_satellite_PRN = 0; + i_satellite_PRN = 0U; // time synchro - d_subframe_timestamp_ms = 0; + d_subframe_timestamp_ms = 0.0; // flags b_alert_flag = false; @@ -107,16 +107,17 @@ void Gps_Navigation_Message::reset() // Ionosphere and UTC flag_iono_valid = false; flag_utc_model_valid = false; - d_alpha0 = 0; - d_alpha1 = 0; - d_alpha2 = 0; - d_alpha3 = 0; - d_beta0 = 0; - d_beta1 = 0; - d_beta2 = 0; - d_beta3 = 0; - d_A1 = 0; - d_A0 = 0; + d_alpha0 = 0.0; + d_alpha1 = 0.0; + d_alpha2 = 0.0; + d_alpha3 = 0.0; + d_beta0 = 0.0; + d_beta1 = 0.0; + d_beta2 = 0.0; + d_beta3 = 0.0; + d_A2 = 0.0; + d_A1 = 0.0; + d_A0 = 0.0; d_t_OT = 0; i_WN_T = 0; d_DeltaT_LS = 0; @@ -124,22 +125,22 @@ void Gps_Navigation_Message::reset() i_DN = 0; d_DeltaT_LSF = 0; - //Almanac - d_Toa = 0; + // Almanac + i_Toa = 0; i_WN_A = 0; - for (int i = 1; i < 32; i++) + for (int32_t i = 1; i < 32; i++) { almanacHealth[i] = 0; } // Satellite velocity - d_satvel_X = 0; - d_satvel_Y = 0; - d_satvel_Z = 0; + d_satvel_X = 0.0; + d_satvel_Y = 0.0; + d_satvel_Z = 0.0; auto gnss_sat = Gnss_Satellite(); std::string _system("GPS"); - for (unsigned int i = 1; i < 33; i++) + for (uint32_t i = 1; i < 33; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); } @@ -152,7 +153,7 @@ Gps_Navigation_Message::Gps_Navigation_Message() } -void Gps_Navigation_Message::print_gps_word_bytes(unsigned int GPS_word) +void Gps_Navigation_Message::print_gps_word_bytes(uint32_t GPS_word) { std::cout << " Word ="; std::cout << std::bitset<32>(GPS_word); @@ -160,11 +161,11 @@ void Gps_Navigation_Message::print_gps_word_bytes(unsigned int GPS_word) } -bool Gps_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) +bool Gps_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector>& parameter) { bool value; - if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1) + if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[0].first]) == 1) { value = true; } @@ -176,18 +177,18 @@ bool Gps_Navigation_Message::read_navigation_bool(std::bitset } -unsigned long int Gps_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +uint64_t Gps_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector>& parameter) { - unsigned long int value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left - if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1) + value <<= 1; // shift left + if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[i].first - j]) == 1) { - value += 1; // insert the bit + value += 1ULL; // insert the bit } } } @@ -195,198 +196,166 @@ unsigned long int Gps_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +int64_t Gps_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector>& parameter) { - signed long int value = 0; - int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(signed long int); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } + int64_t value = 0LL; + int32_t num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } + // read the MSB and perform the sign extension + if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[0].first]) == 1) + { + value ^= 0xFFFFFFFFFFFFFFFFLL; // 64 bits variable } - else // we assume we are in a 32 bits system + else { - // read the MSB and perform the sign extension - if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } + value &= 0LL; + } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) { - for (int j = 0; j < parameter[i].second; j++) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFELL; // reset the corresponding bit (for the 64 bits variable) + if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[i].first - j]) == 1) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value += 1LL; // insert the bit } } } return value; } -int Gps_Navigation_Message::subframe_decoder(char *subframe) + +int32_t Gps_Navigation_Message::subframe_decoder(char* subframe) { - int subframe_ID = 0; - - //double tmp_TOW; - - unsigned int gps_word; + int32_t subframe_ID = 0; + uint32_t gps_word; // UNPACK BYTES TO BITS AND REMOVE THE CRC REDUNDANCE std::bitset subframe_bits; std::bitset word_bits; - for (int i = 0; i < 10; i++) + for (int32_t i = 0; i < 10; i++) { memcpy(&gps_word, &subframe[i * 4], sizeof(char) * 4); word_bits = std::bitset<(GPS_WORD_BITS + 2)>(gps_word); - for (int j = 0; j < GPS_WORD_BITS; j++) + for (int32_t j = 0; j < GPS_WORD_BITS; j++) { subframe_bits[GPS_WORD_BITS * (9 - i) + j] = word_bits[j]; } } - subframe_ID = static_cast(read_navigation_unsigned(subframe_bits, SUBFRAME_ID)); + subframe_ID = static_cast(read_navigation_unsigned(subframe_bits, SUBFRAME_ID)); // Decode all 5 sub-frames switch (subframe_ID) - { - //--- Decode the sub-frame id ------------------------------------------ - // ICD (IS-GPS-200E Appendix II). http://www.losangeles.af.mil/shared/media/document/AFD-100813-045.pdf - case 1: - //--- It is subframe 1 ------------------------------------- - // Compute the time of week (TOW) of the first sub-frames in the array ==== - // The transmitted TOW is actual TOW of the next subframe - // (the variable subframe at this point contains bits of the last subframe). - //TOW = bin2dec(subframe(31:47)) * 6; - d_TOW_SF1 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); - //we are in the first subframe (the transmitted TOW is the start time of the next subframe) ! - d_TOW_SF1 = d_TOW_SF1 * 6.0; - d_TOW = d_TOW_SF1; // Set transmission time - b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); - b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); - b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - i_GPS_week = static_cast(read_navigation_unsigned(subframe_bits, GPS_WEEK)); - i_SV_accuracy = static_cast(read_navigation_unsigned(subframe_bits, SV_ACCURACY)); // (20.3.3.3.1.3) - i_SV_health = static_cast(read_navigation_unsigned(subframe_bits, SV_HEALTH)); - b_L2_P_data_flag = read_navigation_bool(subframe_bits, L2_P_DATA_FLAG); // - i_code_on_L2 = static_cast(read_navigation_unsigned(subframe_bits, CA_OR_P_ON_L2)); - d_TGD = static_cast(read_navigation_signed(subframe_bits, T_GD)); - d_TGD = d_TGD * T_GD_LSB; - d_IODC = static_cast(read_navigation_unsigned(subframe_bits, IODC)); - d_Toc = static_cast(read_navigation_unsigned(subframe_bits, T_OC)); - d_Toc = d_Toc * T_OC_LSB; - d_A_f0 = static_cast(read_navigation_signed(subframe_bits, A_F0)); - d_A_f0 = d_A_f0 * A_F0_LSB; - d_A_f1 = static_cast(read_navigation_signed(subframe_bits, A_F1)); - d_A_f1 = d_A_f1 * A_F1_LSB; - d_A_f2 = static_cast(read_navigation_signed(subframe_bits, A_F2)); - d_A_f2 = d_A_f2 * A_F2_LSB; - + { + //--- Decode the sub-frame id ------------------------------------------ + // ICD (IS-GPS-200E Appendix II). http://www.losangeles.af.mil/shared/media/document/AFD-100813-045.pdf + case 1: + //--- It is subframe 1 ------------------------------------- + // Compute the time of week (TOW) of the first sub-frames in the array ==== + // The transmitted TOW is actual TOW of the next subframe + // (the variable subframe at this point contains bits of the last subframe). + //TOW = bin2dec(subframe(31:47)) * 6; + d_TOW_SF1 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); + //we are in the first subframe (the transmitted TOW is the start time of the next subframe) ! + d_TOW_SF1 = d_TOW_SF1 * 6; + d_TOW = d_TOW_SF1; // Set transmission time + b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); + b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); + b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); + i_GPS_week = static_cast(read_navigation_unsigned(subframe_bits, GPS_WEEK)); + i_SV_accuracy = static_cast(read_navigation_unsigned(subframe_bits, SV_ACCURACY)); // (20.3.3.3.1.3) + i_SV_health = static_cast(read_navigation_unsigned(subframe_bits, SV_HEALTH)); + b_L2_P_data_flag = read_navigation_bool(subframe_bits, L2_P_DATA_FLAG); // + i_code_on_L2 = static_cast(read_navigation_unsigned(subframe_bits, CA_OR_P_ON_L2)); + d_TGD = static_cast(read_navigation_signed(subframe_bits, T_GD)); + d_TGD = d_TGD * T_GD_LSB; + d_IODC = static_cast(read_navigation_unsigned(subframe_bits, IODC)); + d_Toc = static_cast(read_navigation_unsigned(subframe_bits, T_OC)); + d_Toc = d_Toc * T_OC_LSB; + d_A_f0 = static_cast(read_navigation_signed(subframe_bits, A_F0)); + d_A_f0 = d_A_f0 * A_F0_LSB; + d_A_f1 = static_cast(read_navigation_signed(subframe_bits, A_F1)); + d_A_f1 = d_A_f1 * A_F1_LSB; + d_A_f2 = static_cast(read_navigation_signed(subframe_bits, A_F2)); + d_A_f2 = d_A_f2 * A_F2_LSB; break; - case 2: //--- It is subframe 2 ------------------- - d_TOW_SF2 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); - d_TOW_SF2 = d_TOW_SF2 * 6.0; - d_TOW = d_TOW_SF2; // Set transmission time - b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); - b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); - b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - d_IODE_SF2 = static_cast(read_navigation_unsigned(subframe_bits, IODE_SF2)); - d_Crs = static_cast(read_navigation_signed(subframe_bits, C_RS)); - d_Crs = d_Crs * C_RS_LSB; - d_Delta_n = static_cast(read_navigation_signed(subframe_bits, DELTA_N)); - d_Delta_n = d_Delta_n * DELTA_N_LSB; - d_M_0 = static_cast(read_navigation_signed(subframe_bits, M_0)); - d_M_0 = d_M_0 * M_0_LSB; - d_Cuc = static_cast(read_navigation_signed(subframe_bits, C_UC)); - d_Cuc = d_Cuc * C_UC_LSB; - d_e_eccentricity = static_cast(read_navigation_unsigned(subframe_bits, E)); - d_e_eccentricity = d_e_eccentricity * E_LSB; - d_Cus = static_cast(read_navigation_signed(subframe_bits, C_US)); - d_Cus = d_Cus * C_US_LSB; - d_sqrt_A = static_cast(read_navigation_unsigned(subframe_bits, SQRT_A)); - d_sqrt_A = d_sqrt_A * SQRT_A_LSB; - d_Toe = static_cast(read_navigation_unsigned(subframe_bits, T_OE)); - d_Toe = d_Toe * T_OE_LSB; - b_fit_interval_flag = read_navigation_bool(subframe_bits, FIT_INTERVAL_FLAG); - i_AODO = static_cast(read_navigation_unsigned(subframe_bits, AODO)); - i_AODO = i_AODO * AODO_LSB; - + case 2: //--- It is subframe 2 ------------------- + d_TOW_SF2 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); + d_TOW_SF2 = d_TOW_SF2 * 6; + d_TOW = d_TOW_SF2; // Set transmission time + b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); + b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); + b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); + d_IODE_SF2 = static_cast(read_navigation_unsigned(subframe_bits, IODE_SF2)); + d_Crs = static_cast(read_navigation_signed(subframe_bits, C_RS)); + d_Crs = d_Crs * C_RS_LSB; + d_Delta_n = static_cast(read_navigation_signed(subframe_bits, DELTA_N)); + d_Delta_n = d_Delta_n * DELTA_N_LSB; + d_M_0 = static_cast(read_navigation_signed(subframe_bits, M_0)); + d_M_0 = d_M_0 * M_0_LSB; + d_Cuc = static_cast(read_navigation_signed(subframe_bits, C_UC)); + d_Cuc = d_Cuc * C_UC_LSB; + d_e_eccentricity = static_cast(read_navigation_unsigned(subframe_bits, E)); + d_e_eccentricity = d_e_eccentricity * E_LSB; + d_Cus = static_cast(read_navigation_signed(subframe_bits, C_US)); + d_Cus = d_Cus * C_US_LSB; + d_sqrt_A = static_cast(read_navigation_unsigned(subframe_bits, SQRT_A)); + d_sqrt_A = d_sqrt_A * SQRT_A_LSB; + d_Toe = static_cast(read_navigation_unsigned(subframe_bits, T_OE)); + d_Toe = d_Toe * T_OE_LSB; + b_fit_interval_flag = read_navigation_bool(subframe_bits, FIT_INTERVAL_FLAG); + i_AODO = static_cast(read_navigation_unsigned(subframe_bits, AODO)); + i_AODO = i_AODO * AODO_LSB; break; - case 3: // --- It is subframe 3 ------------------------------------- - d_TOW_SF3 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); - d_TOW_SF3 = d_TOW_SF3 * 6.0; - d_TOW = d_TOW_SF3; // Set transmission time - b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); - b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); - b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - d_Cic = static_cast(read_navigation_signed(subframe_bits, C_IC)); - d_Cic = d_Cic * C_IC_LSB; - d_OMEGA0 = static_cast(read_navigation_signed(subframe_bits, OMEGA_0)); - d_OMEGA0 = d_OMEGA0 * OMEGA_0_LSB; - d_Cis = static_cast(read_navigation_signed(subframe_bits, C_IS)); - d_Cis = d_Cis * C_IS_LSB; - d_i_0 = static_cast(read_navigation_signed(subframe_bits, I_0)); - d_i_0 = d_i_0 * I_0_LSB; - d_Crc = static_cast(read_navigation_signed(subframe_bits, C_RC)); - d_Crc = d_Crc * C_RC_LSB; - d_OMEGA = static_cast(read_navigation_signed(subframe_bits, OMEGA)); - d_OMEGA = d_OMEGA * OMEGA_LSB; - d_OMEGA_DOT = static_cast(read_navigation_signed(subframe_bits, OMEGA_DOT)); - d_OMEGA_DOT = d_OMEGA_DOT * OMEGA_DOT_LSB; - d_IODE_SF3 = static_cast(read_navigation_unsigned(subframe_bits, IODE_SF3)); - d_IDOT = static_cast(read_navigation_signed(subframe_bits, I_DOT)); - d_IDOT = d_IDOT * I_DOT_LSB; - + case 3: // --- It is subframe 3 ------------------------------------- + d_TOW_SF3 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); + d_TOW_SF3 = d_TOW_SF3 * 6; + d_TOW = d_TOW_SF3; // Set transmission time + b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); + b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); + b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); + d_Cic = static_cast(read_navigation_signed(subframe_bits, C_IC)); + d_Cic = d_Cic * C_IC_LSB; + d_OMEGA0 = static_cast(read_navigation_signed(subframe_bits, OMEGA_0)); + d_OMEGA0 = d_OMEGA0 * OMEGA_0_LSB; + d_Cis = static_cast(read_navigation_signed(subframe_bits, C_IS)); + d_Cis = d_Cis * C_IS_LSB; + d_i_0 = static_cast(read_navigation_signed(subframe_bits, I_0)); + d_i_0 = d_i_0 * I_0_LSB; + d_Crc = static_cast(read_navigation_signed(subframe_bits, C_RC)); + d_Crc = d_Crc * C_RC_LSB; + d_OMEGA = static_cast(read_navigation_signed(subframe_bits, OMEGA)); + d_OMEGA = d_OMEGA * OMEGA_LSB; + d_OMEGA_DOT = static_cast(read_navigation_signed(subframe_bits, OMEGA_DOT)); + d_OMEGA_DOT = d_OMEGA_DOT * OMEGA_DOT_LSB; + d_IODE_SF3 = static_cast(read_navigation_unsigned(subframe_bits, IODE_SF3)); + d_IDOT = static_cast(read_navigation_signed(subframe_bits, I_DOT)); + d_IDOT = d_IDOT * I_DOT_LSB; break; - case 4: // --- It is subframe 4 ---------- Almanac, ionospheric model, UTC parameters, SV health (PRN: 25-32) - int SV_data_ID; - int SV_page; - d_TOW_SF4 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); - d_TOW_SF4 = d_TOW_SF4 * 6.0; - d_TOW = d_TOW_SF4; // Set transmission time - b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); - b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); - b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - SV_data_ID = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); - SV_page = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); - if (SV_page > 24 && SV_page < 33) // Page 4 (from Table 20-V. Data IDs and SV IDs in Subframes 4 and 5, IS-GPS-200H, page 110) - { - //! \TODO read almanac - if(SV_data_ID){} - } + case 4: // --- It is subframe 4 ---------- Almanac, ionospheric model, UTC parameters, SV health (PRN: 25-32) + int32_t SV_data_ID; + int32_t SV_page; + d_TOW_SF4 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); + d_TOW_SF4 = d_TOW_SF4 * 6; + d_TOW = d_TOW_SF4; // Set transmission time + b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); + b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); + b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); + SV_data_ID = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); + SV_page = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); + if (SV_page > 24 && SV_page < 33) // Page 4 (from Table 20-V. Data IDs and SV IDs in Subframes 4 and 5, IS-GPS-200H, page 110) + { + //! \TODO read almanac + if (SV_data_ID != 0) + { + } + } if (SV_page == 52) // Page 13 (from Table 20-V. Data IDs and SV IDs in Subframes 4 and 5, IS-GPS-200H, page 110) { @@ -416,13 +385,13 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) d_A1 = d_A1 * A_1_LSB; d_A0 = static_cast(read_navigation_signed(subframe_bits, A_0)); d_A0 = d_A0 * A_0_LSB; - d_t_OT = static_cast(read_navigation_unsigned(subframe_bits, T_OT)); + d_t_OT = static_cast(read_navigation_unsigned(subframe_bits, T_OT)); d_t_OT = d_t_OT * T_OT_LSB; - i_WN_T = static_cast(read_navigation_unsigned(subframe_bits, WN_T)); - d_DeltaT_LS = static_cast(read_navigation_signed(subframe_bits, DELTAT_LS)); - i_WN_LSF = static_cast(read_navigation_unsigned(subframe_bits, WN_LSF)); - i_DN = static_cast(read_navigation_unsigned(subframe_bits, DN)); // Right-justified ? - d_DeltaT_LSF = static_cast(read_navigation_signed(subframe_bits, DELTAT_LSF)); + i_WN_T = static_cast(read_navigation_unsigned(subframe_bits, WN_T)); + d_DeltaT_LS = static_cast(read_navigation_signed(subframe_bits, DELTAT_LS)); + i_WN_LSF = static_cast(read_navigation_unsigned(subframe_bits, WN_LSF)); + i_DN = static_cast(read_navigation_unsigned(subframe_bits, DN)); // Right-justified ? + d_DeltaT_LSF = static_cast(read_navigation_signed(subframe_bits, DELTAT_LSF)); flag_iono_valid = true; flag_utc_model_valid = true; } @@ -435,65 +404,66 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) { // Page 25 Anti-Spoofing, SV config and almanac health (PRN: 25-32) //! \TODO Read Anti-Spoofing, SV config - almanacHealth[25] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV25)); - almanacHealth[26] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV26)); - almanacHealth[27] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV27)); - almanacHealth[28] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV28)); - almanacHealth[29] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV29)); - almanacHealth[30] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV30)); - almanacHealth[31] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV31)); - almanacHealth[32] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV32)); + almanacHealth[25] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV25)); + almanacHealth[26] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV26)); + almanacHealth[27] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV27)); + almanacHealth[28] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV28)); + almanacHealth[29] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV29)); + almanacHealth[30] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV30)); + almanacHealth[31] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV31)); + almanacHealth[32] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV32)); } - break; - case 5://--- It is subframe 5 -----------------almanac health (PRN: 1-24) and Almanac reference week number and time. - int SV_data_ID_5; - int SV_page_5; - d_TOW_SF5 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); - d_TOW_SF5 = d_TOW_SF5 * 6.0; - d_TOW = d_TOW_SF5; // Set transmission time - b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); - b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); - b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - SV_data_ID_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); - SV_page_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); - if (SV_page_5 < 25) - { - //! \TODO read almanac - if(SV_data_ID_5){} - } - if (SV_page_5 == 51) // Page 25 (from Table 20-V. Data IDs and SV IDs in Subframes 4 and 5, IS-GPS-200H, page 110) - { - d_Toa = static_cast(read_navigation_unsigned(subframe_bits, T_OA)); - d_Toa = d_Toa * T_OA_LSB; - i_WN_A = static_cast(read_navigation_unsigned(subframe_bits, WN_A)); - almanacHealth[1] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV1)); - almanacHealth[2] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV2)); - almanacHealth[3] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV3)); - almanacHealth[4] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV4)); - almanacHealth[5] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV5)); - almanacHealth[6] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV6)); - almanacHealth[7] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV7)); - almanacHealth[8] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV8)); - almanacHealth[9] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV9)); - almanacHealth[10] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV10)); - almanacHealth[11] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV11)); - almanacHealth[12] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV12)); - almanacHealth[13] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV13)); - almanacHealth[14] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV14)); - almanacHealth[15] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV15)); - almanacHealth[16] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV16)); - almanacHealth[17] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV17)); - almanacHealth[18] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV18)); - almanacHealth[19] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV19)); - almanacHealth[20] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV20)); - almanacHealth[21] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV21)); - almanacHealth[22] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV22)); - almanacHealth[23] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV23)); - almanacHealth[24] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV24)); - } - break; + case 5: //--- It is subframe 5 -----------------almanac health (PRN: 1-24) and Almanac reference week number and time. + int32_t SV_data_ID_5; + int32_t SV_page_5; + d_TOW_SF5 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); + d_TOW_SF5 = d_TOW_SF5 * 6; + d_TOW = d_TOW_SF5; // Set transmission time + b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); + b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); + b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); + SV_data_ID_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); + SV_page_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); + if (SV_page_5 < 25) + { + //! \TODO read almanac + if (SV_data_ID_5 != 0) + { + } + } + if (SV_page_5 == 51) // Page 25 (from Table 20-V. Data IDs and SV IDs in Subframes 4 and 5, IS-GPS-200H, page 110) + { + i_Toa = static_cast(read_navigation_unsigned(subframe_bits, T_OA)); + i_Toa = i_Toa * T_OA_LSB; + i_WN_A = static_cast(read_navigation_unsigned(subframe_bits, WN_A)); + almanacHealth[1] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV1)); + almanacHealth[2] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV2)); + almanacHealth[3] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV3)); + almanacHealth[4] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV4)); + almanacHealth[5] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV5)); + almanacHealth[6] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV6)); + almanacHealth[7] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV7)); + almanacHealth[8] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV8)); + almanacHealth[9] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV9)); + almanacHealth[10] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV10)); + almanacHealth[11] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV11)); + almanacHealth[12] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV12)); + almanacHealth[13] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV13)); + almanacHealth[14] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV14)); + almanacHealth[15] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV15)); + almanacHealth[16] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV16)); + almanacHealth[17] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV17)); + almanacHealth[18] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV18)); + almanacHealth[19] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV19)); + almanacHealth[20] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV20)); + almanacHealth[21] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV21)); + almanacHealth[22] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV22)); + almanacHealth[23] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV23)); + almanacHealth[24] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV24)); + } + break; default: break; @@ -510,12 +480,12 @@ double Gps_Navigation_Message::utc_time(const double gpstime_corrected) const double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast((i_GPS_week - i_WN_T))); // Determine if the effectivity time of the leap second event is in the past - int weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; if ((weeksToLeapSecondEvent) >= 0) // is not in the past { //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; if (weeksToLeapSecondEvent > 0) { t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); @@ -541,7 +511,7 @@ double Gps_Navigation_Message::utc_time(const double gpstime_corrected) const * proper accommodation of the leap second event with a possible week number * transition is provided by the following expression for UTC: */ - int W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + int32_t W = static_cast(fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400)) + 43200; t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); //implement something to handle a leap second event! } @@ -635,7 +605,7 @@ Gps_Iono Gps_Navigation_Message::get_iono() iono.d_beta2 = d_beta2; iono.d_beta3 = d_beta3; iono.valid = flag_iono_valid; - //WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue + // WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue flag_iono_valid = false; return iono; } diff --git a/src/core/system_parameters/gps_navigation_message.h b/src/core/system_parameters/gps_navigation_message.h index ba3312efa..1e79a02c9 100644 --- a/src/core/system_parameters/gps_navigation_message.h +++ b/src/core/system_parameters/gps_navigation_message.h @@ -34,11 +34,12 @@ #include "GPS_L1_CA.h" +#include "gps_almanac.h" #include "gps_ephemeris.h" #include "gps_iono.h" -#include "gps_almanac.h" #include "gps_utc_model.h" #include +#include #include #include #include @@ -53,70 +54,66 @@ class Gps_Navigation_Message { private: - unsigned long int read_navigation_unsigned(std::bitset bits, const std::vector> parameter); - signed long int read_navigation_signed(std::bitset bits, const std::vector> parameter); - bool read_navigation_bool(std::bitset bits, const std::vector> parameter); - void print_gps_word_bytes(unsigned int GPS_word); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector>& parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector>& parameter); + bool read_navigation_bool(std::bitset bits, const std::vector>& parameter); + void print_gps_word_bytes(uint32_t GPS_word); public: bool b_valid_ephemeris_set_flag; // flag indicating that this ephemeris set have passed the validation check - //broadcast orbit 1 - double d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] - double d_TOW_SF1; //!< Time of GPS Week from HOW word of Subframe 1 [s] - double d_TOW_SF2; //!< Time of GPS Week from HOW word of Subframe 2 [s] - double d_TOW_SF3; //!< Time of GPS Week from HOW word of Subframe 3 [s] - double d_TOW_SF4; //!< Time of GPS Week from HOW word of Subframe 4 [s] - double d_TOW_SF5; //!< Time of GPS Week from HOW word of Subframe 5 [s] - - double d_IODE_SF2; - double d_IODE_SF3; + // broadcast orbit 1 + int32_t d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] + int32_t d_TOW_SF1; //!< Time of GPS Week from HOW word of Subframe 1 [s] + int32_t d_TOW_SF2; //!< Time of GPS Week from HOW word of Subframe 2 [s] + int32_t d_TOW_SF3; //!< Time of GPS Week from HOW word of Subframe 3 [s] + int32_t d_TOW_SF4; //!< Time of GPS Week from HOW word of Subframe 4 [s] + int32_t d_TOW_SF5; //!< Time of GPS Week from HOW word of Subframe 5 [s] + int32_t d_IODE_SF2; + int32_t d_IODE_SF3; double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] - //broadcast orbit 2 + // broadcast orbit 2 double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] double d_e_eccentricity; //!< Eccentricity [dimensionless] double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] - //broadcast orbit 3 - double d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] - double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + // broadcast orbit 3 + int32_t d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + int32_t d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] double d_Cis; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] - //broadcast orbit 4 + // broadcast orbit 4 double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] double d_Crc; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] double d_OMEGA; //!< Argument of Perigee [semi-cicles] double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] - //broadcast orbit 5 + // broadcast orbit 5 double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] - int i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; - int i_GPS_week; //!< GPS week number, aka WN [week] + int32_t i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; + int32_t i_GPS_week; //!< GPS week number, aka WN [week] bool b_L2_P_data_flag; //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel - //broadcast orbit 6 - int i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) - int i_SV_health; - double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] - double d_IODC; //!< Issue of Data, Clock - //broadcast orbit 7 - int i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] - + // broadcast orbit 6 + int32_t i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) + int32_t i_SV_health; + double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + int32_t d_IODC; //!< Issue of Data, Clock + // broadcast orbit 7 + int32_t i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] bool b_fit_interval_flag; //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. double d_spare1; double d_spare2; - double d_A_f0; //!< Coefficient 0 of code phase offset model [s] double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] double d_A_f2; //!< Coefficient 2 of code phase offset model [s/s^2] - // Almanac - double d_Toa; //!< Almanac reference time [s] - int i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced - std::map almanacHealth; //!< Map that stores the health information stored in the almanac + int32_t i_Toa; //!< Almanac reference time [s] + int32_t i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (i_Toa) is referenced + std::map almanacHealth; //!< Map that stores the health information stored in the almanac - std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus // Flags @@ -146,11 +143,11 @@ public: double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). // satellite identification info - int i_channel_ID; - unsigned int i_satellite_PRN; + int32_t i_channel_ID; + uint32_t i_satellite_PRN; // time synchro - double d_subframe_timestamp_ms; //[ms] + double d_subframe_timestamp_ms; // [ms] // Ionospheric parameters bool flag_iono_valid; //!< If set, it indicates that the ionospheric parameters are filled (page 18 has arrived and decoded) @@ -165,14 +162,15 @@ public: // UTC parameters bool flag_utc_model_valid; //!< If set, it indicates that the UTC model parameters are filled - double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] - double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s] - int i_WN_T; //!< UTC reference week number [weeks] - double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] - double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] + double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] + double d_A2; //!< 2nd order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] + int32_t d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s] + int32_t i_WN_T; //!< UTC reference week number [weeks] + int32_t d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] // Satellite velocity double d_satvel_X; //!< Earth-fixed velocity coordinate x of the satellite [m] @@ -201,7 +199,7 @@ public: /*! * \brief Decodes the GPS NAV message */ - int subframe_decoder(char *subframe); + int32_t subframe_decoder(char* subframe); /*! * \brief Computes the Coordinated Universal Time (UTC) and diff --git a/src/core/system_parameters/gps_utc_model.cc b/src/core/system_parameters/gps_utc_model.cc index ffe1af6f5..5641186b4 100644 --- a/src/core/system_parameters/gps_utc_model.cc +++ b/src/core/system_parameters/gps_utc_model.cc @@ -35,8 +35,9 @@ Gps_Utc_Model::Gps_Utc_Model() { valid = false; - d_A1 = 0; - d_A0 = 0; + d_A0 = 0.0; + d_A1 = 0.0; + d_A2 = 0.0; d_t_OT = 0; i_WN_T = 0; d_DeltaT_LS = 0; @@ -45,24 +46,25 @@ Gps_Utc_Model::Gps_Utc_Model() d_DeltaT_LSF = 0; } -double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) + +double Gps_Utc_Model::utc_time(double gpstime_corrected, int32_t i_GPS_week) { double t_utc; double t_utc_daytime; double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); // Determine if the effectivity time of the leap second event is in the past - int weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; if (weeksToLeapSecondEvent >= 0) // is not in the past { - //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; if (weeksToLeapSecondEvent > 0) { t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); } - else //we are in the same week than the leap second event + else // we are in the same week than the leap second event { if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) { @@ -83,9 +85,9 @@ double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) * proper accommodation of the leap second event with a possible week number * transition is provided by the following expression for UTC: */ - int W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + int32_t W = static_cast(fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400)) + 43200; t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); - //implement something to handle a leap second event! + // implement something to handle a leap second event! } if ((gpstime_corrected - secondOfLeapSecondEvent) > 21600) { diff --git a/src/core/system_parameters/gps_utc_model.h b/src/core/system_parameters/gps_utc_model.h index ede2c1e67..43283d30d 100644 --- a/src/core/system_parameters/gps_utc_model.h +++ b/src/core/system_parameters/gps_utc_model.h @@ -32,9 +32,8 @@ #ifndef GNSS_SDR_GPS_UTC_MODEL_H_ #define GNSS_SDR_GPS_UTC_MODEL_H_ -#include #include - +#include /*! * \brief This class is a storage for the GPS UTC MODEL data as described in IS-GPS-200E @@ -46,14 +45,15 @@ class Gps_Utc_Model public: bool valid; // UTC parameters - double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] - double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] - double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s] - int i_WN_T; //!< UTC reference week number [weeks] - double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] - double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] + double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] + double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] + double d_A2; //!< 2nd order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] + int32_t d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s] + int32_t i_WN_T; //!< UTC reference week number [weeks] + int32_t d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] /*! * Default constructor @@ -64,7 +64,7 @@ public: /* * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) @@ -85,7 +85,7 @@ public: * \brief Computes the Coordinated Universal Time (UTC) and * returns it in [s] (IS-GPS-200E, 20.3.3.5.2.4) */ - double utc_time(double gpstime_corrected, int i_GPS_week); + double utc_time(double gpstime_corrected, int32_t i_GPS_week); }; #endif diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index b97a62458..ad785f0f0 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,107 +17,85 @@ # -set(GNSS_SDR_OPTIONAL_LIBS "") -set(GNSS_SDR_OPTIONAL_HEADERS "") +add_executable(gnss-sdr ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) + +target_link_libraries(gnss-sdr + PUBLIC + Boost::filesystem + Boost::system + Gflags::gflags + Glog::glog + Threads::Threads + core_receiver + gnss_sdr_flags +) + +target_compile_definitions(gnss-sdr PRIVATE -DGNSS_SDR_VERSION="${VERSION}") + +# Disable internal logging +if(NOT ENABLE_LOG) + target_compile_definitions(gnss-sdr PUBLIC -DGOOGLE_STRIP_LOG=1) +endif() + +if(ENABLE_CUDA) + target_link_libraries(gnss-sdr + PUBLIC + ${CUDA_LIBRARIES} + ) + target_include_directories(gnss-sdr + PUBLIC + ${CUDA_INCLUDE_DIRS} + ) + target_compile_definitions(gnss-sdr PRIVATE -DCUDA_GPU_ACCEL=1) +endif() if(ENABLE_GPERFTOOLS) if(GPERFTOOLS_FOUND) - #set(GNSS_SDR_OPTIONAL_LIBS "${GNSS_SDR_OPTIONAL_LIBS};${GPERFTOOLS_LIBRARIES}") - set(GNSS_SDR_OPTIONAL_LIBS "${GNSS_SDR_OPTIONAL_LIBS};${GPERFTOOLS_PROFILER};${GPERFTOOLS_TCMALLOC}") - set(GNSS_SDR_OPTIONAL_HEADERS "${GNSS_SDR_OPTIONAL_HEADERS};${GPERFTOOLS_INCLUDE_DIR}") - endif(GPERFTOOLS_FOUND) -endif(ENABLE_GPERFTOOLS) - -if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) - set(GNSS_SDR_OPTIONAL_LIBS ${GNSS_SDR_OPTIONAL_LIBS} ${UHD_LIBRARIES} ${GNURADIO_UHD_LIBRARIES}) - set(GNSS_SDR_OPTIONAL_HEADERS ${GNSS_SDR_OPTIONAL_HEADERS} ${UHD_INCLUDE_DIRS}) -endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) - -if(OPENSSL_FOUND) - add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) -endif(OPENSSL_FOUND) - -if(ENABLE_CUDA) - add_definitions(-DCUDA_GPU_ACCEL=1) - set(GNSS_SDR_OPTIONAL_LIBS ${GNSS_SDR_OPTIONAL_LIBS} ${CUDA_LIBRARIES}) - set(GNSS_SDR_OPTIONAL_HEADERS ${GNSS_SDR_OPTIONAL_HEADERS} ${CUDA_INCLUDE_DIRS}) -endif(ENABLE_CUDA) - -if(ORC_FOUND) - set(GNSS_SDR_OPTIONAL_LIBS ${GNSS_SDR_OPTIONAL_LIBS} ${ORC_LIBRARIES}) - set(GNSS_SDR_OPTIONAL_HEADERS ${GNSS_SDR_OPTIONAL_HEADERS} ${ORC_INCLUDE_DIRS}) -endif(ORC_FOUND) - - -include_directories( - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/core/libs - ${CMAKE_SOURCE_DIR}/src/core/libs/supl - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${ARMADILLO_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${GNSS_SDR_OPTIONAL_HEADERS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} - ${OPT_GNSSSDR_INCLUDE_DIRS} -) - -add_definitions( -DGNSS_SDR_VERSION="${VERSION}" ) + target_link_libraries(gnss-sdr + PUBLIC + Gperftools::profiler + Gperftools::tcmalloc + ) + endif() +endif() if(OS_IS_MACOSX) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(MAC_LIBRARIES "-framework Accelerate -lc++") - endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") -endif(OS_IS_MACOSX) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_link_libraries(gnss-sdr + PUBLIC + "-lc++" + ) + endif() +endif() +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(gnss-sdr + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() -add_executable(gnss-sdr ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) - -add_custom_command(TARGET gnss-sdr POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$ - ) - -target_link_libraries(gnss-sdr ${MAC_LIBRARIES} - ${Boost_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FFT_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${ARMADILLO_LIBRARIES} - ${VOLK_GNSSSDR_LIBRARIES} - ${GNSS_SDR_OPTIONAL_LIBS} - gnss_sp_libs - gnss_sdr_flags - gnss_rx - ) - +add_custom_command(TARGET gnss-sdr + POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$ +) install(TARGETS gnss-sdr - RUNTIME DESTINATION bin - COMPONENT "gnss-sdr" - ) + RUNTIME DESTINATION bin + COMPONENT "gnss-sdr") install(DIRECTORY ${CMAKE_SOURCE_DIR}/conf DESTINATION share/gnss-sdr - FILES_MATCHING PATTERN "*.conf" - ) + FILES_MATCHING PATTERN "*.conf") install(FILES ${CMAKE_SOURCE_DIR}/conf/gnss-sdr.conf DESTINATION share/gnss-sdr/conf - RENAME default.conf) + RENAME default.conf) -if(NOT VOLK_GNSSSDR_FOUND) +if(NOT VOLKGNSSSDR_FOUND) install(PROGRAMS ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/build/apps/volk_gnsssdr_profile DESTINATION bin COMPONENT "volk_gnsssdr") install(PROGRAMS ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/build/apps/volk_gnsssdr-config-info DESTINATION bin COMPONENT "volk_gnsssdr") -endif(NOT VOLK_GNSSSDR_FOUND) - +endif() find_program(GZIP gzip @@ -127,24 +105,24 @@ find_program(GZIP /opt/local/bin /sbin ) + if(NOT GZIP_NOTFOUND) execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/docs/manpage/gnss-sdr-manpage - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/gnss-sdr.1.gz") + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/gnss-sdr.1.gz") install(FILES ${CMAKE_BINARY_DIR}/gnss-sdr.1.gz DESTINATION share/man/man1) execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/docs/changelog - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/changelog.gz") + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/changelog.gz") install(FILES ${CMAKE_BINARY_DIR}/changelog.gz DESTINATION share/doc/gnss-sdr) - if(NOT VOLK_GNSSSDR_FOUND) - execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/volk_gnsssdr_profile.1.gz") - execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/volk_gnsssdr-config-info.1.gz") - - install(FILES ${CMAKE_BINARY_DIR}/volk_gnsssdr_profile.1.gz DESTINATION share/man/man1) - install(FILES ${CMAKE_BINARY_DIR}/volk_gnsssdr-config-info.1.gz DESTINATION share/man/man1) - endif(NOT VOLK_GNSSSDR_FOUND) -endif(NOT GZIP_NOTFOUND) + if(NOT VOLKGNSSSDR_FOUND) + execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/volk_gnsssdr_profile.1.gz") + execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/volk_gnsssdr-config-info.1.gz") + install(FILES ${CMAKE_BINARY_DIR}/volk_gnsssdr_profile.1.gz DESTINATION share/man/man1) + install(FILES ${CMAKE_BINARY_DIR}/volk_gnsssdr-config-info.1.gz DESTINATION share/man/man1) + endif() +endif() diff --git a/src/main/main.cc b/src/main/main.cc index d64f9bab6..67e0881f5 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -8,7 +8,7 @@ * * ------------------------------------------------------------------------- * -* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -32,7 +32,7 @@ */ #ifndef GNSS_SDR_VERSION -#define GNSS_SDR_VERSION "0.0.9" +#define GNSS_SDR_VERSION "0.0.10" #endif #ifndef GOOGLE_STRIP_LOG @@ -43,16 +43,19 @@ #include "concurrent_queue.h" #include "control_thread.h" #include "gnss_sdr_flags.h" +#include "gps_acq_assist.h" #include -#include -#include // for create_directories, exists -#include // for path, operator<< -#include // for filesystem +#include // for exception +#include // for create_directories, exists +#include // for path, operator<< +#include // for error_code +#include #include #include +#include #include #include - +#include #if CUDA_GPU_ACCEL // For the CUDA runtime routines (prefixed with "cuda_") @@ -69,14 +72,14 @@ using google::LogMessage; */ // For GPS NAVIGATION (L1) -concurrent_queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; +Concurrent_Queue global_gps_acq_assist_queue; +Concurrent_Map global_gps_acq_assist_map; int main(int argc, char** argv) { const std::string intro_help( std::string("\nGNSS-SDR is an Open Source GNSS Software Defined Receiver\n") + - "Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)\n" + + "Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)\n" + "This program comes with ABSOLUTELY NO WARRANTY;\n" + "See COPYING file to see a copy of the General Public License\n \n"); @@ -129,15 +132,21 @@ int main(int argc, char** argv) } } - std::unique_ptr control_thread(new ControlThread()); - - // record startup time std::chrono::time_point start, end; start = std::chrono::system_clock::now(); - + int return_code = 0; try { - control_thread->run(); + std::unique_ptr control_thread(new ControlThread()); + // record startup time + start = std::chrono::system_clock::now(); + return_code = control_thread->run(); + } + catch (const boost::thread_resource_error& e) + { + std::cout << "Failed to create boost thread." << std::endl; + google::ShutDownCommandLineFlags(); + return 1; } catch (const boost::exception& e) { @@ -189,5 +198,5 @@ int main(int argc, char** argv) google::ShutDownCommandLineFlags(); std::cout << "GNSS-SDR program ended." << std::endl; - return 0; + return return_code; } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index f2b14aa0f..c6e4ab268 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -18,335 +18,324 @@ add_subdirectory(unit-tests/signal-processing-blocks/libs) +add_subdirectory(system-tests/libs) ################################################################################ # Google Test - https://github.com/google/googletest ################################################################################ if(EXISTS $ENV{GTEST_DIR}) - set(GTEST_DIR_LOCAL $ENV{GTEST_DIR}) -endif(EXISTS $ENV{GTEST_DIR}) + set(GTEST_DIR_LOCAL $ENV{GTEST_DIR}) +endif() if(GTEST_DIR) set(GTEST_DIR_LOCAL ${GTEST_DIR}) -endif(GTEST_DIR) +endif() if(NOT GTEST_DIR_LOCAL) set(GTEST_DIR_LOCAL false) else() set(GTEST_DIR_LOCAL true) -endif(NOT GTEST_DIR_LOCAL) +endif() if(GTEST_INCLUDE_DIRS) set(GTEST_DIR_LOCAL true) -endif(GTEST_INCLUDE_DIRS) +endif() set(GTEST_COMPILER -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}) set(TOOLCHAIN_ARG "") if(EXISTS $ENV{OECORE_TARGET_SYSROOT}) set(GTEST_COMPILER "") set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Toolchains/oe-sdk_cross.cmake") -endif(EXISTS $ENV{OECORE_TARGET_SYSROOT}) +else() + if(ENABLE_PACKAGING) + set(TOOLCHAIN_ARG "-DCMAKE_VERBOSE_MAKEFILE=ON") + endif() +endif() if(NOT ${GTEST_DIR_LOCAL}) - # if GTEST_DIR is not defined, we download and build it - if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - gtest-${GNSSSDR_GTEST_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/google/googletest - GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION} - CMAKE_ARGS ${GTEST_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF ${TOOLCHAIN_ARG} - UPDATE_COMMAND "" - PATCH_COMMAND "" - INSTALL_COMMAND "" - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - gtest-${GNSSSDR_GTEST_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/google/googletest - GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION} - CMAKE_ARGS ${GTEST_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF ${TOOLCHAIN_ARG} - UPDATE_COMMAND "" - PATCH_COMMAND "" - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} - INSTALL_COMMAND "" - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) + # if GTEST_DIR is not defined, we download and build it + if(CMAKE_BUILD_TYPE MATCHES Debug) + set(DEBUG_POSTFIX "d") + endif() + if(OS_IS_MACOSX) + if(CMAKE_GENERATOR STREQUAL Xcode) + set(DEBUG_PREFIX "Debug/") + set(DEBUG_POSTFIX "d") + endif() + endif() - # Set up variables - # Set recently downloaded and build Googletest root folder - set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest") - # Source code - ExternalProject_Get_Property(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} source_dir) - set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include) - set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) - # Library - ExternalProject_Get_Property(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} binary_dir) - if(OS_IS_MACOSX) - if(CMAKE_GENERATOR STREQUAL Xcode) - set(binary_dir "${binary_dir}/Debug") - endif(CMAKE_GENERATOR STREQUAL Xcode) - endif(OS_IS_MACOSX) - set(GTEST_LIBRARY_PATH "${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX};${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}") - set(GTEST_LIBRARY gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) - set(GTEST_LIBRARIES - ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} - ) - set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest") -else(NOT ${GTEST_DIR_LOCAL}) - if(GTEST_INCLUDE_DIRS) - set(GTEST_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} ${LIBGTEST_DEV_DIR}) - add_library(gtest ${LIBGTEST_DEV_DIR}/src/gtest-all.cc ${LIBGTEST_DEV_DIR}/src/gtest_main.cc) - set(GTEST_LIBRARIES gtest) - else(GTEST_INCLUDE_DIRS) - # If the variable GTEST_DIR is defined, we use the existing Googletest - set(GTEST_DIR $ENV{GTEST_DIR}) - set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) - add_library(gtest ${GTEST_DIR}/src/gtest-all.cc ${GTEST_DIR}/src/gtest_main.cc) - set(GTEST_LIBRARIES gtest) - endif(GTEST_INCLUDE_DIRS) -endif(NOT ${GTEST_DIR_LOCAL}) + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add( + gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/google/googletest + GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + CMAKE_ARGS ${GTEST_COMPILER} -DINSTALL_GTEST=OFF -DBUILD_GMOCK=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -Dgtest_hide_internal_symbols=ON ${TOOLCHAIN_ARG} + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + ) + else() + ExternalProject_Add( + gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/google/googletest + GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + CMAKE_ARGS ${GTEST_COMPILER} -DINSTALL_GTEST=OFF -DBUILD_GMOCK=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -Dgtest_hide_internal_symbols=ON ${TOOLCHAIN_ARG} + UPDATE_COMMAND "" + PATCH_COMMAND "" + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + INSTALL_COMMAND "" + ) + endif() + ExternalProject_Get_Property(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} binary_dir) + + if(NOT TARGET GTest::GTest) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/include) + add_library(GTest::GTest STATIC IMPORTED) + add_dependencies(GTest::GTest gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) + set_target_properties(GTest::GTest PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${binary_dir}/googletest/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_POSTFIX}${CMAKE_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/include" + INTERFACE_LINK_LIBRARIES "${binary_dir}/googletest/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_POSTFIX}${CMAKE_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + set_target_properties(GTest::GTest PROPERTIES + INTERFACE_LINK_LIBRARIES Threads::Threads + ) + endif() + if(NOT TARGET GTest::Main) + add_library(GTest::Main STATIC IMPORTED) + add_dependencies(GTest::Main gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) + set_target_properties(GTest::Main PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${binary_dir}/googletest/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/include" + INTERFACE_LINK_LIBRARIES "${binary_dir}/googletest/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() +else() + if(GTEST_INCLUDE_DIRS) + set(GTEST_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} ${LIBGTEST_DEV_DIR}) + add_library(gtest STATIC ${LIBGTEST_DEV_DIR}/src/gtest-all.cc) + target_include_directories(gtest + PUBLIC + ${GTEST_INCLUDE_DIRECTORIES} + ) + add_library(gtest_main STATIC ${LIBGTEST_DEV_DIR}/src/gtest_main.cc) + target_include_directories(gtest_main + PUBLIC + ${GTEST_INCLUDE_DIRECTORIES} + ) + if(NOT TARGET GTest::GTest) + add_library(GTest::GTest STATIC IMPORTED) + add_dependencies(GTest::GTest gtest) + set_target_properties(GTest::GTest PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + set_target_properties(GTest::GTest PROPERTIES + INTERFACE_LINK_LIBRARIES Threads::Threads + ) + endif() + if(NOT TARGET GTest::Main) + add_library(GTest::Main STATIC IMPORTED) + add_dependencies(GTest::Main gtest_main) + set_target_properties(GTest::Main PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${DEBUG_PREFIX}${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() + endif() +endif() ################################################################################ -# Optional libraries +# Definitions ################################################################################ -set(GNSS_SDR_TEST_OPTIONAL_LIBS "") -set(GNSS_SDR_TEST_OPTIONAL_HEADERS "") -if(ENABLE_CUDA) - set(GNSS_SDR_TEST_OPTIONAL_HEADERS ${GNSS_SDR_TEST_OPTIONAL_HEADERS} ${CUDA_INCLUDE_DIRS}) - set(GNSS_SDR_TEST_OPTIONAL_LIBS ${GNSS_SDR_TEST_OPTIONAL_LIBS} ${CUDA_LIBRARIES}) -endif(ENABLE_CUDA) - -if(ENABLE_GPERFTOOLS) - if(GPERFTOOLS_FOUND) - set(GNSS_SDR_TEST_OPTIONAL_LIBS "${GNSS_SDR_TEST_OPTIONAL_LIBS};${GPERFTOOLS_LIBRARIES}") - set(GNSS_SDR_TEST_OPTIONAL_HEADERS "${GNSS_SDR_TEST_OPTIONAL_HEADERS};${GPERFTOOLS_INCLUDE_DIR}") - endif(GPERFTOOLS_FOUND) -endif(ENABLE_GPERFTOOLS) - -if(Boost_VERSION LESS 105000) - add_definitions(-DOLD_BOOST=1) -endif(Boost_VERSION LESS 105000) +if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13.4") + add_definitions(-DGR_GREATER_38=1) +endif() if(OPENSSL_FOUND) - add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) -endif(OPENSSL_FOUND) - -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if(OS_IS_MACOSX) - set(CLANG_FLAGS "-stdlib=libc++ -lc++") - endif(OS_IS_MACOSX) -endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_definitions(-DUSE_OPENSSL_FALLBACK=1) +endif() if(OPENCL_FOUND) add_definitions(-DOPENCL_BLOCKS_TEST=1) -endif(OPENCL_FOUND) +endif() if(ENABLE_CUDA) add_definitions(-DCUDA_BLOCKS_TEST=1) -endif(ENABLE_CUDA) +endif() if(ENABLE_FPGA) add_definitions(-DFPGA_BLOCKS_TEST=1) -endif(ENABLE_FPGA) +endif() find_package(Gnuplot) if(GNUPLOT_FOUND) add_definitions(-DGNUPLOT_EXECUTABLE="${GNUPLOT_EXECUTABLE}") -endif(GNUPLOT_FOUND) +endif() -if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) - add_definitions( -DGR_GREATER_38=1 ) -endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) +if(ENABLE_UNIT_TESTING_MINIMAL) + add_definitions(-DUNIT_TESTING_MINIMAL=1) +endif() ################################################################################ # Optional generator ################################################################################ +option(ENABLE_GNSS_SIM_INSTALL "Enable the installation of gnss_sim on the fly" ON) if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) - if(ENABLE_FPGA) + if(ENABLE_FPGA) set(CROSS_INSTALL_DIR "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") if(EXISTS $ENV{OECORE_TARGET_SYSROOT}) set(CROSS_INSTALL_DIR "${CROSS_INSTALL_DIR} -DBOOST_ROOT=$ENV{OECORE_TARGET_SYSROOT}/usr") - endif(EXISTS $ENV{OECORE_TARGET_SYSROOT}) - else(ENABLE_FPGA) + endif() + else() set(CROSS_INSTALL_DIR "") - endif(ENABLE_FPGA) - ExternalProject_Add( - gnss-sim - GIT_REPOSITORY https://bitbucket.org/jarribas/gnss-simulator - GIT_TAG ${GNSSSDR_GNSS_SIM_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gnss-sim - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim - CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} ${CROSS_INSTALL_DIR} - UPDATE_COMMAND "" - PATCH_COMMAND "" - INSTALL_COMMAND "" - ) - if(ENABLE_INSTALL_TESTS) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim/gnss_sim DESTINATION bin) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/brdc3540.14n DESTINATION share/gnss-sim) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/circle.csv DESTINATION share/gnss-sim) - set(SW_GENERATOR_BIN ${CMAKE_INSTALL_PREFIX}/bin/gnss_sim) + endif() + find_package(GNSSSIMULATOR QUIET) + if(GNSSSIMULATOR_FOUND OR NOT ENABLE_GNSS_SIM_INSTALL) add_definitions(-DSW_GENERATOR_BIN="${SW_GENERATOR_BIN}") add_definitions(-DDEFAULT_RINEX_NAV="${CMAKE_INSTALL_PREFIX}/share/gnss-sim/brdc3540.14n") add_definitions(-DDEFAULT_POSITION_FILE="${CMAKE_INSTALL_PREFIX}/share/gnss-sim/circle.csv") - else(ENABLE_INSTALL_TESTS) - set(SW_GENERATOR_BIN ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim/gnss_sim) - add_definitions(-DSW_GENERATOR_BIN="${SW_GENERATOR_BIN}") - add_definitions(-DDEFAULT_RINEX_NAV="${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/brdc3540.14n") - add_definitions(-DDEFAULT_POSITION_FILE="${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/circle.csv") - endif(ENABLE_INSTALL_TESTS) + else() + ExternalProject_Add( + gnss-sim + GIT_REPOSITORY https://bitbucket.org/jarribas/gnss-simulator + GIT_TAG ${GNSSSDR_GNSS_SIM_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gnss-sim + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim + CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} ${CROSS_INSTALL_DIR} + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + ) + if(ENABLE_INSTALL_TESTS) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim/gnss_sim DESTINATION bin) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/brdc3540.14n DESTINATION share/gnss-sim) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/circle.csv DESTINATION share/gnss-sim) + set(SW_GENERATOR_BIN ${CMAKE_INSTALL_PREFIX}/bin/gnss_sim) + add_definitions(-DSW_GENERATOR_BIN="${SW_GENERATOR_BIN}") + add_definitions(-DDEFAULT_RINEX_NAV="${CMAKE_INSTALL_PREFIX}/share/gnss-sim/brdc3540.14n") + add_definitions(-DDEFAULT_POSITION_FILE="${CMAKE_INSTALL_PREFIX}/share/gnss-sim/circle.csv") + else() + set(SW_GENERATOR_BIN ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim/gnss_sim) + add_definitions(-DSW_GENERATOR_BIN="${SW_GENERATOR_BIN}") + add_definitions(-DDEFAULT_RINEX_NAV="${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/brdc3540.14n") + add_definitions(-DDEFAULT_POSITION_FILE="${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/circle.csv") + endif() + endif() - ################################################################################ - # Local installation of GPSTk http://www.gpstk.org/ - ################################################################################ - find_package(GPSTK) - if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) - message(STATUS "GPSTk v${GNSSSDR_GPSTK_LOCAL_VERSION} will be automatically downloaded and built when doing 'make'.") - if(NOT ENABLE_FPGA) - if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/SGL-UT/GPSTk - GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} - CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF - UPDATE_COMMAND "" - PATCH_COMMAND "" - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/SGL-UT/GPSTk - GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} - CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF - BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX} - UPDATE_COMMAND "" - PATCH_COMMAND "" - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) - - set(GPSTK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include CACHE PATH "Local GPSTK headers") - add_library(gpstk UNKNOWN IMPORTED) - set_property(TARGET gpstk PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}) - add_dependencies(gpstk gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}) - set(GPSTK_BINDIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/bin/ ) - add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}") - set(gpstk_libs gpstk) - set(OWN_GPSTK True) - else(NOT ENABLE_FPGA) - message(STATUS "GPSTk has not been found, try to install it on target.") - message(STATUS "Some extra tests requiring GPSTk will not be built.") - endif(NOT ENABLE_FPGA) - else(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) - set(gpstk_libs ${GPSTK_LIBRARIES}) - set(GPSTK_INCLUDE_DIRS ${GPSTK_INCLUDE_DIR}) - set(GPSTK_BINDIR ${GPSTK_LIBRARY}/../bin/ ) - add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}") - endif(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) -endif(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) + ################################################################################ + # Local installation of GPSTk http://www.gpstk.org/ + ################################################################################ + find_package(GPSTK) + if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) + message(STATUS " GPSTk v${GNSSSDR_GPSTK_LOCAL_VERSION} will be automatically downloaded and built when doing 'make'.") + if("${TOOLCHAIN_ARG}" STREQUAL "") + set(TOOLCHAIN_ARG "-DCMAKE_CXX_FLAGS=\"-Wno-deprecated\"") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") + endif() + include(GNUInstallDirs) + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add( + gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/SGL-UT/GPSTk + GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF + UPDATE_COMMAND "" + PATCH_COMMAND "" + ) + else() + ExternalProject_Add( + gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/SGL-UT/GPSTk + GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF + BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX} + UPDATE_COMMAND "" + PATCH_COMMAND "" + ) + endif() + set(GPSTK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include CACHE PATH "Local GPSTK headers") + set(GPSTK_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(GPSTK_BINDIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/bin/) + add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}") + set(OWN_GPSTK True) + add_library(Gpstk::gpstk SHARED IMPORTED) + add_dependencies(Gpstk::gpstk gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}) + file(MAKE_DIRECTORY ${GPSTK_INCLUDE_DIRS}) + file(MAKE_DIRECTORY ${GPSTK_INCLUDE_DIRS}/gpstk) + set_target_properties(Gpstk::gpstk PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GPSTK_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${GPSTK_INCLUDE_DIRS};${GPSTK_INCLUDE_DIRS}/gpstk" + INTERFACE_LINK_LIBRARIES "${GPSTK_LIBRARY}" + ) + else() + set(GPSTK_BINDIR ${GPSTK_INCLUDE_DIR}/../bin/) + add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}") + endif() +endif() if(ENABLE_UNIT_TESTING_EXTRA) - add_definitions(-DEXTRA_TESTS) - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/gps_l2c_m_prn7_5msps.dat) + add_definitions(-DEXTRA_TESTS) + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/gps_l2c_m_prn7_5msps.dat) message(STATUS "Downloading some data files for testing...") file(DOWNLOAD https://sourceforge.net/projects/gnss-sdr/files/data/gps_l2c_m_prn7_5msps.dat ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/gps_l2c_m_prn7_5msps.dat - SHOW_PROGRESS - EXPECTED_HASH MD5=a6fcbefe155137945d3c33c5ef7bd0f9 ) - endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/gps_l2c_m_prn7_5msps.dat) - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat) + SHOW_PROGRESS + EXPECTED_HASH MD5=a6fcbefe155137945d3c33c5ef7bd0f9) + endif() + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat) message(STATUS "Downloading some data files for testing...") file(DOWNLOAD https://sourceforge.net/projects/gnss-sdr/files/data/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat - SHOW_PROGRESS - EXPECTED_HASH MD5=ffb72fc63c116be58d5e5ccb1daaed3a ) - endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat) - # if(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin) - # message(STATUS "Downloading some data files for testing...") - # file(DOWNLOAD https://sourceforge.net/projects/gnss-sdr/files/data/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin - # SHOW_PROGRESS - # EXPECTED_HASH MD5=d7055fc1dc931872b547a148af50a09b ) - # endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin) - if(ENABLE_INSTALL_TESTS) + SHOW_PROGRESS + EXPECTED_HASH MD5=ffb72fc63c116be58d5e5ccb1daaed3a) + endif() + if(ENABLE_INSTALL_TESTS) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/gps_l2c_m_prn7_5msps.dat DESTINATION share/gnss-sdr/signal_samples) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat DESTINATION share/gnss-sdr/signal_samples) - # install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin DESTINATION share/gnss-sdr/signal_samples) - endif(ENABLE_INSTALL_TESTS) -endif(ENABLE_UNIT_TESTING_EXTRA) + endif() +endif() if(ENABLE_INSTALL_TESTS) - install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GSoC_CTTC_capture_2012_07_26_4Msps_4ms.dat DESTINATION share/gnss-sdr/signal_samples) - install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat DESTINATION share/gnss-sdr/signal_samples) - install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat DESTINATION share/gnss-sdr/signal_samples) - install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/NT1065_GLONASS_L1_20160831_fs6625e6_if0e3_4ms.bin DESTINATION share/gnss-sdr/signal_samples) - add_definitions(-DTEST_PATH="${CMAKE_INSTALL_PREFIX}/share/gnss-sdr/") -else(ENABLE_INSTALL_TESTS) - file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GSoC_CTTC_capture_2012_07_26_4Msps_4ms.dat DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) - file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) - file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) - file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/NT1065_GLONASS_L1_20160831_fs6625e6_if0e3_4ms.bin DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) - add_definitions(-DTEST_PATH="${CMAKE_SOURCE_DIR}/thirdparty/") -endif(ENABLE_INSTALL_TESTS) + install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GSoC_CTTC_capture_2012_07_26_4Msps_4ms.dat DESTINATION share/gnss-sdr/signal_samples) + install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat DESTINATION share/gnss-sdr/signal_samples) + install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat DESTINATION share/gnss-sdr/signal_samples) + install(FILES ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/NT1065_GLONASS_L1_20160831_fs6625e6_if0e3_4ms.bin DESTINATION share/gnss-sdr/signal_samples) + install(FILES ${CMAKE_SOURCE_DIR}/src/tests/data/rtklib_test/obs_test1.xml DESTINATION share/gnss-sdr/data/rtklib_test) + install(FILES ${CMAKE_SOURCE_DIR}/src/tests/data/rtklib_test/eph_GPS_L1CA_test1.xml DESTINATION share/gnss-sdr/data/rtklib_test) + add_definitions(-DTEST_PATH="${CMAKE_INSTALL_PREFIX}/share/gnss-sdr/") +else() + file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GSoC_CTTC_capture_2012_07_26_4Msps_4ms.dat DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) + file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) + file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) + file(COPY ${CMAKE_SOURCE_DIR}/src/tests/signal_samples/NT1065_GLONASS_L1_20160831_fs6625e6_if0e3_4ms.bin DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples) + file(COPY ${CMAKE_SOURCE_DIR}/src/tests/data/rtklib_test/obs_test1.xml DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/data/rtklib_test) + file(COPY ${CMAKE_SOURCE_DIR}/src/tests/data/rtklib_test/eph_GPS_L1CA_test1.xml DESTINATION ${CMAKE_SOURCE_DIR}/thirdparty/data/rtklib_test) + add_definitions(-DTEST_PATH="${CMAKE_SOURCE_DIR}/thirdparty/") +endif() -include_directories( - ${GTEST_INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/core/libs - ${CMAKE_SOURCE_DIR}/src/core/libs/supl - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib - ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/resampler/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/resampler/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/channel/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/channel/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/telemetry_decoder/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/observables/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/observables/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_generator/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_generator/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs - ${CMAKE_SOURCE_DIR}/src/tests/unit-tests/signal-processing-blocks/libs - ${CMAKE_SOURCE_DIR}/src/tests/common-files - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${ARMADILLO_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} - ${MATIO_INCLUDE_DIRS} - ${GNSS_SDR_TEST_OPTIONAL_HEADERS} +set(LIST_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/src/tests/common-files ) - +include_directories(${LIST_INCLUDE_DIRS}) ################################################################################ # Unit testing @@ -354,247 +343,205 @@ include_directories( if(ENABLE_UNIT_TESTING) add_executable(run_tests ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cc) - target_link_libraries(run_tests ${CLANG_FLAGS} - ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - ${ARMADILLO_LIBRARIES} - ${VOLK_LIBRARIES} - channel_fsm - gnss_sp_libs - gnss_rx - gnss_system_parameters - signal_generator_blocks - signal_generator_adapters - pvt_gr_blocks - signal_processing_testing_lib - ${VOLK_GNSSSDR_LIBRARIES} - ${MATIO_LIBRARIES} - ${GNSS_SDR_TEST_OPTIONAL_LIBS} + target_link_libraries(run_tests + PUBLIC + Boost::filesystem + Boost::system + Boost::thread + Armadillo::armadillo + Gflags::gflags + Glog::glog + Gnuradio::runtime + Gnuradio::blocks + Gnuradio::filter + Gnuradio::analog + GTest::GTest + GTest::Main + Matio::matio + Volk::volk + Volkgnsssdr::volkgnsssdr + signal_source_adapters + signal_source_gr_blocks + signal_source_libs + data_type_adapters + input_filter_adapters + resampler_adapters + channel_adapters + acquisition_adapters + tracking_adapters + tracking_libs + telemetry_decoder_adapters + obs_adapters + signal_generator_adapters + pvt_adapters + pvt_libs + algorithms_libs + core_monitor + signal_processing_testing_lib + system_testing_lib + core_receiver + core_system_parameters ) - if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(run_tests gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) - endif(NOT ${GTEST_DIR_LOCAL}) - + if(ENABLE_UNIT_TESTING_EXTRA) + target_link_libraries(run_tests PUBLIC Gpstk::gpstk) + endif() if(ENABLE_INSTALL_TESTS) if(EXISTS ${CMAKE_SOURCE_DIR}/install/run_tests) file(REMOVE ${CMAKE_SOURCE_DIR}/install/run_tests) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/run_tests) + endif() install(TARGETS run_tests RUNTIME DESTINATION bin COMPONENT "run_tests") - else(ENABLE_INSTALL_TESTS) + else() add_custom_command(TARGET run_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$) - endif(ENABLE_INSTALL_TESTS) -endif(ENABLE_UNIT_TESTING) + COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$) + endif() + if(ENABLE_GPERFTOOLS) + if(GPERFTOOLS_FOUND) + target_link_libraries(run_tests + PUBLIC + Gperftools::gperftools + ) + endif() + endif() + if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(run_tests + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() + endif() + if(ENABLE_CUDA) + target_link_libraries(run_tests + PUBLIC + ${CUDA_LIBRARIES} + ) + target_include_directories(run_tests + PUBLIC + ${CUDA_INCLUDE_DIRS} + ) + endif() +endif() if(ENABLE_FPGA) add_executable(gps_l1_ca_dll_pll_tracking_test_fpga - ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc ) + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc + ) target_link_libraries(gps_l1_ca_dll_pll_tracking_test_fpga - ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${ARMADILLO_LIBRARIES} - ${VOLK_LIBRARIES} - ${MATIO_LIBRARIES} - channel_fsm - gnss_sp_libs - gnss_rx - gnss_system_parameters - signal_processing_testing_lib - ) + PUBLIC + Armadillo::armadillo + Boost::filesystem + Boost::system + Boost::thread + Gflags::gflags + Glog::glog + Gnuradio::runtime + Gnuradio::blocks + GTest::GTest + GTest::Main + Matio::matio + Volk::volk + channel_libs + data_type_adapters + tracking_adapters + signal_processing_testing_lib + algorithms_libs + core_receiver + core_system_parameters + ) install(TARGETS gps_l1_ca_dll_pll_tracking_test_fpga - RUNTIME DESTINATION bin - COMPONENT "fpga-test" ) -endif(ENABLE_FPGA) - + RUNTIME DESTINATION bin + COMPONENT "fpga-test" + ) +endif() ################################################################################ # System testing ################################################################################ +function(add_system_test executable) + ## Please call this function with variables OPT_INCLUDES_ and OPT_LIBS_ + ## already defined. + set(SYSTEM_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/${executable}.cc) + # Ensure that executable is rebuilt if it was previously built and then removed + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/${executable}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${SYSTEM_TEST_SOURCES}) + endif() + add_executable(${executable} ${SYSTEM_TEST_SOURCES}) + + target_include_directories(${executable} PUBLIC ${OPT_INCLUDES_} ${CMAKE_SOURCES_DIR}/src/algorithms/libs) + target_link_libraries(${executable} PUBLIC ${OPT_LIBS_} algorithms_libs) + + if(ENABLE_INSTALL_TESTS) + if(EXISTS ${CMAKE_SOURCE_DIR}/install/${executable}) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/${executable}) + endif() + install(TARGETS ${executable} RUNTIME DESTINATION bin COMPONENT "${executable}_test") + else() + add_custom_command(TARGET ${executable} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$) + endif() + if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(${executable} + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() + endif() +endfunction() + + if(ENABLE_SYSTEM_TESTING) set(HOST_SYSTEM "Unknown") if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(HOST_SYSTEM "GNU/Linux ${LINUX_DISTRIBUTION} ${LINUX_VER} ${ARCH_}") string(REPLACE "\n" "" HOST_SYSTEM "${HOST_SYSTEM}") - endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + string(REPLACE "\"" "" HOST_SYSTEM "${HOST_SYSTEM}") + endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(HOST_SYSTEM "MacOS") - endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + endif() add_definitions(-DHOST_SYSTEM="${HOST_SYSTEM}") - set(TTFF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/ttff_gps_l1.cc) - # Ensure that ttff is rebuilt if it was previously built and then removed - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${TTFF_SOURCES}) - endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) - - add_executable(ttff ${TTFF_SOURCES} ) - if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(ttff gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) - else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(ttff gtest) - endif(NOT ${GTEST_DIR_LOCAL}) - - target_link_libraries(ttff - ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - ${VOLK_GNSSSDR_LIBRARIES} - gnss_sp_libs - gnss_rx - gnss_system_parameters + #### TTFF + set(OPT_LIBS_ Boost::filesystem Boost::system Boost::thread Boost::date_time + Threads::Threads Gflags::gflags Glog::glog + Gnuradio::runtime GTest::GTest GTest::Main + Gnuradio::blocks Gnuradio::filter + Gnuradio::analog algorithms_libs + core_receiver core_system_parameters ) - - if(ENABLE_INSTALL_TESTS) - if(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/ttff) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) - install(TARGETS ttff RUNTIME DESTINATION bin COMPONENT "ttff") - else(ENABLE_INSTALL_TESTS) - add_custom_command(TARGET ttff POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$ ) - endif(ENABLE_INSTALL_TESTS) + add_system_test(ttff) if(ENABLE_SYSTEM_TESTING_EXTRA) - set(POSITION_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/position_test.cc) - # Ensure that position_test is rebuilt if it was previously built and then removed - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${POSITION_TEST_SOURCES}) - endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - add_executable(position_test ${POSITION_TEST_SOURCES}) - if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(position_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) - else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(position_test gtest) - endif(NOT ${GTEST_DIR_LOCAL}) - target_link_libraries(position_test - ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - ${VOLK_GNSSSDR_LIBRARIES} - gnss_sp_libs - gnss_rx - gnss_system_parameters + #### POSITION_TEST + set(OPT_LIBS_ Boost::filesystem Boost::system Boost::thread + Threads::Threads Gflags::gflags Glog::glog + GTest::GTest GTest::Main Gnuradio::runtime + Gnuradio::blocks Gnuradio::filter + Gnuradio::analog Matio::matio Volkgnsssdr::volkgnsssdr + algorithms_libs core_receiver core_system_parameters + system_testing_lib signal_processing_testing_lib ) - - if(ENABLE_INSTALL_TESTS) - if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - install(TARGETS position_test RUNTIME DESTINATION bin COMPONENT "position_test") - else(ENABLE_INSTALL_TESTS) - add_custom_command(TARGET position_test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$ ) - endif(ENABLE_INSTALL_TESTS) - - if(GPSTK_FOUND OR OWN_GPSTK) - set(OBS_GPS_L1_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) - # Ensure that obs_gps_l1_system_test is rebuilt if it was previously built and then removed - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_GPS_L1_TEST_SOURCES}) - endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - add_executable(obs_gps_l1_system_test ${OBS_GPS_L1_TEST_SOURCES}) - - set(OBS_SYSTEM_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_system_test.cc) - # Ensure that obs_system_test is rebuilt if it was previously built and then removed - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_SYSTEM_TEST_SOURCES}) - endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - add_executable(obs_system_test ${OBS_SYSTEM_TEST_SOURCES}) - - if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(obs_gps_l1_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) - add_dependencies(obs_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) - else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(obs_gps_l1_system_test gtest) - add_dependencies(obs_system_test gtest) - endif(NOT ${GTEST_DIR_LOCAL}) - include_directories(${GPSTK_INCLUDE_DIRS} ${GPSTK_INCLUDE_DIRS}/gpstk) - target_link_libraries(obs_gps_l1_system_test ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - gnss_sp_libs - gnss_rx - ${gpstk_libs}) - - target_link_libraries(obs_system_test ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - gnss_sp_libs - gnss_rx - ${gpstk_libs}) - - if(ENABLE_INSTALL_TESTS) - if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - install(TARGETS obs_gps_l1_system_test RUNTIME DESTINATION bin COMPONENT "obs_gps_l1_system_test") - - if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - install(TARGETS obs_system_test RUNTIME DESTINATION bin COMPONENT "obs_system_test") - else(ENABLE_INSTALL_TESTS) - add_custom_command(TARGET obs_gps_l1_system_test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$ ) - add_custom_command(TARGET obs_system_test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$ ) - - endif(ENABLE_INSTALL_TESTS) - endif(GPSTK_FOUND OR OWN_GPSTK) - else(ENABLE_SYSTEM_TESTING_EXTRA) + add_system_test(position_test) + else() # Avoid working with old executables if they were switched ON and then OFF if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - endif(ENABLE_SYSTEM_TESTING_EXTRA) -else(ENABLE_SYSTEM_TESTING) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test) + endif() + endif() +else() # Avoid working with old executables if they were switched ON and then OFF if(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/ttff) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/ttff) + endif() if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) -endif(ENABLE_SYSTEM_TESTING) + endif() +endif() ######################################################### @@ -603,186 +550,263 @@ endif(ENABLE_SYSTEM_TESTING) set(CMAKE_CTEST_COMMAND ctest -V) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) -add_executable(flowgraph_test ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/gnss_flowgraph_test.cc ) +if(NOT ENABLE_PACKAGING) + add_executable(flowgraph_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/gnss_flowgraph_test.cc + ) + + target_link_libraries(flowgraph_test + PUBLIC + Boost::filesystem + Boost::system + Boost::thread + Gflags::gflags + Glog::glog + Gnuradio::runtime + GTest::GTest + GTest::Main + Volkgnsssdr::volkgnsssdr + signal_source_adapters + signal_source_gr_blocks + signal_source_libs + input_filter_adapters + channel_adapters + core_receiver + algorithms_libs + core_system_parameters + ) + + target_include_directories(flowgraph_test + PUBLIC + ${CMAKE_SOURCE_DIR}/src/algorithms/libs + ) + + add_test(flowgraph_test flowgraph_test) + + set_property(TEST flowgraph_test PROPERTY TIMEOUT 30) +endif() -target_link_libraries(flowgraph_test ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GTEST_LIBRARIES} - gnss_sp_libs - gnss_rx - gnss_system_parameters - ${VOLK_GNSSSDR_LIBRARIES} ) -add_test(flowgraph_test flowgraph_test) -if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(flowgraph_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) -else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(flowgraph_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) -set_property(TEST flowgraph_test PROPERTY TIMEOUT 30) ######################################################### +if(NOT ENABLE_PACKAGING) + add_executable(gnss_block_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/adapter/adapter_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/gnss_block_factory_test.cc + ) + + target_link_libraries(gnss_block_test + PUBLIC + Boost::filesystem + Boost::system + Boost::thread + Gflags::gflags + Glog::glog + Gnuradio::runtime + Gnuradio::blocks + Gnuradio::filter + Gnuradio::analog + GTest::GTest + GTest::Main + Volkgnsssdr::volkgnsssdr + signal_source_adapters + signal_source_gr_blocks + signal_source_libs + data_type_adapters + input_filter_adapters + channel_adapters + core_receiver + algorithms_libs + core_system_parameters + ) + + target_include_directories(gnss_block_test PUBLIC ${CMAKE_SOURCE_DIR}/src/algorithms/libs) + + if(ENABLE_FPGA) + target_compile_definitions(gnss_block_test PUBLIC -DENABLE_FPGA=1) + endif() + + add_test(gnss_block_test gnss_block_test) + + set_property(TEST gnss_block_test PROPERTY TIMEOUT 60) +endif() -add_executable(gnss_block_test ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/adapter/adapter_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/gnss_block_factory_test.cc ) -target_link_libraries(gnss_block_test ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - gnss_sp_libs - gnss_rx - gnss_system_parameters - ${VOLK_GNSSSDR_LIBRARIES} ) -add_test(gnss_block_test gnss_block_test) -if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(gnss_block_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) -else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(gnss_block_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) ######################################################### +if(NOT ENABLE_PACKAGING) + add_executable(gnuradio_block_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc + ) + + target_link_libraries(gnuradio_block_test + PUBLIC + Boost::filesystem + Boost::system + Boost::thread + Gflags::gflags + Glog::glog + Gnuradio::runtime + Gnuradio::blocks + Gnuradio::filter + Gnuradio::analog + GTest::GTest + GTest::Main + Volkgnsssdr::volkgnsssdr + signal_source_gr_blocks + signal_source_libs + core_receiver + algorithms_libs + core_system_parameters + ) + + add_test(gnuradio_block_test gnuradio_block_test) + + set_property(TEST gnuradio_block_test PROPERTY TIMEOUT 30) +endif() -add_executable(gnuradio_block_test ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc ) -target_link_libraries(gnuradio_block_test ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - gnss_sp_libs - gnss_rx - gnss_system_parameters - ${VOLK_GNSSSDR_LIBRARIES} ) -add_test(gnuradio_block_test gnuradio_block_test) -if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(gnuradio_block_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) -else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(gnuradio_block_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) ######################################################### +add_executable(matio_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/arithmetic/matio_test.cc +) -add_executable(matio_test ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/arithmetic/matio_test.cc ) +target_link_libraries(matio_test + PUBLIC + Gflags::gflags + Glog::glog + GTest::GTest + GTest::Main + Matio::matio + core_receiver + core_system_parameters +) -target_link_libraries(matio_test ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${MATIO_LIBRARIES} - gnss_system_parameters ) add_test(matio_test matio_test) -if(NOT ${GTEST_DIR_LOCAL}) - if(MATIO_FOUND) - add_dependencies(matio_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) - else(MATIO_FOUND) - add_dependencies(matio_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) - endif(MATIO_FOUND) -else(NOT ${GTEST_DIR_LOCAL}) - if(MATIO_FOUND) - add_dependencies(matio_test gtest) - else(MATIO_FOUND) - add_dependencies(matio_test gtest matio-${GNSSSDR_MATIO_LOCAL_VERSION}) - endif(MATIO_FOUND) -endif(NOT ${GTEST_DIR_LOCAL}) + +set_property(TEST matio_test PROPERTY TIMEOUT 30) + ######################################################### +if(NOT ENABLE_PACKAGING) + add_executable(acq_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc + ) + + target_link_libraries(acq_test + PUBLIC + Boost::filesystem + Boost::system + Boost::thread + Gflags::gflags + Glog::glog + Gnuradio::runtime + Gnuradio::blocks + Gnuradio::filter + Gnuradio::analog + GTest::GTest + GTest::Main + Volkgnsssdr::volkgnsssdr + signal_generator_gr_blocks + signal_source_gr_blocks + signal_source_libs + acquisition_adapters + acquisition_gr_blocks + algorithms_libs + signal_processing_testing_lib + core_receiver + core_system_parameters + ) + + add_test(acq_test acq_test) + + set_property(TEST acq_test PROPERTY TIMEOUT 30) +endif() -add_executable(acq_test - ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc ) -target_link_libraries(acq_test ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - gnss_sp_libs - gnss_rx - gnss_system_parameters - signal_generator_blocks - signal_processing_testing_lib - ${VOLK_GNSSSDR_LIBRARIES} ) -add_test(acq_test acq_test) -if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(acq_test acq_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) -else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(acq_test acq_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) ######################################################### +if(NOT ENABLE_PACKAGING) + add_executable(trk_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/bayesian_estimation_test.cc + ) -add_executable(trk_test ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc ) + target_link_libraries(trk_test + PUBLIC + Boost::filesystem + Boost::system + Boost::thread + Gflags::gflags + Glog::glog + Gnuradio::runtime + Gnuradio::blocks + Gnuradio::filter + Gnuradio::analog + GTest::GTest + GTest::Main + Volkgnsssdr::volkgnsssdr + signal_source_gr_blocks + signal_source_libs + algorithms_libs + tracking_adapters + signal_generator_gr_blocks + core_receiver + core_system_parameters + ) -target_link_libraries(trk_test ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GNURADIO_ANALOG_LIBRARIES} - gnss_sp_libs - gnss_rx - gnss_system_parameters - signal_generator_blocks - ${VOLK_GNSSSDR_LIBRARIES} ) -add_test(trk_test trk_test) -if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(trk_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) -else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(trk_test gtest) -endif(NOT ${GTEST_DIR_LOCAL}) + add_test(trk_test trk_test) + + set_property(TEST trk_test PROPERTY TIMEOUT 30) +endif() ######################################################### if(NOT ENABLE_PACKAGING) - add_executable(control_thread_test ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/control_message_factory_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/control_thread_test.cc ) + add_executable(control_thread_test + ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/control_message_factory_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/control_thread_test.cc + ) - target_link_libraries(control_thread_test ${Boost_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${GTEST_LIBRARIES} - gnss_rx ) + target_link_libraries(control_thread_test + PUBLIC + Boost::filesystem + Boost::system + Boost::thread + Gflags::gflags + Glog::glog + GTest::GTest + GTest::Main + signal_source_adapters + signal_source_gr_blocks + signal_source_libs + algorithms_libs + core_receiver + core_system_parameters + ) add_test(control_thread_test control_thread_test) - if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(control_thread_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) - else(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(control_thread_test gtest) - endif(NOT ${GTEST_DIR_LOCAL}) + set_property(TEST control_thread_test PROPERTY TIMEOUT 30) -endif(NOT ENABLE_PACKAGING) +endif() ######################################################### if(ENABLE_PACKAGING) - add_dependencies(check flowgraph_test gnss_block_test - gnuradio_block_test acq_test trk_test matio_test) -else(ENABLE_PACKAGING) + add_dependencies(check matio_test) +else() add_dependencies(check control_thread_test flowgraph_test gnss_block_test - gnuradio_block_test acq_test trk_test matio_test) -endif(ENABLE_PACKAGING) + gnuradio_block_test acq_test trk_test matio_test) +endif() diff --git a/src/tests/common-files/gnuplot_i.h b/src/tests/common-files/gnuplot_i.h index 0c9e282a7..afdc47c3a 100644 --- a/src/tests/common-files/gnuplot_i.h +++ b/src/tests/common-files/gnuplot_i.h @@ -47,18 +47,21 @@ #ifndef GNSS_SDR_GNUPLOT_I_H_ #define GNSS_SDR_GNUPLOT_I_H_ - -#include -#include -#include -#include -#include // for std::ostringstream -#include +#include +#include #include #include // for getenv() -#include -#include // for std::list +#include // for strncpy +#include +#include +#include // for std::list +#include // for std::ostringstream +#include +#include +#include +#include +DEFINE_bool(show_plots, true, "Show plots on screen. Disable for non-interactive testing."); #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) //defined for 32 and 64-bit environments @@ -67,7 +70,7 @@ #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) //all UNIX-like OSs (Linux, *BSD, MacOSX, Solaris, ...) #include // for access(), mkstemp() -#define GP_MAX_TMP_FILES 64 +#define GP_MAX_TMP_FILES 1024 #else #error unsupported or unknown operating system #endif @@ -215,6 +218,7 @@ public: const std::string &labely = "y", const std::string &labelz = "z"); + /// destructor: needed to delete temporary files ~Gnuplot(); @@ -243,6 +247,9 @@ public: /// sets terminal type to terminal_std Gnuplot &showonscreen(); // window output is set by default (win/x11/aqua) + /// sets terminal type to unknown (disable the screen output) + Gnuplot &disablescreen(); + /// saves a gnuplot session to a postscript file, filename without extension Gnuplot &savetops(const std::string &filename = "gnuplot_output"); @@ -300,9 +307,9 @@ public: /// /// \return <-- reference to the gnuplot object // ----------------------------------------------- - inline Gnuplot &set_multiplot() + inline Gnuplot &set_multiplot(int rows, int cols) { - cmd("set multiplot"); + cmd("set multiplot layout " + std::to_string(rows) + "," + std::to_string(cols)); //+ " rowfirst"); return *this; }; @@ -644,7 +651,10 @@ public: //---------------------------------------------------------------------------------- inline Gnuplot &replot(void) { - if (nplots > 0) cmd("replot"); + if (nplots > 0) + { + cmd("replot"); + } return *this; }; @@ -696,7 +706,7 @@ std::string Gnuplot::terminal_std = "aqua"; // constructor: set a style during construction // inline Gnuplot::Gnuplot(const std::string &style) - : gnucmd(NULL), valid(false), two_dim(false), nplots(0) + : gnucmd(nullptr), valid(false), two_dim(false), nplots(0) { init(); @@ -713,7 +723,7 @@ inline Gnuplot::Gnuplot(const std::vector &x, const std::string &style, const std::string &labelx, const std::string &labely) - : gnucmd(NULL), valid(false), two_dim(false), nplots(0) + : gnucmd(nullptr), valid(false), two_dim(false), nplots(0) { init(); @@ -735,7 +745,7 @@ inline Gnuplot::Gnuplot(const std::vector &x, const std::string &style, const std::string &labelx, const std::string &labely) - : gnucmd(NULL), valid(false), two_dim(false), nplots(0) + : gnucmd(nullptr), valid(false), two_dim(false), nplots(0) { init(); @@ -759,7 +769,7 @@ inline Gnuplot::Gnuplot(const std::vector &x, const std::string &labelx, const std::string &labely, const std::string &labelz) - : gnucmd(NULL), valid(false), two_dim(false), nplots(0) + : gnucmd(nullptr), valid(false), two_dim(false), nplots(0) { init(); @@ -779,7 +789,7 @@ inline Gnuplot::Gnuplot(const std::vector &x, template Gnuplot &Gnuplot::plot_x(const X &x, const std::string &title) { - if (x.size() == 0) + if (x.empty()) { throw GnuplotException("std::vector too small"); return *this; @@ -787,14 +797,18 @@ Gnuplot &Gnuplot::plot_x(const X &x, const std::string &title) std::ofstream tmp; std::string name = create_tmpfile(tmp); - if (name == "") - return *this; + if (name.empty()) + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << std::endl; + { + tmp << x[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -812,7 +826,7 @@ Gnuplot &Gnuplot::plot_x(const X &x, const std::string &title) template Gnuplot &Gnuplot::plot_xy(const X &x, const Y &y, const std::string &title, const unsigned int decimate) { - if (x.size() == 0 || y.size() == 0) + if (x.empty() || y.empty()) { throw GnuplotException("std::vectors too small"); return *this; @@ -826,14 +840,18 @@ Gnuplot &Gnuplot::plot_xy(const X &x, const Y &y, const std::string &title, cons std::ofstream tmp; std::string name = create_tmpfile(tmp); - if (name == "") - return *this; + if (name.empty()) + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << " " << y[i] << std::endl; + { + tmp << x[i] << " " << y[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -854,7 +872,7 @@ Gnuplot &Gnuplot::plot_xy_err(const X &x, const E &dy, const std::string &title) { - if (x.size() == 0 || y.size() == 0 || dy.size() == 0) + if (x.empty() || y.empty() || dy.empty()) { throw GnuplotException("std::vectors too small"); return *this; @@ -868,14 +886,18 @@ Gnuplot &Gnuplot::plot_xy_err(const X &x, std::ofstream tmp; std::string name = create_tmpfile(tmp); - if (name == "") - return *this; + if (name.empty()) + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << " " << y[i] << " " << dy[i] << std::endl; + { + tmp << x[i] << " " << y[i] << " " << dy[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -897,15 +919,17 @@ Gnuplot &Gnuplot::plot_grid3d(const X &x, const E &mag, const std::string &title) { - if (x.size() == 0 || y.size() == 0) + if (x.empty() || y.empty()) { throw GnuplotException("std::vectors too small"); return *this; } std::ofstream tmp; std::string name = create_tmpfile(tmp); - if (name == "") - return *this; + if (name.empty()) + { + return *this; + } // // write the data to file @@ -930,10 +954,14 @@ Gnuplot &Gnuplot::plot_grid3d(const X &x, cmdstr << " splot \"" << name << "\" u 1:2:3"; - if (title == "") - cmdstr << " notitle with " << pstyle << " palette"; + if (title.empty()) + { + cmdstr << " notitle with " << pstyle << " palette"; + } else - cmdstr << " title \"" << title << "\" with " << pstyle << " palette"; + { + cmdstr << " title \"" << title << "\" with " << pstyle << " palette"; + } cmdstr << "\n"; // @@ -954,7 +982,7 @@ Gnuplot &Gnuplot::plot_xyz(const X &x, const Z &z, const std::string &title) { - if (x.size() == 0 || y.size() == 0 || z.size() == 0) + if (x.empty() || y.empty() || z.empty()) { throw GnuplotException("std::vectors too small"); return *this; @@ -968,14 +996,18 @@ Gnuplot &Gnuplot::plot_xyz(const X &x, std::ofstream tmp; std::string name = create_tmpfile(tmp); - if (name == "") - return *this; + if (name.empty()) + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << " " << y[i] << " " << z[i] << std::endl; + { + tmp << x[i] << " " << y[i] << " " << z[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -1004,11 +1036,9 @@ bool Gnuplot::set_GNUPlotPath(const std::string &path) Gnuplot::m_sGNUPlotPath = path; return true; } - else - { - Gnuplot::m_sGNUPlotPath.clear(); - return false; - } + + Gnuplot::m_sGNUPlotPath.clear(); + return false; } @@ -1020,7 +1050,7 @@ bool Gnuplot::set_GNUPlotPath(const std::string &path) void Gnuplot::set_terminal_std(const std::string &type) { #if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) - if (type.find("x11") != std::string::npos && std::getenv("DISPLAY") == NULL) + if (type.find("x11") != std::string::npos && std::getenv("DISPLAY") == nullptr) { throw GnuplotException("Can't find DISPLAY variable"); } @@ -1050,7 +1080,9 @@ void stringtok(Container &container, i = in.find_first_not_of(delimiters, i); if (i == std::string::npos) - return; // nothing left but white space + { + return; // nothing left but white space + } // find the end of the token std::string::size_type j = in.find_first_of(delimiters, i); @@ -1061,8 +1093,8 @@ void stringtok(Container &container, container.push_back(in.substr(i)); return; } - else - container.push_back(in.substr(i, j - i)); + + container.push_back(in.substr(i, j - i)); // set up for next loop i = j + 1; @@ -1079,18 +1111,19 @@ void stringtok(Container &container, Gnuplot::~Gnuplot() { // remove_tmpfiles(); - // A stream opened by popen() should be closed by pclose() #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) if (_pclose(gnucmd) == -1) + { #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) if (pclose(gnucmd) == -1) + { #endif - // throw GnuplotException("Problem closing communication to gnuplot"); - std::cout << "Gnuplot window left open." << std::endl; + // throw GnuplotException("Problem closing communication to gnuplot"); + std::cout << "Gnuplot window left open." << std::endl; + } } - //------------------------------------------------------------------------------ // // Resets a gnuplot session (next plot will erase previous ones) @@ -1103,7 +1136,6 @@ Gnuplot &Gnuplot::reset_plot() return *this; } - //------------------------------------------------------------------------------ // // resets a gnuplot session and sets all variables to default @@ -1121,7 +1153,6 @@ Gnuplot &Gnuplot::reset_all() return *this; } - //------------------------------------------------------------------------------ // // Change the plotting style of a gnuplot session @@ -1167,7 +1198,6 @@ Gnuplot &Gnuplot::set_style(const std::string &stylestr) return *this; } - //------------------------------------------------------------------------------ // // smooth: interpolation and approximation of data @@ -1192,6 +1222,17 @@ Gnuplot &Gnuplot::set_smooth(const std::string &stylestr) } +//------------------------------------------------------------------------------ +// +// Disable screen output +// +Gnuplot &Gnuplot::disablescreen() +{ + cmd("set output"); + cmd("set terminal unknown"); + return *this; +} + //------------------------------------------------------------------------------ // // sets terminal type to windows / x11 @@ -1485,16 +1526,24 @@ Gnuplot &Gnuplot::plot_slope(const double a, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << a << " * x + " << b << " title \""; - if (title == "") - cmdstr << "f(x) = " << a << " * x + " << b; + if (title.empty()) + { + cmdstr << "f(x) = " << a << " * x + " << b; + } else - cmdstr << title; + { + cmdstr << title; + } cmdstr << "\" with " << pstyle; @@ -1519,16 +1568,24 @@ Gnuplot &Gnuplot::plot_equation(const std::string &equation, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << equation << " title \""; - if (title == "") - cmdstr << "f(x) = " << equation; + if (title.empty()) + { + cmdstr << "f(x) = " << equation; + } else - cmdstr << title; + { + cmdstr << title; + } cmdstr << "\" with " << pstyle; @@ -1553,16 +1610,24 @@ Gnuplot &Gnuplot::plot_equation3d(const std::string &equation, // command to be sent to gnuplot // if (nplots > 0 && two_dim == false) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "splot "; + { + cmdstr << "splot "; + } cmdstr << equation << " title \""; - if (title == "") - cmdstr << "f(x,y) = " << equation; + if (title.empty()) + { + cmdstr << "f(x,y) = " << equation; + } else - cmdstr << title; + { + cmdstr << title; + } cmdstr << "\" with " << pstyle; @@ -1593,21 +1658,33 @@ Gnuplot &Gnuplot::plotfile_x(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << "\"" << filename << "\" using " << column; - if (title == "") - cmdstr << " notitle "; + if (title.empty()) + { + cmdstr << " notitle "; + } else - cmdstr << " title \"" << title << "\" "; + { + cmdstr << " title \"" << title << "\" "; + } - if (smooth == "") - cmdstr << "with " << pstyle; + if (smooth.empty()) + { + cmdstr << "with " << pstyle; + } else - cmdstr << "smooth " << smooth; + { + cmdstr << "smooth " << smooth; + } // // Do the actual plot @@ -1638,21 +1715,33 @@ Gnuplot &Gnuplot::plotfile_xy(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y << " every " << std::to_string(decimate); - if (title == "") - cmdstr << " notitle "; + if (title.empty()) + { + cmdstr << " notitle "; + } else - cmdstr << " title \"" << title << "\" "; + { + cmdstr << " title \"" << title << "\" "; + } - if (smooth == "") - cmdstr << "with " << pstyle; + if (smooth.empty()) + { + cmdstr << "with " << pstyle; + } else - cmdstr << "smooth " << smooth; + { + cmdstr << "smooth " << smooth; + } // // Do the actual plot @@ -1683,18 +1772,26 @@ Gnuplot &Gnuplot::plotfile_xy_err(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y << ":" << column_dy << " with errorbars "; - if (title == "") - cmdstr << " notitle "; + if (title.empty()) + { + cmdstr << " notitle "; + } else - cmdstr << " title \"" << title << "\" "; + { + cmdstr << " title \"" << title << "\" "; + } // // Do the actual plot @@ -1725,17 +1822,25 @@ Gnuplot &Gnuplot::plotfile_xyz(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == false) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "splot "; + { + cmdstr << "splot "; + } cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y << ":" << column_z; - if (title == "") - cmdstr << " notitle with " << pstyle; + if (title.empty()) + { + cmdstr << " notitle with " << pstyle; + } else - cmdstr << " title \"" << title << "\" with " << pstyle; + { + cmdstr << " title \"" << title << "\" with " << pstyle; + } // // Do the actual plot @@ -1757,8 +1862,10 @@ Gnuplot &Gnuplot::plot_image(const unsigned char *ucPicBuf, { std::ofstream tmp; std::string name = create_tmpfile(tmp); - if (name == "") - return *this; + if (name.empty()) + { + return *this; + } // // write the data to file @@ -1781,14 +1888,22 @@ Gnuplot &Gnuplot::plot_image(const unsigned char *ucPicBuf, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } - if (title == "") - cmdstr << "\"" << name << "\" with image"; + if (title.empty()) + { + cmdstr << "\"" << name << "\" with image"; + } else - cmdstr << "\"" << name << "\" title \"" << title << "\" with image"; + { + cmdstr << "\"" << name << "\" title \"" << title << "\" with image"; + } // // Do the actual plot @@ -1808,7 +1923,7 @@ Gnuplot &Gnuplot::plot_circle(double east, double north, double radius, const st cmdstr << "set object circle at " + std::to_string(east) + "," + std::to_string(north) + " size " + std::to_string(radius) + " back\n"; - if (label != "") + if (!label.empty()) { double east_label = (std::cos(M_PI / 3.0) * radius) * 1.1 + east; double north_label = (std::sin(M_PI / 3.0) * radius) * 1.1 + north; @@ -1816,9 +1931,13 @@ Gnuplot &Gnuplot::plot_circle(double east, double north, double radius, const st ", " + std::to_string(north_label) + " norotate back nopoint offset 0,0\n"; } if (nplots > 0) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } // // Do the actual plot @@ -1858,7 +1977,7 @@ Gnuplot &Gnuplot::cmd(const std::string &cmdstr) { return *this; } - else if (cmdstr.find("splot") != std::string::npos) + if (cmdstr.find("splot") != std::string::npos) { two_dim = false; nplots++; @@ -1884,7 +2003,7 @@ void Gnuplot::init() // whose name is specified as argument. If the requested variable is not // part of the environment list, the function returns a NULL pointer. #if (defined(unix) || defined(__unix) || defined(__unix__)) && !defined(__APPLE__) - if (std::getenv("DISPLAY") == NULL) + if (std::getenv("DISPLAY") == nullptr) { valid = false; throw GnuplotException("Can't find DISPLAY variable"); @@ -1904,11 +2023,11 @@ void Gnuplot::init() std::string tmp = Gnuplot::m_sGNUPlotPath + "/" + Gnuplot::m_sGNUPlotFileName; - // FILE *popen(const char *command, const char *mode); - // The popen() function shall execute the command specified by the string - // command, create a pipe between the calling program and the executed - // command, and return a pointer to a stream that can be used to either read - // from or write to the pipe. +// FILE *popen(const char *command, const char *mode); +// The popen() function shall execute the command specified by the string +// command, create a pipe between the calling program and the executed +// command, and return a pointer to a stream that can be used to either read +// from or write to the pipe. #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) gnucmd = _popen(tmp.c_str(), "w"); #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) @@ -1959,47 +2078,46 @@ bool Gnuplot::get_program_path() // // second look in PATH for Gnuplot // - char *path; + const char *path; // Retrieves a C string containing the value of environment variable PATH path = std::getenv("PATH"); - - if (path == NULL || std::char_traits::length(path) > 4096 * sizeof(char)) + std::stringstream s; + s << path; + if (s.fail()) { throw GnuplotException("Path is not set"); } - else + std::string path_str = s.str(); + + std::list ls; + +//split path (one long string) into list ls of strings +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) + stringtok(ls, path_str, ";"); +#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) + stringtok(ls, path_str, ":"); +#endif + + // scan list for Gnuplot program files + for (std::list::const_iterator i = ls.begin(); + i != ls.end(); ++i) { - std::list ls; - std::string path_str(path); - - //split path (one long string) into list ls of strings + tmp = (*i) + "/" + Gnuplot::m_sGNUPlotFileName; #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) - stringtok(ls, path_str, ";"); + if (Gnuplot::file_exists(tmp, 0)) // check existence #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) - stringtok(ls, path_str, ":"); + if (Gnuplot::file_exists(tmp, 1)) // check existence and execution permission #endif - - // scan list for Gnuplot program files - for (std::list::const_iterator i = ls.begin(); - i != ls.end(); ++i) { - tmp = (*i) + "/" + Gnuplot::m_sGNUPlotFileName; -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) - if (Gnuplot::file_exists(tmp, 0)) // check existence -#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) - if (Gnuplot::file_exists(tmp, 1)) // check existence and execution permission -#endif - { - Gnuplot::m_sGNUPlotPath = *i; // set m_sGNUPlotPath - return true; - } + Gnuplot::m_sGNUPlotPath = *i; // set m_sGNUPlotPath + return true; } - - tmp = "Can't find gnuplot neither in PATH nor in \"" + - Gnuplot::m_sGNUPlotPath + "\""; - Gnuplot::m_sGNUPlotPath = ""; - throw GnuplotException(tmp); } + + tmp = "Can't find gnuplot neither in PATH nor in \"" + + Gnuplot::m_sGNUPlotPath + "\""; + Gnuplot::m_sGNUPlotPath = ""; + throw GnuplotException(tmp); } @@ -2017,16 +2135,16 @@ bool Gnuplot::file_exists(const std::string &filename, int mode) return false; } - // int _access(const char *path, int mode); - // returns 0 if the file has the given mode, - // it returns -1 if the named file does not exist or is not accessible in - // the given mode - // mode = 0 (F_OK) (default): checks file for existence only - // mode = 1 (X_OK): execution permission - // mode = 2 (W_OK): write permission - // mode = 4 (R_OK): read permission - // mode = 6 : read and write permission - // mode = 7 : read, write and execution permission +// int _access(const char *path, int mode); +// returns 0 if the file has the given mode, +// it returns -1 if the named file does not exist or is not accessible in +// the given mode +// mode = 0 (F_OK) (default): checks file for existence only +// mode = 1 (X_OK): execution permission +// mode = 2 (W_OK): write permission +// mode = 4 (R_OK): read permission +// mode = 6 : read and write permission +// mode = 7 : read, write and execution permission #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) if (_access(filename.c_str(), mode) == 0) #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) @@ -2035,10 +2153,7 @@ bool Gnuplot::file_exists(const std::string &filename, int mode) { return true; } - else - { - return false; - } + return false; } @@ -2101,17 +2216,24 @@ std::string Gnuplot::create_tmpfile(std::ofstream &tmp) // // open temporary files for output // + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) if (_mktemp(name) == NULL) #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) + mode_t mask = umask(S_IXUSR | S_IRWXG | S_IRWXO); if (mkstemp(name) == -1) #endif { std::ostringstream except; except << "Cannot create temporary file \"" << name << "\""; +#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) + umask(mask); +#endif throw GnuplotException(except.str()); } - +#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) + umask(mask); +#endif tmp.open(name); if (tmp.bad()) { @@ -2123,7 +2245,7 @@ std::string Gnuplot::create_tmpfile(std::ofstream &tmp) // // Save the temporary filename // - tmpfile_list.push_back(name); + tmpfile_list.emplace_back(name); Gnuplot::tmpfile_num++; return name; @@ -2132,11 +2254,15 @@ std::string Gnuplot::create_tmpfile(std::ofstream &tmp) void Gnuplot::remove_tmpfiles() { - if ((tmpfile_list).size() > 0) + if (!(tmpfile_list).empty()) { - for (unsigned int i = 0; i < tmpfile_list.size(); i++) - if (remove(tmpfile_list[i].c_str()) != 0) - std::cout << "Problem closing files" << std::endl; + for (auto &i : tmpfile_list) + { + if (remove(i.c_str()) != 0) + { + std::cout << "Problem closing files" << std::endl; + } + } Gnuplot::tmpfile_num -= tmpfile_list.size(); } diff --git a/src/tests/common-files/observable_tests_flags.h b/src/tests/common-files/observable_tests_flags.h new file mode 100644 index 000000000..37d2bab99 --- /dev/null +++ b/src/tests/common-files/observable_tests_flags.h @@ -0,0 +1,42 @@ +/*! + * \file tracking_tests_flags.h + * \brief Helper file for unit testing + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_OBSERVABLE_TESTS_FLAGS_H_ +#define GNSS_SDR_OBSERVABLE_TESTS_FLAGS_H_ + +#include +#include + +DEFINE_double(skip_obs_transitory_s, 30.0, "Skip the initial observable outputs to avoid transitory results [s]"); +DEFINE_bool(compute_single_diffs, false, "Compute also the single difference errors for Accumulated Carrier Phase and Carrier Doppler (requires LO synchronization between receivers)"); +DEFINE_bool(compare_with_5X, false, "Compare the E5a Doppler and Carrier Phases with the E5 full bw in RINEX (expect discrepancy due to the center frequencies differences"); +DEFINE_bool(duplicated_satellites_test, false, "Enable special observable test mode where the scenario contains duplicated satellite orbits"); +DEFINE_string(duplicated_satellites_prns, "1,2,3,4", "List of duplicated satellites PRN pairs (i.e. 1,2,3,4 indicates that the PRNs 1,2 share the same orbit. The same applies for PRNs 3,4)"); +#endif diff --git a/src/tests/common-files/signal_generator_flags.h b/src/tests/common-files/signal_generator_flags.h index cfc93b8d0..b5e737adc 100644 --- a/src/tests/common-files/signal_generator_flags.h +++ b/src/tests/common-files/signal_generator_flags.h @@ -32,17 +32,20 @@ #define GNSS_SDR_SIGNAL_GENERATOR_FLAGS_H_ #include +#include DEFINE_bool(disable_generator, false, "Disable the signal generator (a external signal file must be available for the test)"); DEFINE_string(generator_binary, std::string(SW_GENERATOR_BIN), "Path of software-defined signal generator binary"); DEFINE_string(rinex_nav_file, std::string(DEFAULT_RINEX_NAV), "Input RINEX navigation file"); DEFINE_int32(duration, 100, "Duration of the experiment [in seconds, max = 300]"); -DEFINE_string(static_position, "30.286502,120.032669,100", "Static receiver position [log,lat,height]"); +DEFINE_string(static_position, "30.286502,120.032669,100", "Static receiver position [latitude,longitude,height]"); DEFINE_string(dynamic_position, "", "Observer positions file, in .csv or .nmea format"); DEFINE_string(filename_rinex_obs, "sim.16o", "Filename of output RINEX navigation file"); DEFINE_string(filename_raw_data, "signal_out.bin", "Filename of output raw data file"); DEFINE_int32(fs_gen_sps, 2600000, "Sampling frequency [sps]"); DEFINE_int32(test_satellite_PRN, 1, "PRN of the satellite under test (must be visible during the observation time)"); DEFINE_int32(test_satellite_PRN2, 2, "PRN of the satellite under test (must be visible during the observation time)"); +DEFINE_string(test_satellite_PRN_list, "1,2,3,6,9,10,12,17,20,23,28", "List of PRN of the satellites under test (must be visible during the observation time)"); +DEFINE_double(CN0_dBHz, std::numeric_limits::infinity(), "Enable noise generator and set the CN0 [dB-Hz]"); #endif diff --git a/src/tests/common-files/tracking_tests_flags.h b/src/tests/common-files/tracking_tests_flags.h new file mode 100644 index 000000000..1724fcf68 --- /dev/null +++ b/src/tests/common-files/tracking_tests_flags.h @@ -0,0 +1,91 @@ +/*! + * \file tracking_tests_flags.h + * \brief Helper file for unit testing + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_TRACKING_TESTS_FLAGS_H_ +#define GNSS_SDR_TRACKING_TESTS_FLAGS_H_ + +#include +#include + + +DEFINE_string(trk_test_implementation, std::string("GPS_L1_CA_DLL_PLL_Tracking"), "Tracking block implementation under test, defaults to GPS_L1_CA_DLL_PLL_Tracking"); +// Input signal configuration +DEFINE_bool(enable_external_signal_file, false, "Use an external signal file capture instead of the software-defined signal generator"); +DEFINE_double(external_signal_acquisition_threshold, 2.5, "Threshold for satellite acquisition when external file is used"); +DEFINE_int32(external_signal_acquisition_dwells, 5, "Maximum dwells count for satellite acquisition when external file is used"); +DEFINE_double(external_signal_acquisition_doppler_max_hz, 5000.0, "Doppler max for satellite acquisition when external file is used"); +DEFINE_double(external_signal_acquisition_doppler_step_hz, 125.0, "Doppler step for satellite acquisition when external file is used"); +DEFINE_bool(use_acquisition_resampler, false, "Reduce the sampling rate of the input signal for the acquisition in order to optimize the SNR and decrease the processor load"); + +DEFINE_string(signal_file, std::string("signal_out.bin"), "Path of the external signal capture file"); +DEFINE_double(CN0_dBHz_start, std::numeric_limits::infinity(), "Enable noise generator and set the CN0 start sweep value [dB-Hz]"); +DEFINE_double(CN0_dBHz_stop, std::numeric_limits::infinity(), "Enable noise generator and set the CN0 stop sweep value [dB-Hz]"); +DEFINE_double(CN0_dB_step, 3.0, "Noise generator CN0 sweep step value [dB]"); + +DEFINE_double(PLL_bw_hz_start, 20.0, "PLL Wide configuration start sweep value [Hz]"); +DEFINE_double(PLL_bw_hz_stop, 20.0, "PLL Wide configuration stop sweep value [Hz]"); +DEFINE_double(PLL_bw_hz_step, 5.0, "PLL Wide configuration sweep step value [Hz]"); + +DEFINE_double(DLL_bw_hz_start, 1.0, "DLL Wide configuration start sweep value [Hz]"); +DEFINE_double(DLL_bw_hz_stop, 1.0, "DLL Wide configuration stop sweep value [Hz]"); +DEFINE_double(DLL_bw_hz_step, 0.25, "DLL Wide configuration sweep step value [Hz]"); + +DEFINE_double(PLL_narrow_bw_hz, 5.0, "PLL Narrow configuration value [Hz]"); +DEFINE_double(DLL_narrow_bw_hz, 0.75, "DLL Narrow configuration value [Hz]"); + +DEFINE_double(acq_Doppler_error_hz_start, 1000.0, "Acquisition Doppler error start sweep value [Hz]"); +DEFINE_double(acq_Doppler_error_hz_stop, -1000.0, "Acquisition Doppler error stop sweep value [Hz]"); +DEFINE_double(acq_Doppler_error_hz_step, -50.0, "Acquisition Doppler error sweep step value [Hz]"); + +DEFINE_double(acq_Delay_error_chips_start, 2.0, "Acquisition Code Delay error start sweep value [Chips]"); +DEFINE_double(acq_Delay_error_chips_stop, -2.0, "Acquisition Code Delay error stop sweep value [Chips]"); +DEFINE_double(acq_Delay_error_chips_step, -0.1, "Acquisition Code Delay error sweep step value [Chips]"); + +DEFINE_double(acq_to_trk_delay_s, 0.0, "Acquisition to Tracking delay value [s]"); + + +DEFINE_int64(skip_samples, 0, "Skip an initial transitory in the processed signal file capture [samples]"); + +DEFINE_int32(plot_detail_level, 0, "Specify the desired plot detail (0,1,2): 0 - Minimum plots (default) 2 - Plot all tracking parameters"); + +DEFINE_double(skip_trk_transitory_s, 1.0, "Skip the initial tracking output signal to avoid transitory results [s]"); + +//Emulated acquisition configuration + +//Tracking configuration +DEFINE_int32(extend_correlation_symbols, 1, "Set the tracking coherent correlation to N symbols (up to 20 for GPS L1 C/A)"); +DEFINE_int32(smoother_length, 10, "Set the moving average size for the carrier phase and code phase in case of high dynamics"); +DEFINE_bool(high_dyn, false, "Activates the code resampler and NCO generator for high dynamics"); + +//Test output configuration +DEFINE_bool(plot_gps_l1_tracking_test, false, "Plots results of GpsL1CADllPllTrackingTest with gnuplot"); + + +#endif diff --git a/src/tests/data/rtklib_test/eph_GPS_L1CA_test1.xml b/src/tests/data/rtklib_test/eph_GPS_L1CA_test1.xml new file mode 100644 index 000000000..4dcc2564d --- /dev/null +++ b/src/tests/data/rtklib_test/eph_GPS_L1CA_test1.xml @@ -0,0 +1,481 @@ + + + + + 11 + 0 + + 1 + + 1 + 5.18448000000000000e+05 + 9.20000000000000000e+01 + 9.20000000000000000e+01 + 1.83125000000000000e+01 + 4.86413118201646669e-09 + 2.06468198930943725e+00 + 9.42498445510864258e-07 + 3.73082922305911736e-03 + 5.76488673686981201e-06 + 5.15366174697875977e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + -5.40167093276977539e-08 + 9.52167247599200905e-01 + 1.86264514923095703e-08 + 9.61377026423456127e-01 + 2.66968750000000000e+02 + 4.44935333708291858e-01 + -8.14641075927847669e-09 + 4.15017287135849497e-10 + 0 + 799 + 0 + 2 + 0 + 5.12227416038513184e-09 + 9.20000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + -1.09937973320484161e-05 + 3.41060513164847988e-13 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 2 + + 2 + 5.18448000000000000e+05 + 5.50000000000000000e+01 + 5.50000000000000000e+01 + 2.22812500000000000e+01 + 5.12771358985317661e-09 + 2.75926302782053146e+00 + 1.10082328319549561e-06 + 1.40569622162729484e-02 + 6.26407563686370850e-06 + 5.15372654151916504e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + -1.86264514923095703e-08 + 9.18037446344556307e-01 + -2.16066837310791016e-07 + 9.39991586696909520e-01 + 2.45468750000000000e+02 + -2.35598690357981555e+00 + -8.07140763509730069e-09 + 5.25736184736635464e-10 + 0 + 799 + 0 + 2 + 0 + -2.00234353542327881e-08 + 5.50000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + 5.36850653588771820e-04 + 2.16004991671070416e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 3 + + 3 + 5.18448000000000000e+05 + 7.00000000000000000e+01 + 7.00000000000000000e+01 + -2.04375000000000000e+01 + 4.75769817722603366e-09 + -1.78871492992227910e+00 + -1.30012631416320801e-06 + 9.70319728367030512e-04 + 8.26455652713775635e-06 + 5.15378153991699219e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + 7.82310962677001953e-08 + 1.99297660614955263e+00 + -1.11758708953857422e-08 + 9.59058451948379909e-01 + 2.19593750000000000e+02 + -3.00536842405812843e+00 + -8.02712007605698577e-09 + -5.17164399115929480e-10 + 0 + 799 + 0 + 2 + 0 + 5.12227416038513184e-09 + 7.00000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + 8.80691222846508026e-05 + 2.89901436190120811e-11 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 6 + + 6 + 5.18448000000000000e+05 + 2.30000000000000000e+01 + 2.30000000000000000e+01 + 1.63750000000000000e+01 + 4.76305554323897445e-09 + -1.28531071631616522e+00 + 9.12696123123168945e-07 + 5.50022465176880251e-04 + 6.24358654022216797e-06 + 5.15365166282653809e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + -1.30385160446166992e-08 + 9.43624288779246867e-01 + -1.86264514923095703e-09 + 9.61292940818096020e-01 + 2.58406250000000000e+02 + 2.29191014519991665e+00 + -8.08069373618639861e-09 + 4.79305679291144535e-10 + 0 + 799 + 0 + 2 + 0 + 4.65661287307739258e-09 + 2.30000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + 3.07881273329257965e-05 + 8.18545231595635253e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 9 + + 9 + 5.18448000000000000e+05 + 4.70000000000000000e+01 + 4.70000000000000000e+01 + 1.12906250000000000e+02 + 4.37911097897818463e-09 + -2.75253879947800195e+00 + 5.85243105888366699e-06 + 2.16206186451017829e-04 + 1.16303563117980957e-05 + 5.15369471168518066e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + 1.67638063430786133e-08 + 3.03742251571970812e+00 + -1.11758708953857422e-08 + 9.59160503650671514e-01 + 1.56125000000000000e+02 + 2.60662251530764344e+00 + -7.85854162551643464e-09 + -3.46443002170201364e-11 + 0 + 799 + 0 + 2 + 0 + 4.65661287307739258e-10 + 4.70000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + -3.18535603582859039e-05 + -9.66338120633736091e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 10 + + 10 + 5.18448000000000000e+05 + 5.80000000000000000e+01 + 5.80000000000000000e+01 + -2.72500000000000000e+01 + 5.27093384126580581e-09 + -8.86982818851813737e-01 + -1.17719173431396484e-06 + 1.44534236751496774e-02 + 7.90506601333618164e-06 + 5.15363725471496582e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + 1.45286321640014648e-07 + 2.00408517949479270e+00 + 2.40281224250793457e-07 + 9.41160112993577269e-01 + 2.15406250000000000e+02 + 9.09732121011562200e-01 + -8.42213653007785350e-09 + -5.42879755978047536e-10 + 0 + 799 + 0 + 2 + 0 + -2.79396772384643555e-09 + 5.80000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + -1.54968351125717163e-04 + -1.59161572810262401e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 12 + + 12 + 5.18448000000000000e+05 + 1.06000000000000000e+02 + 1.06000000000000000e+02 + -1.17468750000000000e+02 + 3.94516433192994276e-09 + 1.11631735294997192e+00 + -6.15417957305908203e-06 + 5.05860964767634782e-03 + 4.52436506748199463e-06 + 5.15376680946350098e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + -5.40167093276977539e-08 + -1.10425023618040785e+00 + 4.09781932830810547e-08 + 9.88803748742243305e-01 + 3.07187500000000000e+02 + 5.00154452274795935e-01 + -7.97176062725659211e-09 + -4.18231706743614228e-10 + 0 + 799 + 0 + 2 + 0 + -1.16415321826934814e-08 + 1.06000000000000000e+02 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + 2.54871323704719543e-04 + 2.72848410531878391e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 17 + + 17 + 5.18448000000000000e+05 + 2.60000000000000000e+01 + 2.60000000000000000e+01 + -5.91250000000000000e+01 + 3.88194741297723567e-09 + -1.94252959218893162e+00 + -3.04728746414184570e-06 + 9.88844956737011498e-03 + 1.18296593427658081e-05 + 5.15369299888610840e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + 2.03028321266174316e-07 + -5.68690999805671268e-02 + -7.63684511184692383e-08 + 9.71201777972365177e-01 + 1.56531250000000000e+02 + -2.06928329237789344e+00 + -7.44602444251995675e-09 + 4.40375486263771432e-10 + 0 + 799 + 0 + 2 + 0 + -1.07102096080780029e-08 + 2.60000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + -1.44933816045522690e-04 + -2.27373675443232019e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 20 + + 20 + 5.18448000000000000e+05 + 1.17000000000000000e+02 + 1.17000000000000000e+02 + -2.58437500000000000e+01 + 5.60380484953655626e-09 + 1.28625710142833249e-01 + -1.52923166751861572e-06 + 5.80669869668781671e-03 + 7.51018524169921875e-06 + 5.15578671264648438e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + -2.23517417907714844e-08 + 1.92543994118208528e+00 + 4.65661287307739258e-08 + 9.26021286652122910e-01 + 2.18031250000000000e+02 + 1.23365536128043107e+00 + -8.54892752571746483e-09 + -5.16450083647537340e-10 + 0 + 799 + 0 + 2 + 0 + -8.38190317153930664e-09 + 1.17000000000000000e+02 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + 2.69209500402212143e-04 + 4.20641299569979229e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 23 + + 23 + 5.18448000000000000e+05 + 4.10000000000000000e+01 + 4.10000000000000000e+01 + 1.20250000000000000e+02 + 4.45161399901998963e-09 + 3.04794581942897569e+00 + 6.13741576671600342e-06 + 9.67817602213471954e-03 + 1.14180147647857666e-05 + 5.15370163154602051e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + -6.14672899246215820e-08 + 3.04748172476042711e+00 + -1.04308128356933594e-07 + 9.50229191282804808e-01 + 1.56000000000000000e+02 + -2.71676891930177256e+00 + -7.78032408172749087e-09 + -2.75011455330984601e-11 + 0 + 799 + 0 + 2 + 0 + -1.95577740669250488e-08 + 4.10000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + -7.56788067519664764e-05 + -2.72848410531878391e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + 28 + + 28 + 5.18448000000000000e+05 + 3.30000000000000000e+01 + 3.30000000000000000e+01 + -1.27750000000000000e+02 + 4.04302555109966970e-09 + -1.16607683198628931e+00 + -6.37024641036987305e-06 + 1.97223023278638686e-02 + 5.66989183425903320e-06 + 5.15368548965454102e+03 + 5.18400000000000000e+05 + 5.18400000000000000e+05 + -1.37835741043090820e-07 + -1.08006546321039543e+00 + 4.35858964920043945e-07 + 9.87961552655681530e-01 + 2.84718750000000000e+02 + -1.69047108635756738e+00 + -8.17855495535612472e-09 + -4.44661379074124424e-10 + 0 + 799 + 0 + 2 + 0 + -1.11758708953857422e-08 + 3.30000000000000000e+01 + 27900 + 0 + 0.00000000000000000e+00 + 0.00000000000000000e+00 + 4.06486913561820984e-04 + 2.61479726759716828e-12 + 0.00000000000000000e+00 + 0 + 0 + 0 + + + + diff --git a/src/tests/data/rtklib_test/obs_test1.xml b/src/tests/data/rtklib_test/obs_test1.xml new file mode 100644 index 000000000..8c96fc2ff --- /dev/null +++ b/src/tests/data/rtklib_test/obs_test1.xml @@ -0,0 +1,358 @@ + + + + + 10 + 0 + + 0 + + 71 + + 3 + 49 + 67 + 0 + + 1 + 0 + 2.28200000000000000e+03 + -2.50000000000000000e+03 + 10791 + 0 + 0 + 2600000 + -3.85959140625000000e+04 + -9.03592163085937500e+02 + 5.96898384094238281e+01 + -2.57914688873291016e+03 + 8.35350813421410858e+05 + 3.31084377635761484e-01 + 133923691 + 1 + 1 + 1 + 518451424 + 2.28178186234515086e+07 + 5.18451500000000000e+05 + 1 + 5.18451423887949765e+08 + + + + 1 + + 71 + + 3 + 49 + 67 + 0 + + 3 + 1 + 2.38500000000000000e+03 + -3.00000000000000000e+03 + 68450858 + 0 + 0 + 2600000 + -4.34972734375000000e+04 + 4.21364685058593750e+02 + 5.16798934936523438e+01 + -3.12509065246582031e+03 + 4.93910706686261110e+05 + 7.36033200862493686e-01 + 133923971 + 1 + 1 + 1 + 518451431 + 2.07516033774388395e+07 + 5.18451500000000000e+05 + 1 + 5.18451430780101955e+08 + + + + 2 + + 71 + + 3 + 49 + 67 + 0 + + 28 + 2 + 1.52700000000000000e+03 + -3.00000000000000000e+03 + 1350770 + 0 + 0 + 2600000 + 4.46268046875000000e+04 + -3.98811938476562500e+03 + 5.25376167297363281e+01 + -2.92984253692626953e+03 + 9.35704822809229488e+05 + 9.30327007595224131e-01 + 133923941 + 1 + 1 + 1 + 518451436 + 1.92492043561209217e+07 + 5.18451500000000000e+05 + 1 + 5.18451435791565657e+08 + + + + 4 + + 71 + + 3 + 49 + 67 + 0 + + 23 + 4 + 1.13100000000000000e+03 + 1.00000000000000000e+03 + 994247 + 0 + 0 + 2600000 + 3.98655546875000000e+04 + -8.63781860351562500e+02 + 5.24684982299804688e+01 + 1.09281750951009121e+03 + -3.54128275530727289e+05 + 4.08304036132904002e-01 + 133922883 + 1 + 1 + 1 + 518451429 + 2.12256989876578376e+07 + 5.18451500000000000e+05 + 1 + 5.18451429198689222e+08 + + + + 5 + + 71 + + 3 + 49 + 67 + 0 + + 2 + 5 + 5.38000000000000000e+02 + 1.75000000000000000e+03 + 4917751 + 0 + 0 + 2600000 + -4.72456406250000000e+04 + -2.63723022460937500e+02 + 4.89446220397949219e+01 + 1.83319645690917969e+03 + -5.72184006019302527e+05 + 5.89544135488722532e-01 + 133922337 + 1 + 1 + 1 + 518451430 + 2.08629709015843943e+07 + 5.18451500000000000e+05 + 1 + 5.18451430408619881e+08 + + + + 6 + + 71 + + 3 + 49 + 67 + 0 + + 17 + 6 + 2.21000000000000000e+02 + 2.50000000000000000e+02 + 514377 + 0 + 0 + 2600000 + 4.27717460937500000e+04 + -9.45822082519531250e+02 + 5.38986015319824219e+01 + 2.73018497467041016e+02 + -9.09813659855529113e+04 + 6.57473345280777721e-01 + 133923172 + 1 + 1 + 1 + 518451440 + 1.79613337841309197e+07 + 5.18451500000000000e+05 + 1 + 5.18451440087439477e+08 + + + + 7 + + 71 + + 3 + 49 + 67 + 0 + + 9 + 7 + 1.56900000000000000e+03 + 2.25000000000000000e+03 + 7365787 + 0 + 0 + 2600000 + -3.96159960937500000e+04 + -5.03847460937500000e+03 + 5.33032913208007812e+01 + 2.30021731185913086e+03 + -7.04913853936602012e+05 + 3.21518194999043772e-01 + 133922169 + 1 + 1 + 1 + 518451430 + 2.08435687343175523e+07 + 5.18451500000000000e+05 + 1 + 5.18451430473338544e+08 + + + + 8 + + 71 + + 3 + 49 + 67 + 0 + + 10 + 8 + 2.12600000000000000e+03 + 2.75000000000000000e+03 + 2173576 + 0 + 0 + 2600000 + 4.00322539062500000e+04 + -3.88590087890625000e+02 + 4.85561523437500000e+01 + 2.81225794982910156e+03 + -8.99142229977656389e+05 + 1.02370741655249731e-01 + 133922664 + 1 + 1 + 1 + 518451438 + 1.85022797143675610e+07 + 5.18451500000000000e+05 + 1 + 5.18451438283038080e+08 + + + + 9 + + 71 + + 3 + 49 + 67 + 0 + + 12 + 9 + 2.13000000000000000e+02 + 3.00000000000000000e+03 + 7464974 + 0 + 0 + 2600000 + -4.03654140625000000e+04 + 3.92351245117187500e+03 + 5.17314453125000000e+01 + 3.03019989013671875e+03 + -9.28340507655202877e+05 + 5.73995602361264901e-01 + 133923741 + 1 + 1 + 1 + 518451427 + 2.19242346189941987e+07 + 5.18451500000000000e+05 + 1 + 5.18451426868625164e+08 + + + + 10 + + 71 + + 3 + 49 + 67 + 0 + + 6 + 10 + 4.70000000000000000e+01 + 5.00000000000000000e+02 + 1859813 + 0 + 0 + 2600000 + 3.87814335937500000e+04 + 2.13637329101562500e+03 + 6.00463027954101562e+01 + 5.54514957427978516e+02 + -1.78723083774703584e+05 + 3.47952294631795667e-01 + 133924211 + 1 + 1 + 1 + 518451439 + 1.83808922785463184e+07 + 5.18451500000000000e+05 + 1 + 5.18451438687942982e+08 + + + + diff --git a/src/tests/single_test_main.cc b/src/tests/single_test_main.cc index 5dbfee8f9..02814af09 100644 --- a/src/tests/single_test_main.cc +++ b/src/tests/single_test_main.cc @@ -29,17 +29,16 @@ * ------------------------------------------------------------------------- */ -#include "concurrent_queue.h" +#include "agnss_ref_location.h" +#include "agnss_ref_time.h" #include "concurrent_map.h" -#include "gps_navigation_message.h" -#include "gps_ephemeris.h" +#include "concurrent_queue.h" +#include "galileo_navigation_message.h" +#include "gps_acq_assist.h" #include "gps_cnav_ephemeris.h" #include "gps_cnav_iono.h" -#include "gps_acq_assist.h" -#include "gps_ref_location.h" -#include "gps_ref_time.h" -#include "galileo_navigation_message.h" -#include +#include "gps_ephemeris.h" +#include "gps_navigation_message.h" #include #include #include @@ -50,9 +49,9 @@ #include -concurrent_queue global_gps_acq_assist_queue; +Concurrent_Queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; +Concurrent_Map global_gps_acq_assist_map; using google::LogMessage; diff --git a/src/tests/system-tests/libs/CMakeLists.txt b/src/tests/system-tests/libs/CMakeLists.txt new file mode 100644 index 000000000..d29962cdf --- /dev/null +++ b/src/tests/system-tests/libs/CMakeLists.txt @@ -0,0 +1,56 @@ +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . +# + + +set(SYSTEM_TESTING_LIB_SOURCES + spirent_motion_csv_dump_reader.cc + rtklib_solver_dump_reader.cc +) + +file(GLOB SYSTEM_TESTING_LIB_HEADERS "*.h") +list(SORT SYSTEM_TESTING_LIB_HEADERS) + +add_library(system_testing_lib + ${SYSTEM_TESTING_LIB_SOURCES} + ${SYSTEM_TESTING_LIB_HEADERS} +) + +source_group(Headers FILES ${SYSTEM_TESTING_LIB_HEADERS}) + +target_link_libraries(system_testing_lib + PUBLIC + Armadillo::armadillo + Gflags::gflags + PRIVATE + Boost::boost + Matio::matio +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(system_testing_lib + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET system_testing_lib + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/tests/system-tests/libs/position_test_flags.h b/src/tests/system-tests/libs/position_test_flags.h new file mode 100644 index 000000000..1ebe296e6 --- /dev/null +++ b/src/tests/system-tests/libs/position_test_flags.h @@ -0,0 +1,50 @@ +/*! + * \file signal_generator_flags.h + * \brief Helper file for unit testing + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_POSITION_TEST_FLAGS_H_ +#define GNSS_SDR_POSITION_TEST_FLAGS_H_ + +#include +#include + +DEFINE_string(config_file_ptest, std::string(""), "File containing the configuration parameters for the position test."); +DEFINE_bool(plot_position_test, false, "Plots results of with gnuplot"); +DEFINE_bool(static_scenario, true, "Compute figures of merit for static user position (DRMS, CEP, etc..)"); +DEFINE_bool(use_ref_motion_file, false, "Enable or disable the use of a reference file containing the true receiver position, velocity and acceleration."); +DEFINE_int32(ref_motion_file_type, 1, "Type of reference motion file: 1- Spirent CSV motion file"); +DEFINE_string(ref_motion_filename, std::string("motion.csv"), "Path and filename for the reference motion file"); +DEFINE_string(pvt_solver_dump_filename, std::string("PVT.dat"), "Path and filename for the PVT solver binary dump file"); +DEFINE_double(static_2D_error_m, 2.0, "Static scenario 2D (East, North) positioning error threshold [meters]"); +DEFINE_double(static_3D_error_m, 5.0, "Static scenario 3D (East, North, Up) positioning error threshold [meters]"); +DEFINE_double(accuracy_CEP, 2.0, "Static scenario 2D (East, North) accuracy Circular Error Position (CEP) threshold [meters]"); +DEFINE_double(precision_SEP, 10.0, "Static scenario 3D (East, North, Up) precision Spherical Error Position (SEP) threshold [meters]"); +DEFINE_double(dynamic_3D_position_RMSE, 10.0, "Dynamic scenario 3D (ECEF) accuracy RMSE threshold [meters]"); +DEFINE_double(dynamic_3D_velocity_RMSE, 5.0, "Dynamic scenario 3D (ECEF) velocity accuracy RMSE threshold [meters/second]"); +#endif diff --git a/src/tests/system-tests/libs/rtklib_solver_dump_reader.cc b/src/tests/system-tests/libs/rtklib_solver_dump_reader.cc new file mode 100644 index 000000000..08939e1e3 --- /dev/null +++ b/src/tests/system-tests/libs/rtklib_solver_dump_reader.cc @@ -0,0 +1,145 @@ +/*! + * \file rtklib_solver_dump_reader.cc + * \brief Helper file for unit testing + * \author Javier Arribas, 2017. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "rtklib_solver_dump_reader.h" +#include +#include +#include + +bool Rtklib_Solver_Dump_Reader::read_binary_obs() +{ + try + { + d_dump_file.read(reinterpret_cast(&TOW_at_current_symbol_ms), sizeof(uint32_t)); + d_dump_file.read(reinterpret_cast(&week), sizeof(uint32_t)); + d_dump_file.read(reinterpret_cast(&RX_time), sizeof(double)); + d_dump_file.read(reinterpret_cast(&clk_offset_s), sizeof(double)); + d_dump_file.read(reinterpret_cast(&rr[0]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&rr[1]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&rr[2]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&rr[3]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&rr[4]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&rr[5]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&qr[0]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&qr[1]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&qr[2]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&qr[3]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&qr[4]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&qr[5]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&latitude), sizeof(double)); + d_dump_file.read(reinterpret_cast(&longitude), sizeof(double)); + d_dump_file.read(reinterpret_cast(&height), sizeof(double)); + d_dump_file.read(reinterpret_cast(&ns), sizeof(uint8_t)); + d_dump_file.read(reinterpret_cast(&status), sizeof(uint8_t)); + d_dump_file.read(reinterpret_cast(&type), sizeof(uint8_t)); + d_dump_file.read(reinterpret_cast(&AR_ratio), sizeof(float)); + d_dump_file.read(reinterpret_cast(&AR_thres), sizeof(float)); + d_dump_file.read(reinterpret_cast(&dop[0]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&dop[1]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&dop[2]), sizeof(double)); + d_dump_file.read(reinterpret_cast(&dop[3]), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + return false; + } + return true; +} + + +bool Rtklib_Solver_Dump_Reader::restart() +{ + if (d_dump_file.is_open()) + { + d_dump_file.clear(); + d_dump_file.seekg(0, std::ios::beg); + return true; + } + return false; +} + + +int64_t Rtklib_Solver_Dump_Reader::num_epochs() +{ + std::ifstream::pos_type size; + int epoch_size_bytes = 2 * sizeof(uint32_t) + 21 * sizeof(double) + 3 * sizeof(uint8_t) + 2 * sizeof(float); + std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + if (tmpfile.is_open()) + { + size = tmpfile.tellg(); + int64_t nepoch = size / epoch_size_bytes; + return nepoch; + } + return 0; +} + + +bool Rtklib_Solver_Dump_Reader::open_obs_file(std::string out_file) +{ + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = std::move(out_file); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary); + return true; + } + catch (const std::ifstream::failure &e) + { + std::cout << "Problem opening rtklib_solver dump Log file: " << d_dump_filename << std::endl; + return false; + } + } + else + { + return false; + } +} + + +Rtklib_Solver_Dump_Reader::~Rtklib_Solver_Dump_Reader() +{ + try + { + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing rtklib_solver dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; + } +} diff --git a/src/tests/system-tests/libs/rtklib_solver_dump_reader.h b/src/tests/system-tests/libs/rtklib_solver_dump_reader.h new file mode 100644 index 000000000..d3990e30f --- /dev/null +++ b/src/tests/system-tests/libs/rtklib_solver_dump_reader.h @@ -0,0 +1,88 @@ +/*! + * \file rtklib_solver_dump_reader.h + * \brief Helper file for unit testing + * \author Javier Arribas, 2017. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_RTKLIB_SOLVER_DUMP_READER_H +#define GNSS_SDR_RTKLIB_SOLVER_DUMP_READER_H + +#include +#include +#include +#include + +class Rtklib_Solver_Dump_Reader +{ +public: + ~Rtklib_Solver_Dump_Reader(); + bool read_binary_obs(); + bool restart(); + int64_t num_epochs(); + bool open_obs_file(std::string out_file); + + // rtklib_solver dump variables + // TOW + uint32_t TOW_at_current_symbol_ms; + // WEEK + uint32_t week; + // PVT GPS time + double RX_time; + // User clock offset [s] + double clk_offset_s; + // ECEF POS X,Y,X [m] + ECEF VEL X,Y,X [m/s] (6 x double) + double rr[6]; + // position variance/covariance (m^2) {c_xx,c_yy,c_zz,c_xy,c_yz,c_zx} (6 x double) + double qr[6]; + + // GEO user position Latitude [deg] + double latitude; + // GEO user position Longitude [deg] + double longitude; + // GEO user position Height [m] + double height; + + // NUMBER OF VALID SATS + uint8_t ns; + // RTKLIB solution status + uint8_t status; + // RTKLIB solution type (0:xyz-ecef,1:enu-baseline) + uint8_t type; + // AR ratio factor for validation + float AR_ratio; + // AR ratio threshold for validation + float AR_thres; + + // GDOP / PDOP / HDOP / VDOP + double dop[4]; + +private: + std::string d_dump_filename; + std::ifstream d_dump_file; +}; + +#endif //GNSS_SDR_RTKLIB_SOLVER_DUMP_READER_H diff --git a/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.cc b/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.cc new file mode 100644 index 000000000..8a97cfeb3 --- /dev/null +++ b/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.cc @@ -0,0 +1,268 @@ +/*! + * \file spirent_motion_csv_dump_reader.cc + * \brief Helper file for unit testing + * \author Javier Arribas, 2017. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "spirent_motion_csv_dump_reader.h" +#include +#include +#include +#include + + +Spirent_Motion_Csv_Dump_Reader::Spirent_Motion_Csv_Dump_Reader() +{ + header_lines = 2; + TOW_ms = 0.0; + Pos_X = 0.0; + Pos_Y = 0.0; + Pos_Z = 0.0; + Vel_X = 0.0; + Vel_Y = 0.0; + Vel_Z = 0.0; + Acc_X = 0.0; + Acc_Y = 0.0; + Acc_Z = 0.0; + Jerk_X = 0.0; + Jerk_Y = 0.0; + Jerk_Z = 0.0; + Lat = 0.0; + Long = 0.0; + Height = 0.0; + Heading = 0.0; + Elevation = 0.0; + Bank = 0.0; + Ang_vel_X = 0.0; + Ang_vel_Y = 0.0; + Ang_vel_Z = 0.0; + Ang_acc_X = 0.0; + Ang_acc_Y = 0.0; + Ang_acc_Z = 0.0; + Ant1_Pos_X = 0.0; + Ant1_Pos_Y = 0.0; + Ant1_Pos_Z = 0.0; + Ant1_Vel_X = 0.0; + Ant1_Vel_Y = 0.0; + Ant1_Vel_Z = 0.0; + Ant1_Acc_X = 0.0; + Ant1_Acc_Y = 0.0; + Ant1_Acc_Z = 0.0; + Ant1_Lat = 0.0; + Ant1_Long = 0.0; + Ant1_Height = 0.0; + Ant1_DOP = 0.0; +} + + +Spirent_Motion_Csv_Dump_Reader::~Spirent_Motion_Csv_Dump_Reader() +{ + try + { + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Spirent CSV dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; + } +} + + +bool Spirent_Motion_Csv_Dump_Reader::read_csv_obs() +{ + try + { + std::vector vec; + std::string line; + if (getline(d_dump_file, line)) + { + boost::tokenizer> tk( + line, boost::escaped_list_separator('\\', ',', '\"')); + for (boost::tokenizer>::iterator i( + tk.begin()); + i != tk.end(); ++i) + { + try + { + vec.push_back(std::stod(*i)); + } + catch (const std::exception &ex) + { + vec.push_back(0.0); + } + } + parse_vector(vec); + } + } + catch (const std::ifstream::failure &e) + { + return false; + } + return true; +} + + +bool Spirent_Motion_Csv_Dump_Reader::parse_vector(std::vector &vec) +{ + try + { + int n = 0; + TOW_ms = vec.at(n++); + Pos_X = vec.at(n++); + Pos_Y = vec.at(n++); + Pos_Z = vec.at(n++); + Vel_X = vec.at(n++); + Vel_Y = vec.at(n++); + Vel_Z = vec.at(n++); + Acc_X = vec.at(n++); + Acc_Y = vec.at(n++); + Acc_Z = vec.at(n++); + Jerk_X = vec.at(n++); + Jerk_Y = vec.at(n++); + Jerk_Z = vec.at(n++); + Lat = vec.at(n++); + Long = vec.at(n++); + Height = vec.at(n++); + Heading = vec.at(n++); + Elevation = vec.at(n++); + Bank = vec.at(n++); + Ang_vel_X = vec.at(n++); + Ang_vel_Y = vec.at(n++); + Ang_vel_Z = vec.at(n++); + Ang_acc_X = vec.at(n++); + Ang_acc_Y = vec.at(n++); + Ang_acc_Z = vec.at(n++); + Ant1_Pos_X = vec.at(n++); + Ant1_Pos_Y = vec.at(n++); + Ant1_Pos_Z = vec.at(n++); + Ant1_Vel_X = vec.at(n++); + Ant1_Vel_Y = vec.at(n++); + Ant1_Vel_Z = vec.at(n++); + Ant1_Acc_X = vec.at(n++); + Ant1_Acc_Y = vec.at(n++); + Ant1_Acc_Z = vec.at(n++); + Ant1_Lat = vec.at(n++); + Ant1_Long = vec.at(n++); + Ant1_Height = vec.at(n++); + Ant1_DOP = vec.at(n++); + return true; + } + catch (const std::exception &ex) + { + return false; + } +} + + +bool Spirent_Motion_Csv_Dump_Reader::restart() +{ + if (d_dump_file.is_open()) + { + d_dump_file.clear(); + d_dump_file.seekg(0, std::ios::beg); + std::string line; + for (int n = 0; n < header_lines; n++) + { + getline(d_dump_file, line); + } + return true; + } + return false; +} + + +int64_t Spirent_Motion_Csv_Dump_Reader::num_epochs() +{ + int64_t nepoch = 0LL; + std::string line; + std::ifstream tmpfile(d_dump_filename.c_str()); + if (tmpfile.is_open()) + { + while (std::getline(tmpfile, line)) + { + ++nepoch; + } + return nepoch - header_lines; + } + return 0; +} + + +bool Spirent_Motion_Csv_Dump_Reader::open_obs_file(std::string out_file) +{ + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = std::move(out_file); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str()); + std::string line; + for (int n = 0; n < header_lines; n++) + { + getline(d_dump_file, line); + } + return true; + } + catch (const std::ifstream::failure &e) + { + std::cout << "Problem opening Spirent CSV dump Log file: " << d_dump_filename << std::endl; + return false; + } + } + else + { + return false; + } +} + + +void Spirent_Motion_Csv_Dump_Reader::close_obs_file() +{ + try + { + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Spirent CSV dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; + } +} diff --git a/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.h b/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.h new file mode 100644 index 000000000..5d8066627 --- /dev/null +++ b/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.h @@ -0,0 +1,97 @@ +/*! + * \file spirent_motion_csv_dump_reader.h + * \brief Helper file for unit testing + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_SPIRENT_MOTION_CSV_DUMP_READER_H +#define GNSS_SDR_SPIRENT_MOTION_CSV_DUMP_READER_H + +#include +#include +#include +#include + +class Spirent_Motion_Csv_Dump_Reader +{ +public: + Spirent_Motion_Csv_Dump_Reader(); + ~Spirent_Motion_Csv_Dump_Reader(); + bool read_csv_obs(); + bool restart(); + int64_t num_epochs(); + bool open_obs_file(std::string out_file); + void close_obs_file(); + + int header_lines; + // dump variables + double TOW_ms; + double Pos_X; + double Pos_Y; + double Pos_Z; + double Vel_X; + double Vel_Y; + double Vel_Z; + double Acc_X; + double Acc_Y; + double Acc_Z; + double Jerk_X; + double Jerk_Y; + double Jerk_Z; + double Lat; + double Long; + double Height; + double Heading; + double Elevation; + double Bank; + double Ang_vel_X; + double Ang_vel_Y; + double Ang_vel_Z; + double Ang_acc_X; + double Ang_acc_Y; + double Ang_acc_Z; + double Ant1_Pos_X; + double Ant1_Pos_Y; + double Ant1_Pos_Z; + double Ant1_Vel_X; + double Ant1_Vel_Y; + double Ant1_Vel_Z; + double Ant1_Acc_X; + double Ant1_Acc_Y; + double Ant1_Acc_Z; + double Ant1_Lat; + double Ant1_Long; + double Ant1_Height; + double Ant1_DOP; + +private: + std::string d_dump_filename; + std::ifstream d_dump_file; + bool parse_vector(std::vector &vec); +}; + +#endif // GNSS_SDR_SPIRENT_MOTION_CSV_DUMP_READER_H diff --git a/src/tests/system-tests/obs_gps_l1_system_test.cc b/src/tests/system-tests/obs_gps_l1_system_test.cc deleted file mode 100644 index 2cace8a00..000000000 --- a/src/tests/system-tests/obs_gps_l1_system_test.cc +++ /dev/null @@ -1,722 +0,0 @@ -/*! - * \file obs_gps_l1_system_test.cc - * \brief This class implements a test for the validation of generated observables. - * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include "concurrent_map.h" -#include "concurrent_queue.h" -#include "control_thread.h" -#include "in_memory_configuration.h" -#include "signal_generator_flags.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -// For GPS NAVIGATION (L1) -concurrent_queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; - - -class ObsGpsL1SystemTest : public ::testing::Test -{ -public: - std::string generator_binary; - std::string p1; - std::string p2; - std::string p3; - std::string p4; - std::string p5; - - const double baseband_sampling_freq = 2.6e6; - - std::string filename_rinex_obs = FLAGS_filename_rinex_obs; - std::string filename_raw_data = FLAGS_filename_raw_data; - std::string generated_rinex_obs; - int configure_generator(); - int generate_signal(); - int configure_receiver(); - int run_receiver(); - void check_results(); - bool check_valid_rinex_nav(std::string filename); // return true if the file is a valid Rinex navigation file. - bool check_valid_rinex_obs(std::string filename); // return true if the file is a valid Rinex observation file. - double compute_stdev(const std::vector& vec); - - std::shared_ptr config; -}; - - -bool ObsGpsL1SystemTest::check_valid_rinex_nav(std::string filename) -{ - bool res = false; - res = gpstk::isRinexNavFile(filename); - return res; -} - - -double ObsGpsL1SystemTest::compute_stdev(const std::vector& vec) -{ - double sum__ = std::accumulate(vec.begin(), vec.end(), 0.0); - double mean__ = sum__ / vec.size(); - double accum__ = 0.0; - std::for_each(std::begin(vec), std::end(vec), [&](const double d) { - accum__ += (d - mean__) * (d - mean__); - }); - double stdev__ = std::sqrt(accum__ / (vec.size() - 1)); - return stdev__; -} - - -bool ObsGpsL1SystemTest::check_valid_rinex_obs(std::string filename) -{ - bool res = false; - res = gpstk::isRinexObsFile(filename); - return res; -} - - -int ObsGpsL1SystemTest::configure_generator() -{ - // Configure signal generator - generator_binary = FLAGS_generator_binary; - - p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; - if (FLAGS_dynamic_position.empty()) - { - p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(std::min(FLAGS_duration * 10, 3000)); - if (FLAGS_duration > 300) std::cout << "WARNING: Duration has been set to its maximum value of 300 s" << std::endl; - } - else - { - p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); - } - p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output - p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples - p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] - return 0; -} - - -int ObsGpsL1SystemTest::generate_signal() -{ - pid_t wait_result; - int child_status; - - char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; - - int pid; - if ((pid = fork()) == -1) - perror("fork error"); - else if (pid == 0) - { - execv(&generator_binary[0], parmList); - std::cout << "Return not expected. Must be an execv error." << std::endl; - std::terminate(); - } - - wait_result = waitpid(pid, &child_status, 0); - if (wait_result == -1) perror("waitpid error"); - EXPECT_EQ(true, check_valid_rinex_obs(filename_rinex_obs)); - std::cout << "Signal and Observables RINEX files created." << std::endl; - return 0; -} - - -int ObsGpsL1SystemTest::configure_receiver() -{ - config = std::make_shared(); - - const int sampling_rate_internal = baseband_sampling_freq; - - const int number_of_taps = 11; - const int number_of_bands = 2; - const float band1_begin = 0.0; - const float band1_end = 0.48; - const float band2_begin = 0.52; - const float band2_end = 1.0; - const float ampl1_begin = 1.0; - const float ampl1_end = 1.0; - const float ampl2_begin = 0.0; - const float ampl2_end = 0.0; - const float band1_error = 1.0; - const float band2_error = 1.0; - const int grid_density = 16; - const int decimation_factor = 1; - - const float zero = 0.0; - const int number_of_channels = 8; - const int in_acquisition = 1; - - const float threshold = 0.01; - const float doppler_max = 8000.0; - const float doppler_step = 500.0; - const int max_dwells = 1; - const int tong_init_val = 2; - const int tong_max_val = 10; - const int tong_max_dwells = 30; - const int coherent_integration_time_ms = 1; - - const float pll_bw_hz = 30.0; - const float dll_bw_hz = 4.0; - const float early_late_space_chips = 0.5; - const float pll_bw_narrow_hz = 20.0; - const float dll_bw_narrow_hz = 2.0; - const int extend_correlation_ms = 1; - - const int display_rate_ms = 500; - const int output_rate_ms = 100; - - config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(sampling_rate_internal)); - - // Set the assistance system parameters - config->set_property("GNSS-SDR.SUPL_read_gps_assistance_xml", "false"); - config->set_property("GNSS-SDR.SUPL_gps_enabled", "false"); - config->set_property("GNSS-SDR.SUPL_gps_ephemeris_server", "supl.google.com"); - config->set_property("GNSS-SDR.SUPL_gps_ephemeris_port", std::to_string(7275)); - config->set_property("GNSS-SDR.SUPL_gps_acquisition_server", "supl.google.com"); - config->set_property("GNSS-SDR.SUPL_gps_acquisition_port", std::to_string(7275)); - config->set_property("GNSS-SDR.SUPL_MCC", std::to_string(244)); - config->set_property("GNSS-SDR.SUPL_MNS", std::to_string(5)); - config->set_property("GNSS-SDR.SUPL_LAC", "0x59e2"); - config->set_property("GNSS-SDR.SUPL_CI", "0x31b0"); - - // Set the Signal Source - config->set_property("SignalSource.implementation", "File_Signal_Source"); - config->set_property("SignalSource.filename", "./" + filename_raw_data); - config->set_property("SignalSource.sampling_frequency", std::to_string(sampling_rate_internal)); - config->set_property("SignalSource.item_type", "ibyte"); - config->set_property("SignalSource.samples", std::to_string(zero)); - - // Set the Signal Conditioner - config->set_property("SignalConditioner.implementation", "Signal_Conditioner"); - config->set_property("DataTypeAdapter.implementation", "Ibyte_To_Complex"); - config->set_property("InputFilter.implementation", "Fir_Filter"); - config->set_property("InputFilter.dump", "false"); - config->set_property("InputFilter.input_item_type", "gr_complex"); - config->set_property("InputFilter.output_item_type", "gr_complex"); - config->set_property("InputFilter.taps_item_type", "float"); - config->set_property("InputFilter.number_of_taps", std::to_string(number_of_taps)); - config->set_property("InputFilter.number_of_bands", std::to_string(number_of_bands)); - config->set_property("InputFilter.band1_begin", std::to_string(band1_begin)); - config->set_property("InputFilter.band1_end", std::to_string(band1_end)); - config->set_property("InputFilter.band2_begin", std::to_string(band2_begin)); - config->set_property("InputFilter.band2_end", std::to_string(band2_end)); - config->set_property("InputFilter.ampl1_begin", std::to_string(ampl1_begin)); - config->set_property("InputFilter.ampl1_end", std::to_string(ampl1_end)); - config->set_property("InputFilter.ampl2_begin", std::to_string(ampl2_begin)); - config->set_property("InputFilter.ampl2_end", std::to_string(ampl2_end)); - config->set_property("InputFilter.band1_error", std::to_string(band1_error)); - config->set_property("InputFilter.band2_error", std::to_string(band2_error)); - config->set_property("InputFilter.filter_type", "bandpass"); - config->set_property("InputFilter.grid_density", std::to_string(grid_density)); - config->set_property("InputFilter.sampling_frequency", std::to_string(sampling_rate_internal)); - config->set_property("InputFilter.IF", std::to_string(zero)); - config->set_property("Resampler.implementation", "Pass_Through"); - config->set_property("Resampler.dump", "false"); - config->set_property("Resampler.item_type", "gr_complex"); - config->set_property("Resampler.sample_freq_in", std::to_string(sampling_rate_internal)); - config->set_property("Resampler.sample_freq_out", std::to_string(sampling_rate_internal)); - - // Set the number of Channels - config->set_property("Channels_1C.count", std::to_string(number_of_channels)); - config->set_property("Channels.in_acquisition", std::to_string(in_acquisition)); - config->set_property("Channel.signal", "1C"); - - // Set Acquisition - config->set_property("Acquisition_1C.implementation", "GPS_L1_CA_PCPS_Tong_Acquisition"); - config->set_property("Acquisition_1C.item_type", "gr_complex"); - config->set_property("Acquisition_1C.if", std::to_string(zero)); - config->set_property("Acquisition_1C.coherent_integration_time_ms", std::to_string(coherent_integration_time_ms)); - config->set_property("Acquisition_1C.threshold", std::to_string(threshold)); - config->set_property("Acquisition_1C.doppler_max", std::to_string(doppler_max)); - config->set_property("Acquisition_1C.doppler_step", std::to_string(doppler_step)); - config->set_property("Acquisition_1C.bit_transition_flag", "false"); - config->set_property("Acquisition_1C.max_dwells", std::to_string(max_dwells)); - config->set_property("Acquisition_1C.tong_init_val", std::to_string(tong_init_val)); - config->set_property("Acquisition_1C.tong_max_val", std::to_string(tong_max_val)); - config->set_property("Acquisition_1C.tong_max_dwells", std::to_string(tong_max_dwells)); - - // Set Tracking - config->set_property("Tracking_1C.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - //config->set_property("Tracking_1C.implementation", "GPS_L1_CA_DLL_PLL_C_Aid_Tracking"); - config->set_property("Tracking_1C.item_type", "gr_complex"); - config->set_property("Tracking_1C.if", std::to_string(zero)); - config->set_property("Tracking_1C.dump", "false"); - config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); - config->set_property("Tracking_1C.pll_bw_hz", std::to_string(pll_bw_hz)); - config->set_property("Tracking_1C.dll_bw_hz", std::to_string(dll_bw_hz)); - config->set_property("Tracking_1C.early_late_space_chips", std::to_string(early_late_space_chips)); - - config->set_property("Tracking_1C.pll_bw_narrow_hz", std::to_string(pll_bw_narrow_hz)); - config->set_property("Tracking_1C.dll_bw_narrow_hz", std::to_string(dll_bw_narrow_hz)); - config->set_property("Tracking_1C.extend_correlation_ms", std::to_string(extend_correlation_ms)); - - // Set Telemetry - config->set_property("TelemetryDecoder_1C.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C.dump", "false"); - config->set_property("TelemetryDecoder_1C.decimation_factor", std::to_string(decimation_factor)); - - // Set Observables - config->set_property("Observables.implementation", "Hybrid_Observables"); - config->set_property("Observables.dump", "false"); - config->set_property("Observables.dump_filename", "./observables.dat"); - config->set_property("Observables.averaging_depth", std::to_string(100)); - - // Set PVT - config->set_property("PVT.implementation", "RTKLIB_PVT"); - config->set_property("PVT.output_rate_ms", std::to_string(output_rate_ms)); - config->set_property("PVT.display_rate_ms", std::to_string(display_rate_ms)); - config->set_property("PVT.dump_filename", "./PVT"); - config->set_property("PVT.nmea_dump_filename", "./gnss_sdr_pvt.nmea"); - config->set_property("PVT.flag_nmea_tty_port", "false"); - config->set_property("PVT.nmea_dump_devname", "/dev/pts/4"); - config->set_property("PVT.flag_rtcm_server", "false"); - config->set_property("PVT.flag_rtcm_tty_port", "false"); - config->set_property("PVT.rtcm_dump_devname", "/dev/pts/1"); - config->set_property("PVT.dump", "false"); - config->set_property("PVT.rinex_version", std::to_string(2)); - - return 0; -} - - -int ObsGpsL1SystemTest::run_receiver() -{ - std::shared_ptr control_thread; - control_thread = std::make_shared(config); - // start receiver - try - { - control_thread->run(); - } - catch (const boost::exception& e) - { - std::cout << "Boost exception: " << boost::diagnostic_information(e); - } - catch (const std::exception& ex) - { - std::cout << "STD exception: " << ex.what(); - } - // Get the name of the RINEX obs file generated by the receiver - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - FILE* fp; - std::string argum2 = std::string("/bin/ls *O | grep GSDR | tail -1"); - char buffer[1035]; - fp = popen(&argum2[0], "r"); - if (fp == NULL) - { - std::cout << "Failed to run command: " << argum2 << std::endl; - return -1; - } - while (fgets(buffer, sizeof(buffer), fp) != NULL) - { - std::string aux = std::string(buffer); - ObsGpsL1SystemTest::generated_rinex_obs = aux.erase(aux.length() - 1, 1); - } - pclose(fp); - return 0; -} - - -void ObsGpsL1SystemTest::check_results() -{ - std::vector>> pseudorange_ref(33); - std::vector>> carrierphase_ref(33); - std::vector>> doppler_ref(33); - - std::vector>> pseudorange_meas(33); - std::vector>> carrierphase_meas(33); - std::vector>> doppler_meas(33); - - // Open and read reference RINEX observables file - try - { - gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs); - r_ref.exceptions(std::ios::failbit); - gpstk::Rinex3ObsData r_ref_data; - gpstk::Rinex3ObsHeader r_ref_header; - - gpstk::RinexDatum dataobj; - - r_ref >> r_ref_header; - - while (r_ref >> r_ref_data) - { - for (int myprn = 1; myprn < 33; myprn++) - { - gpstk::SatID prn(myprn, gpstk::SatID::systemGPS); - gpstk::CommonTime time = r_ref_data.time; - double sow(static_cast(time).sow); - - gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn); - if (pointer == r_ref_data.obs.end()) - { - // PRN not present; do nothing - } - else - { - dataobj = r_ref_data.getObs(prn, "C1C", r_ref_header); - double P1 = dataobj.data; - std::pair pseudo(sow, P1); - pseudorange_ref.at(myprn).push_back(pseudo); - - dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header); - double L1 = dataobj.data; - std::pair carrier(sow, L1); - carrierphase_ref.at(myprn).push_back(carrier); - - dataobj = r_ref_data.getObs(prn, "D1C", r_ref_header); - double D1 = dataobj.data; - std::pair doppler(sow, D1); - doppler_ref.at(myprn).push_back(doppler); - } // End of 'if( pointer == roe.obs.end() )' - } // end for - } // end while - } // End of 'try' block - catch (const gpstk::FFStreamError& e) - { - std::cout << e; - exit(1); - } - catch (const gpstk::Exception& e) - { - std::cout << e; - exit(1); - } - catch (...) - { - std::cout << "unknown error. I don't feel so well..." << std::endl; - exit(1); - } - - try - { - std::string arg2_gen = std::string("./") + ObsGpsL1SystemTest::generated_rinex_obs; - gpstk::Rinex3ObsStream r_meas(arg2_gen); - r_meas.exceptions(std::ios::failbit); - gpstk::Rinex3ObsData r_meas_data; - gpstk::Rinex3ObsHeader r_meas_header; - gpstk::RinexDatum dataobj; - - r_meas >> r_meas_header; - - while (r_meas >> r_meas_data) - { - for (int myprn = 1; myprn < 33; myprn++) - { - gpstk::SatID prn(myprn, gpstk::SatID::systemGPS); - gpstk::CommonTime time = r_meas_data.time; - double sow(static_cast(time).sow); - - gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn); - if (pointer == r_meas_data.obs.end()) - { - // PRN not present; do nothing - } - else - { - dataobj = r_meas_data.getObs(prn, "C1C", r_meas_header); - double P1 = dataobj.data; - std::pair pseudo(sow, P1); - pseudorange_meas.at(myprn).push_back(pseudo); - - dataobj = r_meas_data.getObs(prn, "L1C", r_meas_header); - double L1 = dataobj.data; - std::pair carrier(sow, L1); - carrierphase_meas.at(myprn).push_back(carrier); - - dataobj = r_meas_data.getObs(prn, "D1C", r_meas_header); - double D1 = dataobj.data; - std::pair doppler(sow, D1); - doppler_meas.at(myprn).push_back(doppler); - } // End of 'if( pointer == roe.obs.end() )' - } // end for - } // end while - } // End of 'try' block - catch (const gpstk::FFStreamError& e) - { - std::cout << e; - exit(1); - } - catch (const gpstk::Exception& e) - { - std::cout << e; - exit(1); - } - catch (...) - { - std::cout << "unknown error. I don't feel so well..." << std::endl; - exit(1); - } - - // Time alignment - std::vector>> pseudorange_ref_aligned(33); - std::vector>> carrierphase_ref_aligned(33); - std::vector>> doppler_ref_aligned(33); - - std::vector>>::iterator iter; - std::vector>::iterator it; - std::vector>::iterator it2; - - std::vector> pr_diff(33); - std::vector> cp_diff(33); - std::vector> doppler_diff(33); - - std::vector>::iterator iter_diff; - std::vector::iterator iter_v; - - int prn_id = 0; - for (iter = pseudorange_ref.begin(); iter != pseudorange_ref.end(); iter++) - { - for (it = iter->begin(); it != iter->end(); it++) - { - // If a measure exists for this sow, store it - for (it2 = pseudorange_meas.at(prn_id).begin(); it2 != pseudorange_meas.at(prn_id).end(); it2++) - { - if (std::abs(it->first - it2->first) < 0.1) // store measures closer than 10 ms. - { - pseudorange_ref_aligned.at(prn_id).push_back(*it); - pr_diff.at(prn_id).push_back(it->second - it2->second); - //std::cout << "Sat " << prn_id << ": " << "PR_ref=" << it->second << " PR_meas=" << it2->second << " Diff:" << it->second - it2->second << std::endl; - } - } - } - prn_id++; - } - - prn_id = 0; - for (iter = carrierphase_ref.begin(); iter != carrierphase_ref.end(); iter++) - { - for (it = iter->begin(); it != iter->end(); it++) - { - // If a measure exists for this sow, store it - for (it2 = carrierphase_meas.at(prn_id).begin(); it2 != carrierphase_meas.at(prn_id).end(); it2++) - { - if (std::abs(it->first - it2->first) < 0.1) // store measures closer than 10 ms. - { - carrierphase_ref_aligned.at(prn_id).push_back(*it); - cp_diff.at(prn_id).push_back(it->second - it2->second); - // std::cout << "Sat " << prn_id << ": " << "Carrier_ref=" << it->second << " Carrier_meas=" << it2->second << " Diff:" << it->second - it2->second << std::endl; - } - } - } - prn_id++; - } - prn_id = 0; - for (iter = doppler_ref.begin(); iter != doppler_ref.end(); iter++) - { - for (it = iter->begin(); it != iter->end(); it++) - { - // If a measure exists for this sow, store it - for (it2 = doppler_meas.at(prn_id).begin(); it2 != doppler_meas.at(prn_id).end(); it2++) - { - if (std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. - { - doppler_ref_aligned.at(prn_id).push_back(*it); - doppler_diff.at(prn_id).push_back(it->second - it2->second); - } - } - } - prn_id++; - } - - // Compute pseudorange error - prn_id = 0; - std::vector mean_pr_diff_v; - for (iter_diff = pr_diff.begin(); iter_diff != pr_diff.end(); iter_diff++) - { - // For each satellite with reference and measurements aligned in time - int number_obs = 0; - double mean_diff = 0.0; - for (iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) - { - mean_diff = mean_diff + *iter_v; - number_obs = number_obs + 1; - } - if (number_obs > 0) - { - mean_diff = mean_diff / number_obs; - mean_pr_diff_v.push_back(mean_diff); - std::cout << "-- Mean pseudorange difference for sat " << prn_id << ": " << mean_diff; - double stdev_ = compute_stdev(*iter_diff); - std::cout << " +/- " << stdev_; - std::cout << " [m]" << std::endl; - } - else - { - mean_diff = 0.0; - } - - prn_id++; - } - double stdev_pr = compute_stdev(mean_pr_diff_v); - std::cout << "Pseudorange diff error stdev = " << stdev_pr << " [m]" << std::endl; - ASSERT_LT(stdev_pr, 10.0); - - // Compute carrier phase error - prn_id = 0; - std::vector mean_cp_diff_v; - for (iter_diff = cp_diff.begin(); iter_diff != cp_diff.end(); iter_diff++) - { - // For each satellite with reference and measurements aligned in time - int number_obs = 0; - double mean_diff = 0.0; - for (iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) - { - mean_diff = mean_diff + *iter_v; - number_obs = number_obs + 1; - } - if (number_obs > 0) - { - mean_diff = mean_diff / number_obs; - mean_cp_diff_v.push_back(mean_diff); - std::cout << "-- Mean carrier phase difference for sat " << prn_id << ": " << mean_diff; - double stdev_pr_ = compute_stdev(*iter_diff); - std::cout << " +/- " << stdev_pr_ << " whole cycles (19 cm)" << std::endl; - } - else - { - mean_diff = 0.0; - } - - prn_id++; - } - - // Compute Doppler error - prn_id = 0; - std::vector mean_doppler_v; - for (iter_diff = doppler_diff.begin(); iter_diff != doppler_diff.end(); iter_diff++) - { - // For each satellite with reference and measurements aligned in time - int number_obs = 0; - double mean_diff = 0.0; - for (iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) - { - //std::cout << *iter_v << std::endl; - mean_diff = mean_diff + *iter_v; - number_obs = number_obs + 1; - } - if (number_obs > 0) - { - mean_diff = mean_diff / number_obs; - mean_doppler_v.push_back(mean_diff); - std::cout << "-- Mean Doppler difference for sat " << prn_id << ": " << mean_diff << " [Hz]" << std::endl; - } - else - { - mean_diff = 0.0; - } - - prn_id++; - } - - double stdev_dp = compute_stdev(mean_doppler_v); - std::cout << "Doppler error stdev = " << stdev_dp << " [Hz]" << std::endl; - ASSERT_LT(stdev_dp, 10.0); -} - - -TEST_F(ObsGpsL1SystemTest, Observables_system_test) -{ - std::cout << "Validating input RINEX nav file: " << FLAGS_rinex_nav_file << " ..." << std::endl; - bool is_rinex_nav_valid = check_valid_rinex_nav(FLAGS_rinex_nav_file); - EXPECT_EQ(true, is_rinex_nav_valid) << "The RINEX navigation file " << FLAGS_rinex_nav_file << " is not well formed."; - std::cout << "The file is valid." << std::endl; - - // Configure the signal generator - configure_generator(); - - // Generate signal raw signal samples and observations RINEX file - if (!FLAGS_disable_generator) - { - generate_signal(); - } - - std::cout << "Validating generated reference RINEX obs file: " << FLAGS_filename_rinex_obs << " ..." << std::endl; - bool is_gen_rinex_obs_valid = check_valid_rinex_obs("./" + FLAGS_filename_rinex_obs); - EXPECT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << FLAGS_filename_rinex_obs << ", generated by gnss-sim, is not well formed."; - std::cout << "The file is valid." << std::endl; - - // Configure receiver - configure_receiver(); - - // Run the receiver - EXPECT_EQ(run_receiver(), 0) << "Problem executing the software-defined signal generator"; - - std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << ObsGpsL1SystemTest::generated_rinex_obs << " ..." << std::endl; - is_gen_rinex_obs_valid = check_valid_rinex_obs("./" + ObsGpsL1SystemTest::generated_rinex_obs); - EXPECT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << ObsGpsL1SystemTest::generated_rinex_obs << ", generated by GNSS-SDR, is not well formed."; - std::cout << "The file is valid." << std::endl; - - // Check results - check_results(); -} - - -int main(int argc, char** argv) -{ - std::cout << "Running Observables validation test..." << std::endl; - int res = 0; - try - { - testing::InitGoogleTest(&argc, argv); - } - catch (...) - { - } // catch the "testing::internal::::ClassUniqueToAlwaysTrue" from gtest - - google::ParseCommandLineFlags(&argc, &argv, true); - google::InitGoogleLogging(argv[0]); - - // Run the Tests - try - { - res = RUN_ALL_TESTS(); - } - catch (...) - { - LOG(WARNING) << "Unexpected catch"; - } - google::ShutDownCommandLineFlags(); - return res; -} diff --git a/src/tests/system-tests/obs_system_test.cc b/src/tests/system-tests/obs_system_test.cc deleted file mode 100644 index 2ce3bea48..000000000 --- a/src/tests/system-tests/obs_system_test.cc +++ /dev/null @@ -1,1030 +0,0 @@ -/*! - * \file obs_system_test.cc - * \brief This class implements a test for the validation of generated observables. - * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es - * Antonio Ramos, 2017. antonio.ramos(at)cttc.es - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include "gnuplot_i.h" -#include "test_flags.h" -#include "concurrent_map.h" -#include "concurrent_queue.h" -#include "control_thread.h" -#include "file_configuration.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -// For GPS NAVIGATION (L1) -concurrent_queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; - -DEFINE_string(configuration_file, "./default_configuration.conf", "Path of configuration file"); -DEFINE_string(filename_rinex_true, "./default_rinex.txt", "Path of RINEX true observations"); -DEFINE_string(filename_rinex_obs, "default_string", "Path of RINEX true observations"); -DEFINE_double(pr_error_mean_max, 25.0, "Maximum mean error in pseudorange"); -DEFINE_double(pr_error_std_max, 15.0, "Maximum standard deviation in pseudorange"); -DEFINE_double(cp_error_mean_max, 5.0, "Maximum mean error in carrier phase"); -DEFINE_double(cp_error_std_max, 2.5, "Maximum standard deviation in carrier phase"); -DEFINE_double(dp_error_mean_max, 75.0, "Maximum mean error in Doppler frequency"); -DEFINE_double(dp_error_std_max, 25.0, "Maximum standard deviation in Doppler frequency"); -DEFINE_bool(plot_obs_sys_test, false, "Plots results of ObsSystemTest with gnuplot"); - -class ObsSystemTest : public ::testing::Test -{ -public: - int configure_receiver(); - int run_receiver(); - void check_results(); - bool check_valid_rinex_obs(std::string filename, int rinex_ver); // return true if the file is a valid Rinex observation file. - void read_rinex_files( - std::vector& pseudorange_ref, - std::vector& carrierphase_ref, - std::vector& doppler_ref, - std::vector& pseudorange_meas, - std::vector& carrierphase_meas, - std::vector& doppler_meas, - arma::mat& sow_prn_ref, - int signal_type); - void time_alignment_diff( - std::vector& ref, - std::vector& meas, - std::vector& diff); - void time_alignment_diff_cp( - std::vector& ref, - std::vector& meas, - std::vector& diff); - void time_alignment_diff_pr( - std::vector& ref, - std::vector& meas, - std::vector& diff, - arma::mat& sow_prn_ref); - void compute_pseudorange_error(std::vector& diff, - double error_th_mean, double error_th_std, - std::string signal_name); - void compute_carrierphase_error( - std::vector& diff, - double error_th_mean, double error_th_std, - std::string signal_name); - void compute_doppler_error( - std::vector& diff, - double error_th_mean, double error_th_std, - std::string signal_name); - std::string filename_rinex_obs = FLAGS_filename_rinex_true; - std::string generated_rinex_obs = FLAGS_filename_rinex_obs; - std::string configuration_file_ = FLAGS_configuration_file; - std::shared_ptr config; - bool gps_1C = false; - bool gps_L5 = false; - bool gal_1B = false; - bool gal_E5a = false; - bool internal_rinex_generation = false; - - /****************/ - const int num_prn_gps = 33; - const int num_prn_gal = 31; - - double pseudorange_error_th_mean = FLAGS_pr_error_mean_max; - double pseudorange_error_th_std = FLAGS_pr_error_std_max; - double carrierphase_error_th_mean = FLAGS_cp_error_mean_max; - double carrierphase_error_th_std = FLAGS_cp_error_std_max; - double doppler_error_th_mean = FLAGS_dp_error_mean_max; - double doppler_error_th_std = FLAGS_dp_error_std_max; -}; - - -bool ObsSystemTest::check_valid_rinex_obs(std::string filename, int rinex_ver) -{ - bool res = false; - if (rinex_ver == 2) - { - res = gpstk::isRinexObsFile(filename); - } - if (rinex_ver == 3) - { - res = gpstk::isRinex3ObsFile(filename); - } - return res; -} - - -void ObsSystemTest::read_rinex_files( - std::vector& pseudorange_ref, - std::vector& carrierphase_ref, - std::vector& doppler_ref, - std::vector& pseudorange_meas, - std::vector& carrierphase_meas, - std::vector& doppler_meas, - arma::mat& sow_prn_ref, - int signal_type) -{ - bool ref_exist = false; - bool meas_exist = false; - gpstk::SatID::SatelliteSystem sat_type = gpstk::SatID::systemUnknown; - int max_prn = 0; - std::string pr_string; - std::string cp_string; - std::string dp_string; - std::string signal_type_string; - sow_prn_ref.reset(); - - switch (signal_type) - { - case 0: //GPS L1 - - sat_type = gpstk::SatID::systemGPS; - max_prn = num_prn_gps; - pr_string = "C1C"; - cp_string = "L1C"; - dp_string = "D1C"; - signal_type_string = "GPS L1 C/A"; - break; - - case 1: //Galileo E1B - - sat_type = gpstk::SatID::systemGalileo; - max_prn = num_prn_gal; - pr_string = "C1B"; - cp_string = "L1B"; - dp_string = "D1B"; - signal_type_string = "Galileo E1B"; - break; - - case 2: //GPS L5 - - sat_type = gpstk::SatID::systemGPS; - max_prn = num_prn_gps; - pr_string = "C5X"; - cp_string = "L5X"; - dp_string = "D5X"; - signal_type_string = "GPS L5"; - break; - - case 3: //Galileo E5a - - sat_type = gpstk::SatID::systemGalileo; - max_prn = num_prn_gal; - pr_string = "C5X"; - cp_string = "L5X"; - dp_string = "D5X"; - signal_type_string = "Galileo E5a"; - break; - } - - // Open and read reference RINEX observables file - std::cout << "Read: RINEX " << signal_type_string << " True" << std::endl; - try - { - gpstk::Rinex3ObsStream r_ref(filename_rinex_obs); - r_ref.exceptions(std::ios::failbit); - gpstk::Rinex3ObsData r_ref_data; - gpstk::Rinex3ObsHeader r_ref_header; - gpstk::RinexDatum dataobj; - r_ref >> r_ref_header; - - while (r_ref >> r_ref_data) - { - for (int myprn = 1; myprn < max_prn; myprn++) - { - gpstk::SatID prn(myprn, sat_type); - gpstk::CommonTime time = r_ref_data.time; - double sow(static_cast(time).sow); - gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn); - if (pointer == r_ref_data.obs.end()) - { - // PRN not present; do nothing - } - else - { - dataobj = r_ref_data.getObs(prn, pr_string, r_ref_header); - double P1 = dataobj.data; - pseudorange_ref.at(myprn).insert_rows(pseudorange_ref.at(myprn).n_rows, arma::rowvec({sow, P1})); - - dataobj = r_ref_data.getObs(prn, cp_string, r_ref_header); - double L1 = dataobj.data; - carrierphase_ref.at(myprn).insert_rows(carrierphase_ref.at(myprn).n_rows, arma::rowvec({sow, L1})); - - dataobj = r_ref_data.getObs(prn, dp_string, r_ref_header); - double D1 = dataobj.data; - doppler_ref.at(myprn).insert_rows(doppler_ref.at(myprn).n_rows, arma::rowvec({sow, D1})); - - ref_exist = true; - } // End of 'if( pointer == roe.obs.end() )' - } // end for - } // end while - } // End of 'try' block - catch (const gpstk::FFStreamError& e) - { - std::cout << e; - exit(1); - } - catch (const gpstk::Exception& e) - { - std::cout << e; - exit(1); - } - catch (...) - { - std::cout << "unknown error. I don't feel so well..." << std::endl; - exit(1); - } - - // Open and read measured RINEX observables file - std::cout << "Read: RINEX " << signal_type_string << " measures" << std::endl; - try - { - std::string arg2_gen; - if (internal_rinex_generation) - { - arg2_gen = std::string("./") + generated_rinex_obs; - } - else - { - arg2_gen = generated_rinex_obs; - } - gpstk::Rinex3ObsStream r_meas(arg2_gen); - r_meas.exceptions(std::ios::failbit); - gpstk::Rinex3ObsData r_meas_data; - gpstk::Rinex3ObsHeader r_meas_header; - gpstk::RinexDatum dataobj; - r_meas >> r_meas_header; - - while (r_meas >> r_meas_data) - { - double pr_min = 0.0; - double sow_insert = 0.0; - double prn_min = 0.0; - bool set_pr_min = true; - for (int myprn = 1; myprn < max_prn; myprn++) - { - gpstk::SatID prn(myprn, sat_type); - gpstk::CommonTime time = r_meas_data.time; - double sow(static_cast(time).sow); - gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn); - if (pointer == r_meas_data.obs.end()) - { - // PRN not present; do nothing - } - else - { - dataobj = r_meas_data.getObs(prn, pr_string, r_meas_header); - double P1 = dataobj.data; - pseudorange_meas.at(myprn).insert_rows(pseudorange_meas.at(myprn).n_rows, arma::rowvec({sow, P1})); - if (set_pr_min || (P1 < pr_min)) - { - set_pr_min = false; - pr_min = P1; - sow_insert = sow; - prn_min = static_cast(myprn); - } - - dataobj = r_meas_data.getObs(prn, cp_string, r_meas_header); - double L1 = dataobj.data; - carrierphase_meas.at(myprn).insert_rows(carrierphase_meas.at(myprn).n_rows, arma::rowvec({sow, L1})); - - dataobj = r_meas_data.getObs(prn, dp_string, r_meas_header); - double D1 = dataobj.data; - doppler_meas.at(myprn).insert_rows(doppler_meas.at(myprn).n_rows, arma::rowvec({sow, D1})); - - meas_exist = true; - } // End of 'if( pointer == roe.obs.end() )' - } // end for - if (!set_pr_min) - { - sow_prn_ref.insert_rows(sow_prn_ref.n_rows, arma::rowvec({sow_insert, pr_min, prn_min})); - } - } // end while - } // End of 'try' block - catch (const gpstk::FFStreamError& e) - { - std::cout << e; - exit(1); - } - catch (const gpstk::Exception& e) - { - std::cout << e; - exit(1); - } - catch (...) - { - std::cout << "unknown error. I don't feel so well..." << std::endl; - exit(1); - } - EXPECT_TRUE(ref_exist) << "RINEX reference file does not contain " << signal_type_string << " information"; - EXPECT_TRUE(meas_exist) << "RINEX generated file does not contain " << signal_type_string << " information"; -} - - -void ObsSystemTest::time_alignment_diff( - std::vector& ref, - std::vector& meas, - std::vector& diff) -{ - std::vector::iterator iter_ref; - std::vector::iterator iter_meas; - std::vector::iterator iter_diff; - arma::mat mat_aux; - - iter_ref = ref.begin(); - iter_diff = diff.begin(); - for (iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++) - { - if (!iter_meas->is_empty() && !iter_ref->is_empty()) - { - arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0)); - arma::uword index_min = arma::min(index_); - index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0)); - arma::uword index_max = arma::max(index_); - mat_aux = iter_meas->rows(index_min, index_max); - arma::vec ref_aligned; - arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned); - *iter_diff = ref_aligned - mat_aux.col(1); - } - iter_ref++; - iter_diff++; - } -} - - -void ObsSystemTest::time_alignment_diff_cp( - std::vector& ref, - std::vector& meas, - std::vector& diff) -{ - std::vector::iterator iter_ref; - std::vector::iterator iter_meas; - std::vector::iterator iter_diff; - arma::mat mat_aux; - - iter_ref = ref.begin(); - iter_diff = diff.begin(); - for (iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++) - { - if (!iter_meas->is_empty() && !iter_ref->is_empty()) - { - arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0)); - arma::uword index_min = arma::min(index_); - index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0)); - arma::uword index_max = arma::max(index_); - mat_aux = iter_meas->rows(index_min, index_max); - mat_aux.col(1) -= mat_aux.col(1)(0); - arma::vec ref_aligned; - arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned); - ref_aligned -= ref_aligned(0); - *iter_diff = ref_aligned - mat_aux.col(1); - } - iter_ref++; - iter_diff++; - } -} - - -void ObsSystemTest::time_alignment_diff_pr( - std::vector& ref, - std::vector& meas, - std::vector& diff, - arma::mat& sow_prn_ref) -{ - std::vector::iterator iter_ref; - std::vector::iterator iter_meas; - std::vector::iterator iter_diff; - arma::mat mat_aux; - arma::vec subtraction_meas; - arma::vec subtraction_ref; - - arma::mat subtraction_pr_ref = sow_prn_ref; - arma::vec::iterator iter_vec0 = subtraction_pr_ref.begin_col(0); - arma::vec::iterator iter_vec1 = subtraction_pr_ref.begin_col(1); - arma::vec::iterator iter_vec2 = subtraction_pr_ref.begin_col(2); - - for (iter_vec1 = subtraction_pr_ref.begin_col(1); iter_vec1 != subtraction_pr_ref.end_col(1); iter_vec1++) - { - arma::vec aux_pr; //vector with only 1 element - arma::vec aux_sow = {*iter_vec0}; //vector with only 1 element - arma::interp1(ref.at(static_cast(*iter_vec2)).col(0), - ref.at(static_cast(*iter_vec2)).col(1), - aux_sow, - aux_pr); - *iter_vec1 = aux_pr(0); - iter_vec0++; - iter_vec2++; - } - - iter_ref = ref.begin(); - iter_diff = diff.begin(); - for (iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++) - { - if (!iter_meas->is_empty() && !iter_ref->is_empty()) - { - arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0)); - arma::uword index_min = arma::min(index_); - index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0)); - arma::uword index_max = arma::max(index_); - mat_aux = iter_meas->rows(index_min, index_max); - arma::interp1(sow_prn_ref.col(0), sow_prn_ref.col(1), mat_aux.col(0), subtraction_meas); - mat_aux.col(1) -= subtraction_meas; - arma::vec ref_aligned; - arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned); - arma::interp1(subtraction_pr_ref.col(0), subtraction_pr_ref.col(1), mat_aux.col(0), subtraction_ref); - ref_aligned -= subtraction_ref; - *iter_diff = ref_aligned - mat_aux.col(1); - } - iter_ref++; - iter_diff++; - } -} - - -int ObsSystemTest::configure_receiver() -{ - config = std::make_shared(configuration_file_); - - if (config->property("Channels_1C.count", 0) > 0) - { - gps_1C = true; - } - if (config->property("Channels_1B.count", 0) > 0) - { - gal_1B = true; - } - if (config->property("Channels_5X.count", 0) > 0) - { - gal_E5a = true; - } - if (config->property("Channels_7X.count", 0) > 0) //NOT DEFINITIVE!!!!! - { - gps_L5 = true; - } - - return 0; -} - - -int ObsSystemTest::run_receiver() -{ - std::shared_ptr control_thread; - control_thread = std::make_shared(config); - // start receiver - try - { - control_thread->run(); - } - catch (const boost::exception& e) - { - std::cout << "Boost exception: " << boost::diagnostic_information(e); - } - catch (const std::exception& ex) - { - std::cout << "STD exception: " << ex.what(); - } - // Get the name of the RINEX obs file generated by the receiver - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - FILE* fp; - std::string argum2 = std::string("/bin/ls *O | grep GSDR | tail -1"); - char buffer[1035]; - fp = popen(&argum2[0], "r"); - if (fp == NULL) - { - std::cout << "Failed to run command: " << argum2 << std::endl; - return -1; - } - while (fgets(buffer, sizeof(buffer), fp) != NULL) - { - std::string aux = std::string(buffer); - generated_rinex_obs = aux.erase(aux.length() - 1, 1); - internal_rinex_generation = true; - } - pclose(fp); - return 0; -} - - -void ObsSystemTest::compute_pseudorange_error( - std::vector& diff, - double error_th_mean, double error_th_std, - std::string signal_name) -{ - int prn_id = 0; - std::vector::iterator iter_diff; - std::vector means; - std::vector stddevs; - std::vector prns; - for (iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) - { - if (!iter_diff->is_empty()) - { - while (iter_diff->has_nan()) - { - bool nan_found = false; - int k_aux = 0; - while (!nan_found) - { - if (!iter_diff->row(k_aux).is_finite()) - { - nan_found = true; - iter_diff->shed_row(k_aux); - } - k_aux++; - } - } - double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff))); - means.push_back(d_mean); - double d_stddev = arma::stddev(*iter_diff); - stddevs.push_back(d_stddev); - prns.push_back(static_cast(prn_id)); - std::cout << "-- RMS pseudorange difference for sat " << prn_id << ": " << d_mean; - std::cout << ". Std. dev.: " << d_stddev; - std::cout << " [m]" << std::endl; - EXPECT_LT(d_mean, error_th_mean); - EXPECT_LT(d_stddev, error_th_std); - } - prn_id++; - } - if (FLAGS_plot_obs_sys_test == true) - { - const std::string gnuplot_executable(FLAGS_gnuplot_executable); - if (gnuplot_executable.empty()) - { - std::cout << "WARNING: Although the flag plot_obs_sys_test has been set to TRUE," << std::endl; - std::cout << "gnuplot has not been found in your system." << std::endl; - std::cout << "Test results will not be plotted." << std::endl; - } - else - { - try - { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); - Gnuplot::set_GNUPlotPath(gnuplot_path); - - Gnuplot g1("linespoints"); - g1.set_title(signal_name + " Pseudorange error"); - g1.set_grid(); - g1.set_xlabel("PRN"); - g1.set_ylabel("Pseudorange error [m]"); - g1.plot_xy(prns, means, "RMS error"); - g1.plot_xy(prns, stddevs, "Standard deviation"); - size_t char_pos = signal_name.find(" "); - while (char_pos != std::string::npos) - { - signal_name.replace(char_pos, 1, "_"); - char_pos = signal_name.find(" "); - } - char_pos = signal_name.find("/"); - while (char_pos != std::string::npos) - { - signal_name.replace(char_pos, 1, "_"); - char_pos = signal_name.find("/"); - } - g1.savetops("Pseudorange_error_" + signal_name); - g1.savetopdf("Pseudorange_error_" + signal_name, 18); - g1.showonscreen(); // window output - } - catch (const GnuplotException& ge) - { - std::cout << ge.what() << std::endl; - } - } - } -} - - -void ObsSystemTest::compute_carrierphase_error( - std::vector& diff, - double error_th_mean, double error_th_std, - std::string signal_name) -{ - int prn_id = 0; - std::vector means; - std::vector stddevs; - std::vector prns; - std::vector::iterator iter_diff; - for (iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) - { - if (!iter_diff->is_empty()) - { - while (iter_diff->has_nan()) - { - bool nan_found = false; - int k_aux = 0; - while (!nan_found) - { - if (!iter_diff->row(k_aux).is_finite()) - { - nan_found = true; - iter_diff->shed_row(k_aux); - } - k_aux++; - } - } - double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff))); - means.push_back(d_mean); - double d_stddev = arma::stddev(*iter_diff); - stddevs.push_back(d_stddev); - prns.push_back(static_cast(prn_id)); - std::cout << "-- RMS carrier phase difference for sat " << prn_id << ": " << d_mean; - std::cout << ". Std. dev.: " << d_stddev; - std::cout << " whole cycles" << std::endl; - EXPECT_LT(d_mean, error_th_mean); - EXPECT_LT(d_stddev, error_th_std); - } - prn_id++; - } - if (FLAGS_plot_obs_sys_test == true) - { - const std::string gnuplot_executable(FLAGS_gnuplot_executable); - if (gnuplot_executable.empty()) - { - std::cout << "WARNING: Although the flag plot_obs_sys_test has been set to TRUE," << std::endl; - std::cout << "gnuplot has not been found in your system." << std::endl; - std::cout << "Test results will not be plotted." << std::endl; - } - else - { - try - { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); - Gnuplot::set_GNUPlotPath(gnuplot_path); - - Gnuplot g1("linespoints"); - g1.set_title(signal_name + " Carrier phase error"); - g1.set_grid(); - g1.set_xlabel("PRN"); - g1.set_ylabel("Carrier phase error [whole cycles]"); - g1.plot_xy(prns, means, "RMS error"); - g1.plot_xy(prns, stddevs, "Standard deviation"); - size_t char_pos = signal_name.find(" "); - while (char_pos != std::string::npos) - { - signal_name.replace(char_pos, 1, "_"); - char_pos = signal_name.find(" "); - } - char_pos = signal_name.find("/"); - while (char_pos != std::string::npos) - { - signal_name.replace(char_pos, 1, "_"); - char_pos = signal_name.find("/"); - } - g1.savetops("Carrier_phase_error_" + signal_name); - g1.savetopdf("Carrier_phase_error_" + signal_name, 18); - g1.showonscreen(); // window output - } - catch (const GnuplotException& ge) - { - std::cout << ge.what() << std::endl; - } - } - } -} - - -void ObsSystemTest::compute_doppler_error( - std::vector& diff, - double error_th_mean, double error_th_std, - std::string signal_name) -{ - int prn_id = 0; - std::vector means; - std::vector stddevs; - std::vector prns; - std::vector::iterator iter_diff; - for (iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) - { - if (!iter_diff->is_empty()) - { - while (iter_diff->has_nan()) - { - bool nan_found = false; - int k_aux = 0; - while (!nan_found) - { - if (!iter_diff->row(k_aux).is_finite()) - { - nan_found = true; - iter_diff->shed_row(k_aux); - } - k_aux++; - } - } - double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff))); - means.push_back(d_mean); - double d_stddev = arma::stddev(*iter_diff); - stddevs.push_back(d_stddev); - prns.push_back(static_cast(prn_id)); - std::cout << "-- RMS Doppler difference for sat " << prn_id << ": " << d_mean; - std::cout << ". Std. dev.: " << d_stddev; - std::cout << " [Hz]" << std::endl; - EXPECT_LT(d_mean, error_th_mean); - EXPECT_LT(d_stddev, error_th_std); - } - prn_id++; - } - if (FLAGS_plot_obs_sys_test == true) - { - const std::string gnuplot_executable(FLAGS_gnuplot_executable); - if (gnuplot_executable.empty()) - { - std::cout << "WARNING: Although the flag plot_obs_sys_test has been set to TRUE," << std::endl; - std::cout << "gnuplot has not been found in your system." << std::endl; - std::cout << "Test results will not be plotted." << std::endl; - } - else - { - try - { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); - Gnuplot::set_GNUPlotPath(gnuplot_path); - - Gnuplot g1("linespoints"); - g1.set_title(signal_name + " Doppler error"); - g1.set_grid(); - g1.set_xlabel("PRN"); - g1.set_ylabel("Doppler error [Hz]"); - g1.plot_xy(prns, means, "RMS error"); - g1.plot_xy(prns, stddevs, "Standard deviation"); - size_t char_pos = signal_name.find(" "); - while (char_pos != std::string::npos) - { - signal_name.replace(char_pos, 1, "_"); - char_pos = signal_name.find(" "); - } - char_pos = signal_name.find("/"); - while (char_pos != std::string::npos) - { - signal_name.replace(char_pos, 1, "_"); - char_pos = signal_name.find("/"); - } - g1.savetops("Doppler_error_" + signal_name); - g1.savetopdf("Doppler_error_" + signal_name, 18); - g1.showonscreen(); // window output - } - catch (const GnuplotException& ge) - { - std::cout << ge.what() << std::endl; - } - } - } -} - - -void ObsSystemTest::check_results() -{ - arma::mat sow_prn_ref; - if (gps_1C) - { - std::vector pseudorange_ref(num_prn_gps); - std::vector carrierphase_ref(num_prn_gps); - std::vector doppler_ref(num_prn_gps); - - std::vector pseudorange_meas(num_prn_gps); - std::vector carrierphase_meas(num_prn_gps); - std::vector doppler_meas(num_prn_gps); - - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 0); - - // Time alignment and difference computation - - std::vector pr_diff(num_prn_gps); - std::vector cp_diff(num_prn_gps); - std::vector dp_diff(num_prn_gps); - time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); - time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); - time_alignment_diff(doppler_ref, doppler_meas, dp_diff); - - // Results - std::cout << std::endl; - std::cout << std::endl; - std::cout << "GPS L1 C/A obs. results" << std::endl; - - // Compute pseudorange error - - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "GPS L1 C/A"); - - // Compute carrier phase error - - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "GPS L1 C/A"); - - // Compute Doppler error - - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "GPS L1 C/A"); - } - if (gps_L5) - { - std::vector pseudorange_ref(num_prn_gps); - std::vector carrierphase_ref(num_prn_gps); - std::vector doppler_ref(num_prn_gps); - - std::vector pseudorange_meas(num_prn_gps); - std::vector carrierphase_meas(num_prn_gps); - std::vector doppler_meas(num_prn_gps); - - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 2); - - // Time alignment and difference computation - - std::vector pr_diff(num_prn_gps); - std::vector cp_diff(num_prn_gps); - std::vector dp_diff(num_prn_gps); - time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); - time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); - time_alignment_diff(doppler_ref, doppler_meas, dp_diff); - - // Results - std::cout << std::endl; - std::cout << std::endl; - std::cout << "GPS L5 obs. results" << std::endl; - - // Compute pseudorange error - - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "GPS L5"); - - // Compute carrier phase error - - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "GPS L5"); - - // Compute Doppler error - - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "GPS L5"); - } - if (gal_1B) - { - std::vector pseudorange_ref(num_prn_gal); - std::vector carrierphase_ref(num_prn_gal); - std::vector doppler_ref(num_prn_gal); - - std::vector pseudorange_meas(num_prn_gal); - std::vector carrierphase_meas(num_prn_gal); - std::vector doppler_meas(num_prn_gal); - - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 1); - - // Time alignment and difference computation - - std::vector pr_diff(num_prn_gal); - std::vector cp_diff(num_prn_gal); - std::vector dp_diff(num_prn_gal); - time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); - time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); - time_alignment_diff(doppler_ref, doppler_meas, dp_diff); - - // Results - std::cout << std::endl; - std::cout << std::endl; - std::cout << "Galileo E1B obs. results" << std::endl; - - // Compute pseudorange error - - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "Galileo E1B"); - - // Compute carrier phase error - - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "Galileo E1B"); - - // Compute Doppler error - - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "Galileo E1B"); - } - if (gal_E5a) - { - std::vector pseudorange_ref(num_prn_gal); - std::vector carrierphase_ref(num_prn_gal); - std::vector doppler_ref(num_prn_gal); - - std::vector pseudorange_meas(num_prn_gal); - std::vector carrierphase_meas(num_prn_gal); - std::vector doppler_meas(num_prn_gal); - - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 3); - - // Time alignment and difference computation - - std::vector pr_diff(num_prn_gal); - std::vector cp_diff(num_prn_gal); - std::vector dp_diff(num_prn_gal); - time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); - time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); - time_alignment_diff(doppler_ref, doppler_meas, dp_diff); - - // Results - std::cout << std::endl; - std::cout << std::endl; - std::cout << "Galileo E5a obs. results" << std::endl; - - // Compute pseudorange error - - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "Galileo E5a"); - - // Compute carrier phase error - - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "Galileo E5a"); - - // Compute Doppler error - - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "Galileo E5a"); - } -} - - -TEST_F(ObsSystemTest, Observables_system_test) -{ - std::cout << "Validating input RINEX obs (TRUE) file: " << filename_rinex_obs << " ..." << std::endl; - bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs, 3); - ASSERT_EQ(true, is_rinex_obs_valid) << "The RINEX observation file " << filename_rinex_obs << " is not well formed. Only RINEX v. 3.00 files are allowed"; - std::cout << "The file is valid." << std::endl; - // Configure receiver - configure_receiver(); - if (generated_rinex_obs.compare("default_string") == 0) - { - // Run the receiver - ASSERT_EQ(run_receiver(), 0) << "Problem executing the software-defined signal generator"; - } - std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << generated_rinex_obs << " ..." << std::endl; - bool is_gen_rinex_obs_valid = false; - if (internal_rinex_generation) - { - is_gen_rinex_obs_valid = check_valid_rinex_obs("./" + generated_rinex_obs, config->property("PVT.rinex_version", 3)); - } - else - { - is_gen_rinex_obs_valid = check_valid_rinex_obs(generated_rinex_obs, config->property("PVT.rinex_version", 3)); - } - ASSERT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << generated_rinex_obs << ", generated by GNSS-SDR, is not well formed."; - std::cout << "The file is valid." << std::endl; - // Check results - check_results(); -} - - -int main(int argc, char** argv) -{ - std::cout << "Running GNSS-SDR in Space Observables validation test..." << std::endl; - int res = 0; - try - { - testing::InitGoogleTest(&argc, argv); - } - catch (...) - { - } // catch the "testing::internal::::ClassUniqueToAlwaysTrue" from gtest - - google::ParseCommandLineFlags(&argc, &argv, true); - google::InitGoogleLogging(argv[0]); - - // Run the Tests - try - { - res = RUN_ALL_TESTS(); - } - catch (...) - { - LOG(WARNING) << "Unexpected catch"; - } - google::ShutDownCommandLineFlags(); - return res; -} diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index b17f4de9d..1365b4302 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -1,7 +1,10 @@ /*! * \file position_test.cc * \brief This class implements a test for the validation of computed position. - * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es + * \authors
                      + *
                    • Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es + *
                    • Javier Arribas, 2018. jarribas(at)cttc.es + *
                    * * * ------------------------------------------------------------------------- @@ -29,18 +32,26 @@ * ------------------------------------------------------------------------- */ +#include "MATH_CONSTANTS.h" +#include "acquisition_msg_rx.h" #include "concurrent_map.h" #include "concurrent_queue.h" #include "control_thread.h" -#include "in_memory_configuration.h" #include "file_configuration.h" -#include "MATH_CONSTANTS.h" +#include "geofunctions.h" #include "gnuplot_i.h" -#include "test_flags.h" +#include "in_memory_configuration.h" +#include "position_test_flags.h" +#include "rtklib_solver_dump_reader.h" #include "signal_generator_flags.h" +#include "spirent_motion_csv_dump_reader.h" +#include "test_flags.h" +#include "tracking_tests_flags.h" //acquisition resampler +#include #include #include #include +#include #include #include #include @@ -48,15 +59,11 @@ #include #include - -DEFINE_string(config_file_ptest, std::string(""), "File containing the configuration parameters for the position test."); -DEFINE_bool(plot_position_test, false, "Plots results of FFTLengthTest with gnuplot"); - // For GPS NAVIGATION (L1) -concurrent_queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; +Concurrent_Queue global_gps_acq_assist_queue; +Concurrent_Map global_gps_acq_assist_map; -class StaticPositionSystemTest : public ::testing::Test +class PositionSystemTest : public ::testing::Test { public: int configure_generator(); @@ -64,6 +71,9 @@ public: int configure_receiver(); int run_receiver(); void check_results(); + bool save_mat_xy(std::vector* x, std::vector* y, std::string filename); + bool save_mat_x(std::vector* x, std::string filename); + std::string config_filename_no_extension; private: std::string generator_binary; @@ -78,119 +88,14 @@ private: std::string filename_rinex_obs = FLAGS_filename_rinex_obs; std::string filename_raw_data = FLAGS_filename_raw_data; - void print_results(const std::vector& east, - const std::vector& north, - const std::vector& up); - - double compute_stdev_precision(const std::vector& vec); - double compute_stdev_accuracy(const std::vector& vec, double ref); - - void geodetic2Enu(const double latitude, const double longitude, const double altitude, - double* east, double* north, double* up); - - void geodetic2Ecef(const double latitude, const double longitude, const double altitude, - double* x, double* y, double* z); - + void print_results(const arma::mat& R_eb_enu); std::shared_ptr config; std::shared_ptr config_f; std::string generated_kml_file; }; -void StaticPositionSystemTest::geodetic2Ecef(const double latitude, const double longitude, const double altitude, - double* x, double* y, double* z) -{ - const double a = 6378137.0; // WGS84 - const double b = 6356752.314245; // WGS84 - - double aux_x, aux_y, aux_z; - - // Convert to ECEF (See https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates ) - const double cLat = cos(latitude); - const double cLon = cos(longitude); - const double sLon = sin(longitude); - const double sLat = sin(latitude); - double N = std::pow(a, 2.0) / sqrt(std::pow(a, 2.0) * std::pow(cLat, 2.0) + std::pow(b, 2.0) * std::pow(sLat, 2.0)); - - aux_x = (N + altitude) * cLat * cLon; - aux_y = (N + altitude) * cLat * sLon; - aux_z = ((std::pow(b, 2.0) / std::pow(a, 2.0)) * N + altitude) * sLat; - - *x = aux_x; - *y = aux_y; - *z = aux_z; -} - - -void StaticPositionSystemTest::geodetic2Enu(double latitude, double longitude, double altitude, - double* east, double* north, double* up) -{ - double x, y, z; - const double d2r = PI / 180.0; - - geodetic2Ecef(latitude * d2r, longitude * d2r, altitude, &x, &y, &z); - - double aux_north, aux_east, aux_down; - - std::istringstream iss2(FLAGS_static_position); - std::string str_aux; - std::getline(iss2, str_aux, ','); - double ref_long = std::stod(str_aux); - std::getline(iss2, str_aux, ','); - double ref_lat = std::stod(str_aux); - std::getline(iss2, str_aux, '\n'); - double ref_h = std::stod(str_aux); - double ref_x, ref_y, ref_z; - - geodetic2Ecef(ref_lat * d2r, ref_long * d2r, ref_h, &ref_x, &ref_y, &ref_z); - - double aux_x = x - ref_x; - double aux_y = y - ref_y; - double aux_z = z - ref_z; - - // ECEF to NED matrix - double phiP = atan2(ref_z, sqrt(std::pow(ref_x, 2.0) + std::pow(ref_y, 2.0))); - const double sLat = sin(phiP); - const double sLon = sin(ref_long * d2r); - const double cLat = cos(phiP); - const double cLon = cos(ref_long * d2r); - - aux_north = -aux_x * sLat * cLon - aux_y * sLon + aux_z * cLat * cLon; - aux_east = -aux_x * sLat * sLon + aux_y * cLon + aux_z * cLat * sLon; - aux_down = aux_x * cLat + aux_z * sLat; - - *east = aux_east; - *north = aux_north; - *up = -aux_down; -} - - -double StaticPositionSystemTest::compute_stdev_precision(const std::vector& vec) -{ - double sum__ = std::accumulate(vec.begin(), vec.end(), 0.0); - double mean__ = sum__ / vec.size(); - double accum__ = 0.0; - std::for_each(std::begin(vec), std::end(vec), [&](const double d) { - accum__ += (d - mean__) * (d - mean__); - }); - double stdev__ = std::sqrt(accum__ / (vec.size() - 1)); - return stdev__; -} - - -double StaticPositionSystemTest::compute_stdev_accuracy(const std::vector& vec, const double ref) -{ - const double mean__ = ref; - double accum__ = 0.0; - std::for_each(std::begin(vec), std::end(vec), [&](const double d) { - accum__ += (d - mean__) * (d - mean__); - }); - double stdev__ = std::sqrt(accum__ / (vec.size() - 1)); - return stdev__; -} - - -int StaticPositionSystemTest::configure_generator() +int PositionSystemTest::configure_generator() { // Configure signal generator generator_binary = FLAGS_generator_binary; @@ -199,7 +104,10 @@ int StaticPositionSystemTest::configure_generator() if (FLAGS_dynamic_position.empty()) { p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(std::min(FLAGS_duration * 10, 3000)); - if (FLAGS_duration > 300) std::cout << "WARNING: Duration has been set to its maximum value of 300 s" << std::endl; + if (FLAGS_duration > 300) + { + std::cout << "WARNING: Duration has been set to its maximum value of 300 s" << std::endl; + } } else { @@ -212,16 +120,18 @@ int StaticPositionSystemTest::configure_generator() } -int StaticPositionSystemTest::generate_signal() +int PositionSystemTest::generate_signal() { pid_t wait_result; int child_status; - char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], nullptr}; int pid; if ((pid = fork()) == -1) - perror("fork error"); + { + perror("fork error"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -230,12 +140,15 @@ int StaticPositionSystemTest::generate_signal() } wait_result = waitpid(pid, &child_status, 0); - if (wait_result == -1) perror("waitpid error"); + if (wait_result == -1) + { + perror("waitpid error"); + } return 0; } -int StaticPositionSystemTest::configure_receiver() +int PositionSystemTest::configure_receiver() { if (FLAGS_config_file_ptest.empty()) { @@ -255,32 +168,36 @@ int StaticPositionSystemTest::configure_receiver() const float band1_error = 1.0; const float band2_error = 1.0; const int grid_density = 16; - const int decimation_factor = 1; const float zero = 0.0; - const int number_of_channels = 8; + const int number_of_channels = 11; const int in_acquisition = 1; - const float threshold = 0.01; - const float doppler_max = 8000.0; - const float doppler_step = 500.0; - const int max_dwells = 1; + const float threshold = 2.5; + const float doppler_max = 5000.0; + const float doppler_step = 250.0; + const int max_dwells = 10; const int tong_init_val = 2; const int tong_max_val = 10; const int tong_max_dwells = 30; const int coherent_integration_time_ms = 1; - const float pll_bw_hz = 30.0; - const float dll_bw_hz = 4.0; + const float pll_bw_hz = 35.0; + const float dll_bw_hz = 1.5; const float early_late_space_chips = 0.5; - const float pll_bw_narrow_hz = 20.0; - const float dll_bw_narrow_hz = 2.0; + const float pll_bw_narrow_hz = 1.0; + const float dll_bw_narrow_hz = 0.1; const int extend_correlation_ms = 1; const int display_rate_ms = 500; - const int output_rate_ms = 500; + const int output_rate_ms = 100; config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(sampling_rate_internal)); + // Enable automatic resampler for the acquisition, if required + if (FLAGS_use_acquisition_resampler == true) + { + config->set_property("GNSS-SDR.use_acquisition_resampler", "true"); + } // Set the assistance system parameters config->set_property("GNSS-SDR.SUPL_read_gps_assistance_xml", "false"); @@ -290,7 +207,7 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("GNSS-SDR.SUPL_gps_acquisition_server", "supl.google.com"); config->set_property("GNSS-SDR.SUPL_gps_acquisition_port", std::to_string(7275)); config->set_property("GNSS-SDR.SUPL_MCC", std::to_string(244)); - config->set_property("GNSS-SDR.SUPL_MNS", std::to_string(5)); + config->set_property("GNSS-SDR.SUPL_MNC", std::to_string(5)); config->set_property("GNSS-SDR.SUPL_LAC", "0x59e2"); config->set_property("GNSS-SDR.SUPL_CI", "0x31b0"); @@ -304,7 +221,7 @@ int StaticPositionSystemTest::configure_receiver() // Set the Signal Conditioner config->set_property("SignalConditioner.implementation", "Signal_Conditioner"); config->set_property("DataTypeAdapter.implementation", "Ibyte_To_Complex"); - config->set_property("InputFilter.implementation", "Fir_Filter"); + config->set_property("InputFilter.implementation", "Freq_Xlating_Fir_Filter"); config->set_property("InputFilter.dump", "false"); config->set_property("InputFilter.input_item_type", "gr_complex"); config->set_property("InputFilter.output_item_type", "gr_complex"); @@ -321,7 +238,7 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("InputFilter.ampl2_end", std::to_string(ampl2_end)); config->set_property("InputFilter.band1_error", std::to_string(band1_error)); config->set_property("InputFilter.band2_error", std::to_string(band2_error)); - config->set_property("InputFilter.filter_type", "bandpass"); + config->set_property("InputFilter.filter_type", "lowpass"); config->set_property("InputFilter.grid_density", std::to_string(grid_density)); config->set_property("InputFilter.sampling_frequency", std::to_string(sampling_rate_internal)); config->set_property("InputFilter.IF", std::to_string(zero)); @@ -337,7 +254,7 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("Channel.signal", "1C"); // Set Acquisition - config->set_property("Acquisition_1C.implementation", "GPS_L1_CA_PCPS_Tong_Acquisition"); + config->set_property("Acquisition_1C.implementation", "GPS_L1_CA_PCPS_Acquisition"); config->set_property("Acquisition_1C.item_type", "gr_complex"); config->set_property("Acquisition_1C.coherent_integration_time_ms", std::to_string(coherent_integration_time_ms)); config->set_property("Acquisition_1C.threshold", std::to_string(threshold)); @@ -348,10 +265,13 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("Acquisition_1C.tong_init_val", std::to_string(tong_init_val)); config->set_property("Acquisition_1C.tong_max_val", std::to_string(tong_max_val)); config->set_property("Acquisition_1C.tong_max_dwells", std::to_string(tong_max_dwells)); + config->set_property("Acquisition_1C.dump", "false"); + config->set_property("Acquisition_1C.dump_filename", "./acquisition"); + config->set_property("Acquisition_1C.dump_channel", "1"); + config->set_property("Acquisition_1C.blocking", "true"); // Set Tracking config->set_property("Tracking_1C.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - //config->set_property("Tracking_1C.implementation", "GPS_L1_CA_DLL_PLL_C_Aid_Tracking"); config->set_property("Tracking_1C.item_type", "gr_complex"); config->set_property("Tracking_1C.dump", "false"); config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); @@ -362,6 +282,8 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("Tracking_1C.pll_bw_narrow_hz", std::to_string(pll_bw_narrow_hz)); config->set_property("Tracking_1C.dll_bw_narrow_hz", std::to_string(dll_bw_narrow_hz)); config->set_property("Tracking_1C.extend_correlation_symbols", std::to_string(extend_correlation_ms)); + //config->set_property("Tracking_1C.high_dyn", "true"); + //config->set_property("Tracking_1C.smoother_length", "200"); // Set Telemetry config->set_property("TelemetryDecoder_1C.implementation", "GPS_L1_CA_Telemetry_Decoder"); @@ -374,6 +296,7 @@ int StaticPositionSystemTest::configure_receiver() // Set PVT config->set_property("PVT.implementation", "RTKLIB_PVT"); + config->set_property("PVT.positioning_mode", "PPP_Static"); config->set_property("PVT.output_rate_ms", std::to_string(output_rate_ms)); config->set_property("PVT.display_rate_ms", std::to_string(display_rate_ms)); config->set_property("PVT.dump_filename", "./PVT"); @@ -383,25 +306,25 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("PVT.flag_rtcm_server", "false"); config->set_property("PVT.flag_rtcm_tty_port", "false"); config->set_property("PVT.rtcm_dump_devname", "/dev/pts/1"); - config->set_property("PVT.dump", "false"); + config->set_property("PVT.dump", "true"); config->set_property("PVT.rinex_version", std::to_string(2)); - config->set_property("PVT.positioning_mode", "PPP_Static"); config->set_property("PVT.iono_model", "OFF"); config->set_property("PVT.trop_model", "OFF"); config->set_property("PVT.AR_GPS", "PPP-AR"); + config->set_property("PVT.elevation_mask", std::to_string(15)); - config_f = 0; + config_f = nullptr; } else { config_f = std::make_shared(FLAGS_config_file_ptest); - config = 0; + config = nullptr; } return 0; } -int StaticPositionSystemTest::run_receiver() +int PositionSystemTest::run_receiver() { std::shared_ptr control_thread; if (FLAGS_config_file_ptest.empty()) @@ -433,149 +356,447 @@ int StaticPositionSystemTest::run_receiver() std::string argum2 = std::string("/bin/ls *kml | tail -1"); char buffer[1035]; fp = popen(&argum2[0], "r"); - if (fp == NULL) + if (fp == nullptr) { std::cout << "Failed to run command: " << argum2 << std::endl; return -1; } - while (fgets(buffer, sizeof(buffer), fp) != NULL) + while (fgets(buffer, sizeof(buffer), fp) != nullptr) { std::string aux = std::string(buffer); EXPECT_EQ(aux.empty(), false); - StaticPositionSystemTest::generated_kml_file = aux.erase(aux.length() - 1, 1); + PositionSystemTest::generated_kml_file = aux.erase(aux.length() - 1, 1); } pclose(fp); - EXPECT_EQ(StaticPositionSystemTest::generated_kml_file.empty(), false); + EXPECT_EQ(PositionSystemTest::generated_kml_file.empty(), false); return 0; } -void StaticPositionSystemTest::check_results() +bool PositionSystemTest::save_mat_xy(std::vector* x, std::vector* y, std::string filename) { - std::fstream myfile(StaticPositionSystemTest::generated_kml_file, std::ios_base::in); - ASSERT_TRUE(myfile.is_open()) << "No valid kml file could be opened"; - std::string line; - - std::vector pos_e; - std::vector pos_n; - std::vector pos_u; - - // Skip header - std::getline(myfile, line); - bool is_header = true; - while (is_header) + try { - std::getline(myfile, line); - ASSERT_FALSE(myfile.eof()) << "No valid kml file found."; - std::size_t found = line.find(""); - if (found != std::string::npos) is_header = false; - } - bool is_data = true; - - //read data - while (is_data) - { - if (!std::getline(myfile, line)) + // WRITE MAT FILE + mat_t* matfp; + matvar_t* matvar; + filename.append(".mat"); + std::cout << "save_mat_xy write " << filename << std::endl; + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT5); + if (reinterpret_cast(matfp) != nullptr) { - is_data = false; - break; + size_t dims[2] = {1, x->size()}; + matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &y[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); } - std::size_t found = line.find(""); - if (found != std::string::npos) - is_data = false; else { - std::string str2; - std::istringstream iss(line); - double value; - double lat = 0.0; - double longitude = 0.0; - double h = 0.0; - for (int i = 0; i < 3; i++) - { - std::getline(iss, str2, ','); - value = std::stod(str2); - if (i == 0) lat = value; - if (i == 1) longitude = value; - if (i == 2) h = value; - } - - double north, east, up; - geodetic2Enu(lat, longitude, h, &east, &north, &up); - //std::cout << "E = " << east << ", N = " << north << " U = " << up << std::endl; - pos_e.push_back(east); - pos_n.push_back(north); - pos_u.push_back(up); + std::cout << "save_mat_xy: error creating file" << std::endl; } + Mat_Close(matfp); + return true; } - myfile.close(); - ASSERT_FALSE(pos_e.size() == 0) << "KML file is empty"; - - double sigma_E_2_precision = std::pow(compute_stdev_precision(pos_e), 2.0); - double sigma_N_2_precision = std::pow(compute_stdev_precision(pos_n), 2.0); - double sigma_U_2_precision = std::pow(compute_stdev_precision(pos_u), 2.0); - - double sigma_E_2_accuracy = std::pow(compute_stdev_accuracy(pos_e, 0.0), 2.0); - double sigma_N_2_accuracy = std::pow(compute_stdev_accuracy(pos_n, 0.0), 2.0); - double sigma_U_2_accuracy = std::pow(compute_stdev_accuracy(pos_u, 0.0), 2.0); - - double sum__e = std::accumulate(pos_e.begin(), pos_e.end(), 0.0); - double mean__e = sum__e / pos_e.size(); - double sum__n = std::accumulate(pos_n.begin(), pos_n.end(), 0.0); - double mean__n = sum__n / pos_n.size(); - double sum__u = std::accumulate(pos_u.begin(), pos_u.end(), 0.0); - double mean__u = sum__u / pos_u.size(); - - std::stringstream stm; - std::ofstream position_test_file; - - if (FLAGS_config_file_ptest.empty()) + catch (const std::exception& ex) { - stm << "---- ACCURACY ----" << std::endl; + std::cout << "save_mat_xy: " << ex.what() << std::endl; + return false; + } +} + +bool PositionSystemTest::save_mat_x(std::vector* x, std::string filename) +{ + try + { + // WRITE MAT FILE + mat_t* matfp; + matvar_t* matvar; + filename.append(".mat"); + std::cout << "save_mat_x write " << filename << std::endl; + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT5); + if (reinterpret_cast(matfp) != nullptr) + { + size_t dims[2] = {1, x->size()}; + matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + else + { + std::cout << "save_mat_x: error creating file" << std::endl; + } + Mat_Close(matfp); + return true; + } + catch (const std::exception& ex) + { + std::cout << "save_mat_x: " << ex.what() << std::endl; + return false; + } +} + +void PositionSystemTest::check_results() +{ + arma::mat R_eb_e; //ECEF position (x,y,z) estimation in the Earth frame (Nx3) + arma::mat R_eb_enu; //ENU position (N,E,U) estimation in UTM (Nx3) + arma::mat V_eb_e; //ECEF velocity (x,y,z) estimation in the Earth frame (Nx3) + arma::mat LLH; //Geodetic coordinates (latitude, longitude, height) estimation in WGS84 datum + arma::vec receiver_time_s; + + arma::mat ref_R_eb_e; //ECEF position (x,y,z) reference in the Earth frame (Nx3) + arma::mat ref_V_eb_e; //ECEF velocity (x,y,z) reference in the Earth frame (Nx3) + arma::mat ref_LLH; //Geodetic coordinates (latitude, longitude, height) reference in WGS84 datum + arma::vec ref_time_s; + + std::istringstream iss2(FLAGS_static_position); + std::string str_aux; + std::getline(iss2, str_aux, ','); + double ref_lat = std::stod(str_aux); + std::getline(iss2, str_aux, ','); + double ref_long = std::stod(str_aux); + std::getline(iss2, str_aux, '\n'); + double ref_h = std::stod(str_aux); + int utm_zone = findUtmZone(ref_lat, ref_long); + + arma::vec v_eb_n = {0.0, 0.0, 0.0}; + arma::vec true_r_eb_e = {0.0, 0.0, 0.0}; + arma::vec true_v_eb_e = {0.0, 0.0, 0.0}; + pv_Geo_to_ECEF(degtorad(ref_lat), degtorad(ref_long), ref_h, v_eb_n, true_r_eb_e, true_v_eb_e); + ref_R_eb_e.insert_cols(0, true_r_eb_e); + arma::vec ref_r_enu = {0, 0, 0}; + cart2utm(true_r_eb_e, utm_zone, ref_r_enu); + + Rtklib_Solver_Dump_Reader pvt_reader; + pvt_reader.open_obs_file(FLAGS_pvt_solver_dump_filename); + int64_t n_epochs = pvt_reader.num_epochs(); + R_eb_e = arma::zeros(3, n_epochs); + V_eb_e = arma::zeros(3, n_epochs); + LLH = arma::zeros(3, n_epochs); + receiver_time_s = arma::zeros(n_epochs, 1); + int64_t current_epoch = 0; + while (pvt_reader.read_binary_obs()) + { + receiver_time_s(current_epoch) = pvt_reader.RX_time - pvt_reader.clk_offset_s; + R_eb_e(0, current_epoch) = pvt_reader.rr[0]; + R_eb_e(1, current_epoch) = pvt_reader.rr[1]; + R_eb_e(2, current_epoch) = pvt_reader.rr[2]; + V_eb_e(0, current_epoch) = pvt_reader.rr[3]; + V_eb_e(1, current_epoch) = pvt_reader.rr[4]; + V_eb_e(2, current_epoch) = pvt_reader.rr[5]; + LLH(0, current_epoch) = pvt_reader.latitude; + LLH(1, current_epoch) = pvt_reader.longitude; + LLH(2, current_epoch) = pvt_reader.height; + + arma::vec tmp_r_enu = {0, 0, 0}; + cart2utm(R_eb_e.col(current_epoch), utm_zone, tmp_r_enu); + R_eb_enu.insert_cols(current_epoch, tmp_r_enu); + + // debug check + // std::cout << "t1: " << pvt_reader.RX_time << std::endl; + // std::cout << "t2: " << pvt_reader.TOW_at_current_symbol_ms << std::endl; + // std::cout << "offset: " << pvt_reader.clk_offset_s << std::endl; + // getchar(); + current_epoch++; + } + ASSERT_FALSE(current_epoch == 0) << "PVT dump is empty"; + + // compute results + if (FLAGS_static_scenario) + { + double sigma_E_2_precision = arma::var(R_eb_enu.row(0)); + double sigma_N_2_precision = arma::var(R_eb_enu.row(1)); + double sigma_U_2_precision = arma::var(R_eb_enu.row(2)); + + arma::rowvec error_east_m; + error_east_m = R_eb_enu.row(0) - ref_r_enu(0); + double sigma_E_2_accuracy = arma::as_scalar(error_east_m * error_east_m.t()); + sigma_E_2_accuracy = sigma_E_2_accuracy / error_east_m.n_elem; + + arma::rowvec error_north_m; + error_north_m = R_eb_enu.row(1) - ref_r_enu(1); + double sigma_N_2_accuracy = arma::as_scalar(error_north_m * error_north_m.t()); + sigma_N_2_accuracy = sigma_N_2_accuracy / error_north_m.n_elem; + + arma::rowvec error_up_m; + error_up_m = R_eb_enu.row(2) - ref_r_enu(2); + double sigma_U_2_accuracy = arma::as_scalar(error_up_m * error_up_m.t()); + sigma_U_2_accuracy = sigma_U_2_accuracy / error_up_m.n_elem; + + // arma::mat error_enu_mat = arma::zeros(3, error_east_m.n_elem); + // error_enu_mat.row(0) = error_east_m; + // error_enu_mat.row(1) = error_north_m; + // error_enu_mat.row(2) = error_up_m; + // + // arma::vec error_2D_m = arma::zeros(error_enu_mat.n_cols, 1); + // arma::vec error_3D_m = arma::zeros(error_enu_mat.n_cols, 1); + // for (uint64_t n = 0; n < error_enu_mat.n_cols; n++) + // { + // error_2D_m(n) = arma::norm(error_enu_mat.submat(0, n, 1, n)); + // error_3D_m(n) = arma::norm(error_enu_mat.col(n)); + // } + + double static_2D_error_m = sqrt(pow(arma::mean(error_east_m), 2.0) + pow(arma::mean(error_north_m), 2.0)); + double static_3D_error_m = sqrt(pow(arma::mean(error_east_m), 2.0) + pow(arma::mean(error_north_m), 2.0) + pow(arma::mean(error_up_m), 2.0)); + + std::stringstream stm; + std::ofstream position_test_file; + if (!FLAGS_config_file_ptest.empty()) + { + stm << "Configuration file: " << FLAGS_config_file_ptest << std::endl; + } + + stm << "---- STATIC ACCURACY ----" << std::endl; stm << "2DRMS = " << 2 * sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl; stm << "DRMS = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl; - stm << "CEP = " << 0.62 * compute_stdev_accuracy(pos_n, 0.0) + 0.56 * compute_stdev_accuracy(pos_e, 0.0) << " [m]" << std::endl; + stm << "CEP = " << 0.62 * sqrt(sigma_N_2_accuracy) + 0.56 * sqrt(sigma_E_2_accuracy) << " [m]" << std::endl; stm << "99% SAS = " << 1.122 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; stm << "90% SAS = " << 0.833 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; stm << "MRSE = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; stm << "SEP = " << 0.51 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; - stm << "Bias 2D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0)) << " [m]" << std::endl; - stm << "Bias 3D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0) + std::pow(mean__u, 2.0)) << " [m]" << std::endl; + stm << "Static Bias 2D = " << static_2D_error_m << " [m]" << std::endl; + stm << "Static Bias 3D = " << static_3D_error_m << " [m]" << std::endl; stm << std::endl; + + stm << "---- STATIC PRECISION ----" << std::endl; + stm << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; + stm << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; + stm << "CEP = " << 0.62 * sqrt(sigma_N_2_precision) + 0.56 * sqrt(sigma_E_2_precision) << " [m]" << std::endl; + stm << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + stm << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + stm << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + stm << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + + std::cout << stm.rdbuf(); + std::string output_filename = "position_test_output_" + PositionSystemTest::generated_kml_file.erase(PositionSystemTest::generated_kml_file.length() - 3, 3) + "txt"; + position_test_file.open(output_filename.c_str()); + if (position_test_file.is_open()) + { + position_test_file << stm.str(); + position_test_file.close(); + } + + // Sanity Check + double accuracy_CEP = 0.62 * sqrt(sigma_N_2_accuracy) + 0.56 * sqrt(sigma_E_2_accuracy); + double precision_SEP = 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision); + + EXPECT_LT(static_2D_error_m, FLAGS_static_2D_error_m); + EXPECT_LT(static_2D_error_m, FLAGS_static_2D_error_m); + ASSERT_LT(accuracy_CEP, FLAGS_accuracy_CEP); + ASSERT_LT(precision_SEP, FLAGS_precision_SEP); + + if (FLAGS_plot_position_test == true) + { + print_results(R_eb_enu); + } } - - stm << "---- PRECISION ----" << std::endl; - stm << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; - stm << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; - stm << "CEP = " << 0.62 * compute_stdev_precision(pos_n) + 0.56 * compute_stdev_precision(pos_e) << " [m]" << std::endl; - stm << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; - stm << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; - stm << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; - stm << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; - - std::cout << stm.rdbuf(); - std::string output_filename = "position_test_output_" + StaticPositionSystemTest::generated_kml_file.erase(StaticPositionSystemTest::generated_kml_file.length() - 3, 3) + "txt"; - position_test_file.open(output_filename.c_str()); - if (position_test_file.is_open()) + else { - position_test_file << stm.str(); - position_test_file.close(); - } + //dynamic position + Spirent_Motion_Csv_Dump_Reader ref_reader; + ref_reader.open_obs_file(FLAGS_ref_motion_filename); + int64_t n_epochs = ref_reader.num_epochs(); + ref_R_eb_e = arma::zeros(3, n_epochs); + ref_V_eb_e = arma::zeros(3, n_epochs); + ref_LLH = arma::zeros(3, n_epochs); + ref_time_s = arma::zeros(n_epochs, 1); + int64_t current_epoch = 0; + while (ref_reader.read_csv_obs()) + { + ref_time_s(current_epoch) = ref_reader.TOW_ms / 1000.0; + ref_R_eb_e(0, current_epoch) = ref_reader.Pos_X; + ref_R_eb_e(1, current_epoch) = ref_reader.Pos_Y; + ref_R_eb_e(2, current_epoch) = ref_reader.Pos_Z; + ref_V_eb_e(0, current_epoch) = ref_reader.Vel_X; + ref_V_eb_e(1, current_epoch) = ref_reader.Vel_Y; + ref_V_eb_e(2, current_epoch) = ref_reader.Vel_Z; + ref_LLH(0, current_epoch) = ref_reader.Lat; + ref_LLH(1, current_epoch) = ref_reader.Long; + ref_LLH(2, current_epoch) = ref_reader.Height; + current_epoch++; + } + //interpolation of reference data to receiver epochs timestamps + arma::mat ref_interp_R_eb_e = arma::zeros(3, R_eb_e.n_cols); + arma::mat ref_interp_V_eb_e = arma::zeros(3, V_eb_e.n_cols); + arma::mat ref_interp_LLH = arma::zeros(3, LLH.n_cols); + arma::vec tmp_vector; + for (int n = 0; n < 3; n++) + { + arma::interp1(ref_time_s, ref_R_eb_e.row(n), receiver_time_s, tmp_vector); + ref_interp_R_eb_e.row(n) = tmp_vector.t(); + arma::interp1(ref_time_s, ref_V_eb_e.row(n), receiver_time_s, tmp_vector); + ref_interp_V_eb_e.row(n) = tmp_vector.t(); + arma::interp1(ref_time_s, ref_LLH.row(n), receiver_time_s, tmp_vector); + ref_interp_LLH.row(n) = tmp_vector.t(); + } - // Sanity Check - double precision_SEP = 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision); - ASSERT_LT(precision_SEP, 20.0); + //compute error vectors + arma::mat error_R_eb_e = arma::zeros(3, R_eb_e.n_cols); + arma::mat error_V_eb_e = arma::zeros(3, V_eb_e.n_cols); + arma::mat error_LLH = arma::zeros(3, LLH.n_cols); + error_R_eb_e = R_eb_e - ref_interp_R_eb_e; + error_V_eb_e = V_eb_e - ref_interp_V_eb_e; + error_LLH = LLH - ref_interp_LLH; + arma::vec error_module_R_eb_e = arma::zeros(R_eb_e.n_cols, 1); + arma::vec error_module_V_eb_e = arma::zeros(V_eb_e.n_cols, 1); + for (uint64_t n = 0; n < R_eb_e.n_cols; n++) + { + error_module_R_eb_e(n) = arma::norm(error_R_eb_e.col(n)); + error_module_V_eb_e(n) = arma::norm(error_V_eb_e.col(n)); + } - if (FLAGS_plot_position_test == true) - { - print_results(pos_e, pos_n, pos_u); + //Error statistics + arma::vec tmp_vec; + //RMSE, Mean, Variance and peaks + tmp_vec = arma::square(error_module_R_eb_e); + double rmse_R_eb_e = sqrt(arma::mean(tmp_vec)); + double error_mean_R_eb_e = arma::mean(error_module_R_eb_e); + double error_var_R_eb_e = arma::var(error_module_R_eb_e); + double max_error_R_eb_e = arma::max(error_module_R_eb_e); + double min_error_R_eb_e = arma::min(error_module_R_eb_e); + + tmp_vec = arma::square(error_module_V_eb_e); + double rmse_V_eb_e = sqrt(arma::mean(tmp_vec)); + double error_mean_V_eb_e = arma::mean(error_module_V_eb_e); + double error_var_V_eb_e = arma::var(error_module_V_eb_e); + double max_error_V_eb_e = arma::max(error_module_V_eb_e); + double min_error_V_eb_e = arma::min(error_module_V_eb_e); + + //report + std::cout << "----- Position and Velocity 3D ECEF error statistics -----" << std::endl; + if (!FLAGS_config_file_ptest.empty()) + { + std::cout << "---- Configuration file: " << FLAGS_config_file_ptest << std::endl; + } + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << "---- 3D ECEF Position RMSE = " + << rmse_R_eb_e << ", mean = " << error_mean_R_eb_e + << ", stdev = " << sqrt(error_var_R_eb_e) + << " (max,min) = " << max_error_R_eb_e + << "," << min_error_R_eb_e + << " [m]" << std::endl; + std::cout << "---- 3D ECEF Velocity RMSE = " + << rmse_V_eb_e << ", mean = " << error_mean_V_eb_e + << ", stdev = " << sqrt(error_var_V_eb_e) + << " (max,min) = " << max_error_V_eb_e + << "," << min_error_V_eb_e + << " [m/s]" << std::endl; + std::cout.precision(ss); + + // plots + if (FLAGS_plot_position_test == true) + { + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if (!gnuplot_executable.empty()) + { + Gnuplot g1("points"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } + g1.set_title("3D ECEF error coordinates"); + g1.set_grid(); + //conversion between arma::vec and std:vector + arma::rowvec arma_vec_error_x = error_R_eb_e.row(0); + arma::rowvec arma_vec_error_y = error_R_eb_e.row(1); + arma::rowvec arma_vec_error_z = error_R_eb_e.row(2); + + std::vector X(arma_vec_error_x.colptr(0), arma_vec_error_x.colptr(0) + arma_vec_error_x.n_rows); + std::vector Y(arma_vec_error_y.colptr(0), arma_vec_error_y.colptr(0) + arma_vec_error_y.n_rows); + std::vector Z(arma_vec_error_z.colptr(0), arma_vec_error_z.colptr(0) + arma_vec_error_z.n_rows); + + g1.cmd("set key box opaque"); + g1.plot_xyz(X, Y, Z, "ECEF 3D error"); + g1.set_legend(); + if (FLAGS_config_file_ptest.empty()) + { + g1.savetops("ECEF_3d_error"); + } + else + { + g1.savetops("ECEF_3d_error_" + config_filename_no_extension); + } + arma::vec time_vector_from_start_s = receiver_time_s - receiver_time_s(0); + Gnuplot g3("linespoints"); + if (FLAGS_show_plots) + { + g3.showonscreen(); // window output + } + else + { + g3.disablescreen(); + } + g3.set_title("3D Position estimation error module [m]"); + g3.set_grid(); + g3.set_xlabel("Receiver epoch time from first valid PVT [s]"); + g3.set_ylabel("3D Position error [m]"); + //conversion between arma::vec and std:vector + std::vector error_vec(error_module_R_eb_e.colptr(0), error_module_R_eb_e.colptr(0) + error_module_R_eb_e.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector_from_start_s, error_vec, "Position 3D error"); + double mean3d = std::accumulate(error_vec.begin(), error_vec.end(), 0.0) / error_vec.size(); + std::vector error_mean(error_module_R_eb_e.n_rows, mean3d); + g3.set_style("lines"); + g3.plot_xy(time_vector_from_start_s, error_mean, "Mean"); + g3.set_legend(); + if (FLAGS_config_file_ptest.empty()) + { + g3.savetops("Position_3d_error"); + } + else + { + g3.savetops("Position_3d_error_" + config_filename_no_extension); + } + + Gnuplot g4("linespoints"); + if (FLAGS_show_plots) + { + g4.showonscreen(); // window output + } + else + { + g4.disablescreen(); + } + g4.set_title("3D Velocity estimation error module [m/s]"); + g4.set_grid(); + g4.set_xlabel("Receiver epoch time from first valid PVT [s]"); + g4.set_ylabel("3D Velocity error [m/s]"); + //conversion between arma::vec and std:vector + std::vector error_vec2(error_module_V_eb_e.colptr(0), error_module_V_eb_e.colptr(0) + error_module_V_eb_e.n_rows); + g4.cmd("set key box opaque"); + g4.plot_xy(time_vector_from_start_s, error_vec2, "Velocity 3D error"); + double mean3dv = std::accumulate(error_vec2.begin(), error_vec2.end(), 0.0) / error_vec2.size(); + std::vector error_mean_v(error_module_V_eb_e.n_rows, mean3dv); + g4.set_style("lines"); + g4.plot_xy(time_vector_from_start_s, error_mean_v, "Mean"); + g4.set_legend(); + if (FLAGS_config_file_ptest.empty()) + { + g4.savetops("Velocity_3d_error"); + } + else + { + g4.savetops("Velocity_3d_error_" + config_filename_no_extension); + } + } + } + + //ERROR CHECK + //todo: reduce the error tolerance or enable the option to pass the error tolerance by parameter + EXPECT_LT(rmse_R_eb_e, FLAGS_dynamic_3D_position_RMSE); //3D RMS positioning error less than 10 meters + EXPECT_LT(rmse_V_eb_e, FLAGS_dynamic_3D_velocity_RMSE); //3D RMS speed error less than 5 meters/s (18 km/h) } } -void StaticPositionSystemTest::print_results(const std::vector& east, - const std::vector& north, - const std::vector& up) +void PositionSystemTest::print_results(const arma::mat& R_eb_enu) { const std::string gnuplot_executable(FLAGS_gnuplot_executable); if (gnuplot_executable.empty()) @@ -586,37 +807,56 @@ void StaticPositionSystemTest::print_results(const std::vector& east, } else { - double sigma_E_2_precision = std::pow(compute_stdev_precision(east), 2.0); - double sigma_N_2_precision = std::pow(compute_stdev_precision(north), 2.0); - double sigma_U_2_precision = std::pow(compute_stdev_precision(up), 2.0); + double sigma_E_2_precision = arma::var(R_eb_enu.row(0)); + double sigma_N_2_precision = arma::var(R_eb_enu.row(1)); + double sigma_U_2_precision = arma::var(R_eb_enu.row(2)); - double mean_east = std::accumulate(east.begin(), east.end(), 0.0) / east.size(); - double mean_north = std::accumulate(north.begin(), north.end(), 0.0) / north.size(); + double mean_east = arma::mean(R_eb_enu.row(0)); + double mean_north = arma::mean(R_eb_enu.row(1)); + double mean_up = arma::mean(R_eb_enu.row(2)); - auto it_max_east = std::max_element(std::begin(east), std::end(east)); - auto it_min_east = std::min_element(std::begin(east), std::end(east)); - auto it_max_north = std::max_element(std::begin(north), std::end(north)); - auto it_min_north = std::min_element(std::begin(north), std::end(north)); - auto it_max_up = std::max_element(std::begin(up), std::end(up)); - auto it_min_up = std::min_element(std::begin(up), std::end(up)); + double it_max_east = arma::max(R_eb_enu.row(0) - mean_east); + double it_min_east = arma::min(R_eb_enu.row(0) - mean_east); - auto east_range = std::max(*it_max_east, std::abs(*it_min_east)); - auto north_range = std::max(*it_max_north, std::abs(*it_min_north)); - auto up_range = std::max(*it_max_up, std::abs(*it_min_up)); + double it_max_north = arma::max(R_eb_enu.row(1) - mean_north); + double it_min_north = arma::min(R_eb_enu.row(1) - mean_north); + + double it_max_up = arma::max(R_eb_enu.row(2) - mean_up); + double it_min_up = arma::min(R_eb_enu.row(2) - mean_up); + + double east_range = std::max(it_max_east, std::abs(it_min_east)); + double north_range = std::max(it_max_north, std::abs(it_min_north)); + double up_range = std::max(it_max_up, std::abs(it_min_up)); double range = std::max(east_range, north_range) * 1.1; double range_3d = std::max(std::max(east_range, north_range), up_range) * 1.1; double two_drms = 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision); double ninty_sas = 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision); + arma::rowvec arma_east = R_eb_enu.row(0) - mean_east; + arma::rowvec arma_north = R_eb_enu.row(1) - mean_north; + arma::rowvec arma_up = R_eb_enu.row(2) - mean_up; + + std::vector east(arma_east.colptr(0), arma_east.row(0).colptr(0) + arma_east.row(0).n_cols); + std::vector north(arma_north.colptr(0), arma_north.colptr(0) + arma_north.n_cols); + std::vector up(arma_up.colptr(0), arma_up.colptr(0) + arma_up.n_cols); + try { boost::filesystem::path p(gnuplot_executable); boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); + const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); Gnuplot g1("points"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } g1.set_title("2D precision"); g1.set_xlabel("East [m]"); g1.set_ylabel("North [m]"); @@ -624,18 +864,33 @@ void StaticPositionSystemTest::print_results(const std::vector& east, g1.cmd("set xrange [-" + std::to_string(range) + ":" + std::to_string(range) + "]"); g1.cmd("set yrange [-" + std::to_string(range) + ":" + std::to_string(range) + "]"); + g1.plot_xy(east, north, "2D Position Fixes"); g1.set_style("lines").plot_circle(mean_east, mean_north, two_drms, "2DRMS"); g1.set_style("lines").plot_circle(mean_east, mean_north, two_drms / 2.0, "DRMS"); g1.cmd("set grid front"); g1.cmd("replot"); - - g1.savetops("Position_test_2D"); - g1.savetopdf("Position_test_2D", 18); - g1.showonscreen(); // window output + if (FLAGS_config_file_ptest.empty()) + { + g1.savetops("Position_test_2D"); + g1.savetopdf("Position_test_2D", 18); + } + else + { + g1.savetops("Position_test_2D_" + config_filename_no_extension); + g1.savetopdf("Position_test_2D_" + config_filename_no_extension, 18); + } Gnuplot g2("points"); + if (FLAGS_show_plots) + { + g2.showonscreen(); // window output + } + else + { + g2.disablescreen(); + } g2.set_title("3D precision"); g2.set_xlabel("East [m]"); g2.set_ylabel("North [m]"); @@ -651,10 +906,16 @@ void StaticPositionSystemTest::print_results(const std::vector& east, std::to_string(ninty_sas) + "\n fx(v,u) = r*cos(v)*cos(u)\n fy(v,u) = r*cos(v)*sin(u)\n fz(v) = r*sin(v) \n splot fx(v,u),fy(v,u),fz(v) title \"90\%-SAS\" lt rgb \"gray\"\n"); g2.plot_xyz(east, north, up, "3D Position Fixes"); - - g2.savetops("Position_test_3D"); - g2.savetopdf("Position_test_3D"); - g2.showonscreen(); // window output + if (FLAGS_config_file_ptest.empty()) + { + g2.savetops("Position_test_3D"); + g2.savetopdf("Position_test_3D"); + } + else + { + g2.savetops("Position_test_3D_" + config_filename_no_extension); + g2.savetopdf("Position_test_3D_" + config_filename_no_extension); + } } catch (const GnuplotException& ge) { @@ -663,7 +924,7 @@ void StaticPositionSystemTest::print_results(const std::vector& east, } } -TEST_F(StaticPositionSystemTest, Position_system_test) +TEST_F(PositionSystemTest /*unused*/, Position_system_test /*unused*/) { if (FLAGS_config_file_ptest.empty()) { @@ -676,12 +937,17 @@ TEST_F(StaticPositionSystemTest, Position_system_test) generate_signal(); } } + else + { + config_filename_no_extension = FLAGS_config_file_ptest.substr(FLAGS_config_file_ptest.find_last_of("/\\") + 1); + config_filename_no_extension = config_filename_no_extension.erase(config_filename_no_extension.length() - 5); + } // Configure receiver configure_receiver(); // Run the receiver - EXPECT_EQ(run_receiver(), 0) << "Problem executing the software-defined signal generator"; + EXPECT_EQ(run_receiver(), 0) << "Problem executing GNSS-SDR"; // Check results check_results(); diff --git a/src/tests/system-tests/ttff_gps_l1.cc b/src/tests/system-tests/ttff.cc similarity index 95% rename from src/tests/system-tests/ttff_gps_l1.cc rename to src/tests/system-tests/ttff.cc index 2aaa39dee..ab9391244 100644 --- a/src/tests/system-tests/ttff_gps_l1.cc +++ b/src/tests/system-tests/ttff.cc @@ -1,5 +1,5 @@ /*! - * \file ttff_gps_l1.cc + * \file ttff.cc * \brief This class implements a test for measuring * the Time-To-First-Fix * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es @@ -34,9 +34,9 @@ #include "concurrent_queue.h" #include "control_thread.h" #include "file_configuration.h" -#include "in_memory_configuration.h" #include "gnss_flowgraph.h" #include "gps_acq_assist.h" +#include "in_memory_configuration.h" #include #include #include @@ -48,9 +48,9 @@ #include #include #include -#include #include #include +#include #include @@ -62,11 +62,10 @@ DEFINE_string(subdevice, "A:0", "USRP subdevice"); DEFINE_string(config_file_ttff, std::string(""), "File containing the configuration parameters for the TTFF test."); // For GPS NAVIGATION (L1) -concurrent_queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; +Concurrent_Queue global_gps_acq_assist_queue; +Concurrent_Map global_gps_acq_assist_map; std::vector TTFF_v; -const int decimation_factor = 1; typedef struct { @@ -75,12 +74,12 @@ typedef struct } ttff_msgbuf; -class TfttGpsL1CATest : public ::testing::Test +class TtffTest : public ::testing::Test { public: void config_1(); void config_2(); - void print_TTFF_report(const std::vector &ttff_v, std::shared_ptr config_); + void print_TTFF_report(const std::vector &ttff_v, const std::shared_ptr &config_); std::shared_ptr config; std::shared_ptr config2; @@ -124,7 +123,7 @@ public: }; -void TfttGpsL1CATest::config_1() +void TtffTest::config_1() { config = std::make_shared(); @@ -136,7 +135,7 @@ void TfttGpsL1CATest::config_1() config->set_property("GNSS-SDR.SUPL_gps_acquisition_server", "supl.google.com"); config->set_property("GNSS-SDR.SUPL_gps_acquisition_port", std::to_string(7275)); config->set_property("GNSS-SDR.SUPL_MCC", std::to_string(244)); - config->set_property("GNSS-SDR.SUPL_MNS", std::to_string(5)); + config->set_property("GNSS-SDR.SUPL_MNC", std::to_string(5)); config->set_property("GNSS-SDR.SUPL_LAC", "0x59e2"); config->set_property("GNSS-SDR.SUPL_CI", "0x31b0"); @@ -189,7 +188,6 @@ void TfttGpsL1CATest::config_1() // Set Acquisition config->set_property("Acquisition_1C.implementation", "GPS_L1_CA_PCPS_Tong_Acquisition"); config->set_property("Acquisition_1C.item_type", "gr_complex"); - config->set_property("Acquisition_1C.if", std::to_string(zero)); config->set_property("Acquisition_1C.coherent_integration_time_ms", std::to_string(coherent_integration_time_ms)); config->set_property("Acquisition_1C.threshold", std::to_string(threshold)); config->set_property("Acquisition_1C.doppler_max", std::to_string(doppler_max)); @@ -203,7 +201,6 @@ void TfttGpsL1CATest::config_1() // Set Tracking config->set_property("Tracking_1C.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); config->set_property("Tracking_1C.item_type", "gr_complex"); - config->set_property("Tracking_1C.if", std::to_string(zero)); config->set_property("Tracking_1C.dump", "false"); config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); config->set_property("Tracking_1C.pll_bw_hz", std::to_string(pll_bw_hz)); @@ -213,7 +210,6 @@ void TfttGpsL1CATest::config_1() // Set Telemetry config->set_property("TelemetryDecoder_1C.implementation", "GPS_L1_CA_Telemetry_Decoder"); config->set_property("TelemetryDecoder_1C.dump", "false"); - config->set_property("TelemetryDecoder_1C.decimation_factor", std::to_string(decimation_factor)); // Set Observables config->set_property("Observables.implementation", "Hybrid_Observables"); @@ -222,6 +218,7 @@ void TfttGpsL1CATest::config_1() // Set PVT config->set_property("PVT.implementation", "RTKLIB_PVT"); + config->set_property("PVT.positioning_mode", "Single"); config->set_property("PVT.output_rate_ms", std::to_string(output_rate_ms)); config->set_property("PVT.display_rate_ms", std::to_string(display_rate_ms)); config->set_property("PVT.dump_filename", "./PVT"); @@ -235,7 +232,7 @@ void TfttGpsL1CATest::config_1() } -void TfttGpsL1CATest::config_2() +void TtffTest::config_2() { if (FLAGS_config_file_ttff.empty()) { @@ -300,7 +297,7 @@ void receive_msg() } -void TfttGpsL1CATest::print_TTFF_report(const std::vector &ttff_v, std::shared_ptr config_) +void TtffTest::print_TTFF_report(const std::vector &ttff_v, const std::shared_ptr &config_) { std::ofstream ttff_report_file; std::string filename = "ttff_report"; @@ -388,10 +385,13 @@ void TfttGpsL1CATest::print_TTFF_report(const std::vector &ttff_v, std:: stm << "Disabled." << std::endl; } stm << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): "; - for (double ttff_ : ttff) stm << ttff_ << " "; + for (double ttff_ : ttff) + { + stm << ttff_ << " "; + } stm << std::endl; stm << "TTFF mean: " << mean << " [s]" << std::endl; - if (ttff.size() > 0) + if (!ttff.empty()) { stm << "TTFF max: " << *max_ttff << " [s]" << std::endl; stm << "TTFF min: " << *min_ttff << " [s]" << std::endl; @@ -401,7 +401,7 @@ void TfttGpsL1CATest::print_TTFF_report(const std::vector &ttff_v, std:: stm << "Navigation mode: " << "3D" << std::endl; - if (source.compare("UHD_Signal_Source")) + if (source != "UHD_Signal_Source") { stm << "Source: File" << std::endl; } @@ -420,7 +420,7 @@ void TfttGpsL1CATest::print_TTFF_report(const std::vector &ttff_v, std:: } -TEST_F(TfttGpsL1CATest, ColdStart) +TEST_F(TtffTest /*unused*/, ColdStart /*unused*/) { unsigned int num_measurements = 0; @@ -503,7 +503,7 @@ TEST_F(TfttGpsL1CATest, ColdStart) } -TEST_F(TfttGpsL1CATest, HotStart) +TEST_F(TtffTest /*unused*/, HotStart /*unused*/) { unsigned int num_measurements = 0; TTFF_v.clear(); @@ -632,7 +632,7 @@ int main(int argc, char **argv) msgsend_size = sizeof(msg.ttff); msgsnd(sysv_msqid, &msg, msgsend_size, IPC_NOWAIT); receive_msg_thread.join(); - msgctl(sysv_msqid, IPC_RMID, NULL); + msgctl(sysv_msqid, IPC_RMID, nullptr); google::ShutDownCommandLineFlags(); return res; diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index b139e993e..4f530334f 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -29,134 +29,152 @@ * ------------------------------------------------------------------------- */ -#include "concurrent_queue.h" #include "concurrent_map.h" +#include "concurrent_queue.h" #include "control_thread.h" -#include "gps_navigation_message.h" - -#include "gps_ephemeris.h" -#include "gps_cnav_ephemeris.h" -#include "gps_almanac.h" -#include "gps_iono.h" -#include "gps_cnav_iono.h" -#include "gps_utc_model.h" - -#include "galileo_ephemeris.h" #include "galileo_almanac.h" +#include "galileo_ephemeris.h" #include "galileo_iono.h" #include "galileo_utc_model.h" - -#include "sbas_ephemeris.h" - -#include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" +#include "glonass_gnav_ephemeris.h" #include "glonass_gnav_utc_model.h" - -#include -#include +#include "gps_almanac.h" +#include "gps_cnav_ephemeris.h" +#include "gps_cnav_iono.h" +#include "gps_ephemeris.h" +#include "gps_iono.h" +#include "gps_navigation_message.h" +#include "gps_utc_model.h" +#include "sbas_ephemeris.h" #include +#include #include #include #include #include #include #include -#include #include +#include using google::LogMessage; DECLARE_string(log_dir); +#if UNIT_TESTING_MINIMAL + +#include "unit-tests/arithmetic/matio_test.cc" +#if EXTRA_TESTS +#include "unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc" +#if FPGA_BLOCKS_TEST +#include "unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc" +#endif +#include "unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc" +#endif + + +#else + +#include "unit-tests/arithmetic/matio_test.cc" +#include "unit-tests/arithmetic/code_generation_test.cc" #include "unit-tests/arithmetic/complex_carrier_test.cc" #include "unit-tests/arithmetic/conjugate_test.cc" -#include "unit-tests/arithmetic/magnitude_squared_test.cc" -#include "unit-tests/arithmetic/multiply_test.cc" -#include "unit-tests/arithmetic/code_generation_test.cc" #include "unit-tests/arithmetic/fft_length_test.cc" #include "unit-tests/arithmetic/fft_speed_test.cc" -#include "unit-tests/arithmetic/matio_test.cc" - -#include "unit-tests/control-plane/file_configuration_test.cc" -#include "unit-tests/control-plane/in_memory_configuration_test.cc" +#include "unit-tests/arithmetic/magnitude_squared_test.cc" +#include "unit-tests/arithmetic/multiply_test.cc" #include "unit-tests/control-plane/control_message_factory_test.cc" #include "unit-tests/control-plane/control_thread_test.cc" -#include "unit-tests/control-plane/gnss_flowgraph_test.cc" -#include "unit-tests/control-plane/string_converter_test.cc" +#include "unit-tests/control-plane/file_configuration_test.cc" #include "unit-tests/control-plane/gnss_block_factory_test.cc" - +#include "unit-tests/control-plane/gnss_flowgraph_test.cc" +#include "unit-tests/control-plane/in_memory_configuration_test.cc" +#include "unit-tests/control-plane/string_converter_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc" +#include "unit-tests/signal-processing-blocks/adapter/adapter_test.cc" +#include "unit-tests/signal-processing-blocks/adapter/pass_through_test.cc" +#include "unit-tests/signal-processing-blocks/filter/fir_filter_test.cc" +#include "unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc" +#include "unit-tests/signal-processing-blocks/filter/notch_filter_test.cc" +#include "unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc" +#include "unit-tests/signal-processing-blocks/resampler/direct_resampler_conditioner_cc_test.cc" +#include "unit-tests/signal-processing-blocks/resampler/mmse_resampler_test.cc" #include "unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc" #include "unit-tests/signal-processing-blocks/sources/gnss_sdr_valve_test.cc" #include "unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc" - -#include "unit-tests/signal-processing-blocks/adapter/pass_through_test.cc" -#include "unit-tests/signal-processing-blocks/adapter/adapter_test.cc" - -#include "unit-tests/signal-processing-blocks/filter/fir_filter_test.cc" -#include "unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc" -#include "unit-tests/signal-processing-blocks/filter/notch_filter_test.cc" -#include "unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc" - -#include "unit-tests/signal-processing-blocks/resampler/direct_resampler_conditioner_cc_test.cc" -#include "unit-tests/signal-processing-blocks/resampler/mmse_resampler_test.cc" - -#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc" // #include "unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc" +// #include "unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc" #if OPENCL_BLOCKS_TEST #include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc" #endif +#include "unit-tests/signal-processing-blocks/tracking/bayesian_estimation_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc" #include "unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc" -#include "unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc" -#include "unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc" -#include "unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc" #if CUDA_BLOCKS_TEST #include "unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc" #endif #if FPGA_BLOCKS_TEST -#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc" #include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc" +#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc" #endif -#include "unit-tests/signal-processing-blocks/pvt/rtcm_test.cc" -#include "unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc" -#include "unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc" #include "unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc" - -#if EXTRA_TESTS -#include "unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc" -#include "unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc" -#include "unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc" -#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc" -#include "unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc" -#include "unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc" -#endif - +#include "unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc" +#include "unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc" +#include "unit-tests/signal-processing-blocks/pvt/rtcm_test.cc" +#include "unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc" #include "unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc" #include "unit-tests/system-parameters/glonass_gnav_nav_message_test.cc" + +#if EXTRA_TESTS +#include "unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc" +#include "unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc" +#include "unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc" +#if FPGA_BLOCKS_TEST +#include "unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc" +#endif +#include "unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc" +#if FPGA_BLOCKS_TEST +#include "unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc" +#endif +#include "unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc" +#endif + +#endif // UNIT_TESTING_MINIMAL + // For GPS NAVIGATION (L1) -concurrent_queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; +Concurrent_Queue global_gps_acq_assist_queue; +Concurrent_Map global_gps_acq_assist_map; int main(int argc, char **argv) { diff --git a/src/tests/unit-tests/arithmetic/code_generation_test.cc b/src/tests/unit-tests/arithmetic/code_generation_test.cc index 21f32dd47..e252771af 100644 --- a/src/tests/unit-tests/arithmetic/code_generation_test.cc +++ b/src/tests/unit-tests/arithmetic/code_generation_test.cc @@ -29,15 +29,15 @@ * ------------------------------------------------------------------------- */ +#include "gnss_signal_processing.h" +#include "gps_sdr_signal_processing.h" #include #include -#include "gps_sdr_signal_processing.h" -#include "gnss_signal_processing.h" TEST(CodeGenerationTest, CodeGenGPSL1Test) { - std::complex* _dest = new std::complex[1023]; + auto* _dest = new std::complex[1023]; signed int _prn = 1; unsigned int _chip_shift = 4; @@ -68,7 +68,7 @@ TEST(CodeGenerationTest, CodeGenGPSL1SampledTest) const signed int _codeFreqBasis = 1023000; //Hz const signed int _codeLength = 1023; int _samplesPerCode = round(_fs / static_cast(_codeFreqBasis / _codeLength)); - std::complex* _dest = new std::complex[_samplesPerCode]; + auto* _dest = new std::complex[_samplesPerCode]; int iterations = 1000; @@ -96,7 +96,7 @@ TEST(CodeGenerationTest, ComplexConjugateTest) const signed int _codeFreqBasis = 1023000; //Hz const signed int _codeLength = 1023; int _samplesPerCode = round(_fs / static_cast(_codeFreqBasis / _codeLength)); - std::complex* _dest = new std::complex[_samplesPerCode]; + auto* _dest = new std::complex[_samplesPerCode]; int iterations = 1000; diff --git a/src/tests/unit-tests/arithmetic/complex_carrier_test.cc b/src/tests/unit-tests/arithmetic/complex_carrier_test.cc index 1d4a0a900..72e12bcc0 100644 --- a/src/tests/unit-tests/arithmetic/complex_carrier_test.cc +++ b/src/tests/unit-tests/arithmetic/complex_carrier_test.cc @@ -29,10 +29,10 @@ * ------------------------------------------------------------------------- */ +#include "gnss_signal_processing.h" +#include #include #include -#include -#include "gnss_signal_processing.h" DEFINE_int32(size_carrier_test, 100000, "Size of the arrays used for complex carrier testing"); @@ -41,10 +41,10 @@ TEST(ComplexCarrierTest, StandardComplexImplementation) { // Dynamic allocation creates new usable space on the program STACK // (an area of RAM specifically allocated to the program) - std::complex* output = new std::complex[FLAGS_size_carrier_test]; + auto* output = new std::complex[FLAGS_size_carrier_test]; const double _f = 2000.0; const double _fs = 2000000.0; - const double phase_step = static_cast((GPS_TWO_PI * _f) / _fs); + const auto phase_step = static_cast((GPS_TWO_PI * _f) / _fs); double phase = 0.0; std::chrono::time_point start, end; @@ -84,7 +84,7 @@ TEST(ComplexCarrierTest, C11ComplexImplementation) std::vector> output(FLAGS_size_carrier_test); const double _f = 2000.0; const double _fs = 2000000.0; - const double phase_step = static_cast((GPS_TWO_PI * _f) / _fs); + const auto phase_step = static_cast((GPS_TWO_PI * _f) / _fs); double phase = 0.0; std::chrono::time_point start, end; @@ -113,7 +113,7 @@ TEST(ComplexCarrierTest, C11ComplexImplementation) TEST(ComplexCarrierTest, OwnComplexImplementation) { - std::complex* output = new std::complex[FLAGS_size_carrier_test]; + auto* output = new std::complex[FLAGS_size_carrier_test]; double _f = 2000.0; double _fs = 2000000.0; std::chrono::time_point start, end; diff --git a/src/tests/unit-tests/arithmetic/conjugate_test.cc b/src/tests/unit-tests/arithmetic/conjugate_test.cc index ec1c6e3f0..a32b12ebf 100644 --- a/src/tests/unit-tests/arithmetic/conjugate_test.cc +++ b/src/tests/unit-tests/arithmetic/conjugate_test.cc @@ -29,20 +29,20 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include #include #include #include +#include +#include +#include DEFINE_int32(size_conjugate_test, 100000, "Size of the arrays used for conjugate testing"); TEST(ConjugateTest, StandardCComplexImplementation) { - std::complex* input = new std::complex[FLAGS_size_conjugate_test]; - std::complex* output = new std::complex[FLAGS_size_conjugate_test]; + auto* input = new std::complex[FLAGS_size_conjugate_test]; + auto* output = new std::complex[FLAGS_size_conjugate_test]; std::fill_n(input, FLAGS_size_conjugate_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; @@ -114,8 +114,8 @@ TEST(ConjugateTest, ArmadilloComplexImplementation) TEST(ConjugateTest, VolkComplexImplementation) { - std::complex* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_conjugate_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); - std::complex* output = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_conjugate_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); + auto* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_conjugate_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); + auto* output = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_conjugate_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); std::fill_n(input, FLAGS_size_conjugate_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; diff --git a/src/tests/unit-tests/arithmetic/fft_length_test.cc b/src/tests/unit-tests/arithmetic/fft_length_test.cc index 7cf674c24..c8eb8354d 100644 --- a/src/tests/unit-tests/arithmetic/fft_length_test.cc +++ b/src/tests/unit-tests/arithmetic/fft_length_test.cc @@ -29,14 +29,14 @@ * ------------------------------------------------------------------------- */ +#include "gnuplot_i.h" +#include "test_flags.h" +#include +#include #include #include #include #include -#include -#include -#include "gnuplot_i.h" -#include "test_flags.h" DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT length timing test"); @@ -112,10 +112,18 @@ TEST(FFTLengthTest, MeasureExecutionTime) { boost::filesystem::path p(gnuplot_executable); boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); + const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); Gnuplot g1("linespoints"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } g1.set_title("FFT execution times for different lengths"); g1.set_grid(); g1.set_xlabel("FFT length"); @@ -124,9 +132,16 @@ TEST(FFTLengthTest, MeasureExecutionTime) g1.set_style("points").plot_xy(powers_of_two, execution_times_powers_of_two, "Power of 2"); g1.savetops("FFT_execution_times_extended"); g1.savetopdf("FFT_execution_times_extended", 18); - g1.showonscreen(); // window output Gnuplot g2("linespoints"); + if (FLAGS_show_plots) + { + g2.showonscreen(); // window output + } + else + { + g2.disablescreen(); + } g2.set_title("FFT execution times for different lengths (up to 2^{14}=16384)"); g2.set_grid(); g2.set_xlabel("FFT length"); @@ -136,7 +151,10 @@ TEST(FFTLengthTest, MeasureExecutionTime) g2.set_style("points").plot_xy(powers_of_two, execution_times_powers_of_two, "Power of 2"); g2.savetops("FFT_execution_times"); g2.savetopdf("FFT_execution_times", 18); - g2.showonscreen(); // window output + if (FLAGS_show_plots) + { + g2.showonscreen(); // window output + } } catch (const GnuplotException& ge) { diff --git a/src/tests/unit-tests/arithmetic/fft_speed_test.cc b/src/tests/unit-tests/arithmetic/fft_speed_test.cc index c18c0f822..8d5486e62 100644 --- a/src/tests/unit-tests/arithmetic/fft_speed_test.cc +++ b/src/tests/unit-tests/arithmetic/fft_speed_test.cc @@ -30,10 +30,10 @@ * ------------------------------------------------------------------------- */ +#include +#include #include #include -#include -#include DEFINE_int32(fft_speed_iterations_test, 100, "Number of averaged iterations in FFT length timing test"); @@ -46,8 +46,9 @@ TEST(FFTSpeedTest, ArmadilloVSGNURadioExecutionTime) unsigned int fft_sizes[19] = {16, 25, 32, 45, 64, 95, 128, 195, 256, 325, 512, 785, 1024, 1503, 2048, 3127, 4096, 6349, 8192}; double d_execution_time; EXPECT_NO_THROW( - for (int i = 0; i < 19; i++) { - d_fft_size = fft_sizes[i]; + for (unsigned int fft_size + : fft_sizes) { + d_fft_size = fft_size; gr::fft::fft_complex* d_gr_fft; d_gr_fft = new gr::fft::fft_complex(d_fft_size, true); arma::arma_rng::set_seed_random(); diff --git a/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc b/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc index 616487a8a..d8bd2bd1e 100644 --- a/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc +++ b/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc @@ -30,20 +30,20 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include #include #include #include +#include +#include +#include DEFINE_int32(size_magnitude_test, 100000, "Size of the arrays used for magnitude testing"); TEST(MagnitudeSquaredTest, StandardCComplexImplementation) { - std::complex* input = new std::complex[FLAGS_size_magnitude_test]; - float* output = new float[FLAGS_size_magnitude_test]; + auto* input = new std::complex[FLAGS_size_magnitude_test]; + auto* output = new float[FLAGS_size_magnitude_test]; unsigned int number = 0; std::chrono::time_point start, end; start = std::chrono::system_clock::now(); @@ -114,9 +114,9 @@ TEST(MagnitudeSquaredTest, ArmadilloComplexImplementation) TEST(MagnitudeSquaredTest, VolkComplexImplementation) { - std::complex* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); + auto* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); std::fill_n(input, FLAGS_size_magnitude_test, std::complex(0.0, 0.0)); - float* output = static_cast(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(float), volk_gnsssdr_get_alignment())); + auto* output = static_cast(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(float), volk_gnsssdr_get_alignment())); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); diff --git a/src/tests/unit-tests/arithmetic/matio_test.cc b/src/tests/unit-tests/arithmetic/matio_test.cc index 0429dff75..681aa8a94 100644 --- a/src/tests/unit-tests/arithmetic/matio_test.cc +++ b/src/tests/unit-tests/arithmetic/matio_test.cc @@ -30,10 +30,10 @@ * ------------------------------------------------------------------------- */ -#include -#include #include #include +#include +#include TEST(MatioTest, WriteAndReadDoubles) { @@ -41,13 +41,13 @@ TEST(MatioTest, WriteAndReadDoubles) mat_t *matfp; matvar_t *matvar; std::string filename = "./test.mat"; - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - ASSERT_FALSE(reinterpret_cast(matfp) == NULL) << "Error creating .mat file"; + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + ASSERT_FALSE(reinterpret_cast(matfp) == nullptr) << "Error creating .mat file"; double x[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; size_t dims[2] = {10, 1}; matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, x, 0); - ASSERT_FALSE(reinterpret_cast(matvar) == NULL) << "Error creating variable for ’x’"; + ASSERT_FALSE(reinterpret_cast(matvar) == nullptr) << "Error creating variable for ’x’"; Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -59,13 +59,13 @@ TEST(MatioTest, WriteAndReadDoubles) matvar_t *matvar_read; matfp_read = Mat_Open(filename.c_str(), MAT_ACC_RDONLY); - ASSERT_FALSE(reinterpret_cast(matfp_read) == NULL) << "Error reading .mat file"; + ASSERT_FALSE(reinterpret_cast(matfp_read) == nullptr) << "Error reading .mat file"; matvar_read = Mat_VarReadInfo(matfp_read, "x"); - ASSERT_FALSE(reinterpret_cast(matvar_read) == NULL) << "Error reading variable in .mat file"; + ASSERT_FALSE(reinterpret_cast(matvar_read) == nullptr) << "Error reading variable in .mat file"; matvar_read = Mat_VarRead(matfp_read, "x"); - double *x_read = reinterpret_cast(matvar_read->data); + auto *x_read = reinterpret_cast(matvar_read->data); Mat_Close(matfp_read); for (int i = 0; i < 10; i++) @@ -83,35 +83,35 @@ TEST(MatioTest, WriteAndReadGrComplex) mat_t *matfp; matvar_t *matvar1; std::string filename = "./test3.mat"; - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - ASSERT_FALSE(reinterpret_cast(matfp) == NULL) << "Error creating .mat file"; + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + ASSERT_FALSE(reinterpret_cast(matfp) == nullptr) << "Error creating .mat file"; std::vector x_v = {{1, 10}, {2, 9}, {3, 8}, {4, 7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}}; const unsigned int size = x_v.size(); float x_real[size]; float x_imag[size]; unsigned int i = 0; - for (std::vector::const_iterator it = x_v.cbegin(); it != x_v.cend(); it++) + for (auto it : x_v) { - x_real[i] = it->real(); - x_imag[i] = it->imag(); + x_real[i] = it.real(); + x_imag[i] = it.imag(); i++; } struct mat_complex_split_t x = {x_real, x_imag}; size_t dims[2] = {static_cast(size), 1}; matvar1 = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX); - ASSERT_FALSE(reinterpret_cast(matvar1) == NULL) << "Error creating variable for ’x’"; + ASSERT_FALSE(reinterpret_cast(matvar1) == nullptr) << "Error creating variable for ’x’"; std::vector x2 = {{1.1, -10}, {2, -9}, {3, -8}, {4, -7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}}; const unsigned int size_y = x2.size(); float y_real[size_y]; float y_imag[size_y]; i = 0; - for (std::vector::const_iterator it = x2.cbegin(); it != x2.cend(); it++) + for (auto it : x2) { - y_real[i] = it->real(); - y_imag[i] = it->imag(); + y_real[i] = it.real(); + y_imag[i] = it.imag(); i++; } @@ -119,7 +119,7 @@ TEST(MatioTest, WriteAndReadGrComplex) size_t dims_y[2] = {static_cast(size_y), 1}; matvar_t *matvar2; matvar2 = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX); - ASSERT_FALSE(reinterpret_cast(matvar2) == NULL) << "Error creating variable for ’y’"; + ASSERT_FALSE(reinterpret_cast(matvar2) == nullptr) << "Error creating variable for ’y’"; Mat_VarWrite(matfp, matvar1, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarWrite(matfp, matvar2, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE @@ -133,19 +133,19 @@ TEST(MatioTest, WriteAndReadGrComplex) matvar_t *matvar_read; matfp_read = Mat_Open(filename.c_str(), MAT_ACC_RDONLY); - ASSERT_FALSE(reinterpret_cast(matfp_read) == NULL) << "Error reading .mat file"; + ASSERT_FALSE(reinterpret_cast(matfp_read) == nullptr) << "Error reading .mat file"; matvar_read = Mat_VarReadInfo(matfp_read, "x"); - ASSERT_FALSE(reinterpret_cast(matvar_read) == NULL) << "Error reading variable in .mat file"; + ASSERT_FALSE(reinterpret_cast(matvar_read) == nullptr) << "Error reading variable in .mat file"; matvar_read = Mat_VarRead(matfp_read, "x"); - mat_complex_split_t *x_read_st = reinterpret_cast(matvar_read->data); - float *x_read_real = reinterpret_cast(x_read_st->Re); - float *x_read_imag = reinterpret_cast(x_read_st->Im); + auto *x_read_st = reinterpret_cast(matvar_read->data); + auto *x_read_real = reinterpret_cast(x_read_st->Re); + auto *x_read_imag = reinterpret_cast(x_read_st->Im); std::vector x_v_read; for (unsigned int i = 0; i < size; i++) { - x_v_read.push_back(gr_complex(x_read_real[i], x_read_imag[i])); + x_v_read.emplace_back(x_read_real[i], x_read_imag[i]); } Mat_Close(matfp_read); diff --git a/src/tests/unit-tests/arithmetic/multiply_test.cc b/src/tests/unit-tests/arithmetic/multiply_test.cc index 19abb0434..43a7e21ff 100644 --- a/src/tests/unit-tests/arithmetic/multiply_test.cc +++ b/src/tests/unit-tests/arithmetic/multiply_test.cc @@ -30,21 +30,21 @@ * ------------------------------------------------------------------------- */ +#include +#include +#include #include #include #include #include -#include -#include -#include DEFINE_int32(size_multiply_test, 100000, "Size of the arrays used for multiply testing"); TEST(MultiplyTest, StandardCDoubleImplementation) { - double* input = new double[FLAGS_size_multiply_test]; - double* output = new double[FLAGS_size_multiply_test]; + auto* input = new double[FLAGS_size_multiply_test]; + auto* output = new double[FLAGS_size_multiply_test]; std::fill_n(input, FLAGS_size_multiply_test, 0.0); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); @@ -95,8 +95,8 @@ TEST(MultiplyTest, ArmadilloImplementation) TEST(MultiplyTest, StandardCComplexImplementation) { - std::complex* input = new std::complex[FLAGS_size_multiply_test]; - std::complex* output = new std::complex[FLAGS_size_multiply_test]; + auto* input = new std::complex[FLAGS_size_multiply_test]; + auto* output = new std::complex[FLAGS_size_multiply_test]; std::fill_n(input, FLAGS_size_multiply_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); @@ -174,8 +174,8 @@ TEST(MultiplyTest, ArmadilloComplexImplementation) TEST(MultiplyTest, VolkComplexImplementation) { - std::complex* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); - std::complex* output = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); + auto* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); + auto* output = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); std::fill_n(input, FLAGS_size_multiply_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; @@ -190,10 +190,10 @@ TEST(MultiplyTest, VolkComplexImplementation) << " microseconds" << std::endl; ASSERT_LE(0, elapsed_seconds.count() * 1e6); - float* mag = static_cast(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(float), volk_gnsssdr_get_alignment())); + auto* mag = static_cast(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(float), volk_gnsssdr_get_alignment())); volk_32fc_magnitude_32f(mag, output, FLAGS_size_multiply_test); - float* result = new float(0); + auto* result = new float(0); volk_32f_accumulator_s32f(result, mag, FLAGS_size_multiply_test); // Comparing floating-point numbers is tricky. // Due to round-off errors, it is very unlikely that two floating-points will match exactly. diff --git a/src/tests/unit-tests/control-plane/control_message_factory_test.cc b/src/tests/unit-tests/control-plane/control_message_factory_test.cc index dd372de97..7440d37f4 100644 --- a/src/tests/unit-tests/control-plane/control_message_factory_test.cc +++ b/src/tests/unit-tests/control-plane/control_message_factory_test.cc @@ -31,9 +31,9 @@ */ -#include -#include #include "control_message_factory.h" +#include +#include TEST(ControlMessageFactoryTest, GetQueueMessage) diff --git a/src/tests/unit-tests/control-plane/control_thread_test.cc b/src/tests/unit-tests/control-plane/control_thread_test.cc index 2cc7c6ca2..0155cb227 100644 --- a/src/tests/unit-tests/control-plane/control_thread_test.cc +++ b/src/tests/unit-tests/control-plane/control_thread_test.cc @@ -31,25 +31,25 @@ */ -#include +#include "control_message_factory.h" +#include "control_thread.h" +#include "in_memory_configuration.h" +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include #include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include "control_thread.h" -#include "in_memory_configuration.h" -#include "control_message_factory.h" +#include class ControlThreadTest : public ::testing::Test @@ -88,7 +88,7 @@ int ControlThreadTest::stop_receiver() } -TEST_F(ControlThreadTest, InstantiateRunControlMessages) +TEST_F(ControlThreadTest /*unused*/, InstantiateRunControlMessages /*unused*/) { std::shared_ptr config = std::make_shared(); @@ -150,7 +150,7 @@ TEST_F(ControlThreadTest, InstantiateRunControlMessages) } -TEST_F(ControlThreadTest, InstantiateRunControlMessages2) +TEST_F(ControlThreadTest /*unused*/, InstantiateRunControlMessages2 /*unused*/) { std::shared_ptr config = std::make_shared(); config->set_property("SignalSource.implementation", "File_Signal_Source"); @@ -214,7 +214,7 @@ TEST_F(ControlThreadTest, InstantiateRunControlMessages2) } -TEST_F(ControlThreadTest, StopReceiverProgrammatically) +TEST_F(ControlThreadTest /*unused*/, StopReceiverProgrammatically /*unused*/) { std::shared_ptr config = std::make_shared(); config->set_property("SignalSource.implementation", "File_Signal_Source"); diff --git a/src/tests/unit-tests/control-plane/file_configuration_test.cc b/src/tests/unit-tests/control-plane/file_configuration_test.cc index 68fa64aad..6f7661f30 100644 --- a/src/tests/unit-tests/control-plane/file_configuration_test.cc +++ b/src/tests/unit-tests/control-plane/file_configuration_test.cc @@ -30,8 +30,8 @@ */ -#include #include "file_configuration.h" +#include TEST(FileConfigurationTest, OverridedProperties) diff --git a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc index 97a6524c9..9eff70397 100644 --- a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc +++ b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc @@ -33,18 +33,18 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include -#include "in_memory_configuration.h" -#include "gnss_block_interface.h" #include "acquisition_interface.h" -#include "tracking_interface.h" -#include "telemetry_decoder_interface.h" +#include "channel.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" +#include "in_memory_configuration.h" #include "observables_interface.h" #include "pvt_interface.h" -#include "gnss_block_factory.h" -#include "channel.h" +#include "telemetry_decoder_interface.h" +#include "tracking_interface.h" +#include +#include +#include TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource) { @@ -209,7 +209,7 @@ TEST(GNSSBlockFactoryTest, InstantiateGpsL1CaPcpsAcquisition) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition"); std::unique_ptr factory; - std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "GPS_L1_CA_PCPS_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "GPS_L1_CA_PCPS_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); EXPECT_STREQ("Acquisition", acquisition->role().c_str()); EXPECT_STREQ("GPS_L1_CA_PCPS_Acquisition", acquisition->implementation().c_str()); @@ -221,7 +221,7 @@ TEST(GNSSBlockFactoryTest, InstantiateGpsL1CaPcpsQuickSyncAcquisition) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_QuickSync_Acquisition"); std::shared_ptr factory = std::make_shared(); - std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "GPS_L1_CA_PCPS_QuickSync_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "GPS_L1_CA_PCPS_QuickSync_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); EXPECT_STREQ("Acquisition", acquisition->role().c_str()); EXPECT_STREQ("GPS_L1_CA_PCPS_QuickSync_Acquisition", acquisition->implementation().c_str()); @@ -232,7 +232,7 @@ TEST(GNSSBlockFactoryTest, InstantiateGalileoE1PcpsQuickSyncAmbiguousAcquisition std::shared_ptr configuration = std::make_shared(); configuration->set_property("Acquisition.implementation", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition"); std::shared_ptr factory = std::make_shared(); - std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); EXPECT_STREQ("Acquisition", acquisition->role().c_str()); EXPECT_STREQ("Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", acquisition->implementation().c_str()); @@ -244,7 +244,7 @@ TEST(GNSSBlockFactoryTest, InstantiateGalileoE1PcpsAmbiguousAcquisition) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Acquisition.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); std::unique_ptr factory; - std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); EXPECT_STREQ("Acquisition", acquisition->role().c_str()); EXPECT_STREQ("Galileo_E1_PCPS_Ambiguous_Acquisition", acquisition->implementation().c_str()); @@ -323,7 +323,7 @@ TEST(GNSSBlockFactoryTest, InstantiateChannels) configuration->set_property("Channel1.item_type", "gr_complex"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); std::unique_ptr factory; - std::unique_ptr>> channels = std::move(factory->GetChannels(configuration, queue)); + std::unique_ptr>> channels = factory->GetChannels(configuration, queue); EXPECT_EQ(static_cast(2), channels->size()); channels->erase(channels->begin(), channels->end()); } diff --git a/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc b/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc index c16c6361f..711b49d5f 100644 --- a/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc +++ b/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc @@ -30,21 +30,21 @@ * ------------------------------------------------------------------------- */ +#include "acquisition_interface.h" +#include "channel.h" +#include "channel_interface.h" +#include "file_configuration.h" +#include "file_signal_source.h" +#include "gnss_block_interface.h" +#include "gnss_flowgraph.h" +#include "in_memory_configuration.h" +#include "pass_through.h" +#include "tracking_interface.h" #include #include -#include "gnss_flowgraph.h" -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" -#include "file_configuration.h" -#include "channel.h" -#include "acquisition_interface.h" -#include "tracking_interface.h" -#include "channel_interface.h" -#include "pass_through.h" -#include "file_signal_source.h" -TEST(GNSSFlowgraph, InstantiateConnectStartStopOldNotation) +TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopOldNotation /*unused*/) { std::shared_ptr config = std::make_shared(); @@ -80,7 +80,7 @@ TEST(GNSSFlowgraph, InstantiateConnectStartStopOldNotation) } -TEST(GNSSFlowgraph, InstantiateConnectStartStop) +TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStop /*unused*/) { std::shared_ptr config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", "4000000"); @@ -114,7 +114,7 @@ TEST(GNSSFlowgraph, InstantiateConnectStartStop) EXPECT_FALSE(flowgraph->running()); } -TEST(GNSSFlowgraph, InstantiateConnectStartStopGalileoE1B) +TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopGalileoE1B /*unused*/) { std::shared_ptr config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", "4000000"); @@ -149,7 +149,7 @@ TEST(GNSSFlowgraph, InstantiateConnectStartStopGalileoE1B) } -TEST(GNSSFlowgraph, InstantiateConnectStartStopHybrid) +TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopHybrid /*unused*/) { std::shared_ptr config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", "4000000"); @@ -233,38 +233,22 @@ TEST(GNSSFlowgraph, InstantiateConnectStartStopHybrid) config->set_property("Tracking_1B15.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); config->set_property("TelemetryDecoder_1C0.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C0.decimation_factor", "4"); config->set_property("TelemetryDecoder_1C1.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C1.decimation_factor", "4"); config->set_property("TelemetryDecoder_1C2.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C2.decimation_factor", "4"); config->set_property("TelemetryDecoder_1C3.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C3.decimation_factor", "4"); config->set_property("TelemetryDecoder_1C4.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C4.decimation_factor", "4"); config->set_property("TelemetryDecoder_1C5.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C5.decimation_factor", "4"); config->set_property("TelemetryDecoder_1C6.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C6.decimation_factor", "4"); config->set_property("TelemetryDecoder_1C7.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C7.decimation_factor", "4"); config->set_property("TelemetryDecoder_1B8.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B8.decimation_factor", "1"); config->set_property("TelemetryDecoder_1B9.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B9.decimation_factor", "1"); config->set_property("TelemetryDecoder_1B10.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B10.decimation_factor", "1"); config->set_property("TelemetryDecoder_1B11.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B11.decimation_factor", "1"); config->set_property("TelemetryDecoder_1B12.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B12.decimation_factor", "1"); config->set_property("TelemetryDecoder_1B13.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B13.decimation_factor", "1"); config->set_property("TelemetryDecoder_1B14.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B14.decimation_factor", "1"); config->set_property("TelemetryDecoder_1B15.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B15.decimation_factor", "1"); config->set_property("Observables.implementation", "Hybrid_Observables"); config->set_property("PVT.implementation", "RTKLIB_PVT"); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc new file mode 100644 index 000000000..3021e15a1 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc @@ -0,0 +1,1105 @@ +/*! + * \file acq_performance_test.cc + * \brief This class implements an acquisition performance test + * \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.cat + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "acquisition_dump_reader.h" +#include "display.h" +#include "file_configuration.h" +#include "galileo_e1_pcps_ambiguous_acquisition.h" +#include "galileo_e5a_pcps_acquisition.h" +#include "glonass_l1_ca_pcps_acquisition.h" +#include "glonass_l2_ca_pcps_acquisition.h" +#include "gnss_sdr_valve.h" +#include "gnuplot_i.h" +#include "gps_l1_ca_pcps_acquisition.h" +#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" +#include "gps_l2_m_pcps_acquisition.h" +#include "gps_l5i_pcps_acquisition.h" +#include "in_memory_configuration.h" +#include "signal_generator_flags.h" +#include "test_flags.h" +#include "tracking_true_obs_reader.h" +#include "true_observables_reader.h" +#include +#include +#include +#include +#include +#include +#include + + +DEFINE_string(config_file_ptest, std::string(""), "File containing alternative configuration parameters for the acquisition performance test."); +DEFINE_string(acq_test_input_file, std::string(""), "File containing raw signal data, must be in int8_t format. The signal generator will not be used."); +DEFINE_string(acq_test_implementation, std::string("GPS_L1_CA_PCPS_Acquisition"), "Acquisition block implementation under test. Alternatives: GPS_L1_CA_PCPS_Acquisition, GPS_L1_CA_PCPS_Acquisition_Fine_Doppler, Galileo_E1_PCPS_Ambiguous_Acquisition, GLONASS_L1_CA_PCPS_Acquisition, GLONASS_L2_CA_PCPS_Acquisition, GPS_L2_M_PCPS_Acquisition, Galileo_E5a_Pcps_Acquisition, GPS_L5i_PCPS_Acquisition"); + +DEFINE_int32(acq_test_doppler_max, 5000, "Maximum Doppler, in Hz"); +DEFINE_int32(acq_test_doppler_step, 125, "Doppler step, in Hz."); +DEFINE_int32(acq_test_coherent_time_ms, 1, "Acquisition coherent time, in ms"); +DEFINE_int32(acq_test_max_dwells, 1, "Number of non-coherent integrations."); +DEFINE_bool(acq_test_use_CFAR_algorithm, true, "Use CFAR algorithm."); +DEFINE_bool(acq_test_bit_transition_flag, false, "Bit transition flag."); +DEFINE_bool(acq_test_make_two_steps, false, "Perform second step in a thinner grid."); +DEFINE_int32(acq_test_second_nbins, 4, "If --acq_test_make_two_steps is set to true, this parameter sets the number of bins done in the acquisition refinement stage."); +DEFINE_int32(acq_test_second_doppler_step, 10, "If --acq_test_make_two_steps is set to true, this parameter sets the Doppler step applied in the acquisition refinement stage, in Hz."); + +DEFINE_int32(acq_test_signal_duration_s, 2, "Generated signal duration, in s"); +DEFINE_int32(acq_test_num_meas, 0, "Number of measurements per run. 0 means the complete file."); +DEFINE_double(acq_test_cn0_init, 30.0, "Initial CN0, in dBHz."); +DEFINE_double(acq_test_cn0_final, 45.0, "Final CN0, in dBHz."); +DEFINE_double(acq_test_cn0_step, 3.0, "CN0 step, in dB."); + +DEFINE_double(acq_test_threshold_init, 3.0, "Initial acquisition threshold"); +DEFINE_double(acq_test_threshold_final, 4.0, "Final acquisition threshold"); +DEFINE_double(acq_test_threshold_step, 0.5, "Acquisition threshold step"); + +DEFINE_double(acq_test_pfa_init, 1e-5, "Set initial threshold via probability of false alarm. Disable with -1.0"); + +DEFINE_int32(acq_test_PRN, 1, "PRN number of a present satellite"); +DEFINE_int32(acq_test_fake_PRN, 33, "PRN number of a non-present satellite"); + +DEFINE_int32(acq_test_iterations, 1, "Number of iterations (same signal, different noise realization)"); +DEFINE_bool(plot_acq_test, false, "Plots results with gnuplot, if available"); +DEFINE_int32(acq_test_skiphead, 0, "Number of samples to skip in the input file"); + +DEFINE_bool(acq_test_dump, false, "Dump the results of an acquisition block into .mat files."); + +// ######## GNURADIO BLOCK MESSAGE RECEVER ######### +class AcqPerfTest_msg_rx; + +typedef boost::shared_ptr AcqPerfTest_msg_rx_sptr; + +AcqPerfTest_msg_rx_sptr AcqPerfTest_msg_rx_make(Concurrent_Queue& queue); + +class AcqPerfTest_msg_rx : public gr::block +{ +private: + friend AcqPerfTest_msg_rx_sptr AcqPerfTest_msg_rx_make(Concurrent_Queue& queue); + void msg_handler_events(pmt::pmt_t msg); + AcqPerfTest_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; + +public: + int rx_message; + ~AcqPerfTest_msg_rx(); +}; + + +AcqPerfTest_msg_rx_sptr AcqPerfTest_msg_rx_make(Concurrent_Queue& queue) +{ + return AcqPerfTest_msg_rx_sptr(new AcqPerfTest_msg_rx(queue)); +} + + +void AcqPerfTest_msg_rx::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(std::move(msg)); + rx_message = message; + channel_internal_queue.push(rx_message); + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + + +AcqPerfTest_msg_rx::AcqPerfTest_msg_rx(Concurrent_Queue& queue) : gr::block("AcqPerfTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&AcqPerfTest_msg_rx::msg_handler_events, this, _1)); + rx_message = 0; +} + + +AcqPerfTest_msg_rx::~AcqPerfTest_msg_rx() = default; + +// ----------------------------------------- + + +class AcquisitionPerformanceTest : public ::testing::Test +{ +protected: + AcquisitionPerformanceTest() + { + config = std::make_shared(); + item_size = sizeof(gr_complex); + gnss_synchro = Gnss_Synchro(); + doppler_max = static_cast(FLAGS_acq_test_doppler_max); + doppler_step = static_cast(FLAGS_acq_test_doppler_step); + stop = false; + if (FLAGS_acq_test_input_file.empty()) + { + cn0_vector.push_back(FLAGS_acq_test_cn0_init); + double aux = FLAGS_acq_test_cn0_init + FLAGS_acq_test_cn0_step; + while (aux <= FLAGS_acq_test_cn0_final) + { + cn0_vector.push_back(aux); + aux = aux + FLAGS_acq_test_cn0_step; + } + } + else + { + cn0_vector = {0.0}; + } + + if (implementation == "GPS_L1_CA_PCPS_Acquisition") + { + signal_id = "1C"; + system_id = 'G'; + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + min_integration_ms = 1; + } + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") + { + signal_id = "1C"; + system_id = 'G'; + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + min_integration_ms = 1; + } + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition") + { + signal_id = "1B"; + system_id = 'E'; + min_integration_ms = 4; + if (FLAGS_acq_test_coherent_time_ms == 1) + { + coherent_integration_time_ms = 4; + } + else + { + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + } + } + else if (implementation == "GLONASS_L1_CA_PCPS_Acquisition") + { + signal_id = "1G"; + system_id = 'R'; + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + min_integration_ms = 1; + } + else if (implementation == "GLONASS_L2_CA_PCPS_Acquisition") + { + signal_id = "2G"; + system_id = 'R'; + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + min_integration_ms = 1; + } + else if (implementation == "GPS_L2_M_PCPS_Acquisition") + { + signal_id = "2S"; + system_id = 'G'; + if (FLAGS_acq_test_coherent_time_ms == 1) + { + coherent_integration_time_ms = 20; + } + else + { + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + } + min_integration_ms = 20; + } + else if (implementation == "Galileo_E5a_Pcps_Acquisition") + { + signal_id = "5X"; + system_id = 'E'; + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + min_integration_ms = 1; + } + else if (implementation == "GPS_L5i_PCPS_Acquisition") + { + signal_id = "L5"; + system_id = 'G'; + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + } + else + { + signal_id = "1C"; + system_id = 'G'; + coherent_integration_time_ms = FLAGS_acq_test_coherent_time_ms; + min_integration_ms = 1; + } + + init(); + + if (FLAGS_acq_test_pfa_init > 0.0) + { + pfa_vector.push_back(FLAGS_acq_test_pfa_init); + float aux = 1.0; + while ((FLAGS_acq_test_pfa_init * std::pow(10, aux)) < 1) + { + pfa_vector.push_back(FLAGS_acq_test_pfa_init * std::pow(10, aux)); + aux = aux + 1.0; + } + pfa_vector.push_back(1.0); + } + else + { + auto aux = static_cast(FLAGS_acq_test_threshold_init); + pfa_vector.push_back(aux); + aux = aux + static_cast(FLAGS_acq_test_threshold_step); + while (aux <= static_cast(FLAGS_acq_test_threshold_final)) + { + pfa_vector.push_back(aux); + aux = aux + static_cast(FLAGS_acq_test_threshold_step); + } + } + + num_thresholds = pfa_vector.size(); + + int aux2 = ((generated_signal_duration_s * 1000 - (FLAGS_acq_test_coherent_time_ms * FLAGS_acq_test_max_dwells)) / (FLAGS_acq_test_coherent_time_ms * FLAGS_acq_test_max_dwells)); + if ((FLAGS_acq_test_num_meas > 0) and (FLAGS_acq_test_num_meas < aux2)) + { + num_of_measurements = static_cast(FLAGS_acq_test_num_meas); + } + else + { + num_of_measurements = static_cast(aux2); + } + + Pd.resize(cn0_vector.size()); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + Pd[i].reserve(num_thresholds); + } + Pfa.resize(cn0_vector.size()); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + Pfa[i].reserve(num_thresholds); + } + Pd_correct.resize(cn0_vector.size()); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + Pd_correct[i].reserve(num_thresholds); + } + } + + ~AcquisitionPerformanceTest() = default; + + std::vector cn0_vector; + std::vector pfa_vector; + + int N_iterations = FLAGS_acq_test_iterations; + void init(); + + int configure_generator(double cn0); + int generate_signal(); + int configure_receiver(double cn0, float pfa, unsigned int iter); + void start_queue(); + void wait_message(); + void process_message(); + void stop_queue(); + int run_receiver(); + int count_executions(const std::string& basename, unsigned int sat); + void check_results(); + void plot_results(); + + Concurrent_Queue channel_internal_queue; + + gr::msg_queue::sptr queue; + gr::top_block_sptr top_block; + std::shared_ptr acquisition; + std::shared_ptr config; + std::shared_ptr config_f; + Gnss_Synchro gnss_synchro; + size_t item_size; + unsigned int doppler_max; + unsigned int doppler_step; + bool stop; + + int message; + std::thread ch_thread; + + std::string implementation = FLAGS_acq_test_implementation; + + const double baseband_sampling_freq = static_cast(FLAGS_fs_gen_sps); + int coherent_integration_time_ms; + const int in_acquisition = 1; + const int dump_channel = 0; + + int generated_signal_duration_s = FLAGS_acq_test_signal_duration_s; + unsigned int num_of_measurements; + unsigned int measurement_counter = 0; + + unsigned int observed_satellite = FLAGS_acq_test_PRN; + std::string path_str = "./acq-perf-test"; + + int num_thresholds; + unsigned int min_integration_ms; + + std::vector> Pd; + std::vector> Pfa; + std::vector> Pd_correct; + + std::string signal_id; + +private: + std::string generator_binary; + std::string p1; + std::string p2; + std::string p3; + std::string p4; + std::string p5; + std::string p6; + + std::string filename_rinex_obs = FLAGS_filename_rinex_obs; + std::string filename_raw_data = FLAGS_filename_raw_data; + char system_id; + + double compute_stdev_precision(const std::vector& vec); + double compute_stdev_accuracy(const std::vector& vec, double ref); +}; + + +void AcquisitionPerformanceTest::init() +{ + gnss_synchro.Channel_ID = 0; + gnss_synchro.System = system_id; + std::string signal = signal_id; + signal.copy(gnss_synchro.Signal, 2, 0); + gnss_synchro.PRN = observed_satellite; + message = 0; + measurement_counter = 0; +} + + +void AcquisitionPerformanceTest::start_queue() +{ + stop = false; + ch_thread = std::thread(&AcquisitionPerformanceTest::wait_message, this); +} + + +void AcquisitionPerformanceTest::wait_message() +{ + while (!stop) + { + channel_internal_queue.wait_and_pop(message); + process_message(); + } +} + + +void AcquisitionPerformanceTest::process_message() +{ + measurement_counter++; + acquisition->reset(); + acquisition->set_state(1); + std::cout << "Progress: " << round(static_cast(measurement_counter) / static_cast(num_of_measurements) * 100.0) << "% \r" << std::flush; + if (measurement_counter == num_of_measurements) + { + stop_queue(); + top_block->stop(); + } +} + + +void AcquisitionPerformanceTest::stop_queue() +{ + stop = true; +} + + +int AcquisitionPerformanceTest::configure_generator(double cn0) +{ + // Configure signal generator + generator_binary = FLAGS_generator_binary; + + p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; + if (FLAGS_dynamic_position.empty()) + { + p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(std::min(generated_signal_duration_s * 10, 3000)); + } + else + { + p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); + } + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); // Baseband sampling frequency [MSps] + p6 = std::string("-CN0_dBHz=") + std::to_string(cn0); + return 0; +} + + +int AcquisitionPerformanceTest::generate_signal() +{ + pid_t wait_result; + int child_status; + std::cout << "Generating signal for " << p6 << "..." << std::endl; + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], &p6[0], nullptr}; + + int pid; + if ((pid = fork()) == -1) + { + perror("fork error"); + } + else if (pid == 0) + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv error." << std::endl; + std::terminate(); + } + + wait_result = waitpid(pid, &child_status, 0); + if (wait_result == -1) + { + perror("waitpid error"); + } + return 0; +} + + +int AcquisitionPerformanceTest::configure_receiver(double cn0, float pfa, unsigned int iter) +{ + if (FLAGS_config_file_ptest.empty()) + { + config = std::make_shared(); + const int sampling_rate_internal = baseband_sampling_freq; + + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(sampling_rate_internal)); + + // Set Acquisition + config->set_property("Acquisition.implementation", implementation); + config->set_property("Acquisition.item_type", "gr_complex"); + config->set_property("Acquisition.doppler_max", std::to_string(doppler_max)); + config->set_property("Acquisition.doppler_min", std::to_string(-doppler_max)); + config->set_property("Acquisition.doppler_step", std::to_string(doppler_step)); + + config->set_property("Acquisition.threshold", std::to_string(pfa)); + //if (FLAGS_acq_test_pfa_init > 0.0) config->supersede_property("Acquisition.pfa", std::to_string(pfa)); + if (FLAGS_acq_test_pfa_init > 0.0) + { + config->supersede_property("Acquisition.pfa", std::to_string(pfa)); + } + if (FLAGS_acq_test_use_CFAR_algorithm) + { + config->set_property("Acquisition.use_CFAR_algorithm", "true"); + } + else + { + config->set_property("Acquisition.use_CFAR_algorithm", "false"); + } + + config->set_property("Acquisition.coherent_integration_time_ms", std::to_string(coherent_integration_time_ms)); + if (FLAGS_acq_test_bit_transition_flag) + { + config->set_property("Acquisition.bit_transition_flag", "true"); + } + else + { + config->set_property("Acquisition.bit_transition_flag", "false"); + } + + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_acq_test_max_dwells)); + + config->set_property("Acquisition.repeat_satellite", "true"); + + config->set_property("Acquisition.blocking", "true"); + if (FLAGS_acq_test_make_two_steps) + { + config->set_property("Acquisition.make_two_steps", "true"); + config->set_property("Acquisition.second_nbins", std::to_string(FLAGS_acq_test_second_nbins)); + config->set_property("Acquisition.second_doppler_step", std::to_string(FLAGS_acq_test_second_doppler_step)); + } + else + { + config->set_property("Acquisition.make_two_steps", "false"); + } + + if (FLAGS_acq_test_dump) + { + config->set_property("Acquisition.dump", "true"); + } + else + { + config->set_property("Acquisition.dump", "false"); + } + + std::string dump_file = path_str + std::string("/acquisition_") + std::to_string(cn0) + "_" + std::to_string(iter) + "_" + std::to_string(pfa); + config->set_property("Acquisition.dump_filename", dump_file); + config->set_property("Acquisition.dump_channel", std::to_string(dump_channel)); + config->set_property("Acquisition.blocking_on_standby", "true"); + + config_f = nullptr; + } + else + { + config_f = std::make_shared(FLAGS_config_file_ptest); + config = nullptr; + } + return 0; +} + + +int AcquisitionPerformanceTest::run_receiver() +{ + std::string file; + if (FLAGS_acq_test_input_file.empty()) + { + file = "./" + filename_raw_data; + } + else + { + file = FLAGS_acq_test_input_file; + } + const char* file_name = file.c_str(); + gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + + gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + + top_block = gr::make_top_block("Acquisition test"); + boost::shared_ptr msg_rx = AcqPerfTest_msg_rx_make(channel_internal_queue); + gr::blocks::skiphead::sptr skiphead = gr::blocks::skiphead::make(sizeof(gr_complex), FLAGS_acq_test_skiphead); + + queue = gr::msg_queue::make(0); + gnss_synchro = Gnss_Synchro(); + init(); + + int nsamples = floor(config->property("GNSS-SDR.internal_fs_sps", 2000000) * generated_signal_duration_s); + boost::shared_ptr valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue); + if (implementation == "GPS_L1_CA_PCPS_Acquisition") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GLONASS_L1_CA_PCPS_Acquisition") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GLONASS_L2_CA_PCPS_Acquisition") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GPS_L2_M_PCPS_Acquisition") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "Galileo_E5a_Pcps_Acquisition") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GPS_L5i_PCPS_Acquisition") + { + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else + { + bool aux = false; + EXPECT_EQ(true, aux); + } + + acquisition->set_gnss_synchro(&gnss_synchro); + acquisition->set_channel(0); + acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); + acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); + acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); + acquisition->init(); + acquisition->set_local_code(); + + acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->connect(top_block); + + acquisition->reset(); + top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block->connect(gr_interleaved_char_to_complex, 0, skiphead, 0); + top_block->connect(skiphead, 0, valve, 0); + top_block->connect(valve, 0, acquisition->get_left_block(), 0); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + + start_queue(); + + top_block->run(); // Start threads and wait + + ch_thread.join(); + + return 0; +} + + +int AcquisitionPerformanceTest::count_executions(const std::string& basename, unsigned int sat) +{ + FILE* fp; + std::string argum2 = std::string("/usr/bin/find ") + path_str + std::string(" -maxdepth 1 -name ") + basename.substr(path_str.length() + 1, basename.length() - path_str.length()) + std::string("* | grep sat_") + std::to_string(sat) + std::string(" | wc -l"); + char buffer[1024]; + fp = popen(&argum2[0], "r"); + int num_executions = 1; + if (fp == nullptr) + { + std::cout << "Failed to run command: " << argum2 << std::endl; + return 0; + } + while (fgets(buffer, sizeof(buffer), fp) != nullptr) + { + std::string aux = std::string(buffer); + EXPECT_EQ(aux.empty(), false); + num_executions = std::stoi(aux); + } + pclose(fp); + return num_executions; +} + + +void AcquisitionPerformanceTest::plot_results() +{ + if (FLAGS_plot_acq_test == true) + { + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if (gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag plot_gps_l1_tracking_test has been set to TRUE," << std::endl; + std::cout << "gnuplot has not been found in your system." << std::endl; + std::cout << "Test results will not be plotted." << std::endl; + } + else + { + try + { + boost::filesystem::path p(gnuplot_executable); + boost::filesystem::path dir = p.parent_path(); + const std::string& gnuplot_path = dir.native(); + Gnuplot::set_GNUPlotPath(gnuplot_path); + + Gnuplot g1("linespoints"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } + g1.cmd("set font \"Times,18\""); + g1.set_title("Receiver Operating Characteristic for GPS L1 C/A acquisition"); + g1.cmd("set label 1 \"" + std::string("Coherent integration time: ") + std::to_string(config->property("Acquisition.coherent_integration_time_ms", 1)) + " ms, Non-coherent integrations: " + std::to_string(config->property("Acquisition.max_dwells", 1)) + R"( " at screen 0.12, 0.83 font "Times,16")"); + g1.cmd("set logscale x"); + g1.cmd("set yrange [0:1]"); + g1.cmd("set xrange[0.0001:1]"); + g1.cmd("set grid mxtics"); + g1.cmd("set grid ytics"); + g1.set_xlabel("Pfa"); + g1.set_ylabel("Pd"); + g1.set_grid(); + g1.cmd("show grid"); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + std::vector Pd_i; + std::vector Pfa_i; + for (int k = 0; k < num_thresholds; k++) + { + Pd_i.push_back(Pd[i][k]); + Pfa_i.push_back(Pfa[i][k]); + } + g1.plot_xy(Pfa_i, Pd_i, "CN0 = " + std::to_string(static_cast(cn0_vector[i])) + " dBHz"); + } + g1.set_legend(); + g1.savetops("ROC"); + g1.savetopdf("ROC", 18); + + Gnuplot g2("linespoints"); + if (FLAGS_show_plots) + { + g2.showonscreen(); // window output + } + else + { + g2.disablescreen(); + } + g2.cmd("set font \"Times,18\""); + g2.set_title("Receiver Operating Characteristic for GPS L1 C/A valid acquisition"); + g2.cmd("set label 1 \"" + std::string("Coherent integration time: ") + std::to_string(config->property("Acquisition.coherent_integration_time_ms", 1)) + " ms, Non-coherent integrations: " + std::to_string(config->property("Acquisition.max_dwells", 1)) + R"( " at screen 0.12, 0.83 font "Times,16")"); + g2.cmd("set logscale x"); + g2.cmd("set yrange [0:1]"); + g2.cmd("set xrange[0.0001:1]"); + g2.cmd("set grid mxtics"); + g2.cmd("set grid ytics"); + g2.set_xlabel("Pfa"); + g2.set_ylabel("Valid Pd"); + g2.set_grid(); + g2.cmd("show grid"); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + std::vector Pd_i_correct; + std::vector Pfa_i; + for (int k = 0; k < num_thresholds; k++) + { + Pd_i_correct.push_back(Pd_correct[i][k]); + Pfa_i.push_back(Pfa[i][k]); + } + g2.plot_xy(Pfa_i, Pd_i_correct, "CN0 = " + std::to_string(static_cast(cn0_vector[i])) + " dBHz"); + } + g2.set_legend(); + g2.savetops("ROC-valid-detection"); + g2.savetopdf("ROC-valid-detection", 18); + } + catch (const GnuplotException& ge) + { + std::cout << ge.what() << std::endl; + } + } + } +} + + +TEST_F(AcquisitionPerformanceTest, ROC) +{ + Tracking_True_Obs_Reader true_trk_data; + + if (boost::filesystem::exists(path_str)) + { + boost::filesystem::remove_all(path_str); + } + boost::system::error_code ec; + ASSERT_TRUE(boost::filesystem::create_directory(path_str, ec)) << "Could not create the " << path_str << " folder."; + + unsigned int cn0_index = 0; + for (double it : cn0_vector) + { + std::vector meas_Pd_; + std::vector meas_Pd_correct_; + std::vector meas_Pfa_; + + if (FLAGS_acq_test_input_file.empty()) + { + std::cout << "Execution for CN0 = " << it << " dB-Hz" << std::endl; + } + + // Do N_iterations of the experiment + for (int pfa_iter = 0; pfa_iter < static_cast(pfa_vector.size()); pfa_iter++) + { + if (FLAGS_acq_test_pfa_init > 0.0) + { + std::cout << "Setting threshold for Pfa = " << pfa_vector[pfa_iter] << std::endl; + } + else + { + std::cout << "Setting threshold to " << pfa_vector[pfa_iter] << std::endl; + } + + // Configure the signal generator + if (FLAGS_acq_test_input_file.empty()) + { + configure_generator(it); + } + + for (int iter = 0; iter < N_iterations; iter++) + { + // Generate signal raw signal samples and observations RINEX file + if (FLAGS_acq_test_input_file.empty()) + { + generate_signal(); + } + + for (unsigned k = 0; k < 2; k++) + { + if (k == 0) + { + observed_satellite = FLAGS_acq_test_PRN; + } + else + { + observed_satellite = FLAGS_acq_test_fake_PRN; + } + init(); + + // Configure the receiver + configure_receiver(it, pfa_vector[pfa_iter], iter); + + // Run it + run_receiver(); + + // count executions + std::string basename = path_str + std::string("/acquisition_") + std::to_string(it) + "_" + std::to_string(iter) + "_" + std::to_string(pfa_vector[pfa_iter]) + "_" + gnss_synchro.System + "_" + signal_id; + int num_executions = count_executions(basename, observed_satellite); + + // Read measured data + int ch = config->property("Acquisition.dump_channel", 0); + arma::vec meas_timestamp_s = arma::zeros(num_executions, 1); + arma::vec meas_doppler = arma::zeros(num_executions, 1); + arma::vec positive_acq = arma::zeros(num_executions, 1); + arma::vec meas_acq_delay_chips = arma::zeros(num_executions, 1); + + double coh_time_ms = config->property("Acquisition.coherent_integration_time_ms", 1); + + std::cout << "Num executions: " << num_executions << std::endl; + + unsigned int fft_size = 0; + unsigned int d_consumed_samples = coh_time_ms * config->property("GNSS-SDR.internal_fs_sps", 0) * 0.001; // * (config->property("Acquisition.bit_transition_flag", false) ? 2 : 1); + if (coh_time_ms == min_integration_ms) + { + fft_size = d_consumed_samples; + } + else + { + fft_size = d_consumed_samples * 2; + } + + for (int execution = 1; execution <= num_executions; execution++) + { + Acquisition_Dump_Reader acq_dump(basename, + observed_satellite, + config->property("Acquisition.doppler_max", 0), + config->property("Acquisition.doppler_step", 0), + fft_size, + ch, + execution); + acq_dump.read_binary_acq(); + if (acq_dump.positive_acq) + { + //std::cout << "Meas acq_delay_samples: " << acq_dump.acq_delay_samples << " chips: " << acq_dump.acq_delay_samples / (baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD / GPS_L1_CA_CODE_LENGTH_CHIPS) << std::endl; + meas_timestamp_s(execution - 1) = acq_dump.sample_counter / baseband_sampling_freq; + meas_doppler(execution - 1) = acq_dump.acq_doppler_hz; + meas_acq_delay_chips(execution - 1) = acq_dump.acq_delay_samples / (baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD / GPS_L1_CA_CODE_LENGTH_CHIPS); + positive_acq(execution - 1) = acq_dump.positive_acq; + } + else + { + //std::cout << "Failed acquisition." << std::endl; + meas_timestamp_s(execution - 1) = arma::datum::inf; + meas_doppler(execution - 1) = arma::datum::inf; + meas_acq_delay_chips(execution - 1) = arma::datum::inf; + positive_acq(execution - 1) = acq_dump.positive_acq; + } + } + + // Read reference data + std::string true_trk_file = std::string("./gps_l1_ca_obs_prn"); + true_trk_file.append(std::to_string(observed_satellite)); + true_trk_file.append(".dat"); + true_trk_data.close_obs_file(); + true_trk_data.open_obs_file(true_trk_file); + + // load the true values + int64_t n_true_epochs = true_trk_data.num_epochs(); + arma::vec true_timestamp_s = arma::zeros(n_true_epochs, 1); + arma::vec true_acc_carrier_phase_cycles = arma::zeros(n_true_epochs, 1); + arma::vec true_Doppler_Hz = arma::zeros(n_true_epochs, 1); + arma::vec true_prn_delay_chips = arma::zeros(n_true_epochs, 1); + arma::vec true_tow_s = arma::zeros(n_true_epochs, 1); + + int64_t epoch_counter = 0; + int num_clean_executions = 0; + while (true_trk_data.read_binary_obs()) + { + true_timestamp_s(epoch_counter) = true_trk_data.signal_timestamp_s; + true_acc_carrier_phase_cycles(epoch_counter) = true_trk_data.acc_carrier_phase_cycles; + true_Doppler_Hz(epoch_counter) = true_trk_data.doppler_l1_hz; + true_prn_delay_chips(epoch_counter) = GPS_L1_CA_CODE_LENGTH_CHIPS - true_trk_data.prn_delay_chips; + true_tow_s(epoch_counter) = true_trk_data.tow; + epoch_counter++; + //std::cout << "True PRN_Delay chips = " << GPS_L1_CA_CODE_LENGTH_CHIPS - true_trk_data.prn_delay_chips << " at " << true_trk_data.signal_timestamp_s << std::endl; + } + + // Process results + arma::vec clean_doppler_estimation_error; + arma::vec clean_delay_estimation_error; + + if (epoch_counter > 2) + { + arma::vec true_interpolated_doppler = arma::zeros(num_executions, 1); + arma::vec true_interpolated_prn_delay_chips = arma::zeros(num_executions, 1); + interp1(true_timestamp_s, true_Doppler_Hz, meas_timestamp_s, true_interpolated_doppler); + interp1(true_timestamp_s, true_prn_delay_chips, meas_timestamp_s, true_interpolated_prn_delay_chips); + + arma::vec doppler_estimation_error = true_interpolated_doppler - meas_doppler; + arma::vec delay_estimation_error = true_interpolated_prn_delay_chips - (meas_acq_delay_chips - ((1.0 / baseband_sampling_freq) / GPS_L1_CA_CHIP_PERIOD)); // compensate 1 sample delay + + // Cut measurements without reference + for (int i = 0; i < num_executions; i++) + { + if (!std::isnan(doppler_estimation_error(i)) and !std::isnan(delay_estimation_error(i))) + { + num_clean_executions++; + } + } + clean_doppler_estimation_error = arma::zeros(num_clean_executions, 1); + clean_delay_estimation_error = arma::zeros(num_clean_executions, 1); + num_clean_executions = 0; + for (int i = 0; i < num_executions; i++) + { + if (!std::isnan(doppler_estimation_error(i)) and !std::isnan(delay_estimation_error(i))) + { + clean_doppler_estimation_error(num_clean_executions) = doppler_estimation_error(i); + clean_delay_estimation_error(num_clean_executions) = delay_estimation_error(i); + num_clean_executions++; + } + } + + /* std::cout << "Doppler estimation error [Hz]: "; + for (int i = 0; i < num_executions - 1; i++) + { + std::cout << doppler_estimation_error(i) << " "; + } + std::cout << std::endl; + + std::cout << "Delay estimation error [chips]: "; + for (int i = 0; i < num_executions - 1; i++) + { + std::cout << delay_estimation_error(i) << " "; + + } + std::cout << std::endl; */ + } + if (k == 0) + { + double detected = arma::accu(positive_acq); + double computed_Pd = detected / static_cast(num_executions); + if (num_executions > 0) + { + meas_Pd_.push_back(computed_Pd); + } + else + { + meas_Pd_.push_back(0.0); + } + std::cout << TEXT_BOLD_BLACK << "Probability of detection for channel=" << ch << ", CN0=" << it << " dBHz" + << ": " << (num_executions > 0 ? computed_Pd : 0.0) << TEXT_RESET << std::endl; + } + if (num_clean_executions > 0) + { + arma::vec correct_acq = arma::zeros(num_executions, 1); + double correctly_detected = 0.0; + for (int i = 0; i < num_clean_executions - 1; i++) + + { + if (abs(clean_delay_estimation_error(i)) < 0.5 and abs(clean_doppler_estimation_error(i)) < static_cast(config->property("Acquisition.doppler_step", 1)) / 2.0) + { + correctly_detected = correctly_detected + 1.0; + } + } + double computed_Pd_correct = correctly_detected / static_cast(num_clean_executions); + meas_Pd_correct_.push_back(computed_Pd_correct); + std::cout << TEXT_BOLD_BLACK << "Probability of correct detection for channel=" << ch << ", CN0=" << it << " dBHz" + << ": " << computed_Pd_correct << TEXT_RESET << std::endl; + } + else + { + //std::cout << "No reference data has been found. Maybe a non-present satellite?" << num_executions << std::endl; + if (k == 1) + { + double wrongly_detected = arma::accu(positive_acq); + double computed_Pfa = wrongly_detected / static_cast(num_executions); + if (num_executions > 0) + { + meas_Pfa_.push_back(computed_Pfa); + } + else + { + meas_Pfa_.push_back(0.0); + } + std::cout << TEXT_BOLD_BLACK << "Probability of false alarm for channel=" << ch << ", CN0=" << it << " dBHz" + << ": " << (num_executions > 0 ? computed_Pfa : 0.0) << TEXT_RESET << std::endl; + } + } + true_trk_data.restart(); + } + } + true_trk_data.close_obs_file(); + float sum_pd = static_cast(std::accumulate(meas_Pd_.begin(), meas_Pd_.end(), 0.0)); + float sum_pd_correct = static_cast(std::accumulate(meas_Pd_correct_.begin(), meas_Pd_correct_.end(), 0.0)); + float sum_pfa = static_cast(std::accumulate(meas_Pfa_.begin(), meas_Pfa_.end(), 0.0)); + if (!meas_Pd_.empty() and !meas_Pfa_.empty()) + { + Pd[cn0_index][pfa_iter] = sum_pd / static_cast(meas_Pd_.size()); + Pfa[cn0_index][pfa_iter] = sum_pfa / static_cast(meas_Pfa_.size()); + } + else + { + if (!meas_Pd_.empty()) + { + Pd[cn0_index][pfa_iter] = sum_pd / static_cast(meas_Pd_.size()); + } + else + { + Pd[cn0_index][pfa_iter] = 0.0; + } + if (!meas_Pfa_.empty()) + { + Pfa[cn0_index][pfa_iter] = sum_pfa / static_cast(meas_Pfa_.size()); + } + else + { + Pfa[cn0_index][pfa_iter] = 0.0; + } + } + if (!meas_Pd_correct_.empty()) + { + Pd_correct[cn0_index][pfa_iter] = sum_pd_correct / static_cast(meas_Pd_correct_.size()); + } + else + { + Pd_correct[cn0_index][pfa_iter] = 0.0; + } + meas_Pd_.clear(); + meas_Pfa_.clear(); + meas_Pd_correct_.clear(); + } + cn0_index++; + } + + // Compute results + unsigned int aux_index = 0; + for (double it : cn0_vector) + { + std::cout << "Results for CN0 = " << it << " dBHz:" << std::endl; + std::cout << "Pd = "; + for (int pfa_iter = 0; pfa_iter < num_thresholds; pfa_iter++) + { + std::cout << Pd[aux_index][pfa_iter] << " "; + } + std::cout << std::endl; + std::cout << "Pd_correct = "; + for (int pfa_iter = 0; pfa_iter < num_thresholds; pfa_iter++) + { + std::cout << Pd_correct[aux_index][pfa_iter] << " "; + } + std::cout << std::endl; + std::cout << "Pfa = "; + for (int pfa_iter = 0; pfa_iter < num_thresholds; pfa_iter++) + { + std::cout << Pfa[aux_index][pfa_iter] << " "; + } + std::cout << std::endl; + + aux_index++; + } + + plot_results(); +} diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc new file mode 100644 index 000000000..959d73fed --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc @@ -0,0 +1,350 @@ +/*! + * \file beidou_b1i_pcps_acquisition_test.cc + * \brief This class implements an acquisition test for + * BeidouB1iPcpsAcquisition class based on some input parameters. + * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "Beidou_B1I.h" +#include "acquisition_dump_reader.h" +#include "beidou_b1i_pcps_acquisition.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "gnuplot_i.h" +#include "in_memory_configuration.h" +#include "test_flags.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// ######## GNURADIO BLOCK MESSAGE RECEVER ######### +class BeidouB1iPcpsAcquisitionTest_msg_rx; + +typedef boost::shared_ptr BeidouB1iPcpsAcquisitionTest_msg_rx_sptr; + +BeidouB1iPcpsAcquisitionTest_msg_rx_sptr BeidouB1iPcpsAcquisitionTest_msg_rx_make(); + +class BeidouB1iPcpsAcquisitionTest_msg_rx : public gr::block +{ +private: + friend BeidouB1iPcpsAcquisitionTest_msg_rx_sptr BeidouB1iPcpsAcquisitionTest_msg_rx_make(); + void msg_handler_events(pmt::pmt_t msg); + BeidouB1iPcpsAcquisitionTest_msg_rx(); + +public: + int rx_message; + ~BeidouB1iPcpsAcquisitionTest_msg_rx(); //!< Default destructor +}; + + +BeidouB1iPcpsAcquisitionTest_msg_rx_sptr BeidouB1iPcpsAcquisitionTest_msg_rx_make() +{ + return BeidouB1iPcpsAcquisitionTest_msg_rx_sptr(new BeidouB1iPcpsAcquisitionTest_msg_rx()); +} + + +void BeidouB1iPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg) +{ + try + { + long int message = pmt::to_long(msg); + rx_message = message; + } + catch (boost::bad_any_cast &e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + + +BeidouB1iPcpsAcquisitionTest_msg_rx::BeidouB1iPcpsAcquisitionTest_msg_rx() : gr::block("BeidouB1iPcpsAcquisitionTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&BeidouB1iPcpsAcquisitionTest_msg_rx::msg_handler_events, this, _1)); + rx_message = 0; +} + + +BeidouB1iPcpsAcquisitionTest_msg_rx::~BeidouB1iPcpsAcquisitionTest_msg_rx() +{ +} + + +// ########################################################### + +class BeidouB1iPcpsAcquisitionTest : public ::testing::Test +{ +protected: + BeidouB1iPcpsAcquisitionTest() + { + factory = std::make_shared(); + config = std::make_shared(); + item_size = sizeof(gr_complex); + gnss_synchro = Gnss_Synchro(); + doppler_max = 5000; + doppler_step = 100; + } + + ~BeidouB1iPcpsAcquisitionTest() + { + } + + void init(); + void plot_grid(); + + gr::top_block_sptr top_block; + std::shared_ptr factory; + std::shared_ptr config; + Gnss_Synchro gnss_synchro; + size_t item_size; + unsigned int doppler_max; + unsigned int doppler_step; +}; + + +void BeidouB1iPcpsAcquisitionTest::init() +{ + gnss_synchro.Channel_ID = 0; + gnss_synchro.System = 'C'; + std::string signal = "B1"; + signal.copy(gnss_synchro.Signal, 2, 0); + gnss_synchro.PRN = 1; + config->set_property("GNSS-SDR.internal_fs_sps", "25000000"); + config->set_property("Acquisition_B1.implementation", "BEIDOU_B1I_PCPS_Acquisition"); + config->set_property("Acquisition_B1.item_type", "gr_complex"); + config->set_property("Acquisition_B1.coherent_integration_time_ms", "1"); + if (FLAGS_plot_acq_grid == true) + { + config->set_property("Acquisition_B1.dump", "true"); + } + else + { + config->set_property("Acquisition_B1.dump", "false"); + } + config->set_property("Acquisition_B1.dump_filename", "./tmp-acq-beidou1/acquisition"); + config->set_property("Acquisition_B1.threshold", "0.00001"); + config->set_property("Acquisition_B1.doppler_max", std::to_string(doppler_max)); + config->set_property("Acquisition_B1.doppler_step", std::to_string(doppler_step)); + config->set_property("Acquisition_B1.repeat_satellite", "false"); + //config->set_property("Acquisition_B1.pfa", "0.0"); +} + + +void BeidouB1iPcpsAcquisitionTest::plot_grid() +{ + //load the measured values + std::string basename = "./tmp-acq-beidou1/acquisition_C_B1"; + unsigned int sat = static_cast(gnss_synchro.PRN); + + unsigned int samples_per_code = static_cast(round(4000000 / (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS))); // !! + acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code); + + if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; + + std::vector *doppler = &acq_dump.doppler; + std::vector *samples = &acq_dump.samples; + std::vector > *mag = &acq_dump.mag; + + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if (gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag plot_acq_grid has been set to TRUE," << std::endl; + std::cout << "gnuplot has not been found in your system." << std::endl; + std::cout << "Test results will not be plotted." << std::endl; + } + else + { + std::cout << "Plotting the acquisition grid. This can take a while..." << std::endl; + try + { + boost::filesystem::path p(gnuplot_executable); + boost::filesystem::path dir = p.parent_path(); + std::string gnuplot_path = dir.native(); + Gnuplot::set_GNUPlotPath(gnuplot_path); + + Gnuplot g1("lines"); + g1.set_title("BeiDou signal acquisition for satellite PRN #" + std::to_string(gnss_synchro.PRN)); + g1.set_xlabel("Doppler [Hz]"); + g1.set_ylabel("Sample"); + //g1.cmd("set view 60, 105, 1, 1"); + g1.plot_grid3d(*doppler, *samples, *mag); + + g1.savetops("BEIDOU_B1I_acq_grid"); + g1.savetopdf("BEIDOU_BI1_acq_grid"); + g1.showonscreen(); + } + catch (const GnuplotException &ge) + { + std::cout << ge.what() << std::endl; + } + } + std::string data_str = "./tmp-acq-beidou1"; + if (boost::filesystem::exists(data_str)) + { + boost::filesystem::remove_all(data_str); + } +} + + +TEST_F(BeidouB1iPcpsAcquisitionTest, Instantiate) +{ + init(); + boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_B1", 1, 0); +} + + +TEST_F(BeidouB1iPcpsAcquisitionTest, ConnectAndRun) +{ + int fs_in = 25000000; + int nsamples = 4000; + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds(0); + gr::msg_queue::sptr queue = gr::msg_queue::make(0); + + top_block = gr::make_top_block("Acquisition test"); + init(); + boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_B1", 1, 0); + boost::shared_ptr msg_rx = BeidouB1iPcpsAcquisitionTest_msg_rx_make(); + + ASSERT_NO_THROW({ + acquisition->connect(top_block); + boost::shared_ptr source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0)); + boost::shared_ptr valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue); + top_block->connect(source, 0, valve, 0); + top_block->connect(valve, 0, acquisition->get_left_block(), 0); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting the blocks of acquisition test."; + + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + }) << "Failure running the top_block."; + + std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; +} + + +TEST_F(BeidouB1iPcpsAcquisitionTest, ValidationOfResults) +{ + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds(0.0); + top_block = gr::make_top_block("Acquisition test"); + + double expected_delay_samples = 524; + double expected_doppler_hz = 1680; + + init(); + + if (FLAGS_plot_acq_grid == true) + { + std::string data_str = "./tmp-acq-beidou1"; + if (boost::filesystem::exists(data_str)) + { + boost::filesystem::remove_all(data_str); + } + boost::filesystem::create_directory(data_str); + } + + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_B1", 1, 0); + boost::shared_ptr msg_rx = BeidouB1iPcpsAcquisitionTest_msg_rx_make(); + + ASSERT_NO_THROW({ + acquisition->set_channel(1); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + acquisition->set_gnss_synchro(&gnss_synchro); + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + acquisition->set_threshold(0.001); + }) << "Failure setting threshold."; + + ASSERT_NO_THROW({ + acquisition->set_doppler_max(doppler_max); + }) << "Failure setting doppler_max."; + + ASSERT_NO_THROW({ + acquisition->set_doppler_step(doppler_step); + }) << "Failure setting doppler_step."; + + ASSERT_NO_THROW({ + acquisition->connect(top_block); + }) << "Failure connecting acquisition to the top_block."; + + ASSERT_NO_THROW({ + std::string path = std::string(TEST_PATH); + std::string file = path + "signal_samples/BEIDOU_B1I_ID_1_Fs_4Msps_2ms.dat"; + const char *file_name = file.c_str(); + gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(gr_complex), file_name, false); + top_block->connect(file_source, 0, acquisition->get_left_block(), 0); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting the blocks of acquisition test."; + + acquisition->set_local_code(); + acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->init(); + + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + }) << "Failure running the top_block."; + + unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples; + std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; + ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; + + double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); + float delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + + EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)"; + EXPECT_LT(delay_error_chips, 0.5) << "Delay error exceeds the expected value: 0.5 chips"; + + if (FLAGS_plot_acq_grid == true) + { + plot_grid(); + } +} diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc index ebff28d0b..a1517dd8f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc @@ -30,39 +30,45 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" +#include "fir_filter.h" #include "galileo_e1_pcps_8ms_ambiguous_acquisition.h" +#include "gen_signal_source.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" #include "signal_generator.h" #include "signal_generator_c.h" -#include "fir_filter.h" -#include "gen_signal_source.h" -#include "gnss_sdr_valve.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx; -typedef boost::shared_ptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr; +using GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr = boost::shared_ptr; -GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); +GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); class GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::block { private: - friend GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); + friend GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -70,7 +76,7 @@ public: }; -GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue) +GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue) { return GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr(new GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(queue)); } @@ -80,7 +86,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_events { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -92,16 +98,14 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_events } -GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue) : gr::block("GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue) : gr::block("GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_events, this, _1)); rx_message = 0; } -GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx() -{ -} +GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -119,9 +123,7 @@ protected: init(); } - ~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test() - { - } + ~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test() = default; void init(); void config_1(); @@ -131,7 +133,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr acquisition; @@ -141,7 +143,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -338,7 +340,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_2() void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::start_queue() { stop = false; - ch_thread = boost::thread(&GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::wait_message, this); + ch_thread = std::thread(&GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::wait_message, this); } @@ -420,7 +422,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::stop_queue() TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, Instantiate) { config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 0); } @@ -434,7 +436,7 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun) queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); @@ -484,7 +486,7 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1, queue); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 0, queue); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); @@ -572,7 +574,7 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProb config_2(); queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc index efc44fa62..346e59e79 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc @@ -31,39 +31,44 @@ */ -#include -#include -#include #include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" +#endif +#include "fir_filter.h" #include "galileo_e1_pcps_ambiguous_acquisition.h" +#include "gen_signal_source.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" #include "signal_generator.h" #include "signal_generator_c.h" -#include "fir_filter.h" -#include "gen_signal_source.h" -#include "gnss_sdr_valve.h" +#include +#include // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx; -typedef boost::shared_ptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr; +using GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr = boost::shared_ptr; -GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); +GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); class GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::block { private: - friend GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); + friend GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -71,7 +76,7 @@ public: }; -GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue) +GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue) { return GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr(new GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(queue)); } @@ -81,7 +86,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_events(pm { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -93,16 +98,14 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_events(pm } -GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue) : gr::block("GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue) : gr::block("GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_events, this, _1)); rx_message = 0; } -GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx() -{ -} +GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -120,9 +123,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test() - { - } + ~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test() = default; void init(); void config_1(); @@ -132,7 +133,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr acquisition; @@ -142,7 +143,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -347,7 +348,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::config_2() void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::start_queue() { stop = false; - ch_thread = boost::thread(&GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::wait_message, this); + ch_thread = std::thread(&GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::wait_message, this); } @@ -423,7 +424,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::stop_queue() TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, Instantiate) { config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); } @@ -437,7 +438,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ConnectAndRun) queue = gr::msg_queue::make(0); config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); @@ -466,7 +467,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) config_1(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); @@ -551,7 +552,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabi config_2(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc index 3748c37cf..06ec5811c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc @@ -41,37 +41,42 @@ */ -#include -#include -#include #include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include +#endif +#include "galileo_e1_pcps_ambiguous_acquisition.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_signal.h" #include "gnss_synchro.h" -#include "galileo_e1_pcps_ambiguous_acquisition.h" +#include "in_memory_configuration.h" +#include +#include +#include // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx; -typedef boost::shared_ptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr; +using GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr = boost::shared_ptr; -GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(concurrent_queue& queue); +GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(Concurrent_Queue& queue); class GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx : public gr::block { private: - friend GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(concurrent_queue& queue); + friend GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -79,7 +84,7 @@ public: }; -GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(concurrent_queue& queue) +GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(Concurrent_Queue& queue) { return GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr(new GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(queue)); } @@ -89,7 +94,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::msg_handler_events(pmt::p { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -101,16 +106,14 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::msg_handler_events(pmt::p } -GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(concurrent_queue& queue) : gr::block("GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(Concurrent_Queue& queue) : gr::block("GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::msg_handler_events, this, _1)); rx_message = 0; } -GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx() -{ -} +GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx() = default; // ########################################################### @@ -129,16 +132,14 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GalileoE1PcpsAmbiguousAcquisitionGSoCTest() - { - } + ~GalileoE1PcpsAmbiguousAcquisitionGSoCTest() = default; void init(); void start_queue(); void wait_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr factory; @@ -147,7 +148,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; }; @@ -174,7 +175,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoCTest::init() void GalileoE1PcpsAmbiguousAcquisitionGSoCTest::start_queue() { - ch_thread = boost::thread(&GalileoE1PcpsAmbiguousAcquisitionGSoCTest::wait_message, this); + ch_thread = std::thread(&GalileoE1PcpsAmbiguousAcquisitionGSoCTest::wait_message, this); } @@ -204,7 +205,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoCTest::stop_queue() TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, Instantiate) { init(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); EXPECT_STREQ("Galileo_E1_PCPS_Ambiguous_Acquisition", acquisition->implementation().c_str()); } @@ -220,7 +221,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); init(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(channel_internal_queue); @@ -251,7 +252,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ValidationOfResults) top_block = gr::make_top_block("Acquisition test"); init(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(channel_internal_queue); @@ -306,7 +307,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ValidationOfResults) stop_queue(); - unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples; + uint64_t nsamples = gnss_synchro.Acq_samplestamp_samples; std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 0=ACQ STOP."; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc index 28d37556a..c31937d37 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc @@ -31,32 +31,37 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "Galileo_E1.h" +#include "acquisition_dump_reader.h" +#include "galileo_e1_pcps_ambiguous_acquisition.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_signal.h" #include "gnss_synchro.h" #include "gnuplot_i.h" +#include "in_memory_configuration.h" #include "test_flags.h" -#include "acquisition_dump_reader.h" -#include "galileo_e1_pcps_ambiguous_acquisition.h" -#include "Galileo_E1.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx; -typedef boost::shared_ptr GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx_sptr; +using GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx_sptr = boost::shared_ptr; GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx_make(); @@ -83,7 +88,7 @@ void GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -102,9 +107,7 @@ GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::GalileoE1PcpsAmbiguousAcquisitionT } -GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx() -{ -} +GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx() = default; // ########################################################### @@ -122,9 +125,7 @@ protected: doppler_step = 250; } - ~GalileoE1PcpsAmbiguousAcquisitionTest() - { - } + ~GalileoE1PcpsAmbiguousAcquisitionTest() = default; void init(); void plot_grid(); @@ -172,12 +173,15 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::plot_grid() { //load the measured values std::string basename = "./tmp-acq-gal1/acquisition_E_1B"; - unsigned int sat = static_cast(gnss_synchro.PRN); + auto sat = static_cast(gnss_synchro.PRN); - unsigned int samples_per_code = static_cast(round(4000000 / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); // !! - acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code); + auto samples_per_code = static_cast(round(4000000 / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); // !! + Acquisition_Dump_Reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code); - if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; + if (!acq_dump.read_binary_acq()) + { + std::cout << "Error reading files" << std::endl; + } std::vector* doppler = &acq_dump.doppler; std::vector* samples = &acq_dump.samples; @@ -197,10 +201,18 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::plot_grid() { boost::filesystem::path p(gnuplot_executable); boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); + const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); Gnuplot g1("lines"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } g1.set_title("Galileo E1b/c signal acquisition for satellite PRN #" + std::to_string(gnss_synchro.PRN)); g1.set_xlabel("Doppler [Hz]"); g1.set_ylabel("Sample"); @@ -209,7 +221,6 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::plot_grid() g1.savetops("Galileo_E1_acq_grid"); g1.savetopdf("Galileo_E1_acq_grid"); - g1.showonscreen(); } catch (const GnuplotException& ge) { @@ -227,7 +238,7 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::plot_grid() TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, Instantiate) { init(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); } @@ -241,7 +252,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); init(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx_make(); @@ -283,7 +294,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) double expected_doppler_hz = -632; init(); top_block = gr::make_top_block("Acquisition test"); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 0); std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx_make(); @@ -332,7 +343,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) elapsed_seconds = end - start; }) << "Failure running the top_block."; - unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples; + uint64_t nsamples = gnss_synchro.Acq_samplestamp_samples; std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; @@ -340,7 +351,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) std::cout << "Doppler: " << gnss_synchro.Acq_doppler_hz << std::endl; double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); - float delay_error_chips = static_cast(delay_error_samples * 1023 / 4000000); + auto delay_error_chips = static_cast(delay_error_samples * 1023 / 4000000); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); EXPECT_LE(doppler_error_hz, 166) << "Doppler error exceeds the expected value: 166 Hz = 2/(3*integration period)"; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc index a193c8c4d..60d23b6ba 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc @@ -31,39 +31,45 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" +#include "fir_filter.h" #include "galileo_e1_pcps_cccwsr_ambiguous_acquisition.h" +#include "gen_signal_source.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" #include "signal_generator.h" #include "signal_generator_c.h" -#include "fir_filter.h" -#include "gen_signal_source.h" -#include "gnss_sdr_valve.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx; -typedef boost::shared_ptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr; +using GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr = boost::shared_ptr; -GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(concurrent_queue& queue); +GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(Concurrent_Queue& queue); class GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx : public gr::block { private: - friend GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(concurrent_queue& queue); + friend GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -71,7 +77,7 @@ public: }; -GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(concurrent_queue& queue) +GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(Concurrent_Queue& queue) { return GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr(new GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(queue)); } @@ -81,7 +87,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::msg_handler_events(pmt: { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -93,16 +99,14 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::msg_handler_events(pmt: } -GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(concurrent_queue& queue) : gr::block("GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(Concurrent_Queue& queue) : gr::block("GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::msg_handler_events, this, _1)); rx_message = 0; } -GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx() -{ -} +GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx() = default; // ########################################################### @@ -120,9 +124,7 @@ protected: init(); } - ~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest() - { - } + ~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest() = default; void init(); void config_1(); @@ -132,7 +134,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr acquisition; @@ -142,7 +144,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -243,7 +245,6 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::config_1() config->set_property("InputFilter.grid_density", "16"); config->set_property("Acquisition_1B.item_type", "gr_complex"); - config->set_property("Acquisition_1B.if", "0"); config->set_property("Acquisition_1B.coherent_integration_time_ms", std::to_string(integration_time_ms)); config->set_property("Acquisition_1B.max_dwells", "1"); @@ -346,7 +347,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::config_2() void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::start_queue() { stop = false; - ch_thread = boost::thread(&GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::wait_message, this); + ch_thread = std::thread(&GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::wait_message, this); } @@ -424,7 +425,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::stop_queue() TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, Instantiate) { config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); } @@ -439,7 +440,7 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(channel_internal_queue); @@ -468,7 +469,7 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults) config_1(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(channel_internal_queue); @@ -548,16 +549,10 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults) { EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; } -#ifdef OLD_BOOST + ASSERT_NO_THROW({ - ch_thread.timed_join(boost::posix_time::seconds(1)); + ch_thread.join(); }) << "Failure while waiting the queue to stop"; -#endif -#ifndef OLD_BOOST - ASSERT_NO_THROW({ - ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); - }) << "Failure while waiting the queue to stop"; -#endif } } @@ -567,7 +562,7 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabili config_2(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(channel_internal_queue); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc index 13b86aa6a..f2229bc57 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc @@ -31,25 +31,31 @@ */ +#include "fir_filter.h" +#include "galileo_e1_pcps_quicksync_ambiguous_acquisition.h" +#include "gen_signal_source.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" +#include "signal_generator.h" +#include "signal_generator_c.h" +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" -#include "signal_generator.h" -#include "signal_generator_c.h" -#include "fir_filter.h" -#include "gen_signal_source.h" -#include "gnss_sdr_valve.h" -#include "galileo_e1_pcps_quicksync_ambiguous_acquisition.h" +#endif DEFINE_double(e1_value_threshold, 0.3, "Value of the threshold for the acquisition"); DEFINE_int32(e1_value_CN0_dB_0, 50, "Value for the CN0_dB_0 in channel 0"); @@ -60,18 +66,18 @@ using google::LogMessage; // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx; -typedef boost::shared_ptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr; +using GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr = boost::shared_ptr; -GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(concurrent_queue& queue); +GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue); class GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx : public gr::block { private: - friend GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(concurrent_queue& queue); + friend GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -79,7 +85,7 @@ public: }; -GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(concurrent_queue& queue) +GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue) { return GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr(new GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx(queue)); } @@ -89,7 +95,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::msg_handler_ { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -101,7 +107,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::msg_handler_ } -GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx(concurrent_queue& queue) : gr::block("GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue) : gr::block("GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::msg_handler_events, this, _1)); @@ -109,9 +115,7 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::GalileoE1PcpsQuic } -GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx() -{ -} +GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx() = default; // ########################################################### @@ -128,9 +132,7 @@ protected: gnss_synchro = Gnss_Synchro(); init(); } - ~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test() - { - } + ~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test() = default; void init(); void config_1(); @@ -141,7 +143,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr acquisition; @@ -151,7 +153,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -461,7 +463,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::config_3() void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::start_queue() { stop = false; - ch_thread = boost::thread(&GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::wait_message, this); + ch_thread = std::thread(&GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::wait_message, this); } @@ -548,7 +550,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::stop_queue() TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, Instantiate) { config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); } @@ -564,7 +566,7 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ConnectAndRun) config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(channel_internal_queue); @@ -599,7 +601,7 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(channel_internal_queue); @@ -690,7 +692,7 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(channel_internal_queue); @@ -778,7 +780,7 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(channel_internal_queue); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc index 4f7bbea08..a021e5196 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc @@ -30,42 +30,47 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "configuration_interface.h" -#include "gnss_synchro.h" +#include "fir_filter.h" #include "galileo_e1_pcps_tong_ambiguous_acquisition.h" +#include "gen_signal_source.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" #include "signal_generator.h" #include "signal_generator_c.h" -#include "fir_filter.h" -#include "gen_signal_source.h" -#include "gnss_sdr_valve.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx; -typedef boost::shared_ptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr; +using GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr = boost::shared_ptr; -GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); +GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); class GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::block { private: - friend GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); + friend GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -73,7 +78,7 @@ public: }; -GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue) +GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue) { return GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr(new GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx(queue)); } @@ -83,7 +88,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_event { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -95,7 +100,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_event } -GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue) : gr::block("GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue) : gr::block("GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::msg_handler_events, this, _1)); @@ -103,9 +108,7 @@ GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsTongAmbig } -GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx() -{ -} +GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx() = default; class GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test : public ::testing::Test @@ -121,9 +124,7 @@ protected: init(); } - ~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test() - { - } + ~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test() = default; void init(); void config_1(); @@ -133,7 +134,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr acquisition; @@ -143,7 +144,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -348,7 +349,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::config_2() void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::start_queue() { stop = false; - ch_thread = boost::thread(&GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::wait_message, this); + ch_thread = std::thread(&GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::wait_message, this); } @@ -426,7 +427,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::stop_queue() TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, Instantiate) { config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); } @@ -439,7 +440,7 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); config_1(); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); ASSERT_NO_THROW({ @@ -466,7 +467,7 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) config_1(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); @@ -555,7 +556,7 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsPro config_2(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 1); + std::shared_ptr acq_ = factory->GetBlock(config, "Acquisition_1B", "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition", 1, 0); acquisition = std::dynamic_pointer_cast(acq_); boost::shared_ptr msg_rx = GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index 52bafb284..f90407d0d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -29,40 +29,45 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include #include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" +#endif +#include "fir_filter.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" +#include "gen_signal_source.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" +#include "pass_through.h" #include "signal_generator.h" #include "signal_generator_c.h" -#include "fir_filter.h" -#include "gen_signal_source.h" -#include "gnss_sdr_valve.h" -#include "pass_through.h" +#include +#include // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx; -typedef boost::shared_ptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr; +using GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr = boost::shared_ptr; -GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(concurrent_queue& queue); +GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(Concurrent_Queue& queue); class GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx : public gr::block { private: - friend GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(concurrent_queue& queue); + friend GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -70,7 +75,7 @@ public: }; -GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(concurrent_queue& queue) +GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(Concurrent_Queue& queue) { return GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr(new GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx(queue)); } @@ -80,7 +85,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::msg_handler_events(p { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -92,7 +97,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::msg_handler_events(p } -GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx(concurrent_queue& queue) : gr::block("GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx(Concurrent_Queue& queue) : gr::block("GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::msg_handler_events, this, _1)); @@ -100,9 +105,7 @@ GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::GalileoE5aPcpsAcquisition } -GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx() -{ -} +GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx() = default; class GalileoE5aPcpsAcquisitionGSoC2014GensourceTest : public ::testing::Test @@ -117,9 +120,7 @@ protected: init(); } - ~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest() - { - } + ~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest() = default; void init(); void config_1(); @@ -130,7 +131,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr acquisition; @@ -140,7 +141,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -409,7 +410,6 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_3() config->set_property("InputFilter.grid_density", "16"); config->set_property("Acquisition_5X.item_type", "gr_complex"); - config->set_property("Acquisition_5X.if", "0"); config->set_property("Acquisition_5X.coherent_integration_time_ms", std::to_string(integration_time_ms)); config->set_property("Acquisition_5X.max_dwells", "1"); @@ -426,7 +426,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_3() void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::start_queue() { stop = false; - ch_thread = boost::thread(&GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::wait_message, this); + ch_thread = std::thread(&GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::wait_message, this); } @@ -528,7 +528,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::stop_queue() TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, Instantiate) { config_1(); - acquisition = std::make_shared(config.get(), "Acquisition_5X", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_5X", 1, 0); } @@ -539,7 +539,7 @@ TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, ConnectAndRun) int nsamples = 21000 * 3; std::chrono::time_point start, end; std::chrono::duration elapsed_seconds(0); - acquisition = std::make_shared(config.get(), "Acquisition_5X", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_5X", 1, 0); boost::shared_ptr msg_rx = GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(channel_internal_queue); queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); @@ -569,7 +569,7 @@ TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, ValidationOfSIM) config_1(); queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - acquisition = std::make_shared(config.get(), "Acquisition_5X", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_5X", 1, 0); boost::shared_ptr msg_rx = GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc index 4822dcccb..dbee4f413 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc @@ -31,43 +31,48 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "configuration_interface.h" -#include "gnss_synchro.h" +#include "freq_xlating_fir_filter.h" +#include "gen_signal_source.h" #include "glonass_l1_ca_pcps_acquisition.h" +#include "gnss_block_interface.h" +#include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" +#include "pass_through.h" #include "signal_generator.h" #include "signal_generator_c.h" -#include "fir_filter.h" -#include "gen_signal_source.h" -#include "gnss_sdr_valve.h" -#include "boost/shared_ptr.hpp" -#include "pass_through.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx; -typedef boost::shared_ptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr; +using GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr = boost::shared_ptr; -GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(concurrent_queue& queue); +GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(Concurrent_Queue& queue); class GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx : public gr::block { private: - friend GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(concurrent_queue& queue); + friend GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -75,7 +80,7 @@ public: }; -GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(concurrent_queue& queue) +GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(Concurrent_Queue& queue) { return GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr(new GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx(queue)); } @@ -85,7 +90,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::msg_handler_events(pmt::pmt_ { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -97,7 +102,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::msg_handler_events(pmt::pmt_ } -GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx(concurrent_queue& queue) : gr::block("GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx(Concurrent_Queue& queue) : gr::block("GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::msg_handler_events, this, _1)); @@ -105,9 +110,7 @@ GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::GlonassL1CaPcpsAcquisitionGSoC201 } -GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::~GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx() -{ -} +GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::~GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx() = default; // ########################################################### @@ -121,13 +124,11 @@ protected: stop = false; message = 0; gnss_synchro = Gnss_Synchro(); - acquisition = 0; + acquisition = nullptr; init(); } - ~GlonassL1CaPcpsAcquisitionGSoC2017Test() - { - } + ~GlonassL1CaPcpsAcquisitionGSoC2017Test() = default; void init(); void config_1(); @@ -137,7 +138,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; @@ -147,7 +148,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -226,7 +227,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_1() config->set_property("SignalSource.data_flag", "false"); config->set_property("SignalSource.BW_BB", "0.97"); - config->set_property("InputFilter.implementation", "Fir_Filter"); + config->set_property("InputFilter.implementation", "Freq_Xlating_Fir_Filter"); config->set_property("InputFilter.input_item_type", "gr_complex"); config->set_property("InputFilter.output_item_type", "gr_complex"); config->set_property("InputFilter.taps_item_type", "float"); @@ -244,9 +245,10 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_1() config->set_property("InputFilter.band2_error", "1.0"); config->set_property("InputFilter.filter_type", "bandpass"); config->set_property("InputFilter.grid_density", "16"); + config->set_property("InputFilter.sampling_frequency", std::to_string(fs_in)); + config->set_property("InputFilter.IF", "4000000"); config->set_property("Acquisition.item_type", "gr_complex"); - config->set_property("Acquisition.if", "4000000"); config->set_property("Acquisition.coherent_integration_time_ms", std::to_string(integration_time_ms)); config->set_property("Acquisition.max_dwells", "1"); @@ -314,7 +316,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_2() config->set_property("SignalSource.data_flag", "true"); config->set_property("SignalSource.BW_BB", "0.97"); - config->set_property("InputFilter.implementation", "Fir_Filter"); + config->set_property("InputFilter.implementation", "Freq_Xlating_Fir_Filter"); config->set_property("InputFilter.input_item_type", "gr_complex"); config->set_property("InputFilter.output_item_type", "gr_complex"); config->set_property("InputFilter.taps_item_type", "float"); @@ -332,14 +334,15 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_2() config->set_property("InputFilter.band2_error", "1.0"); config->set_property("InputFilter.filter_type", "bandpass"); config->set_property("InputFilter.grid_density", "16"); + config->set_property("InputFilter.sampling_frequency", std::to_string(fs_in)); + config->set_property("InputFilter.IF", "4000000"); config->set_property("Acquisition.item_type", "gr_complex"); - config->set_property("Acquisition.if", "4000000"); config->set_property("Acquisition.coherent_integration_time_ms", std::to_string(integration_time_ms)); config->set_property("Acquisition.max_dwells", "1"); config->set_property("Acquisition.implementation", "GLONASS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition.pfa", "0.1"); + //config->set_property("Acquisition.pfa", "0.1"); config->set_property("Acquisition.doppler_max", "10000"); config->set_property("Acquisition.doppler_step", "250"); config->set_property("Acquisition.bit_transition_flag", "false"); @@ -350,26 +353,26 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_2() void GlonassL1CaPcpsAcquisitionGSoC2017Test::start_queue() { stop = false; - ch_thread = boost::thread(&GlonassL1CaPcpsAcquisitionGSoC2017Test::wait_message, this); + ch_thread = std::thread(&GlonassL1CaPcpsAcquisitionGSoC2017Test::wait_message, this); } void GlonassL1CaPcpsAcquisitionGSoC2017Test::wait_message() { struct timeval tv; - long long int begin = 0; - long long int end = 0; + int64_t begin = 0; + int64_t end = 0; while (!stop) { acquisition->reset(); - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); begin = tv.tv_sec * 1e6 + tv.tv_usec; channel_internal_queue.wait_and_pop(message); - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); end = tv.tv_sec * 1e6 + tv.tv_usec; mean_acq_time_us += (end - begin); @@ -429,7 +432,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::stop_queue() TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, Instantiate) { config_1(); - acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1); + acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 0); delete acquisition; } @@ -443,7 +446,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); config_1(); - acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1); + acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 0); boost::shared_ptr msg_rx = GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -474,7 +477,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults) queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1); + acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 0); boost::shared_ptr msg_rx = GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -494,7 +497,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults) }) << "Failure setting doppler_step."; ASSERT_NO_THROW({ - acquisition->set_threshold(0.5); + acquisition->set_threshold(0.05); }) << "Failure setting threshold."; ASSERT_NO_THROW({ @@ -505,12 +508,11 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults) acquisition->init(); ASSERT_NO_THROW({ - boost::shared_ptr signal_source; - SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue); - FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1); - signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue)); - signal_source->connect(top_block); - top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0); + std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue); + std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); + signal_generator->connect(top_block); + top_block->connect(signal_generator->get_right_block(), 0, filter->get_left_block(), 0); + top_block->connect(filter->get_right_block(), 0, acquisition->get_left_block(), 0); }) << "Failure connecting the blocks of acquisition test."; // i = 0 --> satellite in acquisition is visible @@ -548,16 +550,10 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults) { EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; } -#ifdef OLD_BOOST + ASSERT_NO_THROW({ - ch_thread.timed_join(boost::posix_time::seconds(1)); - }) << "Failure while waiting the queue to stop."; -#endif -#ifndef OLD_BOOST - ASSERT_NO_THROW({ - ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); + ch_thread.join(); }) << "Failure while waiting the queue to stop"; -#endif } delete acquisition; @@ -569,51 +565,43 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResultsProbabilities) config_2(); queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1); + acquisition = new GlonassL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 0); boost::shared_ptr msg_rx = GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ acquisition->set_channel(1); - }) << "Failure setting channel." - << std::endl; + }) << "Failure setting channel."; ASSERT_NO_THROW({ acquisition->set_gnss_synchro(&gnss_synchro); - }) << "Failure setting gnss_synchro." - << std::endl; + }) << "Failure setting gnss_synchro."; ASSERT_NO_THROW({ acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); - }) << "Failure setting doppler_max." - << std::endl; + }) << "Failure setting doppler_max."; ASSERT_NO_THROW({ acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); - }) << "Failure setting doppler_step." - << std::endl; + }) << "Failure setting doppler_step."; ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); - }) << "Failure setting threshold." - << std::endl; + }) << "Failure setting threshold."; ASSERT_NO_THROW({ acquisition->connect(top_block); top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - }) << "Failure connecting acquisition to the top_block." - << std::endl; + }) << "Failure connecting acquisition to the top_block."; acquisition->init(); ASSERT_NO_THROW({ - boost::shared_ptr signal_source; - SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue); - FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1); - signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue)); - signal_source->connect(top_block); - top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0); - }) << "Failure connecting the blocks of acquisition test." - << std::endl; + std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue); + std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); + signal_generator->connect(top_block); + top_block->connect(signal_generator->get_right_block(), 0, filter->get_left_block(), 0); + top_block->connect(filter->get_right_block(), 0, acquisition->get_left_block(), 0); + }) << "Failure connecting the blocks of acquisition test."; std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl; @@ -652,18 +640,11 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResultsProbabilities) std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; } -#ifdef OLD_BOOST + ASSERT_NO_THROW({ - ch_thread.timed_join(boost::posix_time::seconds(1)); + ch_thread.join(); }) << "Failure while waiting the queue to stop" << std::endl; -#endif -#ifndef OLD_BOOST - ASSERT_NO_THROW({ - ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); - }) << "Failure while waiting the queue to stop" - << std::endl; -#endif } delete acquisition; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc index 04d37af1a..9cd20eefe 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc @@ -30,23 +30,28 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "freq_xlating_fir_filter.h" +#include "glonass_l1_ca_pcps_acquisition.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" -#include "glonass_l1_ca_pcps_acquisition.h" +#include "in_memory_configuration.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### @@ -79,7 +84,7 @@ void GlonassL1CaPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -98,9 +103,7 @@ GlonassL1CaPcpsAcquisitionTest_msg_rx::GlonassL1CaPcpsAcquisitionTest_msg_rx() : } -GlonassL1CaPcpsAcquisitionTest_msg_rx::~GlonassL1CaPcpsAcquisitionTest_msg_rx() -{ -} +GlonassL1CaPcpsAcquisitionTest_msg_rx::~GlonassL1CaPcpsAcquisitionTest_msg_rx() = default; // ########################################################### @@ -116,9 +119,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GlonassL1CaPcpsAcquisitionTest() - { - } + ~GlonassL1CaPcpsAcquisitionTest() = default; void init(); @@ -138,8 +139,26 @@ void GlonassL1CaPcpsAcquisitionTest::init() signal.copy(gnss_synchro.Signal, 2, 0); gnss_synchro.PRN = 1; config->set_property("GNSS-SDR.internal_fs_sps", "62314000"); + config->set_property("InputFilter.IF", "9540000"); + config->set_property("InputFilter.input_item_type", "gr_complex"); + config->set_property("InputFilter.output_item_type", "gr_complex"); + config->set_property("InputFilter.taps_item_type", "float"); + config->set_property("InputFilter.number_of_taps", "11"); + config->set_property("InputFilter.number_of_bands", "2"); + config->set_property("InputFilter.band1_begin", "0.0"); + config->set_property("InputFilter.band1_end", "0.97"); + config->set_property("InputFilter.band2_begin", "0.98"); + config->set_property("InputFilter.band2_end", "1.0"); + config->set_property("InputFilter.ampl1_begin", "1.0"); + config->set_property("InputFilter.ampl1_end", "1.0"); + config->set_property("InputFilter.ampl2_begin", "0.0"); + config->set_property("InputFilter.ampl2_end", "0.0"); + config->set_property("InputFilter.band1_error", "1.0"); + config->set_property("InputFilter.band2_error", "1.0"); + config->set_property("InputFilter.filter_type", "bandpass"); + config->set_property("InputFilter.grid_density", "16"); + config->set_property("InputFilter.sampling_frequency", "62314000"); config->set_property("Acquisition_1G.item_type", "gr_complex"); - config->set_property("Acquisition_1G.if", "9540000"); config->set_property("Acquisition_1G.coherent_integration_time_ms", "1"); config->set_property("Acquisition_1G.dump", "true"); config->set_property("Acquisition_1G.dump_filename", "./acquisition"); @@ -155,7 +174,7 @@ void GlonassL1CaPcpsAcquisitionTest::init() TEST_F(GlonassL1CaPcpsAcquisitionTest, Instantiate) { init(); - boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1G", 1, 1); + boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1G", 1, 0); } @@ -169,7 +188,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); init(); - boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1G", 1, 1); + boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1G", 1, 0); boost::shared_ptr msg_rx = GlonassL1CaPcpsAcquisitionTest_msg_rx_make(); ASSERT_NO_THROW({ @@ -201,8 +220,8 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ValidationOfResults) double expected_delay_samples = 31874; double expected_doppler_hz = -9500; init(); - std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_1G", 1, 1); - + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_1G", 1, 0); + std::shared_ptr input_filter = std::make_shared(config.get(), "InputFilter", 1, 1); boost::shared_ptr msg_rx = GlonassL1CaPcpsAcquisitionTest_msg_rx_make(); ASSERT_NO_THROW({ @@ -238,7 +257,8 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ValidationOfResults) std::string file = path + "signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat"; const char* file_name = file.c_str(); gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(gr_complex), file_name, false); - top_block->connect(file_source, 0, acquisition->get_left_block(), 0); + top_block->connect(file_source, 0, input_filter->get_left_block(), 0); + top_block->connect(input_filter->get_right_block(), 0, acquisition->get_left_block(), 0); top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); }) << "Failure connecting the blocks of acquisition test."; @@ -249,7 +269,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ValidationOfResults) elapsed_seconds = end - begin; }) << "Failure running the top_block."; - unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples; + uint64_t nsamples = gnss_synchro.Acq_samplestamp_samples; std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc index f19aeceb0..ba0611f90 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc @@ -30,27 +30,31 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "configuration_interface.h" -#include "gnss_synchro.h" -#include "glonass_l2_ca_pcps_acquisition.h" -#include "signal_generator.h" -#include "signal_generator_c.h" #include "fir_filter.h" #include "gen_signal_source.h" +#include "glonass_l2_ca_pcps_acquisition.h" +#include "gnss_block_interface.h" #include "gnss_sdr_valve.h" -#include "boost/shared_ptr.hpp" +#include "gnss_synchro.h" +#include "in_memory_configuration.h" #include "pass_through.h" - +#include "signal_generator.h" +#include "signal_generator_c.h" +#include "boost/shared_ptr.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GlonassL2CaPcpsAcquisitionTest_msg_rx; @@ -84,7 +88,7 @@ void GlonassL2CaPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(msg); rx_message = message; channel_internal_queue.push(rx_message); } @@ -146,7 +150,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -245,7 +249,6 @@ void GlonassL2CaPcpsAcquisitionTest::config_1() config->set_property("InputFilter.grid_density", "16"); config->set_property("Acquisition_2G.item_type", "gr_complex"); - config->set_property("Acquisition_2G.if", "4000000"); config->set_property("Acquisition_2G.coherent_integration_time_ms", std::to_string(integration_time_ms)); config->set_property("Acquisition_2G.max_dwells", "1"); @@ -333,7 +336,6 @@ void GlonassL2CaPcpsAcquisitionTest::config_2() config->set_property("InputFilter.grid_density", "16"); config->set_property("Acquisition_2G.item_type", "gr_complex"); - config->set_property("Acquisition_2G.if", "4000000"); config->set_property("Acquisition_2G.coherent_integration_time_ms", std::to_string(integration_time_ms)); config->set_property("Acquisition_2G.max_dwells", "1"); @@ -349,15 +351,15 @@ void GlonassL2CaPcpsAcquisitionTest::config_2() void GlonassL2CaPcpsAcquisitionTest::start_queue() { stop = false; - ch_thread = boost::thread(&GlonassL2CaPcpsAcquisitionTest::wait_message, this); + ch_thread = std::thread(&GlonassL2CaPcpsAcquisitionTest::wait_message, this); } void GlonassL2CaPcpsAcquisitionTest::wait_message() { struct timeval tv; - long long int begin = 0; - long long int end = 0; + int64_t begin = 0; + int64_t end = 0; while (!stop) { @@ -428,7 +430,7 @@ void GlonassL2CaPcpsAcquisitionTest::stop_queue() TEST_F(GlonassL2CaPcpsAcquisitionTest, Instantiate) { config_1(); - acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition", 1, 1); + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition", 1, 0); delete acquisition; } @@ -442,7 +444,7 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); config_1(); - acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 1); + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 0); boost::shared_ptr msg_rx = GlonassL2CaPcpsAcquisitionTest_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -473,7 +475,7 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResults) queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 1); + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 0); boost::shared_ptr msg_rx = GlonassL2CaPcpsAcquisitionTest_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -547,16 +549,10 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResults) { EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; } -#ifdef OLD_BOOST + ASSERT_NO_THROW({ - ch_thread.timed_join(boost::posix_time::seconds(1)); - }) << "Failure while waiting the queue to stop."; -#endif -#ifndef OLD_BOOST - ASSERT_NO_THROW({ - ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); + ch_thread.join(); }) << "Failure while waiting the queue to stop"; -#endif } delete acquisition; @@ -568,7 +564,7 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResultsProbabilities) config_2(); queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 1); + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 0); boost::shared_ptr msg_rx = GlonassL2CaPcpsAcquisitionTest_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -643,16 +639,10 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResultsProbabilities) std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; } -#ifdef OLD_BOOST + ASSERT_NO_THROW({ - ch_thread.timed_join(boost::posix_time::seconds(1)); + ch_thread.join(); }) << "Failure while waiting the queue to stop"; -#endif -#ifndef OLD_BOOST - ASSERT_NO_THROW({ - ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); - }) << "Failure while waiting the queue to stop"; -#endif } delete acquisition; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc index bb00e62bf..e4ef9974b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc @@ -31,43 +31,49 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "configuration_interface.h" -#include "gnss_synchro.h" -#include "gps_l1_ca_pcps_acquisition.h" -#include "signal_generator.h" -#include "signal_generator_c.h" #include "fir_filter.h" #include "gen_signal_source.h" +#include "gnss_block_interface.h" #include "gnss_sdr_valve.h" -#include "boost/shared_ptr.hpp" +#include "gnss_synchro.h" +#include "gps_l1_ca_pcps_acquisition.h" +#include "in_memory_configuration.h" #include "pass_through.h" +#include "signal_generator.h" +#include "signal_generator_c.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx; -typedef boost::shared_ptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr; +using GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr = boost::shared_ptr; -GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); +GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); class GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx : public gr::block { private: - friend GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); + friend GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -75,7 +81,7 @@ public: }; -GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue) +GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue) { return GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr(new GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx(queue)); } @@ -85,7 +91,7 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::msg_handler_events(pmt::pmt_t ms { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -97,16 +103,14 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::msg_handler_events(pmt::pmt_t ms } -GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue) : gr::block("GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue) : gr::block("GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::msg_handler_events, this, _1)); rx_message = 0; } -GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx() -{ -} +GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -120,13 +124,11 @@ protected: stop = false; message = 0; gnss_synchro = Gnss_Synchro(); - acquisition = 0; + acquisition = nullptr; init(); } - ~GpsL1CaPcpsAcquisitionGSoC2013Test() - { - } + ~GpsL1CaPcpsAcquisitionGSoC2013Test() = default; void init(); void config_1(); @@ -136,7 +138,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; @@ -146,7 +148,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -347,7 +349,7 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test::config_2() void GpsL1CaPcpsAcquisitionGSoC2013Test::start_queue() { stop = false; - ch_thread = boost::thread(&GpsL1CaPcpsAcquisitionGSoC2013Test::wait_message, this); + ch_thread = std::thread(&GpsL1CaPcpsAcquisitionGSoC2013Test::wait_message, this); } @@ -423,7 +425,7 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test::stop_queue() TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, Instantiate) { config_1(); - acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1); + acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 0); delete acquisition; } @@ -437,7 +439,7 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); config_1(); - acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition_1C", 1, 1); + acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -468,7 +470,7 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ValidationOfResults) queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition_1C", 1, 1); + acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -542,16 +544,10 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ValidationOfResults) { EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; } -#ifdef OLD_BOOST + ASSERT_NO_THROW({ - ch_thread.timed_join(boost::posix_time::seconds(1)); + ch_thread.join(); }) << "Failure while waiting the queue to stop"; -#endif -#ifndef OLD_BOOST - ASSERT_NO_THROW({ - ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); - }) << "Failure while waiting the queue to stop"; -#endif } delete acquisition; @@ -563,7 +559,7 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) config_2(); queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition_1C", 1, 1); + acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -638,16 +634,10 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; } -#ifdef OLD_BOOST + ASSERT_NO_THROW({ - ch_thread.timed_join(boost::posix_time::seconds(1)); + ch_thread.join(); }) << "Failure while waiting the queue to stop"; -#endif -#ifndef OLD_BOOST - ASSERT_NO_THROW({ - ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); - }) << "Failure while waiting the queue to stop"; -#endif } delete acquisition; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index b2b2ca866..8e6876aa9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -31,33 +31,38 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "GPS_L1_CA.h" +#include "acquisition_dump_reader.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" #include "gnuplot_i.h" -#include "GPS_L1_CA.h" -#include "test_flags.h" -#include "acquisition_dump_reader.h" #include "gps_l1_ca_pcps_acquisition.h" +#include "in_memory_configuration.h" +#include "test_flags.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CaPcpsAcquisitionTest_msg_rx; -typedef boost::shared_ptr GpsL1CaPcpsAcquisitionTest_msg_rx_sptr; +using GpsL1CaPcpsAcquisitionTest_msg_rx_sptr = boost::shared_ptr; GpsL1CaPcpsAcquisitionTest_msg_rx_sptr GpsL1CaPcpsAcquisitionTest_msg_rx_make(); @@ -84,7 +89,7 @@ void GpsL1CaPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast &e) @@ -103,9 +108,7 @@ GpsL1CaPcpsAcquisitionTest_msg_rx::GpsL1CaPcpsAcquisitionTest_msg_rx() : gr::blo } -GpsL1CaPcpsAcquisitionTest_msg_rx::~GpsL1CaPcpsAcquisitionTest_msg_rx() -{ -} +GpsL1CaPcpsAcquisitionTest_msg_rx::~GpsL1CaPcpsAcquisitionTest_msg_rx() = default; // ########################################################### @@ -123,9 +126,7 @@ protected: doppler_step = 100; } - ~GpsL1CaPcpsAcquisitionTest() - { - } + ~GpsL1CaPcpsAcquisitionTest() = default; void init(); void plot_grid(); @@ -133,7 +134,7 @@ protected: gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; - Gnss_Synchro gnss_synchro; + Gnss_Synchro gnss_synchro{}; size_t item_size; unsigned int doppler_max; unsigned int doppler_step; @@ -160,6 +161,7 @@ void GpsL1CaPcpsAcquisitionTest::init() config->set_property("Acquisition_1C.dump", "false"); } config->set_property("Acquisition_1C.dump_filename", "./tmp-acq-gps1/acquisition"); + config->set_property("Acquisition_1C.dump_channel", "1"); config->set_property("Acquisition_1C.threshold", "0.00001"); config->set_property("Acquisition_1C.doppler_max", std::to_string(doppler_max)); config->set_property("Acquisition_1C.doppler_step", std::to_string(doppler_step)); @@ -172,12 +174,15 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() { //load the measured values std::string basename = "./tmp-acq-gps1/acquisition_G_1C"; - unsigned int sat = static_cast(gnss_synchro.PRN); + auto sat = static_cast(gnss_synchro.PRN); - unsigned int samples_per_code = static_cast(round(4000000 / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); // !! - acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code); + auto samples_per_code = static_cast(round(4000000 / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); // !! + Acquisition_Dump_Reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code, 1); - if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; + if (!acq_dump.read_binary_acq()) + { + std::cout << "Error reading files" << std::endl; + } std::vector *doppler = &acq_dump.doppler; std::vector *samples = &acq_dump.samples; @@ -197,10 +202,18 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() { boost::filesystem::path p(gnuplot_executable); boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); + const std::string &gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); Gnuplot g1("lines"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } g1.set_title("GPS L1 C/A signal acquisition for satellite PRN #" + std::to_string(gnss_synchro.PRN)); g1.set_xlabel("Doppler [Hz]"); g1.set_ylabel("Sample"); @@ -209,7 +222,6 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() g1.savetops("GPS_L1_acq_grid"); g1.savetopdf("GPS_L1_acq_grid"); - g1.showonscreen(); } catch (const GnuplotException &ge) { @@ -227,7 +239,7 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() TEST_F(GpsL1CaPcpsAcquisitionTest, Instantiate) { init(); - boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1C", 1, 1); + boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1C", 1, 0); } @@ -241,7 +253,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); init(); - boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1C", 1, 1); + boost::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionTest_msg_rx_make(); ASSERT_NO_THROW({ @@ -285,7 +297,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults) boost::filesystem::create_directory(data_str); } - std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionTest_msg_rx_make(); ASSERT_NO_THROW({ @@ -332,12 +344,12 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults) elapsed_seconds = end - start; }) << "Failure running the top_block."; - unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples; + uint64_t nsamples = gnss_synchro.Acq_samplestamp_samples; std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); - float delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); + auto delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)"; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc index 050d6df2a..fd0da8297 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc @@ -29,26 +29,30 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" #include "gps_l1_ca_pcps_acquisition_fpga.h" - +#include "in_memory_configuration.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif #define DMA_ACQ_TRANSFER_SIZE 2046 // DMA transfer size for the acquisition #define RX_SIGNAL_MAX_VALUE 127 // 2^7 - 1 for 8-bit signed values @@ -200,7 +204,7 @@ void GpsL1CaPcpsAcquisitionTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast &e) @@ -222,9 +226,7 @@ GpsL1CaPcpsAcquisitionTestFpga_msg_rx::GpsL1CaPcpsAcquisitionTestFpga_msg_rx() : } -GpsL1CaPcpsAcquisitionTestFpga_msg_rx::~GpsL1CaPcpsAcquisitionTestFpga_msg_rx() -{ -} +GpsL1CaPcpsAcquisitionTestFpga_msg_rx::~GpsL1CaPcpsAcquisitionTestFpga_msg_rx() = default; class GpsL1CaPcpsAcquisitionTestFpga : public ::testing::Test @@ -238,9 +240,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsAcquisitionTestFpga() - { - } + ~GpsL1CaPcpsAcquisitionTestFpga() = default; void init(); @@ -382,7 +382,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTestFpga, ValidationOfResults) ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); - float delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); + auto delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)"; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc index 0f319a208..2eecb0e53 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc @@ -31,24 +31,29 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "configuration_interface.h" -#include "gnss_synchro.h" -#include "gps_l1_ca_pcps_opencl_acquisition.h" -#include "signal_generator.h" -#include "signal_generator_c.h" #include "fir_filter.h" #include "gen_signal_source.h" +#include "gnss_block_interface.h" #include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "gps_l1_ca_pcps_opencl_acquisition.h" +#include "in_memory_configuration.h" +#include "signal_generator.h" +#include "signal_generator_c.h" +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx; @@ -82,7 +87,7 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx::msg_handler_events(pmt::pm { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(msg); rx_message = message; channel_internal_queue.push(rx_message); } @@ -143,7 +148,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -344,7 +349,7 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::config_2() void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::start_queue() { stop = false; - ch_thread = boost::thread(&GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::wait_message, this); + ch_thread = std::thread(&GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::wait_message, this); } @@ -422,7 +427,7 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::stop_queue() TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, Instantiate) { config_1(); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); } @@ -433,7 +438,7 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun) std::chrono::duration elapsed_seconds(0); config_1(); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -460,7 +465,7 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults) { config_1(); - acquisition = std::make_shared(config.get(), "Acquisition", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -542,7 +547,7 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilitie { config_2(); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc index 5e1d072cd..db5e51af8 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc @@ -31,24 +31,30 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" +#include "gps_l1_ca_pcps_quicksync_acquisition.h" +#include "in_memory_configuration.h" #include "signal_generator.h" #include "signal_generator_c.h" -#include "gps_l1_ca_pcps_quicksync_acquisition.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif DEFINE_double(value_threshold, 1, "Value of the threshold for the acquisition"); DEFINE_int32(value_CN0_dB_0, 44, "Value for the CN0_dB_0 in channel 0"); @@ -58,18 +64,18 @@ using google::LogMessage; // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx; -typedef boost::shared_ptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr; +using GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr = boost::shared_ptr; -GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_make(concurrent_queue& queue); +GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue); class GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx : public gr::block { private: - friend GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_make(concurrent_queue& queue); + friend GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -77,7 +83,7 @@ public: }; -GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_make(concurrent_queue& queue) +GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue) { return GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr(new GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx(queue)); } @@ -87,7 +93,7 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::msg_handler_events(pmt: { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -99,7 +105,7 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::msg_handler_events(pmt: } -GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx(concurrent_queue& queue) : gr::block("GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue) : gr::block("GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::msg_handler_events, this, _1)); @@ -107,9 +113,7 @@ GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::GpsL1CaPcpsQuickSyncAcquisit } -GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx() -{ -} +GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx() = default; // ########################################################### @@ -126,9 +130,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test() - { - } + ~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test() = default; void init(); void config_1(); @@ -139,7 +141,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr factory; @@ -149,7 +151,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -453,7 +455,7 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::config_3() void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::start_queue() { stop = false; - ch_thread = boost::thread(&GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::wait_message, this); + ch_thread = std::thread(&GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::wait_message, this); } @@ -534,7 +536,7 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::stop_queue() TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, Instantiate) { config_1(); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); } @@ -548,7 +550,7 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ConnectAndRun) boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); config_1(); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); ASSERT_NO_THROW({ acquisition->connect(top_block); @@ -575,7 +577,7 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResults) config_1(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -669,7 +671,7 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResultsWithNoise config_1(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -760,7 +762,7 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResultsProbabili config_2(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index ef1502cd5..b5977ff39 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -31,41 +31,47 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "configuration_interface.h" -#include "gnss_synchro.h" -#include "gps_l1_ca_pcps_tong_acquisition.h" -#include "signal_generator.h" -#include "signal_generator_c.h" #include "fir_filter.h" #include "gen_signal_source.h" +#include "gnss_block_interface.h" #include "gnss_sdr_valve.h" +#include "gnss_synchro.h" +#include "gps_l1_ca_pcps_tong_acquisition.h" +#include "in_memory_configuration.h" +#include "signal_generator.h" +#include "signal_generator_c.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx; -typedef boost::shared_ptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr; +using GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr = boost::shared_ptr; -GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); +GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); class GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx : public gr::block { private: - friend GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue); + friend GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue); - concurrent_queue& channel_internal_queue; + GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + Concurrent_Queue& channel_internal_queue; public: int rx_message; @@ -73,7 +79,7 @@ public: }; -GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(concurrent_queue& queue) +GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue) { return GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr(new GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx(queue)); } @@ -83,7 +89,7 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::msg_handler_events(pmt::pmt_ { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -95,16 +101,14 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::msg_handler_events(pmt::pmt_ } -GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx(concurrent_queue& queue) : gr::block("GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue) : gr::block("GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::msg_handler_events, this, _1)); rx_message = 0; } -GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx() -{ -} +GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -120,9 +124,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsTongAcquisitionGSoC2013Test() - { - } + ~GpsL1CaPcpsTongAcquisitionGSoC2013Test() = default; void init(); void config_1(); @@ -132,7 +134,7 @@ protected: void process_message(); void stop_queue(); - concurrent_queue channel_internal_queue; + Concurrent_Queue channel_internal_queue; gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr acquisition; @@ -141,7 +143,7 @@ protected: size_t item_size; bool stop; int message; - boost::thread ch_thread; + std::thread ch_thread; unsigned int integration_time_ms = 0; unsigned int fs_in = 0; @@ -342,7 +344,7 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::config_2() void GpsL1CaPcpsTongAcquisitionGSoC2013Test::start_queue() { stop = false; - ch_thread = boost::thread(&GpsL1CaPcpsTongAcquisitionGSoC2013Test::wait_message, this); + ch_thread = std::thread(&GpsL1CaPcpsTongAcquisitionGSoC2013Test::wait_message, this); } @@ -419,7 +421,7 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::stop_queue() TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, Instantiate) { config_1(); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); } @@ -432,7 +434,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun) queue = gr::msg_queue::make(0); config_1(); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -461,7 +463,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ @@ -549,7 +551,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) config_2(); top_block = gr::make_top_block("Acquisition test"); queue = gr::msg_queue::make(0); - acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 1); + acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); boost::shared_ptr msg_rx = GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue); ASSERT_NO_THROW({ diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc index 952ed26a2..add12d00b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc @@ -31,28 +31,33 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "GPS_L2C.h" +#include "acquisition_dump_reader.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" #include "gnuplot_i.h" -#include "test_flags.h" -#include "acquisition_dump_reader.h" #include "gps_l2_m_pcps_acquisition.h" -#include "GPS_L2C.h" +#include "in_memory_configuration.h" +#include "test_flags.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### @@ -83,7 +88,7 @@ void GpsL2MPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast &e) @@ -100,9 +105,7 @@ GpsL2MPcpsAcquisitionTest_msg_rx::GpsL2MPcpsAcquisitionTest_msg_rx() : gr::block rx_message = 0; } -GpsL2MPcpsAcquisitionTest_msg_rx::~GpsL2MPcpsAcquisitionTest_msg_rx() -{ -} +GpsL2MPcpsAcquisitionTest_msg_rx::~GpsL2MPcpsAcquisitionTest_msg_rx() = default; // ########################################################### @@ -122,9 +125,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL2MPcpsAcquisitionTest() - { - } + ~GpsL2MPcpsAcquisitionTest() = default; void init(); void plot_grid(); @@ -163,7 +164,8 @@ void GpsL2MPcpsAcquisitionTest::init() { config->set_property("Acquisition_2S.dump", "false"); } - config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition"); + config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition_test"); + config->set_property("Acquisition_2S.dump_channel", "1"); config->set_property("Acquisition_2S.threshold", "0.001"); config->set_property("Acquisition_2S.doppler_max", std::to_string(doppler_max)); config->set_property("Acquisition_2S.doppler_step", std::to_string(doppler_step)); @@ -175,12 +177,15 @@ void GpsL2MPcpsAcquisitionTest::init() void GpsL2MPcpsAcquisitionTest::plot_grid() { //load the measured values - std::string basename = "./tmp-acq-gps2/acquisition_G_2S"; - unsigned int sat = static_cast(gnss_synchro.PRN); + std::string basename = "./tmp-acq-gps2/acquisition_test_G_2S"; + auto sat = static_cast(gnss_synchro.PRN); - unsigned int samples_per_code = static_cast(floor(static_cast(sampling_frequency_hz) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); - acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code); - if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; + auto samples_per_code = static_cast(floor(static_cast(sampling_frequency_hz) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); + Acquisition_Dump_Reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code, 1); + if (!acq_dump.read_binary_acq()) + { + std::cout << "Error reading files" << std::endl; + } std::vector *doppler = &acq_dump.doppler; std::vector *samples = &acq_dump.samples; @@ -200,10 +205,18 @@ void GpsL2MPcpsAcquisitionTest::plot_grid() { boost::filesystem::path p(gnuplot_executable); boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); + const std::string &gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); Gnuplot g1("impulses"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } g1.set_title("GPS L2CM signal acquisition for satellite PRN #" + std::to_string(gnss_synchro.PRN)); g1.set_xlabel("Doppler [Hz]"); g1.set_ylabel("Sample"); @@ -212,7 +225,6 @@ void GpsL2MPcpsAcquisitionTest::plot_grid() g1.savetops("GPS_L2CM_acq_grid"); g1.savetopdf("GPS_L2CM_acq_grid"); - g1.showonscreen(); } catch (const GnuplotException &ge) { @@ -231,7 +243,7 @@ TEST_F(GpsL2MPcpsAcquisitionTest, Instantiate) { init(); queue = gr::msg_queue::make(0); - std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_2S", 1, 1); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_2S", 1, 0); } @@ -243,7 +255,7 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ConnectAndRun) queue = gr::msg_queue::make(0); init(); - std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_2S", 1, 1); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_2S", 1, 0); ASSERT_NO_THROW({ acquisition->connect(top_block); @@ -285,7 +297,7 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults) } init(); - std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_2S", 1, 1); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_2S", 1, 0); boost::shared_ptr msg_rx = GpsL2MPcpsAcquisitionTest_msg_rx_make(); ASSERT_NO_THROW({ @@ -350,7 +362,7 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults) ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); - float delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); + auto delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); EXPECT_LE(doppler_error_hz, 200) << "Doppler error exceeds the expected value: 2/(3*integration period)"; diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc index 2aae6e9c6..89f2cd338 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc @@ -29,22 +29,22 @@ * ------------------------------------------------------------------------- */ +#include "byte_to_short.h" +#include "ibyte_to_cbyte.h" +#include "ibyte_to_complex.h" +#include "ibyte_to_cshort.h" +#include "in_memory_configuration.h" +#include "ishort_to_complex.h" +#include "ishort_to_cshort.h" +#include +#include +#include #include #include #include #include #include #include -#include -#include -#include -#include "byte_to_short.h" -#include "ibyte_to_cbyte.h" -#include "ibyte_to_complex.h" -#include "ibyte_to_cshort.h" -#include "ishort_to_complex.h" -#include "ishort_to_cshort.h" -#include "in_memory_configuration.h" class DataTypeAdapter : public ::testing::Test @@ -61,7 +61,7 @@ public: std::string file_name_input; std::string file_name_output; std::vector input_data_bytes; - std::vector input_data_shorts; + std::vector input_data_shorts; }; @@ -70,19 +70,17 @@ DataTypeAdapter::DataTypeAdapter() file_name_input = "adapter_test_input.dat"; file_name_output = "adapter_test_output.dat"; int8_t input_bytes[] = {2, 23, -1, 127, -127, 0}; - short input_shorts[] = {2, 23, -1, 127, -127, 0, 255, 255}; + int16_t input_shorts[] = {2, 23, -1, 127, -127, 0, 255, 255}; const std::vector input_data_bytes_(input_bytes, input_bytes + sizeof(input_bytes) / sizeof(int8_t)); input_data_bytes = input_data_bytes_; - const std::vector input_data_shorts_(input_shorts, input_shorts + sizeof(input_shorts) / sizeof(short)); + const std::vector input_data_shorts_(input_shorts, input_shorts + sizeof(input_shorts) / sizeof(int16_t)); input_data_shorts = input_data_shorts_; } -DataTypeAdapter::~DataTypeAdapter() -{ -} +DataTypeAdapter::~DataTypeAdapter() = default; int DataTypeAdapter::run_ishort_to_cshort_block() @@ -94,15 +92,14 @@ int DataTypeAdapter::run_ishort_to_cshort_block() EXPECT_EQ(expected_implementation, ishort_to_cshort->implementation()); std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary); - for (std::vector::const_iterator i = input_data_shorts.cbegin(); i != input_data_shorts.cend(); ++i) + for (int16_t aux : input_data_shorts) { - short aux = *i; - ofs.write(reinterpret_cast(&aux), sizeof(short)); + ofs.write(reinterpret_cast(&aux), sizeof(int16_t)); } ofs.close(); auto top_block = gr::make_top_block("Ishort_To_Cshort test"); - auto file_source = gr::blocks::file_source::make(sizeof(short), file_name_input.c_str()); + auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str()); auto sink = gr::blocks::file_sink::make(sizeof(lv_16sc_t), file_name_output.c_str(), false); EXPECT_NO_THROW({ @@ -123,15 +120,14 @@ int DataTypeAdapter::run_ishort_to_complex_block() EXPECT_EQ(expected_implementation, ishort_to_complex->implementation()); std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary); - for (std::vector::const_iterator i = input_data_shorts.cbegin(); i != input_data_shorts.cend(); ++i) + for (int16_t aux : input_data_shorts) { - short aux = *i; - ofs.write(reinterpret_cast(&aux), sizeof(short)); + ofs.write(reinterpret_cast(&aux), sizeof(int16_t)); } ofs.close(); auto top_block = gr::make_top_block("Ishort_To_Complex test"); - auto file_source = gr::blocks::file_source::make(sizeof(short), file_name_input.c_str()); + auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str()); auto sink = gr::blocks::file_sink::make(sizeof(gr_complex), file_name_output.c_str(), false); EXPECT_NO_THROW({ @@ -152,9 +148,9 @@ int DataTypeAdapter::run_ibyte_to_cshort_block() EXPECT_EQ(expected_implementation, ibyte_to_cshort->implementation()); std::ofstream ofs(file_name_input.c_str()); - for (std::vector::const_iterator i = input_data_bytes.cbegin(); i != input_data_bytes.cend(); ++i) + for (signed char input_data_byte : input_data_bytes) { - ofs << *i; + ofs << input_data_byte; } ofs.close(); @@ -180,9 +176,9 @@ int DataTypeAdapter::run_ibyte_to_complex_block() EXPECT_EQ(expected_implementation, ibyte_to_complex->implementation()); std::ofstream ofs(file_name_input.c_str()); - for (std::vector::const_iterator i = input_data_bytes.cbegin(); i != input_data_bytes.cend(); ++i) + for (signed char input_data_byte : input_data_bytes) { - ofs << *i; + ofs << input_data_byte; } ofs.close(); @@ -208,15 +204,15 @@ int DataTypeAdapter::run_ibyte_to_cbyte_block() EXPECT_EQ(expected_implementation, ibyte_to_cbyte->implementation()); std::ofstream ofs(file_name_input.c_str()); - for (std::vector::const_iterator i = input_data_bytes.cbegin(); i != input_data_bytes.cend(); ++i) + for (signed char input_data_byte : input_data_bytes) { - ofs << *i; + ofs << input_data_byte; } ofs.close(); auto top_block = gr::make_top_block("Ibyte_To_Cbyte test"); auto file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name_input.c_str()); - auto sink = gr::blocks::file_sink::make(sizeof(short), file_name_output.c_str(), false); + auto sink = gr::blocks::file_sink::make(sizeof(int16_t), file_name_output.c_str(), false); EXPECT_NO_THROW({ top_block->connect(file_source, 0, ibyte_to_cbyte->get_left_block(), 0); @@ -236,9 +232,9 @@ int DataTypeAdapter::run_byte_to_short_block() EXPECT_EQ(expected_implementation, byte_to_short->implementation()); std::ofstream ofs(file_name_input.c_str()); - for (std::vector::const_iterator i = input_data_bytes.cbegin(); i != input_data_bytes.cend(); ++i) + for (signed char input_data_byte : input_data_bytes) { - ofs << *i; + ofs << input_data_byte; } ofs.close(); @@ -368,9 +364,9 @@ TEST_F(DataTypeAdapter, IshortToComplexValidationOfResults) { while (ifs.read(reinterpret_cast(&iSample), sizeof(gr_complex))) { - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); i++; } } @@ -394,9 +390,9 @@ TEST_F(DataTypeAdapter, IshortToCshortValidationOfResults) { while (ifs.read(reinterpret_cast(&iSample), sizeof(lv_16sc_t))) { - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); i++; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc index 224c073e1..e15c5d253 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc @@ -31,9 +31,9 @@ */ +#include "in_memory_configuration.h" #include "pass_through.h" #include -#include "in_memory_configuration.h" TEST(PassThroughTest, Instantiate) diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index 9095f93df..42fb1496a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -28,24 +28,28 @@ * ------------------------------------------------------------------------- */ +#include +#include +#include #include #include #include -#include -#include -#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include +#endif +#include "file_signal_source.h" +#include "fir_filter.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" +#include "in_memory_configuration.h" #include "interleaved_byte_to_complex_byte.h" #include "interleaved_short_to_complex_short.h" -#include "fir_filter.h" -#include "file_signal_source.h" +#include +#include +#include DEFINE_int32(filter_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -59,9 +63,7 @@ protected: item_size = sizeof(gr_complex); config = std::make_shared(); } - ~FirFilterTest() - { - } + ~FirFilterTest() = default; void init(); void configure_cbyte_cbyte(); @@ -135,7 +137,10 @@ TEST_F(FirFilterTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -145,7 +150,10 @@ TEST_F(FirFilterTest, InstantiateCshortCshort) configure_cshort_cshort(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -156,7 +164,10 @@ TEST_F(FirFilterTest, InstantiateCbyteCbyte) configure_cbyte_cbyte(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -167,7 +178,10 @@ TEST_F(FirFilterTest, InstantiateCbyteGrComplex) configure_cbyte_gr_complex(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -227,7 +241,7 @@ TEST_F(FirFilterTest, ConnectAndRunGrcomplex) ASSERT_NO_THROW({ filter->connect(top_block); - boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 1, 1, queue)); + boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 0, 1, queue)); source->connect(top_block); boost::shared_ptr null_sink = gr::blocks::null_sink::make(item_size); @@ -268,7 +282,7 @@ TEST_F(FirFilterTest, ConnectAndRunCshorts) ASSERT_NO_THROW({ filter->connect(top_block); - boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 1, 1, queue)); + boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 0, 1, queue)); source->connect(top_block); interleaved_short_to_complex_short_sptr ishort_to_cshort_ = make_interleaved_short_to_complex_short(); @@ -312,7 +326,7 @@ TEST_F(FirFilterTest, ConnectAndRunCbytes) ASSERT_NO_THROW({ filter->connect(top_block); - boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 1, 1, queue)); + boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 0, 1, queue)); source->connect(top_block); interleaved_byte_to_complex_byte_sptr ibyte_to_cbyte_ = make_interleaved_byte_to_complex_byte(); @@ -356,7 +370,7 @@ TEST_F(FirFilterTest, ConnectAndRunCbyteGrcomplex) ASSERT_NO_THROW({ filter->connect(top_block); - boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 1, 1, queue)); + boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 0, 1, queue)); source->connect(top_block); interleaved_byte_to_complex_byte_sptr ibyte_to_cbyte_ = make_interleaved_byte_to_complex_byte(); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc index e2be9358a..a77e9d853 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc @@ -28,22 +28,26 @@ * ------------------------------------------------------------------------- */ +#include +#include +#include #include #include #include -#include -#include -#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include +#endif +#include "file_signal_source.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" +#include "in_memory_configuration.h" #include "notch_filter_lite.h" -#include "file_signal_source.h" +#include +#include +#include DEFINE_int32(notch_filter_lite_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -58,9 +62,7 @@ protected: config = std::make_shared(); nsamples = FLAGS_notch_filter_lite_test_nsamples; } - ~NotchFilterLiteTest() - { - } + ~NotchFilterLiteTest() = default; void init(); void configure_gr_complex_gr_complex(); @@ -93,7 +95,10 @@ TEST_F(NotchFilterLiteTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new NotchFilterLite(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -150,7 +155,7 @@ TEST_F(NotchFilterLiteTest, ConnectAndRunGrcomplex) ASSERT_NO_THROW({ filter->connect(top_block); - boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 1, 1, queue)); + boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 0, 1, queue)); source->connect(top_block); boost::shared_ptr null_sink = gr::blocks::null_sink::make(item_size); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc index c879a2b75..943ac2fe2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc @@ -28,22 +28,26 @@ * ------------------------------------------------------------------------- */ +#include +#include +#include #include #include #include -#include -#include -#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include +#endif +#include "file_signal_source.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" +#include "in_memory_configuration.h" #include "notch_filter.h" -#include "file_signal_source.h" +#include +#include +#include DEFINE_int32(notch_filter_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -58,9 +62,7 @@ protected: config = std::make_shared(); nsamples = FLAGS_notch_filter_test_nsamples; } - ~NotchFilterTest() - { - } + ~NotchFilterTest() = default; void init(); void configure_gr_complex_gr_complex(); @@ -93,7 +95,10 @@ TEST_F(NotchFilterTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new NotchFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -150,7 +155,7 @@ TEST_F(NotchFilterTest, ConnectAndRunGrcomplex) ASSERT_NO_THROW({ filter->connect(top_block); - boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 1, 1, queue)); + boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 0, 1, queue)); source->connect(top_block); boost::shared_ptr null_sink = gr::blocks::null_sink::make(item_size); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc index a23bb4385..83a63d551 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc @@ -28,22 +28,26 @@ * ------------------------------------------------------------------------- */ +#include +#include +#include #include #include #include -#include -#include -#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include +#endif +#include "file_signal_source.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" +#include "in_memory_configuration.h" #include "pulse_blanking_filter.h" -#include "file_signal_source.h" +#include +#include +#include DEFINE_int32(pb_filter_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -58,9 +62,7 @@ protected: config = std::make_shared(); nsamples = FLAGS_pb_filter_test_nsamples; } - ~PulseBlankingFilterTest() - { - } + ~PulseBlankingFilterTest() = default; void init(); void configure_gr_complex_gr_complex(); @@ -92,7 +94,10 @@ TEST_F(PulseBlankingFilterTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new PulseBlankingFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -149,7 +154,7 @@ TEST_F(PulseBlankingFilterTest, ConnectAndRunGrcomplex) ASSERT_NO_THROW({ filter->connect(top_block); - boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 1, 1, queue)); + boost::shared_ptr source(new FileSignalSource(config2.get(), "Test_Source", 0, 1, queue)); source->connect(top_block); boost::shared_ptr null_sink = gr::blocks::null_sink::make(item_size); diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt index b9a0eb93e..1935b7eda 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt +++ b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt @@ -19,26 +19,45 @@ set(SIGNAL_PROCESSING_TESTING_LIB_SOURCES acquisition_dump_reader.cc + acquisition_msg_rx.cc tracking_dump_reader.cc - tlm_dump_reader.cc - observables_dump_reader.cc + tlm_dump_reader.cc + observables_dump_reader.cc tracking_true_obs_reader.cc true_observables_reader.cc ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${MATIO_INCLUDE_DIRS} -) - - file(GLOB SIGNAL_PROCESSING_TESTING_LIB_HEADERS "*.h") list(SORT SIGNAL_PROCESSING_TESTING_LIB_HEADERS) -add_library(signal_processing_testing_lib ${SIGNAL_PROCESSING_TESTING_LIB_SOURCES} ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS}) + +add_library(signal_processing_testing_lib + ${SIGNAL_PROCESSING_TESTING_LIB_SOURCES} + ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS} +) + source_group(Headers FILES ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS}) -if(NOT MATIO_FOUND) - add_dependencies(signal_processing_testing_lib matio-${GNSSSDR_MATIO_LOCAL_VERSION}) -endif(NOT MATIO_FOUND) \ No newline at end of file +target_link_libraries(signal_processing_testing_lib + PUBLIC + Armadillo::armadillo + Gflags::gflags + Gnuradio::runtime + PRIVATE + Boost::boost + Matio::matio + Glog::glog +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(signal_processing_testing_lib + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +set_property(TARGET signal_processing_testing_lib + APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ +) diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index 32b6de6e2..987ddb350 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -35,16 +35,16 @@ #include #include -bool acquisition_dump_reader::read_binary_acq() +bool Acquisition_Dump_Reader::read_binary_acq() { mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY); - if (matfile == NULL) + if (matfile == nullptr) { std::cout << "¡¡¡Unreachable Acquisition dump file!!!" << std::endl; return false; } - matvar_t* var_ = Mat_VarRead(matfile, "grid"); - if (var_ == NULL) + matvar_t* var_ = Mat_VarRead(matfile, "acq_grid"); + if (var_ == nullptr) { std::cout << "¡¡¡Unreachable grid variable into Acquisition dump file!!!" << std::endl; Mat_Close(matfile); @@ -60,8 +60,14 @@ bool acquisition_dump_reader::read_binary_acq() if ((var_->dims[0] != d_samples_per_code) or (var_->dims[1] != d_num_doppler_bins)) { std::cout << "Invalid Acquisition dump file: dimension matrix error" << std::endl; - if (var_->dims[0] != d_samples_per_code) std::cout << "Expected " << d_samples_per_code << " samples per code. Obtained " << var_->dims[0] << std::endl; - if (var_->dims[1] != d_num_doppler_bins) std::cout << "Expected " << d_num_doppler_bins << " Doppler bins. Obtained " << var_->dims[1] << std::endl; + if (var_->dims[0] != d_samples_per_code) + { + std::cout << "Expected " << d_samples_per_code << " samples per code. Obtained " << var_->dims[0] << std::endl; + } + if (var_->dims[1] != d_num_doppler_bins) + { + std::cout << "Expected " << d_num_doppler_bins << " Doppler bins. Obtained " << var_->dims[1] << std::endl; + } Mat_VarFree(var_); Mat_Close(matfile); return false; @@ -73,16 +79,60 @@ bool acquisition_dump_reader::read_binary_acq() Mat_Close(matfile); return false; } + matvar_t* var2_ = Mat_VarRead(matfile, "doppler_max"); + d_doppler_max = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "doppler_step"); + d_doppler_step = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "input_power"); + input_power = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "acq_doppler_hz"); + acq_doppler_hz = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "acq_delay_samples"); + acq_delay_samples = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "test_statistic"); + test_statistic = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "threshold"); + threshold = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "sample_counter"); + sample_counter = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "d_positive_acq"); + positive_acq = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "num_dwells"); + num_dwells = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "PRN"); + PRN = *static_cast(var2_->data); + Mat_VarFree(var2_); + std::vector >::iterator it1; std::vector::iterator it2; - float* aux = static_cast(var_->data); + auto* aux = static_cast(var_->data); int k = 0; - float normalization_factor = std::pow(d_samples_per_code, 2); + float normalization_factor = std::pow(d_samples_per_code, 4) * input_power; for (it1 = mag.begin(); it1 != mag.end(); it1++) { for (it2 = it1->begin(); it2 != it1->end(); it2++) { - *it2 = static_cast(std::sqrt(aux[k])) / normalization_factor; + *it2 = static_cast(aux[k]) / normalization_factor; k++; } } @@ -93,17 +143,95 @@ bool acquisition_dump_reader::read_binary_acq() } -acquisition_dump_reader::acquisition_dump_reader(const std::string& basename, unsigned int sat, unsigned int doppler_max, unsigned int doppler_step, unsigned int samples_per_code) +Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, + int channel, + int execution) +{ + unsigned int sat_ = 0; + unsigned int doppler_max_ = 0; + unsigned int doppler_step_ = 0; + unsigned int samples_per_code_ = 0; + + mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY); + if (matfile != nullptr) + { + matvar_t* var_ = Mat_VarRead(matfile, "doppler_max"); + doppler_max_ = *static_cast(var_->data); + Mat_VarFree(var_); + + var_ = Mat_VarRead(matfile, "doppler_step"); + doppler_step_ = *static_cast(var_->data); + Mat_VarFree(var_); + + var_ = Mat_VarRead(matfile, "PRN"); + sat_ = *static_cast(var_->data); + Mat_VarFree(var_); + + var_ = Mat_VarRead(matfile, "grid"); + samples_per_code_ = var_->dims[0]; + Mat_VarFree(var_); + + Mat_Close(matfile); + } + else + { + std::cout << "¡¡¡Unreachable Acquisition dump file!!!" << std::endl; + } + acq_doppler_hz = 0.0; + acq_delay_samples = 0.0; + test_statistic = 0.0; + input_power = 0.0; + threshold = 0.0; + positive_acq = 0; + sample_counter = 0; + PRN = 0; + d_sat = 0; + d_doppler_max = doppler_max_; + d_doppler_step = doppler_step_; + d_samples_per_code = samples_per_code_; + d_num_doppler_bins = 0; + num_dwells = 0; + + Acquisition_Dump_Reader(basename, + sat_, + doppler_max_, + doppler_step_, + samples_per_code_, + channel, + execution); +} + + +Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, + unsigned int sat, + unsigned int doppler_max, + unsigned int doppler_step, + unsigned int samples_per_code, + int channel, + int execution) { d_basename = basename; d_sat = sat; d_doppler_max = doppler_max; d_doppler_step = doppler_step; d_samples_per_code = samples_per_code; + acq_doppler_hz = 0.0; + acq_delay_samples = 0.0; + test_statistic = 0.0; + input_power = 0.0; + threshold = 0.0; + positive_acq = 0; + sample_counter = 0; + num_dwells = 0; + PRN = 0; + if (d_doppler_step == 0) + { + d_doppler_step = 1; + } d_num_doppler_bins = static_cast(ceil(static_cast(static_cast(d_doppler_max) - static_cast(-d_doppler_max)) / static_cast(d_doppler_step))); std::vector > mag_aux(d_num_doppler_bins, std::vector(d_samples_per_code)); mag = mag_aux; - d_dump_filename = d_basename + "_sat_" + std::to_string(d_sat) + ".mat"; + d_dump_filename = d_basename + "_ch_" + std::to_string(channel) + "_" + std::to_string(execution) + "_sat_" + std::to_string(d_sat) + ".mat"; for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { doppler.push_back(-static_cast(d_doppler_max) + d_doppler_step * doppler_index); @@ -115,6 +243,4 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string& basename, un } -acquisition_dump_reader::~acquisition_dump_reader() -{ -} +Acquisition_Dump_Reader::~Acquisition_Dump_Reader() = default; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h index 7dd8ee44b..c68a32347 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h @@ -32,19 +32,41 @@ #ifndef GNSS_SDR_ACQUISITION_DUMP_READER_H #define GNSS_SDR_ACQUISITION_DUMP_READER_H +#include #include #include -class acquisition_dump_reader +class Acquisition_Dump_Reader { public: - acquisition_dump_reader(const std::string& basename, unsigned int sat, unsigned int doppler_max, unsigned int doppler_step, unsigned int samples_per_code); - ~acquisition_dump_reader(); + Acquisition_Dump_Reader(const std::string& basename, + unsigned int sat, + unsigned int doppler_max, + unsigned int doppler_step, + unsigned int samples_per_code, + int channel = 0, + int execution = 1); + + Acquisition_Dump_Reader(const std::string& basename, + int channel = 0, + int execution = 1); + + ~Acquisition_Dump_Reader(); + bool read_binary_acq(); std::vector doppler; std::vector samples; std::vector > mag; + float acq_doppler_hz; + float acq_delay_samples; + float test_statistic; + float input_power; + float threshold; + int positive_acq; + unsigned int PRN; + unsigned int num_dwells; + uint64_t sample_counter; private: std::string d_basename; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_msg_rx.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_msg_rx.cc new file mode 100644 index 000000000..4295a6564 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_msg_rx.cc @@ -0,0 +1,71 @@ +/*! + * \file acquisition_msg_rx.cc + * \brief This is a helper class to catch the asynchronous messages + * emitted by an acquisition block. + * \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.cat + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "acquisition_msg_rx.h" +#include +#include +#include +#include +#include + + +Acquisition_msg_rx_sptr Acquisition_msg_rx_make() +{ + return Acquisition_msg_rx_sptr(new Acquisition_msg_rx()); +} + + +void Acquisition_msg_rx::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(std::move(msg)); + rx_message = message; + top_block->stop(); // stop the flowgraph + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_acquisition Bad cast!\n"; + rx_message = 0; + } +} + + +Acquisition_msg_rx::Acquisition_msg_rx() : gr::block("Acquisition_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&Acquisition_msg_rx::msg_handler_events, this, _1)); + rx_message = 0; +} + + +Acquisition_msg_rx::~Acquisition_msg_rx() = default; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_msg_rx.h b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_msg_rx.h new file mode 100644 index 000000000..4dca5bcb8 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_msg_rx.h @@ -0,0 +1,62 @@ +/*! + * \file acquisition_msg_rx.h + * \brief This is a helper class to catch the asynchronous messages + * emitted by an acquisition block. + * \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.cat + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_ACQUISITION_MSG_RX_H +#define GNSS_SDR_ACQUISITION_MSG_RX_H + +#include +#include +#include + +// ######## GNURADIO ACQUISITION BLOCK MESSAGE RECEVER ######### +class Acquisition_msg_rx; + +using Acquisition_msg_rx_sptr = boost::shared_ptr; + +Acquisition_msg_rx_sptr Acquisition_msg_rx_make(); + + +class Acquisition_msg_rx : public gr::block +{ +private: + friend Acquisition_msg_rx_sptr Acquisition_msg_rx_make(); + void msg_handler_events(pmt::pmt_t msg); + Acquisition_msg_rx(); + +public: + int rx_message; + gr::top_block_sptr top_block; + ~Acquisition_msg_rx(); //!< Default destructor +}; + + +#endif diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc index 72a40389d..c85062d55 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc @@ -29,9 +29,11 @@ */ #include "observables_dump_reader.h" +#include #include +#include -bool observables_dump_reader::read_binary_obs() +bool Observables_Dump_Reader::read_binary_obs() { try { @@ -54,7 +56,7 @@ bool observables_dump_reader::read_binary_obs() } -bool observables_dump_reader::restart() +bool Observables_Dump_Reader::restart() { if (d_dump_file.is_open()) { @@ -62,14 +64,11 @@ bool observables_dump_reader::restart() d_dump_file.seekg(0, std::ios::beg); return true; } - else - { - return false; - } + return false; } -long int observables_dump_reader::num_epochs() +int64_t Observables_Dump_Reader::num_epochs() { std::ifstream::pos_type size; int number_of_vars_in_epoch = n_channels * 7; @@ -78,31 +77,27 @@ long int observables_dump_reader::num_epochs() if (tmpfile.is_open()) { size = tmpfile.tellg(); - long int nepoch = size / epoch_size_bytes; + int64_t nepoch = size / epoch_size_bytes; return nepoch; } - else - { - return 0; - } + return 0; } -bool observables_dump_reader::open_obs_file(std::string out_file) +bool Observables_Dump_Reader::open_obs_file(std::string out_file) { if (d_dump_file.is_open() == false) { try { - d_dump_filename = out_file; + d_dump_filename = std::move(out_file); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary); - std::cout << "Observables sum file opened, Log file: " << d_dump_filename.c_str() << std::endl; return true; } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening Observables dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -113,7 +108,16 @@ bool observables_dump_reader::open_obs_file(std::string out_file) } -observables_dump_reader::observables_dump_reader(int n_channels_) +void Observables_Dump_Reader::close_obs_file() +{ + if (d_dump_file.is_open() == false) + { + d_dump_file.close(); + } +} + + +Observables_Dump_Reader::Observables_Dump_Reader(int n_channels_) { n_channels = n_channels_; RX_time = new double[n_channels]; @@ -126,11 +130,22 @@ observables_dump_reader::observables_dump_reader(int n_channels_) } -observables_dump_reader::~observables_dump_reader() +Observables_Dump_Reader::~Observables_Dump_Reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Observables dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } delete[] RX_time; delete[] TOW_at_current_symbol_s; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h index 41c7a60f2..be5c76ed1 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h @@ -31,19 +31,21 @@ #ifndef GNSS_SDR_OBSERVABLES_DUMP_READER_H #define GNSS_SDR_OBSERVABLES_DUMP_READER_H +#include #include #include #include -class observables_dump_reader +class Observables_Dump_Reader { public: - observables_dump_reader(int n_channels); - ~observables_dump_reader(); + Observables_Dump_Reader(int n_channels); + ~Observables_Dump_Reader(); bool read_binary_obs(); bool restart(); - long int num_epochs(); + int64_t num_epochs(); bool open_obs_file(std::string out_file); + void close_obs_file(); //dump variables diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc index 228a2edbe..286994f7e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc @@ -29,14 +29,16 @@ */ #include "tlm_dump_reader.h" +#include #include +#include -bool tlm_dump_reader::read_binary_obs() +bool Tlm_Dump_Reader::read_binary_obs() { try { d_dump_file.read(reinterpret_cast(&TOW_at_current_symbol), sizeof(double)); - d_dump_file.read(reinterpret_cast(&Tracking_sample_counter), sizeof(unsigned long int)); + d_dump_file.read(reinterpret_cast(&Tracking_sample_counter), sizeof(uint64_t)); d_dump_file.read(reinterpret_cast(&d_TOW_at_Preamble), sizeof(double)); } catch (const std::ifstream::failure &e) @@ -47,7 +49,7 @@ bool tlm_dump_reader::read_binary_obs() } -bool tlm_dump_reader::restart() +bool Tlm_Dump_Reader::restart() { if (d_dump_file.is_open()) { @@ -55,39 +57,33 @@ bool tlm_dump_reader::restart() d_dump_file.seekg(0, std::ios::beg); return true; } - else - { - return false; - } + return false; } -long int tlm_dump_reader::num_epochs() +int64_t Tlm_Dump_Reader::num_epochs() { std::ifstream::pos_type size; int number_of_vars_in_epoch = 2; - int epoch_size_bytes = sizeof(double) * number_of_vars_in_epoch + sizeof(unsigned long int); + int epoch_size_bytes = sizeof(double) * number_of_vars_in_epoch + sizeof(uint64_t); std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); if (tmpfile.is_open()) { size = tmpfile.tellg(); - long int nepoch = size / epoch_size_bytes; + int64_t nepoch = size / epoch_size_bytes; return nepoch; } - else - { - return 0; - } + return 0; } -bool tlm_dump_reader::open_obs_file(std::string out_file) +bool Tlm_Dump_Reader::open_obs_file(std::string out_file) { if (d_dump_file.is_open() == false) { try { - d_dump_filename = out_file; + d_dump_filename = std::move(out_file); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary); std::cout << "TLM dump enabled, Log file: " << d_dump_filename.c_str() << std::endl; @@ -95,7 +91,7 @@ bool tlm_dump_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening TLM dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -106,10 +102,21 @@ bool tlm_dump_reader::open_obs_file(std::string out_file) } -tlm_dump_reader::~tlm_dump_reader() +Tlm_Dump_Reader::~Tlm_Dump_Reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing TLM dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h index 1f8a1419f..3eacefee4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h @@ -31,22 +31,23 @@ #ifndef GNSS_SDR_TLM_DUMP_READER_H #define GNSS_SDR_TLM_DUMP_READER_H +#include #include #include #include -class tlm_dump_reader +class Tlm_Dump_Reader { public: - ~tlm_dump_reader(); + ~Tlm_Dump_Reader(); bool read_binary_obs(); bool restart(); - long int num_epochs(); + int64_t num_epochs(); bool open_obs_file(std::string out_file); //telemetry decoder dump variables double TOW_at_current_symbol; - unsigned long int Tracking_sample_counter; + uint64_t Tracking_sample_counter; double d_TOW_at_Preamble; private: diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc index 502c99ea5..49b37e148 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc @@ -29,9 +29,11 @@ */ #include "tracking_dump_reader.h" +#include #include +#include -bool tracking_dump_reader::read_binary_obs() +bool Tracking_Dump_Reader::read_binary_obs() { try { @@ -42,10 +44,12 @@ bool tracking_dump_reader::read_binary_obs() d_dump_file.read(reinterpret_cast(&abs_VL), sizeof(float)); d_dump_file.read(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.read(reinterpret_cast(&prompt_Q), sizeof(float)); - d_dump_file.read(reinterpret_cast(&PRN_start_sample_count), sizeof(unsigned long int)); + d_dump_file.read(reinterpret_cast(&PRN_start_sample_count), sizeof(uint64_t)); d_dump_file.read(reinterpret_cast(&acc_carrier_phase_rad), sizeof(float)); d_dump_file.read(reinterpret_cast(&carrier_doppler_hz), sizeof(float)); + d_dump_file.read(reinterpret_cast(&carrier_doppler_rate_hz_s), sizeof(float)); d_dump_file.read(reinterpret_cast(&code_freq_chips), sizeof(float)); + d_dump_file.read(reinterpret_cast(&code_freq_rate_chips), sizeof(float)); d_dump_file.read(reinterpret_cast(&carr_error_hz), sizeof(float)); d_dump_file.read(reinterpret_cast(&carr_error_filt_hz), sizeof(float)); d_dump_file.read(reinterpret_cast(&code_error_chips), sizeof(float)); @@ -64,7 +68,7 @@ bool tracking_dump_reader::read_binary_obs() } -bool tracking_dump_reader::restart() +bool Tracking_Dump_Reader::restart() { if (d_dump_file.is_open()) { @@ -72,49 +76,44 @@ bool tracking_dump_reader::restart() d_dump_file.seekg(0, std::ios::beg); return true; } - else - { - return false; - } + return false; } -long int tracking_dump_reader::num_epochs() +int64_t Tracking_Dump_Reader::num_epochs() { std::ifstream::pos_type size; int number_of_double_vars = 1; - int number_of_float_vars = 17; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + + int number_of_float_vars = 19; + int epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + sizeof(float) * number_of_float_vars + sizeof(unsigned int); std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); if (tmpfile.is_open()) { size = tmpfile.tellg(); - long int nepoch = size / epoch_size_bytes; + int64_t nepoch = size / epoch_size_bytes; return nepoch; } - else - { - return 0; - } + + + return 0; } -bool tracking_dump_reader::open_obs_file(std::string out_file) +bool Tracking_Dump_Reader::open_obs_file(std::string out_file) { if (d_dump_file.is_open() == false) { try { - d_dump_filename = out_file; + d_dump_filename = std::move(out_file); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary); - std::cout << "Tracking dump enabled, Log file: " << d_dump_filename.c_str() << std::endl; return true; } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -125,10 +124,21 @@ bool tracking_dump_reader::open_obs_file(std::string out_file) } -tracking_dump_reader::~tracking_dump_reader() +Tracking_Dump_Reader::~Tracking_Dump_Reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Tracking dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h index 106a7efdc..7a2ca7e33 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h @@ -31,17 +31,18 @@ #ifndef GNSS_SDR_TRACKING_DUMP_READER_H #define GNSS_SDR_TRACKING_DUMP_READER_H +#include #include #include #include -class tracking_dump_reader +class Tracking_Dump_Reader { public: - ~tracking_dump_reader(); + ~Tracking_Dump_Reader(); bool read_binary_obs(); bool restart(); - long int num_epochs(); + int64_t num_epochs(); bool open_obs_file(std::string out_file); //tracking dump variables @@ -55,14 +56,16 @@ public: float prompt_I; float prompt_Q; // PRN start sample stamp - unsigned long int PRN_start_sample_count; + uint64_t PRN_start_sample_count; // accumulated carrier phase float acc_carrier_phase_rad; // carrier and code frequency float carrier_doppler_hz; + float carrier_doppler_rate_hz_s; float code_freq_chips; + float code_freq_rate_chips; // PLL commands float carr_error_hz; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc index 8b1f91c65..25c81acc1 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc @@ -29,9 +29,11 @@ */ #include "tracking_true_obs_reader.h" +#include #include +#include -bool tracking_true_obs_reader::read_binary_obs() +bool Tracking_True_Obs_Reader::read_binary_obs() { try { @@ -49,7 +51,7 @@ bool tracking_true_obs_reader::read_binary_obs() } -bool tracking_true_obs_reader::restart() +bool Tracking_True_Obs_Reader::restart() { if (d_dump_file.is_open()) { @@ -57,14 +59,11 @@ bool tracking_true_obs_reader::restart() d_dump_file.seekg(0, std::ios::beg); return true; } - else - { - return false; - } + return false; } -long int tracking_true_obs_reader::num_epochs() +int64_t Tracking_True_Obs_Reader::num_epochs() { std::ifstream::pos_type size; int number_of_vars_in_epoch = 5; @@ -73,31 +72,28 @@ long int tracking_true_obs_reader::num_epochs() if (tmpfile.is_open()) { size = tmpfile.tellg(); - long int nepoch = size / epoch_size_bytes; + int64_t nepoch = size / epoch_size_bytes; return nepoch; } - else - { - return 0; - } + return 0; } -bool tracking_true_obs_reader::open_obs_file(std::string out_file) +bool Tracking_True_Obs_Reader::open_obs_file(std::string out_file) { if (d_dump_file.is_open() == false) { try { - d_dump_filename = out_file; + d_dump_file.clear(); + d_dump_filename = std::move(out_file); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary); - std::cout << "Observables dump enabled, Log file: " << d_dump_filename.c_str() << std::endl; return true; } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening Observables dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -107,11 +103,29 @@ bool tracking_true_obs_reader::open_obs_file(std::string out_file) } } - -tracking_true_obs_reader::~tracking_true_obs_reader() +void Tracking_True_Obs_Reader::close_obs_file() { if (d_dump_file.is_open() == true) { d_dump_file.close(); } } + +Tracking_True_Obs_Reader::~Tracking_True_Obs_Reader() +{ + try + { + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Tracking dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; + } +} diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h index 9c4a5db7c..50b496ceb 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h @@ -31,18 +31,20 @@ #ifndef GNSS_SDR_TRACKING_TRUE_OBS_READER_H #define GNSS_SDR_TRACKING_TRUE_OBS_READER_H +#include #include #include #include -class tracking_true_obs_reader +class Tracking_True_Obs_Reader { public: - ~tracking_true_obs_reader(); + ~Tracking_True_Obs_Reader(); bool read_binary_obs(); bool restart(); - long int num_epochs(); + int64_t num_epochs(); bool open_obs_file(std::string out_file); + void close_obs_file(); bool d_dump; double signal_timestamp_s; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc index b1f9d1d9b..dd72ae6dc 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc @@ -29,16 +29,18 @@ */ #include "true_observables_reader.h" +#include #include +#include -bool true_observables_reader::read_binary_obs() +bool True_Observables_Reader::read_binary_obs() { try { for (int i = 0; i < 12; i++) { d_dump_file.read(reinterpret_cast(&gps_time_sec[i]), sizeof(double)); - d_dump_file.read(reinterpret_cast(&doppler_l1_hz), sizeof(double)); + d_dump_file.read(reinterpret_cast(&doppler_l1_hz[i]), sizeof(double)); d_dump_file.read(reinterpret_cast(&acc_carrier_phase_l1_cycles[i]), sizeof(double)); d_dump_file.read(reinterpret_cast(&dist_m[i]), sizeof(double)); d_dump_file.read(reinterpret_cast(&true_dist_m[i]), sizeof(double)); @@ -54,7 +56,7 @@ bool true_observables_reader::read_binary_obs() } -bool true_observables_reader::restart() +bool True_Observables_Reader::restart() { if (d_dump_file.is_open()) { @@ -62,14 +64,11 @@ bool true_observables_reader::restart() d_dump_file.seekg(0, std::ios::beg); return true; } - else - { - return false; - } + return false; } -long int true_observables_reader::num_epochs() +int64_t True_Observables_Reader::num_epochs() { std::ifstream::pos_type size; int number_of_vars_in_epoch = 6 * 12; @@ -78,23 +77,20 @@ long int true_observables_reader::num_epochs() if (tmpfile.is_open()) { size = tmpfile.tellg(); - long int nepoch = size / epoch_size_bytes; + int64_t nepoch = size / epoch_size_bytes; return nepoch; } - else - { - return 0; - } + return 0; } -bool true_observables_reader::open_obs_file(std::string out_file) +bool True_Observables_Reader::open_obs_file(std::string out_file) { if (d_dump_file.is_open() == false) { try { - d_dump_filename = out_file; + d_dump_filename = std::move(out_file); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary); std::cout << "True observables Log file opened: " << d_dump_filename.c_str() << std::endl; @@ -102,7 +98,7 @@ bool true_observables_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening True observables Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening true Observables Log file: " << d_dump_filename << std::endl; return false; } } @@ -113,10 +109,21 @@ bool true_observables_reader::open_obs_file(std::string out_file) } -true_observables_reader::~true_observables_reader() +True_Observables_Reader::~True_Observables_Reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing true Observables dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.h index 41c04002a..f17561f84 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.h @@ -31,17 +31,18 @@ #ifndef GNSS_SDR_TRUE_OBSERVABLES_READER_H #define GNSS_SDR_TRUE_OBSERVABLES_READER_H +#include #include #include #include -class true_observables_reader +class True_Observables_Reader { public: - ~true_observables_reader(); + ~True_Observables_Reader(); bool read_binary_obs(); bool restart(); - long int num_epochs(); + int64_t num_epochs(); bool open_obs_file(std::string out_file); double gps_time_sec[12]; diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc index f93f780cc..cee43548b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc @@ -30,34 +30,62 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include +#include "GPS_L1_CA.h" +#include "GPS_L2C.h" +#include "GPS_L5.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "acquisition_msg_rx.h" +#include "galileo_e1_pcps_ambiguous_acquisition.h" +#include "galileo_e5a_noncoherent_iq_acquisition_caf.h" +#include "galileo_e5a_pcps_acquisition.h" +#include "glonass_l1_ca_pcps_acquisition.h" +#include "glonass_l2_ca_pcps_acquisition.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" +#include "gnss_satellite.h" +#include "gnss_sdr_sample_counter.h" +#include "gnss_synchro.h" +#include "gnuplot_i.h" +#include "gps_l1_ca_dll_pll_tracking.h" +#include "gps_l1_ca_pcps_acquisition.h" +#include "gps_l2_m_pcps_acquisition.h" +#include "gps_l5i_pcps_acquisition.h" +#include "hybrid_observables.h" +#include "in_memory_configuration.h" +#include "observable_tests_flags.h" +#include "observables_dump_reader.h" +#include "signal_generator_flags.h" +#include "telemetry_decoder_interface.h" +#include "test_flags.h" +#include "tlm_dump_reader.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_tests_flags.h" +#include "tracking_true_obs_reader.h" +#include "true_observables_reader.h" #include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include -#include "GPS_L1_CA.h" -#include "gnss_satellite.h" -#include "gnss_block_factory.h" -#include "gnss_block_interface.h" -#include "tracking_interface.h" -#include "telemetry_decoder_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" -#include "gps_l1_ca_telemetry_decoder.h" -#include "tracking_true_obs_reader.h" -#include "true_observables_reader.h" -#include "tracking_dump_reader.h" -#include "observables_dump_reader.h" -#include "tlm_dump_reader.h" -#include "gps_l1_ca_dll_pll_tracking.h" -#include "hybrid_observables.h" -#include "signal_generator_flags.h" -#include "gnss_sdr_sample_counter.h" #include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### @@ -88,7 +116,7 @@ void HybridObservablesTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -105,9 +133,7 @@ HybridObservablesTest_msg_rx::HybridObservablesTest_msg_rx() : gr::block("Hybrid rx_message = 0; } -HybridObservablesTest_msg_rx::~HybridObservablesTest_msg_rx() -{ -} +HybridObservablesTest_msg_rx::~HybridObservablesTest_msg_rx() = default; // ########################################################### @@ -141,7 +167,7 @@ void HybridObservablesTest_tlm_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -158,9 +184,7 @@ HybridObservablesTest_tlm_msg_rx::HybridObservablesTest_tlm_msg_rx() : gr::block rx_message = 0; } -HybridObservablesTest_tlm_msg_rx::~HybridObservablesTest_tlm_msg_rx() -{ -} +HybridObservablesTest_tlm_msg_rx::~HybridObservablesTest_tlm_msg_rx() = default; // ########################################################### @@ -169,12 +193,26 @@ HybridObservablesTest_tlm_msg_rx::~HybridObservablesTest_tlm_msg_rx() class HybridObservablesTest : public ::testing::Test { public: + enum StringValue + { + evGPS_1C, + evGPS_2S, + evGPS_L5, + evSBAS_1C, + evGAL_1B, + evGAL_5X, + evGLO_1G, + evGLO_2G + }; + std::map mapStringValues_; + std::string generator_binary; std::string p1; std::string p2; std::string p3; std::string p4; std::string p5; + std::string implementation = FLAGS_trk_test_implementation; const int baseband_sampling_freq = FLAGS_fs_gen_sps; @@ -183,39 +221,80 @@ public: int configure_generator(); int generate_signal(); + bool save_mat_xy(std::vector& x, std::vector& y, std::string filename); void check_results_carrier_phase( arma::mat& true_ch0, - arma::mat& true_ch1, arma::vec& true_tow_s, arma::mat& measured_ch0, - arma::mat& measured_ch1); - void check_results_code_psudorange( + const std::string& data_title); + void check_results_carrier_phase_double_diff( arma::mat& true_ch0, arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + const std::string& data_title); + void check_results_carrier_doppler(arma::mat& true_ch0, arma::vec& true_tow_s, arma::mat& measured_ch0, - arma::mat& measured_ch1); + const std::string& data_title); + void check_results_carrier_doppler_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + const std::string& data_title); + void check_results_code_pseudorange( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + const std::string& data_title); + + void check_results_duplicated_satellite( + arma::mat& measured_sat1, + arma::mat& measured_sat2, + int ch_id, + const std::string& data_title); HybridObservablesTest() { factory = std::make_shared(); config = std::make_shared(); item_size = sizeof(gr_complex); - gnss_synchro_ch0 = Gnss_Synchro(); - gnss_synchro_ch1 = Gnss_Synchro(); + mapStringValues_["1C"] = evGPS_1C; + mapStringValues_["2S"] = evGPS_2S; + mapStringValues_["L5"] = evGPS_L5; + mapStringValues_["1B"] = evGAL_1B; + mapStringValues_["5X"] = evGAL_5X; + mapStringValues_["1G"] = evGLO_1G; + mapStringValues_["2G"] = evGLO_2G; } - ~HybridObservablesTest() - { - } + ~HybridObservablesTest() = default; - void configure_receiver(); + bool ReadRinexObs(std::vector* obs_vec, Gnss_Synchro gnss); + + bool acquire_signal(); + void configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols, + uint32_t smoother_length, + bool high_dyn); gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; - Gnss_Synchro gnss_synchro_ch0; - Gnss_Synchro gnss_synchro_ch1; + Gnss_Synchro gnss_synchro_master; + std::vector gnss_synchro_vec; size_t item_size; }; @@ -244,11 +323,13 @@ int HybridObservablesTest::generate_signal() { int child_status; - char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], nullptr}; int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -263,67 +344,470 @@ int HybridObservablesTest::generate_signal() } -void HybridObservablesTest::configure_receiver() +bool HybridObservablesTest::acquire_signal() { - gnss_synchro_ch0.Channel_ID = 0; - gnss_synchro_ch0.System = 'G'; - std::string signal = "1C"; - signal.copy(gnss_synchro_ch0.Signal, 2, 0); - gnss_synchro_ch0.PRN = FLAGS_test_satellite_PRN; + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + gr::top_block_sptr top_block; + top_block = gr::make_top_block("Acquisition test"); + int SV_ID = 1; //initial sv id + // Satellite signal definition + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.Channel_ID = 0; + config = std::make_shared(); + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + // Enable automatic resampler for the acquisition, if required + if (FLAGS_use_acquisition_resampler == true) + { + config->set_property("GNSS-SDR.use_acquisition_resampler", "true"); + } + config->set_property("Acquisition.blocking_on_standby", "true"); + config->set_property("Acquisition.blocking", "true"); + config->set_property("Acquisition.dump", "false"); + config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); + config->set_property("Acquisition.use_CFAR_algorithm", "false"); - gnss_synchro_ch1.Channel_ID = 1; - gnss_synchro_ch1.System = 'G'; - signal.copy(gnss_synchro_ch1.Signal, 2, 0); - gnss_synchro_ch1.PRN = FLAGS_test_satellite_PRN2; + std::shared_ptr acquisition; + + std::string System_and_Signal; + std::string signal; + //create the correspondign acquisition block according to the desired tracking signal + if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'G'; + signal = "1C"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L1 CA"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") + { + tmp_gnss_synchro.System = 'E'; + signal = "1B"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E1B"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'G'; + signal = "2S"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L2CM"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking_b") + { + tmp_gnss_synchro.System = 'E'; + signal = "5X"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E5a"; + config->set_property("Acquisition_5X.coherent_integration_time_ms", "1"); + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + config->set_property("Acquisition.CAF_window_hz", "0"); // **Only for E5a** Resolves doppler ambiguity averaging the specified BW in the winner code delay. If set to 0 CAF filter is desactivated. Recommended value 3000 Hz + config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. + config->set_property("Acquisition.bit_transition_flag", "false"); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'E'; + signal = "5X"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E5a"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GPS_L5_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'G'; + signal = "L5"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L5I"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->set_channel(0); + acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition->init(); + acquisition->set_local_code(); + acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->connect(top_block); + + gr::blocks::file_source::sptr file_source; + std::string file = FLAGS_signal_file; + const char* file_name = file.c_str(); + file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); + //top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); + + top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + + // Enable automatic resampler for the acquisition, if required + if (FLAGS_use_acquisition_resampler == true) + { + //create acquisition resamplers if required + double resampler_ratio = 1.0; + + double opt_fs = baseband_sampling_freq; + //find the signal associated to this channel + switch (mapStringValues_[signal]) + { + case evGPS_1C: + opt_fs = GPS_L1_CA_OPT_ACQ_FS_HZ; + break; + case evGPS_2S: + opt_fs = GPS_L2C_OPT_ACQ_FS_HZ; + break; + case evGPS_L5: + opt_fs = GPS_L5_OPT_ACQ_FS_HZ; + break; + case evSBAS_1C: + opt_fs = GPS_L1_CA_OPT_ACQ_FS_HZ; + break; + case evGAL_1B: + opt_fs = GALILEO_E1_OPT_ACQ_FS_HZ; + break; + case evGAL_5X: + opt_fs = GALILEO_E5A_OPT_ACQ_FS_HZ; + break; + case evGLO_1G: + opt_fs = baseband_sampling_freq; + break; + case evGLO_2G: + opt_fs = baseband_sampling_freq; + break; + } + if (opt_fs < baseband_sampling_freq) + { + resampler_ratio = baseband_sampling_freq / opt_fs; + int decimation = floor(resampler_ratio); + while (baseband_sampling_freq % decimation > 0) + { + decimation--; + }; + double acq_fs = baseband_sampling_freq / decimation; + + if (decimation > 1) + { + //create a FIR low pass filter + std::vector taps; + taps = gr::filter::firdes::low_pass(1.0, + baseband_sampling_freq, + acq_fs / 2.1, + acq_fs / 10, + gr::filter::firdes::win_type::WIN_HAMMING); + std::cout << "Enabled decimation low pass filter with " << taps.size() << " taps and decimation factor of " << decimation << std::endl; + acquisition->set_resampler_latency((taps.size() - 1) / 2); + gr::basic_block_sptr fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(decimation, taps); + top_block->connect(gr_interleaved_char_to_complex, 0, fir_filter_ccf_, 0); + top_block->connect(fir_filter_ccf_, 0, acquisition->get_left_block(), 0); + } + else + { + std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; + top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + } + } + else + { + std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; + top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + } + } + else + { + top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + //top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); + } + boost::shared_ptr msg_rx; + try + { + msg_rx = Acquisition_msg_rx_make(); + } + catch (const std::exception& e) + { + std::cout << "Failure connecting the message port system: " << e.what() << std::endl; + exit(0); + } + + msg_rx->top_block = top_block; + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + + // 5. Run the flowgraph + // Get visible GPS satellites (positive acquisitions with Doppler measurements) + // record startup time + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds; + start = std::chrono::system_clock::now(); + + bool start_msg = true; + + unsigned int MAX_PRN_IDX = 0; + + switch (tmp_gnss_synchro.System) + { + case 'G': + MAX_PRN_IDX = 33; + break; + case 'E': + MAX_PRN_IDX = 37; + break; + default: + MAX_PRN_IDX = 33; + } + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + acquisition->reset(); + acquisition->set_state(1); + msg_rx->rx_message = 0; + top_block->run(); + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } + top_block->stop(); + file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + std::cout.flush(); + } + std::cout << "]" << std::endl; + std::cout << "-------------------------------------------\n"; + + for (auto& x : gnss_synchro_vec) + { + std::cout << "DETECTED SATELLITE " << System_and_Signal + << " PRN: " << x.PRN + << " with Doppler: " << x.Acq_doppler_hz + << " [Hz], code phase: " << x.Acq_delay_samples + << " [samples] at signal SampleStamp " << x.Acq_samplestamp_samples << "\n"; + } + + // report the elapsed time + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + std::cout << "Total signal acquisition run time " + << elapsed_seconds.count() + << " [seconds]" << std::endl; + if (!gnss_synchro_vec.empty()) + { + return true; + } + else + { + return false; + } +} + + +void HybridObservablesTest::configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols, + uint32_t smoother_length, + bool high_dyn) +{ + config = std::make_shared(); + config->set_property("Tracking.dump", "true"); + if (high_dyn) + { + config->set_property("Tracking.high_dyn", "true"); + } + else + { + config->set_property("Tracking.high_dyn", "false"); + } + config->set_property("Tracking.smoother_length", std::to_string(smoother_length)); + config->set_property("Tracking.dump_filename", "./tracking_ch_"); + config->set_property("Tracking.implementation", implementation); + config->set_property("Tracking.item_type", "gr_complex"); + config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); + config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); + config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + config->set_property("Observables.implementation", "Hybrid_Observables"); + config->set_property("Observables.dump", "true"); + config->set_property("TelemetryDecoder.dump", "true"); + + gnss_synchro_master.Channel_ID = 0; config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); - // Set Tracking - config->set_property("Tracking_1C.item_type", "gr_complex"); - config->set_property("Tracking_1C.dump", "true"); - config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); - config->set_property("Tracking_1C.pll_bw_hz", "35.0"); - config->set_property("Tracking_1C.dll_bw_hz", "0.5"); - config->set_property("Tracking_1C.early_late_space_chips", "0.5"); - config->set_property("Tracking_1C.unified", "true"); + std::string System_and_Signal; + if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") + { + gnss_synchro_master.System = 'G'; + std::string signal = "1C"; + System_and_Signal = "GPS L1 CA"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null - config->set_property("TelemetryDecoder_1C.dump", "true"); - config->set_property("Observables.dump", "true"); + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); + + config->set_property("TelemetryDecoder.implementation", "GPS_L1_CA_Telemetry_Decoder"); + } + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") + { + gnss_synchro_master.System = 'E'; + std::string signal = "1B"; + System_and_Signal = "Galileo E1B"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_chips", "0.6"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); + config->set_property("Tracking.track_pilot", "true"); + + config->set_property("TelemetryDecoder.implementation", "Galileo_E1B_Telemetry_Decoder"); + } + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") + { + gnss_synchro_master.System = 'G'; + std::string signal = "2S"; + System_and_Signal = "GPS L2CM"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + + config->set_property("TelemetryDecoder.implementation", "GPS_L2C_Telemetry_Decoder"); + } + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking" or implementation == "Galileo_E5a_DLL_PLL_Tracking_b") + { + gnss_synchro_master.System = 'E'; + std::string signal = "5X"; + System_and_Signal = "Galileo E5a"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + if (implementation == "Galileo_E5a_DLL_PLL_Tracking_b") + { + config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); + } + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + config->set_property("Tracking.order", "2"); + + config->set_property("TelemetryDecoder.implementation", "Galileo_E5a_Telemetry_Decoder"); + } + else if (implementation == "GPS_L5_DLL_PLL_Tracking") + { + gnss_synchro_master.System = 'G'; + std::string signal = "L5"; + System_and_Signal = "GPS L5I"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + config->set_property("Tracking.order", "2"); + + config->set_property("TelemetryDecoder.implementation", "GPS_L5_Telemetry_Decoder"); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + std::cout << "*****************************************\n"; + std::cout << "*** Tracking configuration parameters ***\n"; + std::cout << "*****************************************\n"; + std::cout << "Signal: " << System_and_Signal << "\n"; + std::cout << "implementation: " << config->property("Tracking.implementation", std::string("undefined")) << " \n"; + std::cout << "pll_bw_hz: " << config->property("Tracking.pll_bw_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_hz: " << config->property("Tracking.dll_bw_hz", 0.0) << " Hz\n"; + std::cout << "pll_bw_narrow_hz: " << config->property("Tracking.pll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_narrow_hz: " << config->property("Tracking.dll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "extend_correlation_symbols: " << config->property("Tracking.extend_correlation_symbols", 0) << " Symbols\n"; + std::cout << "high_dyn: " << config->property("Tracking.high_dyn", false) << "\n"; + std::cout << "smoother_length: " << config->property("Tracking.smoother_length", 0) << "\n"; + std::cout << "*****************************************\n"; + std::cout << "*****************************************\n"; } void HybridObservablesTest::check_results_carrier_phase( arma::mat& true_ch0, - arma::mat& true_ch1, arma::vec& true_tow_s, arma::mat& measured_ch0, - arma::mat& measured_ch1) + const std::string& data_title) { //1. True value interpolation to match the measurement times - double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + double t0 = measured_ch0(0, 0); int size1 = measured_ch0.col(0).n_rows; - int size2 = measured_ch1.col(0).n_rows; - double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + double t1 = measured_ch0(size1 - 1, 0); arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); arma::vec true_ch0_phase_interp; - arma::vec true_ch1_phase_interp; arma::interp1(true_tow_s, true_ch0.col(3), t, true_ch0_phase_interp); - arma::interp1(true_tow_s, true_ch1.col(3), t, true_ch1_phase_interp); arma::vec meas_ch0_phase_interp; - arma::vec meas_ch1_phase_interp; arma::interp1(measured_ch0.col(0), measured_ch0.col(3), t, meas_ch0_phase_interp); - arma::interp1(measured_ch1.col(0), measured_ch1.col(3), t, meas_ch1_phase_interp); //2. RMSE arma::vec err_ch0_cycles; - arma::vec err_ch1_cycles; //compute error without the accumulated carrier phase offsets (which depends on the receiver starting time) err_ch0_cycles = meas_ch0_phase_interp - true_ch0_phase_interp - meas_ch0_phase_interp(0) + true_ch0_phase_interp(0); - err_ch1_cycles = meas_ch1_phase_interp - true_ch1_phase_interp - meas_ch1_phase_interp(0) + true_ch1_phase_interp(0); arma::vec err2_ch0 = arma::square(err_ch0_cycles); double rmse_ch0 = sqrt(arma::mean(err2_ch0)); @@ -336,21 +820,9 @@ void HybridObservablesTest::check_results_carrier_phase( double max_error_ch0 = arma::max(err_ch0_cycles); double min_error_ch0 = arma::min(err_ch0_cycles); - arma::vec err2_ch1 = arma::square(err_ch1_cycles); - double rmse_ch1 = sqrt(arma::mean(err2_ch1)); - - //3. Mean err and variance - double error_mean_ch1 = arma::mean(err_ch1_cycles); - double error_var_ch1 = arma::var(err_ch1_cycles); - - // 4. Peaks - double max_error_ch1 = arma::max(err_ch1_cycles); - double min_error_ch1 = arma::min(err_ch1_cycles); - - //5. report std::streamsize ss = std::cout.precision(); - std::cout << std::setprecision(10) << "Channel 0 Carrier phase RMSE = " + std::cout << std::setprecision(10) << data_title << " Accumulated Carrier phase RMSE = " << rmse_ch0 << ", mean = " << error_mean_ch0 << ", stdev = " << sqrt(error_var_ch0) << " (max,min) = " << max_error_ch0 @@ -358,38 +830,43 @@ void HybridObservablesTest::check_results_carrier_phase( << " [cycles]" << std::endl; std::cout.precision(ss); - ASSERT_LT(rmse_ch0, 5e-2); - ASSERT_LT(error_mean_ch0, 5e-2); - ASSERT_GT(error_mean_ch0, -5e-2); - ASSERT_LT(error_var_ch0, 5e-2); - ASSERT_LT(max_error_ch0, 5e-2); - ASSERT_GT(min_error_ch0, -5e-2); + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Accumulated Carrier phase error [cycles]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Phase error [cycles]"); + //conversion between arma::vec and std:vector + std::vector error_vec(err_ch0_cycles.colptr(0), err_ch0_cycles.colptr(0) + err_ch0_cycles.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, error_vec, + "Carrier Phase error"); + g3.set_legend(); + g3.savetops(data_title + "Carrier_phase_error"); - //5. report - ss = std::cout.precision(); - std::cout << std::setprecision(10) << "Channel 1 Carrier phase RMSE = " - << rmse_ch1 << ", mean = " << error_mean_ch1 - << ", stdev = " << sqrt(error_var_ch1) - << " (max,min) = " << max_error_ch1 - << "," << min_error_ch1 - << " [cycles]" << std::endl; - std::cout.precision(ss); + g3.showonscreen(); // window output + } - ASSERT_LT(rmse_ch1, 5e-2); - ASSERT_LT(error_mean_ch1, 5e-2); - ASSERT_GT(error_mean_ch1, -5e-2); - ASSERT_LT(error_var_ch1, 5e-2); - ASSERT_LT(max_error_ch1, 5e-2); - ASSERT_GT(min_error_ch1, -5e-2); + //check results against the test tolerance + ASSERT_LT(rmse_ch0, 0.25); + ASSERT_LT(error_mean_ch0, 0.2); + ASSERT_GT(error_mean_ch0, -0.2); + ASSERT_LT(error_var_ch0, 0.5); + ASSERT_LT(max_error_ch0, 0.5); + ASSERT_GT(min_error_ch0, -0.5); } -void HybridObservablesTest::check_results_code_psudorange( +void HybridObservablesTest::check_results_carrier_phase_double_diff( arma::mat& true_ch0, arma::mat& true_ch1, - arma::vec& true_tow_s, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, arma::mat& measured_ch0, - arma::mat& measured_ch1) + arma::mat& measured_ch1, + const std::string& data_title) { //1. True value interpolation to match the measurement times @@ -397,12 +874,562 @@ void HybridObservablesTest::check_results_code_psudorange( int size1 = measured_ch0.col(0).n_rows; int size2 = measured_ch1.col(0).n_rows; double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_carrier_phase_interp; + arma::vec true_ch1_carrier_phase_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(3), t, true_ch0_carrier_phase_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(3), t, true_ch1_carrier_phase_interp); + + arma::vec meas_ch0_carrier_phase_interp; + arma::vec meas_ch1_carrier_phase_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(3), t, meas_ch0_carrier_phase_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(3), t, meas_ch1_carrier_phase_interp); + + // generate double difference accumulated carrier phases + //compute error without the accumulated carrier phase offsets (which depends on the receiver starting time) + arma::vec delta_true_carrier_phase_cycles = (true_ch0_carrier_phase_interp - true_ch0_carrier_phase_interp(0)) - (true_ch1_carrier_phase_interp - true_ch1_carrier_phase_interp(0)); + arma::vec delta_measured_carrier_phase_cycles = (meas_ch0_carrier_phase_interp - meas_ch0_carrier_phase_interp(0)) - (meas_ch1_carrier_phase_interp - meas_ch1_carrier_phase_interp(0)); + + //2. RMSE + arma::vec err; + + err = delta_measured_carrier_phase_cycles - delta_true_carrier_phase_cycles; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Carrier Phase RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [Cycles]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Carrier Phase error [Cycles]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Carrier Phase error [Cycles]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Carrier Phase error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_carrier_phase_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse, 0.25); + ASSERT_LT(error_mean, 0.2); + ASSERT_GT(error_mean, -0.2); + ASSERT_LT(error_var, 0.5); + ASSERT_LT(max_error, 0.5); + ASSERT_GT(min_error, -0.5); +} + + +void HybridObservablesTest::check_results_carrier_doppler_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + const std::string& data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_carrier_doppler_interp; + arma::vec true_ch1_carrier_doppler_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(2), t, true_ch0_carrier_doppler_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(2), t, true_ch1_carrier_doppler_interp); + + arma::vec meas_ch0_carrier_doppler_interp; + arma::vec meas_ch1_carrier_doppler_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(2), t, meas_ch0_carrier_doppler_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(2), t, meas_ch1_carrier_doppler_interp); + + // generate double difference carrier Doppler + arma::vec delta_true_carrier_doppler_cycles = true_ch0_carrier_doppler_interp - true_ch1_carrier_doppler_interp; + arma::vec delta_measured_carrier_doppler_cycles = meas_ch0_carrier_doppler_interp - meas_ch1_carrier_doppler_interp; + + //2. RMSE + arma::vec err; + + err = delta_measured_carrier_doppler_cycles - delta_true_carrier_doppler_cycles; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Carrier Doppler RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [Hz]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Carrier Doppler error [Hz]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Carrier Doppler error [Hz]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Carrier Doppler error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_carrier_doppler_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(error_mean, 5); + ASSERT_GT(error_mean, -5); + //assuming PLL BW=35 + ASSERT_LT(error_var, 250); + ASSERT_LT(max_error, 100); + ASSERT_GT(min_error, -100); + ASSERT_LT(rmse, 30); +} + + +void HybridObservablesTest::check_results_carrier_doppler( + arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + const std::string& data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = measured_ch0(0, 0); + int size1 = measured_ch0.col(0).n_rows; + double t1 = measured_ch0(size1 - 1, 0); + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + arma::vec true_ch0_doppler_interp; + arma::interp1(true_tow_s, true_ch0.col(2), t, true_ch0_doppler_interp); + + arma::vec meas_ch0_doppler_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(2), t, meas_ch0_doppler_interp); + + //2. RMSE + arma::vec err_ch0_hz; + + //compute error + err_ch0_hz = meas_ch0_doppler_interp - true_ch0_doppler_interp; + + arma::vec err2_ch0 = arma::square(err_ch0_hz); + double rmse_ch0 = sqrt(arma::mean(err2_ch0)); + + //3. Mean err and variance + double error_mean_ch0 = arma::mean(err_ch0_hz); + double error_var_ch0 = arma::var(err_ch0_hz); + + // 4. Peaks + double max_error_ch0 = arma::max(err_ch0_hz); + double min_error_ch0 = arma::min(err_ch0_hz); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Carrier Doppler RMSE = " + << rmse_ch0 << ", mean = " << error_mean_ch0 + << ", stdev = " << sqrt(error_var_ch0) + << " (max,min) = " << max_error_ch0 + << "," << min_error_ch0 + << " [Hz]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Carrier Doppler error [Hz]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Doppler error [Hz]"); + //conversion between arma::vec and std:vector + std::vector error_vec(err_ch0_hz.colptr(0), err_ch0_hz.colptr(0) + err_ch0_hz.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, error_vec, + "Carrier Doppler error"); + g3.set_legend(); + g3.savetops(data_title + "Carrier_doppler_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(error_mean_ch0, 5); + ASSERT_GT(error_mean_ch0, -5); + //assuming PLL BW=35 + ASSERT_LT(error_var_ch0, 250); + ASSERT_LT(max_error_ch0, 100); + ASSERT_GT(min_error_ch0, -100); + ASSERT_LT(rmse_ch0, 30); +} + +void HybridObservablesTest::check_results_duplicated_satellite( + arma::mat& measured_sat1, + arma::mat& measured_sat2, + int ch_id, + const std::string& data_title) +{ + //1. True value interpolation to match the measurement times + + //define the common measured time interval + double t0_sat1 = measured_sat1(0, 0); + int size1 = measured_sat1.col(0).n_rows; + double t1_sat1 = measured_sat1(size1 - 1, 0); + + double t0_sat2 = measured_sat2(0, 0); + int size2 = measured_sat2.col(0).n_rows; + double t1_sat2 = measured_sat2(size2 - 1, 0); + + double t0; + double t1; + if (t0_sat1 > t0_sat2) + { + t0 = t0_sat1; + } + else + { + t0 = t0_sat2; + } + + if (t1_sat1 > t1_sat2) + { + t1 = t1_sat2; + } + else + { + t1 = t1_sat1; + } + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + //Doppler + arma::vec meas_sat1_doppler_interp; + arma::interp1(measured_sat1.col(0), measured_sat1.col(2), t, meas_sat1_doppler_interp); + arma::vec meas_sat2_doppler_interp; + arma::interp1(measured_sat2.col(0), measured_sat2.col(2), t, meas_sat2_doppler_interp); + + //Carrier Phase + arma::vec meas_sat1_carrier_phase_interp; + arma::vec meas_sat2_carrier_phase_interp; + arma::interp1(measured_sat1.col(0), measured_sat1.col(3), t, meas_sat1_carrier_phase_interp); + arma::interp1(measured_sat2.col(0), measured_sat2.col(3), t, meas_sat2_carrier_phase_interp); + + // generate double difference accumulated carrier phases + //compute error without the accumulated carrier phase offsets (which depends on the receiver starting time) + arma::vec delta_measured_carrier_phase_cycles = (meas_sat1_carrier_phase_interp - meas_sat1_carrier_phase_interp(0)) - (meas_sat2_carrier_phase_interp - meas_sat2_carrier_phase_interp(0)); + + //Pseudoranges + arma::vec meas_sat1_dist_interp; + arma::vec meas_sat2_dist_interp; + arma::interp1(measured_sat1.col(0), measured_sat1.col(4), t, meas_sat1_dist_interp); + arma::interp1(measured_sat2.col(0), measured_sat2.col(4), t, meas_sat2_dist_interp); + // generate delta pseudoranges + arma::vec delta_measured_dist_m = meas_sat1_dist_interp - meas_sat2_dist_interp; + + //Carrier Doppler error + //2. RMSE + arma::vec err_ch0_hz; + + //compute error + err_ch0_hz = meas_sat1_doppler_interp - meas_sat2_doppler_interp; + + //save matlab file for further analysis + std::vector tmp_vector_common_time_s(t.colptr(0), + t.colptr(0) + t.n_rows); + + std::vector tmp_vector_err_ch0_hz(err_ch0_hz.colptr(0), + err_ch0_hz.colptr(0) + err_ch0_hz.n_rows); + save_mat_xy(tmp_vector_common_time_s, tmp_vector_err_ch0_hz, std::string("measured_doppler_error_ch_" + std::to_string(ch_id))); + + //compute statistics + arma::vec err2_ch0 = arma::square(err_ch0_hz); + double rmse_ch0 = sqrt(arma::mean(err2_ch0)); + + //3. Mean err and variance + double error_mean_ch0 = arma::mean(err_ch0_hz); + double error_var_ch0 = arma::var(err_ch0_hz); + + // 4. Peaks + double max_error_ch0 = arma::max(err_ch0_hz); + double min_error_ch0 = arma::min(err_ch0_hz); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Carrier Doppler RMSE = " + << rmse_ch0 << ", mean = " << error_mean_ch0 + << ", stdev = " << sqrt(error_var_ch0) + << " (max,min) = " << max_error_ch0 + << "," << min_error_ch0 + << " [Hz]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Carrier Doppler error [Hz]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Doppler error [Hz]"); + //conversion between arma::vec and std:vector + std::vector error_vec(err_ch0_hz.colptr(0), err_ch0_hz.colptr(0) + err_ch0_hz.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, error_vec, + "Carrier Doppler error"); + g3.set_legend(); + g3.savetops(data_title + "Carrier_doppler_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + EXPECT_LT(error_mean_ch0, 5); + EXPECT_GT(error_mean_ch0, -5); + //assuming PLL BW=35 + EXPECT_LT(error_var_ch0, 250); + EXPECT_LT(max_error_ch0, 100); + EXPECT_GT(min_error_ch0, -100); + EXPECT_LT(rmse_ch0, 30); + + //Carrier Phase error + //2. RMSE + arma::vec err_carrier_phase; + + err_carrier_phase = delta_measured_carrier_phase_cycles; + + //save matlab file for further analysis + std::vector tmp_vector_err_carrier_phase(err_carrier_phase.colptr(0), + err_carrier_phase.colptr(0) + err_carrier_phase.n_rows); + save_mat_xy(tmp_vector_common_time_s, tmp_vector_err_carrier_phase, std::string("measured_carrier_phase_error_ch_" + std::to_string(ch_id))); + + + arma::vec err2_carrier_phase = arma::square(err_carrier_phase); + double rmse_carrier_phase = sqrt(arma::mean(err2_carrier_phase)); + + //3. Mean err and variance + double error_mean_carrier_phase = arma::mean(err_carrier_phase); + double error_var_carrier_phase = arma::var(err_carrier_phase); + + // 4. Peaks + double max_error_carrier_phase = arma::max(err_carrier_phase); + double min_error_carrier_phase = arma::min(err_carrier_phase); + + //5. report + ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Carrier Phase RMSE = " + << rmse_carrier_phase << ", mean = " << error_mean_carrier_phase + << ", stdev = " << sqrt(error_var_carrier_phase) + << " (max,min) = " << max_error_carrier_phase + << "," << min_error_carrier_phase + << " [Cycles]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Carrier Phase error [Cycles]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Phase error [Cycles]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err_carrier_phase.colptr(0), err_carrier_phase.colptr(0) + err_carrier_phase.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Carrier Phase error"); + g3.set_legend(); + g3.savetops(data_title + "duplicated_satellite_carrier_phase_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + EXPECT_LT(rmse_carrier_phase, 0.25); + EXPECT_LT(error_mean_carrier_phase, 0.2); + EXPECT_GT(error_mean_carrier_phase, -0.2); + EXPECT_LT(error_var_carrier_phase, 0.5); + EXPECT_LT(max_error_carrier_phase, 0.5); + EXPECT_GT(min_error_carrier_phase, -0.5); + + //Pseudorange error + //2. RMSE + arma::vec err_pseudorange; + + err_pseudorange = delta_measured_dist_m; + + //save matlab file for further analysis + std::vector tmp_vector_err_pseudorange(err_pseudorange.colptr(0), + err_pseudorange.colptr(0) + err_pseudorange.n_rows); + save_mat_xy(tmp_vector_common_time_s, tmp_vector_err_pseudorange, std::string("measured_pr_error_ch_" + std::to_string(ch_id))); + + arma::vec err2_pseudorange = arma::square(err_pseudorange); + double rmse_pseudorange = sqrt(arma::mean(err2_pseudorange)); + + //3. Mean err and variance + double error_mean_pseudorange = arma::mean(err_pseudorange); + double error_var_pseudorange = arma::var(err_pseudorange); + + // 4. Peaks + double max_error_pseudorange = arma::max(err_pseudorange); + double min_error_pseudorange = arma::min(err_pseudorange); + + //5. report + ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Pseudorange RMSE = " + << rmse_pseudorange << ", mean = " << error_mean_pseudorange + << ", stdev = " << sqrt(error_var_pseudorange) + << " (max,min) = " << max_error_pseudorange + << "," << min_error_pseudorange + << " [meters]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Pseudorange error [m]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Pseudorange error [m]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err_pseudorange.colptr(0), err_pseudorange.colptr(0) + err_pseudorange.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Pseudorrange error"); + g3.set_legend(); + g3.savetops(data_title + "duplicated_satellite_pseudorrange_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + EXPECT_LT(rmse_pseudorange, 3.0); + EXPECT_LT(error_mean_pseudorange, 1.0); + EXPECT_GT(error_mean_pseudorange, -1.0); + EXPECT_LT(error_var_pseudorange, 10.0); + EXPECT_LT(max_error_pseudorange, 10.0); + EXPECT_GT(min_error_pseudorange, -10.0); +} + +bool HybridObservablesTest::save_mat_xy(std::vector& x, std::vector& y, std::string filename) +{ + try + { + // WRITE MAT FILE + mat_t* matfp; + matvar_t* matvar; + filename.append(".mat"); + std::cout << "save_mat_xy write " << filename << std::endl; + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT5); + if (reinterpret_cast(matfp) != nullptr) + { + size_t dims[2] = {1, x.size()}; + matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &y[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + else + { + std::cout << "save_mat_xy: error creating file" << std::endl; + } + Mat_Close(matfp); + return true; + } + catch (const std::exception& ex) + { + std::cout << "save_mat_xy: " << ex.what() << std::endl; + return false; + } +} + +void HybridObservablesTest::check_results_code_pseudorange( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + const std::string& data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + arma::vec true_ch0_dist_interp; arma::vec true_ch1_dist_interp; - arma::interp1(true_tow_s, true_ch0.col(1), t, true_ch0_dist_interp); - arma::interp1(true_tow_s, true_ch1.col(1), t, true_ch1_dist_interp); + arma::interp1(true_tow_ch0_s, true_ch0.col(1), t, true_ch0_dist_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(1), t, true_ch1_dist_interp); arma::vec meas_ch0_dist_interp; arma::vec meas_ch1_dist_interp; @@ -430,7 +1457,7 @@ void HybridObservablesTest::check_results_code_psudorange( //5. report std::streamsize ss = std::cout.precision(); - std::cout << std::setprecision(10) << "Delta Observables RMSE = " + std::cout << std::setprecision(10) << data_title << "Double diff Pseudorange RMSE = " << rmse << ", mean = " << error_mean << ", stdev = " << sqrt(error_var) << " (max,min) = " << max_error @@ -438,15 +1465,174 @@ void HybridObservablesTest::check_results_code_psudorange( << " [meters]" << std::endl; std::cout.precision(ss); - ASSERT_LT(rmse, 0.5); - ASSERT_LT(error_mean, 0.5); - ASSERT_GT(error_mean, -0.5); - ASSERT_LT(error_var, 0.5); - ASSERT_LT(max_error, 2.0); - ASSERT_GT(min_error, -2.0); + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Pseudorange error [m]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Pseudorange error [m]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Pseudorrange error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_pseudorrange_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse, 3.0); + ASSERT_LT(error_mean, 1.0); + ASSERT_GT(error_mean, -1.0); + ASSERT_LT(error_var, 10.0); + ASSERT_LT(max_error, 10.0); + ASSERT_GT(min_error, -10.0); } +bool HybridObservablesTest::ReadRinexObs(std::vector* obs_vec, Gnss_Synchro gnss) +{ + // Open and read reference RINEX observables file + try + { + gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs); + r_ref.exceptions(std::ios::failbit); + gpstk::Rinex3ObsData r_ref_data; + gpstk::Rinex3ObsHeader r_ref_header; + gpstk::RinexDatum dataobj; + + r_ref >> r_ref_header; + + std::vector first_row; + gpstk::SatID prn; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + first_row.push_back(true); + obs_vec->push_back(arma::zeros(1, 4)); + } + while (r_ref >> r_ref_data) + { + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + int myprn = gnss_synchro_vec.at(n).PRN; + + switch (gnss.System) + { + case 'G': + prn = gpstk::SatID(myprn, gpstk::SatID::systemGPS); + break; + case 'E': + prn = gpstk::SatID(myprn, gpstk::SatID::systemGalileo); + break; + default: + prn = gpstk::SatID(myprn, gpstk::SatID::systemGPS); + } + + gpstk::CommonTime time = r_ref_data.time; + double sow(static_cast(time).sow); + + auto pointer = r_ref_data.obs.find(prn); + if (pointer == r_ref_data.obs.end()) + { + // PRN not present; do nothing + } + else + { + if (first_row.at(n) == false) + { + //insert next column + obs_vec->at(n).insert_rows(obs_vec->at(n).n_rows, 1); + } + else + { + first_row.at(n) = false; + } + if (strcmp("1C\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; //C1C P1 (psudorange L1) + dataobj = r_ref_data.getObs(prn, "D1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; //D1C Carrier Doppler + dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; //L1C Carrier Phase + } + else if (strcmp("1B\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("2S\0", gnss.Signal) == 0) //L2M + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("L5\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("5X\0", gnss.Signal) == 0) //Simulator gives RINEX with E5a+E5b. Doppler and accumulated Carrier phase WILL differ + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else + { + std::cout << "ReadRinexObs unknown signal requested: " << gnss.Signal << std::endl; + return false; + } + } + } + } // end while + } // End of 'try' block + catch (const gpstk::FFStreamError& e) + { + std::cout << e; + return false; + } + catch (const gpstk::Exception& e) + { + std::cout << e; + return false; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what(); + std::cout << "unknown error. I don't feel so well..." << std::endl; + return false; + } + std::cout << "ReadRinexObs info:" << std::endl; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + std::cout << "SAT PRN " << gnss_synchro_vec.at(n).PRN << " RINEX epoch readed: " << obs_vec->at(n).n_rows << std::endl; + } + return true; +} TEST_F(HybridObservablesTest, ValidationOfResults) { // Configure the signal generator @@ -461,135 +1647,181 @@ TEST_F(HybridObservablesTest, ValidationOfResults) std::chrono::time_point start, end; std::chrono::duration elapsed_seconds(0); - configure_receiver(); + // use generator or use an external capture file + if (FLAGS_enable_external_signal_file) + { + //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters + ASSERT_EQ(acquire_signal(), true); + } + else + { + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.System = 'G'; + std::string signal = "1C"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); - //open true observables log file written by the simulator - tracking_true_obs_reader true_obs_data_ch0; - tracking_true_obs_reader true_obs_data_ch1; - int test_satellite_PRN = FLAGS_test_satellite_PRN; - int test_satellite_PRN2 = FLAGS_test_satellite_PRN2; - std::cout << "Testing satellite PRNs " << test_satellite_PRN << "," << test_satellite_PRN << std::endl; - std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); - true_obs_file.append(std::to_string(test_satellite_PRN)); - true_obs_file.append(".dat"); - ASSERT_NO_THROW({ - if (true_obs_data_ch0.open_obs_file(true_obs_file) == false) - { - throw std::exception(); - }; - }) << "Failure opening true observables file"; + std::istringstream ss(FLAGS_test_satellite_PRN_list); + std::string token; - true_obs_file = std::string("./gps_l1_ca_obs_prn"); - true_obs_file.append(std::to_string(test_satellite_PRN2)); - true_obs_file.append(".dat"); - ASSERT_NO_THROW({ - if (true_obs_data_ch1.open_obs_file(true_obs_file) == false) - { - throw std::exception(); - }; - }) << "Failure opening true observables file"; + while (std::getline(ss, token, ',')) + { + tmp_gnss_synchro.PRN = boost::lexical_cast(token); + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + } + + + configure_receiver(FLAGS_PLL_bw_hz_start, + FLAGS_DLL_bw_hz_start, + FLAGS_PLL_narrow_bw_hz, + FLAGS_DLL_narrow_bw_hz, + FLAGS_extend_correlation_symbols, + FLAGS_smoother_length, + FLAGS_high_dyn); + + + for (auto& n : gnss_synchro_vec) + { + //setup the signal synchronization, simulating an acquisition + if (!FLAGS_enable_external_signal_file) + { + //based on true observables metadata (for custom sdr generator) + //open true observables log file written by the simulator or based on provided RINEX obs + std::vector> true_reader_vec; + //read true data from the generator logs + true_reader_vec.push_back(std::make_shared()); + std::cout << "Loading true observable data for PRN " << n.PRN << std::endl; + std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); + true_obs_file.append(std::to_string(n.PRN)); + true_obs_file.append(".dat"); + ASSERT_NO_THROW({ + if (true_reader_vec.back()->open_obs_file(true_obs_file) == false) + { + throw std::exception(); + }; + }) << "Failure opening true observables file"; + + // load acquisition data based on the first epoch of the true observations + ASSERT_NO_THROW({ + if (true_reader_vec.back()->read_binary_obs() == false) + { + throw std::exception(); + }; + }) << "Failure reading true observables file"; + + //restart the epoch counter + true_reader_vec.back()->restart(); + + std::cout << "Initial Doppler [Hz]=" << true_reader_vec.back()->doppler_l1_hz << " Initial code delay [Chips]=" + << true_reader_vec.back()->prn_delay_chips << std::endl; + n.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_reader_vec.back()->prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; + n.Acq_doppler_hz = true_reader_vec.back()->doppler_l1_hz; + n.Acq_samplestamp_samples = 0; + } + else + { + //based on the signal acquisition process + std::cout << "Estimated Initial Doppler " << n.Acq_doppler_hz + << " [Hz], estimated Initial code delay " << n.Acq_delay_samples << " [Samples]" + << " Acquisition SampleStamp is " << n.Acq_samplestamp_samples << std::endl; + n.Acq_samplestamp_samples = 0; + } + } + + std::vector> tracking_ch_vec; + std::vector> tlm_ch_vec; + + std::vector null_sink_vec; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + //set channels ids + gnss_synchro_vec.at(n).Channel_ID = n; + + //create the tracking channels and create the telemetry decoders + + std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); + tracking_ch_vec.push_back(std::dynamic_pointer_cast(trk_)); + std::shared_ptr tlm_ = factory->GetBlock(config, "TelemetryDecoder", config->property("TelemetryDecoder.implementation", std::string("undefined")), 1, 1); + tlm_ch_vec.push_back(std::dynamic_pointer_cast(tlm_)); + + //create null sinks for observables output + null_sink_vec.push_back(gr::blocks::null_sink::make(sizeof(Gnss_Synchro))); + + ASSERT_NO_THROW({ + tlm_ch_vec.back()->set_channel(gnss_synchro_vec.at(n).Channel_ID); + + switch (gnss_synchro_master.System) + { + case 'G': + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_vec.at(n).PRN)); + break; + case 'E': + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("Galileo"), gnss_synchro_vec.at(n).PRN)); + break; + default: + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_vec.at(n).PRN)); + } + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + tracking_ch_vec.back()->set_channel(gnss_synchro_vec.at(n).Channel_ID); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + tracking_ch_vec.back()->set_gnss_synchro(&gnss_synchro_vec.at(n)); + }) << "Failure setting gnss_synchro."; + } top_block = gr::make_top_block("Telemetry_Decoder test"); - std::shared_ptr tracking_ch0 = std::make_shared(config.get(), "Tracking_1C", 1, 1); - std::shared_ptr tracking_ch1 = std::make_shared(config.get(), "Tracking_1C", 1, 1); - - boost::shared_ptr msg_rx_ch0 = HybridObservablesTest_msg_rx_make(); - boost::shared_ptr msg_rx_ch1 = HybridObservablesTest_msg_rx_make(); - - // load acquisition data based on the first epoch of the true observations - ASSERT_NO_THROW({ - if (true_obs_data_ch0.read_binary_obs() == false) - { - throw std::exception(); - }; - }) << "Failure reading true observables file"; - - ASSERT_NO_THROW({ - if (true_obs_data_ch1.read_binary_obs() == false) - { - throw std::exception(); - }; - }) << "Failure reading true observables file"; - - //restart the epoch counter - true_obs_data_ch0.restart(); - true_obs_data_ch1.restart(); - - std::cout << "Initial Doppler [Hz]=" << true_obs_data_ch0.doppler_l1_hz << " Initial code delay [Chips]=" << true_obs_data_ch0.prn_delay_chips << std::endl; - - gnss_synchro_ch0.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data_ch0.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; - gnss_synchro_ch0.Acq_doppler_hz = true_obs_data_ch0.doppler_l1_hz; - gnss_synchro_ch0.Acq_samplestamp_samples = 0; - - std::cout << "Initial Doppler [Hz]=" << true_obs_data_ch1.doppler_l1_hz << " Initial code delay [Chips]=" << true_obs_data_ch1.prn_delay_chips << std::endl; - - gnss_synchro_ch1.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data_ch1.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; - gnss_synchro_ch1.Acq_doppler_hz = true_obs_data_ch1.doppler_l1_hz; - gnss_synchro_ch1.Acq_samplestamp_samples = 0; - - //telemetry decoders - std::shared_ptr tlm_ch0(new GpsL1CaTelemetryDecoder(config.get(), "TelemetryDecoder_1C", 1, 1)); - std::shared_ptr tlm_ch1(new GpsL1CaTelemetryDecoder(config.get(), "TelemetryDecoder_1C", 1, 1)); - - ASSERT_NO_THROW({ - tlm_ch0->set_channel(0); - tlm_ch1->set_channel(1); - - tlm_ch0->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_ch0.PRN)); - tlm_ch1->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_ch1.PRN)); - }) << "Failure setting gnss_synchro."; - - boost::shared_ptr tlm_msg_rx_ch1 = HybridObservablesTest_tlm_msg_rx_make(); - boost::shared_ptr tlm_msg_rx_ch2 = HybridObservablesTest_tlm_msg_rx_make(); - + boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_make(); + boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_make(); //Observables - std::shared_ptr observables(new HybridObservables(config.get(), "Observables", 3, 2)); + std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); + + for (auto& n : tracking_ch_vec) + { + ASSERT_NO_THROW({ + n->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + } + ASSERT_NO_THROW({ - tracking_ch0->set_channel(gnss_synchro_ch0.Channel_ID); - tracking_ch1->set_channel(gnss_synchro_ch1.Channel_ID); - }) << "Failure setting channel."; - - ASSERT_NO_THROW({ - tracking_ch0->set_gnss_synchro(&gnss_synchro_ch0); - tracking_ch1->set_gnss_synchro(&gnss_synchro_ch1); - }) << "Failure setting gnss_synchro."; - - ASSERT_NO_THROW({ - tracking_ch0->connect(top_block); - tracking_ch1->connect(top_block); - }) << "Failure connecting tracking to the top_block."; - - ASSERT_NO_THROW({ - std::string file = "./" + filename_raw_data; + std::string file; + if (!FLAGS_enable_external_signal_file) + { + file = "./" + filename_raw_data; + } + else + { + file = FLAGS_signal_file; + } const char* file_name = file.c_str(); gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); - gr::blocks::null_sink::sptr sink_ch0 = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); - gr::blocks::null_sink::sptr sink_ch1 = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); - gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), sizeof(gr_complex)); + int observable_interval_ms = 20; + gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); - //ch0 - top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch0->get_left_block(), 0); - top_block->connect(tracking_ch0->get_right_block(), 0, tlm_ch0->get_left_block(), 0); - top_block->connect(tlm_ch0->get_right_block(), 0, observables->get_left_block(), 0); - top_block->msg_connect(tracking_ch0->get_right_block(), pmt::mp("events"), msg_rx_ch0, pmt::mp("events")); - //ch1 - top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch1->get_left_block(), 0); - top_block->connect(tracking_ch1->get_right_block(), 0, tlm_ch1->get_left_block(), 0); - top_block->connect(tlm_ch1->get_right_block(), 0, observables->get_left_block(), 1); - top_block->msg_connect(tracking_ch1->get_right_block(), pmt::mp("events"), msg_rx_ch1, pmt::mp("events")); - - top_block->connect(observables->get_right_block(), 0, sink_ch0, 0); - top_block->connect(observables->get_right_block(), 1, sink_ch1, 0); - top_block->connect(samp_counter, 0, observables->get_left_block(), 2); + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); + top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); + top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); + } + //connect sample counter and timmer to the last channel in observables block (extra channel) + top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks."; - tracking_ch0->start_tracking(); - tracking_ch1->start_tracking(); + for (auto& n : tracking_ch_vec) + { + n->start_tracking(); + } EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); @@ -599,55 +1831,61 @@ TEST_F(HybridObservablesTest, ValidationOfResults) }) << "Failure running the top_block."; //check results - //load the true values - - true_observables_reader true_observables; - - ASSERT_NO_THROW({ - if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) - { - throw std::exception(); - } - }) << "Failure opening true observables file"; - - unsigned int nepoch = static_cast(true_observables.num_epochs()); - - std::cout << "True observation epochs = " << nepoch << std::endl; // Matrices for storing columnwise true GPS time, Range, Doppler and Carrier phase - arma::mat true_ch0 = arma::zeros(nepoch, 4); - arma::mat true_ch1 = arma::zeros(nepoch, 4); + std::vector true_obs_vec; - true_observables.restart(); - long int epoch_counter = 0; - ASSERT_NO_THROW({ - while (true_observables.read_binary_obs()) - { - if (round(true_observables.prn[0]) != gnss_synchro_ch0.PRN) + if (!FLAGS_enable_external_signal_file) + { + //load the true values + True_Observables_Reader true_observables; + ASSERT_NO_THROW({ + if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) { - std::cout << "True observables SV PRN does not match " << round(true_observables.prn[1]) << std::endl; throw std::exception(); } - if (round(true_observables.prn[1]) != gnss_synchro_ch1.PRN) + }) << "Failure opening true observables file"; + + auto nepoch = static_cast(true_observables.num_epochs()); + + std::cout << "True observation epochs = " << nepoch << std::endl; + + true_observables.restart(); + int64_t epoch_counter = 0; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + true_obs_vec.push_back(arma::zeros(nepoch, 4)); + } + + ASSERT_NO_THROW({ + while (true_observables.read_binary_obs()) { - std::cout << "True observables SV PRN does not match " << round(true_observables.prn[1]) << std::endl; - throw std::exception(); + for (unsigned int n = 0; n < true_obs_vec.size(); n++) + { + if (round(true_observables.prn[n]) != gnss_synchro_vec.at(n).PRN) + { + std::cout << "True observables SV PRN does not match measured ones: " + << round(true_observables.prn[n]) << " vs. " << gnss_synchro_vec.at(n).PRN << std::endl; + throw std::exception(); + } + true_obs_vec.at(n)(epoch_counter, 0) = true_observables.gps_time_sec[n]; + true_obs_vec.at(n)(epoch_counter, 1) = true_observables.dist_m[n]; + true_obs_vec.at(n)(epoch_counter, 2) = true_observables.doppler_l1_hz[n]; + true_obs_vec.at(n)(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[n]; + } + epoch_counter++; } - true_ch0(epoch_counter, 0) = true_observables.gps_time_sec[0]; - true_ch0(epoch_counter, 1) = true_observables.dist_m[0]; - true_ch0(epoch_counter, 2) = true_observables.doppler_l1_hz[0]; - true_ch0(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[0]; - - true_ch1(epoch_counter, 0) = true_observables.gps_time_sec[1]; - true_ch1(epoch_counter, 1) = true_observables.dist_m[1]; - true_ch1(epoch_counter, 2) = true_observables.doppler_l1_hz[1]; - true_ch1(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[1]; - - epoch_counter++; - } - }); - + }); + } + else + { + if (!FLAGS_duplicated_satellites_test) + { + ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) + << "Failure reading RINEX file"; + } + } //read measured values - observables_dump_reader estimated_observables(2); //two channels + Observables_Dump_Reader estimated_observables(tracking_ch_vec.size()); ASSERT_NO_THROW({ if (estimated_observables.open_obs_file(std::string("./observables.dat")) == false) { @@ -655,82 +1893,253 @@ TEST_F(HybridObservablesTest, ValidationOfResults) } }) << "Failure opening dump observables file"; - nepoch = static_cast(estimated_observables.num_epochs()); - std::cout << "Measured observation epochs = " << nepoch << std::endl; + auto nepoch = static_cast(estimated_observables.num_epochs()); + std::cout << "Measured observations epochs = " << nepoch << std::endl; // Matrices for storing columnwise measured RX_time, TOW, Doppler, Carrier phase and Pseudorange - arma::mat measured_ch0 = arma::zeros(nepoch, 5); - arma::mat measured_ch1 = arma::zeros(nepoch, 5); + std::vector measured_obs_vec; + std::vector epoch_counters_vec; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + measured_obs_vec.push_back(arma::zeros(nepoch, 5)); + epoch_counters_vec.push_back(0); + } estimated_observables.restart(); - epoch_counter = 0; - long int epoch_counter2 = 0; while (estimated_observables.read_binary_obs()) { - if (static_cast(estimated_observables.valid[0])) + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) { - measured_ch0(epoch_counter, 0) = estimated_observables.RX_time[0]; - measured_ch0(epoch_counter, 1) = estimated_observables.TOW_at_current_symbol_s[0]; - measured_ch0(epoch_counter, 2) = estimated_observables.Carrier_Doppler_hz[0]; - measured_ch0(epoch_counter, 3) = estimated_observables.Acc_carrier_phase_hz[0]; - measured_ch0(epoch_counter, 4) = estimated_observables.Pseudorange_m[0]; - epoch_counter++; - } - if (static_cast(estimated_observables.valid[1])) - { - measured_ch1(epoch_counter2, 0) = estimated_observables.RX_time[1]; - measured_ch1(epoch_counter2, 1) = estimated_observables.TOW_at_current_symbol_s[1]; - measured_ch1(epoch_counter2, 2) = estimated_observables.Carrier_Doppler_hz[1]; - measured_ch1(epoch_counter2, 3) = estimated_observables.Acc_carrier_phase_hz[1]; - measured_ch1(epoch_counter2, 4) = estimated_observables.Pseudorange_m[1]; - epoch_counter2++; + if (static_cast(estimated_observables.valid[n])) + { + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 3) = estimated_observables.Acc_carrier_phase_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 4) = estimated_observables.Pseudorange_m[n]; + epoch_counters_vec.at(n)++; + } } } //Cut measurement tail zeros - arma::uvec index = arma::find(measured_ch0.col(0) > 0.0, 1, "last"); - if ((index.size() > 0) and index(0) < (nepoch - 1)) + arma::uvec index; + for (auto& n : measured_obs_vec) { - measured_ch0.shed_rows(index(0) + 1, nepoch - 1); - } - index = arma::find(measured_ch1.col(0) > 0.0, 1, "last"); - if ((index.size() > 0) and index(0) < (nepoch - 1)) - { - measured_ch1.shed_rows(index(0) + 1, nepoch - 1); + index = arma::find(n.col(0) > 0.0, 1, "last"); + if ((!index.empty()) and index(0) < (nepoch - 1)) + { + n.shed_rows(index(0) + 1, nepoch - 1); + } } //Cut measurement initial transitory of the measurements - index = arma::find(measured_ch0.col(0) >= true_ch0(0, 0), 1, "first"); - if ((index.size() > 0) and (index(0) > 0)) + double initial_transitory_s = FLAGS_skip_obs_transitory_s; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) { - measured_ch0.shed_rows(0, index(0)); - } - index = arma::find(measured_ch1.col(0) >= true_ch1(0, 0), 1, "first"); - if ((index.size() > 0) and (index(0) > 0)) - { - measured_ch1.shed_rows(0, index(0)); + index = arma::find(measured_obs_vec.at(n).col(0) >= (measured_obs_vec.at(n)(0, 0) + initial_transitory_s), 1, "first"); + if ((!index.empty()) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + + if (!FLAGS_duplicated_satellites_test) + { + index = arma::find(measured_obs_vec.at(n).col(0) >= true_obs_vec.at(n)(0, 0), 1, "first"); + if ((!index.empty()) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + } } - //Correct the clock error using true values (it is not possible for a receiver to correct - //the receiver clock offset error at the observables level because it is required the - //decoding of the ephemeris data and solve the PVT equations) - //Find the reference satellite (the nearest) and compute the receiver time offset at observable level - arma::vec receiver_time_offset_s; - if (measured_ch0(0, 4) < measured_ch1(0, 4)) + if (FLAGS_duplicated_satellites_test) { - receiver_time_offset_s = true_ch0.col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; + //special test mode for duplicated satellites + std::vector prn_pairs; + std::stringstream ss(FLAGS_duplicated_satellites_prns); + unsigned int i; + while (ss >> i) + { + prn_pairs.push_back(i); + if (ss.peek() == ',') + { + ss.ignore(); + } + } + + if (prn_pairs.size() % 2 != 0) + { + std::cout << "Test settings error: duplicated_satellites_prns are even\n"; + } + else + { + for (unsigned int n = 0; n < prn_pairs.size(); n = n + 2) + { + int sat1_ch_id = -1; + int sat2_ch_id = -1; + for (unsigned int ch = 0; ch < measured_obs_vec.size(); ch++) + { + if (epoch_counters_vec.at(ch) > 10) //discard non-valid channels + { + if (gnss_synchro_vec.at(ch).PRN == prn_pairs.at(n)) + { + sat1_ch_id = ch; + } + if (gnss_synchro_vec.at(ch).PRN == prn_pairs.at(n + 1)) + { + sat2_ch_id = ch; + } + } + } + if (sat1_ch_id != -1 and sat2_ch_id != -1) + { + //compute single differences for the duplicated satellite + + check_results_duplicated_satellite( + measured_obs_vec.at(sat1_ch_id), + measured_obs_vec.at(sat2_ch_id), + sat1_ch_id, + "Duplicated sat [CH " + std::to_string(sat1_ch_id) + "," + std::to_string(sat2_ch_id) + "] PRNs " + std::to_string(gnss_synchro_vec.at(sat1_ch_id).PRN) + "," + std::to_string(gnss_synchro_vec.at(sat2_ch_id).PRN) + " "); + } + else + { + std::cout << "Satellites PRNs " << prn_pairs.at(n) << "and " << prn_pairs.at(n) << " not found\n"; + } + } + } } else { - receiver_time_offset_s = true_ch1.col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; + //normal mode + + //Correct the clock error using true values (it is not possible for a receiver to correct + //the receiver clock offset error at the observables level because it is required the + //decoding of the ephemeris data and solve the PVT equations) + + //Find the reference satellite (the nearest) and compute the receiver time offset at observable level + double min_pr = std::numeric_limits::max(); + unsigned int min_pr_ch_id = 0; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + { + if (measured_obs_vec.at(n)(0, 4) < min_pr) + { + min_pr = measured_obs_vec.at(n)(0, 4); + min_pr_ch_id = n; + } + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } + + arma::vec receiver_time_offset_ref_channel_s; + receiver_time_offset_ref_channel_s = (true_obs_vec.at(min_pr_ch_id).col(1)(0) - measured_obs_vec.at(min_pr_ch_id).col(4)(0)) / GPS_C_M_S; + std::cout << "Ref. channel initial Receiver time offset " << receiver_time_offset_ref_channel_s(0) * 1e3 << " [ms]" << std::endl; + + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + //debug save to .mat + std::vector tmp_vector_x(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y(true_obs_vec.at(n).col(1).colptr(0), + true_obs_vec.at(n).col(1).colptr(0) + true_obs_vec.at(n).col(1).n_rows); + save_mat_xy(tmp_vector_x, tmp_vector_y, std::string("true_pr_ch_" + std::to_string(n))); + + std::vector tmp_vector_x2(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y2(measured_obs_vec.at(n).col(4).colptr(0), + measured_obs_vec.at(n).col(4).colptr(0) + measured_obs_vec.at(n).col(4).n_rows); + save_mat_xy(tmp_vector_x2, tmp_vector_y2, std::string("measured_pr_ch_" + std::to_string(n))); + + std::vector tmp_vector_x3(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y3(true_obs_vec.at(n).col(2).colptr(0), + true_obs_vec.at(n).col(2).colptr(0) + true_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x3, tmp_vector_y3, std::string("true_doppler_ch_" + std::to_string(n))); + + std::vector tmp_vector_x4(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y4(measured_obs_vec.at(n).col(2).colptr(0), + measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); + + std::vector tmp_vector_x5(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y5(true_obs_vec.at(n).col(3).colptr(0), + true_obs_vec.at(n).col(3).colptr(0) + true_obs_vec.at(n).col(3).n_rows); + save_mat_xy(tmp_vector_x5, tmp_vector_y5, std::string("true_cp_ch_" + std::to_string(n))); + + std::vector tmp_vector_x6(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y6(measured_obs_vec.at(n).col(3).colptr(0), + measured_obs_vec.at(n).col(3).colptr(0) + measured_obs_vec.at(n).col(3).n_rows); + save_mat_xy(tmp_vector_x6, tmp_vector_y6, std::string("measured_cp_ch_" + std::to_string(n))); + + + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); + arma::vec true_TOW_ch_s = true_obs_vec.at(n).col(0) - receiver_time_offset_ref_channel_s(0); + //Compare measured observables + if (min_pr_ch_id != n) + { + check_results_code_pseudorange(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + + //Do not compare E5a with E5 RINEX due to the Doppler frequency discrepancy caused by the different center frequencies + //E5a_fc=1176.45e6, E5b_fc=1207.14e6, E5_fc=1191.795e6; + if (strcmp("5X\0", gnss_synchro_vec.at(n).Signal) != 0 or FLAGS_compare_with_5X) + { + check_results_carrier_phase_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + + check_results_carrier_doppler_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + } + else + { + std::cout << "[CH " << std::to_string(n) << "] PRN " << std::to_string(gnss_synchro_vec.at(n).PRN) << " is the reference satellite" << std::endl; + } + if (FLAGS_compute_single_diffs) + { + check_results_carrier_phase(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_doppler(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } } - arma::vec corrected_reference_TOW_s = true_ch0.col(0) - receiver_time_offset_s; - std::cout << "Receiver time offset: " << receiver_time_offset_s(0) * 1e3 << " [ms]" << std::endl; - - //Compare measured observables - check_results_code_psudorange(true_ch0, true_ch1, corrected_reference_TOW_s, measured_ch0, measured_ch1); - check_results_carrier_phase(true_ch0, true_ch1, corrected_reference_TOW_s, measured_ch0, measured_ch1); - std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc new file mode 100644 index 000000000..c8024eb2c --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -0,0 +1,1979 @@ +/*! + * \file hybrid_observables_test.cc + * \brief This class implements a tracking test for Galileo_E5a_DLL_PLL_Tracking + * implementation based on some input parameters. + * \author Javier Arribas, 2015. jarribas(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "GPS_L1_CA.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" +#include "gnss_satellite.h" +#include "gnss_sdr_fpga_sample_counter.h" +#include "gnss_synchro.h" +#include "gnuplot_i.h" +#include "gps_l1_ca_dll_pll_tracking.h" +#include "gps_l1_ca_dll_pll_tracking_fpga.h" +#include "gps_l1_ca_telemetry_decoder.h" +#include "hybrid_observables.h" +#include "in_memory_configuration.h" +#include "observable_tests_flags.h" +#include "observables_dump_reader.h" +#include "signal_generator_flags.h" +#include "telemetry_decoder_interface.h" +#include "test_flags.h" +#include "tlm_dump_reader.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_tests_flags.h" +#include "tracking_true_obs_reader.h" +#include "true_observables_reader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// threads +#include // for open, O_RDWR, O_SYNC +#include // for cout, endl +#include // for pthread stuff +#include // for mmap + +#define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples +#define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes +#define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) +#define TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define TEST_OBS_DOWNSAMPLING_FILTER_DELAY 48 + + +// HW related options +bool test_observables_show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if test_observables_doppler_control_in_sw = 1), 0=> do not show it +bool test_observables_skip_samples_already_used = 1; // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops + // (exactly in the same way as the SW) + +class HybridObservablesTest_msg_rx_Fpga; + +typedef boost::shared_ptr HybridObservablesTest_msg_rx_Fpga_sptr; + +HybridObservablesTest_msg_rx_Fpga_sptr HybridObservablesTest_msg_rx_Fpga_make(); + +class HybridObservablesTest_msg_rx_Fpga : public gr::block +{ +private: + friend HybridObservablesTest_msg_rx_Fpga_sptr HybridObservablesTest_msg_rx_Fpga_make(); + void msg_handler_events(pmt::pmt_t msg); + HybridObservablesTest_msg_rx_Fpga(); + +public: + int rx_message; + ~HybridObservablesTest_msg_rx_Fpga(); //!< Default destructor +}; + +HybridObservablesTest_msg_rx_Fpga_sptr HybridObservablesTest_msg_rx_Fpga_make() +{ + return HybridObservablesTest_msg_rx_Fpga_sptr(new HybridObservablesTest_msg_rx_Fpga()); +} + +void HybridObservablesTest_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(msg); + rx_message = message; + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + +HybridObservablesTest_msg_rx_Fpga::HybridObservablesTest_msg_rx_Fpga() : gr::block("HybridObservablesTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&HybridObservablesTest_msg_rx_Fpga::msg_handler_events, this, _1)); + rx_message = 0; +} + +HybridObservablesTest_msg_rx_Fpga::~HybridObservablesTest_msg_rx_Fpga() +{ +} + + +class HybridObservablesTest_tlm_msg_rx_Fpga; + +typedef boost::shared_ptr HybridObservablesTest_tlm_msg_rx_Fpga_sptr; + +HybridObservablesTest_tlm_msg_rx_Fpga_sptr HybridObservablesTest_tlm_msg_rx_Fpga_make(); + +class HybridObservablesTest_tlm_msg_rx_Fpga : public gr::block +{ +private: + friend HybridObservablesTest_tlm_msg_rx_Fpga_sptr HybridObservablesTest_tlm_msg_rx_Fpga_make(); + void msg_handler_events(pmt::pmt_t msg); + HybridObservablesTest_tlm_msg_rx_Fpga(); + +public: + int rx_message; + ~HybridObservablesTest_tlm_msg_rx_Fpga(); //!< Default destructor +}; + +HybridObservablesTest_tlm_msg_rx_Fpga_sptr HybridObservablesTest_tlm_msg_rx_Fpga_make() +{ + return HybridObservablesTest_tlm_msg_rx_Fpga_sptr(new HybridObservablesTest_tlm_msg_rx_Fpga()); +} + +void HybridObservablesTest_tlm_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(msg); + rx_message = message; + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + +HybridObservablesTest_tlm_msg_rx_Fpga::HybridObservablesTest_tlm_msg_rx_Fpga() : gr::block("HybridObservablesTest_tlm_msg_rx_Fpga", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&HybridObservablesTest_tlm_msg_rx_Fpga::msg_handler_events, this, _1)); + rx_message = 0; +} + +HybridObservablesTest_tlm_msg_rx_Fpga::~HybridObservablesTest_tlm_msg_rx_Fpga() +{ +} + +class HybridObservablesTestFpga : public ::testing::Test +{ +public: + std::string generator_binary; + std::string p1; + std::string p2; + std::string p3; + std::string p4; + std::string p5; + std::string implementation = FLAGS_trk_test_implementation; + + const int baseband_sampling_freq = FLAGS_fs_gen_sps; + + std::string filename_rinex_obs = FLAGS_filename_rinex_obs; + std::string filename_raw_data = FLAGS_filename_raw_data; + + int configure_generator(); + int generate_signal(); + bool save_mat_xy(std::vector& x, std::vector& y, std::string filename); + void check_results_carrier_phase( + arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title); + void check_results_carrier_phase_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title); + void check_results_carrier_doppler(arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title); + void check_results_carrier_doppler_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title); + void check_results_code_pseudorange( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title); + + HybridObservablesTestFpga() + { + factory = std::make_shared(); + config = std::make_shared(); + item_size = sizeof(gr_complex); + } + + ~HybridObservablesTestFpga() + { + } + + bool ReadRinexObs(std::vector* obs_vec, Gnss_Synchro gnss); + + bool acquire_signal(); + void configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols); + + gr::top_block_sptr top_block; + std::shared_ptr factory; + std::shared_ptr config; + Gnss_Synchro gnss_synchro_master; + std::vector gnss_synchro_vec; + size_t item_size; +}; + +int HybridObservablesTestFpga::configure_generator() +{ + // Configure signal generator + generator_binary = FLAGS_generator_binary; + + p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; + if (FLAGS_dynamic_position.empty()) + { + p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10); + } + else + { + p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); + } + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] + return 0; +} + + +int HybridObservablesTestFpga::generate_signal() +{ + int child_status; + + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; + + int pid; + if ((pid = fork()) == -1) + perror("fork err"); + else if (pid == 0) + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv err." << std::endl; + std::terminate(); + } + + waitpid(pid, &child_status, 0); + + std::cout << "Signal and Observables RINEX and RAW files created." << std::endl; + return 0; +} + + +const size_t TEST_OBS_PAGE_SIZE = 0x10000; +const unsigned int TEST_OBS_TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; + +void setup_fpga_switch_obs_test(void) +{ + int switch_device_descriptor; // driver descriptor + volatile unsigned* switch_map_base; // driver memory map + + if ((switch_device_descriptor = open("/dev/uio1", O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" + << "/dev/uio1"; + } + switch_map_base = reinterpret_cast(mmap(nullptr, TEST_OBS_PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, switch_device_descriptor, 0)); + + if (switch_map_base == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; + std::cout << "Could not map switch memory." << std::endl; + } + + // sanity check : check test register + unsigned writeval = TEST_OBS_TEST_REGISTER_TRACK_WRITEVAL; + unsigned readval; + // write value to test register + switch_map_base[3] = writeval; + // read value from test register + readval = switch_map_base[3]; + + if (writeval != readval) + { + LOG(WARNING) << "Test register sanity check failed"; + } + else + { + LOG(INFO) << "Test register sanity check success !"; + } + + switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues +} + + +static pthread_mutex_t mutex_obs_test = PTHREAD_MUTEX_INITIALIZER; + +volatile unsigned int send_samples_start_obs_test = 0; + +int8_t input_samples_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL * TEST_OBS_COMPLEX_SAMPLE_SIZE]; // re - im +int8_t input_samples_dma_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL * TEST_OBS_COMPLEX_SAMPLE_SIZE * TEST_OBS_NUM_QUEUES]; + +struct DMA_handler_args_obs_test +{ + std::string file; + unsigned int nsamples_tx; + unsigned int skip_used_samples; + unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 +}; + +void* handler_DMA_obs_test(void* arguments) +{ + // DMA process that configures the DMA to send the samples to the acquisition engine + int tx_fd; // DMA descriptor + FILE* rx_signal_file_id; // Input file descriptor + bool file_completed = false; // flag to indicate if the file is completed + unsigned int nsamples_block; // number of samples to send in the next DMA block of samples + unsigned int nread_elements; // number of elements effectively read from the input file + unsigned int nsamples = 0; // number of complex samples effectively transferred + unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA + + unsigned int nsamples_transmitted; + + struct DMA_handler_args* args = (struct DMA_handler_args*)arguments; + + unsigned int nsamples_tx = args->nsamples_tx; + std::string file = args->file; // input filename + unsigned int skip_used_samples = args->skip_used_samples; + + // open DMA device + tx_fd = open("/dev/loop_tx", O_WRONLY); + if (tx_fd < 0) + { + std::cout << "DMA can't open loop device" << std::endl; + exit(1); + } + else + + // open input file + rx_signal_file_id = fopen(file.c_str(), "rb"); + if (rx_signal_file_id == NULL) + { + std::cout << "DMA can't open input file" << std::endl; + exit(1); + } + while (send_samples_start_obs_test == 0) + ; // wait until acquisition starts + // skip initial samples + int skip_samples = (int)FLAGS_skip_samples; + + fseek(rx_signal_file_id, (skip_samples + skip_used_samples) * 2, SEEK_SET); + + usleep(50000); // wait some time to give time to the main thread to start the acquisition module + + while (file_completed == false) + { + if (nsamples_tx - nsamples > TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + { + nsamples_block = TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + } + else + { + nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent + file_completed = true; + } + + nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + + if (nread_elements != nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE) + { + std::cout << "file completed" << std::endl; + file_completed = true; + } + + nsamples += (nread_elements / TEST_OBS_COMPLEX_SAMPLE_SIZE); + + if (nread_elements > 0) + { + // for the 32-BIT DMA + dma_index = 0; + for (index0 = 0; index0 < (nread_elements); index0 += TEST_OBS_COMPLEX_SAMPLE_SIZE) + { + if (args->freq_band == 0) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma_obs_test[dma_index] = 0; + input_samples_dma_obs_test[dma_index + 1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma_obs_test[dma_index + 2] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index + 3] = input_samples_obs_test[index0 + 1]; + } + else + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma_obs_test[dma_index] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index + 1] = input_samples_obs_test[index0 + 1]; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma_obs_test[dma_index + 2] = 0; + input_samples_dma_obs_test[dma_index + 3] = 0; + } + dma_index += 4; + } + nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements * TEST_OBS_NUM_QUEUES); + if (nsamples_transmitted != nread_elements * TEST_OBS_NUM_QUEUES) + { + std::cout << "Error : DMA could not send all the requested samples" << std::endl; + } + } + } + + + close(tx_fd); + fclose(rx_signal_file_id); + return NULL; +} + + +bool HybridObservablesTestFpga::acquire_signal() +{ + pthread_t thread_DMA; + + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + gr::top_block_sptr top_block; + top_block = gr::make_top_block("Acquisition test"); + int SV_ID = 1; //initial sv id + + // Satellite signal definition + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.Channel_ID = 0; + config = std::make_shared(); + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + + std::shared_ptr acquisition; + + std::string System_and_Signal; + + struct DMA_handler_args_obs_test args; + + //create the correspondign acquisition block according to the desired tracking signal + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'G'; + std::string signal = "1C"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L1 CA"; + + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'E'; + std::string signal = "1B"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E1B"; + + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'E'; + std::string signal = "5X"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E5a"; + + args.freq_band = 1; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'G'; + std::string signal = "L5"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L5I"; + + args.freq_band = 1; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + acquisition->set_channel(0); + acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition->connect(top_block); + + std::string file = FLAGS_signal_file; + + boost::shared_ptr msg_rx; + try + { + msg_rx = Acquisition_msg_rx_make(); + } + catch (const std::exception& e) + { + std::cout << "Failure connecting the message port system: " << e.what() << std::endl; + exit(0); + } + + msg_rx->top_block = top_block; + + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + + + // 5. Run the flowgraph + // Get visible GPS satellites (positive acquisitions with Doppler measurements) + // record startup time + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds; + start = std::chrono::system_clock::now(); + + bool start_msg = true; + + unsigned int MAX_PRN_IDX = 0; + + switch (tmp_gnss_synchro.System) + { + case 'G': + MAX_PRN_IDX = 33; + break; + case 'E': + MAX_PRN_IDX = 37; + break; + default: + MAX_PRN_IDX = 33; + } + + setup_fpga_switch_obs_test(); + + unsigned int nsamples_to_transfer; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS))); + } + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / GPS_L5I_CODE_LENGTH_CHIPS))); + } + + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; + + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + + args.file = file; + + + send_samples_start_obs_test = 0; + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + args.skip_used_samples = -TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES; + + args.nsamples_tx = TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES + TEST_OBS_DOWNSAMPLING_FILTER_DELAY; + + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start_obs_test = 0; + + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = TEST_OBS_DOWNSAMPLING_FILTER_DELAY; + } + else + { + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = 0; + } + + + // create DMA child process + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); + + acquisition->reset(); // set active + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex); + + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do + { + usleep(100000); + } + while (msg_rx->rx_message == 0); + + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + + tmp_gnss_synchro.Acq_doppler_hz = tmp_gnss_synchro.Acq_doppler_hz; + tmp_gnss_synchro.Acq_delay_samples = tmp_gnss_synchro.Acq_delay_samples; + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + tmp_gnss_synchro.Acq_samplestamp_samples = tmp_gnss_synchro.Acq_samplestamp_samples; // delay due to the downsampling filter in the acquisition + + + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } + + + top_block->stop(); + + + std::cout.flush(); + } + std::cout << "]" << std::endl; + std::cout << "-------------------------------------------\n"; + + for (auto& x : gnss_synchro_vec) + { + std::cout << "DETECTED SATELLITE " << System_and_Signal + << " PRN: " << x.PRN + << " with Doppler: " << x.Acq_doppler_hz + << " [Hz], code phase: " << x.Acq_delay_samples + << " [samples] at signal SampleStamp " << x.Acq_samplestamp_samples << "\n"; + } + + // report the elapsed time + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + std::cout << "Total signal acquisition run time " + << elapsed_seconds.count() + << " [seconds]" << std::endl; + if (gnss_synchro_vec.size() > 0) + { + return true; + } + else + { + return false; + } + + + return true; +} + + +void HybridObservablesTestFpga::configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols) +{ + config = std::make_shared(); + config->set_property("Tracking.dump", "true"); + config->set_property("Tracking.dump_filename", "./tracking_ch_"); + config->set_property("Tracking.implementation", implementation); + config->set_property("Tracking.item_type", "gr_complex"); + config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); + config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); + config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + config->set_property("Observables.implementation", "Hybrid_Observables"); + config->set_property("Observables.dump", "true"); + config->set_property("TelemetryDecoder.dump", "true"); + + gnss_synchro_master.Channel_ID = 0; + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + + std::string System_and_Signal; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + gnss_synchro_master.System = 'G'; + std::string signal = "1C"; + System_and_Signal = "GPS L1 CA"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); + + config->set_property("TelemetryDecoder.implementation", "GPS_L1_CA_Telemetry_Decoder"); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + gnss_synchro_master.System = 'E'; + std::string signal = "1B"; + System_and_Signal = "Galileo E1B"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_chips", "0.6"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); + config->set_property("Tracking.track_pilot", "true"); + + config->set_property("TelemetryDecoder.implementation", "Galileo_E1B_Telemetry_Decoder"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + { + gnss_synchro_master.System = 'E'; + std::string signal = "5X"; + System_and_Signal = "Galileo E5a"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + config->set_property("Tracking.order", "2"); + + config->set_property("TelemetryDecoder.implementation", "Galileo_E5a_Telemetry_Decoder"); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + gnss_synchro_master.System = 'G'; + std::string signal = "L5"; + System_and_Signal = "GPS L5I"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + config->set_property("Tracking.order", "2"); + + config->set_property("TelemetryDecoder.implementation", "GPS_L5_Telemetry_Decoder"); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + std::cout << "*****************************************\n"; + std::cout << "*** Tracking configuration parameters ***\n"; + std::cout << "*****************************************\n"; + std::cout << "Signal: " << System_and_Signal << "\n"; + std::cout << "implementation: " << config->property("Tracking.implementation", std::string("undefined")) << " \n"; + std::cout << "pll_bw_hz: " << config->property("Tracking.pll_bw_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_hz: " << config->property("Tracking.dll_bw_hz", 0.0) << " Hz\n"; + std::cout << "pll_bw_narrow_hz: " << config->property("Tracking.pll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_narrow_hz: " << config->property("Tracking.dll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "extend_correlation_symbols: " << config->property("Tracking.extend_correlation_symbols", 0) << " Symbols\n"; + std::cout << "*****************************************\n"; + std::cout << "*****************************************\n"; +} + +void HybridObservablesTestFpga::check_results_carrier_phase( + arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = measured_ch0(0, 0); + int size1 = measured_ch0.col(0).n_rows; + double t1 = measured_ch0(size1 - 1, 0); + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + arma::vec true_ch0_phase_interp; + arma::interp1(true_tow_s, true_ch0.col(3), t, true_ch0_phase_interp); + + arma::vec meas_ch0_phase_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(3), t, meas_ch0_phase_interp); + + //2. RMSE + arma::vec err_ch0_cycles; + + //compute error without the accumulated carrier phase offsets (which depends on the receiver starting time) + err_ch0_cycles = meas_ch0_phase_interp - true_ch0_phase_interp - meas_ch0_phase_interp(0) + true_ch0_phase_interp(0); + + arma::vec err2_ch0 = arma::square(err_ch0_cycles); + double rmse_ch0 = sqrt(arma::mean(err2_ch0)); + + //3. Mean err and variance + double error_mean_ch0 = arma::mean(err_ch0_cycles); + double error_var_ch0 = arma::var(err_ch0_cycles); + + // 4. Peaks + double max_error_ch0 = arma::max(err_ch0_cycles); + double min_error_ch0 = arma::min(err_ch0_cycles); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << " Accumulated Carrier phase RMSE = " + << rmse_ch0 << ", mean = " << error_mean_ch0 + << ", stdev = " << sqrt(error_var_ch0) + << " (max,min) = " << max_error_ch0 + << "," << min_error_ch0 + << " [cycles]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Accumulated Carrier phase error [cycles]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Phase error [cycles]"); + //conversion between arma::vec and std:vector + std::vector error_vec(err_ch0_cycles.colptr(0), err_ch0_cycles.colptr(0) + err_ch0_cycles.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, error_vec, + "Carrier Phase error"); + g3.set_legend(); + g3.savetops(data_title + "Carrier_phase_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse_ch0, 0.25); + ASSERT_LT(error_mean_ch0, 0.2); + ASSERT_GT(error_mean_ch0, -0.2); + ASSERT_LT(error_var_ch0, 0.5); + ASSERT_LT(max_error_ch0, 0.5); + ASSERT_GT(min_error_ch0, -0.5); +} + + +void HybridObservablesTestFpga::check_results_carrier_phase_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_carrier_phase_interp; + arma::vec true_ch1_carrier_phase_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(3), t, true_ch0_carrier_phase_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(3), t, true_ch1_carrier_phase_interp); + + arma::vec meas_ch0_carrier_phase_interp; + arma::vec meas_ch1_carrier_phase_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(3), t, meas_ch0_carrier_phase_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(3), t, meas_ch1_carrier_phase_interp); + + // generate double difference accumulated carrier phases + //compute error without the accumulated carrier phase offsets (which depends on the receiver starting time) + arma::vec delta_true_carrier_phase_cycles = (true_ch0_carrier_phase_interp - true_ch0_carrier_phase_interp(0)) - (true_ch1_carrier_phase_interp - true_ch1_carrier_phase_interp(0)); + arma::vec delta_measured_carrier_phase_cycles = (meas_ch0_carrier_phase_interp - meas_ch0_carrier_phase_interp(0)) - (meas_ch1_carrier_phase_interp - meas_ch1_carrier_phase_interp(0)); + + //2. RMSE + arma::vec err; + + err = delta_measured_carrier_phase_cycles - delta_true_carrier_phase_cycles; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Carrier Phase RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [Cycles]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Carrier Phase error [Cycles]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Carrier Phase error [Cycles]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Carrier Phase error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_carrier_phase_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse, 0.25); + ASSERT_LT(error_mean, 0.2); + ASSERT_GT(error_mean, -0.2); + ASSERT_LT(error_var, 0.5); + ASSERT_LT(max_error, 0.5); + ASSERT_GT(min_error, -0.5); +} + + +void HybridObservablesTestFpga::check_results_carrier_doppler_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_carrier_doppler_interp; + arma::vec true_ch1_carrier_doppler_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(2), t, true_ch0_carrier_doppler_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(2), t, true_ch1_carrier_doppler_interp); + + arma::vec meas_ch0_carrier_doppler_interp; + arma::vec meas_ch1_carrier_doppler_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(2), t, meas_ch0_carrier_doppler_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(2), t, meas_ch1_carrier_doppler_interp); + + // generate double difference carrier Doppler + arma::vec delta_true_carrier_doppler_cycles = true_ch0_carrier_doppler_interp - true_ch1_carrier_doppler_interp; + arma::vec delta_measured_carrier_doppler_cycles = meas_ch0_carrier_doppler_interp - meas_ch1_carrier_doppler_interp; + + //2. RMSE + arma::vec err; + + err = delta_measured_carrier_doppler_cycles - delta_true_carrier_doppler_cycles; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Carrier Doppler RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [Hz]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Carrier Doppler error [Hz]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Carrier Doppler error [Hz]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Carrier Doppler error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_carrier_doppler_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(error_mean, 5); + ASSERT_GT(error_mean, -5); + //assuming PLL BW=35 + ASSERT_LT(error_var, 200); + ASSERT_LT(max_error, 70); + ASSERT_GT(min_error, -70); + ASSERT_LT(rmse, 30); +} + + +void HybridObservablesTestFpga::check_results_carrier_doppler( + arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = measured_ch0(0, 0); + int size1 = measured_ch0.col(0).n_rows; + double t1 = measured_ch0(size1 - 1, 0); + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + arma::vec true_ch0_doppler_interp; + arma::interp1(true_tow_s, true_ch0.col(2), t, true_ch0_doppler_interp); + + arma::vec meas_ch0_doppler_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(2), t, meas_ch0_doppler_interp); + + //2. RMSE + arma::vec err_ch0_hz; + + //compute error + err_ch0_hz = meas_ch0_doppler_interp - true_ch0_doppler_interp; + + arma::vec err2_ch0 = arma::square(err_ch0_hz); + double rmse_ch0 = sqrt(arma::mean(err2_ch0)); + + //3. Mean err and variance + double error_mean_ch0 = arma::mean(err_ch0_hz); + double error_var_ch0 = arma::var(err_ch0_hz); + + // 4. Peaks + double max_error_ch0 = arma::max(err_ch0_hz); + double min_error_ch0 = arma::min(err_ch0_hz); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Carrier Doppler RMSE = " + << rmse_ch0 << ", mean = " << error_mean_ch0 + << ", stdev = " << sqrt(error_var_ch0) + << " (max,min) = " << max_error_ch0 + << "," << min_error_ch0 + << " [Hz]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Carrier Doppler error [Hz]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Doppler error [Hz]"); + //conversion between arma::vec and std:vector + std::vector error_vec(err_ch0_hz.colptr(0), err_ch0_hz.colptr(0) + err_ch0_hz.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, error_vec, + "Carrier Doppler error"); + g3.set_legend(); + g3.savetops(data_title + "Carrier_doppler_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(error_mean_ch0, 5); + ASSERT_GT(error_mean_ch0, -5); + //assuming PLL BW=35 + ASSERT_LT(error_var_ch0, 200); + ASSERT_LT(max_error_ch0, 70); + ASSERT_GT(min_error_ch0, -70); + ASSERT_LT(rmse_ch0, 30); +} + +bool HybridObservablesTestFpga::save_mat_xy(std::vector& x, std::vector& y, std::string filename) +{ + try + { + // WRITE MAT FILE + mat_t* matfp; + matvar_t* matvar; + filename.append(".mat"); + std::cout << "save_mat_xy write " << filename << std::endl; + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT5); + if (reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, x.size()}; + matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &y[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + else + { + std::cout << "save_mat_xy: error creating file" << std::endl; + } + Mat_Close(matfp); + return true; + } + catch (const std::exception& ex) + { + std::cout << "save_mat_xy: " << ex.what() << std::endl; + return false; + } +} + +void HybridObservablesTestFpga::check_results_code_pseudorange( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_dist_interp; + arma::vec true_ch1_dist_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(1), t, true_ch0_dist_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(1), t, true_ch1_dist_interp); + + arma::vec meas_ch0_dist_interp; + arma::vec meas_ch1_dist_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(4), t, meas_ch0_dist_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(4), t, meas_ch1_dist_interp); + + // generate delta pseudoranges + arma::vec delta_true_dist_m = true_ch0_dist_interp - true_ch1_dist_interp; + arma::vec delta_measured_dist_m = meas_ch0_dist_interp - meas_ch1_dist_interp; + + //2. RMSE + arma::vec err; + + err = delta_measured_dist_m - delta_true_dist_m; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Pseudorange RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [meters]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Pseudorange error [m]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Pseudorange error [m]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Pseudorrange error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_pseudorrange_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse, 3.0); + ASSERT_LT(error_mean, 1.0); + ASSERT_GT(error_mean, -1.0); + ASSERT_LT(error_var, 10.0); + ASSERT_LT(max_error, 10.0); + ASSERT_GT(min_error, -10.0); +} + +bool HybridObservablesTestFpga::ReadRinexObs(std::vector* obs_vec, Gnss_Synchro gnss) +{ + // Open and read reference RINEX observables file + try + { + gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs); + r_ref.exceptions(std::ios::failbit); + gpstk::Rinex3ObsData r_ref_data; + gpstk::Rinex3ObsHeader r_ref_header; + + gpstk::RinexDatum dataobj; + + r_ref >> r_ref_header; + + std::vector first_row; + gpstk::SatID prn; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + first_row.push_back(true); + obs_vec->push_back(arma::zeros(1, 4)); + } + while (r_ref >> r_ref_data) + { + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + int myprn = gnss_synchro_vec.at(n).PRN; + + switch (gnss.System) + { + case 'G': + prn = gpstk::SatID(myprn, gpstk::SatID::systemGPS); + break; + case 'E': + prn = gpstk::SatID(myprn, gpstk::SatID::systemGalileo); + break; + default: + prn = gpstk::SatID(myprn, gpstk::SatID::systemGPS); + } + + gpstk::CommonTime time = r_ref_data.time; + double sow(static_cast(time).sow); + + gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn); + if (pointer == r_ref_data.obs.end()) + { + // PRN not present; do nothing + } + else + { + if (first_row.at(n) == false) + { + //insert next column + obs_vec->at(n).insert_rows(obs_vec->at(n).n_rows, 1); + } + else + { + first_row.at(n) = false; + } + if (strcmp("1C\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; //C1C P1 (psudorange L1) + dataobj = r_ref_data.getObs(prn, "D1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; //D1C Carrier Doppler + dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; //L1C Carrier Phase + } + else if (strcmp("1B\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("2S\0", gnss.Signal) == 0) //L2M + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("L5\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("5X\0", gnss.Signal) == 0) //Simulator gives RINEX with E5a+E5b + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else + { + std::cout << "ReadRinexObs unknown signal requested: " << gnss.Signal << std::endl; + return false; + } + } + } + } // end while + } // End of 'try' block + catch (const gpstk::FFStreamError& e) + { + std::cout << e; + return false; + } + catch (const gpstk::Exception& e) + { + std::cout << e; + return false; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what(); + std::cout << "unknown error. I don't feel so well..." << std::endl; + return false; + } + std::cout << "ReadRinexObs info:" << std::endl; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + std::cout << "SAT PRN " << gnss_synchro_vec.at(n).PRN << " RINEX epoch readed: " << obs_vec->at(n).n_rows << std::endl; + } + return true; +} +TEST_F(HybridObservablesTestFpga, ValidationOfResults) +{ + // pointer to the DMA thread that sends the samples to the acquisition engine + pthread_t thread_DMA; + + struct DMA_handler_args_obs_test args; + + // Configure the signal generator + configure_generator(); + + // Generate signal raw signal samples and observations RINEX file + if (FLAGS_disable_generator == false) + { + generate_signal(); + } + + + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds(0); + + // use generator or use an external capture file + if (FLAGS_enable_external_signal_file) + { + //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters + ASSERT_EQ(acquire_signal(), true); + } + else + { + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.System = 'G'; + std::string signal = "1C"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + + std::istringstream ss(FLAGS_test_satellite_PRN_list); + std::string token; + + while (std::getline(ss, token, ',')) + { + tmp_gnss_synchro.PRN = boost::lexical_cast(token); + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + } + + configure_receiver(FLAGS_PLL_bw_hz_start, + FLAGS_DLL_bw_hz_start, + FLAGS_PLL_narrow_bw_hz, + FLAGS_DLL_narrow_bw_hz, + FLAGS_extend_correlation_symbols); + + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + //setup the signal synchronization, simulating an acquisition + if (!FLAGS_enable_external_signal_file) + { + //based on true observables metadata (for custom sdr generator) + //open true observables log file written by the simulator or based on provided RINEX obs + //std::vector> true_reader_vec; + std::vector> true_reader_vec; + //read true data from the generator logs + true_reader_vec.push_back(std::make_shared()); + std::cout << "Loading true observable data for PRN " << gnss_synchro_vec.at(n).PRN << std::endl; + std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); + true_obs_file.append(std::to_string(gnss_synchro_vec.at(n).PRN)); + true_obs_file.append(".dat"); + ASSERT_NO_THROW({ + if (true_reader_vec.back()->open_obs_file(true_obs_file) == false) + { + throw std::exception(); + }; + }) << "Failure opening true observables file"; + + // load acquisition data based on the first epoch of the true observations + ASSERT_NO_THROW({ + if (true_reader_vec.back()->read_binary_obs() == false) + { + throw std::exception(); + }; + }) << "Failure reading true observables file"; + + //restart the epoch counter + true_reader_vec.back()->restart(); + + std::cout << "Initial Doppler [Hz]=" << true_reader_vec.back()->doppler_l1_hz << " Initial code delay [Chips]=" + << true_reader_vec.back()->prn_delay_chips << std::endl; + gnss_synchro_vec.at(n).Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_reader_vec.back()->prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; + gnss_synchro_vec.at(n).Acq_doppler_hz = true_reader_vec.back()->doppler_l1_hz; + gnss_synchro_vec.at(n).Acq_samplestamp_samples = 0; + } + else + { + //based on the signal acquisition process + std::cout << "Estimated Initial Doppler " << gnss_synchro_vec.at(n).Acq_doppler_hz + << " [Hz], estimated Initial code delay " << gnss_synchro_vec.at(n).Acq_delay_samples << " [Samples]" + << " Acquisition SampleStamp is " << gnss_synchro_vec.at(n).Acq_samplestamp_samples << std::endl; + } + } + + + // The HW has been reset after the acquisition phase when the acquisition class was destroyed. + // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the + // GPS L1 / Galileo E1 filter has been cleared. + // During this test all the samples coming from the DMA are consumed so in principle there would be + // no need to reset the HW. However we need to clear the sample counter in each test. Therefore we have + // to reset the HW at the beginning of each test. + + // instantiate the acquisition modules in order to use them to reset the HW. + // (note that the constructor of the acquisition modules resets the HW too) + + + std::shared_ptr acquisition; + + // reset the HW to clear the sample counters: the acquisition constructor generates a reset + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + + std::vector> tracking_ch_vec; + std::vector> tlm_ch_vec; + + std::vector null_sink_vec; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + //set channels ids + gnss_synchro_vec.at(n).Channel_ID = n; + + //create the tracking channels and create the telemetry decoders + + std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); + tracking_ch_vec.push_back(std::dynamic_pointer_cast(trk_)); + std::shared_ptr tlm_ = factory->GetBlock(config, "TelemetryDecoder", config->property("TelemetryDecoder.implementation", std::string("undefined")), 1, 1); + tlm_ch_vec.push_back(std::dynamic_pointer_cast(tlm_)); + + //create null sinks for observables output + null_sink_vec.push_back(gr::blocks::null_sink::make(sizeof(Gnss_Synchro))); + + ASSERT_NO_THROW({ + tlm_ch_vec.back()->set_channel(gnss_synchro_vec.at(n).Channel_ID); + + switch (gnss_synchro_master.System) + { + case 'G': + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_vec.at(n).PRN)); + break; + case 'E': + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("Galileo"), gnss_synchro_vec.at(n).PRN)); + break; + default: + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_vec.at(n).PRN)); + } + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + tracking_ch_vec.back()->set_channel(gnss_synchro_vec.at(n).Channel_ID); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + tracking_ch_vec.back()->set_gnss_synchro(&gnss_synchro_vec.at(n)); + }) << "Failure setting gnss_synchro."; + } + + top_block = gr::make_top_block("Telemetry_Decoder test"); + boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_Fpga_make(); + boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_Fpga_make(); + //Observables + std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); + + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + ASSERT_NO_THROW({ + tracking_ch_vec.at(n)->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + } + + std::string file; + + ASSERT_NO_THROW({ + if (!FLAGS_enable_external_signal_file) + { + file = "./" + filename_raw_data; + } + else + { + file = FLAGS_signal_file; + } + int observable_interval_ms = 20; + + double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); + + gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter; + ch_out_fpga_sample_counter = gnss_sdr_make_fpga_sample_counter(fs, observable_interval_ms); + + + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + //top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); + top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); + top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); + } + //connect sample counter and timmer to the last channel in observables block (extra channel) + //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse + }) << "Failure connecting the blocks."; + + + args.file = file; + args.nsamples_tx = baseband_sampling_freq * FLAGS_duration; + ; + + args.skip_used_samples = 0; + + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + + + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + tracking_ch_vec.at(n)->start_tracking(); + } + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex_obs_test); + + + top_block->start(); + + + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + //top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + }) << "Failure running the top_block."; + + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + + top_block->stop(); + + + // reset the HW AGAIN + acquisition->stop_acquisition(); + + + // pthread_mutex_lock(&mutex_obs_test); + // send_samples_start_obs_test = 0; + // pthread_mutex_unlock(&mutex_obs_test); + + + //check results + // Matrices for storing columnwise true GPS time, Range, Doppler and Carrier phase + std::vector true_obs_vec; + + if (!FLAGS_enable_external_signal_file) + { + //load the true values + True_Observables_Reader true_observables; + ASSERT_NO_THROW({ + if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) + { + throw std::exception(); + } + }) << "Failure opening true observables file"; + + unsigned int nepoch = static_cast(true_observables.num_epochs()); + + std::cout << "True observation epochs = " << nepoch << std::endl; + + true_observables.restart(); + int64_t epoch_counter = 0; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + true_obs_vec.push_back(arma::zeros(nepoch, 4)); + } + + ASSERT_NO_THROW({ + while (true_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < true_obs_vec.size(); n++) + { + if (round(true_observables.prn[n]) != gnss_synchro_vec.at(n).PRN) + { + std::cout << "True observables SV PRN does not match measured ones: " + << round(true_observables.prn[n]) << " vs. " << gnss_synchro_vec.at(n).PRN << std::endl; + throw std::exception(); + } + true_obs_vec.at(n)(epoch_counter, 0) = true_observables.gps_time_sec[n]; + true_obs_vec.at(n)(epoch_counter, 1) = true_observables.dist_m[n]; + true_obs_vec.at(n)(epoch_counter, 2) = true_observables.doppler_l1_hz[n]; + true_obs_vec.at(n)(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[n]; + } + epoch_counter++; + } + }); + } + else + { + ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) + << "Failure reading RINEX file"; + } + + + //read measured values + Observables_Dump_Reader estimated_observables(tracking_ch_vec.size()); + ASSERT_NO_THROW({ + if (estimated_observables.open_obs_file(std::string("./observables.dat")) == false) + { + throw std::exception(); + } + }) << "Failure opening dump observables file"; + + unsigned int nepoch = static_cast(estimated_observables.num_epochs()); + std::cout << "Measured observations epochs = " << nepoch << std::endl; + + // Matrices for storing columnwise measured RX_time, TOW, Doppler, Carrier phase and Pseudorange + std::vector measured_obs_vec; + std::vector epoch_counters_vec; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + measured_obs_vec.push_back(arma::zeros(nepoch, 5)); + epoch_counters_vec.push_back(0); + } + + estimated_observables.restart(); + while (estimated_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (static_cast(estimated_observables.valid[n])) + { + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 3) = estimated_observables.Acc_carrier_phase_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 4) = estimated_observables.Pseudorange_m[n]; + epoch_counters_vec.at(n)++; + } + } + } + + + //Cut measurement tail zeros + arma::uvec index; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) > 0.0, 1, "last"); + if ((index.size() > 0) and index(0) < (nepoch - 1)) + { + measured_obs_vec.at(n).shed_rows(index(0) + 1, nepoch - 1); + } + } + + //Cut measurement initial transitory of the measurements + + double initial_transitory_s = FLAGS_skip_obs_transitory_s; + + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) >= (measured_obs_vec.at(n)(0, 0) + initial_transitory_s), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + + index = arma::find(measured_obs_vec.at(n).col(0) >= true_obs_vec.at(n)(0, 0), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + } + + + //Correct the clock error using true values (it is not possible for a receiver to correct + //the receiver clock offset error at the observables level because it is required the + //decoding of the ephemeris data and solve the PVT equations) + + //Find the reference satellite (the nearest) and compute the receiver time offset at observable level + double min_pr = std::numeric_limits::max(); + unsigned int min_pr_ch_id = 0; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + { + if (measured_obs_vec.at(n)(0, 4) < min_pr) + { + min_pr = measured_obs_vec.at(n)(0, 4); + min_pr_ch_id = n; + } + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } + + arma::vec receiver_time_offset_ref_channel_s; + //receiver_time_offset_ref_channel_s = true_obs_vec.at(min_pr_ch_id).col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; + receiver_time_offset_ref_channel_s = (true_obs_vec.at(min_pr_ch_id).col(1)(0) - measured_obs_vec.at(min_pr_ch_id).col(4)(0)) / GPS_C_M_S; + std::cout << "Ref channel initial Receiver time offset " << receiver_time_offset_ref_channel_s(0) * 1e3 << " [ms]" << std::endl; + + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + //debug save to .mat + std::vector tmp_vector_x(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y(true_obs_vec.at(n).col(1).colptr(0), + true_obs_vec.at(n).col(1).colptr(0) + true_obs_vec.at(n).col(1).n_rows); + save_mat_xy(tmp_vector_x, tmp_vector_y, std::string("true_pr_ch_" + std::to_string(n))); + + std::vector tmp_vector_x2(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y2(measured_obs_vec.at(n).col(4).colptr(0), + measured_obs_vec.at(n).col(4).colptr(0) + measured_obs_vec.at(n).col(4).n_rows); + save_mat_xy(tmp_vector_x2, tmp_vector_y2, std::string("measured_pr_ch_" + std::to_string(n))); + + std::vector tmp_vector_x3(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y3(true_obs_vec.at(n).col(2).colptr(0), + true_obs_vec.at(n).col(2).colptr(0) + true_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x3, tmp_vector_y3, std::string("true_doppler_ch_" + std::to_string(n))); + + std::vector tmp_vector_x4(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y4(measured_obs_vec.at(n).col(2).colptr(0), + measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); + + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); + arma::vec true_TOW_ch_s = true_obs_vec.at(n).col(0) - receiver_time_offset_ref_channel_s(0); + //Compare measured observables + if (min_pr_ch_id != n) + { + check_results_code_pseudorange(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_phase_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + + check_results_carrier_doppler_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + else + { + std::cout << "[CH " << std::to_string(n) << "] PRN " << std::to_string(gnss_synchro_vec.at(n).PRN) << " is the reference satellite" << std::endl; + } + if (FLAGS_compute_single_diffs) + { + check_results_carrier_phase(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_doppler(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } + + + std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; +} diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index 445f6a91a..89cbfad09 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -29,31 +29,153 @@ */ +#include "nmea_printer.h" #include #include #include -#include "nmea_printer.h" -TEST(NmeaPrinterTest, PrintLine) +class NmeaPrinterTest : public ::testing::Test +{ +protected: + NmeaPrinterTest() + { + this->conf(); + } + ~NmeaPrinterTest() = default; + void conf(); + rtk_t rtk; +}; + +void NmeaPrinterTest::conf() +{ + snrmask_t snrmask = {{}, {{}, {}}}; + int positioning_mode = 0; // Single + int number_of_frequencies = 1; + double elevation_mask = 5; + int navigation_system = 1; // GPS + int integer_ambiguity_resolution_gps = 0; + int integer_ambiguity_resolution_glo = 0; + int integer_ambiguity_resolution_bds = 0; + int outage_reset_ambiguity = 5; + int min_lock_to_fix_ambiguity = 0; + int iono_model = 0; + int trop_model = 0; + int dynamics_model = 0; + int earth_tide = 0; + int number_filter_iter = 1; + double code_phase_error_ratio_l1 = 100.0; + double code_phase_error_ratio_l2 = 100.0; + double code_phase_error_ratio_l5 = 100.0; + double carrier_phase_error_factor_a = 0.003; + double carrier_phase_error_factor_b = 0.003; + double bias_0 = 30.0; + double iono_0 = 0.03; + double trop_0 = 0.3; + double sigma_bias = 1e-4; + double sigma_iono = 1e-3; + double sigma_trop = 1e-4; + double sigma_acch = 1e-1; + double sigma_accv = 1e-2; + double sigma_pos = 0.0; + double min_ratio_to_fix_ambiguity = 3.0; + double min_elevation_to_fix_ambiguity = 0.0; + double slip_threshold = 0.05; + double threshold_reject_innovation = 30.0; + double threshold_reject_gdop = 30.0; + int sat_PCV = 0; + int rec_PCV = 0; + int phwindup = 0; + int reject_GPS_IIA = 0; + int raim_fde = 0; + + prcopt_t rtklib_configuration_options = { + positioning_mode, /* positioning mode (PMODE_XXX) see src/algorithms/libs/rtklib/rtklib.h */ + 0, /* solution type (0:forward,1:backward,2:combined) */ + number_of_frequencies, /* number of frequencies (1:L1, 2:L1+L2, 3:L1+L2+L5)*/ + navigation_system, /* navigation system */ + elevation_mask * D2R, /* elevation mask angle (degrees) */ + snrmask, /* snrmask_t snrmask SNR mask */ + 0, /* satellite ephemeris/clock (EPHOPT_XXX) */ + integer_ambiguity_resolution_gps, /* AR mode (0:off,1:continuous,2:instantaneous,3:fix and hold,4:ppp-ar) */ + integer_ambiguity_resolution_glo, /* GLONASS AR mode (0:off,1:on,2:auto cal,3:ext cal) */ + integer_ambiguity_resolution_bds, /* BeiDou AR mode (0:off,1:on) */ + outage_reset_ambiguity, /* obs outage count to reset bias */ + min_lock_to_fix_ambiguity, /* min lock count to fix ambiguity */ + 10, /* min fix count to hold ambiguity */ + 1, /* max iteration to resolve ambiguity */ + iono_model, /* ionosphere option (IONOOPT_XXX) */ + trop_model, /* troposphere option (TROPOPT_XXX) */ + dynamics_model, /* dynamics model (0:none, 1:velocity, 2:accel) */ + earth_tide, /* earth tide correction (0:off,1:solid,2:solid+otl+pole) */ + number_filter_iter, /* number of filter iteration */ + 0, /* code smoothing window size (0:none) */ + 0, /* interpolate reference obs (for post mission) */ + 0, /* sbssat_t sbssat SBAS correction options */ + 0, /* sbsion_t sbsion[MAXBAND+1] SBAS satellite selection (0:all) */ + 0, /* rover position for fixed mode */ + 0, /* base position for relative mode */ + /* 0:pos in prcopt, 1:average of single pos, */ + /* 2:read from file, 3:rinex header, 4:rtcm pos */ + {code_phase_error_ratio_l1, code_phase_error_ratio_l2, code_phase_error_ratio_l5}, /* eratio[NFREQ] code/phase error ratio */ + {100.0, carrier_phase_error_factor_a, carrier_phase_error_factor_b, 0.0, 1.0}, /* err[5]: measurement error factor [0]:reserved, [1-3]:error factor a/b/c of phase (m) , [4]:doppler frequency (hz) */ + {bias_0, iono_0, trop_0}, /* std[3]: initial-state std [0]bias,[1]iono [2]trop*/ + {sigma_bias, sigma_iono, sigma_trop, sigma_acch, sigma_accv, sigma_pos}, /* prn[6] process-noise std */ + 5e-12, /* sclkstab: satellite clock stability (sec/sec) */ + {min_ratio_to_fix_ambiguity, 0.9999, 0.25, 0.1, 0.05, 0.0, 0.0, 0.0}, /* thresar[8]: AR validation threshold */ + min_elevation_to_fix_ambiguity, /* elevation mask of AR for rising satellite (deg) */ + 0.0, /* elevation mask to hold ambiguity (deg) */ + slip_threshold, /* slip threshold of geometry-free phase (m) */ + 30.0, /* max difference of time (sec) */ + threshold_reject_innovation, /* reject threshold of innovation (m) */ + threshold_reject_gdop, /* reject threshold of gdop */ + {}, /* double baseline[2] baseline length constraint {const,sigma} (m) */ + {}, /* double ru[3] rover position for fixed mode {x,y,z} (ecef) (m) */ + {}, /* double rb[3] base position for relative mode {x,y,z} (ecef) (m) */ + {"", ""}, /* char anttype[2][MAXANT] antenna types {rover,base} */ + {{}, {}}, /* double antdel[2][3] antenna delta {{rov_e,rov_n,rov_u},{ref_e,ref_n,ref_u}} */ + {}, /* pcv_t pcvr[2] receiver antenna parameters {rov,base} */ + {}, /* unsigned char exsats[MAXSAT] excluded satellites (1:excluded, 2:included) */ + 0, /* max averaging epoches */ + 0, /* initialize by restart */ + 1, /* output single by dgps/float/fix/ppp outage */ + {"", ""}, /* char rnxopt[2][256] rinex options {rover,base} */ + {sat_PCV, rec_PCV, phwindup, reject_GPS_IIA, raim_fde}, /* posopt[6] positioning options [0]: satellite and receiver antenna PCV model; [1]: interpolate antenna parameters; [2]: apply phase wind-up correction for PPP modes; [3]: exclude measurements of GPS Block IIA satellites satellite [4]: RAIM FDE (fault detection and exclusion) [5]: handle day-boundary clock jump */ + 0, /* solution sync mode (0:off,1:on) */ + {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ + {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ + 0, /* disable L2-AR */ + {} /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + }; + + rtkinit(&rtk, &rtklib_configuration_options); +} + + +TEST_F(NmeaPrinterTest, PrintLine) { std::string filename("nmea_test.nmea"); - rtk_t rtk; - prcopt_t rtklib_configuration_options; - rtkinit(&rtk, &rtklib_configuration_options); - std::shared_ptr pvt_solution = std::make_shared(12, "filename", false, rtk); + std::shared_ptr pvt_solution = std::make_shared(12, "filename", false, false, rtk); boost::posix_time::ptime pt(boost::gregorian::date(1994, boost::date_time::Nov, 19), - boost::posix_time::hours(22) + boost::posix_time::minutes(54) + boost::posix_time::seconds(46)); // example from http://aprs.gids.nl/nmea/#rmc - pvt_solution->set_position_UTC_time(pt); + boost::posix_time::hours(22) + boost::posix_time::minutes(54) + boost::posix_time::seconds(46)); + std::time_t tim = (pt - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds(); + gtime_t gtime; + gtime.time = tim; + gtime.sec = 0.0; - arma::vec pos = {49.27416667, -123.18533333, 0}; - pvt_solution->set_rx_pos(pos); - - pvt_solution->set_valid_position(true); + pvt_solution->pvt_sol.rr[0] = -2282104.0; //49.27416667; + pvt_solution->pvt_sol.rr[1] = -3489369.0; //-123.18533333; + pvt_solution->pvt_sol.rr[2] = 4810507.0; // 0 + pvt_solution->pvt_sol.rr[3] = 0.0; + pvt_solution->pvt_sol.rr[4] = 0.0; + pvt_solution->pvt_sol.rr[5] = 0.0; + pvt_solution->pvt_sol.stat = 1; // SOLQ_FIX + pvt_solution->pvt_sol.time = gtime; + bool flag_nmea_output_file = true; ASSERT_NO_THROW({ - std::shared_ptr nmea_printer = std::make_shared(filename, false, ""); + std::shared_ptr nmea_printer = std::make_shared(filename, flag_nmea_output_file, false, ""); nmea_printer->Print_Nmea_Line(pvt_solution, false); }) << "Failure printing NMEA messages."; @@ -67,48 +189,7 @@ TEST(NmeaPrinterTest, PrintLine) std::size_t found = line.find(GPRMC); if (found != std::string::npos) { - EXPECT_EQ(line, "$GPRMC,225446.000,A,4916.4500,N,12311.1199,W,0.00,0.00,191194,,*1c\r"); - } - } - test_file.close(); - } - EXPECT_EQ(0, remove(filename.c_str())) << "Failure deleting a temporary file."; -} - - -TEST(NmeaPrinterTest, PrintLineLessthan10min) -{ - std::string filename("nmea_test.nmea"); - rtk_t rtk; - prcopt_t rtklib_configuration_options; - rtkinit(&rtk, &rtklib_configuration_options); - std::shared_ptr pvt_solution = std::make_shared(12, "filename", false, rtk); - - boost::posix_time::ptime pt(boost::gregorian::date(1994, boost::date_time::Nov, 19), - boost::posix_time::hours(22) + boost::posix_time::minutes(54) + boost::posix_time::seconds(46)); // example from http://aprs.gids.nl/nmea/#rmc - pvt_solution->set_position_UTC_time(pt); - - arma::vec pos = {49.07416667, -123.02527778, 0}; - pvt_solution->set_rx_pos(pos); - - pvt_solution->set_valid_position(true); - - ASSERT_NO_THROW({ - std::shared_ptr nmea_printer = std::make_shared(filename, false, ""); - nmea_printer->Print_Nmea_Line(pvt_solution, false); - }) << "Failure printing NMEA messages."; - - std::ifstream test_file(filename); - std::string line; - std::string GPRMC("$GPRMC"); - if (test_file.is_open()) - { - while (getline(test_file, line)) - { - std::size_t found = line.find(GPRMC); - if (found != std::string::npos) - { - EXPECT_EQ(line, "$GPRMC,225446.000,A,4904.4500,N,12301.5166,W,0.00,0.00,191194,,*1a\r"); + EXPECT_EQ(line, "$GPRMC,225436.00,A,4916.4497617,N,12311.1202744,W,0.00,0.00,191194,0.0,E,D*21\r"); } } test_file.close(); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index 007ace647..2f5e819f0 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -28,8 +28,8 @@ * ------------------------------------------------------------------------- */ -#include #include "rinex_printer.h" +#include TEST(RinexPrinterTest, GalileoObsHeader) @@ -58,7 +58,10 @@ TEST(RinexPrinterTest, GalileoObsHeader) } std::string expected_str("E 4 C1B L1B D1B S1B SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } line_aux.clear(); std::shared_ptr rp2; @@ -82,7 +85,10 @@ TEST(RinexPrinterTest, GalileoObsHeader) std::string expected_str2("E 12 C1B L1B D1B S1B C5X L5X D5X S5X C7X L7X D7X S7X SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str2.compare(line_aux)); - if (remove(rp2->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp2->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -113,7 +119,10 @@ TEST(RinexPrinterTest, GlonassObsHeader) } std::string expected_str("R 4 C1C L1C D1C S1C SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } line_aux.clear(); } @@ -158,7 +167,10 @@ TEST(RinexPrinterTest, MixedObsHeader) std::string expected_str2("E 8 C1B L1B D1B S1B C5X L5X D5X S5X SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); EXPECT_EQ(0, expected_str2.compare(line_aux2)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -202,7 +214,10 @@ TEST(RinexPrinterTest, MixedObsHeaderGpsGlo) std::string expected_str2("R 4 C1C L1C D1C S1C SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); EXPECT_EQ(0, expected_str2.compare(line_aux2)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -270,7 +285,10 @@ TEST(RinexPrinterTest, GalileoObsLog) std::string expected_str("E22 22000000.000 7 3.724 7 1534.000 7 42.000 "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -338,7 +356,10 @@ TEST(RinexPrinterTest, GlonassObsLog) std::string expected_str("R22 22000000.000 7 3.724 7 1534.000 7 42.000 "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -419,7 +440,10 @@ TEST(RinexPrinterTest, GpsObsLogDualBand) std::string expected_str("G08 22000002.100 6 7.226 6 321.000 6 39.000 22000000.000 7 3.724 7 1534.000 7 42.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -500,7 +524,10 @@ TEST(RinexPrinterTest, GalileoObsLogDualBand) std::string expected_str("E08 22000002.100 6 7.226 6 321.000 6 39.000 22000000.000 7 3.724 7 1534.000 7 42.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -610,7 +637,10 @@ TEST(RinexPrinterTest, MixedObsLog) std::string expected_str("E16 22000000.000 7 0.127 7 -20.000 7 42.000 22000000.000 6 8.292 6 1534.000 6 41.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -719,5 +749,8 @@ TEST(RinexPrinterTest, MixedObsLogGpsGlo) std::string expected_str("R16 22000000.000 6 8.292 6 1534.000 6 41.000 22000000.000 7 0.127 7 -20.000 7 42.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc index 24544f380..a1e52190d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc @@ -29,8 +29,8 @@ */ -#include #include "rtcm_printer.h" +#include TEST(RtcmPrinterTest, Instantiate) @@ -39,9 +39,10 @@ TEST(RtcmPrinterTest, Instantiate) bool flag_rtcm_tty_port = false; std::string rtcm_dump_devname = "/dev/pts/4"; bool flag_rtcm_server = false; + bool rtcm_file_output_enabled = false; unsigned short rtcm_tcp_port = 2101; unsigned short rtcm_station_id = 1234; - std::unique_ptr RTCM_printer(new Rtcm_Printer(filename, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_dump_devname)); + std::unique_ptr RTCM_printer(new Rtcm_Printer(filename, rtcm_file_output_enabled, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_dump_devname)); } @@ -49,12 +50,13 @@ TEST(RtcmPrinterTest, Run) { std::string filename = "test.rtcm"; bool flag_rtcm_tty_port = false; + bool rtcm_file_output_enabled = false; std::string rtcm_dump_devname = "/dev/pts/4"; bool flag_rtcm_server = false; unsigned short rtcm_tcp_port = 2101; unsigned short rtcm_station_id = 1234; - std::unique_ptr RTCM_printer(new Rtcm_Printer(filename, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_dump_devname)); + std::unique_ptr RTCM_printer(new Rtcm_Printer(filename, rtcm_file_output_enabled, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_dump_devname)); std::string reference_msg = "D300133ED7D30202980EDEEF34B4BD62AC0941986F33360B98"; @@ -63,7 +65,7 @@ TEST(RtcmPrinterTest, Run) unsigned char c[1]; for (unsigned int i = 0; i < reference_msg.length(); i = i + 2) { - unsigned long int n, n2; + uint64_t n, n2; std::istringstream(reference_msg.substr(i, 1)) >> std::hex >> n; std::istringstream(reference_msg.substr(i + 1, 1)) >> std::hex >> n2; c[0] = static_cast(n * 16) + static_cast(n2); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc index 6ec85e562..53028074b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc @@ -29,10 +29,10 @@ * ------------------------------------------------------------------------- */ +#include "Galileo_E1.h" +#include "rtcm.h" #include #include -#include "rtcm.h" -#include "Galileo_E1.h" TEST(RtcmTest, HexToBin) { @@ -103,8 +103,8 @@ TEST(RtcmTest, HexToInt) auto rtcm = std::make_shared(); std::string test1 = "2A"; - long int test1_int = rtcm->hex_to_int(test1); - long int expected1 = 42; + int64_t test1_int = rtcm->hex_to_int(test1); + int64_t expected1 = 42; EXPECT_EQ(expected1, test1_int); } @@ -112,7 +112,7 @@ TEST(RtcmTest, HexToInt) TEST(RtcmTest, HexToUint) { auto rtcm = std::make_shared(); - long unsigned int expected1 = 42; + uint64_t expected1 = 42; EXPECT_EQ(expected1, rtcm->hex_to_uint(rtcm->bin_to_hex("00101010"))); } @@ -122,8 +122,8 @@ TEST(RtcmTest, BinToDouble) auto rtcm = std::make_shared(); std::bitset<4> test1(5); - long int test1_int = static_cast(rtcm->bin_to_double(test1.to_string())); - long int expected1 = 5; + int64_t test1_int = static_cast(rtcm->bin_to_double(test1.to_string())); + int64_t expected1 = 5; EXPECT_EQ(expected1, test1_int); std::bitset<4> test2(-5); @@ -137,9 +137,9 @@ TEST(RtcmTest, BinToDouble) TEST(RtcmTest, BinToUint) { auto rtcm = std::make_shared(); - long unsigned int expected1 = 42; + uint32_t expected1 = 42; EXPECT_EQ(expected1, rtcm->bin_to_uint("00101010")); - long unsigned int expected2 = 214; + uint32_t expected2 = 214; EXPECT_EQ(expected2, rtcm->bin_to_uint("11010110")); } @@ -147,9 +147,9 @@ TEST(RtcmTest, BinToUint) TEST(RtcmTest, BinToInt) { auto rtcm = std::make_shared(); - long int expected1 = 42; + int32_t expected1 = 42; EXPECT_EQ(expected1, rtcm->bin_to_int("00101010")); - long int expected2 = -42; + int32_t expected2 = -42; EXPECT_EQ(expected2, rtcm->bin_to_int("11010110")); } @@ -295,7 +295,7 @@ TEST(RtcmTest, MT1020) // Bit distribution per fields dependent on other factors gnav_ephemeris.d_t_b = 8100; // Binary flag representation - gnav_ephemeris.d_P_3 = 1; + gnav_ephemeris.d_P_3 = true; std::string tx_msg = rtcm->print_MT1020(gnav_ephemeris, gnav_utc_model); @@ -336,14 +336,14 @@ TEST(RtcmTest, MT1045) Galileo_Ephemeris gal_eph_read = Galileo_Ephemeris(); gal_eph.i_satellite_PRN = 5; - gal_eph.OMEGA_dot_3 = 53.0 * OMEGA_dot_3_LSB; + gal_eph.OMEGA_dot_3 = 53.0 * OMEGA_DOT_3_LSB; gal_eph.E5a_DVS = true; std::string tx_msg = rtcm->print_MT1045(gal_eph); EXPECT_EQ(0, rtcm->read_MT1045(tx_msg, gal_eph_read)); EXPECT_EQ(expected_true, gal_eph_read.E5a_DVS); - EXPECT_DOUBLE_EQ(53.0 * OMEGA_dot_3_LSB, gal_eph_read.OMEGA_dot_3); + EXPECT_DOUBLE_EQ(53.0 * OMEGA_DOT_3_LSB, gal_eph_read.OMEGA_dot_3); EXPECT_EQ(static_cast(5), gal_eph_read.i_satellite_PRN); EXPECT_EQ(1, rtcm->read_MT1045(rtcm->bin_to_binary_data(rtcm->hex_to_bin("FFFFFFFFFFF")), gal_eph_read)); } @@ -570,7 +570,7 @@ TEST(RtcmTest, MSM1) EXPECT_EQ(ref_id, rtcm->bin_to_uint(MSM1_bin.substr(size_header + size_msg_length + 12, 12))); EXPECT_EQ(0, MSM1_bin.substr(size_header + size_msg_length + 169, Nsat * Nsig).compare("101101")); // check cell mask - double meters_to_miliseconds = GPS_C_m_s * 0.001; + double meters_to_miliseconds = GPS_C_M_S * 0.001; unsigned int rough_range_1 = static_cast(std::floor(std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10)) + 0.5) & 0x3FFu; unsigned int rough_range_2 = static_cast(std::floor(std::round(gnss_synchro2.Pseudorange_m / meters_to_miliseconds / TWO_N10)) + 0.5) & 0x3FFu; unsigned int rough_range_4 = static_cast(std::floor(std::round(gnss_synchro3.Pseudorange_m / meters_to_miliseconds / TWO_N10)) + 0.5) & 0x3FFu; @@ -620,7 +620,7 @@ TEST(RtcmTest, InstantiateServer) std::string test6 = "0011"; std::string test6_hex = rtcm->bin_to_hex(test6); EXPECT_EQ(0, test6_hex.compare("3")); - long unsigned int expected1 = 42; + uint64_t expected1 = 42; EXPECT_EQ(expected1, rtcm->bin_to_uint("00101010")); rtcm->run_server(); std::string test4_bin = rtcm->hex_to_bin(test3); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc new file mode 100644 index 000000000..ce191b01a --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc @@ -0,0 +1,525 @@ +/*! + * \file rtklib_solver_test.cc + * \brief Implements Unit Test for the rtklib PVT solver class. + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "geofunctions.h" +#include "gnss_sdr_supl_client.h" +#include "in_memory_configuration.h" +#include "rtklib_solver.h" +#include +#include +#include +#include +#include +#include +#include +#include + + +rtk_t configure_rtklib_options() +{ + std::shared_ptr configuration; + configuration = std::make_shared(); + std::string role = "rtklib_solver"; + // custom options + configuration->set_property("rtklib_solver.positioning_mode", "Single"); + configuration->set_property("rtklib_solver.elevation_mask", "0"); + configuration->set_property("rtklib_solver.iono_model", "OFF"); + configuration->set_property("rtklib_solver.trop_model", "OFF"); + //RTKLIB PVT solver options + + // Settings 1 + int positioning_mode = -1; + std::string default_pos_mode("Single"); + std::string positioning_mode_str = configuration->property(role + ".positioning_mode", default_pos_mode); /* (PMODE_XXX) see src/algorithms/libs/rtklib/rtklib.h */ + if (positioning_mode_str == "Single") + { + positioning_mode = PMODE_SINGLE; + } + if (positioning_mode_str == "Static") + { + positioning_mode = PMODE_STATIC; + } + if (positioning_mode_str == "Kinematic") + { + positioning_mode = PMODE_KINEMA; + } + if (positioning_mode_str == "PPP_Static") + { + positioning_mode = PMODE_PPP_STATIC; + } + if (positioning_mode_str == "PPP_Kinematic") + { + positioning_mode = PMODE_PPP_KINEMA; + } + + if (positioning_mode == -1) + { + //warn user and set the default + std::cout << "WARNING: Bad specification of positioning mode." << std::endl; + std::cout << "positioning_mode possible values: Single / Static / Kinematic / PPP_Static / PPP_Kinematic" << std::endl; + std::cout << "positioning_mode specified value: " << positioning_mode_str << std::endl; + std::cout << "Setting positioning_mode to Single" << std::endl; + positioning_mode = PMODE_SINGLE; + } + + int num_bands = 1; + + // if ((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) num_bands = 1; + // if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0))) num_bands = 2; + // if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 2; + // if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 3; + + int number_of_frequencies = configuration->property(role + ".num_bands", num_bands); /* (1:L1, 2:L1+L2, 3:L1+L2+L5) */ + if ((number_of_frequencies < 1) || (number_of_frequencies > 3)) + { + //warn user and set the default + number_of_frequencies = num_bands; + } + + double elevation_mask = configuration->property(role + ".elevation_mask", 15.0); + if ((elevation_mask < 0.0) || (elevation_mask > 90.0)) + { + //warn user and set the default + LOG(WARNING) << "Erroneous Elevation Mask. Setting to default value of 15.0 degrees"; + elevation_mask = 15.0; + } + + int dynamics_model = configuration->property(role + ".dynamics_model", 0); /* dynamics model (0:none, 1:velocity, 2:accel) */ + if ((dynamics_model < 0) || (dynamics_model > 2)) + { + //warn user and set the default + LOG(WARNING) << "Erroneous Dynamics Model configuration. Setting to default value of (0:none)"; + dynamics_model = 0; + } + + std::string default_iono_model("OFF"); + std::string iono_model_str = configuration->property(role + ".iono_model", default_iono_model); /* (IONOOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ + int iono_model = -1; + if (iono_model_str == "OFF") + { + iono_model = IONOOPT_OFF; + } + if (iono_model_str == "Broadcast") + { + iono_model = IONOOPT_BRDC; + } + if (iono_model_str == "SBAS") + { + iono_model = IONOOPT_SBAS; + } + if (iono_model_str == "Iono-Free-LC") + { + iono_model = IONOOPT_IFLC; + } + if (iono_model_str == "Estimate_STEC") + { + iono_model = IONOOPT_EST; + } + if (iono_model_str == "IONEX") + { + iono_model = IONOOPT_TEC; + } + if (iono_model == -1) + { + //warn user and set the default + std::cout << "WARNING: Bad specification of ionospheric model." << std::endl; + std::cout << "iono_model possible values: OFF / Broadcast / SBAS / Iono-Free-LC / Estimate_STEC / IONEX" << std::endl; + std::cout << "iono_model specified value: " << iono_model_str << std::endl; + std::cout << "Setting iono_model to OFF" << std::endl; + iono_model = IONOOPT_OFF; /* 0: ionosphere option: correction off */ + } + + std::string default_trop_model("OFF"); + int trop_model = -1; + std::string trop_model_str = configuration->property(role + ".trop_model", default_trop_model); /* (TROPOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ + if (trop_model_str == "OFF") + { + trop_model = TROPOPT_OFF; + } + if (trop_model_str == "Saastamoinen") + { + trop_model = TROPOPT_SAAS; + } + if (trop_model_str == "SBAS") + { + trop_model = TROPOPT_SBAS; + } + if (trop_model_str == "Estimate_ZTD") + { + trop_model = TROPOPT_EST; + } + if (trop_model_str == "Estimate_ZTD_Grad") + { + trop_model = TROPOPT_ESTG; + } + if (trop_model == -1) + { + //warn user and set the default + std::cout << "WARNING: Bad specification of tropospheric model." << std::endl; + std::cout << "trop_model possible values: OFF / Saastamoinen / SBAS / Estimate_ZTD / Estimate_ZTD_Grad" << std::endl; + std::cout << "trop_model specified value: " << trop_model_str << std::endl; + std::cout << "Setting trop_model to OFF" << std::endl; + trop_model = TROPOPT_OFF; + } + + /* RTKLIB positioning options */ + int sat_PCV = 0; /* Set whether the satellite antenna PCV (phase center variation) model is used or not. This feature requires a Satellite Antenna PCV File. */ + int rec_PCV = 0; /* Set whether the receiver antenna PCV (phase center variation) model is used or not. This feature requires a Receiver Antenna PCV File. */ + + /* Set whether the phase windup correction for PPP modes is applied or not. Only applicable to PPP‐* modes.*/ + int phwindup = configuration->property(role + ".phwindup", 0); + + /* Set whether the GPS Block IIA satellites in eclipse are excluded or not. + The eclipsing Block IIA satellites often degrade the PPP solutions due to unpredicted behavior of yaw‐attitude. Only applicable to PPP‐* modes.*/ + int reject_GPS_IIA = configuration->property(role + ".reject_GPS_IIA", 0); + + /* Set whether RAIM (receiver autonomous integrity monitoring) FDE (fault detection and exclusion) feature is enabled or not. + In case of RAIM FDE enabled, a satellite is excluded if SSE (sum of squared errors) of residuals is over a threshold. + The excluded satellite is selected to indicate the minimum SSE. */ + int raim_fde = configuration->property(role + ".raim_fde", 0); + + int earth_tide = configuration->property(role + ".earth_tide", 0); + + int nsys = SYS_GPS; + // if ((gps_1C_count > 0) || (gps_2S_count > 0) || (gps_L5_count > 0)) nsys += SYS_GPS; + // if ((gal_1B_count > 0) || (gal_E5a_count > 0) || (gal_E5b_count > 0)) nsys += SYS_GAL; + // if ((glo_1G_count > 0) || (glo_2G_count > 0)) nsys += SYS_GLO; + int navigation_system = configuration->property(role + ".navigation_system", nsys); /* (SYS_XXX) see src/algorithms/libs/rtklib/rtklib.h */ + if ((navigation_system < 1) || (navigation_system > 255)) /* GPS: 1 SBAS: 2 GPS+SBAS: 3 Galileo: 8 Galileo+GPS: 9 GPS+SBAS+Galileo: 11 All: 255 */ + { + //warn user and set the default + LOG(WARNING) << "Erroneous Navigation System. Setting to default value of (0:none)"; + navigation_system = nsys; + } + + // Settings 2 + std::string default_gps_ar("Continuous"); + std::string integer_ambiguity_resolution_gps_str = configuration->property(role + ".AR_GPS", default_gps_ar); /* Integer Ambiguity Resolution mode for GPS (0:off,1:continuous,2:instantaneous,3:fix and hold,4:ppp-ar) */ + int integer_ambiguity_resolution_gps = -1; + if (integer_ambiguity_resolution_gps_str == "OFF") + { + integer_ambiguity_resolution_gps = ARMODE_OFF; + } + if (integer_ambiguity_resolution_gps_str == "Continuous") + { + integer_ambiguity_resolution_gps = ARMODE_CONT; + } + if (integer_ambiguity_resolution_gps_str == "Instantaneous") + { + integer_ambiguity_resolution_gps = ARMODE_INST; + } + if (integer_ambiguity_resolution_gps_str == "Fix-and-Hold") + { + integer_ambiguity_resolution_gps = ARMODE_FIXHOLD; + } + if (integer_ambiguity_resolution_gps_str == "PPP-AR") + { + integer_ambiguity_resolution_gps = ARMODE_PPPAR; + } + if (integer_ambiguity_resolution_gps == -1) + { + //warn user and set the default + std::cout << "WARNING: Bad specification of GPS ambiguity resolution method." << std::endl; + std::cout << "AR_GPS possible values: OFF / Continuous / Instantaneous / Fix-and-Hold / PPP-AR" << std::endl; + std::cout << "AR_GPS specified value: " << integer_ambiguity_resolution_gps_str << std::endl; + std::cout << "Setting AR_GPS to OFF" << std::endl; + integer_ambiguity_resolution_gps = ARMODE_OFF; + } + + int integer_ambiguity_resolution_glo = configuration->property(role + ".AR_GLO", 1); /* Integer Ambiguity Resolution mode for GLONASS (0:off,1:on,2:auto cal,3:ext cal) */ + if ((integer_ambiguity_resolution_glo < 0) || (integer_ambiguity_resolution_glo > 3)) + { + //warn user and set the default + LOG(WARNING) << "Erroneous Integer Ambiguity Resolution for GLONASS . Setting to default value of (1:on)"; + integer_ambiguity_resolution_glo = 1; + } + + int integer_ambiguity_resolution_bds = configuration->property(role + ".AR_DBS", 1); /* Integer Ambiguity Resolution mode for BEIDOU (0:off,1:on) */ + if ((integer_ambiguity_resolution_bds < 0) || (integer_ambiguity_resolution_bds > 1)) + { + //warn user and set the default + LOG(WARNING) << "Erroneous Integer Ambiguity Resolution for BEIDOU . Setting to default value of (1:on)"; + integer_ambiguity_resolution_bds = 1; + } + + double min_ratio_to_fix_ambiguity = configuration->property(role + ".min_ratio_to_fix_ambiguity", 3.0); /* Set the integer ambiguity validation threshold for ratio‐test, + which uses the ratio of squared residuals of the best integer vector to the second‐best vector. */ + + int min_lock_to_fix_ambiguity = configuration->property(role + ".min_lock_to_fix_ambiguity", 0); /* Set the minimum lock count to fix integer ambiguity. + If the lock count is less than the value, the ambiguity is excluded from the fixed integer vector. */ + + double min_elevation_to_fix_ambiguity = configuration->property(role + ".min_elevation_to_fix_ambiguity", 0.0); /* Set the minimum elevation (deg) to fix integer ambiguity. + If the elevation of the satellite is less than the value, the ambiguity is excluded from the fixed integer vector. */ + + int outage_reset_ambiguity = configuration->property(role + ".outage_reset_ambiguity", 5); /* Set the outage count to reset ambiguity. If the data outage count is over the value, the estimated ambiguity is reset to the initial value. */ + + double slip_threshold = configuration->property(role + ".slip_threshold", 0.05); /* set the cycle‐slip threshold (m) of geometry‐free LC carrier‐phase difference between epochs */ + + double threshold_reject_gdop = configuration->property(role + ".threshold_reject_gdop", 30.0); /* reject threshold of GDOP. If the GDOP is over the value, the observable is excluded for the estimation process as an outlier. */ + + double threshold_reject_innovation = configuration->property(role + ".threshold_reject_innovation", 30.0); /* reject threshold of innovation (m). If the innovation is over the value, the observable is excluded for the estimation process as an outlier. */ + + int number_filter_iter = configuration->property(role + ".number_filter_iter", 1); /* Set the number of iteration in the measurement update of the estimation filter. + If the baseline length is very short like 1 m, the iteration may be effective to handle + the nonlinearity of measurement equation. */ + + /// Statistics + double bias_0 = configuration->property(role + ".bias_0", 30.0); + + double iono_0 = configuration->property(role + ".iono_0", 0.03); + + double trop_0 = configuration->property(role + ".trop_0", 0.3); + + double sigma_bias = configuration->property(role + ".sigma_bias", 1e-4); /* Set the process noise standard deviation of carrier‐phase + bias (ambiguity) (cycle/sqrt(s)) */ + + double sigma_iono = configuration->property(role + ".sigma_iono", 1e-3); /* Set the process noise standard deviation of vertical ionospheric delay per 10 km baseline (m/sqrt(s)). */ + + double sigma_trop = configuration->property(role + ".sigma_trop", 1e-4); /* Set the process noise standard deviation of zenith tropospheric delay (m/sqrt(s)). */ + + double sigma_acch = configuration->property(role + ".sigma_acch", 1e-1); /* Set the process noise standard deviation of the receiver acceleration as + the horizontal component. (m/s2/sqrt(s)). If Receiver Dynamics is set to OFF, they are not used. */ + + double sigma_accv = configuration->property(role + ".sigma_accv", 1e-2); /* Set the process noise standard deviation of the receiver acceleration as + the vertical component. (m/s2/sqrt(s)). If Receiver Dynamics is set to OFF, they are not used. */ + + double sigma_pos = configuration->property(role + ".sigma_pos", 0.0); + + double code_phase_error_ratio_l1 = configuration->property(role + ".code_phase_error_ratio_l1", 100.0); + double code_phase_error_ratio_l2 = configuration->property(role + ".code_phase_error_ratio_l2", 100.0); + double code_phase_error_ratio_l5 = configuration->property(role + ".code_phase_error_ratio_l5", 100.0); + double carrier_phase_error_factor_a = configuration->property(role + ".carrier_phase_error_factor_a", 0.003); + double carrier_phase_error_factor_b = configuration->property(role + ".carrier_phase_error_factor_b", 0.003); + + snrmask_t snrmask = {{}, {{}, {}}}; + + prcopt_t rtklib_configuration_options = { + positioning_mode, /* positioning mode (PMODE_XXX) see src/algorithms/libs/rtklib/rtklib.h */ + 0, /* solution type (0:forward,1:backward,2:combined) */ + number_of_frequencies, /* number of frequencies (1:L1, 2:L1+L2, 3:L1+L2+L5)*/ + navigation_system, /* navigation system */ + elevation_mask * D2R, /* elevation mask angle (degrees) */ + snrmask, /* snrmask_t snrmask SNR mask */ + 0, /* satellite ephemeris/clock (EPHOPT_XXX) */ + integer_ambiguity_resolution_gps, /* AR mode (0:off,1:continuous,2:instantaneous,3:fix and hold,4:ppp-ar) */ + integer_ambiguity_resolution_glo, /* GLONASS AR mode (0:off,1:on,2:auto cal,3:ext cal) */ + integer_ambiguity_resolution_bds, /* BeiDou AR mode (0:off,1:on) */ + outage_reset_ambiguity, /* obs outage count to reset bias */ + min_lock_to_fix_ambiguity, /* min lock count to fix ambiguity */ + 10, /* min fix count to hold ambiguity */ + 1, /* max iteration to resolve ambiguity */ + iono_model, /* ionosphere option (IONOOPT_XXX) */ + trop_model, /* troposphere option (TROPOPT_XXX) */ + dynamics_model, /* dynamics model (0:none, 1:velocity, 2:accel) */ + earth_tide, /* earth tide correction (0:off,1:solid,2:solid+otl+pole) */ + number_filter_iter, /* number of filter iteration */ + 0, /* code smoothing window size (0:none) */ + 0, /* interpolate reference obs (for post mission) */ + 0, /* sbssat_t sbssat SBAS correction options */ + 0, /* sbsion_t sbsion[MAXBAND+1] SBAS satellite selection (0:all) */ + 0, /* rover position for fixed mode */ + 0, /* base position for relative mode */ + /* 0:pos in prcopt, 1:average of single pos, */ + /* 2:read from file, 3:rinex header, 4:rtcm pos */ + {code_phase_error_ratio_l1, code_phase_error_ratio_l2, code_phase_error_ratio_l5}, /* eratio[NFREQ] code/phase error ratio */ + {100.0, carrier_phase_error_factor_a, carrier_phase_error_factor_b, 0.0, 1.0}, /* err[5]: measurement error factor [0]:reserved, [1-3]:error factor a/b/c of phase (m) , [4]:doppler frequency (hz) */ + {bias_0, iono_0, trop_0}, /* std[3]: initial-state std [0]bias,[1]iono [2]trop*/ + {sigma_bias, sigma_iono, sigma_trop, sigma_acch, sigma_accv, sigma_pos}, /* prn[6] process-noise std */ + 5e-12, /* sclkstab: satellite clock stability (sec/sec) */ + {min_ratio_to_fix_ambiguity, 0.9999, 0.25, 0.1, 0.05, 0.0, 0.0, 0.0}, /* thresar[8]: AR validation threshold */ + min_elevation_to_fix_ambiguity, /* elevation mask of AR for rising satellite (deg) */ + 0.0, /* elevation mask to hold ambiguity (deg) */ + slip_threshold, /* slip threshold of geometry-free phase (m) */ + 30.0, /* max difference of time (sec) */ + threshold_reject_innovation, /* reject threshold of innovation (m) */ + threshold_reject_gdop, /* reject threshold of gdop */ + {}, /* double baseline[2] baseline length constraint {const,sigma} (m) */ + {}, /* double ru[3] rover position for fixed mode {x,y,z} (ecef) (m) */ + {}, /* double rb[3] base position for relative mode {x,y,z} (ecef) (m) */ + {"", ""}, /* char anttype[2][MAXANT] antenna types {rover,base} */ + {{}, {}}, /* double antdel[2][3] antenna delta {{rov_e,rov_n,rov_u},{ref_e,ref_n,ref_u}} */ + {}, /* pcv_t pcvr[2] receiver antenna parameters {rov,base} */ + {}, /* unsigned char exsats[MAXSAT] excluded satellites (1:excluded, 2:included) */ + 0, /* max averaging epoches */ + 0, /* initialize by restart */ + 1, /* output single by dgps/float/fix/ppp outage */ + {"", ""}, /* char rnxopt[2][256] rinex options {rover,base} */ + {sat_PCV, rec_PCV, phwindup, reject_GPS_IIA, raim_fde}, /* posopt[6] positioning options [0]: satellite and receiver antenna PCV model; [1]: interpolate antenna parameters; [2]: apply phase wind-up correction for PPP modes; [3]: exclude measurements of GPS Block IIA satellites satellite [4]: RAIM FDE (fault detection and exclusion) [5]: handle day-boundary clock jump */ + 0, /* solution sync mode (0:off,1:on) */ + {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ + {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ + 0, /* disable L2-AR */ + {} /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + }; + + rtk_t rtk; + rtkinit(&rtk, &rtklib_configuration_options); + return rtk; +} + + +//todo: add test cases for Galileo E1, E5 and GPS L5 +TEST(RTKLibSolverTest, test1) +{ + //test case #1: GPS L1 CA simulated with gnss-sim + std::string path = std::string(TEST_PATH); + int nchannels = 8; + std::string dump_filename = ".rtklib_solver_dump.dat"; + bool flag_dump_to_file = false; + bool save_to_mat = false; + rtk_t rtk = configure_rtklib_options(); + + std::unique_ptr d_ls_pvt(new Rtklib_Solver(nchannels, dump_filename, flag_dump_to_file, save_to_mat, rtk)); + d_ls_pvt->set_averaging_depth(1); + + // load ephemeris + std::string eph_xml_filename = path + "data/rtklib_test/eph_GPS_L1CA_test1.xml"; + Gnss_Sdr_Supl_Client supl_client_ephemeris_; + + std::cout << "SUPL: Try read GPS ephemeris from XML file " << eph_xml_filename << std::endl; + if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) + { + std::map::const_iterator gps_eph_iter; + for (gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.cbegin(); + gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend(); + gps_eph_iter++) + { + std::cout << "SUPL: Read XML Ephemeris for GPS SV " << gps_eph_iter->first << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); + // update/insert new ephemeris record to the global ephemeris map + d_ls_pvt->gps_ephemeris_map[gps_eph_iter->first] = *tmp_obj; + } + } + else + { + std::cout << "ERROR: SUPL client error reading XML" << std::endl; + } + + // insert observables epoch + std::map gnss_synchro_map; + // Gnss_Synchro tmp_obs; + // tmp_obs.System = 'G'; + // std::string signal = "1C"; + // const char* str = signal.c_str(); // get a C style null terminated string + // std::memcpy(static_cast(tmp_obs.Signal), str, 3); // copy string into synchro char array: 2 char + null + // + // gnss_synchro_map[0] = tmp_obs; + // gnss_synchro_map[0].PRN = 1; + + //load from xml (boost serialize) + std::string file_name = path + "data/rtklib_test/obs_test1.xml"; + + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gnss_synchro_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_synchro_map); + std::cout << "Loaded gnss_synchro map data with " << gnss_synchro_map.size() << " pseudoranges" << std::endl; + } + catch (std::exception& e) + { + std::cout << e.what() << "File: " << file_name; + } + ifs.close(); + + // solve + bool pvt_valid = false; + if (d_ls_pvt->get_PVT(gnss_synchro_map, false)) + { + // DEBUG MESSAGE: Display position in console output + if (d_ls_pvt->is_valid_position()) + { + std::streamsize ss = std::cout.precision(); // save current precision + std::cout.setf(std::ios::fixed, std::ios::floatfield); + + auto facet = new boost::posix_time::time_facet("%Y-%b-%d %H:%M:%S.%f %z"); + std::cout.imbue(std::locale(std::cout.getloc(), facet)); + + std::cout << "Position at " << d_ls_pvt->get_position_UTC_time() + << " UTC using " << d_ls_pvt->get_num_valid_observations() + << std::fixed << std::setprecision(9) + << " observations is Lat = " << d_ls_pvt->get_latitude() << " [deg], Long = " << d_ls_pvt->get_longitude() + << std::fixed << std::setprecision(3) + << " [deg], Height = " << d_ls_pvt->get_height() << " [m]" << std::endl; + std::cout << std::setprecision(ss); + std::cout << "RX clock offset: " << d_ls_pvt->get_time_offset_s() << "[s]" << std::endl; + + // boost::posix_time::ptime p_time; + // gtime_t rtklib_utc_time = gpst2time(adjgpsweek(d_ls_pvt->gps_ephemeris_map.cbegin()->second.i_GPS_week), d_rx_time); + // p_time = boost::posix_time::from_time_t(rtklib_utc_time.time); + // p_time += boost::posix_time::microseconds(round(rtklib_utc_time.sec * 1e6)); + // std::cout << TEXT_MAGENTA << "Observable RX time (GPST) " << boost::posix_time::to_simple_string(p_time) << TEXT_RESET << std::endl; + + std::cout << "RTKLIB Position at RX TOW = " << gnss_synchro_map.begin()->second.RX_time + << " in ECEF (X,Y,Z,t[meters]) = " << std::fixed << std::setprecision(16) + << d_ls_pvt->pvt_sol.rr[0] << "," + << d_ls_pvt->pvt_sol.rr[1] << "," + << d_ls_pvt->pvt_sol.rr[2] << std::endl; + /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_ls_pvt->get_position_UTC_time()) + << " UTC using "<< d_ls_pvt->get_num_valid_observations() <<" observations is HDOP = " << d_ls_pvt->get_hdop() << " VDOP = " + << d_ls_pvt->get_vdop() + << " GDOP = " << d_ls_pvt->get_gdop() << std::endl; */ + + //todo: check here the positioning error against the reference position generated with gnss-sim + //reference position on in WGS84: Lat (deg), Long (deg) , H (m): 30.286502,120.032669,100 + arma::vec LLH = {30.286502, 120.032669, 100}; //ref position for this scenario + + double error_LLH_m = great_circle_distance(LLH(0), LLH(1), d_ls_pvt->get_latitude(), d_ls_pvt->get_longitude()); + std::cout << "Lat, Long, H error: " << d_ls_pvt->get_latitude() - LLH(0) + << "," << d_ls_pvt->get_longitude() - LLH(1) + << "," << d_ls_pvt->get_height() - LLH(2) << " [deg,deg,meters]" << std::endl; + + std::cout << "Haversine Great Circle error LLH distance: " << error_LLH_m << " [meters]" << std::endl; + + arma::vec v_eb_n = {0.0, 0.0, 0.0}; + arma::vec true_r_eb_e; + arma::vec true_v_eb_e; + pv_Geo_to_ECEF(degtorad(LLH(0)), degtorad(LLH(1)), LLH(2), v_eb_n, true_r_eb_e, true_v_eb_e); + + arma::vec measured_r_eb_e = {d_ls_pvt->pvt_sol.rr[0], d_ls_pvt->pvt_sol.rr[1], d_ls_pvt->pvt_sol.rr[2]}; + + arma::vec error_r_eb_e = measured_r_eb_e - true_r_eb_e; + + std::cout << "ECEF position error vector: " << error_r_eb_e << " [meters]" << std::endl; + + double error_3d_m = arma::norm(error_r_eb_e, 2); + + std::cout << "3D positioning error: " << error_3d_m << " [meters]" << std::endl; + + //check results against the test tolerance + ASSERT_LT(error_3d_m, 0.2); + pvt_valid = true; + } + } + + EXPECT_EQ(true, pvt_valid); +} diff --git a/src/tests/unit-tests/signal-processing-blocks/resampler/direct_resampler_conditioner_cc_test.cc b/src/tests/unit-tests/signal-processing-blocks/resampler/direct_resampler_conditioner_cc_test.cc index 8dc1ef42c..d8ce67450 100644 --- a/src/tests/unit-tests/signal-processing-blocks/resampler/direct_resampler_conditioner_cc_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/resampler/direct_resampler_conditioner_cc_test.cc @@ -31,14 +31,18 @@ */ -#include -#include #include +#include +#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include -#include "gnss_sdr_valve.h" +#endif #include "direct_resampler_conditioner_cc.h" +#include "gnss_sdr_valve.h" +#include +#include TEST(DirectResamplerConditionerCcTest, InstantiationAndRunTest) diff --git a/src/tests/unit-tests/signal-processing-blocks/resampler/mmse_resampler_test.cc b/src/tests/unit-tests/signal-processing-blocks/resampler/mmse_resampler_test.cc index 1292f93dc..2bc26b8b4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/resampler/mmse_resampler_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/resampler/mmse_resampler_test.cc @@ -29,14 +29,18 @@ * ------------------------------------------------------------------------- */ -#include -#include #include +#include +#include +#ifdef GR_GREATER_38 +#include +#else #include -#include -#include +#endif #include "gnss_sdr_valve.h" #include "mmse_resampler_conditioner.h" +#include +#include TEST(MmseResamplerTest, InstantiationAndRunTestWarning) { diff --git a/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc b/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc index 5b62bdfe7..dd1020249 100644 --- a/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc @@ -29,13 +29,12 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include -#include -#include #include "file_signal_source.h" #include "in_memory_configuration.h" +#include +#include +#include +#include TEST(FileSignalSource, Instantiate) { @@ -50,7 +49,7 @@ TEST(FileSignalSource, Instantiate) config->set_property("Test.item_type", "gr_complex"); config->set_property("Test.repeat", "false"); - std::unique_ptr signal_source(new FileSignalSource(config.get(), "Test", 1, 1, queue)); + std::unique_ptr signal_source(new FileSignalSource(config.get(), "Test", 0, 1, queue)); EXPECT_STREQ("gr_complex", signal_source->item_type().c_str()); EXPECT_TRUE(signal_source->repeat() == false); @@ -67,5 +66,5 @@ TEST(FileSignalSource, InstantiateFileNotExists) config->set_property("Test.item_type", "gr_complex"); config->set_property("Test.repeat", "false"); - EXPECT_THROW({ auto uptr = std::make_shared(config.get(), "Test", 1, 1, queue); }, std::exception); + EXPECT_THROW({ auto uptr = std::make_shared(config.get(), "Test", 0, 1, queue); }, std::exception); } diff --git a/src/tests/unit-tests/signal-processing-blocks/sources/gnss_sdr_valve_test.cc b/src/tests/unit-tests/signal-processing-blocks/sources/gnss_sdr_valve_test.cc index 26a57621e..02e1b09df 100644 --- a/src/tests/unit-tests/signal-processing-blocks/sources/gnss_sdr_valve_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/sources/gnss_sdr_valve_test.cc @@ -31,12 +31,16 @@ */ -#include #include +#include +#ifdef GR_GREATER_38 +#include +#else #include +#endif +#include "gnss_sdr_valve.h" #include #include -#include "gnss_sdr_valve.h" TEST(ValveTest, CheckEventSentAfter100Samples) { diff --git a/src/tests/unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc b/src/tests/unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc index 9229f16be..7fc787352 100644 --- a/src/tests/unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc @@ -31,13 +31,18 @@ */ -#include #include +#include +#ifdef GR_GREATER_38 +#include +#include +#else +#include #include #include -#include -#include +#endif #include "unpack_2bit_samples.h" +#include std::vector packData(std::vector const &raw_data, bool big_endian) @@ -47,9 +52,9 @@ std::vector packData(std::vector const &raw_data, int shift = (big_endian ? 6 : 0); unsigned int j = 0; - for (unsigned int i = 0; i < raw_data.size(); ++i) + for (signed char i : raw_data) { - unsigned val = static_cast((raw_data[i] - 1) / 2 & 0x03); + auto val = static_cast((i - 1) / 2 & 0x03); packed_data[j] |= val << shift; diff --git a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc new file mode 100644 index 000000000..ae2416ec3 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc @@ -0,0 +1,285 @@ +/*! + * \file galileo_fnav_inav_decoder_test.cc + * \brief This class implements the unit test for the Galileo FNAV and INAV frames + * according to the Galileo ICD + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "convolutional.h" +#include "galileo_fnav_message.h" +#include "galileo_navigation_message.h" +#include +#include +#include +#include +#include +#include +#include + + +class Galileo_FNAV_INAV_test : public ::testing::Test +{ +public: + Galileo_Navigation_Message INAV_decoder; + Galileo_Fnav_Message FNAV_decoder; + // vars for Viterbi decoder + int32_t *out0, *out1, *state0, *state1; + int32_t g_encoder[2]; + const int32_t nn = 2; // Coding rate 1/n + const int32_t KK = 7; // Constraint Length + int32_t mm = KK - 1; + int32_t flag_even_word_arrived; + void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits, int32_t _datalength) + { + Viterbi(page_part_bits, out0, state0, out1, state1, + page_part_symbols, KK, nn, _datalength); + } + + + void deinterleaver(int32_t rows, int32_t cols, const double *in, double *out) + { + for (int32_t r = 0; r < rows; r++) + { + for (int32_t c = 0; c < cols; c++) + { + out[c * rows + r] = in[r * cols + c]; + } + } + } + + + bool decode_INAV_word(double *page_part_symbols, int32_t frame_length) + { + // 1. De-interleave + auto *page_part_symbols_deint = static_cast(volk_gnsssdr_malloc(frame_length * sizeof(double), volk_gnsssdr_get_alignment())); + deinterleaver(GALILEO_INAV_INTERLEAVER_ROWS, GALILEO_INAV_INTERLEAVER_COLS, page_part_symbols, page_part_symbols_deint); + + // 2. Viterbi decoder + // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) + // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180º + for (int32_t i = 0; i < frame_length; i++) + { + if ((i + 1) % 2 == 0) + { + page_part_symbols_deint[i] = -page_part_symbols_deint[i]; + } + } + + auto *page_part_bits = static_cast(volk_gnsssdr_malloc((frame_length / 2) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + + const int32_t CodeLength = 240; + int32_t DataLength = (CodeLength / nn) - mm; + viterbi_decoder(page_part_symbols_deint, page_part_bits, DataLength); + volk_gnsssdr_free(page_part_symbols_deint); + + // 3. Call the Galileo page decoder + std::string page_String; + for (int32_t i = 0; i < (frame_length / 2); i++) + { + if (page_part_bits[i] > 0) + { + page_String.push_back('1'); + } + else + { + page_String.push_back('0'); + } + } + + bool crc_ok = false; + if (page_part_bits[0] == 1) + { + // DECODE COMPLETE WORD (even + odd) and TEST CRC + INAV_decoder.split_page(page_String, flag_even_word_arrived); + if (INAV_decoder.flag_CRC_test == true) + { + std::cout << "Galileo E1 INAV PAGE CRC correct \n"; + //std::cout << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl; + crc_ok = true; + } + flag_even_word_arrived = 0; + } + else + { + // STORE HALF WORD (even page) + INAV_decoder.split_page(page_String.c_str(), flag_even_word_arrived); + flag_even_word_arrived = 1; + } + volk_gnsssdr_free(page_part_bits); + return crc_ok; + } + + bool decode_FNAV_word(double *page_symbols, int32_t frame_length) + { + // 1. De-interleave + auto *page_symbols_deint = static_cast(volk_gnsssdr_malloc(frame_length * sizeof(double), volk_gnsssdr_get_alignment())); + deinterleaver(GALILEO_FNAV_INTERLEAVER_ROWS, GALILEO_FNAV_INTERLEAVER_COLS, page_symbols, page_symbols_deint); + + // 2. Viterbi decoder + // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) + // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180 + for (int32_t i = 0; i < frame_length; i++) + { + if ((i + 1) % 2 == 0) + { + page_symbols_deint[i] = -page_symbols_deint[i]; + } + } + auto *page_bits = static_cast(volk_gnsssdr_malloc((frame_length / 2) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + + const int32_t CodeLength = 488; + int32_t DataLength = (CodeLength / nn) - mm; + viterbi_decoder(page_symbols_deint, page_bits, DataLength); + + volk_gnsssdr_free(page_symbols_deint); + + // 3. Call the Galileo page decoder + std::string page_String; + for (int32_t i = 0; i < frame_length; i++) + { + if (page_bits[i] > 0) + { + page_String.push_back('1'); + } + else + { + page_String.push_back('0'); + } + } + volk_gnsssdr_free(page_bits); + + // DECODE COMPLETE WORD (even + odd) and TEST CRC + FNAV_decoder.split_page(page_String); + if (FNAV_decoder.flag_CRC_test == true) + { + std::cout << "Galileo E5a FNAV PAGE CRC correct \n"; + return true; + } + return false; + } + + Galileo_FNAV_INAV_test() + { + // vars for Viterbi decoder + int32_t max_states = 1 << mm; // 2^mm + g_encoder[0] = 121; // Polynomial G1 + g_encoder[1] = 91; // Polynomial G2 + out0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + // create appropriate transition matrices + nsc_transit(out0, state0, 0, g_encoder, KK, nn); + nsc_transit(out1, state1, 1, g_encoder, KK, nn); + flag_even_word_arrived = 0; + } + + ~Galileo_FNAV_INAV_test() + { + volk_gnsssdr_free(out0); + volk_gnsssdr_free(out1); + volk_gnsssdr_free(state0); + volk_gnsssdr_free(state1); + } +}; + +TEST_F(Galileo_FNAV_INAV_test, ValidationOfResults) +{ + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds(0); + start = std::chrono::system_clock::now(); + int repetitions = 10; + // FNAV FULLY ENCODED FRAME + double FNAV_frame[488] = {-1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, + -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, + -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, + -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, + -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, + -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, + -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, + 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, + -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, + 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, + -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, + 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, + 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1}; + + ASSERT_NO_THROW({ + for (int n = 0; n < repetitions; n++) + { + EXPECT_EQ(decode_FNAV_word(&FNAV_frame[0], 488), true); + } + }) << "Exception during FNAV frame decoding"; + + + // INAV FULLY ENCODED FRAME + double INAV_frame_even[240] = {-1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, + -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, + 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, + -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1}; + + double INAV_frame_odd[240] = {1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, + 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, + -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, + 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, + -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, + 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, + -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, + -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, + 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1}; + + ASSERT_NO_THROW({ + for (int n = 0; n < repetitions; n++) + { + decode_INAV_word(&INAV_frame_even[0], 240); + EXPECT_EQ(decode_INAV_word(&INAV_frame_odd[0], 240), true); + } + }) << "Exception during INAV frame decoding"; + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + std::cout << "Galileo FNAV/INAV Test completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; +} diff --git a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc index 184ad30c0..be7963164 100644 --- a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc @@ -30,33 +30,38 @@ * ------------------------------------------------------------------------- */ -#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else #include +#endif +#include "GPS_L1_CA.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" +#include "gnss_synchro.h" +#include "gps_l1_ca_dll_pll_c_aid_tracking.h" +#include "gps_l1_ca_dll_pll_tracking.h" +#include "gps_l1_ca_telemetry_decoder.h" +#include "in_memory_configuration.h" +#include "signal_generator_flags.h" +#include "telemetry_decoder_interface.h" +#include "tlm_dump_reader.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_true_obs_reader.h" #include #include #include #include -#include "GPS_L1_CA.h" -#include "gnss_block_factory.h" -#include "gnss_block_interface.h" -#include "tracking_interface.h" -#include "telemetry_decoder_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" -#include "gps_l1_ca_telemetry_decoder.h" -#include "tracking_true_obs_reader.h" -#include "tracking_dump_reader.h" -#include "tlm_dump_reader.h" -#include "gps_l1_ca_dll_pll_tracking.h" -#include "gps_l1_ca_dll_pll_c_aid_tracking.h" -#include "signal_generator_flags.h" // ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### @@ -87,7 +92,7 @@ void GpsL1CADllPllTelemetryDecoderTest_msg_rx::msg_handler_events(pmt::pmt_t msg { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -104,9 +109,7 @@ GpsL1CADllPllTelemetryDecoderTest_msg_rx::GpsL1CADllPllTelemetryDecoderTest_msg_ rx_message = 0; } -GpsL1CADllPllTelemetryDecoderTest_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_msg_rx() -{ -} +GpsL1CADllPllTelemetryDecoderTest_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_msg_rx() = default; // ########################################################### @@ -140,7 +143,7 @@ void GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::msg_handler_events(pmt::pmt_t { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -157,9 +160,7 @@ GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::GpsL1CADllPllTelemetryDecoderTest_ rx_message = 0; } -GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx() -{ -} +GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx() = default; // ########################################################### @@ -195,9 +196,7 @@ public: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CATelemetryDecoderTest() - { - } + ~GpsL1CATelemetryDecoderTest() = default; void configure_receiver(); @@ -234,11 +233,13 @@ int GpsL1CATelemetryDecoderTest::generate_signal() { int child_status; - char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], nullptr}; int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -293,7 +294,7 @@ void GpsL1CATelemetryDecoderTest::check_results(arma::vec& true_time_s, //2. RMSE //arma::vec err = meas_value - true_value_interp + 0.001; - arma::vec err = meas_value - true_value_interp - 0.001; + arma::vec err = meas_value - true_value_interp; // - 0.001; arma::vec err2 = arma::square(err); double rmse = sqrt(arma::mean(err2)); @@ -342,7 +343,7 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults) configure_receiver(); //open true observables log file written by the simulator - tracking_true_obs_reader true_obs_data; + Tracking_True_Obs_Reader true_obs_data; int test_satellite_PRN = FLAGS_test_satellite_PRN; std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl; std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); @@ -418,7 +419,7 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults) //check results //load the true values - long int nepoch = true_obs_data.num_epochs(); + int64_t nepoch = true_obs_data.num_epochs(); std::cout << "True observation epochs=" << nepoch << std::endl; arma::vec true_timestamp_s = arma::zeros(nepoch, 1); @@ -427,7 +428,7 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults) arma::vec true_prn_delay_chips = arma::zeros(nepoch, 1); arma::vec true_tow_s = arma::zeros(nepoch, 1); - long int epoch_counter = 0; + int64_t epoch_counter = 0; while (true_obs_data.read_binary_obs()) { true_timestamp_s(epoch_counter) = true_obs_data.signal_timestamp_s; @@ -439,7 +440,7 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults) } //load the measured values - tlm_dump_reader tlm_dump; + Tlm_Dump_Reader tlm_dump; ASSERT_NO_THROW({ if (tlm_dump.open_obs_file(std::string("./telemetry0.dat")) == false) { diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/bayesian_estimation_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/bayesian_estimation_test.cc new file mode 100644 index 000000000..dd7d0398b --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/bayesian_estimation_test.cc @@ -0,0 +1,69 @@ +/*! + * \file bayesian_estimation_positivity_test.cc + * \brief This file implements timing tests for the Bayesian covariance estimator + * \author Gerald LaMountain, 20168. gerald(at)ece.neu.edu + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "bayesian_estimation.h" +#include +#include +#include + +#define BAYESIAN_TEST_N_TRIALS 100 +#define BAYESIAN_TEST_ITER 10000 + +TEST(BayesianEstimationPositivityTest, BayesianPositivityTest) +{ + Bayesian_estimator bayes; + arma::vec bayes_mu = arma::zeros(1, 1); + int bayes_nu = 0; + int bayes_kappa = 0; + arma::mat bayes_Psi = arma::ones(1, 1); + arma::vec input = arma::zeros(1, 1); + + //--- Perform initializations ------------------------------ + + std::random_device r; + std::default_random_engine e1(r()); + std::normal_distribution normal_dist(0, 5); + + for (int k = 0; k < BAYESIAN_TEST_N_TRIALS; k++) + { + bayes.init(bayes_mu, bayes_kappa, bayes_nu, bayes_Psi); + + for (int n = 0; n < BAYESIAN_TEST_ITER; n++) + { + input(0) = static_cast(normal_dist(e1)); + bayes.update_sequential(input); + + arma::mat output = bayes.get_Psi_est(); + double output0 = output(0, 0); + ASSERT_EQ(output0 > 0.0, true); + } + } +} diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc index 1be7bbe49..b4c5f432c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc @@ -29,26 +29,27 @@ * ------------------------------------------------------------------------- */ +#include "GPS_L1_CA.h" +#include "cpu_multicorrelator_real_codes.h" +#include "gps_sdr_signal_processing.h" +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include "cpu_multicorrelator_real_codes.h" -#include "gps_sdr_signal_processing.h" -#include "GPS_L1_CA.h" DEFINE_int32(cpu_multicorrelator_real_codes_iterations_test, 100, "Number of averaged iterations in CPU multicorrelator test timing test"); DEFINE_int32(cpu_multicorrelator_real_codes_max_threads_test, 12, "Number of maximum concurrent correlators in CPU multicorrelator test timing test"); -void run_correlator_cpu_real_codes(cpu_multicorrelator_real_codes* correlator, +void run_correlator_cpu_real_codes(Cpu_Multicorrelator_Real_Codes* correlator, float d_rem_carrier_phase_rad, float d_carrier_phase_step_rad, float d_code_phase_step_chips, + float d_code_phase_rate_step_chips, float d_rem_code_phase_chips, int correlation_size) { @@ -58,6 +59,7 @@ void run_correlator_cpu_real_codes(cpu_multicorrelator_real_codes* correlator, d_carrier_phase_step_rad, d_code_phase_step_chips, d_rem_code_phase_chips, + d_code_phase_rate_step_chips, correlation_size); } } @@ -69,7 +71,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) std::chrono::duration elapsed_seconds(0); int max_threads = FLAGS_cpu_multicorrelator_real_codes_max_threads_test; std::vector thread_pool; - cpu_multicorrelator_real_codes* correlator_pool[max_threads]; + Cpu_Multicorrelator_Real_Codes* correlator_pool[max_threads]; unsigned int correlation_sizes[3] = {2048, 4096, 8192}; double execution_times[3]; @@ -116,7 +118,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) for (int n = 0; n < max_threads; n++) { - correlator_pool[n] = new cpu_multicorrelator_real_codes(); + correlator_pool[n] = new Cpu_Multicorrelator_Real_Codes(); correlator_pool[n]->init(d_vector_length, d_n_correlator_taps); correlator_pool[n]->set_input_output_vectors(d_correlator_outs, in_cpu); correlator_pool[n]->set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); @@ -125,6 +127,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) float d_rem_carrier_phase_rad = 0.0; float d_carrier_phase_step_rad = 0.1; float d_code_phase_step_chips = 0.3; + float d_code_phase_rate_step_chips = 0.00001; float d_rem_code_phase_chips = 0.4; EXPECT_NO_THROW( @@ -141,6 +144,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, + d_code_phase_rate_step_chips, d_rem_code_phase_chips, correlation_sizes[correlation_sizes_idx])); } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc index 068a9dce5..0f133db98 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc @@ -29,23 +29,23 @@ * ------------------------------------------------------------------------- */ +#include "GPS_L1_CA.h" +#include "cpu_multicorrelator.h" +#include "gps_sdr_signal_processing.h" +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include "cpu_multicorrelator.h" -#include "gps_sdr_signal_processing.h" -#include "GPS_L1_CA.h" DEFINE_int32(cpu_multicorrelator_iterations_test, 100, "Number of averaged iterations in CPU multicorrelator test timing test"); DEFINE_int32(cpu_multicorrelator_max_threads_test, 12, "Number of maximum concurrent correlators in CPU multicorrelator test timing test"); -void run_correlator_cpu(cpu_multicorrelator* correlator, +void run_correlator_cpu(Cpu_Multicorrelator* correlator, float d_rem_carrier_phase_rad, float d_carrier_phase_step_rad, float d_code_phase_step_chips, @@ -69,7 +69,7 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime) std::chrono::duration elapsed_seconds(0); int max_threads = FLAGS_cpu_multicorrelator_max_threads_test; std::vector thread_pool; - cpu_multicorrelator* correlator_pool[max_threads]; + Cpu_Multicorrelator* correlator_pool[max_threads]; unsigned int correlation_sizes[3] = {2048, 4096, 8192}; double execution_times[3]; @@ -116,7 +116,7 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime) for (int n = 0; n < max_threads; n++) { - correlator_pool[n] = new cpu_multicorrelator(); + correlator_pool[n] = new Cpu_Multicorrelator(); correlator_pool[n]->init(d_vector_length, d_n_correlator_taps); correlator_pool[n]->set_input_output_vectors(d_correlator_outs, in_cpu); correlator_pool[n]->set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc index 55b2e80f8..897257b93 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc @@ -31,22 +31,25 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "galileo_e1_dll_pll_veml_tracking.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" -#include "galileo_e1_dll_pll_veml_tracking.h" - +#include "in_memory_configuration.h" +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif class GalileoE1DllPllVemlTrackingInternalTest : public ::testing::Test { @@ -61,9 +64,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GalileoE1DllPllVemlTrackingInternalTest() - { - } + ~GalileoE1DllPllVemlTrackingInternalTest() = default; void init(); @@ -71,7 +72,7 @@ protected: gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; - Gnss_Synchro gnss_synchro; + Gnss_Synchro gnss_synchro{}; size_t item_size; bool stop; int message; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc index 2aad4e5bd..122184eb7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc @@ -31,21 +31,25 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "galileo_e5a_dll_pll_tracking.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" -#include "galileo_e5a_dll_pll_tracking.h" +#include "in_memory_configuration.h" +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif class GalileoE5aTrackingTest : public ::testing::Test @@ -61,9 +65,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GalileoE5aTrackingTest() - { - } + ~GalileoE5aTrackingTest() = default; void init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc index 3aadcba51..003c63a9d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc @@ -31,28 +31,32 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "glonass_l1_ca_dll_pll_c_aid_tracking.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "tracking_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" -#include "glonass_l1_ca_dll_pll_c_aid_tracking.h" - +#include "in_memory_configuration.h" +#include "tracking_interface.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GlonassL1CaDllPllCAidTrackingTest_msg_rx; -typedef boost::shared_ptr GlonassL1CaDllPllCAidTrackingTest_msg_rx_sptr; +using GlonassL1CaDllPllCAidTrackingTest_msg_rx_sptr = boost::shared_ptr; GlonassL1CaDllPllCAidTrackingTest_msg_rx_sptr GlonassL1CaDllPllCAidTrackingTest_msg_rx_make(); @@ -77,7 +81,7 @@ void GlonassL1CaDllPllCAidTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -94,9 +98,7 @@ GlonassL1CaDllPllCAidTrackingTest_msg_rx::GlonassL1CaDllPllCAidTrackingTest_msg_ rx_message = 0; } -GlonassL1CaDllPllCAidTrackingTest_msg_rx::~GlonassL1CaDllPllCAidTrackingTest_msg_rx() -{ -} +GlonassL1CaDllPllCAidTrackingTest_msg_rx::~GlonassL1CaDllPllCAidTrackingTest_msg_rx() = default; // ########################################################### @@ -113,9 +115,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GlonassL1CaDllPllCAidTrackingTest() - { - } + ~GlonassL1CaDllPllCAidTrackingTest() = default; void init(); @@ -137,11 +137,10 @@ void GlonassL1CaDllPllCAidTrackingTest::init() gnss_synchro.PRN = 11; config->set_property("GNSS-SDR.internal_fs_sps", "6625000"); + config->set_property("Tracking_1G.implementation", "GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking"); config->set_property("Tracking_1G.item_type", "gr_complex"); config->set_property("Tracking_1G.dump", "false"); - config->set_property("Tracking_1G.if", "0.0"); config->set_property("Tracking_1G.dump_filename", "./tracking_ch_"); - config->set_property("Tracking_1G.implementation", "GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking"); config->set_property("Tracking_1G.early_late_space_chips", "0.5"); config->set_property("Tracking_1G.order", "2"); config->set_property("Tracking_1G.pll_bw_hz", "2"); @@ -159,7 +158,7 @@ TEST_F(GlonassL1CaDllPllCAidTrackingTest, ValidationOfResults) init(); queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Tracking test"); - std::shared_ptr tracking = std::make_shared(config.get(), "Tracking_1G", 1, 1); + std::shared_ptr tracking = std::make_shared(config.get(), "Tracking_1G", 1, 1); boost::shared_ptr msg_rx = GlonassL1CaDllPllCAidTrackingTest_msg_rx_make(); gnss_synchro.Acq_delay_samples = 1343; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc index 65a4e9797..20a910ce4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc @@ -31,28 +31,33 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "glonass_l1_ca_dll_pll_tracking.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "tracking_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" -#include "glonass_l1_ca_dll_pll_tracking.h" +#include "in_memory_configuration.h" +#include "tracking_interface.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GlonassL1CaDllPllTrackingTest_msg_rx; -typedef boost::shared_ptr GlonassL1CaDllPllTrackingTest_msg_rx_sptr; +using GlonassL1CaDllPllTrackingTest_msg_rx_sptr = boost::shared_ptr; GlonassL1CaDllPllTrackingTest_msg_rx_sptr GlonassL1CaDllPllTrackingTest_msg_rx_make(); @@ -77,7 +82,7 @@ void GlonassL1CaDllPllTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -94,9 +99,7 @@ GlonassL1CaDllPllTrackingTest_msg_rx::GlonassL1CaDllPllTrackingTest_msg_rx() : g rx_message = 0; } -GlonassL1CaDllPllTrackingTest_msg_rx::~GlonassL1CaDllPllTrackingTest_msg_rx() -{ -} +GlonassL1CaDllPllTrackingTest_msg_rx::~GlonassL1CaDllPllTrackingTest_msg_rx() = default; // ########################################################### @@ -113,9 +116,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GlonassL1CaDllPllTrackingTest() - { - } + ~GlonassL1CaDllPllTrackingTest() = default; void init(); @@ -137,11 +138,10 @@ void GlonassL1CaDllPllTrackingTest::init() gnss_synchro.PRN = 11; config->set_property("GNSS-SDR.internal_fs_sps", "6625000"); + config->set_property("Tracking_1G.implementation", "GLONASS_L1_CA_DLL_PLL_Tracking"); config->set_property("Tracking_1G.item_type", "gr_complex"); config->set_property("Tracking_1G.dump", "false"); - config->set_property("Tracking_1G.if", "0.0"); config->set_property("Tracking_1G.dump_filename", "./tracking_ch_"); - config->set_property("Tracking_1G.implementation", "GLONASS_L1_CA_DLL_PLL_Tracking"); config->set_property("Tracking_1G.early_late_space_chips", "0.5"); config->set_property("Tracking_1G.order", "2"); config->set_property("Tracking_1G.pll_bw_hz", "2"); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc index b8363c383..982eda0ee 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc @@ -1,6 +1,6 @@ /*! * \file gps_l1_ca_dll_pll_tracking_test.cc - * \brief This class implements a tracking test for Galileo_E5a_DLL_PLL_Tracking + * \brief This class implements a tracking test for GPS_L1_CA_DLL_PLL_Tracking * implementation based on some input parameters. * \author Javier Arribas, 2017. jarribas(at)cttc.es * @@ -30,32 +30,35 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include +#include "GPS_L1_CA.h" +#include "gnss_block_factory.h" +#include "gnuplot_i.h" +#include "in_memory_configuration.h" +#include "signal_generator_flags.h" +#include "test_flags.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_tests_flags.h" +#include "tracking_true_obs_reader.h" #include #include -#include -#include #include -#include +#include #include #include #include +#include #include -#include "GPS_L1_CA.h" -#include "gnss_block_factory.h" -#include "tracking_interface.h" -#include "in_memory_configuration.h" -#include "tracking_true_obs_reader.h" -#include "tracking_dump_reader.h" -#include "signal_generator_flags.h" -#include "gnuplot_i.h" -#include "test_flags.h" - -DEFINE_bool(plot_gps_l1_tracking_test, false, "Plots results of GpsL1CADllPllTrackingTest with gnuplot"); -DEFINE_double(CN0_dBHz, std::numeric_limits::infinity(), "Enable noise generator and set the CN0 [dB-Hz]"); -DEFINE_int32(extend_correlation_symbols, 1, "Set the tracking coherent correlation to N symbols (up to 20 for GPS L1 C/A)"); +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CADllPllTrackingTest_msg_rx; @@ -87,8 +90,9 @@ void GpsL1CADllPllTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); - rx_message = message; + int64_t message = pmt::to_long(std::move(msg)); + rx_message = message; //3 -> loss of lock + //std::cout << "Received trk message: " << rx_message << std::endl; } catch (boost::bad_any_cast& e) { @@ -106,9 +110,7 @@ GpsL1CADllPllTrackingTest_msg_rx::GpsL1CADllPllTrackingTest_msg_rx() : gr::block } -GpsL1CADllPllTrackingTest_msg_rx::~GpsL1CADllPllTrackingTest_msg_rx() -{ -} +GpsL1CADllPllTrackingTest_msg_rx::~GpsL1CADllPllTrackingTest_msg_rx() = default; // ########################################################### @@ -130,21 +132,31 @@ public: std::string filename_rinex_obs = FLAGS_filename_rinex_obs; std::string filename_raw_data = FLAGS_filename_raw_data; - int configure_generator(); + int configure_generator(double CN0_dBHz, int file_idx); int generate_signal(); - void check_results_doppler(arma::vec& true_time_s, + std::vector check_results_doppler(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, - arma::vec& meas_value); - void check_results_acc_carrier_phase(arma::vec& true_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error, + double& rmse); + std::vector check_results_acc_carrier_phase(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, - arma::vec& meas_value); - void check_results_codephase(arma::vec& true_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error, + double& rmse); + std::vector check_results_codephase(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, - arma::vec& meas_value); + arma::vec& meas_value, + double& mean_error, + double& std_dev_error, + double& rmse); + bool save_mat_xy(std::vector& x, std::vector& y, std::string filename); GpsL1CADllPllTrackingTest() { factory = std::make_shared(); @@ -153,11 +165,13 @@ public: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CADllPllTrackingTest() - { - } + ~GpsL1CADllPllTrackingTest() = default; - void configure_receiver(); + void configure_receiver(double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols); gr::top_block_sptr top_block; std::shared_ptr factory; @@ -167,7 +181,7 @@ public: }; -int GpsL1CADllPllTrackingTest::configure_generator() +int GpsL1CADllPllTrackingTest::configure_generator(double CN0_dBHz, int file_idx) { // Configure signal generator generator_binary = FLAGS_generator_binary; @@ -181,10 +195,10 @@ int GpsL1CADllPllTrackingTest::configure_generator() { p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); } - p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output - p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples - p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] - p6 = std::string("-CN0_dBHz=") + std::to_string(FLAGS_CN0_dBHz); // Signal generator CN0 + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data + std::to_string(file_idx); // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] + p6 = std::string("-CN0_dBHz=") + std::to_string(CN0_dBHz); // Signal generator CN0 return 0; } @@ -193,11 +207,13 @@ int GpsL1CADllPllTrackingTest::generate_signal() { int child_status; - char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0],&p6[0], NULL}; + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], &p6[0], nullptr}; int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -212,7 +228,12 @@ int GpsL1CADllPllTrackingTest::generate_signal() } -void GpsL1CADllPllTrackingTest::configure_receiver() +void GpsL1CADllPllTrackingTest::configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols) { gnss_synchro.Channel_ID = 0; gnss_synchro.System = 'G'; @@ -220,26 +241,41 @@ void GpsL1CADllPllTrackingTest::configure_receiver() signal.copy(gnss_synchro.Signal, 2, 0); gnss_synchro.PRN = FLAGS_test_satellite_PRN; + config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); // Set Tracking config->set_property("Tracking_1C.implementation", implementation); config->set_property("Tracking_1C.item_type", "gr_complex"); - config->set_property("Tracking_1C.pll_bw_hz", "20.0"); - config->set_property("Tracking_1C.dll_bw_hz", "1.5"); + config->set_property("Tracking_1C.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); + config->set_property("Tracking_1C.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); config->set_property("Tracking_1C.early_late_space_chips", "0.5"); - config->set_property("Tracking_1C.extend_correlation_symbols", std::to_string(FLAGS_extend_correlation_symbols)); - config->set_property("Tracking_1C.pll_bw_narrow_hz", "2.0"); - config->set_property("Tracking_1C.dll_bw_narrow_hz", "1.0"); + config->set_property("Tracking_1C.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking_1C.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking_1C.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); config->set_property("Tracking_1C.early_late_space_narrow_chips", "0.5"); config->set_property("Tracking_1C.dump", "true"); config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); + + std::cout << "*****************************************\n"; + std::cout << "*** Tracking configuration parameters ***\n"; + std::cout << "*****************************************\n"; + std::cout << "pll_bw_hz: " << config->property("Tracking_1C.pll_bw_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_hz: " << config->property("Tracking_1C.dll_bw_hz", 0.0) << " Hz\n"; + std::cout << "pll_bw_narrow_hz: " << config->property("Tracking_1C.pll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_narrow_hz: " << config->property("Tracking_1C.dll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "extend_correlation_symbols: " << config->property("Tracking_1C.extend_correlation_symbols", 0) << " Symbols\n"; + std::cout << "*****************************************\n"; + std::cout << "*****************************************\n"; } -void GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec& true_time_s, +std::vector GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, - arma::vec& meas_value) + arma::vec& meas_value, + double& mean_error, + double& std_dev_error, + double& rmse) { // 1. True value interpolation to match the measurement times arma::vec true_value_interp; @@ -256,13 +292,20 @@ void GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec& true_time_s, arma::vec err; err = meas_value - true_value_interp; + + //conversion between arma::vec and std:vector + std::vector err_std_vector(err.colptr(0), err.colptr(0) + err.n_rows); + arma::vec err2 = arma::square(err); - double rmse = sqrt(arma::mean(err2)); + rmse = sqrt(arma::mean(err2)); // 3. Mean err and variance double error_mean = arma::mean(err); double error_var = arma::var(err); + mean_error = error_mean; + std_dev_error = sqrt(error_var); + // 4. Peaks double max_error = arma::max(err); double min_error = arma::min(err); @@ -273,13 +316,17 @@ void GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec& true_time_s, << ", mean=" << error_mean << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl; std::cout.precision(ss); + return err_std_vector; } -void GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(arma::vec& true_time_s, +std::vector GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, - arma::vec& meas_value) + arma::vec& meas_value, + double& mean_error, + double& std_dev_error, + double& rmse) { // 1. True value interpolation to match the measurement times arma::vec true_value_interp; @@ -294,14 +341,20 @@ void GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(arma::vec& true_ // 2. RMSE arma::vec err; - err = meas_value - true_value_interp; + //it is required to remove the initial offset in the accumulated carrier phase error + err = (meas_value - meas_value(0)) - (true_value_interp - true_value_interp(0)); arma::vec err2 = arma::square(err); - double rmse = sqrt(arma::mean(err2)); + //conversion between arma::vec and std:vector + std::vector err_std_vector(err.colptr(0), err.colptr(0) + err.n_rows); + + rmse = sqrt(arma::mean(err2)); // 3. Mean err and variance double error_mean = arma::mean(err); double error_var = arma::var(err); + mean_error = error_mean; + std_dev_error = sqrt(error_var); // 4. Peaks double max_error = arma::max(err); double min_error = arma::min(err); @@ -312,13 +365,17 @@ void GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(arma::vec& true_ << ", mean=" << error_mean << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl; std::cout.precision(ss); + return err_std_vector; } -void GpsL1CADllPllTrackingTest::check_results_codephase(arma::vec& true_time_s, +std::vector GpsL1CADllPllTrackingTest::check_results_codephase(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, - arma::vec& meas_value) + arma::vec& meas_value, + double& mean_error, + double& std_dev_error, + double& rmse) { // 1. True value interpolation to match the measurement times arma::vec true_value_interp; @@ -335,13 +392,19 @@ void GpsL1CADllPllTrackingTest::check_results_codephase(arma::vec& true_time_s, arma::vec err; err = meas_value - true_value_interp; + //conversion between arma::vec and std:vector + std::vector err_std_vector(err.colptr(0), err.colptr(0) + err.n_rows); + arma::vec err2 = arma::square(err); - double rmse = sqrt(arma::mean(err2)); + rmse = sqrt(arma::mean(err2)); // 3. Mean err and variance double error_mean = arma::mean(err); double error_var = arma::var(err); + mean_error = error_mean; + std_dev_error = sqrt(error_var); + // 4. Peaks double max_error = arma::max(err); double min_error = arma::min(err); @@ -352,229 +415,772 @@ void GpsL1CADllPllTrackingTest::check_results_codephase(arma::vec& true_time_s, << ", mean=" << error_mean << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Chips]" << std::endl; std::cout.precision(ss); + return err_std_vector; } TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults) { - // Configure the signal generator - configure_generator(); + //************************************************* + //***** STEP 2: Prepare the parameters sweep ****** + //************************************************* - // Generate signal raw signal samples and observations RINEX file - if (FLAGS_disable_generator == false) + std::vector generator_CN0_values; + + + //data containers for config param sweep + std::vector> mean_doppler_error_sweep; //swep config param and cn0 sweep + std::vector> std_dev_doppler_error_sweep; //swep config param and cn0 sweep + std::vector> rmse_doppler_sweep; //swep config param and cn0 sweep + + std::vector> mean_code_phase_error_sweep; //swep config param and cn0 sweep + std::vector> std_dev_code_phase_error_sweep; //swep config param and cn0 sweep + std::vector> rmse_code_phase_sweep; //swep config param and cn0 sweep + + std::vector> mean_carrier_phase_error_sweep; //swep config param and cn0 sweep + std::vector> std_dev_carrier_phase_error_sweep; //swep config param and cn0 sweep + std::vector> rmse_carrier_phase_sweep; //swep config param and cn0 sweep + + std::vector> trk_valid_timestamp_s_sweep; + std::vector> generator_CN0_values_sweep_copy; + + int test_satellite_PRN = 0; + double acq_delay_samples = 0.0; + double acq_doppler_hz = 0.0; + Tracking_True_Obs_Reader true_obs_data; + + + // CONFIG PARAM SWEEP LOOP + std::vector PLL_wide_bw_values; + std::vector DLL_wide_bw_values; + + + //*********************************************************** + //***** STEP 2: Tracking configuration parameters sweep ***** + //*********************************************************** + + if (FLAGS_PLL_bw_hz_start == FLAGS_PLL_bw_hz_stop) { - generate_signal(); - } - - std::chrono::time_point start, end; - - configure_receiver(); - - // open true observables log file written by the simulator - tracking_true_obs_reader true_obs_data; - int test_satellite_PRN = FLAGS_test_satellite_PRN; - std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl; - std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); - true_obs_file.append(std::to_string(test_satellite_PRN)); - true_obs_file.append(".dat"); - ASSERT_EQ(true_obs_data.open_obs_file(true_obs_file), true) << "Failure opening true observables file"; - - top_block = gr::make_top_block("Tracking test"); - - std::shared_ptr trk_ = factory->GetBlock(config, "Tracking_1C", implementation, 1, 1); - std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); //std::make_shared(config.get(), "Tracking_1C", 1, 1); - - boost::shared_ptr msg_rx = GpsL1CADllPllTrackingTest_msg_rx_make(); - - // load acquisition data based on the first epoch of the true observations - ASSERT_EQ(true_obs_data.read_binary_obs(), true) - << "Failure reading true tracking dump file." << std::endl - << "Maybe sat PRN #" + std::to_string(FLAGS_test_satellite_PRN) + - " is not available?"; - - // restart the epoch counter - true_obs_data.restart(); - - std::cout << "Initial Doppler [Hz]=" << true_obs_data.doppler_l1_hz << " Initial code delay [Chips]=" << true_obs_data.prn_delay_chips << std::endl; - gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * static_cast(baseband_sampling_freq) * GPS_L1_CA_CODE_PERIOD; - gnss_synchro.Acq_doppler_hz = true_obs_data.doppler_l1_hz; - gnss_synchro.Acq_samplestamp_samples = 0; - - ASSERT_NO_THROW({ - tracking->set_channel(gnss_synchro.Channel_ID); - }) << "Failure setting channel."; - - ASSERT_NO_THROW({ - tracking->set_gnss_synchro(&gnss_synchro); - }) << "Failure setting gnss_synchro."; - - ASSERT_NO_THROW({ - tracking->connect(top_block); - }) << "Failure connecting tracking to the top_block."; - - ASSERT_NO_THROW({ - std::string file = "./" + filename_raw_data; - const char* file_name = file.c_str(); - gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); - gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); - top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - top_block->connect(gr_interleaved_char_to_complex, 0, tracking->get_left_block(), 0); - top_block->connect(tracking->get_right_block(), 0, sink, 0); - top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - }) << "Failure connecting the blocks of tracking test."; - - tracking->start_tracking(); - - EXPECT_NO_THROW({ - start = std::chrono::system_clock::now(); - top_block->run(); // Start threads and wait - end = std::chrono::system_clock::now(); - }) << "Failure running the top_block."; - - // check results - // load the true values - long int nepoch = true_obs_data.num_epochs(); - std::cout << "True observation epochs=" << nepoch << std::endl; - - arma::vec true_timestamp_s = arma::zeros(nepoch, 1); - arma::vec true_acc_carrier_phase_cycles = arma::zeros(nepoch, 1); - arma::vec true_Doppler_Hz = arma::zeros(nepoch, 1); - arma::vec true_prn_delay_chips = arma::zeros(nepoch, 1); - arma::vec true_tow_s = arma::zeros(nepoch, 1); - - long int epoch_counter = 0; - while (true_obs_data.read_binary_obs()) - { - true_timestamp_s(epoch_counter) = true_obs_data.signal_timestamp_s; - true_acc_carrier_phase_cycles(epoch_counter) = true_obs_data.acc_carrier_phase_cycles; - true_Doppler_Hz(epoch_counter) = true_obs_data.doppler_l1_hz; - true_prn_delay_chips(epoch_counter) = true_obs_data.prn_delay_chips; - true_tow_s(epoch_counter) = true_obs_data.tow; - epoch_counter++; - } - - //load the measured values - tracking_dump_reader trk_dump; - - ASSERT_EQ(trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")), true) - << "Failure opening tracking dump file"; - - nepoch = trk_dump.num_epochs(); - std::cout << "Measured observation epochs=" << nepoch << std::endl; - - arma::vec trk_timestamp_s = arma::zeros(nepoch, 1); - arma::vec trk_acc_carrier_phase_cycles = arma::zeros(nepoch, 1); - arma::vec trk_Doppler_Hz = arma::zeros(nepoch, 1); - arma::vec trk_prn_delay_chips = arma::zeros(nepoch, 1); - - std::vector prompt; - std::vector early; - std::vector late; - std::vector promptI; - std::vector promptQ; - std::vector CN0_dBHz; - - epoch_counter = 0; - while (trk_dump.read_binary_obs()) - { - trk_timestamp_s(epoch_counter) = static_cast(trk_dump.PRN_start_sample_count) / static_cast(baseband_sampling_freq); - trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI; - trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz; - - double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast(baseband_sampling_freq), 1.0e-3) / 1.0e-3); - - trk_prn_delay_chips(epoch_counter) = delay_chips; - epoch_counter++; - prompt.push_back(trk_dump.abs_P); - early.push_back(trk_dump.abs_E); - late.push_back(trk_dump.abs_L); - promptI.push_back(trk_dump.prompt_I); - promptQ.push_back(trk_dump.prompt_Q); - CN0_dBHz.push_back(trk_dump.CN0_SNV_dB_Hz); - } - - // Align initial measurements and cut the tracking pull-in transitory - double pull_in_offset_s = 1.0; - arma::uvec initial_meas_point = arma::find(trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first"); - - trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1); - trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1); - trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0), trk_Doppler_Hz.size() - 1); - trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0), trk_prn_delay_chips.size() - 1); - - check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz); - check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips); - check_results_acc_carrier_phase(true_timestamp_s, true_acc_carrier_phase_cycles, trk_timestamp_s, trk_acc_carrier_phase_cycles); - - std::chrono::duration elapsed_seconds = end - start; - std::cout << "Signal tracking completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; - - if (FLAGS_plot_gps_l1_tracking_test == true) - { - const std::string gnuplot_executable(FLAGS_gnuplot_executable); - if (gnuplot_executable.empty()) + if (FLAGS_DLL_bw_hz_start == FLAGS_DLL_bw_hz_stop) { - std::cout << "WARNING: Although the flag plot_gps_l1_tracking_test has been set to TRUE," << std::endl; - std::cout << "gnuplot has not been found in your system." << std::endl; - std::cout << "Test results will not be plotted." << std::endl; + //NO PLL/DLL BW sweep + PLL_wide_bw_values.push_back(FLAGS_PLL_bw_hz_start); + DLL_wide_bw_values.push_back(FLAGS_DLL_bw_hz_start); } else { - try + //DLL BW Sweep + for (double dll_bw = FLAGS_DLL_bw_hz_start; dll_bw >= FLAGS_DLL_bw_hz_stop; dll_bw = dll_bw - FLAGS_DLL_bw_hz_step) { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); - std::string gnuplot_path = dir.native(); - Gnuplot::set_GNUPlotPath(gnuplot_path); - - std::vector timevec; - double t = 0.0; - for (auto it = prompt.begin(); it != prompt.end(); it++) - { - timevec.push_back(t); - t = t + GPS_L1_CA_CODE_PERIOD; - } - Gnuplot g1("linespoints"); - g1.set_title("GPS L1 C/A signal tracking correlators' output (satellite PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); - g1.set_grid(); - g1.set_xlabel("Time [s]"); - g1.set_ylabel("Correlators' output"); - g1.cmd("set key box opaque"); - unsigned int decimate = static_cast(FLAGS_plot_decimate); - g1.plot_xy(timevec, prompt, "Prompt", decimate); - g1.plot_xy(timevec, early, "Early", decimate); - g1.plot_xy(timevec, late, "Late", decimate); - g1.savetops("Correlators_outputs"); - g1.savetopdf("Correlators_outputs", 18); - g1.showonscreen(); // window output - - Gnuplot g2("points"); - g2.set_title("Constellation diagram (satellite PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); - g2.set_grid(); - g2.set_xlabel("Inphase"); - g2.set_ylabel("Quadrature"); - g2.cmd("set size ratio -1"); - g2.plot_xy(promptI, promptQ); - g2.savetops("Constellation"); - g2.savetopdf("Constellation", 18); - g2.showonscreen(); // window output - - Gnuplot g3("linespoints"); - g3.set_title("GPS L1 C/A tracking CN0 output (satellite PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); - g3.set_grid(); - g3.set_xlabel("Time [s]"); - g3.set_ylabel("Reported CN0 [dB-Hz]"); - g3.cmd("set key box opaque"); - g3.plot_xy(timevec, CN0_dBHz, "Prompt", decimate); - g3.savetops("CN0_output"); - g3.savetopdf("CN0_output", 18); - g3.showonscreen(); // window output - } - catch (const GnuplotException& ge) - { - std::cout << ge.what() << std::endl; + PLL_wide_bw_values.push_back(FLAGS_PLL_bw_hz_start); + DLL_wide_bw_values.push_back(dll_bw); } } } + else + { + //PLL BW Sweep + for (double pll_bw = FLAGS_PLL_bw_hz_start; pll_bw >= FLAGS_PLL_bw_hz_stop; pll_bw = pll_bw - FLAGS_PLL_bw_hz_step) + { + PLL_wide_bw_values.push_back(pll_bw); + DLL_wide_bw_values.push_back(FLAGS_DLL_bw_hz_start); + } + } + + //********************************************* + //***** STEP 3: Generate the input signal ***** + //********************************************* + + + std::vector cno_vector; + if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop) + { + generator_CN0_values.push_back(FLAGS_CN0_dBHz_start); + } + else + { + for (double cn0 = FLAGS_CN0_dBHz_start; cn0 > FLAGS_CN0_dBHz_stop; cn0 = cn0 - FLAGS_CN0_dB_step) + { + generator_CN0_values.push_back(cn0); + } + } + + // use generator or use an external capture file + if (FLAGS_enable_external_signal_file) + { + //todo: create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters + } + else + { + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + // Configure the signal generator + configure_generator(generator_CN0_values.at(current_cn0_idx), current_cn0_idx); + // Generate signal raw signal samples and observations RINEX file + if (FLAGS_disable_generator == false) + { + generate_signal(); + } + // open true observables log file written by the simulator + } + } + + //************************************************************ + //***** STEP 4: Configure the signal tracking parameters ***** + //************************************************************ + for (unsigned int config_idx = 0; config_idx < PLL_wide_bw_values.size(); config_idx++) + { + //CN0 LOOP + // data containers for CN0 sweep + std::vector> prompt_sweep; + std::vector> early_sweep; + std::vector> late_sweep; + std::vector> promptI_sweep; + std::vector> promptQ_sweep; + std::vector> CN0_dBHz_sweep; + std::vector> trk_timestamp_s_sweep; + + std::vector> doppler_error_sweep; + std::vector> code_phase_error_sweep; + std::vector> code_phase_error_meters_sweep; + std::vector> acc_carrier_phase_error_sweep; + + std::vector mean_doppler_error; + std::vector std_dev_doppler_error; + std::vector rmse_doppler; + std::vector mean_code_phase_error; + std::vector std_dev_code_phase_error; + std::vector rmse_code_phase; + std::vector mean_carrier_phase_error; + std::vector std_dev_carrier_phase_error; + std::vector rmse_carrier_phase; + std::vector valid_CN0_values; + + configure_receiver(PLL_wide_bw_values.at(config_idx), + DLL_wide_bw_values.at(config_idx), + FLAGS_PLL_narrow_bw_hz, + FLAGS_DLL_narrow_bw_hz, + FLAGS_extend_correlation_symbols); + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + //****************************************************************************************** + //***** Obtain the initial signal sinchronization parameters (emulating an acquisition) **** + //****************************************************************************************** + if (!FLAGS_enable_external_signal_file) + { + test_satellite_PRN = FLAGS_test_satellite_PRN; + std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); + true_obs_file.append(std::to_string(test_satellite_PRN)); + true_obs_file.append(".dat"); + true_obs_data.close_obs_file(); + ASSERT_EQ(true_obs_data.open_obs_file(true_obs_file), true) << "Failure opening true observables file"; + // load acquisition data based on the first epoch of the true observations + ASSERT_EQ(true_obs_data.read_binary_obs(), true) + << "Failure reading true tracking dump file." << std::endl + << "Maybe sat PRN #" + std::to_string(FLAGS_test_satellite_PRN) + + " is not available?"; + std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl; + std::cout << "Initial Doppler [Hz]=" << true_obs_data.doppler_l1_hz << " Initial code delay [Chips]=" << true_obs_data.prn_delay_chips << std::endl; + acq_doppler_hz = true_obs_data.doppler_l1_hz; + acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * static_cast(baseband_sampling_freq) * GPS_L1_CA_CODE_PERIOD; + // restart the epoch counter + true_obs_data.restart(); + } + + + std::chrono::time_point start, end; + + top_block = gr::make_top_block("Tracking test"); + + std::shared_ptr trk_ = factory->GetBlock(config, "Tracking_1C", implementation, 1, 1); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); + + boost::shared_ptr msg_rx = GpsL1CADllPllTrackingTest_msg_rx_make(); + + gnss_synchro.Acq_delay_samples = acq_delay_samples; + gnss_synchro.Acq_doppler_hz = acq_doppler_hz; + gnss_synchro.Acq_samplestamp_samples = 0; + + ASSERT_NO_THROW({ + tracking->set_channel(gnss_synchro.Channel_ID); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + tracking->set_gnss_synchro(&gnss_synchro); + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + tracking->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + + ASSERT_NO_THROW({ + std::string file = "./" + filename_raw_data + std::to_string(current_cn0_idx); + const char* file_name = file.c_str(); + gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); + top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block->connect(gr_interleaved_char_to_complex, 0, tracking->get_left_block(), 0); + top_block->connect(tracking->get_right_block(), 0, sink, 0); + top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting the blocks of tracking test."; + + + //******************************************************************** + //***** STEP 5: Perform the signal tracking and read the results ***** + //******************************************************************** + std::cout << "------------ START TRACKING -------------" << std::endl; + tracking->start_tracking(); + + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + }) << "Failure running the top_block."; + + std::chrono::duration elapsed_seconds = end - start; + std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds" << std::endl; + + int tracking_last_msg = msg_rx->rx_message; //save last aasynchronous tracking message in order to detect a loss of lock + + //check results + //load the measured values + Tracking_Dump_Reader trk_dump; + ASSERT_EQ(trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")), true) + << "Failure opening tracking dump file"; + + int64_t n_measured_epochs = trk_dump.num_epochs(); + //std::cout << "Measured observation epochs=" << n_measured_epochs << std::endl; + + arma::vec trk_timestamp_s = arma::zeros(n_measured_epochs, 1); + arma::vec trk_acc_carrier_phase_cycles = arma::zeros(n_measured_epochs, 1); + arma::vec trk_Doppler_Hz = arma::zeros(n_measured_epochs, 1); + arma::vec trk_prn_delay_chips = arma::zeros(n_measured_epochs, 1); + + int64_t epoch_counter = 0; + + std::vector timestamp_s; + std::vector prompt; + std::vector early; + std::vector late; + std::vector promptI; + std::vector promptQ; + std::vector CN0_dBHz; + while (trk_dump.read_binary_obs()) + { + trk_timestamp_s(epoch_counter) = static_cast(trk_dump.PRN_start_sample_count) / static_cast(baseband_sampling_freq); + trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI; + trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz; + double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast(baseband_sampling_freq), 1.0e-3) / 1.0e-3); + + trk_prn_delay_chips(epoch_counter) = delay_chips; + + timestamp_s.push_back(trk_timestamp_s(epoch_counter)); + prompt.push_back(trk_dump.abs_P); + early.push_back(trk_dump.abs_E); + late.push_back(trk_dump.abs_L); + promptI.push_back(trk_dump.prompt_I); + promptQ.push_back(trk_dump.prompt_Q); + CN0_dBHz.push_back(trk_dump.CN0_SNV_dB_Hz); + + epoch_counter++; + } + trk_timestamp_s_sweep.push_back(timestamp_s); + prompt_sweep.push_back(prompt); + early_sweep.push_back(early); + late_sweep.push_back(late); + promptI_sweep.push_back(promptI); + promptQ_sweep.push_back(promptQ); + CN0_dBHz_sweep.push_back(CN0_dBHz); + + //*********************************************************** + //***** STEP 6: Compare with true values (if available) ***** + //*********************************************************** + if (!FLAGS_enable_external_signal_file) + { + std::vector doppler_error_hz; + std::vector code_phase_error_chips; + std::vector code_phase_error_meters; + std::vector acc_carrier_phase_hz; + + try + { + // load the true values + int64_t n_true_epochs = true_obs_data.num_epochs(); + //std::cout << "True observation epochs=" << n_true_epochs << std::endl; + + arma::vec true_timestamp_s = arma::zeros(n_true_epochs, 1); + arma::vec true_acc_carrier_phase_cycles = arma::zeros(n_true_epochs, 1); + arma::vec true_Doppler_Hz = arma::zeros(n_true_epochs, 1); + arma::vec true_prn_delay_chips = arma::zeros(n_true_epochs, 1); + arma::vec true_tow_s = arma::zeros(n_true_epochs, 1); + + int64_t epoch_counter = 0; + while (true_obs_data.read_binary_obs()) + { + true_timestamp_s(epoch_counter) = true_obs_data.signal_timestamp_s; + true_acc_carrier_phase_cycles(epoch_counter) = true_obs_data.acc_carrier_phase_cycles; + true_Doppler_Hz(epoch_counter) = true_obs_data.doppler_l1_hz; + true_prn_delay_chips(epoch_counter) = true_obs_data.prn_delay_chips; + true_tow_s(epoch_counter) = true_obs_data.tow; + epoch_counter++; + } + // Align initial measurements and cut the tracking pull-in transitory + double pull_in_offset_s = FLAGS_skip_trk_transitory_s; + + arma::uvec initial_meas_point = arma::find(trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first"); + if (!initial_meas_point.empty() and tracking_last_msg != 3) + { + trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1); + trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1); + trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0), trk_Doppler_Hz.size() - 1); + trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0), trk_prn_delay_chips.size() - 1); + + + double mean_error; + double std_dev_error; + double rmse; + + valid_CN0_values.push_back(generator_CN0_values.at(current_cn0_idx)); //save the current cn0 value (valid tracking) + + doppler_error_hz = check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz, mean_error, std_dev_error, rmse); + mean_doppler_error.push_back(mean_error); + std_dev_doppler_error.push_back(std_dev_error); + rmse_doppler.push_back(rmse); + + code_phase_error_chips = check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips, mean_error, std_dev_error, rmse); + for (double code_phase_error_chip : code_phase_error_chips) + { + code_phase_error_meters.push_back(GPS_L1_CA_CHIP_PERIOD * code_phase_error_chip * GPS_C_M_S); + } + mean_code_phase_error.push_back(mean_error); + std_dev_code_phase_error.push_back(std_dev_error); + rmse_code_phase.push_back(rmse); + + acc_carrier_phase_hz = check_results_acc_carrier_phase(true_timestamp_s, true_acc_carrier_phase_cycles, trk_timestamp_s, trk_acc_carrier_phase_cycles, mean_error, std_dev_error, rmse); + mean_carrier_phase_error.push_back(mean_error); + std_dev_carrier_phase_error.push_back(std_dev_error); + rmse_carrier_phase.push_back(rmse); + + //save tracking measurement timestamps to std::vector + std::vector vector_trk_timestamp_s(trk_timestamp_s.colptr(0), trk_timestamp_s.colptr(0) + trk_timestamp_s.n_rows); + trk_valid_timestamp_s_sweep.push_back(vector_trk_timestamp_s); + + doppler_error_sweep.push_back(doppler_error_hz); + code_phase_error_sweep.push_back(code_phase_error_chips); + code_phase_error_meters_sweep.push_back(code_phase_error_meters); + acc_carrier_phase_error_sweep.push_back(acc_carrier_phase_hz); + } + else + { + std::cout << "Tracking output could not be used, possible loss of lock " << std::endl; + } + } + catch (const std::exception& ex) + { + std::cout << "Tracking output could not be used, possible loss of lock " << ex.what() << std::endl; + } + } + + } //CN0 LOOP + + if (!FLAGS_enable_external_signal_file) + { + mean_doppler_error_sweep.push_back(mean_doppler_error); + std_dev_doppler_error_sweep.push_back(std_dev_doppler_error); + rmse_doppler_sweep.push_back(rmse_doppler); + + mean_code_phase_error_sweep.push_back(mean_code_phase_error); + std_dev_code_phase_error_sweep.push_back(std_dev_code_phase_error); + rmse_code_phase_sweep.push_back(rmse_code_phase); + + mean_carrier_phase_error_sweep.push_back(mean_carrier_phase_error); + std_dev_carrier_phase_error_sweep.push_back(std_dev_carrier_phase_error); + rmse_carrier_phase_sweep.push_back(rmse_carrier_phase); + + //make a copy of the CN0 vector for each configuration parameter in order to filter the loss of lock events + generator_CN0_values_sweep_copy.push_back(valid_CN0_values); + } + + //******************************** + //***** STEP 7: Plot results ***** + //******************************** + if (FLAGS_plot_gps_l1_tracking_test == true) + { + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if (gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag plot_gps_l1_tracking_test has been set to TRUE," << std::endl; + std::cout << "gnuplot has not been found in your system." << std::endl; + std::cout << "Test results will not be plotted." << std::endl; + } + else + { + try + { + boost::filesystem::path p(gnuplot_executable); + boost::filesystem::path dir = p.parent_path(); + const std::string& gnuplot_path = dir.native(); + Gnuplot::set_GNUPlotPath(gnuplot_path); + auto decimate = static_cast(FLAGS_plot_decimate); + + if (FLAGS_plot_detail_level >= 2) + { + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + Gnuplot g1("linespoints"); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } + g1.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, " + "PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz" + "GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g1.set_grid(); + g1.set_xlabel("Time [s]"); + g1.set_ylabel("Correlators' output"); + //g1.cmd("set key box opaque"); + g1.plot_xy(trk_timestamp_s_sweep.at(current_cn0_idx), prompt_sweep.at(current_cn0_idx), "Prompt", decimate); + g1.plot_xy(trk_timestamp_s_sweep.at(current_cn0_idx), early_sweep.at(current_cn0_idx), "Early", decimate); + g1.plot_xy(trk_timestamp_s_sweep.at(current_cn0_idx), late_sweep.at(current_cn0_idx), "Late", decimate); + g1.set_legend(); + g1.savetops("Correlators_outputs" + std::to_string(generator_CN0_values.at(current_cn0_idx))); + g1.savetopdf("Correlators_outputs" + std::to_string(generator_CN0_values.at(current_cn0_idx)), 18); + } + Gnuplot g2("points"); + if (FLAGS_show_plots) + { + g2.showonscreen(); // window output + } + else + { + g2.disablescreen(); + } + g2.set_multiplot(ceil(static_cast(generator_CN0_values.size()) / 2.0), + ceil(static_cast(generator_CN0_values.size()) / 2)); + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + g2.reset_plot(); + g2.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz Constellation " + "PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz" + "GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g2.set_grid(); + g2.set_xlabel("Inphase"); + g2.set_ylabel("Quadrature"); + //g2.cmd("set size ratio -1"); + g2.plot_xy(promptI_sweep.at(current_cn0_idx), promptQ_sweep.at(current_cn0_idx)); + } + g2.unset_multiplot(); + g2.savetops("Constellation"); + g2.savetopdf("Constellation", 18); + + Gnuplot g3("linespoints"); + g3.set_title("GPS L1 C/A tracking CN0 output (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Reported CN0 [dB-Hz]"); + g3.cmd("set key box opaque"); + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + g3.plot_xy(trk_timestamp_s_sweep.at(current_cn0_idx), CN0_dBHz_sweep.at(current_cn0_idx), + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate); + } + g3.set_legend(); + g3.savetops("CN0_output"); + g3.savetopdf("CN0_output", 18); + if (FLAGS_show_plots) + { + g3.showonscreen(); // window output + } + else + { + g3.disablescreen(); + } + } + + //PLOT ERROR FIGURES (only if it is used the signal generator) + if (!FLAGS_enable_external_signal_file) + { + if (FLAGS_plot_detail_level >= 1) + { + Gnuplot g5("points"); + if (FLAGS_show_plots) + { + g5.showonscreen(); // window output + } + else + { + g5.disablescreen(); + } + g5.set_title("Code delay error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g5.set_grid(); + g5.set_xlabel("Time [s]"); + g5.set_ylabel("Code delay error [Chips]"); + + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++) + { + try + { + g5.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), code_phase_error_sweep.at(current_cn0_idx), + std::to_string(static_cast(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz]", decimate); + } + catch (const GnuplotException& ge) + { + } + save_mat_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), + code_phase_error_sweep.at(current_cn0_idx), + "Code_error_chips" + std::to_string(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)) + + std::to_string(PLL_wide_bw_values.at(config_idx)) + "_" + std::to_string(DLL_wide_bw_values.at(config_idx))); + } + g5.set_legend(); + g5.set_legend(); + g5.savetops("Code_error_chips"); + g5.savetopdf("Code_error_chips", 18); + + Gnuplot g5b("points"); + if (FLAGS_show_plots) + { + g5b.showonscreen(); // window output + } + else + { + g5b.disablescreen(); + } + g5b.set_title("Code delay error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g5b.set_grid(); + g5b.set_xlabel("Time [s]"); + g5b.set_ylabel("Code delay error [meters]"); + + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++) + { + try + { + g5b.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), code_phase_error_meters_sweep.at(current_cn0_idx), + std::to_string(static_cast(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz]", decimate); + } + catch (const GnuplotException& ge) + { + } + save_mat_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), + code_phase_error_sweep.at(current_cn0_idx), + "Code_error_meters" + std::to_string(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)) + + std::to_string(PLL_wide_bw_values.at(config_idx)) + "_" + std::to_string(DLL_wide_bw_values.at(config_idx))); + } + g5b.set_legend(); + g5b.set_legend(); + g5b.savetops("Code_error_meters"); + g5b.savetopdf("Code_error_meters", 18); + + + Gnuplot g6("points"); + if (FLAGS_show_plots) + { + g6.showonscreen(); // window output + } + else + { + g6.disablescreen(); + } + g6.set_title("Accumulated carrier phase error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g6.set_grid(); + g6.set_xlabel("Time [s]"); + g6.set_ylabel("Accumulated carrier phase error [Cycles]"); + + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++) + { + try + { + g6.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), acc_carrier_phase_error_sweep.at(current_cn0_idx), + std::to_string(static_cast(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz]", decimate); + } + catch (const GnuplotException& ge) + { + } + save_mat_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), + acc_carrier_phase_error_sweep.at(current_cn0_idx), + "Carrier_phase_error" + std::to_string(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)) + + std::to_string(PLL_wide_bw_values.at(config_idx)) + "_" + std::to_string(DLL_wide_bw_values.at(config_idx))); + } + g6.set_legend(); + g6.set_legend(); + g6.savetops("Acc_carrier_phase_error_cycles"); + g6.savetopdf("Acc_carrier_phase_error_cycles", 18); + + Gnuplot g4("points"); + if (FLAGS_show_plots) + { + g4.showonscreen(); // window output + } + else + { + g4.disablescreen(); + } + g4.set_multiplot(ceil(static_cast(generator_CN0_values.size()) / 2.0), + ceil(static_cast(generator_CN0_values.size()) / 2)); + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++) + { + g4.reset_plot(); + g4.set_title("Dopper error" + std::to_string(static_cast(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz], PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g4.set_grid(); + //g4.cmd("set key box opaque"); + g4.set_xlabel("Time [s]"); + g4.set_ylabel("Dopper error [Hz]"); + try + { + g4.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), doppler_error_sweep.at(current_cn0_idx), + std::to_string(static_cast(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz]", decimate); + } + catch (const GnuplotException& ge) + { + } + + save_mat_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), + doppler_error_sweep.at(current_cn0_idx), + "Doppler_error" + std::to_string(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)) + + std::to_string(PLL_wide_bw_values.at(config_idx)) + "_" + std::to_string(DLL_wide_bw_values.at(config_idx))); + } + g4.unset_multiplot(); + g4.savetops("Doppler_error_hz"); + g4.savetopdf("Doppler_error_hz", 18); + } + } + } + catch (const GnuplotException& ge) + { + std::cout << ge.what() << std::endl; + } + } + } + } + + if (FLAGS_plot_gps_l1_tracking_test == true) + { + std::cout << "Ploting performance metrics..." << std::endl; + try + { + if (generator_CN0_values.size() > 1) + { + //plot metrics + + Gnuplot g7("linespoints"); + if (FLAGS_show_plots) + { + g7.showonscreen(); // window output + } + else + { + g7.disablescreen(); + } + g7.set_title("Doppler error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g7.set_grid(); + g7.set_xlabel("CN0 [dB-Hz]"); + g7.set_ylabel("Doppler error [Hz]"); + g7.set_pointsize(2); + g7.cmd("set termoption lw 2"); + g7.cmd("set key box opaque"); + for (unsigned int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++) + { + g7.plot_xy_err(generator_CN0_values_sweep_copy.at(config_sweep_idx), + mean_doppler_error_sweep.at(config_sweep_idx), + std_dev_doppler_error_sweep.at(config_sweep_idx), + "PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) + + +"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz"); + + //matlab save + save_mat_xy(generator_CN0_values_sweep_copy.at(config_sweep_idx), + rmse_doppler_sweep.at(config_sweep_idx), + "RMSE_Doppler_CN0_Sweep_PLL_DLL" + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) + + +"_" + std::to_string(DLL_wide_bw_values.at(config_sweep_idx))); + } + g7.savetops("Doppler_error_metrics"); + g7.savetopdf("Doppler_error_metrics", 18); + + + Gnuplot g8("linespoints"); + g8.set_title("Accumulated carrier phase error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g8.set_grid(); + g8.set_xlabel("CN0 [dB-Hz]"); + g8.set_ylabel("Accumulated Carrier Phase error [Cycles]"); + g8.cmd("set key box opaque"); + g8.cmd("set termoption lw 2"); + g8.set_pointsize(2); + for (unsigned int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++) + { + g8.plot_xy_err(generator_CN0_values_sweep_copy.at(config_sweep_idx), + mean_carrier_phase_error_sweep.at(config_sweep_idx), + std_dev_carrier_phase_error_sweep.at(config_sweep_idx), + "PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) + + +"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz"); + //matlab save + save_mat_xy(generator_CN0_values_sweep_copy.at(config_sweep_idx), + rmse_carrier_phase_sweep.at(config_sweep_idx), + "RMSE_Carrier_Phase_CN0_Sweep_PLL_DLL" + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) + + +"_" + std::to_string(DLL_wide_bw_values.at(config_sweep_idx))); + } + g8.savetops("Carrier_error_metrics"); + g8.savetopdf("Carrier_error_metrics", 18); + + Gnuplot g9("linespoints"); + g9.set_title("Code Phase error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g9.set_grid(); + g9.set_xlabel("CN0 [dB-Hz]"); + g9.set_ylabel("Code Phase error [Chips]"); + g9.cmd("set key box opaque"); + g9.cmd("set termoption lw 2"); + g9.set_pointsize(2); + for (unsigned int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++) + { + g9.plot_xy_err(generator_CN0_values_sweep_copy.at(config_sweep_idx), + mean_code_phase_error_sweep.at(config_sweep_idx), + std_dev_code_phase_error_sweep.at(config_sweep_idx), + "PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) + + +"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz"); + //matlab save + save_mat_xy(generator_CN0_values_sweep_copy.at(config_sweep_idx), + rmse_code_phase_sweep.at(config_sweep_idx), + "RMSE_Code_Phase_CN0_Sweep_PLL_DLL" + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) + + +"_" + std::to_string(DLL_wide_bw_values.at(config_sweep_idx))); + } + g9.savetops("Code_error_metrics"); + g9.savetopdf("Code_error_metrics", 18); + } + } + catch (const GnuplotException& ge) + { + std::cout << ge.what() << std::endl; + } + } +} + +bool GpsL1CADllPllTrackingTest::save_mat_xy(std::vector& x, std::vector& y, std::string filename) +{ + try + { + // WRITE MAT FILE + mat_t* matfp; + matvar_t* matvar; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != nullptr) + { + size_t dims[2] = {1, x.size()}; + matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &y[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + return true; + } + catch (const std::exception& ex) + { + return false; + } } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc index 7b7275eb0..78303a1cf 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc @@ -2,7 +2,7 @@ * \file gps_l1_ca_dll_pll_tracking_test.cc * \brief This class implements a tracking test for Galileo_E5a_DLL_PLL_Tracking * implementation based on some input parameters. - * \author Marc Majoral, 2017. mmajoral(at)cttc.cat + * \author Marc Majoral, 2017. mmajoral(at)cttc.cat * \author Javier Arribas, 2017. jarribas(at)cttc.es * * @@ -31,47 +31,51 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include -#include -#include -#include // to test the FPGA we have to create a simultaneous task to send the samples using the DMA and stop the test -#include // FPGA read input file -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "GPS_L1_CA.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "tracking_interface.h" -#include "in_memory_configuration.h" #include "gnss_synchro.h" -//#include "gps_l1_ca_dll_pll_c_aid_tracking_fpga.h" #include "gps_l1_ca_dll_pll_tracking_fpga.h" -#include "tracking_true_obs_reader.h" -#include "tracking_dump_reader.h" -#include "signal_generator_flags.h" +#include "in_memory_configuration.h" #include "interleaved_byte_to_complex_short.h" +#include "signal_generator_flags.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_true_obs_reader.h" +#include +#include // to test the FPGA we have to create a simultaneous task to send the samples using the DMA and stop the test +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // FPGA read input file +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif -#define DMA_TRACK_TRANSFER_SIZE 2046 // DMA transfer size for tracking -#define MIN_SAMPLES_REMAINING 20000 // number of remaining samples in the DMA that causes the CPU to stop the flowgraph (it has to be a bit alrger than 2x max packet size) -#define FIVE_SECONDS 5000000 // five seconds in microseconds +#define DMA_TRACK_TRANSFER_SIZE 2046 // DMA transfer size for tracking +#define MIN_SAMPLES_REMAINING 20000 // number of remaining samples in the DMA that causes the CPU to stop the flowgraph (it has to be a bit alrger than 2x max packet size) +#define FIVE_SECONDS 5000000 // five seconds in microseconds void send_tracking_gps_input_samples(FILE *rx_signal_file, - int num_remaining_samples, gr::top_block_sptr top_block) + int num_remaining_samples, const gr::top_block_sptr &top_block) { - int num_samples_transferred = 0; // number of samples that have been transferred to the DMA so far - static int flowgraph_stopped = 0; // flag to indicate if the flowgraph is stopped already - char *buffer_DMA; // temporary buffer to store the samples to be sent to the DMA - int dma_descr; // DMA descriptor + int num_samples_transferred = 0; // number of samples that have been transferred to the DMA so far + static int flowgraph_stopped = 0; // flag to indicate if the flowgraph is stopped already + char *buffer_DMA; // temporary buffer to store the samples to be sent to the DMA + int dma_descr; // DMA descriptor dma_descr = open("/dev/loop_tx", O_WRONLY); if (dma_descr < 0) { @@ -79,7 +83,7 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file, exit(1); } - buffer_DMA = (char *) malloc(DMA_TRACK_TRANSFER_SIZE); + buffer_DMA = (char *)malloc(DMA_TRACK_TRANSFER_SIZE); if (!buffer_DMA) { fprintf(stderr, "Memory error!"); @@ -98,8 +102,7 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file, } if (num_remaining_samples > DMA_TRACK_TRANSFER_SIZE) { - - fread(buffer_DMA, DMA_TRACK_TRANSFER_SIZE, 1,rx_signal_file); + fread(buffer_DMA, DMA_TRACK_TRANSFER_SIZE, 1, rx_signal_file); assert(DMA_TRACK_TRANSFER_SIZE == write(dma_descr, &buffer_DMA[0], DMA_TRACK_TRANSFER_SIZE)); num_remaining_samples = num_remaining_samples - DMA_TRACK_TRANSFER_SIZE; @@ -121,11 +124,11 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file, // thread that sends the samples to the FPGA -void thread(gr::top_block_sptr top_block, const char * file_name) +void sending_thread(gr::top_block_sptr top_block, const char *file_name) { // file descriptor - FILE *rx_signal_file; // file descriptor - int file_length; // length of the file containing the received samples + FILE *rx_signal_file; // file descriptor + int file_length; // length of the file containing the received samples rx_signal_file = fopen(file_name, "rb"); if (!rx_signal_file) @@ -137,7 +140,7 @@ void thread(gr::top_block_sptr top_block, const char * file_name) file_length = ftell(rx_signal_file); fseek(rx_signal_file, 0, SEEK_SET); - usleep(FIVE_SECONDS); // wait for some time to give time to the other thread to program the device + usleep(FIVE_SECONDS); // wait for some time to give time to the other thread to program the device //send_tracking_gps_input_samples(dma_descr, rx_signal_file, file_length); send_tracking_gps_input_samples(rx_signal_file, file_length, top_block); @@ -149,7 +152,7 @@ void thread(gr::top_block_sptr top_block, const char * file_name) // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CADllPllTrackingTestFpga_msg_rx; -typedef boost::shared_ptr GpsL1CADllPllTrackingTestFpga_msg_rx_sptr; +using GpsL1CADllPllTrackingTestFpga_msg_rx_sptr = boost::shared_ptr; GpsL1CADllPllTrackingTestFpga_msg_rx_sptr GpsL1CADllPllTrackingTestFpga_msg_rx_make(); @@ -163,14 +166,14 @@ private: public: int rx_message; - ~GpsL1CADllPllTrackingTestFpga_msg_rx(); //!< Default destructor + ~GpsL1CADllPllTrackingTestFpga_msg_rx(); //!< Default destructor }; GpsL1CADllPllTrackingTestFpga_msg_rx_sptr GpsL1CADllPllTrackingTestFpga_msg_rx_make() { return GpsL1CADllPllTrackingTestFpga_msg_rx_sptr( - new GpsL1CADllPllTrackingTestFpga_msg_rx()); + new GpsL1CADllPllTrackingTestFpga_msg_rx()); } @@ -178,10 +181,10 @@ void GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } - catch (boost::bad_any_cast& e) + catch (boost::bad_any_cast &e) { LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; rx_message = 0; @@ -189,22 +192,20 @@ void GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg) } -GpsL1CADllPllTrackingTestFpga_msg_rx::GpsL1CADllPllTrackingTestFpga_msg_rx() : - gr::block("GpsL1CADllPllTrackingTestFpga_msg_rx", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)) +GpsL1CADllPllTrackingTestFpga_msg_rx::GpsL1CADllPllTrackingTestFpga_msg_rx() : gr::block("GpsL1CADllPllTrackingTestFpga_msg_rx", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), - boost::bind( - &GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events, - this, _1)); + boost::bind( + &GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events, + this, _1)); rx_message = 0; } -GpsL1CADllPllTrackingTestFpga_msg_rx::~GpsL1CADllPllTrackingTestFpga_msg_rx() -{} +GpsL1CADllPllTrackingTestFpga_msg_rx::~GpsL1CADllPllTrackingTestFpga_msg_rx() = default; // ########################################################### @@ -226,12 +227,12 @@ public: int configure_generator(); int generate_signal(); - void check_results_doppler(arma::vec & true_time_s, arma::vec & true_value, - arma::vec & meas_time_s, arma::vec & meas_value); - void check_results_acc_carrier_phase(arma::vec & true_time_s, - arma::vec & true_value, arma::vec & meas_time_s, arma::vec & meas_value); - void check_results_codephase(arma::vec & true_time_s, arma::vec & true_value, - arma::vec & meas_time_s, arma::vec & meas_value); + void check_results_doppler(arma::vec &true_time_s, arma::vec &true_value, + arma::vec &meas_time_s, arma::vec &meas_value); + void check_results_acc_carrier_phase(arma::vec &true_time_s, + arma::vec &true_value, arma::vec &meas_time_s, arma::vec &meas_value); + void check_results_codephase(arma::vec &true_time_s, arma::vec &true_value, + arma::vec &meas_time_s, arma::vec &meas_value); GpsL1CADllPllTrackingTestFpga() { @@ -241,9 +242,7 @@ public: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CADllPllTrackingTestFpga() - { - } + ~GpsL1CADllPllTrackingTestFpga() = default; void configure_receiver(); @@ -263,16 +262,15 @@ int GpsL1CADllPllTrackingTestFpga::configure_generator() p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; if (FLAGS_dynamic_position.empty()) { - p2 = std::string("-static_position=") + FLAGS_static_position - + std::string(",") + std::to_string(FLAGS_duration * 10); + p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10); } else { p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); } - p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output - p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples - p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] return 0; } @@ -281,8 +279,8 @@ int GpsL1CADllPllTrackingTestFpga::generate_signal() { int child_status; - char * const parmList[] = { &generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], - &p4[0], &p5[0], NULL }; + char *const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], + &p4[0], &p5[0], nullptr}; int pid; if ((pid = fork()) == -1) @@ -310,14 +308,13 @@ void GpsL1CADllPllTrackingTestFpga::configure_receiver() gnss_synchro.PRN = FLAGS_test_satellite_PRN; config->set_property("GNSS-SDR.internal_fs_sps", - std::to_string(baseband_sampling_freq)); + std::to_string(baseband_sampling_freq)); // Set Tracking //config->set_property("Tracking_1C.implementation", // "GPS_L1_CA_DLL_PLL_C_Aid_Tracking_Fpga"); config->set_property("Tracking_1C.implementation", - "GPS_L1_CA_DLL_PLL_Tracking_Fpga"); + "GPS_L1_CA_DLL_PLL_Tracking_Fpga"); config->set_property("Tracking_1C.item_type", "cshort"); - config->set_property("Tracking_1C.if", "0"); config->set_property("Tracking_1C.dump", "true"); config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); config->set_property("Tracking_1C.pll_bw_hz", "30.0"); @@ -328,8 +325,8 @@ void GpsL1CADllPllTrackingTestFpga::configure_receiver() } -void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec & true_time_s, - arma::vec & true_value, arma::vec & meas_time_s, arma::vec & meas_value) +void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec &true_time_s, + arma::vec &true_value, arma::vec &meas_time_s, arma::vec &meas_value) { //1. True value interpolation to match the measurement times arma::vec true_value_interp; @@ -362,13 +359,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec & true_time_ << ", mean=" << error_mean << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl; - std::cout.precision (ss); + std::cout.precision(ss); } void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase( - arma::vec & true_time_s, arma::vec & true_value, arma::vec & meas_time_s, - arma::vec & meas_value) + arma::vec &true_time_s, arma::vec &true_value, arma::vec &meas_time_s, + arma::vec &meas_value) { //1. True value interpolation to match the measurement times arma::vec true_value_interp; @@ -401,13 +398,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase( << ", mean=" << error_mean << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl; - std::cout.precision (ss); + std::cout.precision(ss); } void GpsL1CADllPllTrackingTestFpga::check_results_codephase( - arma::vec & true_time_s, arma::vec & true_value, arma::vec & meas_time_s, - arma::vec & meas_value) + arma::vec &true_time_s, arma::vec &true_value, arma::vec &meas_time_s, + arma::vec &meas_value) { //1. True value interpolation to match the measurement times arma::vec true_value_interp; @@ -439,7 +436,7 @@ void GpsL1CADllPllTrackingTestFpga::check_results_codephase( << ", mean=" << error_mean << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Chips]" << std::endl; - std::cout.precision (ss); + std::cout.precision(ss); } @@ -456,34 +453,36 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) configure_receiver(); //open true observables log file written by the simulator - tracking_true_obs_reader true_obs_data; + Tracking_True_Obs_Reader true_obs_data; int test_satellite_PRN = FLAGS_test_satellite_PRN; std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl; std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); true_obs_file.append(std::to_string(test_satellite_PRN)); true_obs_file.append(".dat"); ASSERT_NO_THROW( + { + if (true_obs_data.open_obs_file(true_obs_file) == false) { - if (true_obs_data.open_obs_file(true_obs_file) == false) - { - throw std::exception(); - }; - }) << "Failure opening true observables file"; + throw std::exception(); + }; + }) + << "Failure opening true observables file"; top_block = gr::make_top_block("Tracking test"); //std::shared_ptr tracking = std::make_shared (config.get(), "Tracking_1C", 1, 1); - std::shared_ptr tracking = std::make_shared (config.get(), "Tracking_1C", 1, 1); + std::shared_ptr tracking = std::make_shared(config.get(), "Tracking_1C", 1, 1); boost::shared_ptr msg_rx = GpsL1CADllPllTrackingTestFpga_msg_rx_make(); // load acquisition data based on the first epoch of the true observations ASSERT_NO_THROW( + { + if (true_obs_data.read_binary_obs() == false) { - if (true_obs_data.read_binary_obs() == false) - { - throw std::exception(); - }; - }) << "Failure reading true observables file"; + throw std::exception(); + }; + }) + << "Failure reading true observables file"; //restart the epoch counter true_obs_data.restart(); @@ -492,59 +491,61 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) << " Initial code delay [Chips]=" << true_obs_data.prn_delay_chips << std::endl; - gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) - * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; + gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; gnss_synchro.Acq_doppler_hz = true_obs_data.doppler_l1_hz; gnss_synchro.Acq_samplestamp_samples = 0; ASSERT_NO_THROW( - { - tracking->set_channel(gnss_synchro.Channel_ID); - }) << "Failure setting channel."; + { + tracking->set_channel(gnss_synchro.Channel_ID); + }) + << "Failure setting channel."; ASSERT_NO_THROW( - { - tracking->set_gnss_synchro(&gnss_synchro); - }) << "Failure setting gnss_synchro."; + { + tracking->set_gnss_synchro(&gnss_synchro); + }) + << "Failure setting gnss_synchro."; ASSERT_NO_THROW( - { - tracking->connect(top_block); - }) << "Failure connecting tracking to the top_block."; + { + tracking->connect(top_block); + }) + << "Failure connecting tracking to the top_block."; ASSERT_NO_THROW( - { - gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); - top_block->connect(tracking->get_right_block(), 0, sink, 0); - top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - }) << "Failure connecting the blocks of tracking test."; + { + gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); + top_block->connect(tracking->get_right_block(), 0, sink, 0); + top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) + << "Failure connecting the blocks of tracking test."; tracking->start_tracking(); // assemble again the file name in a null terminated string (not available by default in the main program flow) std::string file = "./" + filename_raw_data; - const char * file_name = file.c_str(); + const char *file_name = file.c_str(); // start thread that sends the DMA samples to the FPGA - boost::thread t - { thread, top_block, file_name }; + boost::thread t{sending_thread, top_block, file_name}; EXPECT_NO_THROW( - { - start = std::chrono::system_clock::now(); - top_block->run(); // Start threads and wait - //tracking->reset();// unlock the channel - end = std::chrono::system_clock::now(); - elapsed_seconds = end - start; - }) << "Failure running the top_block."; + { + start = std::chrono::system_clock::now(); + top_block->run(); // Start threads and wait + //tracking->reset();// unlock the channel + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + }) + << "Failure running the top_block."; // wait until child thread terminates t.join(); //check results //load the true values - long int nepoch = true_obs_data.num_epochs(); + int64_t nepoch = true_obs_data.num_epochs(); std::cout << "True observation epochs=" << nepoch << std::endl; arma::vec true_timestamp_s = arma::zeros(nepoch, 1); @@ -553,7 +554,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) arma::vec true_prn_delay_chips = arma::zeros(nepoch, 1); arma::vec true_tow_s = arma::zeros(nepoch, 1); - long int epoch_counter = 0; + int64_t epoch_counter = 0; while (true_obs_data.read_binary_obs()) { true_timestamp_s(epoch_counter) = true_obs_data.signal_timestamp_s; @@ -565,14 +566,15 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) } //load the measured values - tracking_dump_reader trk_dump; + Tracking_Dump_Reader trk_dump; ASSERT_NO_THROW( + { + if (trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")) == false) { - if (trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")) == false) - { - throw std::exception(); - }; - }) << "Failure opening tracking dump file"; + throw std::exception(); + }; + }) + << "Failure opening tracking dump file"; nepoch = trk_dump.num_epochs(); std::cout << "Measured observation epochs=" << nepoch << std::endl; @@ -585,14 +587,11 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) epoch_counter = 0; while (trk_dump.read_binary_obs()) { - trk_timestamp_s(epoch_counter) = static_cast(trk_dump.PRN_start_sample_count) - / static_cast(baseband_sampling_freq); + trk_timestamp_s(epoch_counter) = static_cast(trk_dump.PRN_start_sample_count) / static_cast(baseband_sampling_freq); trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI; trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz; - double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS - * (fmod( (static_cast(trk_dump.PRN_start_sample_count) + trk_dump.aux1) - / static_cast(baseband_sampling_freq), 1.0e-3) / 1.0e-3); + double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast(baseband_sampling_freq), 1.0e-3) / 1.0e-3); trk_prn_delay_chips(epoch_counter) = delay_chips; epoch_counter++; @@ -600,7 +599,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) //Align initial measurements and cut the tracking pull-in transitory double pull_in_offset_s = 1.0; - arma::uvec initial_meas_point = arma::find( trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first"); + arma::uvec initial_meas_point = arma::find(trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first"); trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1); trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1); @@ -610,8 +609,8 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz); check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips); check_results_acc_carrier_phase(true_timestamp_s, - true_acc_carrier_phase_cycles, trk_timestamp_s, - trk_acc_carrier_phase_cycles); + true_acc_carrier_phase_cycles, trk_timestamp_s, + trk_acc_carrier_phase_cycles); std::cout << "Signal tracking completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc new file mode 100644 index 000000000..f1046a12b --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc @@ -0,0 +1,585 @@ +/*! + * \file gps_l1_ca_kf_tracking_test.cc + * \brief This class implements a tracking test for GPS_L1_CA_KF_Tracking + * implementation based on some input parameters. + * \author Carles Fernandez, 2018 + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "GPS_L1_CA.h" +#include "gnss_block_factory.h" +#include "gnss_sdr_flags.h" +#include "gnuplot_i.h" +#include "in_memory_configuration.h" +#include "signal_generator_flags.h" +#include "test_flags.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_true_obs_reader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif + +DEFINE_bool(plot_gps_l1_kf_tracking_test, false, "Plots results of GpsL1CAKfTrackingTest with gnuplot"); + + +// ######## GNURADIO BLOCK MESSAGE RECEVER ######### +class GpsL1CAKfTrackingTest_msg_rx; + +typedef boost::shared_ptr GpsL1CAKfTrackingTest_msg_rx_sptr; + +GpsL1CAKfTrackingTest_msg_rx_sptr GpsL1CAKfTrackingTest_msg_rx_make(); + +class GpsL1CAKfTrackingTest_msg_rx : public gr::block +{ +private: + friend GpsL1CAKfTrackingTest_msg_rx_sptr GpsL1CAKfTrackingTest_msg_rx_make(); + void msg_handler_events(pmt::pmt_t msg); + GpsL1CAKfTrackingTest_msg_rx(); + +public: + int rx_message; + ~GpsL1CAKfTrackingTest_msg_rx(); //!< Default destructor +}; + + +GpsL1CAKfTrackingTest_msg_rx_sptr GpsL1CAKfTrackingTest_msg_rx_make() +{ + return GpsL1CAKfTrackingTest_msg_rx_sptr(new GpsL1CAKfTrackingTest_msg_rx()); +} + + +void GpsL1CAKfTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg) +{ + try + { + long int message = pmt::to_long(std::move(msg)); + rx_message = message; + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + + +GpsL1CAKfTrackingTest_msg_rx::GpsL1CAKfTrackingTest_msg_rx() : gr::block("GpsL1CAKfTrackingTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL1CAKfTrackingTest_msg_rx::msg_handler_events, this, _1)); + rx_message = 0; +} + + +GpsL1CAKfTrackingTest_msg_rx::~GpsL1CAKfTrackingTest_msg_rx() = default; + + +// ########################################################### + +class GpsL1CAKfTrackingTest : public ::testing::Test +{ +public: + std::string generator_binary; + std::string p1; + std::string p2; + std::string p3; + std::string p4; + std::string p5; + + std::string implementation = "GPS_L1_CA_KF_Tracking"; + + const int baseband_sampling_freq = FLAGS_fs_gen_sps; + + std::string filename_rinex_obs = FLAGS_filename_rinex_obs; + std::string filename_raw_data = FLAGS_filename_raw_data; + + int configure_generator(); + int generate_signal(); + void check_results_doppler(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value); + void check_results_acc_carrier_phase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value); + void check_results_codephase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value); + + GpsL1CAKfTrackingTest() + { + factory = std::make_shared(); + config = std::make_shared(); + item_size = sizeof(gr_complex); + gnss_synchro = Gnss_Synchro(); + } + + ~GpsL1CAKfTrackingTest() = default; + + void configure_receiver(); + + gr::top_block_sptr top_block; + std::shared_ptr factory; + std::shared_ptr config; + Gnss_Synchro gnss_synchro; + size_t item_size; +}; + + +int GpsL1CAKfTrackingTest::configure_generator() +{ + // Configure signal generator + generator_binary = FLAGS_generator_binary; + + p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; + if (FLAGS_dynamic_position.empty()) + { + p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10); + } + else + { + p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); + } + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); // Baseband sampling frequency [MSps] + return 0; +} + + +int GpsL1CAKfTrackingTest::generate_signal() +{ + int child_status; + + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], nullptr}; + + int pid; + if ((pid = fork()) == -1) + { + perror("fork err"); + } + else if (pid == 0) + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv err." << std::endl; + std::terminate(); + } + + waitpid(pid, &child_status, 0); + + std::cout << "Signal and Observables RINEX and RAW files created." << std::endl; + return 0; +} + + +void GpsL1CAKfTrackingTest::configure_receiver() +{ + gnss_synchro.Channel_ID = 0; + gnss_synchro.System = 'G'; + std::string signal = "1C"; + signal.copy(gnss_synchro.Signal, 2, 0); + gnss_synchro.PRN = FLAGS_test_satellite_PRN; + + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + // Set Tracking + config->set_property("Tracking_1C.implementation", implementation); + config->set_property("Tracking_1C.item_type", "gr_complex"); + if (FLAGS_dll_bw_hz != 0.0) + { + config->set_property("Tracking_1C.dll_bw_hz", std::to_string(FLAGS_dll_bw_hz)); + } + else + { + config->set_property("Tracking_1C.dll_bw_hz", "2.0"); + } + config->set_property("Tracking_1C.early_late_space_chips", "0.5"); + config->set_property("Tracking_1C.extend_correlation_ms", "1"); + config->set_property("Tracking_1C.dump", "true"); + config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); +} + + +void GpsL1CAKfTrackingTest::check_results_doppler(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value) +{ + // 1. True value interpolation to match the measurement times + arma::vec true_value_interp; + arma::uvec true_time_s_valid = find(true_time_s > 0); + true_time_s = true_time_s(true_time_s_valid); + true_value = true_value(true_time_s_valid); + arma::uvec meas_time_s_valid = find(meas_time_s > 0); + meas_time_s = meas_time_s(meas_time_s_valid); + meas_value = meas_value(meas_time_s_valid); + arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp); + + // 2. RMSE + arma::vec err; + + err = meas_value - true_value_interp; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + // 3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + // 5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << "TRK Doppler RMSE=" << rmse + << ", mean=" << error_mean + << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl; + std::cout.precision(ss); +} + + +void GpsL1CAKfTrackingTest::check_results_acc_carrier_phase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value) +{ + // 1. True value interpolation to match the measurement times + arma::vec true_value_interp; + arma::uvec true_time_s_valid = find(true_time_s > 0); + true_time_s = true_time_s(true_time_s_valid); + true_value = true_value(true_time_s_valid); + arma::uvec meas_time_s_valid = find(meas_time_s > 0); + meas_time_s = meas_time_s(meas_time_s_valid); + meas_value = meas_value(meas_time_s_valid); + + arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp); + + // 2. RMSE + arma::vec err; + err = meas_value - true_value_interp; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + // 3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + // 5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << "TRK acc carrier phase RMSE=" << rmse + << ", mean=" << error_mean + << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl; + std::cout.precision(ss); +} + + +void GpsL1CAKfTrackingTest::check_results_codephase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value) +{ + // 1. True value interpolation to match the measurement times + arma::vec true_value_interp; + arma::uvec true_time_s_valid = find(true_time_s > 0); + true_time_s = true_time_s(true_time_s_valid); + true_value = true_value(true_time_s_valid); + arma::uvec meas_time_s_valid = find(meas_time_s > 0); + meas_time_s = meas_time_s(meas_time_s_valid); + meas_value = meas_value(meas_time_s_valid); + + arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp); + + // 2. RMSE + arma::vec err; + + err = meas_value - true_value_interp; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + // 3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + // 5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << "TRK code phase RMSE=" << rmse + << ", mean=" << error_mean + << ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Chips]" << std::endl; + std::cout.precision(ss); +} + + +TEST_F(GpsL1CAKfTrackingTest, ValidationOfResults) +{ + // Configure the signal generator + configure_generator(); + + // Generate signal raw signal samples and observations RINEX file + if (FLAGS_disable_generator == false) + { + generate_signal(); + } + + std::chrono::time_point start, end; + + configure_receiver(); + + // open true observables log file written by the simulator + Tracking_True_Obs_Reader true_obs_data; + int test_satellite_PRN = FLAGS_test_satellite_PRN; + std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl; + std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); + true_obs_file.append(std::to_string(test_satellite_PRN)); + true_obs_file.append(".dat"); + ASSERT_EQ(true_obs_data.open_obs_file(true_obs_file), true) << "Failure opening true observables file"; + + top_block = gr::make_top_block("Tracking test"); + + std::shared_ptr trk_ = factory->GetBlock(config, "Tracking_1C", implementation, 1, 1); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); //std::make_shared(config.get(), "Tracking_1C", 1, 1); + + boost::shared_ptr msg_rx = GpsL1CAKfTrackingTest_msg_rx_make(); + + // load acquisition data based on the first epoch of the true observations + ASSERT_EQ(true_obs_data.read_binary_obs(), true) + << "Failure reading true tracking dump file." << std::endl + << "Maybe sat PRN #" + std::to_string(FLAGS_test_satellite_PRN) + + " is not available?"; + + // restart the epoch counter + true_obs_data.restart(); + + std::cout << "Initial Doppler [Hz]=" << true_obs_data.doppler_l1_hz << " Initial code delay [Chips]=" << true_obs_data.prn_delay_chips << std::endl; + gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; + gnss_synchro.Acq_doppler_hz = true_obs_data.doppler_l1_hz; + gnss_synchro.Acq_samplestamp_samples = 0; + + ASSERT_NO_THROW({ + tracking->set_channel(gnss_synchro.Channel_ID); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + tracking->set_gnss_synchro(&gnss_synchro); + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + tracking->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + + ASSERT_NO_THROW({ + std::string file = "./" + filename_raw_data; + const char* file_name = file.c_str(); + gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); + top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block->connect(gr_interleaved_char_to_complex, 0, tracking->get_left_block(), 0); + top_block->connect(tracking->get_right_block(), 0, sink, 0); + top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting the blocks of tracking test."; + + tracking->start_tracking(); + + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + }) << "Failure running the top_block."; + + // check results + // load the true values + long int nepoch = true_obs_data.num_epochs(); + std::cout << "True observation epochs=" << nepoch << std::endl; + + arma::vec true_timestamp_s = arma::zeros(nepoch, 1); + arma::vec true_acc_carrier_phase_cycles = arma::zeros(nepoch, 1); + arma::vec true_Doppler_Hz = arma::zeros(nepoch, 1); + arma::vec true_prn_delay_chips = arma::zeros(nepoch, 1); + arma::vec true_tow_s = arma::zeros(nepoch, 1); + + long int epoch_counter = 0; + while (true_obs_data.read_binary_obs()) + { + true_timestamp_s(epoch_counter) = true_obs_data.signal_timestamp_s; + true_acc_carrier_phase_cycles(epoch_counter) = true_obs_data.acc_carrier_phase_cycles; + true_Doppler_Hz(epoch_counter) = true_obs_data.doppler_l1_hz; + true_prn_delay_chips(epoch_counter) = true_obs_data.prn_delay_chips; + true_tow_s(epoch_counter) = true_obs_data.tow; + epoch_counter++; + } + + //load the measured values + Tracking_Dump_Reader trk_dump; + + ASSERT_EQ(trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")), true) + << "Failure opening tracking dump file"; + + nepoch = trk_dump.num_epochs(); + std::cout << "Measured observation epochs=" << nepoch << std::endl; + //trk_dump.restart(); + + arma::vec trk_timestamp_s = arma::zeros(nepoch, 1); + arma::vec trk_acc_carrier_phase_cycles = arma::zeros(nepoch, 1); + arma::vec trk_Doppler_Hz = arma::zeros(nepoch, 1); + arma::vec trk_prn_delay_chips = arma::zeros(nepoch, 1); + + std::vector prompt; + std::vector early; + std::vector late; + std::vector promptI; + std::vector promptQ; + + epoch_counter = 0; + while (trk_dump.read_binary_obs()) + { + trk_timestamp_s(epoch_counter) = static_cast(trk_dump.PRN_start_sample_count) / static_cast(baseband_sampling_freq); + trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI; + trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz; + double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast(baseband_sampling_freq), 1.0e-3) / 1.0e-3); + + trk_prn_delay_chips(epoch_counter) = delay_chips; + epoch_counter++; + prompt.push_back(trk_dump.abs_P); + early.push_back(trk_dump.abs_E); + late.push_back(trk_dump.abs_L); + promptI.push_back(trk_dump.prompt_I); + promptQ.push_back(trk_dump.prompt_Q); + } + + // Align initial measurements and cut the tracking pull-in transitory + double pull_in_offset_s = 1.0; + arma::uvec initial_meas_point = arma::find(trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first"); + + trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1); + trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1); + trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0), trk_Doppler_Hz.size() - 1); + trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0), trk_prn_delay_chips.size() - 1); + + check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz); + check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips); + check_results_acc_carrier_phase(true_timestamp_s, true_acc_carrier_phase_cycles, trk_timestamp_s, trk_acc_carrier_phase_cycles); + + std::chrono::duration elapsed_seconds = end - start; + std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds." << std::endl; + + if (FLAGS_plot_gps_l1_kf_tracking_test == true) + { + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if (gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag plot_gps_l1_tracking_test has been set to TRUE," << std::endl; + std::cout << "gnuplot has not been found in your system." << std::endl; + std::cout << "Test results will not be plotted." << std::endl; + } + else + { + try + { + boost::filesystem::path p(gnuplot_executable); + boost::filesystem::path dir = p.parent_path(); + const std::string& gnuplot_path = dir.native(); + Gnuplot::set_GNUPlotPath(gnuplot_path); + + std::vector timevec; + double t = 0.0; + for (auto it = prompt.begin(); it != prompt.end(); it++) + { + timevec.push_back(t); + t = t + GPS_L1_CA_CODE_PERIOD; + } + Gnuplot g1("linespoints"); + g1.set_title("GPS L1 C/A signal tracking correlators' output (satellite PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g1.set_grid(); + g1.set_xlabel("Time [s]"); + g1.set_ylabel("Correlators' output"); + g1.cmd("set key box opaque"); + auto decimate = static_cast(FLAGS_plot_decimate); + g1.plot_xy(timevec, prompt, "Prompt", decimate); + g1.plot_xy(timevec, early, "Early", decimate); + g1.plot_xy(timevec, late, "Late", decimate); + g1.savetops("Correlators_outputs"); + g1.savetopdf("Correlators_outputs", 18); + if (FLAGS_show_plots) + { + g1.showonscreen(); // window output + } + else + { + g1.disablescreen(); + } + + Gnuplot g2("points"); + g2.set_title("Constellation diagram (satellite PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g2.set_grid(); + g2.set_xlabel("Inphase"); + g2.set_ylabel("Quadrature"); + g2.cmd("set size ratio -1"); + g2.plot_xy(promptI, promptQ); + g2.savetops("Constellation"); + g2.savetopdf("Constellation", 18); + if (FLAGS_show_plots) + { + g2.showonscreen(); // window output + } + else + { + g2.disablescreen(); + } + } + catch (const GnuplotException& ge) + { + std::cout << ge.what() << std::endl; + } + } + } +} diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc index bfd715260..3b6b325a4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc @@ -31,22 +31,27 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "gnss_block_factory.h" #include "gnss_block_interface.h" -#include "tracking_interface.h" -#include "in_memory_configuration.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" #include "gps_l2_m_dll_pll_tracking.h" +#include "in_memory_configuration.h" +#include "tracking_interface.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### @@ -79,7 +84,7 @@ void GpsL2MDllPllTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast& e) @@ -98,9 +103,7 @@ GpsL2MDllPllTrackingTest_msg_rx::GpsL2MDllPllTrackingTest_msg_rx() : gr::block(" } -GpsL2MDllPllTrackingTest_msg_rx::~GpsL2MDllPllTrackingTest_msg_rx() -{ -} +GpsL2MDllPllTrackingTest_msg_rx::~GpsL2MDllPllTrackingTest_msg_rx() = default; // ########################################################### @@ -116,9 +119,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL2MDllPllTrackingTest() - { - } + ~GpsL2MDllPllTrackingTest() = default; void init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc index 35095ad7f..5048fe638 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc @@ -29,15 +29,15 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include -#include -#include -#include +#include "GPS_L1_CA.h" #include "cuda_multicorrelator.h" #include "gps_sdr_signal_processing.h" -#include "GPS_L1_CA.h" +#include +#include +#include +#include +#include +#include DEFINE_int32(gpu_multicorrelator_iterations_test, 1000, "Number of averaged iterations in GPU multicorrelator test timing test"); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc index 34abf6f46..f59a87a1c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc @@ -56,10 +56,10 @@ TEST(TrackingLoopFilterTest, FirstOrderLoop) float g1 = noise_bandwidth * 4.0; float result = 0.0; - for (unsigned int i = 0; i < sample_data.size(); ++i) + for (float i : sample_data) { - result = theFilter.apply(sample_data[i]); - EXPECT_FLOAT_EQ(result, sample_data[i] * g1); + result = theFilter.apply(i); + EXPECT_FLOAT_EQ(result, i * g1); } } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc new file mode 100644 index 000000000..306ad74fd --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc @@ -0,0 +1,1137 @@ +/*! + * \file tracking_test.cc + * \brief This class implements a tracking Pull-In test for GPS_L1_CA_DLL_PLL_Tracking + * implementation based on some input parameters. + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "GPS_L1_CA.h" +#include "GPS_L2C.h" +#include "GPS_L5.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "acquisition_msg_rx.h" +#include "control_message_factory.h" +#include "galileo_e1_pcps_ambiguous_acquisition.h" +#include "galileo_e5a_noncoherent_iq_acquisition_caf.h" +#include "galileo_e5a_pcps_acquisition.h" +#include "gnss_block_factory.h" +#include "gnss_sdr_valve.h" +#include "gnuplot_i.h" +#include "gps_l1_ca_pcps_acquisition.h" +#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" +#include "gps_l2_m_pcps_acquisition.h" +#include "gps_l5i_pcps_acquisition.h" +#include "in_memory_configuration.h" +#include "signal_generator_flags.h" +#include "test_flags.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_tests_flags.h" +#include "tracking_true_obs_reader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GR_GREATER_38 +#include +#else +#include +#endif + + +// ######## GNURADIO TRACKING BLOCK MESSAGE RECEVER ######### +class TrackingPullInTest_msg_rx; + +typedef boost::shared_ptr TrackingPullInTest_msg_rx_sptr; + +TrackingPullInTest_msg_rx_sptr TrackingPullInTest_msg_rx_make(); + +class TrackingPullInTest_msg_rx : public gr::block +{ +private: + friend TrackingPullInTest_msg_rx_sptr TrackingPullInTest_msg_rx_make(); + void msg_handler_events(pmt::pmt_t msg); + TrackingPullInTest_msg_rx(); + +public: + int rx_message; + ~TrackingPullInTest_msg_rx(); //!< Default destructor +}; + + +TrackingPullInTest_msg_rx_sptr TrackingPullInTest_msg_rx_make() +{ + return TrackingPullInTest_msg_rx_sptr(new TrackingPullInTest_msg_rx()); +} + + +void TrackingPullInTest_msg_rx::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(std::move(msg)); + rx_message = message; //3 -> loss of lock + //std::cout << "Received trk message: " << rx_message << std::endl; + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_tracking Bad cast!"; + rx_message = 0; + } +} + + +TrackingPullInTest_msg_rx::TrackingPullInTest_msg_rx() : gr::block("TrackingPullInTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&TrackingPullInTest_msg_rx::msg_handler_events, this, _1)); + rx_message = 0; +} + + +TrackingPullInTest_msg_rx::~TrackingPullInTest_msg_rx() = default; + + +// ########################################################### + +class TrackingPullInTest : public ::testing::Test +{ +public: + enum StringValue + { + evGPS_1C, + evGPS_2S, + evGPS_L5, + evSBAS_1C, + evGAL_1B, + evGAL_5X, + evGLO_1G, + evGLO_2G + }; + std::map mapStringValues_; + + std::string generator_binary; + std::string p1; + std::string p2; + std::string p3; + std::string p4; + std::string p5; + std::string p6; + std::string implementation = FLAGS_trk_test_implementation; + + const int baseband_sampling_freq = FLAGS_fs_gen_sps; + + std::string filename_rinex_obs = FLAGS_filename_rinex_obs; + std::string filename_raw_data = FLAGS_signal_file; + + std::map doppler_measurements_map; + std::map code_delay_measurements_map; + std::map acq_samplestamp_map; + + int configure_generator(double CN0_dBHz, int file_idx); + int generate_signal(); + std::vector check_results_doppler(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error); + std::vector check_results_acc_carrier_phase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error); + std::vector check_results_codephase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error); + + TrackingPullInTest() + { + factory = std::make_shared(); + config = std::make_shared(); + item_size = sizeof(gr_complex); + gnss_synchro = Gnss_Synchro(); + mapStringValues_["1C"] = evGPS_1C; + mapStringValues_["2S"] = evGPS_2S; + mapStringValues_["L5"] = evGPS_L5; + mapStringValues_["1B"] = evGAL_1B; + mapStringValues_["5X"] = evGAL_5X; + mapStringValues_["1G"] = evGLO_1G; + mapStringValues_["2G"] = evGLO_2G; + } + + ~TrackingPullInTest() = default; + + void configure_receiver(double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols); + + bool acquire_signal(int SV_ID); + gr::top_block_sptr top_block; + std::shared_ptr factory; + std::shared_ptr config; + Gnss_Synchro gnss_synchro; + size_t item_size; + + gr::msg_queue::sptr queue; +}; + + +int TrackingPullInTest::configure_generator(double CN0_dBHz, int file_idx) +{ + // Configure signal generator + generator_binary = FLAGS_generator_binary; + + p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; + if (FLAGS_dynamic_position.empty()) + { + p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10); + } + else + { + p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); + } + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_signal_file + std::to_string(file_idx); // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] + p6 = std::string("-CN0_dBHz=") + std::to_string(CN0_dBHz); // Signal generator CN0 + return 0; +} + + +int TrackingPullInTest::generate_signal() +{ + int child_status; + + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], &p6[0], nullptr}; + + int pid; + if ((pid = fork()) == -1) + { + perror("fork err"); + } + else if (pid == 0) + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv err." << std::endl; + std::terminate(); + } + + waitpid(pid, &child_status, 0); + + std::cout << "Signal and Observables RINEX and RAW files created." << std::endl; + return 0; +} + + +void TrackingPullInTest::configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols) +{ + config = std::make_shared(); + config->set_property("Tracking.dump", "true"); + config->set_property("Tracking.dump_filename", "./tracking_ch_"); + config->set_property("Tracking.implementation", implementation); + config->set_property("Tracking.item_type", "gr_complex"); + config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); + config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); + config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + gnss_synchro.PRN = FLAGS_test_satellite_PRN; + gnss_synchro.Channel_ID = 0; + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + + std::string System_and_Signal; + if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") + { + gnss_synchro.System = 'G'; + std::string signal = "1C"; + System_and_Signal = "GPS L1 CA"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); + } + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") + { + gnss_synchro.System = 'E'; + std::string signal = "1B"; + System_and_Signal = "Galileo E1B"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_chips", "0.6"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); + config->set_property("Tracking.track_pilot", "true"); + } + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") + { + gnss_synchro.System = 'G'; + std::string signal = "2S"; + System_and_Signal = "GPS L2CM"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + } + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking" or implementation == "Galileo_E5a_DLL_PLL_Tracking_b") + { + gnss_synchro.System = 'E'; + std::string signal = "5X"; + System_and_Signal = "Galileo E5a"; + signal.copy(gnss_synchro.Signal, 2, 0); + if (implementation == "Galileo_E5a_DLL_PLL_Tracking_b") + { + config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); + } + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + config->set_property("Tracking.order", "2"); + } + else if (implementation == "GPS_L5_DLL_PLL_Tracking") + { + gnss_synchro.System = 'G'; + std::string signal = "L5"; + System_and_Signal = "GPS L5I"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "true"); + config->set_property("Tracking.order", "2"); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + std::cout << "*****************************************\n"; + std::cout << "*** Tracking configuration parameters ***\n"; + std::cout << "*****************************************\n"; + std::cout << "Signal: " << System_and_Signal << "\n"; + std::cout << "implementation: " << config->property("Tracking.implementation", std::string("undefined")) << " \n"; + std::cout << "pll_bw_hz: " << config->property("Tracking.pll_bw_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_hz: " << config->property("Tracking.dll_bw_hz", 0.0) << " Hz\n"; + std::cout << "pll_bw_narrow_hz: " << config->property("Tracking.pll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_narrow_hz: " << config->property("Tracking.dll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "extend_correlation_symbols: " << config->property("Tracking.extend_correlation_symbols", 0) << " Symbols\n"; + std::cout << "*****************************************\n"; + std::cout << "*****************************************\n"; +} + + +bool TrackingPullInTest::acquire_signal(int SV_ID) +{ + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + gr::top_block_sptr top_block; + top_block = gr::make_top_block("Acquisition test"); + + // Satellite signal definition + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.Channel_ID = 0; + + + config = std::make_shared(); + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + // Enable automatic resampler for the acquisition, if required + if (FLAGS_use_acquisition_resampler == true) + { + config->set_property("GNSS-SDR.use_acquisition_resampler", "true"); + } + config->set_property("Acquisition.blocking_on_standby", "true"); + config->set_property("Acquisition.blocking", "true"); + config->set_property("Acquisition.dump", "false"); + config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); + config->set_property("Acquisition.use_CFAR_algorithm", "false"); + + std::shared_ptr acquisition; + + std::string System_and_Signal; + std::string signal; + //create the correspondign acquisition block according to the desired tracking signal + if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'G'; + signal = "1C"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L1 CA"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") + { + tmp_gnss_synchro.System = 'E'; + signal = "1B"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E1B"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'G'; + signal = "2S"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L2CM"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking_b") + { + tmp_gnss_synchro.System = 'E'; + signal = "5X"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E5a"; + config->set_property("Acquisition_5X.coherent_integration_time_ms", "1"); + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + config->set_property("Acquisition.CAF_window_hz", "0"); // **Only for E5a** Resolves doppler ambiguity averaging the specified BW in the winner code delay. If set to 0 CAF filter is desactivated. Recommended value 3000 Hz + config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. + config->set_property("Acquisition.bit_transition_flag", "false"); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'E'; + signal = "5X"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E5a"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else if (implementation == "GPS_L5_DLL_PLL_Tracking") + { + tmp_gnss_synchro.System = 'G'; + signal = "L5"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L5I"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->set_channel(0); + acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition->init(); + acquisition->set_local_code(); + acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->connect(top_block); + + gr::blocks::file_source::sptr file_source; + std::string file = FLAGS_signal_file; + const char* file_name = file.c_str(); + file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + file_source->seek(2 * FLAGS_skip_samples, SEEK_SET); //skip head. ibyte, two bytes per complex sample + gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); + + top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + + // Enable automatic resampler for the acquisition, if required + if (FLAGS_use_acquisition_resampler == true) + { + //create acquisition resamplers if required + double resampler_ratio = 1.0; + + double opt_fs = baseband_sampling_freq; + //find the signal associated to this channel + switch (mapStringValues_[signal]) + { + case evGPS_1C: + opt_fs = GPS_L1_CA_OPT_ACQ_FS_HZ; + break; + case evGPS_2S: + opt_fs = GPS_L2C_OPT_ACQ_FS_HZ; + break; + case evGPS_L5: + opt_fs = GPS_L5_OPT_ACQ_FS_HZ; + break; + case evSBAS_1C: + opt_fs = GPS_L1_CA_OPT_ACQ_FS_HZ; + break; + case evGAL_1B: + opt_fs = GALILEO_E1_OPT_ACQ_FS_HZ; + break; + case evGAL_5X: + opt_fs = GALILEO_E5A_OPT_ACQ_FS_HZ; + break; + case evGLO_1G: + opt_fs = baseband_sampling_freq; + break; + case evGLO_2G: + opt_fs = baseband_sampling_freq; + break; + } + if (opt_fs < baseband_sampling_freq) + { + resampler_ratio = baseband_sampling_freq / opt_fs; + int decimation = floor(resampler_ratio); + while (baseband_sampling_freq % decimation > 0) + { + decimation--; + }; + double acq_fs = baseband_sampling_freq / decimation; + + if (decimation > 1) + { + //create a FIR low pass filter + std::vector taps; + taps = gr::filter::firdes::low_pass(1.0, + baseband_sampling_freq, + acq_fs / 2.1, + acq_fs / 10, + gr::filter::firdes::win_type::WIN_HAMMING); + std::cout << "Enabled decimation low pass filter with " << taps.size() << " taps and decimation factor of " << decimation << std::endl; + acquisition->set_resampler_latency((taps.size() - 1) / 2); + gr::basic_block_sptr fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(decimation, taps); + top_block->connect(gr_interleaved_char_to_complex, 0, fir_filter_ccf_, 0); + top_block->connect(fir_filter_ccf_, 0, acquisition->get_left_block(), 0); + } + else + { + std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; + top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + } + } + else + { + std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; + top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + } + } + else + { + top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + //top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); + } + + + boost::shared_ptr msg_rx; + try + { + msg_rx = Acquisition_msg_rx_make(); + } + catch (const std::exception& e) + { + std::cout << "Failure connecting the message port system: " << e.what() << std::endl; + exit(0); + } + + msg_rx->top_block = top_block; + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + + // 5. Run the flowgraph + // Get visible GPS satellites (positive acquisitions with Doppler measurements) + // record startup time + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds; + start = std::chrono::system_clock::now(); + + bool start_msg = true; + + doppler_measurements_map.clear(); + code_delay_measurements_map.clear(); + acq_samplestamp_map.clear(); + + unsigned int MAX_PRN_IDX = 0; + + switch (tmp_gnss_synchro.System) + { + case 'G': + MAX_PRN_IDX = 33; + break; + case 'E': + MAX_PRN_IDX = 37; + break; + default: + MAX_PRN_IDX = 33; + } + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + acquisition->reset(); + acquisition->set_state(1); + msg_rx->rx_message = 0; + top_block->run(); + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); + code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); + acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } + top_block->stop(); + file_source->seek(2 * FLAGS_skip_samples, SEEK_SET); //skip head. ibyte, two bytes per complex sample + std::cout.flush(); + } + std::cout << "]" << std::endl; + std::cout << "-------------------------------------------\n"; + + for (auto& x : doppler_measurements_map) + { + std::cout << "DETECTED SATELLITE " << System_and_Signal << " PRN: " << x.first << " with Doppler: " << x.second << " [Hz], code phase: " << code_delay_measurements_map.at(x.first) << " [samples] at signal SampleStamp " << acq_samplestamp_map.at(x.first) << "\n"; + } + + // report the elapsed time + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + std::cout << "Total signal acquisition run time " + << elapsed_seconds.count() + << " [seconds]" << std::endl; + return true; +} + +TEST_F(TrackingPullInTest, ValidationOfResults) +{ + //************************************************* + //***** STEP 1: Prepare the parameters sweep ****** + //************************************************* + std::vector + acq_doppler_error_hz_values; + std::vector> acq_delay_error_chips_values; //vector of vector + + for (double doppler_hz = FLAGS_acq_Doppler_error_hz_start; doppler_hz >= FLAGS_acq_Doppler_error_hz_stop; doppler_hz = doppler_hz + FLAGS_acq_Doppler_error_hz_step) + { + acq_doppler_error_hz_values.push_back(doppler_hz); + std::vector tmp_vector; + //Code Delay Sweep + for (double code_delay_chips = FLAGS_acq_Delay_error_chips_start; code_delay_chips >= FLAGS_acq_Delay_error_chips_stop; code_delay_chips = code_delay_chips + FLAGS_acq_Delay_error_chips_step) + { + tmp_vector.push_back(code_delay_chips); + } + acq_delay_error_chips_values.push_back(tmp_vector); + } + + + //*********************************************************** + //***** STEP 2: Generate the input signal (if required) ***** + //*********************************************************** + std::vector generator_CN0_values; + if (FLAGS_enable_external_signal_file) + { + generator_CN0_values.push_back(999); // an external input signal capture is selected, no CN0 information available + } + else + { + if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop) + { + generator_CN0_values.push_back(FLAGS_CN0_dBHz_start); + } + else + { + for (double cn0 = FLAGS_CN0_dBHz_start; cn0 > FLAGS_CN0_dBHz_stop; cn0 = cn0 - FLAGS_CN0_dB_step) + { + generator_CN0_values.push_back(cn0); + } + } + } + + // use generator or use an external capture file + if (FLAGS_enable_external_signal_file) + { + //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters + ASSERT_EQ(acquire_signal(FLAGS_test_satellite_PRN), true); + bool found_satellite = doppler_measurements_map.find(FLAGS_test_satellite_PRN) != doppler_measurements_map.end(); + EXPECT_TRUE(found_satellite) << "Error: satellite SV: " << FLAGS_test_satellite_PRN << " is not acquired"; + if (!found_satellite) + { + return; + } + } + else + { + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + // Configure the signal generator + configure_generator(generator_CN0_values.at(current_cn0_idx), current_cn0_idx); + // Generate signal raw signal samples and observations RINEX file + if (FLAGS_disable_generator == false) + { + generate_signal(); + } + } + } + + + configure_receiver(FLAGS_PLL_bw_hz_start, + FLAGS_DLL_bw_hz_start, + FLAGS_PLL_narrow_bw_hz, + FLAGS_DLL_narrow_bw_hz, + FLAGS_extend_correlation_symbols); + + //****************************************************************************************** + //***** Obtain the initial signal sinchronization parameters (emulating an acquisition) **** + //****************************************************************************************** + int test_satellite_PRN = 0; + double true_acq_doppler_hz = 0.0; + double true_acq_delay_samples = 0.0; + uint64_t acq_samplestamp_samples = 0; + + Tracking_True_Obs_Reader true_obs_data; + if (!FLAGS_enable_external_signal_file) + { + test_satellite_PRN = FLAGS_test_satellite_PRN; + std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); + true_obs_file.append(std::to_string(test_satellite_PRN)); + true_obs_file.append(".dat"); + true_obs_data.close_obs_file(); + ASSERT_EQ(true_obs_data.open_obs_file(true_obs_file), true) << "Failure opening true observables file"; + // load acquisition data based on the first epoch of the true observations + ASSERT_EQ(true_obs_data.read_binary_obs(), true) + << "Failure reading true tracking dump file." << std::endl + << "Maybe sat PRN #" + std::to_string(FLAGS_test_satellite_PRN) + + " is not available?"; + std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl; + std::cout << "True Initial Doppler " << true_obs_data.doppler_l1_hz << " [Hz], true Initial code delay [Chips]=" << true_obs_data.prn_delay_chips << "[Chips]" << std::endl; + true_acq_doppler_hz = true_obs_data.doppler_l1_hz; + true_acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * static_cast(baseband_sampling_freq) * GPS_L1_CA_CODE_PERIOD; + acq_samplestamp_samples = 0; + } + else + { + true_acq_doppler_hz = doppler_measurements_map.find(FLAGS_test_satellite_PRN)->second; + true_acq_delay_samples = code_delay_measurements_map.find(FLAGS_test_satellite_PRN)->second; + acq_samplestamp_samples = 0; + std::cout << "Estimated Initial Doppler " << true_acq_doppler_hz + << " [Hz], estimated Initial code delay " << true_acq_delay_samples << " [Samples]" + << " Acquisition SampleStamp is " << acq_samplestamp_map.find(FLAGS_test_satellite_PRN)->second << std::endl; + } + + // create the msg queue for valve + + queue = gr::msg_queue::make(0); + boost::shared_ptr reseteable_valve; + long long int acq_to_trk_delay_samples = ceil(static_cast(FLAGS_fs_gen_sps) * FLAGS_acq_to_trk_delay_s); + boost::shared_ptr resetable_valve_(new Gnss_Sdr_Valve(sizeof(gr_complex), acq_to_trk_delay_samples, queue, false)); + + std::shared_ptr control_message_factory_; + std::shared_ptr>> control_messages_; + + + //CN0 LOOP + std::vector> pull_in_results_v_v; + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + std::vector pull_in_results_v; + for (unsigned int current_acq_doppler_error_idx = 0; current_acq_doppler_error_idx < acq_doppler_error_hz_values.size(); current_acq_doppler_error_idx++) + { + for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) + { + gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; + //simulate a Doppler error in acquisition + gnss_synchro.Acq_doppler_hz = true_acq_doppler_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx); + //simulate Code Delay error in acquisition + gnss_synchro.Acq_delay_samples = true_acq_delay_samples + (acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) / GPS_L1_CA_CODE_RATE_HZ) * static_cast(baseband_sampling_freq); + + //create flowgraph + top_block = gr::make_top_block("Tracking test"); + std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); + boost::shared_ptr msg_rx = TrackingPullInTest_msg_rx_make(); + + + ASSERT_NO_THROW({ + tracking->set_channel(gnss_synchro.Channel_ID); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + tracking->set_gnss_synchro(&gnss_synchro); + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + tracking->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + + std::string file; + ASSERT_NO_THROW({ + if (!FLAGS_enable_external_signal_file) + { + file = "./" + filename_raw_data + std::to_string(current_cn0_idx); + } + else + { + file = FLAGS_signal_file; + } + const char* file_name = file.c_str(); + gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); + gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); + top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block->connect(gr_interleaved_char_to_complex, 0, head_samples, 0); + if (acq_to_trk_delay_samples > 0) + { + top_block->connect(head_samples, 0, resetable_valve_, 0); + top_block->connect(resetable_valve_, 0, tracking->get_left_block(), 0); + } + else + { + top_block->connect(head_samples, 0, tracking->get_left_block(), 0); + } + top_block->connect(tracking->get_right_block(), 0, sink, 0); + top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + }) << "Failure connecting the blocks of tracking test."; + + + //******************************************************************** + //***** STEP 5: Perform the signal tracking and read the results ***** + //******************************************************************** + std::cout << "--- START TRACKING WITH PULL-IN ERROR: " << acq_doppler_error_hz_values.at(current_acq_doppler_error_idx) << " [Hz] and " << acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) << " [Chips] ---" << std::endl; + std::chrono::time_point start, end; + if (acq_to_trk_delay_samples > 0) + { + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + std::cout << "--- SIMULATING A PULL-IN DELAY OF " << FLAGS_acq_to_trk_delay_s << " SECONDS ---\n"; + top_block->start(); + std::cout << " Waiting for valve...\n"; + //wait the valve message indicating the circulation of the amount of samples of the delay + gr::message::sptr queue_message = queue->delete_head(); + if (queue_message != nullptr) + { + control_messages_ = control_message_factory_->GetControlMessages(queue_message); + } + else + { + control_messages_->clear(); + } + std::cout << " Starting tracking...\n"; + tracking->start_tracking(); + resetable_valve_->open_valve(); + std::cout << " Waiting flowgraph..\n"; + top_block->wait(); + end = std::chrono::system_clock::now(); + }) << "Failure running the top_block."; + } + else + { + tracking->start_tracking(); + std::chrono::time_point start, end; + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + }) << "Failure running the top_block."; + } + + std::chrono::duration elapsed_seconds = end - start; + std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds" << std::endl; + + pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock + + //******************************** + //***** STEP 7: Plot results ***** + //******************************** + if (FLAGS_plot_detail_level >= 2 and FLAGS_show_plots) + { + //load the measured values + Tracking_Dump_Reader trk_dump; + ASSERT_EQ(trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")), true) + << "Failure opening tracking dump file"; + + int64_t n_measured_epochs = trk_dump.num_epochs(); + //todo: use vectors instead + arma::vec trk_timestamp_s = arma::zeros(n_measured_epochs, 1); + arma::vec trk_acc_carrier_phase_cycles = arma::zeros(n_measured_epochs, 1); + arma::vec trk_Doppler_Hz = arma::zeros(n_measured_epochs, 1); + arma::vec trk_prn_delay_chips = arma::zeros(n_measured_epochs, 1); + std::vector timestamp_s; + std::vector prompt; + std::vector early; + std::vector late; + std::vector v_early; + std::vector v_late; + std::vector promptI; + std::vector promptQ; + std::vector CN0_dBHz; + std::vector Doppler; + int64_t epoch_counter = 0; + while (trk_dump.read_binary_obs()) + { + trk_timestamp_s(epoch_counter) = static_cast(trk_dump.PRN_start_sample_count) / static_cast(baseband_sampling_freq); + trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI; + trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz; + double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast(baseband_sampling_freq), 1.0e-3) / 1.0e-3); + + trk_prn_delay_chips(epoch_counter) = delay_chips; + + timestamp_s.push_back(trk_timestamp_s(epoch_counter)); + prompt.push_back(trk_dump.abs_P); + early.push_back(trk_dump.abs_E); + late.push_back(trk_dump.abs_L); + v_early.push_back(trk_dump.abs_VE); + v_late.push_back(trk_dump.abs_VL); + promptI.push_back(trk_dump.prompt_I); + promptQ.push_back(trk_dump.prompt_Q); + CN0_dBHz.push_back(trk_dump.CN0_SNV_dB_Hz); + Doppler.push_back(trk_dump.carrier_doppler_hz); + epoch_counter++; + } + + + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if (gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag show_plots has been set to TRUE," << std::endl; + std::cout << "gnuplot has not been found in your system." << std::endl; + std::cout << "Test results will not be plotted." << std::endl; + } + else + { + try + { + boost::filesystem::path p(gnuplot_executable); + boost::filesystem::path dir = p.parent_path(); + const std::string& gnuplot_path = dir.native(); + Gnuplot::set_GNUPlotPath(gnuplot_path); + auto decimate = static_cast(FLAGS_plot_decimate); + + if (FLAGS_plot_detail_level >= 2 and FLAGS_show_plots) + { + Gnuplot g1("linespoints"); + g1.showonscreen(); // window output + if (!FLAGS_enable_external_signal_file) + { + g1.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, " + "PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g1.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + + g1.set_grid(); + g1.set_xlabel("Time [s]"); + g1.set_ylabel("Correlators' output"); + //g1.cmd("set key box opaque"); + g1.plot_xy(trk_timestamp_s, prompt, "Prompt", decimate); + g1.plot_xy(trk_timestamp_s, early, "Early", decimate); + g1.plot_xy(trk_timestamp_s, late, "Late", decimate); + if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") + { + g1.plot_xy(trk_timestamp_s, v_early, "Very Early", decimate); + g1.plot_xy(trk_timestamp_s, v_late, "Very Late", decimate); + } + g1.set_legend(); + g1.savetops("Correlators_outputs"); + + Gnuplot g2("points"); + g2.showonscreen(); // window output + if (!FLAGS_enable_external_signal_file) + { + g2.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz Constellation " + "PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g2.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + + g2.set_grid(); + g2.set_xlabel("Inphase"); + g2.set_ylabel("Quadrature"); + //g2.cmd("set size ratio -1"); + g2.plot_xy(promptI, promptQ); + g2.savetops("Constellation"); + + Gnuplot g3("linespoints"); + if (!FLAGS_enable_external_signal_file) + { + g3.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, GPS L1 C/A tracking CN0 output (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g3.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips] PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Reported CN0 [dB-Hz]"); + g3.cmd("set key box opaque"); + + g3.plot_xy(trk_timestamp_s, CN0_dBHz, + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate); + + g3.set_legend(); + g3.savetops("CN0_output"); + + g3.showonscreen(); // window output + + Gnuplot g4("linespoints"); + if (!FLAGS_enable_external_signal_file) + { + g4.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, GPS L1 C/A tracking CN0 output (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g4.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips] PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + g4.set_grid(); + g4.set_xlabel("Time [s]"); + g4.set_ylabel("Estimated Doppler [Hz]"); + g4.cmd("set key box opaque"); + + g4.plot_xy(trk_timestamp_s, Doppler, + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate); + + g4.set_legend(); + g4.savetops("Doppler"); + + g4.showonscreen(); // window output + } + } + catch (const GnuplotException& ge) + { + std::cout << ge.what() << std::endl; + } + } + } //end plot + + } //end acquisition Delay errors loop + } //end acquisition Doppler errors loop + pull_in_results_v_v.push_back(pull_in_results_v); + + + } //end CN0 LOOP + //build the mesh grid + std::vector doppler_error_mesh; + std::vector code_delay_error_mesh; + for (unsigned int current_acq_doppler_error_idx = 0; current_acq_doppler_error_idx < acq_doppler_error_hz_values.size(); current_acq_doppler_error_idx++) + { + for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) + { + doppler_error_mesh.push_back(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)); + code_delay_error_mesh.push_back(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)); + } + } + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + std::vector pull_in_result_mesh; + pull_in_result_mesh = pull_in_results_v_v.at(current_cn0_idx); + //plot grid + Gnuplot g4("points palette pointsize 2 pointtype 7"); + if (FLAGS_show_plots) + { + g4.showonscreen(); // window output + } + else + { + g4.disablescreen(); + } + g4.cmd(R"(set palette defined ( 0 "black", 1 "green" ))"); + g4.cmd("set key off"); + g4.cmd("set view map"); + std::string title; + if (!FLAGS_enable_external_signal_file) + { + title = std::string("Tracking Pull-in result grid at CN0:" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + " [dB-Hz], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz]."); + } + else + { + title = std::string("Tracking Pull-in result grid, PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + + g4.set_title(title); + g4.set_grid(); + g4.set_xlabel("Acquisition Doppler error [Hz]"); + g4.set_ylabel("Acquisition Code Delay error [Chips]"); + g4.cmd("set cbrange[0:1]"); + g4.plot_xyz(doppler_error_mesh, + code_delay_error_mesh, + pull_in_result_mesh); + g4.set_legend(); + if (!FLAGS_enable_external_signal_file) + { + g4.savetops("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx))))); + g4.savetopdf("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))), 12); + } + else + { + g4.savetops("trk_pull_in_grid_external_file"); + g4.savetopdf("trk_pull_in_grid_external_file", 12); + } + } +} diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc new file mode 100644 index 000000000..9205d0ba6 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -0,0 +1,1324 @@ +/*! + * \file tracking_pull-in_test_fpga.cc + * \brief This class implements a tracking Pull-In test for FPGA HW accelerator + * implementations based on some input parameters. + * \author Marc Majoral, 2019. majoralmarc(at)cttc.es + * Javier Arribas, 2018. jarribas(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "GPS_L1_CA.h" +#include "acquisition_msg_rx.h" +#include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" +#include "galileo_e5a_noncoherent_iq_acquisition_caf.h" +#include "galileo_e5a_pcps_acquisition.h" +#include "galileo_e5a_pcps_acquisition_fpga.h" +#include "gnss_block_factory.h" +#include "gps_l1_ca_pcps_acquisition_fpga.h" +#include "gps_l5i_pcps_acquisition_fpga.h" +#include "in_memory_configuration.h" +#include "signal_generator_flags.h" +#include "test_flags.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_tests_flags.h" +#include "tracking_true_obs_reader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// threads +#include // for open, O_RDWR, O_SYNC +#include // for cout, endl +#include // for pthread stuff +#include // for mmap + +#define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples +#define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes +#define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) +#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define DOWNSAMPLING_FILTER_DELAY 48 // delay of the downsampling filter in samples + + +// HW related options +bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops + // (exactly in the same way as the SW) + +class Acquisition_msg_rx_Fpga; + +typedef boost::shared_ptr Acquisition_msg_rx_Fpga_sptr; + +Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make(); + +class Acquisition_msg_rx_Fpga : public gr::block +{ +private: + friend Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make(); + void msg_handler_events(pmt::pmt_t msg); + Acquisition_msg_rx_Fpga(); + +public: + int rx_message; + gr::top_block_sptr top_block; + ~Acquisition_msg_rx_Fpga(); //!< Default destructor +}; + +Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make() +{ + return Acquisition_msg_rx_Fpga_sptr(new Acquisition_msg_rx_Fpga()); +} + +void Acquisition_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(msg); + rx_message = message; + top_block->stop(); //stop the flowgraph + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_acquisition Bad cast!\n"; + rx_message = 0; + } +} + +Acquisition_msg_rx_Fpga::Acquisition_msg_rx_Fpga() : gr::block("Acquisition_msg_rx_Fpga", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&Acquisition_msg_rx_Fpga::msg_handler_events, this, _1)); + rx_message = 0; +} + +Acquisition_msg_rx_Fpga::~Acquisition_msg_rx_Fpga() {} + +class TrackingPullInTestFpga_msg_rx; + +typedef boost::shared_ptr TrackingPullInTestFpga_msg_rx_sptr; + +TrackingPullInTestFpga_msg_rx_sptr TrackingPullInTestFpga_msg_rx_make(); + +class TrackingPullInTestFpga_msg_rx : public gr::block +{ +private: + friend TrackingPullInTestFpga_msg_rx_sptr TrackingPullInTestFpga_msg_rx_make(); + void msg_handler_events(pmt::pmt_t msg); + TrackingPullInTestFpga_msg_rx(); + +public: + int rx_message; + ~TrackingPullInTestFpga_msg_rx(); //!< Default destructor +}; + +TrackingPullInTestFpga_msg_rx_sptr TrackingPullInTestFpga_msg_rx_make() +{ + return TrackingPullInTestFpga_msg_rx_sptr(new TrackingPullInTestFpga_msg_rx()); +} + +void TrackingPullInTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(msg); + rx_message = message; //3 -> loss of lock + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_tracking Bad cast!"; + rx_message = 0; + } +} + +TrackingPullInTestFpga_msg_rx::TrackingPullInTestFpga_msg_rx() : gr::block("TrackingPullInTestFpga_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&TrackingPullInTestFpga_msg_rx::msg_handler_events, this, _1)); + rx_message = 0; +} + + +TrackingPullInTestFpga_msg_rx::~TrackingPullInTestFpga_msg_rx() +{ +} + +class TrackingPullInTestFpga : public ::testing::Test +{ +public: + std::string generator_binary; + std::string p1; + std::string p2; + std::string p3; + std::string p4; + std::string p5; + std::string p6; + std::string implementation = FLAGS_trk_test_implementation; + + const int baseband_sampling_freq = FLAGS_fs_gen_sps; + std::string filename_rinex_obs = FLAGS_filename_rinex_obs; + std::string filename_raw_data = FLAGS_signal_file; + + std::map doppler_measurements_map; + std::map code_delay_measurements_map; + std::map acq_samplestamp_map; + + int configure_generator(double CN0_dBHz, int file_idx); + int generate_signal(); + std::vector check_results_doppler(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error); + std::vector check_results_acc_carrier_phase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error); + std::vector check_results_codephase(arma::vec& true_time_s, + arma::vec& true_value, + arma::vec& meas_time_s, + arma::vec& meas_value, + double& mean_error, + double& std_dev_error); + + TrackingPullInTestFpga() + { + factory = std::make_shared(); + config = std::make_shared(); + item_size = sizeof(gr_complex); + gnss_synchro = Gnss_Synchro(); + } + + ~TrackingPullInTestFpga() + { + } + + void configure_receiver(double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols); + + bool acquire_signal(int SV_ID); + gr::top_block_sptr top_block; + std::shared_ptr factory; + std::shared_ptr config; + Gnss_Synchro gnss_synchro; + size_t item_size; +}; + +int TrackingPullInTestFpga::configure_generator(double CN0_dBHz, int file_idx) +{ + // Configure signal generator + generator_binary = FLAGS_generator_binary; + + p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; + if (FLAGS_dynamic_position.empty()) + { + p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10); + } + else + { + p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); + } + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_signal_file + std::to_string(file_idx); // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] + p6 = std::string("-CN0_dBHz=") + std::to_string(CN0_dBHz); // Signal generator CN0 + return 0; +} + +int TrackingPullInTestFpga::generate_signal() +{ + int child_status; + + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], &p6[0], NULL}; + + int pid; + if ((pid = fork()) == -1) + perror("fork err"); + else if (pid == 0) + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv err." << std::endl; + std::terminate(); + } + + waitpid(pid, &child_status, 0); + + std::cout << "Signal and Observables RINEX and RAW files created." << std::endl; + return 0; +} + +void TrackingPullInTestFpga::configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols) +{ + config = std::make_shared(); + config->set_property("Tracking.dump", "true"); + config->set_property("Tracking.dump_filename", "./tracking_ch_"); + config->set_property("Tracking.implementation", implementation); + config->set_property("Tracking.item_type", "cshort"); + config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); + config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); + config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + gnss_synchro.PRN = FLAGS_test_satellite_PRN; + gnss_synchro.Channel_ID = 0; + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + + std::string System_and_Signal; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + gnss_synchro.System = 'G'; + std::string signal = "1C"; + System_and_Signal = "GPS L1 CA"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.if", "0"); + config->set_property("Tracking.order", "3"); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + gnss_synchro.System = 'E'; + std::string signal = "1B"; + System_and_Signal = "Galileo E1B"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_chips", "0.6"); + config->set_property("Tracking.track_pilot", "true"); + + // added by me + config->set_property("Tracking.if", "0"); + config->set_property("Tracking.devicename", "/dev/uio"); + config->set_property("Tracking.device_base", "15"); + } + + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + { + gnss_synchro.System = 'E'; + std::string signal = "5X"; + System_and_Signal = "Galileo E5a"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "false"); + config->set_property("Tracking.order", "2"); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + gnss_synchro.System = 'G'; + std::string signal = "L5"; + System_and_Signal = "GPS L5I"; + signal.copy(gnss_synchro.Signal, 2, 0); + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "false"); + config->set_property("Tracking.order", "2"); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + std::cout << "*****************************************\n"; + std::cout << "*** Tracking configuration parameters ***\n"; + std::cout << "*****************************************\n"; + std::cout << "Signal: " << System_and_Signal << "\n"; + std::cout << "implementation: " << config->property("Tracking.implementation", std::string("undefined")) << " \n"; + std::cout << "pll_bw_hz: " << config->property("Tracking.pll_bw_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_hz: " << config->property("Tracking.dll_bw_hz", 0.0) << " Hz\n"; + std::cout << "pll_bw_narrow_hz: " << config->property("Tracking.pll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_narrow_hz: " << config->property("Tracking.dll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "extend_correlation_symbols: " << config->property("Tracking.extend_correlation_symbols", 0) << " Symbols\n"; + std::cout << "*****************************************\n"; + std::cout << "*****************************************\n"; +} + +const size_t PAGE_SIZE = 0x10000; +const unsigned int TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; + +void setup_fpga_switch(void) +{ + int switch_device_descriptor; // driver descriptor + volatile unsigned* switch_map_base; // driver memory map + + if ((switch_device_descriptor = open("/dev/uio1", O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" + << "/dev/uio1"; + } + switch_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, switch_device_descriptor, 0)); + + if (switch_map_base == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; + std::cout << "Could not map switch memory." << std::endl; + } + + // sanity check : check test register + unsigned writeval = TEST_REGISTER_TRACK_WRITEVAL; + unsigned readval; + // write value to test register + switch_map_base[3] = writeval; + // read value from test register + readval = switch_map_base[3]; + + if (writeval != readval) + { + LOG(WARNING) << "Test register sanity check failed"; + } + else + { + LOG(INFO) << "Test register sanity check success !"; + } + + switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues +} + + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +volatile unsigned int send_samples_start = 0; + +int8_t input_samples[MAX_INPUT_COMPLEX_SAMPLES_TOTAL * COMPLEX_SAMPLE_SIZE]; // re - im +int8_t input_samples_dma[MAX_INPUT_COMPLEX_SAMPLES_TOTAL * COMPLEX_SAMPLE_SIZE * NUM_QUEUES]; + +struct DMA_handler_args +{ + std::string file; + unsigned int nsamples_tx; + unsigned int skip_used_samples; + unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 +}; + +void* handler_DMA(void* arguments) +{ + // DMA process that configures the DMA to send the samples to the acquisition engine + int tx_fd; // DMA descriptor + FILE* rx_signal_file_id; // Input file descriptor + bool file_completed = false; // flag to indicate if the file is completed + unsigned int nsamples_block; // number of samples to send in the next DMA block of samples + unsigned int nread_elements; // number of elements effectively read from the input file + unsigned int nsamples = 0; // number of complex samples effectively transferred + unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA + + unsigned int nsamples_transmitted; + + struct DMA_handler_args* args = (struct DMA_handler_args*)arguments; + + unsigned int nsamples_tx = args->nsamples_tx; + std::string file = args->file; // input filename + unsigned int skip_used_samples = args->skip_used_samples; + + // open DMA device + tx_fd = open("/dev/loop_tx", O_WRONLY); + if (tx_fd < 0) + { + std::cout << "DMA can't open loop device" << std::endl; + exit(1); + } + else + + // open input file + rx_signal_file_id = fopen(file.c_str(), "rb"); + if (rx_signal_file_id == NULL) + { + std::cout << "DMA can't open input file" << std::endl; + exit(1); + } + while (send_samples_start == 0) + ; // wait until main thread tells the DMA to start + + // skip initial samples + int skip_samples = (int)FLAGS_skip_samples; + + fseek(rx_signal_file_id, (skip_samples + skip_used_samples) * 2, SEEK_SET); + + usleep(50000); // wait some time to give time to the main thread to start the acquisition module + + while (file_completed == false) + { + if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + { + nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + } + else + { + nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent + file_completed = true; + } + + nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block * COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + + if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) + { + std::cout << "file completed" << std::endl; + file_completed = true; + } + + nsamples += (nread_elements / COMPLEX_SAMPLE_SIZE); + + if (nread_elements > 0) + { + // for the 32-BIT DMA + dma_index = 0; + for (index0 = 0; index0 < (nread_elements); index0 += COMPLEX_SAMPLE_SIZE) + { + if (args->freq_band == 0) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = 0; + input_samples_dma[dma_index + 1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index + 2] = input_samples[index0]; + input_samples_dma[dma_index + 3] = input_samples[index0 + 1]; + } + else + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = input_samples[index0]; + input_samples_dma[dma_index + 1] = input_samples[index0 + 1]; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index + 2] = 0; + input_samples_dma[dma_index + 3] = 0; + } + dma_index += 4; + } + nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements * NUM_QUEUES); + if (nsamples_transmitted != nread_elements * NUM_QUEUES) + { + std::cout << "Error : DMA could not send all the requested samples" << std::endl; + } + } + } + + + close(tx_fd); + fclose(rx_signal_file_id); + return NULL; +} + + +bool TrackingPullInTestFpga::acquire_signal(int SV_ID) +{ + pthread_t thread_DMA; + + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + gr::top_block_sptr top_block; + top_block = gr::make_top_block("Acquisition test"); + + // Satellite signal definition + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.Channel_ID = 0; + config = std::make_shared(); + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + + + std::shared_ptr acquisition; + + std::string System_and_Signal; + + struct DMA_handler_args args; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'G'; + std::string signal = "1C"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L1 CA"; + + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + + + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'E'; + std::string signal = "1B"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E1B"; + + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'E'; + std::string signal = "5X"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E5a"; + + args.freq_band = 1; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'G'; + std::string signal = "L5"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L5I"; + + args.freq_band = 1; + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else + { + std::cout << "The test can not run with the selected tracking implementation \n "; + throw(std::exception()); + } + + + acquisition->set_channel(0); + acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition->connect(top_block); + + std::string file = FLAGS_signal_file; + + boost::shared_ptr msg_rx; + try + { + msg_rx = Acquisition_msg_rx_Fpga_make(); + } + catch (const std::exception& e) + { + std::cout << "Failure connecting the message port system: " << e.what() << std::endl; + exit(0); + } + + msg_rx->top_block = top_block; + + + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + + + // 5. Run the flowgraph + // Get visible GPS satellites (positive acquisitions with Doppler measurements) + // record startup time + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds; + start = std::chrono::system_clock::now(); + + bool start_msg = true; + + doppler_measurements_map.clear(); + code_delay_measurements_map.clear(); + acq_samplestamp_map.clear(); + + unsigned int MAX_PRN_IDX = 0; + + switch (tmp_gnss_synchro.System) + { + case 'G': + MAX_PRN_IDX = 33; + break; + case 'E': + MAX_PRN_IDX = 37; + break; + default: + MAX_PRN_IDX = 33; + } + + setup_fpga_switch(); + + unsigned int nsamples_to_transfer; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; + + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + + args.file = file; + + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; + + args.skip_used_samples = -DOWNAMPLING_FILTER_INIT_SAMPLES; + + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start = 0; + + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; + } + else + { + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = 0; + } + + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + + acquisition->reset(); // set active + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do + { + usleep(100000); + } + while (msg_rx->rx_message == 0); + + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); + code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } + + + top_block->stop(); + + std::cout.flush(); + } + + std::cout << "]" << std::endl; + std::cout << "-------------------------------------------\n"; + + for (auto& x : doppler_measurements_map) + { + std::cout << "DETECTED SATELLITE " << System_and_Signal << " PRN: " << x.first << " with Doppler: " << x.second << " [Hz], code phase: " << code_delay_measurements_map.at(x.first) << " [samples] at signal SampleStamp " << acq_samplestamp_map.at(x.first) << "\n"; + } + + + // report the elapsed time + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + std::cout << "Total signal acquisition run time " + << elapsed_seconds.count() + << " [seconds]" << std::endl; + return true; +} + +TEST_F(TrackingPullInTestFpga, ValidationOfResults) +{ + // pointer to the DMA thread that sends the samples to the acquisition engine + pthread_t thread_DMA; + + + struct DMA_handler_args args; + + + //************************************************* + //***** STEP 1: Prepare the parameters sweep ****** + //************************************************* + std::vector + acq_doppler_error_hz_values; + std::vector> acq_delay_error_chips_values; //vector of vector + + for (double doppler_hz = FLAGS_acq_Doppler_error_hz_start; doppler_hz >= FLAGS_acq_Doppler_error_hz_stop; doppler_hz = doppler_hz + FLAGS_acq_Doppler_error_hz_step) + { + acq_doppler_error_hz_values.push_back(doppler_hz); + std::vector tmp_vector; + //Code Delay Sweep + for (double code_delay_chips = FLAGS_acq_Delay_error_chips_start; code_delay_chips >= FLAGS_acq_Delay_error_chips_stop; code_delay_chips = code_delay_chips + FLAGS_acq_Delay_error_chips_step) + { + tmp_vector.push_back(code_delay_chips); + } + acq_delay_error_chips_values.push_back(tmp_vector); + } + + + //*********************************************************** + //***** STEP 2: Generate the input signal (if required) ***** + //*********************************************************** + std::vector generator_CN0_values; + if (FLAGS_enable_external_signal_file) + { + generator_CN0_values.push_back(999); // an external input signal capture is selected, no CN0 information available + } + else + { + if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop) + { + generator_CN0_values.push_back(FLAGS_CN0_dBHz_start); + } + else + { + for (double cn0 = FLAGS_CN0_dBHz_start; cn0 > FLAGS_CN0_dBHz_stop; cn0 = cn0 - FLAGS_CN0_dB_step) + { + generator_CN0_values.push_back(cn0); + } + } + } + + + // use generator or use an external capture file + if (FLAGS_enable_external_signal_file) + { + //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters + ASSERT_EQ(acquire_signal(FLAGS_test_satellite_PRN), true); + bool found_satellite = doppler_measurements_map.find(FLAGS_test_satellite_PRN) != doppler_measurements_map.end(); + EXPECT_TRUE(found_satellite) << "Error: satellite SV: " << FLAGS_test_satellite_PRN << " is not acquired"; + if (!found_satellite) return; + } + else + { + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + // Configure the signal generator + configure_generator(generator_CN0_values.at(current_cn0_idx), current_cn0_idx); + // Generate signal raw signal samples and observations RINEX file + if (FLAGS_disable_generator == false) + { + generate_signal(); + } + } + } + + configure_receiver(FLAGS_PLL_bw_hz_start, + FLAGS_DLL_bw_hz_start, + FLAGS_PLL_narrow_bw_hz, + FLAGS_DLL_narrow_bw_hz, + FLAGS_extend_correlation_symbols); + + + //****************************************************************************************** + //***** Obtain the initial signal sinchronization parameters (emulating an acquisition) **** + //****************************************************************************************** + int test_satellite_PRN = 0; + double true_acq_doppler_hz = 0.0; + double true_acq_delay_samples = 0.0; + uint64_t acq_samplestamp_samples = 0; + + Tracking_True_Obs_Reader true_obs_data; + if (!FLAGS_enable_external_signal_file) + { + test_satellite_PRN = FLAGS_test_satellite_PRN; + std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); + true_obs_file.append(std::to_string(test_satellite_PRN)); + true_obs_file.append(".dat"); + true_obs_data.close_obs_file(); + ASSERT_EQ(true_obs_data.open_obs_file(true_obs_file), true) << "Failure opening true observables file"; + // load acquisition data based on the first epoch of the true observations + ASSERT_EQ(true_obs_data.read_binary_obs(), true) + << "Failure reading true tracking dump file." << std::endl + << "Maybe sat PRN #" + std::to_string(FLAGS_test_satellite_PRN) + + " is not available?"; + std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl; + std::cout << "True Initial Doppler " << true_obs_data.doppler_l1_hz << " [Hz], true Initial code delay [Chips]=" << true_obs_data.prn_delay_chips << "[Chips]" << std::endl; + true_acq_doppler_hz = true_obs_data.doppler_l1_hz; + true_acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * static_cast(baseband_sampling_freq) * GPS_L1_CA_CODE_PERIOD; + acq_samplestamp_samples = 0; + } + else + { + true_acq_doppler_hz = doppler_measurements_map.find(FLAGS_test_satellite_PRN)->second; + true_acq_delay_samples = code_delay_measurements_map.find(FLAGS_test_satellite_PRN)->second; + acq_samplestamp_samples = acq_samplestamp_map.find(FLAGS_test_satellite_PRN)->second; + std::cout << "Estimated Initial Doppler " << true_acq_doppler_hz + << " [Hz], estimated Initial code delay " << true_acq_delay_samples << " [Samples]" + << " Acquisition SampleStamp is " << acq_samplestamp_samples << std::endl; + } + + std::vector> pull_in_results_v_v; + + unsigned int code_length; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); + } + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); + } + + float nbits = ceilf(log2f((float)code_length)); + unsigned int fft_size = pow(2, nbits); + + // The HW has been reset after the acquisition phase when the acquisition class was destroyed. + // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the + // GPS L1 / Galileo E1 filter has been cleared. + // During this test all the samples coming from the DMA are consumed so in principle there would be + // no need to reset the HW. However we need to clear the sample counter in each test. Therefore we have + // to reset the HW at the beginning of each test. + + // instantiate the acquisition modules in order to use them to reset the HW. + // (note that the constructor of the acquisition modules resets the HW too) + + std::shared_ptr acquisition; + + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + std::vector pull_in_results_v; + for (unsigned int current_acq_doppler_error_idx = 0; current_acq_doppler_error_idx < acq_doppler_error_hz_values.size(); current_acq_doppler_error_idx++) + { + for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) + { + // reset the HW to clear the sample counters + acquisition->stop_acquisition(); + + gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; + //simulate a Doppler error in acquisition + gnss_synchro.Acq_doppler_hz = true_acq_doppler_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx); + //simulate Code Delay error in acquisition + gnss_synchro.Acq_delay_samples = true_acq_delay_samples + (acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) / GPS_L1_CA_CODE_RATE_HZ) * static_cast(baseband_sampling_freq); + + //create flowgraph + top_block = gr::make_top_block("Tracking test"); + std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); + boost::shared_ptr msg_rx = TrackingPullInTestFpga_msg_rx_make(); + + ASSERT_NO_THROW({ + tracking->set_channel(gnss_synchro.Channel_ID); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + tracking->set_gnss_synchro(&gnss_synchro); + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + tracking->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + + ASSERT_NO_THROW({ + gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); + top_block->connect(tracking->get_right_block(), 0, sink, 0); + top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting the blocks of tracking test."; + + + std::string file = FLAGS_signal_file; + + args.file = file; + + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (gnss_synchro.PRN - 1) * fft_size; + } + else + { + args.skip_used_samples = 0; + } + + + //******************************************************************** + //***** STEP 5: Perform the signal tracking and read the results ***** + //******************************************************************** + + + args.nsamples_tx = baseband_sampling_freq * FLAGS_duration; + + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + + std::cout << "--- START TRACKING WITH PULL-IN ERROR: " << acq_doppler_error_hz_values.at(current_acq_doppler_error_idx) << " [Hz] and " << acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) << " [Chips] ---" << std::endl; + + tracking->start_tracking(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + top_block->start(); + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + top_block->stop(); + + // reset the HW to launch the pending interrupts + acquisition->stop_acquisition(); + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + + pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock + + //******************************** + //***** STEP 7: Plot results ***** + //******************************** + if (FLAGS_plot_detail_level >= 2 and FLAGS_show_plots) + { + //load the measured values + Tracking_Dump_Reader trk_dump; + ASSERT_EQ(trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")), true) + << "Failure opening tracking dump file"; + + int64_t n_measured_epochs = trk_dump.num_epochs(); + //todo: use vectors instead + arma::vec trk_timestamp_s = arma::zeros(n_measured_epochs, 1); + arma::vec trk_acc_carrier_phase_cycles = arma::zeros(n_measured_epochs, 1); + arma::vec trk_Doppler_Hz = arma::zeros(n_measured_epochs, 1); + arma::vec trk_prn_delay_chips = arma::zeros(n_measured_epochs, 1); + std::vector timestamp_s; + std::vector prompt; + std::vector early; + std::vector late; + std::vector v_early; + std::vector v_late; + std::vector promptI; + std::vector promptQ; + std::vector CN0_dBHz; + std::vector Doppler; + int64_t epoch_counter = 0; + while (trk_dump.read_binary_obs()) + { + trk_timestamp_s(epoch_counter) = static_cast(trk_dump.PRN_start_sample_count) / static_cast(baseband_sampling_freq); + trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI; + trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz; + double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast(baseband_sampling_freq), 1.0e-3) / 1.0e-3); + + trk_prn_delay_chips(epoch_counter) = delay_chips; + + timestamp_s.push_back(trk_timestamp_s(epoch_counter)); + prompt.push_back(trk_dump.abs_P); + early.push_back(trk_dump.abs_E); + late.push_back(trk_dump.abs_L); + v_early.push_back(trk_dump.abs_VE); + v_late.push_back(trk_dump.abs_VL); + promptI.push_back(trk_dump.prompt_I); + promptQ.push_back(trk_dump.prompt_Q); + CN0_dBHz.push_back(trk_dump.CN0_SNV_dB_Hz); + Doppler.push_back(trk_dump.carrier_doppler_hz); + epoch_counter++; + } + + + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if (gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag show_plots has been set to TRUE," << std::endl; + std::cout << "gnuplot has not been found in your system." << std::endl; + std::cout << "Test results will not be plotted." << std::endl; + } + else + { + try + { + boost::filesystem::path p(gnuplot_executable); + boost::filesystem::path dir = p.parent_path(); + std::string gnuplot_path = dir.native(); + Gnuplot::set_GNUPlotPath(gnuplot_path); + unsigned int decimate = static_cast(FLAGS_plot_decimate); + + if (FLAGS_plot_detail_level >= 2 and FLAGS_show_plots) + { + Gnuplot g1("linespoints"); + g1.showonscreen(); // window output + if (!FLAGS_enable_external_signal_file) + { + g1.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, " + "PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g1.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + + g1.set_grid(); + g1.set_xlabel("Time [s]"); + g1.set_ylabel("Correlators' output"); + //g1.cmd("set key box opaque"); + g1.plot_xy(trk_timestamp_s, prompt, "Prompt", decimate); + g1.plot_xy(trk_timestamp_s, early, "Early", decimate); + g1.plot_xy(trk_timestamp_s, late, "Late", decimate); + if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) + { + g1.plot_xy(trk_timestamp_s, v_early, "Very Early", decimate); + g1.plot_xy(trk_timestamp_s, v_late, "Very Late", decimate); + } + g1.set_legend(); + g1.savetops("Correlators_outputs"); + + Gnuplot g2("points"); + g2.showonscreen(); // window output + if (!FLAGS_enable_external_signal_file) + { + g2.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz Constellation " + "PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g2.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + + g2.set_grid(); + g2.set_xlabel("Inphase"); + g2.set_ylabel("Quadrature"); + //g2.cmd("set size ratio -1"); + g2.plot_xy(promptI, promptQ); + g2.savetops("Constellation"); + + Gnuplot g3("linespoints"); + if (!FLAGS_enable_external_signal_file) + { + g3.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, GPS L1 C/A tracking CN0 output (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g3.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips] PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Reported CN0 [dB-Hz]"); + g3.cmd("set key box opaque"); + + g3.plot_xy(trk_timestamp_s, CN0_dBHz, + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate); + + g3.set_legend(); + g3.savetops("CN0_output"); + + g3.showonscreen(); // window output + + Gnuplot g4("linespoints"); + if (!FLAGS_enable_external_signal_file) + { + g4.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, GPS L1 C/A tracking CN0 output (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + else + { + g4.set_title("D_e=" + std::to_string(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)) + " [Hz] " + "T_e= " + std::to_string(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)) + " [Chips] PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + g4.set_grid(); + g4.set_xlabel("Time [s]"); + g4.set_ylabel("Estimated Doppler [Hz]"); + g4.cmd("set key box opaque"); + + g4.plot_xy(trk_timestamp_s, Doppler, + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate); + + g4.set_legend(); + g4.savetops("Doppler"); + + g4.showonscreen(); // window output + } + } + catch (const GnuplotException& ge) + { + std::cout << ge.what() << std::endl; + } + } + } //end plot + + } //end acquisition Delay errors loop + + usleep(100000); // give time to the HW to consume all the remaining samples + + } //end acquisition Doppler errors loop + + pull_in_results_v_v.push_back(pull_in_results_v); + + } //end CN0 LOOP + //build the mesh grid + + std::vector doppler_error_mesh; + std::vector code_delay_error_mesh; + for (unsigned int current_acq_doppler_error_idx = 0; current_acq_doppler_error_idx < acq_doppler_error_hz_values.size(); current_acq_doppler_error_idx++) + { + for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) + { + doppler_error_mesh.push_back(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx)); + code_delay_error_mesh.push_back(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx)); + } + } + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) + { + std::vector pull_in_result_mesh; + pull_in_result_mesh = pull_in_results_v_v.at(current_cn0_idx); + //plot grid + + if (FLAGS_show_plots) + { + Gnuplot g4("points palette pointsize 2 pointtype 7"); + g4.showonscreen(); // window output + g4.cmd("set palette defined ( 0 \"black\", 1 \"green\" )"); + g4.cmd("set key off"); + g4.cmd("set view map"); + std::string title; + if (!FLAGS_enable_external_signal_file) + { + title = std::string("Tracking Pull-in result grid at CN0:" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + " [dB-Hz], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz]."); + } + else + { + title = std::string("Tracking Pull-in result grid, PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + + g4.set_title(title); + g4.set_grid(); + g4.set_xlabel("Acquisition Doppler error [Hz]"); + g4.set_ylabel("Acquisition Code Delay error [Chips]"); + g4.cmd("set cbrange[0:1]"); + g4.plot_xyz(doppler_error_mesh, + code_delay_error_mesh, + pull_in_result_mesh); + g4.set_legend(); + if (!FLAGS_enable_external_signal_file) + { + g4.savetops("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx))))); + g4.savetopdf("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))), 12); + } + else + { + g4.savetops("trk_pull_in_grid_external_file"); + g4.savetopdf("trk_pull_in_grid_external_file", 12); + } + } + } +} diff --git a/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc b/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc index d73c9e767..b69c8fd15 100644 --- a/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc +++ b/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc @@ -31,8 +31,8 @@ */ -#include "gnss_signal_processing.h" #include "glonass_gnav_ephemeris.h" +#include "gnss_signal_processing.h" TEST(GlonassGnavEphemerisTest, ComputeGlonassTime) diff --git a/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc b/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc index f42a0d04d..0f570fe2a 100644 --- a/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc +++ b/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc @@ -31,8 +31,8 @@ * ------------------------------------------------------------------------- */ -#include "gnss_signal_processing.h" #include "glonass_gnav_navigation_message.h" +#include "gnss_signal_processing.h" /*! * \brief Testing CRC computation for GLONASS GNAV data bits of a string @@ -126,7 +126,7 @@ TEST(GlonassGnavNavigationMessageTest, String2Decoder) // Fill out ephemeris values for truth gnav_ephemeris.d_B_n = 0; - gnav_ephemeris.d_P_2 = 1; + gnav_ephemeris.d_P_2 = true; gnav_ephemeris.d_t_b = 8100; gnav_ephemeris.d_VYn = -2.69022750854492; gnav_ephemeris.d_AYn = 0; @@ -162,10 +162,10 @@ TEST(GlonassGnavNavigationMessageTest, String3Decoder) Glonass_Gnav_Ephemeris gnav_ephemeris; // Fill out ephemeris values for truth - gnav_ephemeris.d_P_3 = 1; + gnav_ephemeris.d_P_3 = true; gnav_ephemeris.d_gamma_n = 1.81898940354586e-12; gnav_ephemeris.d_P = 3; - gnav_ephemeris.d_l3rd_n = 0; + gnav_ephemeris.d_l3rd_n = false; gnav_ephemeris.d_VZn = -1.82016849517822; gnav_ephemeris.d_AZn = -2.79396772384644e-09; gnav_ephemeris.d_Zn = 19929.2377929688; @@ -203,7 +203,7 @@ TEST(GlonassGnavNavigationMessageTest, String4Decoder) gnav_ephemeris.d_tau_n = -8.30907374620438e-05; gnav_ephemeris.d_Delta_tau_n = 9.31322574615479e-10; gnav_ephemeris.d_E_n = 0; - gnav_ephemeris.d_P_4 = 0; + gnav_ephemeris.d_P_4 = false; gnav_ephemeris.d_F_T = 6; gnav_ephemeris.d_N_T = 268; gnav_ephemeris.d_n = 21; diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 1396ed3e6..c68294b45 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -17,3 +17,7 @@ # add_subdirectory(front-end-cal) + +if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) + add_subdirectory(rinex2assist) +endif() diff --git a/src/utils/front-end-cal/CMakeLists.txt b/src/utils/front-end-cal/CMakeLists.txt index 03d6bc956..a8d0e244e 100644 --- a/src/utils/front-end-cal/CMakeLists.txt +++ b/src/utils/front-end-cal/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -17,101 +17,91 @@ # -if(OPENSSL_FOUND) - add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) -endif(OPENSSL_FOUND) - set(FRONT_END_CAL_SOURCES front_end_cal.cc) +set(FRONT_END_CAL_HEADERS front_end_cal.h) -include_directories( - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/core/libs - ${CMAKE_SOURCE_DIR}/src/core/libs/supl - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp - ${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${GNURADIO_BLOCKS_INCLUDE_DIRS} - ${ARMADILLO_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${VOLK_GNSSSDR_INCLUDE_DIRS} -) - -file(GLOB FRONT_END_CAL_HEADERS "*.h") -list(SORT FRONT_END_CAL_HEADERS) add_library(front_end_cal_lib ${FRONT_END_CAL_SOURCES} ${FRONT_END_CAL_HEADERS}) source_group(Headers FILES ${FRONT_END_CAL_HEADERS}) -target_link_libraries(front_end_cal_lib ${MAC_LIBRARIES} - ${Boost_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FFT_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${ARMADILLO_LIBRARIES} - ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} - ${GNSS_SDR_OPTIONAL_LIBS} - rx_core_lib - gnss_sdr_flags - gnss_rx - channel_fsm +target_link_libraries(front_end_cal_lib + PUBLIC + Armadillo::armadillo + Threads::Threads + Volkgnsssdr::volkgnsssdr ${ORC_LIBRARIES} + signal_source_adapters + signal_source_gr_blocks + signal_source_libs + acquisition_adapters + gnss_sdr_flags + channel_libs + algorithms_libs + core_receiver + core_libs + PRIVATE + Boost::boost + Gflags::gflags + Glog::glog + Gnuradio::blocks + Gnuradio::runtime ) - -add_dependencies(front_end_cal_lib glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) -add_definitions( -DGNSS_SDR_VERSION="${VERSION}" ) -add_definitions( -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" ) +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(front_end_cal_lib + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() add_executable(front-end-cal ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) -add_custom_command(TARGET front-end-cal POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$) - - -target_link_libraries(front-end-cal ${MAC_LIBRARIES} - ${Boost_LIBRARIES} - ${GNURADIO_RUNTIME_LIBRARIES} - ${GNURADIO_BLOCKS_LIBRARIES} - ${GNURADIO_FFT_LIBRARIES} - ${GNURADIO_FILTER_LIBRARIES} - ${GFlags_LIBS} - ${GLOG_LIBRARIES} - ${ARMADILLO_LIBRARIES} - ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} - ${GNSS_SDR_OPTIONAL_LIBS} - rx_core_lib - gnss_rx - front_end_cal_lib +target_link_libraries(front-end-cal + PUBLIC + Volkgnsssdr::volkgnsssdr ${ORC_LIBRARIES} + core_libs + core_receiver + front_end_cal_lib + gnss_sdr_flags + PRIVATE + Boost::filesystem + Gflags::gflags + Glog::glog ) - +target_compile_definitions(front-end-cal + PUBLIC -DGNSS_SDR_VERSION="${VERSION}" + PUBLIC -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" +) + +if(ENABLE_CLANG_TIDY) + if(CLANG_TIDY_EXE) + set_target_properties(front-end-cal + PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) + endif() +endif() + +add_custom_command(TARGET front-end-cal POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$) + install(TARGETS front-end-cal - RUNTIME DESTINATION bin - COMPONENT "front-end-cal" + RUNTIME DESTINATION bin + COMPONENT "front-end-cal" ) find_program(GZIP gzip - /bin - /usr/bin - /usr/local/bin - /opt/local/bin - /sbin - ) + /bin + /usr/bin + /usr/local/bin + /opt/local/bin + /sbin +) if(NOT GZIP_NOTFOUND) execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/docs/manpage/front-end-cal-manpage - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/front-end-cal.1.gz") - + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/front-end-cal.1.gz") install(FILES ${CMAKE_BINARY_DIR}/front-end-cal.1.gz DESTINATION share/man/man1) -endif(NOT GZIP_NOTFOUND) - - +endif() diff --git a/src/utils/front-end-cal/front_end_cal.cc b/src/utils/front-end-cal/front_end_cal.cc index 6b8b937ac..58e38e067 100644 --- a/src/utils/front-end-cal/front_end_cal.cc +++ b/src/utils/front-end-cal/front_end_cal.cc @@ -30,36 +30,34 @@ */ #include "front_end_cal.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "gps_navigation_message.h" -#include "gps_ephemeris.h" -#include "gps_cnav_ephemeris.h" -#include "gps_almanac.h" -#include "gps_iono.h" -#include "gps_cnav_iono.h" -#include "gps_utc_model.h" #include "gnss_sdr_supl_client.h" +#include "gps_almanac.h" +#include "gps_cnav_ephemeris.h" +#include "gps_cnav_iono.h" +#include "gps_ephemeris.h" +#include "gps_iono.h" +#include "gps_navigation_message.h" +#include "gps_utc_model.h" +#include +#include +#include +#include +#include +#include -extern concurrent_map global_gps_ephemeris_map; -extern concurrent_map global_gps_iono_map; -extern concurrent_map global_gps_utc_model_map; -extern concurrent_map global_gps_almanac_map; -extern concurrent_map global_gps_acq_assist_map; +extern Concurrent_Map global_gps_ephemeris_map; +extern Concurrent_Map global_gps_iono_map; +extern Concurrent_Map global_gps_utc_model_map; +extern Concurrent_Map global_gps_almanac_map; +extern Concurrent_Map global_gps_acq_assist_map; -FrontEndCal::FrontEndCal() {} +FrontEndCal::FrontEndCal() = default; -FrontEndCal::~FrontEndCal() {} +FrontEndCal::~FrontEndCal() = default; bool FrontEndCal::read_assistance_from_XML() { - gnss_sdr_supl_client supl_client_ephemeris_; + Gnss_Sdr_Supl_Client supl_client_ephemeris_; std::string eph_xml_filename = "gps_ephemeris.xml"; std::cout << "SUPL: Trying to read GPS ephemeris from XML file " << eph_xml_filename << std::endl; LOG(INFO) << "SUPL: Trying to read GPS ephemeris from XML file " << eph_xml_filename; @@ -77,20 +75,17 @@ bool FrontEndCal::read_assistance_from_XML() } return true; } - else - { - std::cout << "ERROR: SUPL client error reading XML" << std::endl; - LOG(WARNING) << "ERROR: SUPL client error reading XML"; - return false; - } + std::cout << "ERROR: SUPL client error reading XML" << std::endl; + LOG(WARNING) << "ERROR: SUPL client error reading XML"; + return false; } int FrontEndCal::Get_SUPL_Assist() { //######### GNSS Assistance ################################# - gnss_sdr_supl_client supl_client_acquisition_; - gnss_sdr_supl_client supl_client_ephemeris_; + Gnss_Sdr_Supl_Client supl_client_acquisition_; + Gnss_Sdr_Supl_Client supl_client_ephemeris_; int supl_mcc; // Current network MCC (Mobile country code), 3 digits. int supl_mns; //Current network MNC (Mobile Network code), 2 or 3 digits. int supl_lac; // Current network LAC (Location area code),16 bits, 1-65520 are valid values. @@ -110,7 +105,7 @@ int FrontEndCal::Get_SUPL_Assist() supl_client_ephemeris_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port", 7275); supl_client_acquisition_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_port", 7275); supl_mcc = configuration_->property("GNSS-SDR.SUPL_MCC", 244); - supl_mns = configuration_->property("GNSS-SDR.SUPL_MNS", 5); + supl_mns = configuration_->property("GNSS-SDR.SUPL_MNC", 5); std::string default_lac = "0x59e2"; std::string default_ci = "0x31b0"; @@ -235,7 +230,7 @@ int FrontEndCal::Get_SUPL_Assist() void FrontEndCal::set_configuration(std::shared_ptr configuration) { - configuration_ = configuration; + configuration_ = std::move(configuration); } @@ -255,29 +250,18 @@ bool FrontEndCal::get_ephemeris() { return true; } - else - { - return false; - } - } - else - { - return true; - } - } - else - { - std::cout << "Trying to read ephemeris from SUPL server..." << std::endl; - LOG(INFO) << "Trying to read ephemeris from SUPL server..."; - if (Get_SUPL_Assist() == 0) - { - return true; - } - else - { return false; } + return true; } + + std::cout << "Trying to read ephemeris from SUPL server..." << std::endl; + LOG(INFO) << "Trying to read ephemeris from SUPL server..."; + if (Get_SUPL_Assist() == 0) + { + return true; + } + return false; } @@ -371,15 +355,12 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub //Doppler estimation arma::vec Doppler_Hz; - Doppler_Hz = (obs_to_sat_velocity / GPS_C_m_s) * GPS_L1_FREQ_HZ; + Doppler_Hz = (obs_to_sat_velocity / GPS_C_M_S) * GPS_L1_FREQ_HZ; double mean_Doppler_Hz; mean_Doppler_Hz = arma::mean(Doppler_Hz); return mean_Doppler_Hz; } - else - { - throw(1); - } + throw(1); } diff --git a/src/utils/front-end-cal/front_end_cal.h b/src/utils/front-end-cal/front_end_cal.h index 3a6e9aeeb..261043461 100644 --- a/src/utils/front-end-cal/front_end_cal.h +++ b/src/utils/front-end-cal/front_end_cal.h @@ -32,9 +32,9 @@ #ifndef GNSS_SDR_FRONT_END_CAL_H_ #define GNSS_SDR_FRONT_END_CAL_H_ -#include -#include "file_configuration.h" #include "concurrent_map.h" +#include "file_configuration.h" +#include class FrontEndCal diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index cbdb6d28b..6d9380cb4 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -32,46 +32,48 @@ #define FRONT_END_CAL_VERSION "0.0.1" #endif -#include "front_end_cal.h" #include "concurrent_map.h" #include "concurrent_queue.h" #include "file_configuration.h" -#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" -#include "gnss_signal.h" -#include "gnss_synchro.h" -#include "gnss_block_factory.h" -#include "gps_navigation_message.h" -#include "gps_ephemeris.h" -#include "gps_cnav_ephemeris.h" -#include "gps_almanac.h" -#include "gps_iono.h" -#include "gps_cnav_iono.h" -#include "gps_utc_model.h" -#include "galileo_ephemeris.h" +#include "front_end_cal.h" #include "galileo_almanac.h" +#include "galileo_ephemeris.h" #include "galileo_iono.h" #include "galileo_utc_model.h" -#include "sbas_ephemeris.h" -#include "gnss_sdr_supl_client.h" +#include "gnss_block_factory.h" #include "gnss_sdr_flags.h" +#include "gnss_sdr_supl_client.h" +#include "gnss_signal.h" +#include "gnss_synchro.h" +#include "gps_almanac.h" +#include "gps_cnav_ephemeris.h" +#include "gps_cnav_iono.h" +#include "gps_ephemeris.h" +#include "gps_iono.h" +#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" +#include "gps_navigation_message.h" +#include "gps_utc_model.h" +#include "sbas_ephemeris.h" +#include #include #include -#include -#include #include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include #include +#include +#include #include // for ctime #include #include #include +#include +#include #include @@ -79,14 +81,14 @@ using google::LogMessage; DECLARE_string(log_dir); -concurrent_map global_gps_ephemeris_map; -concurrent_map global_gps_iono_map; -concurrent_map global_gps_utc_model_map; -concurrent_map global_gps_almanac_map; -concurrent_map global_gps_acq_assist_map; +Concurrent_Map global_gps_ephemeris_map; +Concurrent_Map global_gps_iono_map; +Concurrent_Map global_gps_utc_model_map; +Concurrent_Map global_gps_almanac_map; +Concurrent_Map global_gps_acq_assist_map; bool stop; -concurrent_queue channel_internal_queue; +Concurrent_Queue channel_internal_queue; GpsL1CaPcpsAcquisitionFineDoppler* acquisition; Gnss_Synchro* gnss_synchro; std::vector gnss_sync_vector; @@ -95,7 +97,7 @@ std::vector gnss_sync_vector; // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class FrontEndCal_msg_rx; -typedef boost::shared_ptr FrontEndCal_msg_rx_sptr; +using FrontEndCal_msg_rx_sptr = boost::shared_ptr; FrontEndCal_msg_rx_sptr FrontEndCal_msg_rx_make(); @@ -123,7 +125,7 @@ void FrontEndCal_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - long int message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; channel_internal_queue.push(rx_message); } @@ -143,11 +145,9 @@ FrontEndCal_msg_rx::FrontEndCal_msg_rx() : gr::block("FrontEndCal_msg_rx", gr::i } -FrontEndCal_msg_rx::~FrontEndCal_msg_rx() {} +FrontEndCal_msg_rx::~FrontEndCal_msg_rx() = default; -// ########################################################### - void wait_message() { while (!stop) @@ -174,7 +174,7 @@ void wait_message() } -bool front_end_capture(std::shared_ptr configuration) +bool front_end_capture(const std::shared_ptr& configuration) { gr::top_block_sptr top_block; GNSSBlockFactory block_factory; @@ -191,7 +191,7 @@ bool front_end_capture(std::shared_ptr configuration) catch (const boost::exception_ptr& e) { std::cout << "Exception caught in creating source " << e << std::endl; - return 0; + return false; } std::shared_ptr conditioner; @@ -202,13 +202,13 @@ bool front_end_capture(std::shared_ptr configuration) catch (const boost::exception_ptr& e) { std::cout << "Exception caught in creating signal conditioner " << e << std::endl; - return 0; + return false; } gr::block_sptr sink; sink = gr::blocks::file_sink::make(sizeof(gr_complex), "tmp_capture.dat"); //--- Find number of samples per spreading code --- - long fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); + int64_t fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); int samples_per_code = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); int nsamples = samples_per_code * 50; @@ -234,13 +234,11 @@ bool front_end_capture(std::shared_ptr configuration) return false; } - //delete conditioner; - //delete source; return true; } -static time_t utc_time(int week, long tow) +static time_t utc_time(int week, int64_t tow) { time_t t; @@ -275,7 +273,6 @@ int main(int argc, char** argv) if (FLAGS_log_dir.empty()) { std::cout << "Logging will be done at " - << "/tmp" << std::endl << "Use front-end-cal --log_dir=/path/to/log to change that." @@ -296,23 +293,26 @@ int main(int argc, char** argv) << FLAGS_log_dir << std::endl; } - // 0. Instantiate the FrontEnd Calibration class FrontEndCal front_end_cal; // 1. Load configuration parameters from config file - std::shared_ptr configuration = std::make_shared(FLAGS_config_file); - front_end_cal.set_configuration(configuration); - // 2. Get SUPL information from server: Ephemeris record, assistance info and TOW - if (front_end_cal.get_ephemeris() == true) + try { - std::cout << "SUPL data received OK!" << std::endl; + if (front_end_cal.get_ephemeris() == true) + { + std::cout << "SUPL data received OK!" << std::endl; + } + else + { + std::cout << "Failure connecting to SUPL server" << std::endl; + } } - else + catch (const boost::exception& e) { std::cout << "Failure connecting to SUPL server" << std::endl; } @@ -354,14 +354,15 @@ int main(int argc, char** argv) signal.copy(gnss_synchro->Signal, 2, 0); gnss_synchro->PRN = 1; - long fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); + int64_t fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); + configuration->set_property("Acquisition.max_dwells", "10"); GNSSBlockFactory block_factory; acquisition = new GpsL1CaPcpsAcquisitionFineDoppler(configuration.get(), "Acquisition", 1, 1); acquisition->set_channel(1); acquisition->set_gnss_synchro(gnss_synchro); - acquisition->set_threshold(configuration->property("Acquisition.threshold", 0.0)); + acquisition->set_threshold(configuration->property("Acquisition.threshold", 2.0)); acquisition->set_doppler_max(configuration->property("Acquisition.doppler_max", 10000)); acquisition->set_doppler_step(configuration->property("Acquisition.doppler_step", 250)); @@ -378,11 +379,6 @@ int main(int argc, char** argv) exit(0); } - //gr_basic_block_sptr head = gr_make_head(sizeof(gr_complex), nsamples); - //gr_head_sptr head_sptr = boost::dynamic_pointer_cast(head); - //head_sptr->set_length(nsamples); - //head_sptr->reset(); - try { acquisition->connect(top_block); @@ -402,11 +398,11 @@ int main(int argc, char** argv) std::map doppler_measurements_map; std::map cn0_measurements_map; - boost::thread ch_thread; + std::thread ch_thread; // record startup time std::chrono::time_point start, end; - std::chrono::duration elapsed_seconds; + std::chrono::duration elapsed_seconds{}; start = std::chrono::system_clock::now(); bool start_msg = true; @@ -421,9 +417,9 @@ int main(int argc, char** argv) stop = false; try { - ch_thread = boost::thread(wait_message); + ch_thread = std::thread(wait_message); } - catch (const boost::thread_resource_error& e) + catch (const std::exception& e) { LOG(INFO) << "Exception caught (thread resource error)"; } @@ -434,13 +430,13 @@ int main(int argc, char** argv) std::cout << "["; start_msg = false; } - if (gnss_sync_vector.size() > 0) + if (!gnss_sync_vector.empty()) { std::cout << " " << PRN << " "; double doppler_measurement_hz = 0; - for (std::vector::iterator it = gnss_sync_vector.begin(); it != gnss_sync_vector.end(); ++it) + for (auto& it : gnss_sync_vector) { - doppler_measurement_hz += (*it).Acq_doppler_hz; + doppler_measurement_hz += it.Acq_doppler_hz; } doppler_measurement_hz = doppler_measurement_hz / gnss_sync_vector.size(); doppler_measurements_map.insert(std::pair(PRN, doppler_measurement_hz)); @@ -449,12 +445,19 @@ int main(int argc, char** argv) { std::cout << " . "; } - channel_internal_queue.push(3); + try + { + channel_internal_queue.push(3); + } + catch (const boost::exception& e) + { + LOG(INFO) << "Exception caught while pushing to the internal queue."; + } try { ch_thread.join(); } - catch (const boost::thread_resource_error& e) + catch (const std::exception& e) { LOG(INFO) << "Exception caught while joining threads."; } @@ -471,26 +474,37 @@ int main(int argc, char** argv) << elapsed_seconds.count() << " [seconds]" << std::endl; - //6. find TOW from SUPL assistance - + // 6. find TOW from SUPL assistance double current_TOW = 0; - if (global_gps_ephemeris_map.size() > 0) + try { - std::map Eph_map; - Eph_map = global_gps_ephemeris_map.get_map_copy(); - current_TOW = Eph_map.begin()->second.d_TOW; + if (global_gps_ephemeris_map.size() > 0) + { + std::map Eph_map; + Eph_map = global_gps_ephemeris_map.get_map_copy(); + current_TOW = Eph_map.begin()->second.d_TOW; - time_t t = utc_time(Eph_map.begin()->second.i_GPS_week, (long int)current_TOW); + time_t t = utc_time(Eph_map.begin()->second.i_GPS_week, static_cast(current_TOW)); - fprintf(stdout, "Reference Time:\n"); - fprintf(stdout, " GPS Week: %d\n", Eph_map.begin()->second.i_GPS_week); - fprintf(stdout, " GPS TOW: %ld %lf\n", (long int)current_TOW, (long int)current_TOW * 0.08); - fprintf(stdout, " ~ UTC: %s", ctime(&t)); - std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << std::endl; + std::cout << "Reference Time:" << std::endl; + std::cout << " GPS Week: " << Eph_map.begin()->second.i_GPS_week << std::endl; + std::cout << " GPS TOW: " << static_cast(current_TOW) << " " << static_cast(current_TOW) * 0.08 << std::endl; + std::cout << " ~ UTC: " << ctime(&t) << std::endl; + std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << std::endl; + } + else + { + std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!" << std::endl; + delete acquisition; + delete gnss_synchro; + google::ShutDownCommandLineFlags(); + std::cout << "GNSS-SDR Front-end calibration program ended." << std::endl; + return 0; + } } - else + catch (const boost::exception& e) { - std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!" << std::endl; + std::cout << "Exception in getting Global ephemeris map" << std::endl; delete acquisition; delete gnss_synchro; google::ShutDownCommandLineFlags(); @@ -498,18 +512,18 @@ int main(int argc, char** argv) return 0; } - //Get user position from config file (or from SUPL using GSM Cell ID) + // Get user position from config file (or from SUPL using GSM Cell ID) double lat_deg = configuration->property("GNSS-SDR.init_latitude_deg", 41.0); double lon_deg = configuration->property("GNSS-SDR.init_longitude_deg", 2.0); double altitude_m = configuration->property("GNSS-SDR.init_altitude_m", 100); std::cout << "Reference location (defined in config file):" << std::endl; - std::cout << "Latitude=" << lat_deg << " [�]" << std::endl; - std::cout << "Longitude=" << lon_deg << " [�]" << std::endl; + std::cout << "Latitude=" << lat_deg << " [º]" << std::endl; + std::cout << "Longitude=" << lon_deg << " [º]" << std::endl; std::cout << "Altitude=" << altitude_m << " [m]" << std::endl; - if (doppler_measurements_map.size() == 0) + if (doppler_measurements_map.empty()) { std::cout << "Sorry, no GPS satellites detected in the front-end capture, please check the antenna setup..." << std::endl; delete acquisition; @@ -527,21 +541,21 @@ int main(int argc, char** argv) std::cout << "SV ID Measured [Hz] Predicted [Hz]" << std::endl; - for (std::map::iterator it = doppler_measurements_map.begin(); it != doppler_measurements_map.end(); ++it) + for (auto& it : doppler_measurements_map) { try { double doppler_estimated_hz; - doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it->first, current_TOW, lat_deg, lon_deg, altitude_m); - std::cout << " " << it->first << " " << it->second << " " << doppler_estimated_hz << std::endl; + doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it.first, current_TOW, lat_deg, lon_deg, altitude_m); + std::cout << " " << it.first << " " << it.second << " " << doppler_estimated_hz << std::endl; // 7. Compute front-end IF and sampling frequency estimation // Compare with the measurements and compute clock drift using FE model double estimated_fs_Hz, estimated_f_if_Hz, f_osc_err_ppm; - front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz, it->second, fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm); + front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz, it.second, fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm); - f_if_estimation_Hz_map.insert(std::pair(it->first, estimated_f_if_Hz)); - f_fs_estimation_Hz_map.insert(std::pair(it->first, estimated_fs_Hz)); - f_ppm_estimation_Hz_map.insert(std::pair(it->first, f_osc_err_ppm)); + f_if_estimation_Hz_map.insert(std::pair(it.first, estimated_f_if_Hz)); + f_fs_estimation_Hz_map.insert(std::pair(it.first, estimated_fs_Hz)); + f_ppm_estimation_Hz_map.insert(std::pair(it.first, f_osc_err_ppm)); } catch (const std::logic_error& e) { @@ -553,7 +567,7 @@ int main(int argc, char** argv) } catch (int ex) { - std::cout << " " << it->first << " " << it->second << " (Eph not found)" << std::endl; + std::cout << " " << it.first << " " << it.second << " (Eph not found)" << std::endl; } } @@ -563,11 +577,11 @@ int main(int argc, char** argv) double mean_osc_err_ppm = 0; int n_elements = f_if_estimation_Hz_map.size(); - for (std::map::iterator it = f_if_estimation_Hz_map.begin(); it != f_if_estimation_Hz_map.end(); ++it) + for (auto& it : f_if_estimation_Hz_map) { - mean_f_if_Hz += (*it).second; - mean_fs_Hz += f_fs_estimation_Hz_map.find((*it).first)->second; - mean_osc_err_ppm += f_ppm_estimation_Hz_map.find((*it).first)->second; + mean_f_if_Hz += it.second; + mean_fs_Hz += f_fs_estimation_Hz_map.find(it.first)->second; + mean_osc_err_ppm += f_ppm_estimation_Hz_map.find(it.first)->second; } mean_f_if_Hz /= n_elements; @@ -584,13 +598,13 @@ int main(int argc, char** argv) << "Corrected Doppler vs. Predicted" << std::endl; std::cout << "SV ID Corrected [Hz] Predicted [Hz]" << std::endl; - for (std::map::iterator it = doppler_measurements_map.begin(); it != doppler_measurements_map.end(); ++it) + for (auto& it : doppler_measurements_map) { try { double doppler_estimated_hz; - doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it->first, current_TOW, lat_deg, lon_deg, altitude_m); - std::cout << " " << it->first << " " << it->second - mean_f_if_Hz << " " << doppler_estimated_hz << std::endl; + doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it.first, current_TOW, lat_deg, lon_deg, altitude_m); + std::cout << " " << it.first << " " << it.second - mean_f_if_Hz << " " << doppler_estimated_hz << std::endl; } catch (const std::logic_error& e) { @@ -602,7 +616,7 @@ int main(int argc, char** argv) } catch (int ex) { - std::cout << " " << it->first << " " << it->second - mean_f_if_Hz << " (Eph not found)" << std::endl; + std::cout << " " << it.first << " " << it.second - mean_f_if_Hz << " (Eph not found)" << std::endl; } } diff --git a/src/utils/gpstk/gnsspvt/CMakeLists.txt b/src/utils/gpstk/gnsspvt/CMakeLists.txt deleted file mode 100644 index b7255c413..000000000 --- a/src/utils/gpstk/gnsspvt/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# CMAKE for GPSTK by Javier Arribas 2012 -cmake_minimum_required (VERSION 2.6) -project (gnsspvt_project) - -include_directories(${gnsspvt_project_SOURCE_DIR}/src) - -add_library (kml_printer_gpstk ${gnsspvt_project_SOURCE_DIR}/src/kml_printer_gpstk.cpp) -add_executable(gnsspvt ${gnsspvt_project_SOURCE_DIR}/src/gnsspvt.cpp) - -target_link_libraries (gnsspvt kml_printer_gpstk) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") - -find_package(GPSTK REQUIRED) - -if ( NOT GPSTK_FOUND ) - message(FATAL_ERROR "GPSTK library not found!") -endif( NOT GPSTK_FOUND ) - -find_package(GLOG REQUIRED) -if ( NOT GLOG_FOUND ) - message(FATAL_ERROR "GLOG library not found!") -endif( NOT GLOG_FOUND ) - -include_directories(${GLOG_INCLUDE_DIRS}) - -# IMPORTANT NOTICE: The GPSTK linking order is critical. First it is required to link agains libprocframe to avoid vtable errors -include_directories(${GPSTK_INCLUDE_DIR}/gpstk ${GEOMATICS_INCLUDE_DIR} ${PROCFRAME_INCLUDE_DIR} ${VDRAW_INCLUDE_DIR} ${VPLOT_INCLUDE_DIR} ${RXIO_INCLUDE_DIR}) -# set(LIBS ${LIBS} ${GPSTK_LIBRARIES} ${GEOMATICS_LIBRARIES} ${VDRAW_LIBRARIES} ${VPLOT_LIBRARIES} ${RXIO_LIBRARIES}) -set(LIBS ${LIBS} ${PROCFRAME_LIBRARIES} ${GPSTK_LIBRARIES} ${GEOMATICS_LIBRARIES} ${GLOG_LIBRARIES}) - - -target_link_libraries(gnsspvt ${LIBS}) - -message(STATUS "GPSTK_INCLUDE_DIR="${GLOG_LIBRARIES}) -#message(STATUS "GPSTK_LIBRARIES=${GPSTK_LIBRARIES}") -#message(STATUS "LIBS=${LIBS}") - -# debug info: print all variables -#get_cmake_property(_variableNames VARIABLES) -#foreach (_variableName ${_variableNames}) -# message(STATUS "${_variableName}=${${_variableName}}") -#endforeach() - -#get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) -#foreach(dir ${dirs}) -# message(STATUS "INCLUDE_DIRECTORIES='${dir}'") -#endforeach() - diff --git a/src/utils/gpstk/gnsspvt/CMakeModules/FindGLOG.cmake b/src/utils/gpstk/gnsspvt/CMakeModules/FindGLOG.cmake deleted file mode 100644 index c4ddbe28a..000000000 --- a/src/utils/gpstk/gnsspvt/CMakeModules/FindGLOG.cmake +++ /dev/null @@ -1,103 +0,0 @@ -# - Try to find the Google Glog library -# -# This module defines the following variables -# -# GLOG_FOUND - Was Glog found -# GLOG_INCLUDE_DIRS - the Glog include directories -# GLOG_LIBRARIES - Link to this -# -# This module accepts the following variables -# -# GLOG_ROOT - Can be set to Glog install path or Windows build path -# -#============================================================================= -# FindGlog.cmake, adapted from FindBullet.cmake which has the following -# copyright - -#----------------------------------------------------------------------------- -# Copyright 2009 Kitware, Inc. -# Copyright 2009 Philip Lowman -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -if (NOT DEFINED GLOG_ROOT) -set (GLOG_ROOT /usr /usr/local) -endif (NOT DEFINED GLOG_ROOT) - -if(MSVC) -set(LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/Release) -else(MSVC) -set (LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/lib) -endif(MSVC) - -macro(_FIND_GLOG_LIBRARIES _var) -find_library(${_var} -NAMES -${ARGN} -PATHS -${LIB_PATHS} -PATH_SUFFIXES lib -) -mark_as_advanced(${_var}) -endmacro() - -macro(_GLOG_APPEND_LIBRARIES _list _release) -set(_debug ${_release}_DEBUG) -if(${_debug}) -set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}}) -else() -set(${_list} ${${_list}} ${${_release}}) -endif() -endmacro() - -if(MSVC) -find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h -PATHS -${GLOG_ROOT}/src/windows -${GLOG_ROOT}/src/windows/glog -) -else(MSVC) -# Linux/OS X builds -find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h -PATHS -${GLOG_ROOT}/include/glog -) -endif(MSVC) - -# Find the libraries -if(MSVC) -_FIND_GLOG_LIBRARIES(GLOG_LIBRARIES libglog.lib) -else(MSVC) -# Linux/OS X builds -_FIND_GLOG_LIBRARIES(GLOG_LIBRARIES libglog.so) -endif(MSVC) - -message("glog library = " ${GLOG_LIBRARIES}) - -# handle the QUIETLY and REQUIRED arguments and set GLOG_FOUND to TRUE if -# all listed variables are TRUE -include("${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake") -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Glog DEFAULT_MSG -GLOG_LIBRARIES) - -if(MSVC) -string(REGEX REPLACE "/glog$" "" VAR_WITHOUT ${GLOG_INCLUDE_DIR}) -string(REGEX REPLACE "/windows$" "" VAR_WITHOUT ${VAR_WITHOUT}) -set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS} "${VAR_WITHOUT}") -string(REGEX REPLACE "/libglog.lib" "" GLOG_LIBRARIES_DIR ${GLOG_LIBRARIES}) -else(MSVC) -# Linux/OS X builds -set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) -string(REGEX REPLACE "/libglog.so" "" GLOG_LIBRARIES_DIR ${GLOG_LIBRARIES}) -endif(MSVC) - -if(GLOG_FOUND) -# _GLOG_APPEND_LIBRARIES(GLOG GLOG_LIBRARIES) -endif() diff --git a/src/utils/gpstk/gnsspvt/CMakeModules/FindGPSTK.cmake b/src/utils/gpstk/gnsspvt/CMakeModules/FindGPSTK.cmake deleted file mode 100644 index 9529154f9..000000000 --- a/src/utils/gpstk/gnsspvt/CMakeModules/FindGPSTK.cmake +++ /dev/null @@ -1,87 +0,0 @@ -# - Find gpstk library -# Find the native gpstk includes and library -# This module defines -# GPSTK_INCLUDE_DIR, where to find tiff.h, etc. -# GPSTK_LIBRARIES, libraries to link against to use GPSTK. -# GPSTK_FOUND, If false, do not try to use GPSTK. -# also defined, but not for general use are -# GPSTK_LIBRARY, where to find the GPSTK library. - -FIND_PATH(GPSTK_INCLUDE_DIR gpstk/Matrix.hpp) -FIND_PATH(GEOMATICS_INCLUDE_DIR gpstk/random.hpp) -FIND_PATH(PROCFRAME_INCLUDE_DIR gpstk/SolverWMS.hpp) -FIND_PATH(VDRAW_INCLUDE_DIR gpstk/Layout.hpp) -FIND_PATH(VPLOT_INCLUDE_DIR gpstk/ScatterPlot.hpp) -FIND_PATH(RXIO_INCLUDE_DIR gpstk/EphReader.hpp) - -SET(GPSTK_NAMES ${GPSTK_NAMES} gpstk libgpstk) -FIND_LIBRARY(GPSTK_LIBRARY NAMES ${GPSTK_NAMES} ) - -SET(GEOMATICS_NAMES ${GEOMATICS_NAMES} geomatics libgeomatics) -FIND_LIBRARY(GEOMATICS_LIBRARY NAMES ${GEOMATICS_NAMES} ) - -SET(PROCFRAME_NAMES ${PROCFRAME_NAMES} procframe libprocframe) -FIND_LIBRARY(PROCFRAME_LIBRARY NAMES ${PROCFRAME_NAMES} ) - -SET(VDRAW_NAMES ${VDRAW_NAMES} vdraw libvdraw) -FIND_LIBRARY(VDRAW_LIBRARY NAMES ${VDRAW_NAMES} ) - -SET(VPLOT_NAMES ${VPLOT_NAMES} vplot libvplot) -FIND_LIBRARY(VPLOT_LIBRARY NAMES ${VPLOT_NAMES} ) - -SET(RXIO_NAMES ${RXIO_NAMES} rxio librxio) -FIND_LIBRARY(RXIO_LIBRARY NAMES ${RXIO_NAMES} ) - -# handle the QUIETLY and REQUIRED arguments and set GPSTK_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GPSTK DEFAULT_MSG GPSTK_LIBRARY GPSTK_INCLUDE_DIR) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GEOMATICS DEFAULT_MSG GEOMATICS_LIBRARY GEOMATICS_INCLUDE_DIR) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROCFRAME DEFAULT_MSG PROCFRAME_LIBRARY PROCFRAME_INCLUDE_DIR) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(VDRAW DEFAULT_MSG VDRAW_LIBRARY VDRAW_INCLUDE_DIR) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(VPLOT DEFAULT_MSG VPLOT_LIBRARY VPLOT_INCLUDE_DIR) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(RXIO DEFAULT_MSG RXIO_LIBRARY RXIO_INCLUDE_DIR) - -IF(GPSTK_FOUND) - SET( GPSTK_LIBRARIES ${GPSTK_LIBRARY} ) -ENDIF(GPSTK_FOUND) - -IF(GEOMATICS_FOUND) - SET( GEOMATICS_LIBRARIES ${GEOMATICS_LIBRARY} ) -ENDIF(GEOMATICS_FOUND) - -IF(PROCFRAME_FOUND) - SET( PROCFRAME_LIBRARIES ${PROCFRAME_LIBRARY} ) -ENDIF(PROCFRAME_FOUND) - -IF(VDRAW_FOUND) - SET( VDRAW_LIBRARIES ${VDRAW_LIBRARY} ) -ENDIF(VDRAW_FOUND) - -IF(VPLOT_FOUND) - SET( VPLOT_LIBRARIES ${VPLOT_LIBRARY} ) -ENDIF(VPLOT_FOUND) - -IF(RXIO_FOUND) - SET( RXIO_LIBRARIES ${RXIO_LIBRARY} ) -ENDIF(RXIO_FOUND) - -MARK_AS_ADVANCED(GPSTK_INCLUDE_DIR GPSTK_LIBRARY) - -MARK_AS_ADVANCED(GEOMATICS_INCLUDE_DIR GEOMATICS_LIBRARY) - -MARK_AS_ADVANCED(PROCFRAME_INCLUDE_DIR PROCFRAME_LIBRARY) - -MARK_AS_ADVANCED(VDRAW_INCLUDE_DIR VDRAW_LIBRARY) - -MARK_AS_ADVANCED(VPLOT_INCLUDE_DIR VPLOT_LIBRARY) - -MARK_AS_ADVANCED(RXIO_INCLUDE_DIR RXIO_LIBRARY) - - diff --git a/src/utils/gpstk/gnsspvt/README b/src/utils/gpstk/gnsspvt/README deleted file mode 100644 index 6360ac4be..000000000 --- a/src/utils/gpstk/gnsspvt/README +++ /dev/null @@ -1,62 +0,0 @@ -ABOUT GNSSPVT ----------------------- -This program uses the high level GpsTk classes to implement a simple PVT solver -that uses RINEX files as an input. -The output is written both in the console and in a Google Earth KML file. - -HOW TO BUILD GNSSPVT ----------------------- - -Installation in Ubuntu 11.04, 11.10, 12.04 (32 and 64 bits) ------------------------------------------------------------ - -- Install CMake through your OS's package manager or by some other means. - -- Install GpsTk: - - The following procedure will build and install the GPSTk. - - Ensure that prerequisites such as jam have been installed. - Download the GPSTk source distribution from http://www.gpstk.org/bin/view/Documentation/GPSTkDownloads - Extract the GPSTk tarball. For example, using GNU tar - - tar xvzf gpstk.tar.gz - - Change into the gpstk/dev directory (if using Subversion) or the gpstk/ directory (if using the tarball)and type - - jam - - To build the source documentation using doxygen: - - doxygen - - To install GPSTk as a system library in /usr/local, assume root privileges then execute - - jam install - - To install to a different directory, define the environment variable PREFIX to point to the root of the installation - - -- Download, unzip, configure, build and install glog, a Google's library that implements application-level logging: - -$ wget http://google-glog.googlecode.com/files/glog-0.3.2.tar.gz -$ tar xvfz glog-0.3.2.tar.gz -$ cd glog-0.3.2 -$ ./configure -$ make -$ sudo make install - -- Go to GNSSPVT root directory and compile the gnsspvt: - -$ cd gnss-sdr/src/utils/gpstk/gnsspvt/ -$ mkdir build -$ cd build -$ cmake ../ -$ make - -If everything goes well, the executable file is available in the build directory. - -USAGE ----------------------- - -./gnsspvt -i path_to_rinex_observable_file -n path_to_rinex_navigation_file -k path_to_kml_output_file diff --git a/src/utils/gpstk/gnsspvt/src/gnsspvt.cpp b/src/utils/gpstk/gnsspvt/src/gnsspvt.cpp deleted file mode 100644 index e571e3138..000000000 --- a/src/utils/gpstk/gnsspvt/src/gnsspvt.cpp +++ /dev/null @@ -1,593 +0,0 @@ -/*! - * \file gnsspvt.cpp - * \brief Adapted version of high level gpstk PVT solver to read RINEX files, - * compute the position, velocity and time solution, and write Google Earth KML output file. - * The input Observables and Navigation files can be RINEX 2.10 or RINEX 3.00. - * It is a modified version of the example5.cpp code provided in gpstk source code. - * - * \author Javier Arribas, 2012. jarribas(at)cttc.es - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -// Modified Example program Nro 5 for GPSTk -// This program shows how to use some high-level GPSTk classes - - // Basic input/output C++ class -#include - - // Classes for handling observations RINEX files (data) -#include "gpstk/Rinex3ObsData.hpp" -#include "gpstk/Rinex3ObsStream.hpp" - - // Class to easily extract data from Rinex3ObsData objects -#include "gpstk/ExtractData.hpp" - - // Classes for handling satellite navigation parameters RINEX files - // (Broadcast ephemerides) -#include "gpstk/Rinex3NavHeader.hpp" -#include "gpstk/Rinex3NavData.hpp" -#include "gpstk/Rinex3NavStream.hpp" - - // Class to store satellite broadcast navigation data -#include "gpstk/GPSEphemerisStore.hpp" - - // Class to model GPS data for a mobile receiver -#include "gpstk/ModeledPR.hpp" - -#include "gpstk/GNSSconstants.hpp" -#include "gpstk/CommonTime.hpp" -#include "gpstk/SatID.hpp" -#include "gpstk/Matrix.hpp" -#include "gpstk/XvtStore.hpp" -#include "gpstk/TropModel.hpp" - - // Class to model the tropospheric delays -#include "gpstk/TropModel.hpp" - - // Classes to model ans store ionospheric delays -#include "gpstk/IonoModel.hpp" -#include "gpstk/IonoModelStore.hpp" - - // Class to solve the equations system using a Weighted Least Mean Square method -#include "gpstk/SolverWMS.hpp" - - // Class to compute the weights to be used for each satellite -#include "gpstk/MOPSWeight.hpp" - - // Basic framework for programs in the GPSTk. The 'process()' method MUST - // be implemented -#include "gpstk/BasicFramework.hpp" - -#include "gpstk/geometry.hpp" // DEG_TO_RAD - - // Time-class year-day-second -#include "gpstk/YDSTime.hpp" - -#include "kml_printer_gpstk.h" - -using namespace std; -using namespace gpstk; - - - // A new class is declared that will handle program behaviour - // This class inherits from BasicFramework -class gpstk_solver : public BasicFramework -{ -public: - - // Constructor declaration - gpstk_solver(char* arg0); - ~gpstk_solver(); - -protected: - - // Method that will take care of processing - virtual void process(); - - // Method that hold code to be run BEFORE processing - virtual void spinUp(); - - virtual int Prepare( const CommonTime& Tr, - std::vector& Satellite, - std::vector& Pseudorange, - const XvtStore& Eph ); - virtual int Prepare2( const CommonTime& Tr, - const Vector& Satellite, - const Vector& Pseudorange, - const XvtStore& Eph ); - -private: - - // These field represent options at command line interface (CLI) - CommandOptionWithArg dataFile; - CommandOptionWithArg navFile; - CommandOptionWithArg kmlFile; - - Kml_Printer_gpstk kml_printer; - - // If you want to share objects and variables among methods, you'd - // better declare them here - Rinex3ObsStream rObsFile; // Object to read Rinex observation data files - Rinex3ObsData rData; // Object to store Rinex observation data - Rinex3NavStream rNavFile; // Object to read Rinex navigation data files - Rinex3NavData rNavData; // Object to store Rinex navigation data - Rinex3NavHeader rNavHeader; // Object to read the header of Rinex - // navigation data files - IonoModelStore ionoStore; // Object to store ionospheric models - GPSEphemerisStore bceStore; // Object to store ephemeris - ModeledPR modelPR; // Declare a ModeledReferencePR object - MOPSTropModel mopsTM; // Declare a MOPSTropModel object - ExtractData obsC1; // Declare an ExtractData object - int indexC1; // Index to "C1" observation - bool useFormerPos; // Flag indicating if we have an a priori - // position - Position formerPosition; // Object to store the former position - IonoModel ioModel; // Declare a Ionospheric Model object - SolverWMS solver; // Declare an object to apply WMS method - MOPSWeight mopsWeights; // Object to compute satellites' weights - -}; - - - // Let's implement constructor details -gpstk_solver::gpstk_solver(char* arg0) - : BasicFramework(arg0, "\nProgram to print the position solution in ECEF " - "and longitude, latitude, height, based in C1 and " - "given a RINEX observations file and a RINEX " - "broadcast navigation file.\n\n" - "The output is: \n" - " Time(sec) X(m) Y(m) Z(m) Lon(deg) " - " Lat(deg) Height(m)\n"), - // Option initialization. "true" means a mandatory option - dataFile(CommandOption::stdType, 'i', "datainput", - " [-i|--datainput] Name of RINEX observations file.", true), - navFile(CommandOption::stdType, 'n', "navinput", - " [-n|--navinput] Name of RINEX broadcast navigation file.", true), - kmlFile(CommandOption::stdType, 'k', "kmloutput", - " [-n|--navinput] Name of KML output file.", true) -{ - // These options may appear just once at CLI - dataFile.setMaxCount(1); - navFile.setMaxCount(1); - kmlFile.setMaxCount(1); -} // End of constructor details - - - - /* Method to set an a priori position of receiver using - * Bancroft's method. - * - * @param Tr Time of observation - * @param Satellite std::vector of satellites in view - * @param Pseudorange std::vector of pseudoranges measured from - * rover station to satellites - * @param Eph Satellites Ephemeris - * - * @return - * 0 if OK - * -1 if problems arose - */ - int gpstk_solver::Prepare( const CommonTime& Tr, - std::vector& Satellite, - std::vector& Pseudorange, - const XvtStore& Eph ) - { - - Matrix SVP; - Bancroft Ban; - Vector vPos; - PRSolution2 raimObj; - - try - { - cerr << "Tr=" <::iterator it = Satellite.begin() ; it != Satellite.end(); ++it) - { - cerr << "SatID=" << *it<& Satellite, - const Vector& Pseudorange, - const XvtStore& Eph ) - { - - int i; - std::vector vSat; - std::vector vPR; - - // Convert from gpstk::Vector to std::vector - for (i = 0; i < (int)Satellite.size(); i++) - { - vSat.push_back(Satellite[i]); - } - - for (i = 0; i < (int)Pseudorange.size(); i++) - { - vPR.push_back(Pseudorange[i]); - } - - return Prepare(Tr, vSat, vPR, Eph); - - } // End of method 'ModeledPR::Prepare()' - - - // Method that will be executed AFTER initialization but BEFORE processing -void gpstk_solver::spinUp() -{ - - - //open KML output file - if (kml_printer.set_headers(kmlFile.getValue()[0].c_str())!=true) - { - cerr << "Problem creating the kml file "<> roh; - - // We need the index pointing to C1-type observations - try - { - indexC1 = roh.getObsIndex( "C1" ); - } - catch(...) - { - cerr << "The observation file doesn't have C1 pseudoranges." << endl; - exit(1); - } - - - // Activate failbit to enable exceptions - rNavFile.exceptions(ios::failbit); - - // Read nav file and store unique list of ephemerides - try - { - rNavFile.open(navFile.getValue()[0].c_str(), std::ios::in); - } - catch(...) - { - cerr << "Problem opening file " << navFile.getValue()[0].c_str() << endl; - cerr << "Maybe it doesn't exist or you don't have proper read " - << "permissions." << endl; - - exit (-1); - } - - // We will need to read ionospheric parameters (Klobuchar model) from - // the file header - rNavFile >> rNavHeader; - - // Let's feed the ionospheric model (Klobuchar type) from data in the - // navigation (ephemeris) file header. First, we must check if there are - // valid ionospheric correction parameters in the header - if(rNavHeader.valid & Rinex3NavHeader::validIonoCorrGPS) - { - // Extract the Alpha and Beta parameters from the header - double* ionAlpha = rNavHeader.mapIonoCorr["GPSA"].param; - double* ionBeta = rNavHeader.mapIonoCorr["GPSB"].param; - - // Feed the ionospheric model with the parameters - ioModel.setModel(ionAlpha, ionBeta); - } - else - { - cerr << "WARNING: Navigation file " << navFile.getValue()[0].c_str() - << " doesn't have valid ionospheric correction parameters." << endl; - } - - // WARNING-WARNING-WARNING: In this case, the same model will be used - // for the full data span - ionoStore.addIonoModel(CommonTime::BEGINNING_OF_TIME, ioModel); - - // Storing the ephemeris in "bceStore" - while (rNavFile >> rNavData) - { - bceStore.addEphemeris(rNavData); - rNavData.dump(cerr); - cerr<> rData ) - { - - // Begin usable data with enough number of satellites - if( (rData.epochFlag == 0 || rData.epochFlag == 1) && - (rData.numSVs > 3) ) - { - - // Number of satellites with valid data in this epoch - int validSats = 0; - int prepareResult; - double rxAltitude; // Receiver altitude for tropospheric model - double rxLatitude; // Receiver latitude for tropospheric model - - // We need to extract C1 data from this epoch. Skip epoch if not - // enough data (4 SV at least) is available - if( obsC1.getData(rData, indexC1) < 4 ) - { - // The former position will not be valid next time - useFormerPos = false; - continue; - } - - - // If possible, use former position as a priori - if( useFormerPos ) - { - - prepareResult = modelPR.Prepare(formerPosition); - - // We need to seed this kind of tropospheric model with - // receiver altitude - rxAltitude = formerPosition.getAltitude(); - rxLatitude = formerPosition.getGeodeticLatitude(); - - } - else - { - // Use Bancroft method is no a priori position is available - cerr << "Bancroft method was used at epoch " - << static_cast(rData.time).sod << endl; - - Prepare2( rData.time,obsC1.availableSV,obsC1.obsData,bceStore ); - prepareResult = modelPR.Prepare( rData.time, - obsC1.availableSV, - obsC1.obsData, - bceStore ); - - // We need to seed this kind of tropospheric model with - // receiver altitude - rxAltitude = modelPR.rxPos.getAltitude(); - rxLatitude = modelPR.rxPos.getGeodeticLatitude(); - } - - // If there were problems with Prepare(), skip this epoch - if( prepareResult ) - { - // The former position will not be valid next time - useFormerPos = false; - continue; - } - - // If there were no problems, let's feed the tropospheric model - mopsTM.setReceiverHeight(rxAltitude); - mopsTM.setReceiverLatitude(rxLatitude); - mopsTM.setDayOfYear(static_cast(rData.time).doy); - - - // Now, let's compute the GPS model for our observable (C1) - validSats = modelPR.Compute( rData.time, - obsC1.availableSV, - obsC1.obsData, - bceStore, - &mopsTM, - &ionoStore ); - - // Only get into further computations if there are enough - // satellites - if( validSats >= 4 ) - { - - // Now let's solve the navigation equations using the WMS method - try - { - // First, compute the satellites' weights - int goodSv = mopsWeights.getWeights( rData.time, - modelPR.availableSV, - bceStore, - modelPR.ionoCorrections, - modelPR.elevationSV, - modelPR.azimuthSV, - modelPR.rxPos ); - - // Some minimum checking is in order - if ( goodSv != (int)modelPR.prefitResiduals.size() ) continue; - - // Then, solve the system - solver.Compute( modelPR.prefitResiduals, - modelPR.geoMatrix, - mopsWeights.weightsVector ); - - } - catch( InvalidSolver& e ) - { - cerr << "Couldn't solve equations system at epoch " - << static_cast(rData.time).sod << endl; - cerr << e << endl; - - // The former position will not be valid next time - useFormerPos = false; - continue; - } - - // With "solver", we got the difference vector between the - // a priori position and the computed, 'real' position. Then, - // let's convert the solution to a Position object - Position solPos( (modelPR.rxPos.X() + solver.solution[0]), - (modelPR.rxPos.Y() + solver.solution[1]), - (modelPR.rxPos.Z() + solver.solution[2]) ); - - // Print results - cout << static_cast(rData.time).sod - << " "; // Output field #1 - cout << "X="<= 4 )' - else - { - // The former position will not be valid next time - useFormerPos = false; - } - - } // End of 'if( (rData.epochFlag == 0 || rData.epochFlag == 1) &&...' - else - { - // The former position will not be valid next time - useFormerPos = false; - } - - } // End of 'while( rObsFile >> rData )' - - return; - -} // End of 'gpstk_solver::process()' - -gpstk_solver::~gpstk_solver() -{ - kml_printer.close_file(); -} - // Main function -int main(int argc, char* argv[]) -{ - - try - { - gpstk_solver program(argv[0]); - if (!program.initialize(argc, argv)) - return 0; - if (!program.run()) - return 1; - - return 0; - } - catch(Exception& e) - { - cout << "Problem: " << e << endl; - return 1; - } - catch(...) - { - cout << "Unknown error." << endl; - return 1; - } - - return 0; - -} // End of 'main()' diff --git a/src/utils/gpstk/gnsspvt/src/kml_printer_gpstk.cpp b/src/utils/gpstk/gnsspvt/src/kml_printer_gpstk.cpp deleted file mode 100644 index 7778c1dfe..000000000 --- a/src/utils/gpstk/gnsspvt/src/kml_printer_gpstk.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*! - * \file kml_printer.cc - * \brief Implementation of a class that prints PVT information to a kml file - * for GPSTK data structures - * \author Javier Arribas, 2012. jarribas(at)cttc.es - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include "kml_printer_gpstk.h" -#include -#include -#include - -bool Kml_Printer_gpstk::set_headers(std::string filename) -{ - time_t rawtime; - struct tm * timeinfo; - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - kml_file.open(filename.c_str()); - if (kml_file.is_open()) - { - DLOG(INFO) << "KML printer writing on " << filename.c_str(); - // Set iostream numeric format and precision - kml_file.setf(kml_file.fixed,kml_file.floatfield); - kml_file << std::setprecision(14); - kml_file << "" << std::endl - << "" << std::endl - << " " << std::endl - << " GNSS Track" << std::endl - << " GNSS-SDR Receiver position log file created at " << asctime (timeinfo) - << " " << std::endl - << "" << std::endl - << "" << std::endl - << "GNSS-SDR PVT" << std::endl - << "GNSS-SDR position log" << std::endl - << "#yellowLineGreenPoly" << std::endl - << "" << std::endl - << "0" << std::endl - << "1" << std::endl - << "absolute" << std::endl - << "" << std::endl; - return true; - } - else - { - return false; - } -} - - - -bool Kml_Printer_gpstk::print_position(gpstk::Position position) -{ - double latitude; - double longitude; - double height; - latitude = position.geodeticLatitude(); - longitude = position.getLongitude(); - if (longitude>190) - { - longitude=longitude-360; - } - height = position.getHeight(); - - if (kml_file.is_open()) - { - kml_file << longitude << "," << latitude << "," << height << std::endl; - return true; - } - else - { - return false; - } -} - - - -bool Kml_Printer_gpstk::close_file() -{ - if (kml_file.is_open()) - { - kml_file << "" << std::endl - << "" << std::endl - << "" << std::endl - << "" << std::endl - << ""; - kml_file.close(); - return true; - } - else - { - return false; - } -} - - - -Kml_Printer_gpstk::Kml_Printer_gpstk () {} - - - -Kml_Printer_gpstk::~Kml_Printer_gpstk () {} - diff --git a/src/utils/matlab/gps_l1_ca_kf_plot_sample.m b/src/utils/matlab/gps_l1_ca_kf_plot_sample.m new file mode 100644 index 000000000..f8fcb0ed7 --- /dev/null +++ b/src/utils/matlab/gps_l1_ca_kf_plot_sample.m @@ -0,0 +1,93 @@ +% Reads GNSS-SDR Tracking dump binary file using the provided +% function and plots some internal variables +% Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR 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 General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +close all; +clear all; + +if ~exist('dll_pll_veml_read_tracking_dump.m', 'file') + addpath('./libs') +end + + +samplingFreq = 6625000; %[Hz] +channels = 8; +first_channel = 0; +code_period = 0.001; + +path = '/archive/'; %% CHANGE THIS PATH +figpath = [path]; + +for N=1:1:channels + tracking_log_path = [path 'epl_tracking_ch_' num2str(N+first_channel-1) '.dat']; %% CHANGE epl_tracking_ch_ BY YOUR dump_filename + GNSS_tracking(N) = gps_l1_ca_kf_read_tracking_dump(tracking_log_path); +end + +% GNSS-SDR format conversion to MATLAB GPS receiver + +for N=1:1:channels + trackResults(N).status = 'T'; %fake track + trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; + trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; + trackResults(N).carrFreqRate = GNSS_tracking(N).carrier_dopplerrate_hz2.'; + trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; + trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; + trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; + trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; + + trackResults(N).I_P = GNSS_tracking(N).prompt_I.'; + trackResults(N).Q_P = GNSS_tracking(N).prompt_Q.'; + + trackResults(N).I_E = GNSS_tracking(N).E.'; + trackResults(N).I_L = GNSS_tracking(N).L.'; + trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).PRN = GNSS_tracking(N).PRN.'; + trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; + + + kalmanResults(N).PRN = GNSS_tracking(N).PRN.'; + kalmanResults(N).innovation = GNSS_tracking(N).carr_error.'; + kalmanResults(N).state1 = GNSS_tracking(N).carr_nco.'; + kalmanResults(N).state2 = GNSS_tracking(N).carrier_doppler_hz.'; + kalmanResults(N).state3 = GNSS_tracking(N).carrier_dopplerrate_hz2.'; + kalmanResults(N).r_noise_cov = GNSS_tracking(N).carr_noise_sigma2.'; + kalmanResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; + + % Use original MATLAB tracking plot function + settings.numberOfChannels = channels; + settings.msToProcess = length(GNSS_tracking(N).E); + settings.codePeriod = code_period; + settings.timeStartInSeconds = 20; + + %plotTracking(N, trackResults, settings) + plotKalman(N, kalmanResults, settings) + + saveas(gcf, [figpath 'epl_tracking_ch_' num2str(N) '_PRN_' num2str(trackResults(N).PRN(end)) '.png'], 'png') +end + + diff --git a/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m b/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m index f25ab5d21..1d56cb60d 100644 --- a/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m +++ b/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m @@ -30,7 +30,7 @@ %clear all; samplingFreq = 64e6/16; %[Hz] channels=4; -path='/home/javier/workspace/gnss-sdr-ref/trunk/install/'; +path='/home/sergi/gnss/gnss-sdr/install/'; clear PRN_absolute_sample_start; for N=1:1:channels telemetry_log_path=[path 'telemetry' num2str(N-1) '.dat']; diff --git a/src/utils/matlab/libs/dll_pll_veml_read_tracking_dump.m b/src/utils/matlab/libs/dll_pll_veml_read_tracking_dump.m index a53dedbf9..698a1b5df 100644 --- a/src/utils/matlab/libs/dll_pll_veml_read_tracking_dump.m +++ b/src/utils/matlab/libs/dll_pll_veml_read_tracking_dump.m @@ -33,7 +33,7 @@ function [GNSS_tracking] = dll_pll_veml_read_tracking_dump (filename, count) m = nargchk (1,2,nargin); -num_float_vars = 17; +num_float_vars = 19; num_unsigned_long_int_vars = 1; num_double_vars = 1; num_unsigned_int_vars = 1; @@ -114,17 +114,23 @@ else fseek(f,bytes_shift,'bof'); % move to next float v16 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float + fseek(f,bytes_shift,'bof'); % move to next float v17 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); bytes_shift = bytes_shift + float_size_bytes; fseek(f,bytes_shift,'bof'); % move to next float - v18 = fread (f, count, 'float', skip_bytes_each_read-float_size_bytes); + v18 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved float + v19 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v20 = fread (f, count, 'float', skip_bytes_each_read-float_size_bytes); bytes_shift = bytes_shift + float_size_bytes; fseek(f,bytes_shift,'bof'); % move to next double - v19 = fread (f, count, 'double', skip_bytes_each_read - double_size_bytes); + v21 = fread (f, count, 'double', skip_bytes_each_read - double_size_bytes); bytes_shift = bytes_shift + double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next unsigned int - v20 = fread (f, count, 'uint', skip_bytes_each_read - unsigned_int_size_bytes); + v22 = fread (f, count, 'uint', skip_bytes_each_read - unsigned_int_size_bytes); fclose (f); GNSS_tracking.VE = v1; @@ -137,15 +143,17 @@ else GNSS_tracking.PRN_start_sample = v8; GNSS_tracking.acc_carrier_phase_rad = v9; GNSS_tracking.carrier_doppler_hz = v10; - GNSS_tracking.code_freq_hz = v11; - GNSS_tracking.carr_error = v12; - GNSS_tracking.carr_nco = v13; - GNSS_tracking.code_error = v14; - GNSS_tracking.code_nco = v15; - GNSS_tracking.CN0_SNV_dB_Hz = v16; - GNSS_tracking.carrier_lock_test = v17; - GNSS_tracking.var1 = v18; - GNSS_tracking.var2 = v19; - GNSS_tracking.PRN = v20; + GNSS_tracking.carrier_doppler_rate_hz_s = v11; + GNSS_tracking.code_freq_hz = v12; + GNSS_tracking.code_freq_rate_hz_s = v13; + GNSS_tracking.carr_error = v14; + GNSS_tracking.carr_nco = v15; + GNSS_tracking.code_error = v16; + GNSS_tracking.code_nco = v17; + GNSS_tracking.CN0_SNV_dB_Hz = v18; + GNSS_tracking.carrier_lock_test = v19; + GNSS_tracking.var1 = v20; + GNSS_tracking.var2 = v21; + GNSS_tracking.PRN = v22; end diff --git a/src/utils/matlab/libs/gps_l1_ca_kf_read_tracking_dump.m b/src/utils/matlab/libs/gps_l1_ca_kf_read_tracking_dump.m new file mode 100644 index 000000000..e1f1c8687 --- /dev/null +++ b/src/utils/matlab/libs/gps_l1_ca_kf_read_tracking_dump.m @@ -0,0 +1,158 @@ +% Usage: gps_l1_ca_kf_read_tracking_dump (filename, [count]) +% +% Opens GNSS-SDR tracking binary log file .dat and returns the contents + +% Read GNSS-SDR Tracking dump binary file into MATLAB. +% Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR 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 General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +function [GNSS_tracking] = gps_l1_ca_kf_read_tracking_dump (filename, count) + +m = nargchk (1,2,nargin); + +num_float_vars = 19; +num_unsigned_long_int_vars = 1; +num_double_vars = 1; +num_unsigned_int_vars = 1; + +if(~isempty(strfind(computer('arch'), '64'))) + % 64-bit computer + double_size_bytes = 8; + unsigned_long_int_size_bytes = 8; + float_size_bytes = 4; + unsigned_int_size_bytes = 4; +else + double_size_bytes = 8; + unsigned_long_int_size_bytes = 4; + float_size_bytes = 4; + unsigned_int_size_bytes = 4; +end + +skip_bytes_each_read = float_size_bytes * num_float_vars + unsigned_long_int_size_bytes * num_unsigned_long_int_vars + ... + double_size_bytes * num_double_vars + num_unsigned_int_vars*unsigned_int_size_bytes; + +bytes_shift = 0; + +if (m) + usage (m); +end + +if (nargin < 2) + count = Inf; +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else + v1 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v2 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v3 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v4 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v5 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v6 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v7 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved float + v8 = fread (f, count, 'long', skip_bytes_each_read - unsigned_long_int_size_bytes); + bytes_shift = bytes_shift + unsigned_long_int_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v9 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v10 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v11 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v12 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v13 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v14 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v15 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v16 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v17 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v18 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved float + v19 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v20 = fread (f, count, 'float', skip_bytes_each_read-float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next double + v21 = fread (f, count, 'double', skip_bytes_each_read - double_size_bytes); + bytes_shift = bytes_shift + double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next unsigned int + v22 = fread (f, count, 'uint', skip_bytes_each_read - unsigned_int_size_bytes); + fclose (f); + + GNSS_tracking.VE = v1; + GNSS_tracking.E = v2; + GNSS_tracking.P = v3; + GNSS_tracking.L = v4; + GNSS_tracking.VL = v5; + GNSS_tracking.prompt_I = v6; + GNSS_tracking.prompt_Q = v7; + GNSS_tracking.PRN_start_sample = v8; + GNSS_tracking.acc_carrier_phase_rad = v9; + GNSS_tracking.carrier_doppler_hz = v10; + GNSS_tracking.carrier_dopplerrate_hz2 = v11; + GNSS_tracking.code_freq_hz = v12; + GNSS_tracking.carr_error = v13; + GNSS_tracking.carr_noise_sigma2 = v14; + GNSS_tracking.carr_nco = v15; + GNSS_tracking.code_error = v16; + GNSS_tracking.code_nco = v17; + GNSS_tracking.CN0_SNV_dB_Hz = v18; + GNSS_tracking.carrier_lock_test = v19; + GNSS_tracking.var1 = v20; + GNSS_tracking.var2 = v21; + GNSS_tracking.PRN = v22; +end \ No newline at end of file diff --git a/src/utils/matlab/libs/plotKalman.m b/src/utils/matlab/libs/plotKalman.m new file mode 100644 index 000000000..e05fd0d52 --- /dev/null +++ b/src/utils/matlab/libs/plotKalman.m @@ -0,0 +1,135 @@ +function plotKalman(channelList, trackResults, settings) +% This function plots the tracking results for the given channel list. +% +% plotTracking(channelList, trackResults, settings) +% +% Inputs: +% channelList - list of channels to be plotted. +% trackResults - tracking results from the tracking function. +% settings - receiver settings. + +%-------------------------------------------------------------------------- +% SoftGNSS v3.0 +% +% Copyright (C) Darius Plausinaitis +% Written by Darius Plausinaitis +%-------------------------------------------------------------------------- +%This program is free software; you can redistribute it and/or +%modify it under the terms of the GNU General Public License +%as published by the Free Software Foundation; either version 2 +%of the License, or (at your option) any later version. +% +%This program 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 General Public License for more details. +% +%You should have received a copy of the GNU General Public License +%along with this program; if not, write to the Free Software +%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +%USA. +%-------------------------------------------------------------------------- + +% Protection - if the list contains incorrect channel numbers +channelList = intersect(channelList, 1:settings.numberOfChannels); + +%=== For all listed channels ============================================== +for channelNr = channelList + + %% Select (or create) and clear the figure ================================ + % The number 200 is added just for more convenient handling of the open + % figure windows, when many figures are closed and reopened. + % Figures drawn or opened by the user, will not be "overwritten" by + % this function. + + figure(channelNr +200); + clf(channelNr +200); + set(channelNr +200, 'Name', ['Channel ', num2str(channelNr), ... + ' (PRN ', ... + num2str(trackResults(channelNr).PRN(end-1)), ... + ') results']); + + timeStart = settings.timeStartInSeconds; + + %% Draw axes ============================================================== + % Row 1 + handles(1, 1) = subplot(4, 2, 1); + handles(1, 2) = subplot(4, 2, 2); + % Row 2 + handles(2, 1) = subplot(4, 2, 3); + handles(2, 2) = subplot(4, 2, 4); + % Row 3 + handles(3, 1) = subplot(4, 2, [5 6]); + % Row 4 + handles(4, 1) = subplot(4, 2, [7 8]); + + %% Plot all figures ======================================================= + + timeAxisInSeconds = (1:settings.msToProcess)/1000; + + %----- CNo for signal---------------------------------- + plot (handles(1, 1), timeAxisInSeconds, ... + trackResults(channelNr).CNo(1:settings.msToProcess), 'b'); + + grid (handles(1, 1)); + axis (handles(1, 1), 'tight'); + xlabel(handles(1, 1), 'Time (s)'); + ylabel(handles(1, 1), 'CNo (dB-Hz)'); + title (handles(1, 1), 'Carrier to Noise Ratio'); + + %----- PLL discriminator filtered---------------------------------- + plot (handles(1, 2), timeAxisInSeconds, ... + trackResults(channelNr).state1(1:settings.msToProcess), 'b'); + + grid (handles(1, 2)); + axis (handles(1, 2), 'tight'); + xlim (handles(1, 2), [timeStart, timeAxisInSeconds(end)]); + xlabel(handles(1, 2), 'Time (s)'); + ylabel(handles(1, 2), 'Phase Amplitude'); + title (handles(1, 2), 'Filtered Carrier Phase'); + + %----- Carrier Frequency -------------------------------- + plot (handles(2, 1), timeAxisInSeconds(2:end), ... + trackResults(channelNr).state2(2:settings.msToProcess), 'Color',[0.42 0.25 0.39]); + + grid (handles(2, 1)); + axis (handles(2, 1)); + xlim (handles(2, 1), [timeStart, timeAxisInSeconds(end)]); + xlabel(handles(2, 1), 'Time (s)'); + ylabel(handles(2, 1), 'Freq (hz)'); + title (handles(2, 1), 'Filtered Doppler Frequency'); + + %----- Carrier Frequency Rate -------------------------------- + plot (handles(2, 2), timeAxisInSeconds(2:end), ... + trackResults(channelNr).state3(2:settings.msToProcess), 'Color',[0.42 0.25 0.39]); + + grid (handles(2, 2)); + axis (handles(2, 2)); + xlim (handles(2, 2), [timeStart, timeAxisInSeconds(end)]); + xlabel(handles(2, 2), 'Time (s)'); + ylabel(handles(2, 2), 'Freq (hz)'); + title (handles(2, 2), 'Filtered Doppler Frequency Rate'); + + %----- PLL discriminator unfiltered-------------------------------- + plot (handles(3, 1), timeAxisInSeconds, ... + trackResults(channelNr).innovation, 'r'); + + grid (handles(3, 1)); + axis (handles(3, 1), 'auto'); + xlim (handles(3, 1), [timeStart, timeAxisInSeconds(end)]); + xlabel(handles(3, 1), 'Time (s)'); + ylabel(handles(3, 1), 'Amplitude'); + title (handles(3, 1), 'Raw PLL discriminator (Innovation)'); + + + %----- PLL discriminator covariance -------------------------------- + plot (handles(4, 1), timeAxisInSeconds, ... + trackResults(channelNr).r_noise_cov, 'r'); + + grid (handles(4, 1)); + axis (handles(4, 1), 'auto'); + xlim (handles(4, 1), [timeStart, timeAxisInSeconds(end)]); + xlabel(handles(4, 1), 'Time (s)'); + ylabel(handles(4, 1), 'Variance'); + title (handles(4, 1), 'Estimated Noise Variance'); +end % for channelNr = channelList diff --git a/src/utils/matlab/libs/read_hybrid_observables_dump.m b/src/utils/matlab/libs/read_hybrid_observables_dump.m index 3ccfe9b67..f8dccdd41 100644 --- a/src/utils/matlab/libs/read_hybrid_observables_dump.m +++ b/src/utils/matlab/libs/read_hybrid_observables_dump.m @@ -79,7 +79,7 @@ else % { % tmp_double = current_gnss_synchro[i].RX_time; % d_dump_file.write((char*)&tmp_double, sizeof(double)); - % tmp_double = current_gnss_synchro[i].TOW_at_current_symbol_s; + % tmp_double = current_gnss_synchro[i].TOW_at_current_symbol_ms; % d_dump_file.write((char*)&tmp_double, sizeof(double)); % tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz; % d_dump_file.write((char*)&tmp_double, sizeof(double)); diff --git a/src/utils/matlab/plot_acq_grid.m b/src/utils/matlab/plot_acq_grid.m index c18e44556..b72946a77 100644 --- a/src/utils/matlab/plot_acq_grid.m +++ b/src/utils/matlab/plot_acq_grid.m @@ -28,11 +28,13 @@ %%%%%%%%% ?????? CONFIGURE !!! %%%%%%%%%%%%% -path = '/archive/'; -file = 'acq'; +path = '/home/dmiralles/Documents/gnss-sdr/'; +file = 'bds_acq'; -sat = 7; +sat = 32; +channel = 0; +execution = 3; % Signal: % 1 GPS L1 % 2 GPS L2M @@ -40,10 +42,11 @@ sat = 7; % 4 Gal. E1B % 5 Gal. E5 % 6 Glo. 1G +% 7 BDS B1 -signal_type = 1; +signal_type = 7; -%%% True for light grid representation +%%% True for light acq_grid representation lite_view = true; %%% If lite_view, it sets the number of samples per chip in the graphical representation @@ -76,21 +79,25 @@ switch(signal_type) n_chips = 511; system = 'R'; signal = '1G'; + case 7 + n_chips = 2046; + system = 'C'; + signal = 'B1'; end -filename = [path file '_' system '_' signal '_sat_' num2str(sat) '.mat']; +filename = [path file '_' system '_' signal '_ch_' num2str(channel) '_' num2str(execution) '_sat_' num2str(sat) '.mat']; load(filename); -[n_fft n_dop_bins] = size(grid); -[d_max f_max] = find(grid == max(max(grid))); +[n_fft n_dop_bins] = size(acq_grid); +[d_max f_max] = find(acq_grid == max(max(acq_grid))); freq = (0 : n_dop_bins - 1) * doppler_step - doppler_max; delay = (0 : n_fft - 1) / n_fft * n_chips; figure(1) if(lite_view == false) - surf(freq, delay, grid, 'FaceColor', 'interp', 'LineStyle', 'none') + surf(freq, delay, acq_grid, 'FaceColor', 'interp', 'LineStyle', 'none') ylim([min(delay) max(delay)]) else delay_interp = (0 : n_samples_per_chip * n_chips - 1) / n_samples_per_chip; - grid_interp = spline(delay, grid', delay_interp)'; - surf(freq, delay_interp, grid_interp, 'FaceColor', 'interp', 'LineStyle', 'none') + acq_grid_interp = spline(delay, acq_grid', delay_interp)'; + surf(freq, delay_interp, acq_grid_interp, 'FaceColor', 'interp', 'LineStyle', 'none') ylim([min(delay_interp) max(delay_interp)]) end xlabel('Doppler shift / Hz') @@ -99,13 +106,14 @@ ylabel('Code delay / chips') zlabel('Test statistics') figure(2) subplot(2,1,1) -plot(freq, grid(d_max, :)) +plot(freq, acq_grid(d_max, :)) xlim([min(freq) max(freq)]) xlabel('Doppler shift / Hz') ylabel('Test statistics') title(['Fixed code delay to ' num2str((d_max - 1) / n_fft * n_chips) ' chips']) subplot(2,1,2) -plot(delay, grid(:, f_max)) +normalization = (d_samples_per_code^4) * input_power; +plot(delay, acq_acq_grid(:, f_max)./normalization) xlim([min(delay) max(delay)]) xlabel('Code delay / chips') ylabel('Test statistics') diff --git a/src/utils/matlab/plot_tracking_quality_indicators.m b/src/utils/matlab/plot_tracking_quality_indicators.m new file mode 100644 index 000000000..a1c263aa3 --- /dev/null +++ b/src/utils/matlab/plot_tracking_quality_indicators.m @@ -0,0 +1,18 @@ +%plot tracking quality indicators +figure; +hold on; +title('Carrier lock test output for all the channels'); +for n=1:1:length(GNSS_tracking) + plot(GNSS_tracking(n).carrier_lock_test) + plotnames{n}=['SV ' num2str(round(mean(GNSS_tracking(n).PRN)))]; +end +legend(plotnames); + +figure; +hold on; +title('Carrier CN0 output for all the channels'); +for n=1:1:length(GNSS_tracking) + plot(GNSS_tracking(n).CN0_SNV_dB_Hz) + plotnames{n}=['SV ' num2str(round(mean(GNSS_tracking(n).PRN)))]; +end +legend(plotnames); \ No newline at end of file diff --git a/src/utils/reproducibility/ieee-access18/L2-access18.conf b/src/utils/reproducibility/ieee-access18/L2-access18.conf index e4bc4ae44..e4d7b5e67 100644 --- a/src/utils/reproducibility/ieee-access18/L2-access18.conf +++ b/src/utils/reproducibility/ieee-access18/L2-access18.conf @@ -85,7 +85,7 @@ Acquisition_2S.doppler_step=125 Acquisition_2S.use_CFAR_algorithm=false -Acquisition_2S.threshold=19.5 +Acquisition_2S.threshold=10 Acquisition_2S.blocking=true @@ -133,7 +133,7 @@ PVT.display_rate_ms=500 ;# KML, GeoJSON, NMEA and RTCM output configuration ;#dump_filename: Log path and filename without extension. Notice that PVT will add ".dat" to the binary dump and ".kml" to GoogleEarth dump. -PVT.dump_filename=./data/PVT +PVT.dump_filename=./data/access18 ;#nmea_dump_filename: NMEA log path and filename PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea diff --git a/src/utils/reproducibility/ieee-access18/README.md b/src/utils/reproducibility/ieee-access18/README.md index 62098afaa..58a2350ff 100644 --- a/src/utils/reproducibility/ieee-access18/README.md +++ b/src/utils/reproducibility/ieee-access18/README.md @@ -4,7 +4,7 @@ Continuous Reproducibility in GNSS Signal Processing This folder contains files required for the reproduction of the experiment proposed in: -C. Fernández-Prades, J. Vilà-Valls, J. Arribas and A. Ramos, [*Continuous Reproducibility in GNSS Signal Processing*](http://ieeexplore.ieee.org/document/8331069/), IEEE Access, accepted for publication, April 2018. DOI: 10.1109/ACCESS.2018.2822835 +C. Fernández-Prades, J. Vilà-Valls, J. Arribas and A. Ramos, [*Continuous Reproducibility in GNSS Signal Processing*](https://ieeexplore.ieee.org/document/8331069/), IEEE Access, Vol. 6, No. 1, pp. 20451-20463, April 2018. DOI: [10.1109/ACCESS.2018.2822835](https://doi.org/10.1109/ACCESS.2018.2822835) The data set used in this paper is available at https://zenodo.org/record/1184601 diff --git a/src/utils/reproducibility/ieee-access18/plot_dump.m b/src/utils/reproducibility/ieee-access18/plot_dump.m index 33416ad77..11aaba424 100644 --- a/src/utils/reproducibility/ieee-access18/plot_dump.m +++ b/src/utils/reproducibility/ieee-access18/plot_dump.m @@ -62,26 +62,46 @@ ylabel('Navigation data bits','fontname','Times','fontsize', fontsize) grid on -fileID = fopen('data/PVT_ls_pvt.dat', 'r'); -dinfo = dir('data/PVT_ls_pvt.dat'); +fileID = fopen('data/access18.dat', 'r'); +dinfo = dir('data/access18.dat'); filesize = dinfo.bytes; aux = 1; while ne(ftell(fileID), filesize) - navsol.RX_time(aux) = fread(fileID, 1, 'double'); - navsol.X(aux) = fread(fileID, 1, 'double'); - navsol.Y(aux) = fread(fileID, 1, 'double'); - navsol.Z(aux) = fread(fileID, 1, 'double'); - navsol.user_clock(aux) = fread(fileID, 1, 'double'); - navsol.lat(aux) = fread(fileID, 1, 'double'); - navsol.long(aux) = fread(fileID, 1, 'double'); - navsol.height(aux) = fread(fileID, 1, 'double'); + navsol.TOW_at_current_symbol_ms(aux) = fread(fileID, 1, 'uint32'); + navsol.week(aux) = fread(fileID, 1, 'uint32'); + navsol.RX_time(aux) = fread(fileID, 1, 'double'); + navsol.user_clock_offset(aux) = fread(fileID, 1, 'double'); + navsol.X(aux) = fread(fileID, 1, 'double'); + navsol.Y(aux) = fread(fileID, 1, 'double'); + navsol.Z(aux) = fread(fileID, 1, 'double'); + navsol.VX(aux) = fread(fileID, 1, 'double'); + navsol.VY(aux) = fread(fileID, 1, 'double'); + navsol.VZ(aux) = fread(fileID, 1, 'double'); + navsol.varXX(aux) = fread(fileID, 1, 'double'); + navsol.varYY(aux) = fread(fileID, 1, 'double'); + navsol.varZZ(aux) = fread(fileID, 1, 'double'); + navsol.varXY(aux) = fread(fileID, 1, 'double'); + navsol.varYZ(aux) = fread(fileID, 1, 'double'); + navsol.varZX(aux) = fread(fileID, 1, 'double'); + navsol.latitude(aux) = fread(fileID, 1, 'double'); + navsol.longitude(aux) = fread(fileID, 1, 'double'); + navsol.height(aux) = fread(fileID, 1, 'double'); + navsol.number_sats(aux) = fread(fileID, 1, 'uint8'); + navsol.solution_status(aux) = fread(fileID, 1, 'uint8'); + navsol.solution_type(aux) = fread(fileID, 1, 'uint8'); + navsol.AR_ratio_factor(aux) = fread(fileID, 1, 'float'); + navsol.AR_ratio_threshold(aux) = fread(fileID, 1, 'float'); + navsol.GDOP(aux) = fread(fileID, 1, 'double'); + navsol.PDOP(aux) = fread(fileID, 1, 'double'); + navsol.HDOP(aux) = fread(fileID, 1, 'double'); + navsol.VDOP(aux) = fread(fileID, 1, 'double'); aux = aux + 1; end fclose(fileID); -mean_Latitude = mean(navsol.lat); -mean_Longitude = mean(navsol.long); +mean_Latitude = mean(navsol.latitude); +mean_Longitude = mean(navsol.longitude); mean_h = mean(navsol.height); utmZone = findUtmZone(mean_Latitude, mean_Longitude); [ref_X_cart, ref_Y_cart, ref_Z_cart] = geo2cart(dms2mat(deg2dms(mean_Latitude)), dms2mat(deg2dms(mean_Longitude)), mean_h, 5); diff --git a/src/utils/rinex2assist/CMakeLists.txt b/src/utils/rinex2assist/CMakeLists.txt new file mode 100644 index 000000000..d42b379b5 --- /dev/null +++ b/src/utils/rinex2assist/CMakeLists.txt @@ -0,0 +1,101 @@ +# Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . +# + +find_package(GPSTK QUIET) +if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) + include(GNUInstallDirs) + #string(REGEX REPLACE /[^/]*$ "" LIBDIR ${CMAKE_INSTALL_LIBDIR}) + set(GPSTK_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(GPSTK_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include) +endif() + + +find_package(Boost COMPONENTS iostreams serialization QUIET) +if(CMAKE_VERSION VERSION_LESS 3.5) + if(NOT TARGET Boost::iostreams) + add_library(Boost::iostreams IMPORTED SHARED) + set_property(TARGET Boost::iostreams PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::iostreams PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_IOSTREAMS_LIBRARIES}) + set_property(TARGET Boost::iostreams PROPERTY + IMPORTED_LOCATION ${Boost_IOSTREAMS_LIBRARIES}) + endif() + if(NOT TARGET Boost::serialization) + add_library(Boost::serialization IMPORTED SHARED) + set_property(TARGET Boost::serialization PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) + set_property(TARGET Boost::serialization PROPERTY + INTERFACE_LINK_LIBRARIES ${Boost_SERIALIZARION_LIBRARIES}) + set_property(TARGET Boost::serialization PROPERTY + IMPORTED_LOCATION ${Boost_SERIALIZARION_LIBRARIES}) + endif() +endif() + + +find_program(UNCOMPRESS_EXECUTABLE uncompress + PATHS /bin + /usr/bin + /usr/sbin +) + +if(Boost_FOUND) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") + + add_executable(rinex2assist ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) + + target_link_libraries(rinex2assist + PUBLIC + Boost::iostreams + Boost::serialization + ${GPSTK_LIBRARY} + Gflags::gflags + algorithms_libs + core_receiver + core_system_parameters + ) + + target_include_directories(rinex2assist + PUBLIC + ${GPSTK_INCLUDE_DIR}/gpstk + ${GPSTK_INCLUDE_DIR} + ) + + if(NOT UNCOMPRESS_EXECUTABLE-NOTFOUND) + target_compile_definitions(rinex2assist PUBLIC -DUNCOMPRESS_EXECUTABLE="${UNCOMPRESS_EXECUTABLE}") + else() + target_compile_definitions(rinex2assist PUBLIC -DUNCOMPRESS_EXECUTABLE="") + endif() + + if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) + add_dependencies(rinex2assist gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}) + endif() + + add_custom_command(TARGET rinex2assist POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$ + ) + + install(TARGETS rinex2assist + RUNTIME DESTINATION bin + COMPONENT "rinex2assist" + ) +else() + message(STATUS "Boost Iostreams library not found.") + message(STATUS " rinex2assist will not be built.") +endif() diff --git a/src/utils/rinex2assist/README.md b/src/utils/rinex2assist/README.md new file mode 100644 index 000000000..9d378d797 --- /dev/null +++ b/src/utils/rinex2assist/README.md @@ -0,0 +1,81 @@ +Rinex2assist +------------ + +This program reads data from RINEX navigation files and generates XML files that can be read by GNSS-SDR as Assisted GNSS data. + +### Building + +This program is built along with GNSS-SDR if the options `ENABLE_UNIT_TESTING_EXTRA` or `ENABLE_SYSTEM_TESTING_EXTRA` are set to `ON` when calling CMake: + +``` +$ cmake -DENABLE_SYSTEM_TESTING_EXTRA=ON .. +$ make +$ sudo make intall +``` + +The last step is optional. Without it, you will get the executable at `../install/rinex2assist`. + +The building requires two extra dependencies: the Boost Iostreams library and the program `uncompress`: + + * The Boost Iostreams library can be installed through a package: + - In Debian / Ubuntu: `sudo apt-get install libboost-iostreams-dev` + - In Fedora / CentOS: `sudo yum install boost-iostreams` + - In OpenSUSE: `sudo zypper install libboost_iostreams-devel` + - In Arch Linux: included in `boost-libs` package. + - In MacOS: included in Macports / Homebrew `boost` package. + * The program `uncompress` is available by default in most UNIX and GNU/Linux systems. + - In Fedora / CentOS: `sudo yum install ncompress` + - In OpenSUSE: `sudo zypper install ncompress` + +### Usage + +The usage is as follows: + +``` +$ rinex2assist /path/to/RINEX_nav_file +``` + +The argument is mandatory (the name of the RINEX navigation file). The name `gps_ephemeris.xml` is given to the output if GPS NAV data is fould. If the RINEX file contains Galileo data, the corresponding `gal_ephemeris.xml` file will be generated. The program is also able to extract parameters of the UTC and the Ionospheric models from the RINEX header, if available. They will be called `gps_utc_model.xml`, `gps_iono.xml`, `gal_utc_model.xml` and `gal_iono.xml`. + +There are some servers available for downloading recent RINEX navigation files. For instance: + * NASA: [ftp://cddis.gsfc.nasa.gov/pub/gnss/data/hourly/](ftp://gssc.esa.int/gnss/data/hourly/) + * ESA: [ftp://gssc.esa.int/gnss/data/hourly/](ftp://gssc.esa.int/gnss/data/hourly/) + * UNAVCO: [ftp://data-out.unavco.org/pub/hourly/rinex/](ftp://data-out.unavco.org/pub/hourly/rinex/) + +Just make sure to pick up a recent file from a [station near you](http://www.igs.org/network). + +The program accepts either versions 2.xx or 3.xx for the RINEX navigation data file, as well as compressed files (ending in `.gz` or `.Z`). + +Examples: + +``` +$ rinex2assist EBRE00ESP_R_20183290400_01H_GN.rnx.gz +Generated file: gps_ephemeris.xml +Generated file: gps_utc_model.xml +Generated file: gps_iono.xml +``` + +and + +``` +$ rinex2assist EBRE00ESP_R_20183290000_01H_EN.rnx.gz +Generated file: gal_ephemeris.xml +Generated file: gal_utc_model.xml +Generated file: gal_iono.xml +``` + + +An example of GNSS-SDR configuration using ephemeris, UTC and ionospheric model parameters for GPS L1 and Galileo signals is shown below: + +``` +GNSS-SDR.AGNSS_XML_enabled=true +GNSS-SDR.AGNSS_ref_location=41.39,2.31 +GNSS-SDR.AGNSS_gps_ephemeris_xml=gps_ephemeris.xml +GNSS-SDR.AGNSS_gps_iono_xml=gps_iono.xml +GNSS-SDR.AGNSS_gps_utc_model_xml=gps_utc_model.xml +GNSS-SDR.AGNSS_gal_ephemeris_xml=gal_ephemeris.xml +GNSS-SDR.AGNSS_gal_iono_xml=gal_iono.xml +GNSS-SDR.AGNSS_gal_utc_model_xml=gal_utc_model.xml +``` + +More info about the usage of AGNSS data [here](https://gnss-sdr.org/docs/sp-blocks/global-parameters/#assisted-gnss-with-xml-files). diff --git a/src/utils/rinex2assist/main.cc b/src/utils/rinex2assist/main.cc new file mode 100644 index 000000000..f23b58ed7 --- /dev/null +++ b/src/utils/rinex2assist/main.cc @@ -0,0 +1,440 @@ +/*! + * \file main.cc + * \brief converts navigation RINEX files into XML files for Assisted GNSS. + * \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.cat + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "galileo_ephemeris.h" +#include "galileo_iono.h" +#include "galileo_utc_model.h" +#include "gps_ephemeris.h" +#include "gps_iono.h" +#include "gps_utc_model.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main(int argc, char** argv) +{ + const std::string intro_help( + std::string("\n rinex2assist converts navigation RINEX files into XML files for Assisted GNSS\n") + + "Copyright (C) 2018 (see AUTHORS file for a list of contributors)\n" + + "This program comes with ABSOLUTELY NO WARRANTY;\n" + + "See COPYING file to see a copy of the General Public License.\n \n" + + "Usage: \n" + + " rinex2assist "); + + google::SetUsageMessage(intro_help); + google::SetVersionString("1.0"); + google::ParseCommandLineFlags(&argc, &argv, true); + + if ((argc != 2)) + { + std::cerr << "Usage:" << std::endl; + std::cerr << " " << argv[0] + << " " + << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + std::string xml_filename; + + // Uncompress if RINEX file is gzipped + std::string rinex_filename(argv[1]); + std::string input_filename = rinex_filename; + std::size_t found = rinex_filename.find_last_of('.'); + if (found != std::string::npos) + { + if (rinex_filename.size() >= found + 3) + { + if ((rinex_filename.substr(found + 1, found + 3) == "gz")) + { + std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary); + if (file.fail()) + { + std::cerr << "Could not open file " << rinex_filename << std::endl; + return 1; + } + boost::iostreams::filtering_streambuf in; + try + { + in.push(boost::iostreams::gzip_decompressor()); + } + catch (const boost::exception& e) + { + std::cerr << "Could not decompress file " << rinex_filename << std::endl; + return 1; + } + in.push(file); + std::string rinex_filename_unzipped = rinex_filename.substr(0, found); + std::ofstream output_file(rinex_filename_unzipped.c_str(), std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); + if (file.fail()) + { + std::cerr << "Could not create file " << rinex_filename_unzipped << std::endl; + return 1; + } + boost::iostreams::copy(in, output_file); + input_filename = rinex_filename_unzipped; + } + } + if (rinex_filename.size() >= found + 2) + { + if ((rinex_filename.substr(found + 1, found + 2) == "Z")) + { + std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary); + if (file.fail()) + { + std::cerr << "Could not open file" << rinex_filename << std::endl; + return 1; + } + file.close(); + std::string uncompress_executable(UNCOMPRESS_EXECUTABLE); + if (!uncompress_executable.empty()) + { + // option k is not always available, so we save a copy of the original file + std::string argum = std::string("/bin/cp " + rinex_filename + " " + rinex_filename + ".aux"); + int s1 = std::system(argum.c_str()); + std::string argum2 = std::string(uncompress_executable + " -f " + rinex_filename); + int s2 = std::system(argum2.c_str()); + std::string argum3 = std::string("/bin/mv " + rinex_filename + +".aux" + " " + rinex_filename); + int s3 = std::system(argum3.c_str()); + input_filename = rinex_filename.substr(0, found); + if ((s1 != 0) or (s2 != 0) or (s3 != 0)) + { + std::cerr << "Failure uncompressing file." << std::endl; + return 1; + } + } + else + { + std::cerr << "uncompress program not found." << std::endl; + return 1; + } + } + } + } + + std::map eph_map; + std::map eph_gal_map; + + Gps_Utc_Model gps_utc_model; + Gps_Iono gps_iono; + Galileo_Utc_Model gal_utc_model; + Galileo_Iono gal_iono; + + int i = 0; + int j = 0; + try + { + // Read nav file + gpstk::Rinex3NavStream rnffs(input_filename.c_str()); // Open navigation data file + gpstk::Rinex3NavData rne; + gpstk::Rinex3NavHeader hdr; + + // Read header + rnffs >> hdr; + + // Check that it really is a RINEX navigation file + if (hdr.fileType.substr(0, 1) != "N") + { + std::cerr << "This is not a valid RINEX navigation file, or file not found." << std::endl; + std::cerr << "No XML file will be created." << std::endl; + return 1; + } + + // Collect UTC parameters from RINEX header + if (hdr.fileSys == "G: (GPS)" || hdr.fileSys == "MIXED") + { + gps_utc_model.valid = (hdr.valid > 2147483648) ? true : false; + gps_utc_model.d_A1 = hdr.mapTimeCorr["GPUT"].A0; + gps_utc_model.d_A0 = hdr.mapTimeCorr["GPUT"].A1; + gps_utc_model.d_t_OT = hdr.mapTimeCorr["GPUT"].refSOW; + gps_utc_model.i_WN_T = hdr.mapTimeCorr["GPUT"].refWeek; + gps_utc_model.d_DeltaT_LS = hdr.leapSeconds; + gps_utc_model.i_WN_LSF = hdr.leapWeek; + gps_utc_model.i_DN = hdr.leapDay; + gps_utc_model.d_DeltaT_LSF = hdr.leapDelta; + + // Collect iono parameters from RINEX header + gps_iono.valid = (hdr.mapIonoCorr["GPSA"].param[0] == 0) ? false : true; + gps_iono.d_alpha0 = hdr.mapIonoCorr["GPSA"].param[0]; + gps_iono.d_alpha1 = hdr.mapIonoCorr["GPSA"].param[1]; + gps_iono.d_alpha2 = hdr.mapIonoCorr["GPSA"].param[2]; + gps_iono.d_alpha3 = hdr.mapIonoCorr["GPSA"].param[3]; + gps_iono.d_beta0 = hdr.mapIonoCorr["GPSB"].param[0]; + gps_iono.d_beta1 = hdr.mapIonoCorr["GPSB"].param[1]; + gps_iono.d_beta2 = hdr.mapIonoCorr["GPSB"].param[2]; + gps_iono.d_beta3 = hdr.mapIonoCorr["GPSB"].param[3]; + } + if (hdr.fileSys == "E: (GAL)" || hdr.fileSys == "MIXED") + { + gal_utc_model.A0_6 = hdr.mapTimeCorr["GAUT"].A0; + gal_utc_model.A1_6 = hdr.mapTimeCorr["GAUT"].A1; + gal_utc_model.Delta_tLS_6 = hdr.leapSeconds; + gal_utc_model.t0t_6 = hdr.mapTimeCorr["GAUT"].refSOW; + gal_utc_model.WNot_6 = hdr.mapTimeCorr["GAUT"].refWeek; + gal_utc_model.WN_LSF_6 = hdr.leapWeek; + gal_utc_model.DN_6 = hdr.leapDay; + gal_utc_model.Delta_tLSF_6 = hdr.leapDelta; + gal_utc_model.flag_utc_model = (hdr.mapTimeCorr["GAUT"].A0 == 0.0); + gal_iono.ai0_5 = hdr.mapIonoCorr["GAL"].param[0]; + gal_iono.ai1_5 = hdr.mapIonoCorr["GAL"].param[1]; + gal_iono.ai2_5 = hdr.mapIonoCorr["GAL"].param[2]; + gal_iono.Region1_flag_5 = false; + gal_iono.Region2_flag_5 = false; + gal_iono.Region3_flag_5 = false; + gal_iono.Region4_flag_5 = false; + gal_iono.Region5_flag_5 = false; + gal_iono.TOW_5 = 0.0; + gal_iono.WN_5 = 0.0; + } + + // Read navigation data + while (rnffs >> rne) + { + if (rne.satSys == "G" or rne.satSys.empty()) + { + // Fill GPS ephemeris object + Gps_Ephemeris eph; + eph.i_satellite_PRN = rne.PRNID; + eph.d_TOW = rne.xmitTime; + eph.d_IODE_SF2 = rne.IODE; + eph.d_IODE_SF3 = rne.IODE; + eph.d_Crs = rne.Crs; + eph.d_Delta_n = rne.dn; + eph.d_M_0 = rne.M0; + eph.d_Cuc = rne.Cuc; + eph.d_e_eccentricity = rne.ecc; + eph.d_Cus = rne.Cus; + eph.d_sqrt_A = rne.Ahalf; + eph.d_Toe = rne.Toe; + eph.d_Toc = rne.Toc; + eph.d_Cic = rne.Cic; + eph.d_OMEGA0 = rne.OMEGA0; + eph.d_Cis = rne.Cis; + eph.d_i_0 = rne.i0; + eph.d_Crc = rne.Crc; + eph.d_OMEGA = rne.w; + eph.d_OMEGA_DOT = rne.OMEGAdot; + eph.d_IDOT = rne.idot; + eph.i_code_on_L2 = rne.codeflgs; // + eph.i_GPS_week = rne.weeknum; + eph.b_L2_P_data_flag = rne.L2Pdata; + eph.i_SV_accuracy = rne.accuracy; + eph.i_SV_health = rne.health; + eph.d_TGD = rne.Tgd; + eph.d_IODC = rne.IODC; + eph.i_AODO = 0; // + eph.b_fit_interval_flag = (rne.fitint > 4) ? true : false; + eph.d_spare1 = 0.0; + eph.d_spare2 = 0.0; + eph.d_A_f0 = rne.af0; + eph.d_A_f1 = rne.af1; + eph.d_A_f2 = rne.af2; + eph.b_integrity_status_flag = false; // + eph.b_alert_flag = false; // + eph.b_antispoofing_flag = false; // + eph_map[i] = eph; + i++; + } + if (rne.satSys == "E") + { + // Fill Galileo ephemeris object + Galileo_Ephemeris eph; + eph.i_satellite_PRN = rne.PRNID; + eph.M0_1 = rne.M0; + eph.e_1 = rne.ecc; + eph.A_1 = rne.Ahalf; + eph.OMEGA_0_2 = rne.OMEGA0; + eph.i_0_2 = rne.i0; + eph.omega_2 = rne.w; + eph.OMEGA_dot_3 = rne.OMEGAdot; + eph.delta_n_3 = rne.dn; + eph.iDot_2 = rne.idot; + eph.C_uc_3 = rne.Cuc; + eph.C_us_3 = rne.Cus; + eph.C_rc_3 = rne.Crc; + eph.C_rs_3 = rne.Crs; + eph.C_ic_4 = rne.Cic; + eph.C_is_4 = rne.Cis; + eph.t0e_1 = rne.Toe; + eph.t0c_4 = rne.Toc; + eph.af0_4 = rne.af0; + eph.af1_4 = rne.af1; + eph.af2_4 = rne.af2; + eph.WN_5 = rne.weeknum; + eph_gal_map[j] = eph; + j++; + } + } + } + catch (std::exception& e) + { + std::cerr << "Error reading the RINEX file: " << e.what() << std::endl; + std::cerr << "No XML file will be created." << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + + if (i == 0 and j == 0) + { + std::cerr << "No navigation data found in the RINEX file. No XML file will be created." << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + + // Write XML ephemeris + if (i != 0) + { + std::ofstream ofs; + if (xml_filename.empty()) + { + xml_filename = "gps_ephemeris.xml"; + } + try + { + ofs.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map); + } + catch (std::exception& e) + { + std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + std::cout << "Generated file: " << xml_filename << std::endl; + } + if (j != 0) + { + std::ofstream ofs2; + xml_filename = "gal_ephemeris.xml"; + try + { + ofs2.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs2); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", eph_gal_map); + } + catch (std::exception& e) + { + std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + std::cout << "Generated file: " << xml_filename << std::endl; + } + + // Write XML UTC + if (gps_utc_model.valid) + { + std::ofstream ofs3; + xml_filename = "gps_utc_model.xml"; + try + { + ofs3.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs3); + xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", gps_utc_model); + } + catch (std::exception& e) + { + std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + std::cout << "Generated file: " << xml_filename << std::endl; + } + + // Write XML iono + if (gps_iono.valid) + { + std::ofstream ofs4; + xml_filename = "gps_iono.xml"; + try + { + ofs4.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs4); + xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", gps_iono); + } + catch (std::exception& e) + { + std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + std::cout << "Generated file: " << xml_filename << std::endl; + } + + if (gal_utc_model.A0_6 != 0) + { + std::ofstream ofs5; + xml_filename = "gal_utc_model.xml"; + try + { + ofs5.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs5); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", gal_utc_model); + } + catch (std::exception& e) + { + std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + std::cout << "Generated file: " << xml_filename << std::endl; + } + if (gal_iono.ai0_5 != 0) + { + std::ofstream ofs7; + xml_filename = "gal_iono.xml"; + try + { + ofs7.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs7); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", gal_iono); + } + catch (std::exception& e) + { + std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl; + google::ShutDownCommandLineFlags(); + return 1; + } + std::cout << "Generated file: " << xml_filename << std::endl; + } + google::ShutDownCommandLineFlags(); + return 0; +} diff --git a/src/utils/scripts/gnss-sdr-harness.sh b/src/utils/scripts/gnss-sdr-harness.sh new file mode 100755 index 000000000..b025bb07b --- /dev/null +++ b/src/utils/scripts/gnss-sdr-harness.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# GNSS-SDR shell script that enables the remote GNSS-SDR restart telecommand +# usage: ./gnss-sdr-harness.sh ./gnss-sdr -c config_file.conf +echo $@ +$@ +while [ $? -eq 42 ] +do + echo "restarting GNSS-SDR..." + $@ +done