diff options
author | Helmut Schmidt <Helmut.3.Schmidt@continental-corporation.com> | 2014-08-22 17:50:59 +0200 |
---|---|---|
committer | Helmut Schmidt <Helmut.3.Schmidt@continental-corporation.com> | 2014-08-22 18:09:07 +0200 |
commit | 6b92da94e457c2a5bbd2418dec6c17ffc968185b (patch) | |
tree | e3606cc61f69369809409d63ff93e5244df1fa0d | |
parent | be37f943204fb53e5f015110855bbcd5555d3aae (diff) | |
parent | 2f8e86379ef3b8d01cb401690eec488b484af51a (diff) | |
download | positioning-6b92da94e457c2a5bbd2418dec6c17ffc968185b.tar.gz |
Merge branch 'GT-3012' containing the GNSS API redesign
This provides a single data structure with all GNSS
information required for GNSS/DR sensor fusion
See https://collab.genivi.org/issues/browse/GT-3012
21 files changed, 1040 insertions, 1364 deletions
diff --git a/enhanced-position-service/src/enhanced-position.cpp b/enhanced-position-service/src/enhanced-position.cpp index b5b271f..a1b999e 100644 --- a/enhanced-position-service/src/enhanced-position.cpp +++ b/enhanced-position-service/src/enhanced-position.cpp @@ -85,8 +85,7 @@ std::map< uint16_t, ::DBus::Variant > EnhancedPosition::GetData(const std::vecto { std::map< uint16_t, ::DBus::Variant > Data; - TGNSSPosition pos; - TGNSSCourse course; + TGNSSPosition position; bool isPosRequested = false; bool isCourseRequested = false; @@ -97,7 +96,6 @@ std::map< uint16_t, ::DBus::Variant > EnhancedPosition::GetData(const std::vecto (valuesToReturn[i] == POS_LONGITUDE) || (valuesToReturn[i] == POS_ALTITUDE)) { - //if any of the three IDs above is set, then gnssSimpleGetPosition will have to be called isPosRequested = true; } @@ -105,49 +103,48 @@ std::map< uint16_t, ::DBus::Variant > EnhancedPosition::GetData(const std::vecto (valuesToReturn[i] == POS_SPEED) || (valuesToReturn[i] == POS_CLIMB )) { - //if any of the three IDs above is set, then gnssSimpleGetCourse will have to be called isCourseRequested = true; } } if(isPosRequested) { - if(gnssSimpleGetPosition(&pos)) + if(gnssGetPosition(&position)) { - if (pos.validityBits && GNSS_POSITION_LATITUDE_VALID) + if (position.validityBits & GNSS_POSITION_LATITUDE_VALID) { - Data[POS_LATITUDE] = variant_double(pos.latitude); + Data[POS_LATITUDE] = variant_double(position.latitude); } - if (pos.validityBits && GNSS_POSITION_LONGITUDE_VALID) + if (position.validityBits & GNSS_POSITION_LONGITUDE_VALID) { - Data[POS_LONGITUDE] = variant_double(pos.longitude); + Data[POS_LONGITUDE] = variant_double(position.longitude); } - if (pos.validityBits && GNSS_POSITION_ALTITUDE_VALID) + if (position.validityBits & GNSS_POSITION_ALTITUDEMSL_VALID) { - Data[POS_ALTITUDE] = variant_double(pos.altitude); + Data[POS_ALTITUDE] = variant_double(position.altitudeMSL); } } } if(isCourseRequested) { - if(gnssSimpleGetCourse(&course)) + if(gnssGetPosition(&position)) { - if (course.validityBits && GNSS_COURSE_SPEED_VALID) + if (position.validityBits & GNSS_POSITION_HEADING_VALID) { - Data[POS_HEADING] = variant_double(course.heading); + Data[POS_HEADING] = variant_double(position.heading); } - if (course.validityBits && GNSS_COURSE_CLIMB_VALID) + if (position.validityBits & GNSS_POSITION_HSPEED_VALID) { - Data[POS_SPEED] = variant_double(course.speed); + Data[POS_SPEED] = variant_double(position.hSpeed); } - if (course.validityBits && GNSS_COURSE_HEADING_VALID) + if (position.validityBits & GNSS_POSITION_VSPEED_VALID) { - Data[POS_CLIMB] = variant_double(course.climb); + Data[POS_CLIMB] = variant_double(position.vSpeed); } } } @@ -158,44 +155,40 @@ std::map< uint16_t, ::DBus::Variant > EnhancedPosition::GetData(const std::vecto std::map< uint16_t, ::DBus::Variant > EnhancedPosition::GetPosition() { std::map< uint16_t, ::DBus::Variant > Position; - TGNSSPosition pos; - TGNSSCourse course; + TGNSSPosition position; - if (gnssSimpleGetPosition(&pos)) - { - if (pos.validityBits && GNSS_POSITION_LATITUDE_VALID) + if(gnssGetPosition(&position)) { - Position[POS_LATITUDE] = variant_double(pos.latitude); - } + if (position.validityBits & GNSS_POSITION_LATITUDE_VALID) + { + Position[POS_LATITUDE] = variant_double(position.latitude); + } - if (pos.validityBits && GNSS_POSITION_LONGITUDE_VALID) - { - Position[POS_LONGITUDE] = variant_double(pos.longitude); - } + if (position.validityBits & GNSS_POSITION_LONGITUDE_VALID) + { + Position[POS_LONGITUDE] = variant_double(position.longitude); + } - if (pos.validityBits && GNSS_POSITION_ALTITUDE_VALID) - { - Position[POS_ALTITUDE] = variant_double(pos.altitude); - } - } + if (position.validityBits & GNSS_POSITION_ALTITUDEMSL_VALID) + { + Position[POS_ALTITUDE] = variant_double(position.altitudeMSL); + } - if(gnssSimpleGetCourse(&course)) - { - if (pos.validityBits && GNSS_COURSE_SPEED_VALID) - { - Position[POS_HEADING] = variant_double(course.heading); - } + if (position.validityBits & GNSS_POSITION_HEADING_VALID) + { + Position[POS_HEADING] = variant_double(position.heading); + } - if (pos.validityBits && GNSS_COURSE_CLIMB_VALID) - { - Position[POS_SPEED] = variant_double(course.speed); - } + if (position.validityBits & GNSS_POSITION_HSPEED_VALID) + { + Position[POS_SPEED] = variant_double(position.hSpeed); + } - if (pos.validityBits && GNSS_COURSE_HEADING_VALID) - { - Position[POS_CLIMB] = variant_double(course.climb); + if (position.validityBits & GNSS_POSITION_VSPEED_VALID) + { + Position[POS_CLIMB] = variant_double(position.vSpeed); + } } - } return Position; } @@ -245,17 +238,19 @@ std::map< uint16_t, ::DBus::Variant > EnhancedPosition::GetTime() return Time; } -void EnhancedPosition::cbPosition(const TGNSSPosition pos[], uint16_t numElements) +void EnhancedPosition::sigPositionUpdate(const TGNSSPosition position[], uint16_t numElements) { bool latChanged = false; bool lonChanged = false; bool altChanged = false; + bool speedChanged = false; + bool headingChanged = false; + bool climbChanged = false; - std::vector< uint16_t > position; - if (pos == NULL || numElements < 1) + if (position == NULL || numElements < 1) { - LOG_ERROR_MSG(gCtx,"cbPosition failed!"); + LOG_ERROR_MSG(gCtx,"sigPositionUpdate failed!"); return; } @@ -264,23 +259,38 @@ void EnhancedPosition::cbPosition(const TGNSSPosition pos[], uint16_t numElement LOG_INFO(gCtx,"Position Update[%d/%d]: lat=%f lon=%f alt=%f", i+1, numElements, - pos[i].latitude, - pos[i].longitude, - pos[i].altitude); + position[i].latitude, + position[i].longitude, + position[i].altitudeMSL); if (latChanged == false) { - latChanged = (pos[i].validityBits && GNSS_POSITION_LATITUDE_VALID); + latChanged = (position[i].validityBits & GNSS_POSITION_LATITUDE_VALID); } if (lonChanged == false) { - lonChanged = (pos[i].validityBits && GNSS_POSITION_LONGITUDE_VALID); + lonChanged = (position[i].validityBits & GNSS_POSITION_LONGITUDE_VALID); } if (altChanged == false) { - altChanged = (pos[i].validityBits && GNSS_POSITION_ALTITUDE_VALID); + altChanged = (position[i].validityBits & GNSS_POSITION_ALTITUDEMSL_VALID); + } + + if (speedChanged == false) + { + speedChanged = (position[i].validityBits & GNSS_POSITION_HSPEED_VALID); + } + + if (headingChanged == false) + { + headingChanged = (position[i].validityBits & GNSS_POSITION_HEADING_VALID); + } + + if (climbChanged == false) + { + climbChanged = (position[i].validityBits & GNSS_POSITION_VSPEED_VALID); } } @@ -307,6 +317,21 @@ void EnhancedPosition::cbPosition(const TGNSSPosition pos[], uint16_t numElement it = changedValues.insert(it,POS_ALTITUDE); } + if (speedChanged) + { + it = changedValues.insert(it,POS_SPEED); + } + + if (headingChanged) + { + it = changedValues.insert(it,POS_HEADING); + } + + if (climbChanged) + { + it = changedValues.insert(it,POS_CLIMB); + } + if (!mpSelf) { LOG_ERROR_MSG(gCtx,"Null pointer!"); @@ -315,182 +340,202 @@ void EnhancedPosition::cbPosition(const TGNSSPosition pos[], uint16_t numElement //notify clients mpSelf->PositionUpdate(changedValues); + + } -void EnhancedPosition::cbCourse(const TGNSSCourse course[], uint16_t numElements) -{ - bool speedChanged = false; - bool headingChanged = false; - bool climbChanged = false; - - if (course == NULL || numElements < 1) +void EnhancedPosition::sigAccuracyUpdate(const TGNSSPosition position[], uint16_t numElements) +{ + bool pdopChanged = false; + bool hdopChanged = false; + bool vdopChanged = false; + bool sigmaHPosChanged = false; + bool sigmaAltitudeChanged = false; + + if (position == NULL || numElements < 1) { - LOG_ERROR_MSG(gCtx,"cbCourse failed!"); - return; + LOG_ERROR_MSG(gCtx,"sigAccuracyUpdate failed!"); + return; } - for (int i = 0; i < numElements; i++) + for (int i = 0; i< numElements; i++) { - LOG_INFO(gCtx,"Course Update[%d/%d]: speed=%f heading=%f climb=%f", - i+1, - numElements, - course[i].speed, - course[i].heading, - course[i].climb); + LOG_INFO(gCtx,"Accuracy Update[%d/%d]: pdop=%f hdop=%f vdop=%f \ + sigmaHPosition=%f sigmaAltitude=%f", + i+1, + numElements, + position[i].pdop, + position[i].hdop, + position[i].vdop, + position[i].sigmaHPosition, + position[i].sigmaAltitude); - if (speedChanged == false) + if (pdopChanged == false) { - speedChanged = (course[i].validityBits && GNSS_COURSE_SPEED_VALID); + pdopChanged = (position[i].validityBits & GNSS_POSITION_PDOP_VALID); } - if (headingChanged == false) + if (hdopChanged == false) { - headingChanged = (course[i].validityBits && GNSS_COURSE_HEADING_VALID); + hdopChanged = (position[i].validityBits & GNSS_POSITION_HDOP_VALID); } - if (climbChanged == false) + if (vdopChanged == false) + { + vdopChanged = (position[i].validityBits & GNSS_POSITION_VDOP_VALID); + } + + if (sigmaHPosChanged == false) + { + sigmaHPosChanged = (position[i].validityBits & GNSS_POSITION_SHPOS_VALID); + } + + if (sigmaAltitudeChanged == false) { - climbChanged = (course[i].validityBits && GNSS_COURSE_CLIMB_VALID); + sigmaAltitudeChanged = (position[i].validityBits & GNSS_POSITION_SALT_VALID); } } - //in a real product, the course would be used for dead-reckoning. + //in a real product, the accuracy would be used for dead-reckoning. //in this proof of concept, the client application is simply notified - //about changes of speed, heading and/or climb - std::vector< uint16_t > changedValues; + //about accuracy changes std::vector<uint16_t>::iterator it; - it = changedValues.begin(); - - if (speedChanged) + + std::vector< uint16_t > changedAccuracyValues; + it = changedAccuracyValues.begin(); + + if (pdopChanged) { - it = changedValues.insert(it,POS_SPEED); + it = changedAccuracyValues.insert(it,POS_PDOP); } - if (headingChanged) + if (hdopChanged) { - it = changedValues.insert(it,POS_HEADING); + it = changedAccuracyValues.insert(it,POS_HDOP); } + + if (vdopChanged) + { + it = changedAccuracyValues.insert(it,POS_VDOP); + } - if (climbChanged) + if (sigmaHPosChanged) { - it = changedValues.insert(it,POS_CLIMB); + it = changedAccuracyValues.insert(it,POS_SIGMA_LATITUDE); + it = changedAccuracyValues.insert(it,POS_SIGMA_LONGITUDE); + } + + if (sigmaAltitudeChanged) + { + it = changedAccuracyValues.insert(it,POS_VISIBLE_SATELLITES); } + //todo: handle other field-changes here (accuracy and status) + if (!mpSelf) { LOG_ERROR_MSG(gCtx,"Null pointer!"); return; } - - //notify clients - mpSelf->PositionUpdate(changedValues); + + mpSelf->AccuracyUpdate(changedAccuracyValues); } -void EnhancedPosition::cbAccuracy(const TGNSSAccuracy accuracy[], uint16_t numElements) +void EnhancedPosition::sigStatusUpdate(const TGNSSPosition position[], uint16_t numElements) { - //satellite info - bool usedSatellitesChanged = false; - bool trackedSatellitesChanged = false; - bool visibleSatellitesChanged = false; - - //status + bool fixStatusChanged = false; bool fixTypeBitsChanged = false; - - //accuracy - bool pdopChanged = false; - bool hdopChanged = false; - bool vdopChanged = false; - bool sigmaLatitudeChanged = false; - bool sigmaLongitudeChanged = false; - bool sigmaAltitudeChanged = false; - if (accuracy == NULL || numElements < 1) + if (position == NULL || numElements < 1) { - LOG_ERROR_MSG(gCtx,"cbAccuracy failed!"); + LOG_ERROR_MSG(gCtx,"sigStatusUpdate failed!"); return; } for (int i = 0; i< numElements; i++) { - LOG_INFO(gCtx,"Accuracy Update[%d/%d]: usedSatellites=%d trackedSatellites=%d visibleSatellites=%d", - i+1, - numElements, - accuracy[i].usedSatellites, - accuracy[i].trackedSatellites, - accuracy[i].visibleSatellites); - - LOG_INFO(gCtx,"Accuracy Update[%d/%d]: fixStatus=%d fixTypeBits=0x%08X", + LOG_INFO(gCtx,"Status Update[%d/%d]: fixStatus=%d fixTypeBits=0x%08X", i+1, numElements, - accuracy[i].fixStatus, - accuracy[i].fixTypeBits); - - LOG_INFO(gCtx,"Accuracy Update[%d/%d]: pdop=%f hdop=%f vdop=%f \ - sigmaLatitude=%f sigmaLongitude=%f sigmaAltitude=%f", - i+1, - numElements, - accuracy[i].pdop, - accuracy[i].hdop, - accuracy[i].vdop, - accuracy[i].sigmaLatitude, - accuracy[i].sigmaLongitude, - accuracy[i].sigmaAltitude); - - if (usedSatellitesChanged == false) + position[i].fixStatus, + position[i].fixTypeBits); + + if (fixStatusChanged == false) { - usedSatellitesChanged = (accuracy[i].validityBits && GNSS_ACCURACY_USAT_VALID); + fixStatusChanged = (position[i].validityBits & GNSS_POSITION_STAT_VALID); } - if (trackedSatellitesChanged == false) + if (fixTypeBitsChanged == false) { - trackedSatellitesChanged = (accuracy[i].validityBits && GNSS_ACCURACY_TSAT_VALID); + fixTypeBitsChanged = (position[i].validityBits & GNSS_POSITION_TYPE_VALID); } - if (visibleSatellitesChanged == false) - { - visibleSatellitesChanged = (accuracy[i].validityBits && GNSS_ACCURACY_VSAT_VALID); - } + } - if (fixStatusChanged == false) - { - fixStatusChanged = (accuracy[i].validityBits && GNSS_ACCURACY_STAT_VALID); - } - - if (fixTypeBitsChanged == false) - { - fixTypeBitsChanged = (accuracy[i].validityBits && GNSS_ACCURACY_TYPE_VALID); - } + //in a real product, the accuracy would be used for dead-reckoning. + //in this proof of concept, the client application is simply notified + //about status changes + std::vector<uint16_t>::iterator it; + + std::vector< uint16_t > changedStatusValues; + it = changedStatusValues.begin(); - if (pdopChanged == false) - { - pdopChanged = (accuracy[i].validityBits && GNSS_ACCURACY_PDOP_VALID); - } + if (fixStatusChanged) + { + it = changedStatusValues.insert(it,POS_GNSS_FIX_STATUS); + } - if (hdopChanged == false) - { - hdopChanged = (accuracy[i].validityBits && GNSS_ACCURACY_HDOP_VALID); - } + if (!mpSelf) + { + LOG_ERROR_MSG(gCtx,"Null pointer!"); + return; + } + + mpSelf->StatusUpdate(changedStatusValues); +} - if (vdopChanged == false) - { - vdopChanged = (accuracy[i].validityBits && GNSS_ACCURACY_VDOP_VALID); - } - if (sigmaLatitudeChanged == false) + +void EnhancedPosition::sigSatelliteInfoUpdate(const TGNSSPosition position[], uint16_t numElements) +{ + //satellite info + bool usedSatellitesChanged = false; + bool trackedSatellitesChanged = false; + bool visibleSatellitesChanged = false; + + + + if (position == NULL || numElements < 1) + { + LOG_ERROR_MSG(gCtx,"sigSatelliteInfoUpdate failed!"); + return; + } + + for (int i = 0; i< numElements; i++) + { + LOG_INFO(gCtx,"SatelliteInfo Update[%d/%d]: usedSatellites=%d trackedSatellites=%d visibleSatellites=%d", + i+1, + numElements, + position[i].usedSatellites, + position[i].trackedSatellites, + position[i].visibleSatellites); + + if (usedSatellitesChanged == false) { - sigmaLatitudeChanged = (accuracy[i].validityBits && GNSS_ACCURACY_SLAT_VALID); + usedSatellitesChanged = (position[i].validityBits & GNSS_POSITION_USAT_VALID); } - if (sigmaLongitudeChanged == false) + if (trackedSatellitesChanged == false) { - sigmaLongitudeChanged = (accuracy[i].validityBits && GNSS_ACCURACY_SLON_VALID); + trackedSatellitesChanged = (position[i].validityBits & GNSS_POSITION_TSAT_VALID); } - if (sigmaAltitudeChanged == false) + if (visibleSatellitesChanged == false) { - sigmaAltitudeChanged = (accuracy[i].validityBits && GNSS_ACCURACY_SALT_VALID); + visibleSatellitesChanged = (position[i].validityBits & GNSS_POSITION_VSAT_VALID); } + } //in a real product, the accuracy would be used for dead-reckoning. @@ -526,11 +571,17 @@ void EnhancedPosition::cbAccuracy(const TGNSSAccuracy accuracy[], uint16_t numEl mpSelf->SatelliteInfoUpdate(changedSatelliteInfoValues); - //todo: send other notifications - //mpSelf->AccuracyUpdate(changedAccuracyValues); - //mpSelf->StatusUpdate(changedStatusValues); } +void EnhancedPosition::cbPosition(const TGNSSPosition position[], uint16_t numElements) +{ + sigPositionUpdate(position, numElements); + sigAccuracyUpdate(position, numElements); + sigStatusUpdate(position, numElements); + sigSatelliteInfoUpdate(position, numElements); +} + + void EnhancedPosition::cbSatelliteDetail(const TGNSSSatelliteDetail satelliteDetail[], uint16_t numElements) { if (satelliteDetail == NULL || numElements < 1) @@ -580,7 +631,7 @@ bool EnhancedPosition::checkMajorVersion(int expectedMajor) void EnhancedPosition::run() { - if(!checkMajorVersion(2)) + if(!checkMajorVersion(3)) { exit(EXIT_FAILURE); } @@ -590,28 +641,18 @@ void EnhancedPosition::run() exit(EXIT_FAILURE); } - if(!gnssSimpleInit()) - { - exit(EXIT_FAILURE); - } - LOG_INFO_MSG(gCtx,"Starting EnhancedPosition dispatcher..."); - gnssSimpleRegisterPositionCallback(&cbPosition); - gnssSimpleRegisterCourseCallback(&cbCourse); - gnssExtendedRegisterAccuracyCallback(&cbAccuracy); - gnssExtendedRegisterSatelliteDetailCallback(&cbSatelliteDetail); + gnssRegisterPositionCallback(&cbPosition); + gnssRegisterSatelliteDetailCallback(&cbSatelliteDetail); } void EnhancedPosition::shutdown() { LOG_INFO_MSG(gCtx,"Shutting down EnhancedPosition dispatcher..."); - gnssSimpleDeregisterPositionCallback(&cbPosition); - gnssSimpleDeregisterCourseCallback(&cbCourse); - gnssExtendedDeregisterAccuracyCallback(&cbAccuracy); - gnssExtendedDeregisterSatelliteDetailCallback(&cbSatelliteDetail); - gnssSimpleDestroy(); + gnssDeregisterPositionCallback(&cbPosition); + gnssDeregisterSatelliteDetailCallback(&cbSatelliteDetail); gnssDestroy(); } diff --git a/enhanced-position-service/src/enhanced-position.h b/enhanced-position-service/src/enhanced-position.h index af76a98..eef2b0c 100644 --- a/enhanced-position-service/src/enhanced-position.h +++ b/enhanced-position-service/src/enhanced-position.h @@ -21,9 +21,8 @@ #include <dbus-c++/dbus.h> #include "enhanced-position-adaptor.h" +#include "gnss-init.h" #include "gnss.h" -#include "gnss-simple.h" -#include "gnss-ext.h" class EnhancedPosition : public org::genivi::positioning::EnhancedPosition_adaptor @@ -62,11 +61,14 @@ private: static void cbSatelliteDetail(const TGNSSSatelliteDetail satelliteDetail[], uint16_t numElements); - static void cbAccuracy(const TGNSSAccuracy accuracy[], uint16_t numElements); - - static void cbCourse(const TGNSSCourse course[], uint16_t numElements); - - static void cbPosition(const TGNSSPosition pos[], uint16_t numElements); + static void cbPosition(const TGNSSPosition position[], uint16_t numElements); + static void sigPositionUpdate(const TGNSSPosition position[], uint16_t numElements); + static void sigAccuracyUpdate(const TGNSSPosition position[], uint16_t numElements); + static void sigStatusUpdate(const TGNSSPosition position[], uint16_t numElements); + static void sigSatelliteInfoUpdate(const TGNSSPosition position[], uint16_t numElements); + + + static EnhancedPosition* mpSelf; }; diff --git a/gnss-service/api/gnss-ext.h b/gnss-service/api/gnss-ext.h deleted file mode 100644 index 18439e3..0000000 --- a/gnss-service/api/gnss-ext.h +++ /dev/null @@ -1,488 +0,0 @@ -/************************************************************************** - * @licence app begin@ - * - * SPDX-License-Identifier: MPL-2.0 - * - * \ingroup GNSSService - * \brief Compliance Level: Abstract Component - * \copyright Copyright (C) 2012, BMW Car IT GmbH, Continental Automotive GmbH, PCA Peugeot Citroën, XS Embedded GmbH - * - * \license - * This Source Code Form is subject to the terms of the - * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with - * this file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * @licence end@ - **************************************************************************/ - -#ifndef INCLUDE_GENIVI_GNSS_EXT -#define INCLUDE_GENIVI_GNSS_EXT - -#include "gnss-meta-data.h" -#include <stdint.h> -#include <stdbool.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * 3 dimensional distance used for description of geometric descriptions within the vehicle reference system. - */ -typedef struct { - float x; /**< Distance in x direction in [m] according to the reference coordinate system. */ - float y; /**< Distance in y direction in [m] according to the reference coordinate system. */ - float z; /**< Distance in z direction in [m] according to the reference coordinate system. */ -} TGNSSDistance3D; - -/** - * TGNSSAccuracy::validityBits provides information about the currently valid signals of the GNSS accuracy data. - * It is a or'ed bitmask of the EGNSSAccuracyValidityBits values. - */ -typedef enum { - GNSS_ACCURACY_PDOP_VALID = 0x00000001, /**< Validity bit for field TGNSSAccuracy::pdop. */ - GNSS_ACCURACY_HDOP_VALID = 0x00000002, /**< Validity bit for field TGNSSAccuracy::hdop. */ - GNSS_ACCURACY_VDOP_VALID = 0x00000004, /**< Validity bit for field TGNSSAccuracy::vdop. */ - GNSS_ACCURACY_USAT_VALID = 0x00000008, /**< Validity bit for field TGNSSAccuracy::usedSatellites. */ - GNSS_ACCURACY_TSAT_VALID = 0x00000010, /**< Validity bit for field TGNSSAccuracy::trackedSatellites. */ - GNSS_ACCURACY_VSAT_VALID = 0x00000020, /**< Validity bit for field TGNSSAccuracy::visibleSatellites. */ - GNSS_ACCURACY_SLAT_VALID = 0x00000040, /**< Validity bit for field TGNSSAccuracy::sigmaLatitude. */ - GNSS_ACCURACY_SLON_VALID = 0x00000080, /**< Validity bit for field TGNSSAccuracy::sigmaLongitude. */ - GNSS_ACCURACY_SALT_VALID = 0x00000100, /**< Validity bit for field TGNSSAccuracy::sigmaAltitude. */ - GNSS_ACCURACY_STAT_VALID = 0x00000200, /**< Validity bit for field TGNSSAccuracy::fixStatus. */ - GNSS_ACCURACY_TYPE_VALID = 0x00000400, /**< Validity bit for field TGNSSAccuracy::fixTypeBits. */ -} EGNSSAccuracyValidityBits; - -/** - * Description of the fix status of the GNSS reveiver. - */ -typedef enum { - GNSS_FIX_STATUS_NO, /**< GNSS has no fix, i.e. position, velocity, time cannot be determined */ - GNSS_FIX_STATUS_2D, /**< GNSS has a 2D fix, i.e. the horizontal position can be determined but not the altitude. - This implies that also velocity and time are available. */ - GNSS_FIX_STATUS_3D, /**< GNSS has a 3D fix, i.e. position can be determined including the altitude. - This implies that also velocity and time are available. */ - GNSS_FIX_STATUS_TIME /**< GNSS can only determine the time, but not position and velocity */ -} EGNSSFixStatus; - -/** - * TGNSSAccuracy::fixTypeBits provides GNSS Fix Type indication. - * I.e. it identifies the sources actually used for the GNSS calculation - * It is a or'ed bitmask of the EGNSSFixType values. - * The bit values have been grouped logically with gaps where future extensions can be foreseen - * Within one group, not all combinations make necessarily sense - * Between different groups, all combinations should make sense - */ -typedef enum { - //Information about the used satellite data - GNSS_FIX_TYPE_SINGLE_FREQUENCY = 0x00000001, /**< GNSS satellite data are received on a single frequency. - A typical example is GPS using only the C/A code on the L1 frequency. - It e.g. also applies to a combined GPS(L1)/Galileo(E1) fix since L1 and E1 share the same frequency. */ - GNSS_FIX_TYPE_MULTI_FREQUENCY = 0x00000002, /**< GNSS satellite data are received on a multiple frequencies. - This enables the receiver to correct frequency-dependent errors such as for ionospheric delays. - An example could be a GPS receiver receiving on the L1 and L2C band. */ - GNSS_FIX_TYPE_MULTI_CONSTELLATION = 0x00000004, /**< GNSS satellite data are received and used for the fix from more than one GNSS system. - For example, the fix could be calculated from GPS and GLONASS. - This is also possible for single frequency as several GNSS systems share the same frequencies. */ - //Information of improvement techniques based on the satellite signals - GNSS_FIX_TYPE_PPP = 0x00000010, /**< PPP = Precise Point Positioning - An improved precision is achieved without differential corrections. - This is possible even for single frequency receivers, e.g. by using carrier phase tracking */ - GNSS_FIX_TYPE_INTEGRITY_CHECKED = 0x00000020, /**< Additional integrity checks have been done to ensure the correctness of the fix. */ - //Information about used correction data - GNSS_FIX_TYPE_SBAS = 0x00001000, /**< SBAS = Satellite Based Augmentation System - Correction data from an SBAS system such as WAAS, EGNOS, ... are taken into account */ - GNSS_FIX_TYPE_DGNSS = 0x00002000, /**< DGNSS = Differential GNSS - Correction data from Differential GNSS is taken into account */ - GNSS_FIX_TYPE_RTK_FIXED = 0x00004000, /**< RTK = Real Time Kinematic - Correction data from a RTK fixed solution is taken into account */ - GNSS_FIX_TYPE_RTK_FLOAT = 0x00008000, /**< RTK = Real Time Kinematic - Correction data from a RTK floating solution is taken into account */ - //Information about position propagation - GNSS_FIX_TYPE_ESTIMATED = 0x00100000, /**< The position is propagated without additional sensor input */ - GNSS_FIX_TYPE_DEAD_RECKONING = 0x00200000, /**< The position is propagated supported with additional sensor input */ - //Information to identify artificial GNSS fixes - GNSS_FIX_TYPE_MANUAL = 0x10000000, /**< Position is set by manual input */ - GNSS_FIX_TYPE_SIMULATOR_MODE = 0x20000000, /**< Position is simulated */ -} EGNSSFixType; - -/** - * Accuracy and status information about the GNSS position. - * This data structure provides accuracy information. Either the directly from most GNSS receivers - * available DOP information or if available the error expressed in sigmas for the different axis. - */ -typedef struct { - uint64_t timestamp; /**< Timestamp of the acquisition of the accuracy data. */ - float pdop; /**< The positional (3D) dilution of precision. */ - float hdop; /**< The horizontal (2D) dilution of precision. */ - float vdop; /**< The vertical (altitude) dilution of precision. */ - uint16_t usedSatellites; /**< Number of used satellites. */ - uint16_t trackedSatellites; /**< Number of tracked satellites. */ - uint16_t visibleSatellites; /**< Number of visible satellites. */ - float sigmaLatitude; /**< Standard error estimate of latitude in [m]. */ - float sigmaLongitude; /**< Standard error estimate of longitude in [m]. */ - float sigmaAltitude; /**< Standard error estimate of altitude in [m]. */ - EGNSSFixStatus fixStatus; /**< Value representing the GNSS mode. */ - uint32_t fixTypeBits; /**< Bit mask indicating the sources actually used for the GNSS calculation. - [bitwise or'ed @ref EGNSSFixType values]. */ - uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. - [bitwise or'ed @ref EGNSSAccuracyValidityBits values]. - Must be checked before usage. */ -} TGNSSAccuracy; - -/** - * TGNSSCourse3D::validityBits provides information about the currently valid signals of the GNSS course 3D data. - * It is a or'ed bitmask of the EGNSSCourse3DValidityBits values. - */ -typedef enum { - GNSS_COURSE3D_SPEEDLAT_VALID = 0x00000001, /**< Validity bit for field TGNSSCourse3D::speedLatitude. */ - GNSS_COURSE3D_SPEEDLON_VALID = 0x00000002, /**< Validity bit for field TGNSSCourse3D::speedLongitude. */ - GNSS_COURSE3D_SPEEDALT_VALID = 0x00000004, /**< Validity bit for field TGNSSCourse3D::speedAltitude. */ -} EGNSSCourse3DValidityBits; - -/** - * Course 3D is an extension to the normal course information provided by the GNSS service. - * The course information is given for each axis seperately. - */ -typedef struct { - uint64_t timestamp; /**< Timestamp of the acquisition of the accuracy data. */ - float speedLatitude; /**< Speed in direction of latitude in [m/s]. */ - float speedLongitude; /**< Speed in direction of longitude in [m/s]. */ - float speedAltitude; /**< Speed in direction of altitude in [m/s]. */ - uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. - [bitwise or'ed @ref EGNSSCourse3DValidityBits values]. - Must be checked before usage. */ -} TGNSSCourse3D; - -/** - * Provides the UTC (Coordinated Universal Time) time part. - */ -typedef struct { - uint8_t hour; /**< Hour fraction of the UTC time. Unit: [hour] Number between 0 and 23 */ - uint8_t minute; /**< Minute fraction of the UTC time. Unit: [minutes] Number between 0 and 59 */ - uint8_t second; /**< Second fraction of the UTC time. Unit: [seconds] Number between 0 and 59. - In case of a leap second this value is 60. */ - uint16_t ms; /**< Millisecond fraction of the UTC time. Unit: [milliseconds] Number between 0 and 999 */ - bool valid; /**< Defines the validity of the complete structure. Must be checked before usage. */ -} TUTCTime; - -/** - * Provides the UTC (Coordinated Universal Time) date part. - */ -typedef struct { - uint8_t day; /**< Day fraction of the UTC time. Unit: [day]. Number between 1 and 31 */ - uint8_t month; /**< Month fraction of the UTC time. Unit: [month] Number betweeen 0 and 11 */ - uint16_t year; /**< Year fraction of the UTC time. Unit: [year] Number equivalent to the year */ - bool valid; /**< Defines the validity of the complete structure. Must be checked before usage. */ -} TUTCDate; - -/** - * Enumeration to describe the type of GNSS system to which a particular GNSS satellite belongs. - */ -typedef enum { - GNSS_SYSTEM_GPS = 1, /**< GPS */ - GNSS_SYSTEM_GLONASS = 2, /**< GLONASS */ - GNSS_SYSTEM_GALILEO = 3, /**< GALILEO */ - GNSS_SYSTEM_COMPASS = 4, /**< COMPASS / Bei Du */ - /* Numbers > 100 are used to identify SBAS (satellite based augmentation system) */ - GNSS_SYSTEM_SBAS_WAAS = 101, /**< WASS (North America) */ - GNSS_SYSTEM_SBAS_EGNOS = 102, /**< EGNOS (Europe) */ - GNSS_SYSTEM_SBAS_MSAS = 103, /**< MSAS (Japan) */ - GNSS_SYSTEM_SBAS_QZSS_SAIF = 104, /**< QZSS-SAIF (Japan) */ - GNSS_SYSTEM_SBAS_SDCM = 105, /**< SDCM (Russia) */ - GNSS_SYSTEM_SBAS_GAGAN = 106, /**< GAGAN (India) */ -} EGNSSSystem; - -/** - * TGNSSSatelliteDetail::statusBits provides additional status information about a GNSS satellite. - * It is a or'ed bitmask of the EGNSSSatelliteFlag values. - */ -typedef enum { - GNSS_SATELLITE_USED = 0x00000001, /**< Bit is set when satellite is used for fix. */ - GNSS_SATELLITE_EPHEMERIS_AVAILABLE = 0x00000002, /**< Bit is set when ephemeris is available for this satellite. */ -} EGNSSSatelliteFlag; - -/** - * TGNSSSatelliteDetail::validityBits provides information about the currently valid values of GNSS satellite data. - * It is a or'ed bitmask of the EGNSSSatelliteDetailValidityBits values. - */ -typedef enum { - GNSS_SATELLITE_SYSTEM_VALID = 0x00000001, /**< Validity bit for field TGNSSSatelliteDetail::system. */ - GNSS_SATELLITE_ID_VALID = 0x00000002, /**< Validity bit for field TGNSSSatelliteDetail::satelliteId. */ - GNSS_SATELLITE_AZIMUTH_VALID = 0x00000004, /**< Validity bit for field TGNSSSatelliteDetail::azimuth. */ - GNSS_SATELLITE_ELEVATION_VALIDLID = 0x00000008, /**< Validity bit for field TGNSSSatelliteDetail::elevation. */ - GNSS_SATELLITE_SNR_VALID = 0x00000010, /**< Validity bit for field TGNSSSatelliteDetail::SNR. */ - GNSS_SATELLITE_USED_VALID = 0x00000020, /**< Validity bit for field TGNSSSatelliteDetail::statusBits::GNSS_SATELLITE_USED. */ - GNSS_SATELLITE_EPHEMERIS_AVAILABLE_VALID = 0x00000040, /**< Validity bit for field TGNSSSatelliteDetail::statusBits::GNSS_SATELLITE_EPHEMERIS_AVAILABLE. */ -} EGNSSSatelliteDetailValidityBits; - -/** - * Detailed data from one GNSS satellite. - */ -typedef struct { - uint64_t timestamp; /**< Timestamp of the acquisition of the satellite detail data. */ - EGNSSSystem system; /**< Value representing the GNSS system. */ - uint16_t satelliteId; /**< Satellite ID. See also https://collab.genivi.org/issues/browse/GT-2299 - Numbering scheme as defined by NMEA-0183 (v3.01 or later) for the GSV sentence - 1..32: GPS satellites (by PRN) - 33..64: SBAS/WAAS satellites - 65..96: GLONASS satellites - Note: Later NMEA-0183 versions probably already have Galileo support - */ - uint16_t azimuth; /**< Satellite Azimuth in degrees. Value range 0..359 */ - uint16_t elevation; /**< Satellite Elevation in degrees. Value range 0..90 */ - uint16_t SNR; /**< SNR (C/No) in dBHz. Range 0 to 99, null when not tracking */ - uint32_t statusBits; /**< Bit mask of additional status flags. - [bitwise or'ed @ref EGNSSSatelliteFlag values]. */ - uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. - [bitwise or'ed @ref EGNSSSatelliteDetailValidityBits values]. - Must be checked before usage. */ -} TGNSSSatelliteDetail; - -/** - * Callback type for extended GNSS accuracy. - * Use this type of callback if you want to register for extended GNSS accuracy data. - * This callback may return buffered data (numElements >1) for different reasons - * for (large) portions of data buffered at startup - * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) - * If the array contains (numElements >1), the elements will be ordered with rising timestamps - * @param accuracy pointer to an array of TGNSSAccuracy with size numElements - * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. - */ -typedef void (*GNSSAccuracyCallback)(const TGNSSAccuracy accuracy[], uint16_t numElements); - -/** - * Callback type for extended GNSS 3D course. - * Use this type of callback if you want to register for extended GNSS 3D course data. - * This callback may return buffered data (numElements >1) for different reasons - * for (large) portions of data buffered at startup - * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) - * If the array contains (numElements >1), the elements will be ordered with rising timestamps - * @param course pointer to an array of TGNSSCourse3D with size numElements - * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. - */ -typedef void (*GNSSCourse3DCallback)(const TGNSSCourse3D course[], uint16_t numElements); - -/** - * Callback type for extended GNSS UTC time. - * Use this type of callback if you want to register for extended GNSS UTC time data. - * This callback may return buffered data (numElements >1) for different reasons - * for (large) portions of data buffered at startup - * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) - * If the array contains (numElements >1), the elements will be ordered with rising timestamps - * @param time pointer to an array of TUTCTime with size numElements - * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. - */ -typedef void (*GNSSUTCTimeCallback)(const TUTCTime time[], uint16_t numElements); - -/** - * Callback type for extended GNSS UTC date. - * Use this type of callback if you want to register for extended - * GNSS UTC date and the GNSS UTC time data. - * This callback may return buffered data (numElements >1) for different reasons - * for (large) portions of data buffered at startup - * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) - * If the array contains (numElements >1), the elements will be ordered with rising timestamps - * @param date pointer to an array of TUTCDate with size numElements - * @param time pointer to an array of TUTCTime with size numElements - * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. - */ -typedef void (*GNSSUTCDateCallback)(const TUTCDate date[], const TUTCTime time[], uint16_t numElements); - -/** - * Callback type for GNSS satellite details. - * Use this type of callback if you want to register for GNSS satellite detail data. - * This callback may return buffered data (numElements >1) for different reasons - * for (large) portions of data buffered at startup - * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) - * If the array contains (numElements >1), the elements will be ordered with rising timestamps - * @param time pointer to an array of TGNSSSatelliteDetail with size numElements - * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. - */ -typedef void (*GNSSSatelliteDetailCallback)(const TGNSSSatelliteDetail satelliteDetail[], uint16_t numElements); - -/** - * Initialization of the extended GNSS service. - * Must be called before using the extended GNSS service to set up the service. - * @return True if initialization has been successfull. - */ -bool gnssExtendedInit(); - -/** - * Destroy the extended GNSS service. - * Must be called after using the extended GNSS service to shut down the service. - * @return True if shutdown has been successfull. - */ -bool gnssExtendedDestroy(); - -/** - * Provide meta information about extended GNSS service. - * The meta data of a service provides information about it's name, version, type, subtype, sampling frequency etc. - * @param data Meta data content about the sensor service. - * @return True if meta data is available. - */ -bool gnssExtendedGetMetaData(TGnssMetaData *data); - -/** - * Accessing static configuration information about the antenna position. - * @param distance After calling the method the currently available antenna configuration data is written into this parameter. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - * - * Static configuration data for the extended GNSS service. - * The reference point mentioned in the vehicle configuration lies underneath the center of the rear axle on the surface of the road. - * The reference coordinate system is the car reference system as provided in the documentation. - * See https://collab.genivi.org/wiki/display/genivi/LBSSensorServiceRequirementsBorg#LBSSensorServiceRequirementsBorg-ReferenceSystem - */ -bool gnssExtendedGetAntennaPosition(TGNSSDistance3D *distance); - -/** - * Method to get the accuracy data at a specific point in time. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param accuracy After calling the method the currently available GNSS accuracy data is written into this parameter. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssExtendedGetAccuracy(TGNSSAccuracy *accuracy); - -/** - * Register GNSS accuracy callback. - * This is the recommended method for continuously accessing the accuracy data. - * The callback will be invoked when new accuracy data is available from the GNSS receiver. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param callback The callback which should be registered. - * @return True if callback has been registered successfully. - */ -bool gnssExtendedRegisterAccuracyCallback(GNSSAccuracyCallback callback); - -/** - * Deregister extended GNSS accuracy callback. - * After calling this method no new GNSS accuracy data will be delivered to the client. - * @param callback The callback which should be deregistered. - * @return True if callback has been deregistered successfully. - */ -bool gnssExtendedDeregisterAccuracyCallback(GNSSAccuracyCallback callback); - -/** - * Method to get the extended 3D course data at a specific point in time. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param course After calling the method the currently available GNSS 3D course data is written into this parameter. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssExtendedGet3DCourse(TGNSSCourse3D *course); - -/** - * Register extended GNSS 3D course callback. - * This is the recommended method for continuously accessing the 3D course data. - * The callback will be invoked when new course data is available from the GNSS receiver. - * It is intended to extend the GNSS course information by data split into each axis. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param callback The callback which should be registered. - * @return True if callback has been registered successfully. - */ -bool gnssExtendedRegister3DCourseCallback(GNSSCourse3DCallback callback); - -/** - * Deregister extended GNSS 3D course callback. - * After calling this method no new GNSS 3D course data will be delivered to the client. - * @param callback The callback which should be deregistered. - * @return True if callback has been deregistered successfully. - */ -bool gnssExtendedDeregister3DCourseCallback(GNSSCourse3DCallback callback); - -/** - * Method to get the UTC Time data of the GNSS receiver at a specific point in time. - * The valid flag is updated. The data is only guaranteed to be updated when the valid flag is true. - * @param time After calling the method the current GNSS UTC time is written into this parameter. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssExtendedGetUTCTime(TUTCTime *time); - -/** - * Register extended GNSS UTC time callback. - * The callback will be invoked when new time data is available from the GNSS receiver. - * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true. - * @param callback The callback which should be registered. - * @return True if callback has been registered successfully. - */ -bool gnssExtendedRegisterUTCTimeCallback(GNSSUTCTimeCallback callback); - -/** - * Deregister extended GNSS UTC time callback. - * After calling this method no new time will be delivered to the client. - * @param callback The callback which should be deregistered. - * @return True if callback has been deregistered successfully. - */ -bool gnssExtendedDeregisterUTCTimeCallback(GNSSUTCTimeCallback callback); - -/** - * Method to get the UTC date of the GNSS receiver at a specific point in time. - * The valid flag is updated. The data is only guaranteed to be updated when the valid flag is true. - * @param date After calling the method the current GNSS UTC date is written into this parameter. - * @param time After calling the method the current GNSS UTC time is written into this parameter. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssExtendedGetUTCDate(TUTCDate *date, TUTCTime *time); - -/** - * Register extended GNSS UTC date callback. - * The callback will be invoked when new date data is available from the GNSS receiver. - * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true. - * @param callback The callback which should be registered. - * @return True if callback has been registered successfully. - */ -bool gnssExtendedRegisterUTCDateCallback(GNSSUTCDateCallback callback); - -/** - * Deregister extended GNSS UTC date callback. - * After calling this method no new date will be delivered to the client. - * @param callback The callback which should be deregistered. - * @return True if callback has been deregistered successfully. - */ -bool gnssExtendedDeregisterUTCDateCallback(GNSSUTCDateCallback callback); - -/** - * Method to get the GNSS satellite details at a specific point in time. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flag is true. - * @param satelliteDetails After calling the method current GNSS satellite details are written into this array with size count. - * @param count Number of elements of the array *satelliteDetails. This should be at least TGnssMetaData::numChannels. - * @param numSatelliteDetails Number of elements written to the array *satelliteDetails. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssExtendedGetSatelliteDetails(TGNSSSatelliteDetail* satelliteDetails, uint16_t count, uint16_t* numSatelliteDetails); - -/** - * Register GNSS satellite detail callback. - * The callback will be invoked when new date data is available from the GNSS receiver. - * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true. - * @param callback The callback which should be registered. - * @return True if callback has been registered successfully. - */ -bool gnssExtendedRegisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback); - -/** - * Deregister GNSS satellite detail callback. - * After calling this method no new data will be delivered to the client. - * @param callback The callback which should be deregistered. - * @return True if callback has been deregistered successfully. - */ -bool gnssExtendedDeregisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback); - -/** - * Provides the precision timing information as signaled by the GNSS PPS signal. - * For accurate timing the 1 PPS (pulse per second) signal from the GNSS receiver is used within the positioning framework. - * The PPS is a hardware signal which is a UTC synchronized pulse. - * The duration between the pulses is 1s +/- 40ns and the duration of the pulse is configurable (about 100-200ms). - * The PPS signal can be provided in the positioning framework as an interrupt service routine and this method provides the access - * to the delta from UTC to system time. - * If you really need precision timing you have to have the system time set within a range of +/-2s of UTC. - * @param delta The result is provided in this parameter in nanoseconds. It gives the deviation of the system time (+/-) in respect to the PPS pulse and UTC. - * If the deviation is is greater than a value that can be represented with 32 Bits (i.e. more or less than about 2s) the - * maximum values are written to this parameter and the return value will be false. - * @return True if the precision timing is available and fits in the range which can be represented by the delta parameter. - */ -bool gnssExtendedGetPrecisionTimingOffset(int32_t *delta); - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDE_GENIVI_SNS_GNSS_EXT */ diff --git a/gnss-service/api/gnss-init.h b/gnss-service/api/gnss-init.h new file mode 100644 index 0000000..ee1765c --- /dev/null +++ b/gnss-service/api/gnss-init.h @@ -0,0 +1,62 @@ +/************************************************************************** + * @licence app begin@ + * + * SPDX-License-Identifier: MPL-2.0 + * + * \ingroup GNSSService + * \brief Compliance Level: Abstract Component + * \copyright Copyright (C) 2012, BMW Car IT GmbH, Continental Automotive GmbH, PCA Peugeot Citroën, XS Embedded GmbH + * + * \license + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * @licence end@ + **************************************************************************/ + +#ifndef INCLUDE_GENIVI_GNSS +#define INCLUDE_GENIVI_GNSS + +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +// API Version +#define GENIVI_GNSS_API_MAJOR 3 +#define GENIVI_GNSS_API_MINOR 0 +#define GENIVI_GNSS_API_MICRO 0 + +/** + * Initialization of the GNSS service. + * Must be called before using the GNSS service to set up the service. + * @return True if initialization has been successfull. + */ +bool gnssInit(); + +/** + * Destroy the GNSS service. + * Must be called after using the GNSS service to shut down the service. + * @return True if shutdown has been successfull. + */ +bool gnssDestroy(); + +/** + * GNSS services version information. + * This information is for the GNSS services system structure. + * The version information for each specific GNSS component can be obtained via the metadata. + * @param major Major version number. Changes in this number are used for incompatible API change. + * @param minor Minor version number. Changes in this number are used for compatible API change. + * @param micro Micro version number. Changes in this number are used for minor changes. + */ +void gnssGetVersion(int *major, int *minor, int *micro); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/gnss-service/api/gnss-meta-data.h b/gnss-service/api/gnss-meta-data.h index b1a57e2..e2eebd7 100644 --- a/gnss-service/api/gnss-meta-data.h +++ b/gnss-service/api/gnss-meta-data.h @@ -62,12 +62,12 @@ typedef struct { } TGnssMetaData; /** - * Retrieve the metadata of all available GNSS sensors. - * @param returns a a pointer an array of TGnssMetaData (maybe NULL if no metadata is available) - * @return number of elements in the array of TGnssMetaData + * Provide meta information about GNSS service. + * The meta data of a service provides information about it's name, version, type, subtype, sampling frequency etc. + * @param data Meta data content about the sensor service. + * @return True if meta data is available. */ -int32_t getGnssMetaDataList(const TGnssMetaData** metadata); - +bool gnssGetMetaData(TGnssMetaData *data); #ifdef __cplusplus } diff --git a/gnss-service/api/gnss-simple.h b/gnss-service/api/gnss-simple.h deleted file mode 100644 index c82d250..0000000 --- a/gnss-service/api/gnss-simple.h +++ /dev/null @@ -1,211 +0,0 @@ -/************************************************************************** - * @licence app begin@ - * - * SPDX-License-Identifier: MPL-2.0 - * - * \ingroup GNSSService - * \brief Compliance Level: Abstract Component - * \copyright Copyright (C) 2012, BMW Car IT GmbH, Continental Automotive GmbH, PCA Peugeot Citroën, XS Embedded GmbH - * - * \license - * This Source Code Form is subject to the terms of the - * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with - * this file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * @licence end@ - **************************************************************************/ - -#ifndef INCLUDE_GENIVI_GNSS_SIMPLE -#define INCLUDE_GENIVI_GNSS_SIMPLE - -#include "gnss-meta-data.h" -#include <stdint.h> -#include <stdbool.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Reference level for the GNSS altitude. - */ -typedef enum { - GNSS_ALTITUDE_UNKNOWN = 0, /**< Reference level is unknown. */ - GNSS_ALTITUDE_ELLIPSOIDE = 1, /**< Reference level is the WGS-84 ellopsoid. */ - GNSS_ALTITUDE_ABOVE_MEAN_SEA_LEVEL = 2 /**< Reference level is the geoid (mean sea level). */ -} EGNSSAltitudeType; - -/** - * TGNSSSimpleConfiguration::validityBits provides information about the currently valid values of GNSS configuration data. - * It is a or'ed bitmask of the EGNSSSimpleConfigurationValidityBits values. - */ -typedef enum { - GNSS_SIMPLE_CONFIG_ALTITUDE_TYPE_VALID = 0x00000001 /**< Validity bit for field TGNSSSimpleConfiguration::typeOfAltitude. */ -} EGNSSSimpleConfigurationValidityBits; - -/** - * GNSS Simple Configuration Data. - */ -typedef struct { - EGNSSAltitudeType altitudeType; /**< Reference level for the GNSS altitude. */ - uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. - [bitwise or'ed @ref EGNSSSimpleConfigurationValidityBits values]. - Must be checked before usage. */ -} TGNSSSimpleConfiguration; - -/** - * TGNSSPosition::validityBits provides information about the currently valid signals of the GNSS position data. - * It is a or'ed bitmask of the EGNSSPositionValidityBits values. - */ -typedef enum { - GNSS_POSITION_LATITUDE_VALID = 0x00000001, /**< Validity bit for field TGNSSPosition::latitude. */ - GNSS_POSITION_LONGITUDE_VALID = 0x00000002, /**< Validity bit for field TGNSSPosition::longitude. */ - GNSS_POSITION_ALTITUDE_VALID = 0x00000004, /**< Validity bit for field TGNSSPosition::altitude. */ -} EGNSSPositionValidityBits; - -/** - * Main position information. - */ -typedef struct { - uint64_t timestamp; /**< Timestamp of the acquisition of the position data. [ms] */ - double latitude; /**< Latitude in WGS84 in degrees. */ - double longitude; /**< Longitude in WGS84 in degrees. */ - float altitude; /**< Altitude in [m]. See TGNSSSimpleConfiguration.typeOfAltitude for reference level (ellipsoid or MSL). */ - uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. - [bitwise or'ed @ref EGNSSPositionValidityBits values]. - Must be checked before usage. */ -} TGNSSPosition; - -/** - * TGNSSCourse::validityBits provides information about the currently valid signals of the GNSS course data. - * It is a or'ed bitmask of the EGNSSCourseValidityBits values. - */ -typedef enum { - GNSS_COURSE_SPEED_VALID = 0x00000001, /**< Validity bit for field TGNSSCourse::speed. */ - GNSS_COURSE_CLIMB_VALID = 0x00000002, /**< Validity bit for field TGNSSCourse::climb. */ - GNSS_COURSE_HEADING_VALID = 0x00000004, /**< Validity bit for field TGNSSCourse::heading. */ -} EGNSSCourseValidityBits; - -/** - * GNSS course provides information about the currently course of the receiver. - * There is an extended service providing the speed for each axis seperately in GNSS-Extended. - */ -typedef struct { - uint64_t timestamp; /**< Timestamp of the acquisition of the GNSS course signal in [ms]. - To enable an accurate DR filtering a defined clock has to be used. */ - float speed; /**< Speed measured by the GPS receiver [m/s]. */ - float climb; /**< Incline / decline in degrees [degree]. */ - float heading; /**< GNSS course angle [degree] (0 => north, 90 => east, 180 => south, 270 => west, no negative values). */ - uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. - [bitwise or'ed @ref EGNSSCourseValidityBits values]. - Must be checked before usage. */ -} TGNSSCourse; - -/** - * Callback type for GNSS position. - * Use this type of callback if you want to register for GNSS position data. - * This callback may return buffered data (numElements >1) for different reasons - * for (large) portions of data buffered at startup - * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) - * If the array contains (numElements >1), the elements will be ordered with rising timestamps - * @param pos pointer to an array of TGNSSPosition with size numElements - * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. - */ -typedef void (*GNSSPositionCallback)(const TGNSSPosition pos[], uint16_t numElements); - -/** - * Callback type for GNSS course. - * Use this type of callback if you want to register for GNSS course data. - * This callback may return buffered data (numElements >1) for different reasons - * for (large) portions of data buffered at startup - * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) - * If the array contains (numElements >1), the elements will be ordered with rising timestamps - * @param course pointer to an array of TGNSSCourse with size numElements - * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. - */ -typedef void (*GNSSCourseCallback)(const TGNSSCourse course[], uint16_t numElements); - -/** - * Initialization of the GNSS service. - * Must be called before using the GNSS service to set up the service. - * @return True if initialization has been successfull. - */ -bool gnssSimpleInit(); - -/** - * Destroy the GNSS service. - * Must be called after using the GNSS service to shut down the service. - * @return True if shutdown has been successfull. - */ -bool gnssSimpleDestroy(); - -/** - * Accessing static configuration information about the GNSS sensor. - * @param gnssConfig After calling the method the currently available GNSS configuration data is written into gnssConfig. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssSimpleGetConfiguration(TGNSSSimpleConfiguration* gnssConfig); - -/** - * Provide meta information about GNSS service. - * The meta data of a service provides information about it's name, version, type, subtype, sampling frequency etc. - * @param data Meta data content about the sensor service. - * @return True if meta data is available. - */ -bool gnssSimpleGetMetaData(TGnssMetaData *data); - -/** - * Method to get the GNSS position data at a specific point in time. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param pos After calling the method the currently available position data is written into this parameter. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssSimpleGetPosition(TGNSSPosition* pos); - -/** - * Register GNSS position callback. - * The callback will be invoked when new position data is available from the GNSS receiver. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param callback The callback which should be registered. - * @return True if callback has been registered successfully. - */ -bool gnssSimpleRegisterPositionCallback(GNSSPositionCallback callback); - -/** - * Deregister GNSS Position callback. - * After calling this method no new GNSS position data will be delivered to the client. - * @param callback The callback which should be deregistered. - * @return True if callback has been deregistered successfully. - */ -bool gnssSimpleDeregisterPositionCallback(GNSSPositionCallback callback); - -/** - * Method to get the GNSS course data at a specific point in time. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param course After calling the method the currently available position data is written into this parameter. - * @return Is true if data can be provided and false otherwise, e.g. missing initialization - */ -bool gnssSimpleGetCourse(TGNSSCourse* course); - -/** - * Register GNSS course callback. - * The callback will be invoked when new course data is available from the GNSS receiver. - * All valid flags are updated. The data is only guaranteed to be updated when the valid flags are true. - * @param callback The callback which should be registered. - * @return True if callback has been registered successfully. - */ -bool gnssSimpleRegisterCourseCallback(GNSSCourseCallback callback); - -/** - * Deregister GNSS course callback. - * After calling this method no new GNSS course data will be delivered to the client. - * @param callback The callback which should be deregistered. - * @return True if callback has been deregistered successfully. - */ -bool gnssSimpleDeregisterCourseCallback(GNSSCourseCallback callback); - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDE_GENIVI_GNSS_SIMPLE */ diff --git a/gnss-service/api/gnss.h b/gnss-service/api/gnss.h index d42d3f2..7427958 100644 --- a/gnss-service/api/gnss.h +++ b/gnss-service/api/gnss.h @@ -15,48 +15,391 @@ * @licence end@ **************************************************************************/ -#ifndef INCLUDE_GENIVI_GNSS -#define INCLUDE_GENIVI_GNSS +#ifndef INCLUDE_GENIVI_GNSS_EXT +#define INCLUDE_GENIVI_GNSS_EXT +#include "gnss-meta-data.h" +#include <stdint.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif +/** + * 3 dimensional distance used for description of geometric descriptions within the vehicle reference system. + */ +typedef struct { + float x; /**< Distance in x direction in [m] according to the reference coordinate system. */ + float y; /**< Distance in y direction in [m] according to the reference coordinate system. */ + float z; /**< Distance in z direction in [m] according to the reference coordinate system. */ +} TGNSSDistance3D; + +/** + * Description of the fix status of the GNSS reveiver. + */ +typedef enum { + GNSS_FIX_STATUS_NO, /**< GNSS has no fix, i.e. position, velocity, time cannot be determined */ + GNSS_FIX_STATUS_TIME, /**< GNSS can only determine the time, but not position and velocity */ + GNSS_FIX_STATUS_2D, /**< GNSS has a 2D fix, i.e. the horizontal position can be determined but not the altitude. + This implies that also velocity and time are available. */ + GNSS_FIX_STATUS_3D /**< GNSS has a 3D fix, i.e. position can be determined including the altitude. + This implies that also velocity and time are available. */ +} EGNSSFixStatus; + +/** + * TGNSSAccuracy::fixTypeBits provides GNSS Fix Type indication. + * I.e. it identifies the sources actually used for the GNSS calculation + * It is a or'ed bitmask of the EGNSSFixType values. + * The bit values have been grouped logically with gaps where future extensions can be foreseen + * Within one group, not all combinations make necessarily sense + * Between different groups, all combinations should make sense + */ +typedef enum { + //Information about the used satellite data + GNSS_FIX_TYPE_SINGLE_FREQUENCY = 0x00000001, /**< GNSS satellite data are received on a single frequency. + A typical example is GPS using only the C/A code on the L1 frequency. + It e.g. also applies to a combined GPS(L1)/Galileo(E1) fix since L1 and E1 share the same frequency. */ + GNSS_FIX_TYPE_MULTI_FREQUENCY = 0x00000002, /**< GNSS satellite data are received on a multiple frequencies. + This enables the receiver to correct frequency-dependent errors such as for ionospheric delays. + An example could be a GPS receiver receiving on the L1 and L2C band. */ + GNSS_FIX_TYPE_MULTI_CONSTELLATION = 0x00000004, /**< GNSS satellite data are received and used for the fix from more than one GNSS system. + For example, the fix could be calculated from GPS and GLONASS. + This is also possible for single frequency as several GNSS systems share the same frequencies. */ + //Information of improvement techniques based on the satellite signals + GNSS_FIX_TYPE_PPP = 0x00000010, /**< PPP = Precise Point Positioning + An improved precision is achieved without differential corrections. + This is possible even for single frequency receivers, e.g. by using carrier phase tracking */ + GNSS_FIX_TYPE_INTEGRITY_CHECKED = 0x00000020, /**< Additional integrity checks have been done to ensure the correctness of the fix. */ + //Information about used correction data + GNSS_FIX_TYPE_SBAS = 0x00001000, /**< SBAS = Satellite Based Augmentation System + Correction data from an SBAS system such as WAAS, EGNOS, ... are taken into account */ + GNSS_FIX_TYPE_DGNSS = 0x00002000, /**< DGNSS = Differential GNSS + Correction data from Differential GNSS is taken into account */ + GNSS_FIX_TYPE_RTK_FIXED = 0x00004000, /**< RTK = Real Time Kinematic + Correction data from a RTK fixed solution is taken into account */ + GNSS_FIX_TYPE_RTK_FLOAT = 0x00008000, /**< RTK = Real Time Kinematic + Correction data from a RTK floating solution is taken into account */ + //Information about position propagation + GNSS_FIX_TYPE_ESTIMATED = 0x00100000, /**< The position is propagated without additional sensor input */ + GNSS_FIX_TYPE_DEAD_RECKONING = 0x00200000, /**< The position is propagated supported with additional sensor input */ + //Information to identify artificial GNSS fixes + GNSS_FIX_TYPE_MANUAL = 0x10000000, /**< Position is set by manual input */ + GNSS_FIX_TYPE_SIMULATOR_MODE = 0x20000000, /**< Position is simulated */ +} EGNSSFixType; + +/** + * TGNSSTime::validityBits provides information about the currently valid parts of UTC date/time. + * It is a or'ed bitmask of the EGNSSUTCValidityBits values. + * There are separate validity bits for date end time since a GPS receiver may be able to provide time earlier than date. + */ +typedef enum { + GNSS_TIME_TIME_VALID = 0x00000001, /**< Validity bit for field TGNSSTime fields hour, minute, second, ms. */ + GNSS_TIME_DATE_VALID = 0x00000002, /**< Validity bit for field TGNSSTime fields year, month, day. */ +} EGNSSTimeValidityBits; -// API Version -#define GENIVI_GNSS_API_MAJOR 2 -#define GENIVI_GNSS_API_MINOR 0 -#define GENIVI_GNSS_API_MICRO 0 +/** + * Provides the current date and time according UTC (Coordinated Universal Time) + * Note: the uncommon numbering of day and month is chosen to be compatible with the struct tm from the standard C-Library + */ +typedef struct { + uint64_t timestamp; /**< Timestamp of the acquisition of the UTC date/time. */ + uint16_t year; /**< Year fraction of the UTC time. Unit: [year] Number equivalent to the year (4 digits) */ + uint8_t month; /**< Month fraction of the UTC time. Unit: [month] Number betweeen 0 and 11 */ + uint8_t day; /**< Day of month fraction of the UTC time. Unit: [day]. Number between 1 and 31 */ + uint8_t hour; /**< Hour fraction of the UTC time. Unit: [hour] Number between 0 and 23 */ + uint8_t minute; /**< Minute fraction of the UTC time. Unit: [minutes] Number between 0 and 59 */ + uint8_t second; /**< Second fraction of the UTC time. Unit: [seconds] Number between 0 and 59. + In case of a leap second this value is 60. */ + uint16_t ms; /**< Millisecond fraction of the UTC time. Unit: [milliseconds] Number between 0 and 999 */ + uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. + [bitwise or'ed @ref EGNSSTimeValidityBits values]. + Must be checked before usage. */ +} TGNSSTime; /** - * Initialization of the GNSS service. - * Must be called before using the GNSS service to set up the service. - * @return True if initialization has been successfull. + * Enumeration to describe the type of GNSS system to which a particular GNSS satellite belongs. */ -bool gnssInit(); +typedef enum { + GNSS_SYSTEM_GPS = 1, /**< GPS */ + GNSS_SYSTEM_GLONASS = 2, /**< GLONASS */ + GNSS_SYSTEM_GALILEO = 3, /**< GALILEO */ + GNSS_SYSTEM_COMPASS = 4, /**< COMPASS / Bei Du */ + /* Numbers > 100 are used to identify SBAS (satellite based augmentation system) */ + GNSS_SYSTEM_SBAS_WAAS = 101, /**< WASS (North America) */ + GNSS_SYSTEM_SBAS_EGNOS = 102, /**< EGNOS (Europe) */ + GNSS_SYSTEM_SBAS_MSAS = 103, /**< MSAS (Japan) */ + GNSS_SYSTEM_SBAS_QZSS_SAIF = 104, /**< QZSS-SAIF (Japan) */ + GNSS_SYSTEM_SBAS_SDCM = 105, /**< SDCM (Russia) */ + GNSS_SYSTEM_SBAS_GAGAN = 106, /**< GAGAN (India) */ +} EGNSSSystem; /** - * Destroy the GNSS service. - * Must be called after using the GNSS service to shut down the service. - * @return True if shutdown has been successfull. + * TGNSSSatelliteDetail::statusBits provides additional status information about a GNSS satellite. + * It is a or'ed bitmask of the EGNSSSatelliteFlag values. */ -bool gnssDestroy(); +typedef enum { + GNSS_SATELLITE_USED = 0x00000001, /**< Bit is set when satellite is used for fix. */ + GNSS_SATELLITE_EPHEMERIS_AVAILABLE = 0x00000002, /**< Bit is set when ephemeris is available for this satellite. */ +} EGNSSSatelliteFlag; /** - * GNSS services version information. - * This information is for the GNSS services system structure. - * The version information for each specific GNSS component can be obtained via the metadata. - * @param major Major version number. Changes in this number are used for incompatible API change. - * @param minor Minor version number. Changes in this number are used for compatible API change. - * @param micro Micro version number. Changes in this number are used for minor changes. + * TGNSSSatelliteDetail::validityBits provides information about the currently valid values of GNSS satellite data. + * It is a or'ed bitmask of the EGNSSSatelliteDetailValidityBits values. */ -void gnssGetVersion(int *major, int *minor, int *micro); +typedef enum { + GNSS_SATELLITE_SYSTEM_VALID = 0x00000001, /**< Validity bit for field TGNSSSatelliteDetail::system. */ + GNSS_SATELLITE_ID_VALID = 0x00000002, /**< Validity bit for field TGNSSSatelliteDetail::satelliteId. */ + GNSS_SATELLITE_AZIMUTH_VALID = 0x00000004, /**< Validity bit for field TGNSSSatelliteDetail::azimuth. */ + GNSS_SATELLITE_ELEVATION_VALID = 0x00000008, /**< Validity bit for field TGNSSSatelliteDetail::elevation. */ + GNSS_SATELLITE_SNR_VALID = 0x00000010, /**< Validity bit for field TGNSSSatelliteDetail::SNR. */ + GNSS_SATELLITE_USED_VALID = 0x00000020, /**< Validity bit for field TGNSSSatelliteDetail::statusBits::GNSS_SATELLITE_USED. */ + GNSS_SATELLITE_EPHEMERIS_AVAILABLE_VALID = 0x00000040, /**< Validity bit for field TGNSSSatelliteDetail::statusBits::GNSS_SATELLITE_EPHEMERIS_AVAILABLE. */ + GNSS_SATELLITE_RESIDUAL_VALID = 0x00000080, /**< Validity bit for field TGNSSSatelliteDetail::posResidual. */ +} EGNSSSatelliteDetailValidityBits; +/** + * Detailed data from one GNSS satellite. + */ +typedef struct { + uint64_t timestamp; /**< Timestamp of the acquisition of the satellite detail data. */ + EGNSSSystem system; /**< Value representing the GNSS system. */ + uint16_t satelliteId; /**< Satellite ID. See also https://collab.genivi.org/issues/browse/GT-2299 + Numbering scheme as defined by NMEA-0183 (v3.01 or later) for the GSV sentence + 1..32: GPS satellites (by PRN) + 33..64: SBAS/WAAS satellites + 65..96: GLONASS satellites + Note: Later NMEA-0183 versions probably already have Galileo support + */ + uint16_t azimuth; /**< Satellite Azimuth in degrees. Value range 0..359 */ + uint16_t elevation; /**< Satellite Elevation in degrees. Value range 0..90 */ + uint16_t SNR; /**< SNR (C/No) in dBHz. Range 0 to 99, null when not tracking */ + uint32_t statusBits; /**< Bit mask of additional status flags. + [bitwise or'ed @ref EGNSSSatelliteFlag values]. */ + int16_t posResidual; /**< Residual in m of position calculation. Range -999 to +999, 0 if not tracking */ + uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. + [bitwise or'ed @ref EGNSSSatelliteDetailValidityBits values]. + Must be checked before usage. */ +} TGNSSSatelliteDetail; + +/** + * TGNSSPosition::validityBits provides information about the currently valid signals + * of the GNSS position and velocity including status and accuracy data. + * It is a or'ed bitmask of the EGNSSPositionValidityBits values. + */ +typedef enum { + //position + GNSS_POSITION_LATITUDE_VALID = 0x00000001, /**< Validity bit for field TGNSSPosition::latitude. */ + GNSS_POSITION_LONGITUDE_VALID = 0x00000002, /**< Validity bit for field TGNSSPosition::longitude. */ + GNSS_POSITION_ALTITUDEMSL_VALID = 0x00000004, /**< Validity bit for field TGNSSPosition::altitudeMSL. */ + GNSS_POSITION_ALTITUDEELL_VALID = 0x00000008, /**< Validity bit for field TGNSSPosition::altitudeEll. */ + //velocity + GNSS_POSITION_HSPEED_VALID = 0x00000010, /**< Validity bit for field TGNSSPosition::hSpeed. */ + GNSS_POSITION_VSPEED_VALID = 0x00000020, /**< Validity bit for field TGNSSPosition::vSpeed. */ + GNSS_POSITION_HEADING_VALID = 0x00000040, /**< Validity bit for field TGNSSPosition::heading. */ + //quality parameters: satellite constellation + GNSS_POSITION_PDOP_VALID = 0x00000080, /**< Validity bit for field TGNSSPosition::pdop. */ + GNSS_POSITION_HDOP_VALID = 0x00000100, /**< Validity bit for field TGNSSPosition::hdop. */ + GNSS_POSITION_VDOP_VALID = 0x00000200, /**< Validity bit for field TGNSSPosition::vdop. */ + + GNSS_POSITION_USAT_VALID = 0x00000400, /**< Validity bit for field TGNSSPosition::usedSatellites. */ + GNSS_POSITION_TSAT_VALID = 0x00000800, /**< Validity bit for field TGNSSPosition::trackedSatellites. */ + GNSS_POSITION_VSAT_VALID = 0x00001000, /**< Validity bit for field TGNSSPosition::visibleSatellites. */ + //quality parameters: error estimates + GNSS_POSITION_SHPOS_VALID = 0x00002000, /**< Validity bit for field TGNSSPosition::sigmaHPosition. */ + GNSS_POSITION_SALT_VALID = 0x00004000, /**< Validity bit for field TGNSSPosition::sigmaAltitude. */ + GNSS_POSITION_SHSPEED_VALID = 0x00008000, /**< Validity bit for field TGNSSPosition::sigmaHSpeed. */ + GNSS_POSITION_SVSPEED_VALID = 0x00010000, /**< Validity bit for field TGNSSPosition::sigmaVSpeed. */ + GNSS_POSITION_SHEADING_VALID = 0x00020000, /**< Validity bit for field TGNSSPosition::sigmaHeading. */ + //quality parameters: overall GNSS fix status + GNSS_POSITION_STAT_VALID = 0x00040000, /**< Validity bit for field TGNSSPosition::fixStatus. */ + GNSS_POSITION_TYPE_VALID = 0x00080000, /**< Validity bit for field TGNSSPosition::fixTypeBits. */ +} EGNSSPositionValidityBits; + +/** + * GNSS position data including velocity, status and accuracy. + * This data structure provides all GNSS information which is typically needed + * for positioning applications such as GNSS/Dead Reckoning sensor fusion. + */ +typedef struct { + uint64_t timestamp; /**< Timestamp of the acquisition of the GNSS data. [ms] */ + //position + double latitude; /**< Latitude in WGS84 in degrees. */ + double longitude; /**< Longitude in WGS84 in degrees. */ + float altitudeMSL; /**< Altitude above mean sea level (geoid) */ + float altitudeEll; /**< Altitude above WGS84 ellipsoid */ + //velocity + float hSpeed; /**< Horizontal speed [m/s]. */ + float vSpeed; /**< Vertical speed [m/s]. */ + float heading; /**< GNSS course angle [degree] (0 => north, 90 => east, 180 => south, 270 => west, no negative values). */ + //quality parameters: satellite constellation + float pdop; /**< The positional (3D) dilution of precision. [Note: pdop^2 = hdop^2+vdop^2] */ + float hdop; /**< The horizontal (2D) dilution of precision. */ + float vdop; /**< The vertical (altitude) dilution of precision. */ + uint16_t usedSatellites; /**< Number of satellites used for the GNSS fix. */ + uint16_t trackedSatellites; /**< Number of satellites from which a signal is received. */ + uint16_t visibleSatellites; /**< Number of satellites expected to be receiveable, i.e. above horizon or elevation mask. */ + //quality parameters: error estimates + float sigmaHPosition; /**< Standard error estimate of the horizontal position in [m]. */ + float sigmaAltitude; /**< Standard error estimate of altitude in [m]. */ + float sigmaHSpeed; /**< Standard error estimate of horizontal speed in [m/s]. */ + float sigmaVSpeed; /**< Standard error estimate of vertical speed in [m/s]. */ + float sigmaHeading; /**< Standard error estimate of horizontal heading/course in [degree]. */ + //quality parameters: overall GNSS fix status + EGNSSFixStatus fixStatus; /**< Value representing the GNSS mode. */ + uint32_t fixTypeBits; /**< Bit mask indicating the sources actually used for the GNSS calculation. + [bitwise or'ed @ref EGNSSFixType values]. */ + + uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value. + [bitwise or'ed @ref EGNSSPositionValidityBits values]. + Must be checked before usage. */ +} TGNSSPosition; + + + +/** + * Callback type for GNSS UTC date and time. + * Use this type of callback if you want to register for GNSS UTC time data. + * This callback may return buffered data (numElements >1) for different reasons + * for (large) portions of data buffered at startup + * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) + * If the array contains (numElements >1), the elements will be ordered with rising timestamps + * @param time pointer to an array of TGNSSTime with size numElements + * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. + */ +typedef void (*GNSSTimeCallback)(const TGNSSTime time[], uint16_t numElements); + +/** + * Callback type for GNSS satellite details. + * Use this type of callback if you want to register for GNSS satellite detail data. + * This callback may return buffered data (numElements >1) for different reasons + * for (large) portions of data buffered at startup + * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) + * If the array contains (numElements >1), the elements will be ordered with rising timestamps + * @param time pointer to an array of TGNSSSatelliteDetail with size numElements + * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. + */ +typedef void (*GNSSSatelliteDetailCallback)(const TGNSSSatelliteDetail satelliteDetail[], uint16_t numElements); + +/** + * Callback type for GNSS position data + * Use this type of callback if you want to register for GNSS position data. + * This callback may return buffered data (numElements >1) for different reasons + * for (large) portions of data buffered at startup + * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency) + * If the array contains (numElements >1), the elements will be ordered with rising timestamps + * @param position pointer to an array of TGNSSPosition with size numElements + * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided. + */ +typedef void (*GNSSPositionCallback)(const TGNSSPosition position[], uint16_t numElements); + +/** + * Accessing static configuration information about the antenna position. + * @param distance After calling the method the currently available antenna configuration data is written into this parameter. + * @return Is true if data can be provided and false otherwise, e.g. missing initialization + * + * Static configuration data for the GNSS service. + * The reference point mentioned in the vehicle configuration lies underneath the center of the rear axle on the surface of the road. + * The reference coordinate system is the car reference system as provided in the documentation. + * See https://collab.genivi.org/wiki/display/genivi/LBSSensorServiceRequirementsBorg#LBSSensorServiceRequirementsBorg-ReferenceSystem + */ +bool gnssGetAntennaPosition(TGNSSDistance3D *distance); + +/** + * Method to get the UTC date / time data of the GNSS receiver at a specific point in time. + * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true. + * @param time After calling the method the current GNSS UTC date / time is written into this parameter. + * @return Is true if data can be provided and false otherwise, e.g. missing initialization + */ +bool gnssGetTime(TGNSSTime *utc); + +/** + * Register GNSS UTC time callback. + * The callback will be invoked when new time data is available from the GNSS receiver. + * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true. + * @param callback The callback which should be registered. + * @return True if callback has been registered successfully. + */ +bool gnssRegisterTimeCallback(GNSSTimeCallback callback); + +/** + * Deregister GNSS UTC time callback. + * After calling this method no new time will be delivered to the client. + * @param callback The callback which should be deregistered. + * @return True if callback has been deregistered successfully. + */ +bool gnssDeregisterTimeCallback(GNSSTimeCallback callback); + +/** + * Method to get the GNSS satellite details at a specific point in time. + * All valid flags are updated. The data is only guaranteed to be updated when the valid flag is true. + * @param satelliteDetails After calling the method current GNSS satellite details are written into this array with size count. + * @param count Number of elements of the array *satelliteDetails. This should be at least TGnssMetaData::numChannels. + * @param numSatelliteDetails Number of elements written to the array *satelliteDetails. + * @return Is true if data can be provided and false otherwise, e.g. missing initialization + */ +bool gnssGetSatelliteDetails(TGNSSSatelliteDetail* satelliteDetails, uint16_t count, uint16_t* numSatelliteDetails); + +/** + * Register GNSS satellite detail callback. + * The callback will be invoked when new date data is available from the GNSS receiver. + * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true. + * @param callback The callback which should be registered. + * @return True if callback has been registered successfully. + */ +bool gnssRegisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback); + +/** + * Deregister GNSS satellite detail callback. + * After calling this method no new data will be delivered to the client. + * @param callback The callback which should be deregistered. + * @return True if callback has been deregistered successfully. + */ +bool gnssDeregisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback); + +/** + * Method to get the GNSS position data at a specific point in time. + * All valid flags are updated. The data is only guaranteed to be updated when the valid flag is true. + * @param position After calling the method current GNSS position, velocity, accuracy are written into this parameter. + * @return Is true if data can be provided and false otherwise, e.g. missing initialization + */ +bool gnssGetPosition(TGNSSPosition* position); + +/** + * Register GNSS position callback. + * The callback will be invoked when new position data data is available from the GNSS receiver. + * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true. + * @param callback The callback which should be registered. + * @return True if callback has been registered successfully. + */ +bool gnssRegisterPositionCallback(GNSSPositionCallback callback); + +/** + * Deregister GNSS position callback. + * After calling this method no new data will be delivered to the client. + * @param callback The callback which should be deregistered. + * @return True if callback has been deregistered successfully. + */ +bool gnssDeregisterPositionCallback(GNSSPositionCallback callback); + + +/** + * Provides the precision timing information as signaled by the GNSS PPS signal. + * For accurate timing the 1 PPS (pulse per second) signal from the GNSS receiver is used within the positioning framework. + * The PPS is a hardware signal which is a UTC synchronized pulse. + * The duration between the pulses is 1s +/- 40ns and the duration of the pulse is configurable (about 100-200ms). + * The PPS signal can be provided in the positioning framework as an interrupt service routine and this method provides the access + * to the delta from UTC to system time. + * If you really need precision timing you have to have the system time set within a range of +/-2s of UTC. + * @param delta The result is provided in this parameter in nanoseconds. It gives the deviation of the system time (+/-) in respect to the PPS pulse and UTC. + * If the deviation is is greater than a value that can be represented with 32 Bits (i.e. more or less than about 2s) the + * maximum values are written to this parameter and the return value will be false. + * @return True if the precision timing is available and fits in the range which can be represented by the delta parameter. + */ +bool gnssGetPrecisionTimingOffset(int32_t *delta); #ifdef __cplusplus } #endif -#endif +#endif /* INCLUDE_GENIVI_GNSS_EXT */ diff --git a/gnss-service/src/CMakeLists.txt b/gnss-service/src/CMakeLists.txt index 1c802fe..fa6dbbb 100644 --- a/gnss-service/src/CMakeLists.txt +++ b/gnss-service/src/CMakeLists.txt @@ -40,16 +40,14 @@ if(WITH_GPSD) pkg_check_modules(GPSD libgps>=2.94) #generate library using gpsd as input set(LIB_SRC_USE_GPSD ${CMAKE_SOURCE_DIR}/src/gnss-use-gpsd.c - ${CMAKE_SOURCE_DIR}/src/gnss-simple.c - ${CMAKE_SOURCE_DIR}/src/gnss-ext.c + ${CMAKE_SOURCE_DIR}/src/gnss-impl.c ${CMAKE_SOURCE_DIR}/src/gnss-meta-data.c) add_library(gnss-service-use-gpsd SHARED ${LIB_SRC_USE_GPSD}) target_link_libraries(gnss-service-use-gpsd gps ${LIBRARIES}) elseif(WITH_REPLAYER) #generate library using replayer as input set(LIB_SRC_USE_REPLAYER ${CMAKE_SOURCE_DIR}/src/gnss-use-replayer.c - ${CMAKE_SOURCE_DIR}/src/gnss-simple.c - ${CMAKE_SOURCE_DIR}/src/gnss-ext.c + ${CMAKE_SOURCE_DIR}/src/gnss-impl.c ${CMAKE_SOURCE_DIR}/src/gnss-meta-data.c) add_library(gnss-service-use-replayer SHARED ${LIB_SRC_USE_REPLAYER}) target_link_libraries(gnss-service-use-replayer ${LIBRARIES}) diff --git a/gnss-service/src/globals.h b/gnss-service/src/globals.h index 4e252c4..98086ee 100644 --- a/gnss-service/src/globals.h +++ b/gnss-service/src/globals.h @@ -23,25 +23,22 @@ #include <pthread.h> #include <time.h> +#include "gnss-init.h" #include "gnss.h" -#include "gnss-simple.h" -#include "gnss-ext.h" #include "gnss-meta-data.h" extern pthread_mutex_t mutexCb; extern pthread_mutex_t mutexData; -extern TGNSSPosition gPosition; -extern TGNSSCourse gCourse; -extern TGNSSAccuracy gAccuracy; extern TGNSSSatelliteDetail gSatelliteDetail; //TODO: buffer full set of satellite details for one point in time -extern TGNSSSimpleConfiguration gConfiguration; +extern TGNSSPosition gPosition; +extern TGNSSTime gTime; + extern const TGnssMetaData gMetaData; -extern GNSSPositionCallback cbPosition; -extern GNSSCourseCallback cbCourse; -extern GNSSAccuracyCallback cbAccuracy; extern GNSSSatelliteDetailCallback cbSatelliteDetail; +extern GNSSPositionCallback cbPosition; +extern GNSSTimeCallback cbTime; #endif /* GLOBALS_H */ diff --git a/gnss-service/src/gnss-ext.c b/gnss-service/src/gnss-impl.c index 8f88c07..c19f23c 100644 --- a/gnss-service/src/gnss-ext.c +++ b/gnss-service/src/gnss-impl.c @@ -17,44 +17,82 @@ **************************************************************************/ #include "globals.h" -#include "gnss-ext.h" - -TGNSSAccuracy gAccuracy; -GNSSAccuracyCallback cbAccuracy = 0; +#include "gnss.h" TGNSSSatelliteDetail gSatelliteDetail; //TODO: buffer full set of satellite details for one point in time GNSSSatelliteDetailCallback cbSatelliteDetail = 0; -bool gnssExtendedInit() +TGNSSPosition gPosition; +GNSSPositionCallback cbPosition = 0; + +TGNSSTime gTime; +GNSSTimeCallback cbTime = 0; + + +bool gnssRegisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback) { + if(cbSatelliteDetail != 0) + { + return false; //if already registered + } + + pthread_mutex_lock(&mutexCb); + cbSatelliteDetail = callback; + pthread_mutex_unlock(&mutexCb); + return true; } -bool gnssExtendedDestroy() +bool gnssDeregisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback) { + if(cbSatelliteDetail == callback && callback != 0) + { + pthread_mutex_lock(&mutexCb); + cbSatelliteDetail = 0; + pthread_mutex_unlock(&mutexCb); + + return true; + } + + return false; +} + +bool gnssGetSatelliteDetails(TGNSSSatelliteDetail* satelliteDetails, uint16_t count, uint16_t* numSatelliteDetails) +{ + if(!satelliteDetails || !count) + { + return false; + } + +//TODO: return full set of satellite details for one point in time + pthread_mutex_lock(&mutexData); + *satelliteDetails = gSatelliteDetail; + *numSatelliteDetails = 1; + pthread_mutex_unlock(&mutexData); + return true; } -bool gnssExtendedRegisterAccuracyCallback(GNSSAccuracyCallback callback) +bool gnssRegisterPositionCallback(GNSSPositionCallback callback) { - if(cbAccuracy != 0) + if(cbPosition != 0) { return false; //if already registered } pthread_mutex_lock(&mutexCb); - cbAccuracy = callback; + cbPosition = callback; pthread_mutex_unlock(&mutexCb); return true; } -bool gnssExtendedDeregisterAccuracyCallback(GNSSAccuracyCallback callback) +bool gnssDeregisterPositionCallback(GNSSPositionCallback callback) { - if(cbAccuracy == callback && callback != 0) + if(cbPosition == callback && callback != 0) { pthread_mutex_lock(&mutexCb); - cbAccuracy = 0; + cbPosition = 0; pthread_mutex_unlock(&mutexCb); return true; @@ -63,40 +101,41 @@ bool gnssExtendedDeregisterAccuracyCallback(GNSSAccuracyCallback callback) return false; } -bool gnssExtendedGetAccuracy(TGNSSAccuracy* accuracy) +bool gnssGetPosition(TGNSSPosition* position) { - if(!accuracy) + if(!position) { return false; } pthread_mutex_lock(&mutexData); - *accuracy = gAccuracy; + *position = gPosition; pthread_mutex_unlock(&mutexData); return true; } -bool gnssExtendedRegisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback) + +bool gnssRegisterTimeCallback(GNSSTimeCallback callback) { - if(cbSatelliteDetail != 0) + if(cbTime != 0) { return false; //if already registered } pthread_mutex_lock(&mutexCb); - cbSatelliteDetail = callback; + cbTime = callback; pthread_mutex_unlock(&mutexCb); return true; } -bool gnssExtendedDeregisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback) +bool gnssDeregisterTimeCallback(GNSSTimeCallback callback) { - if(cbSatelliteDetail == callback && callback != 0) + if(cbTime == callback && callback != 0) { pthread_mutex_lock(&mutexCb); - cbSatelliteDetail = 0; + cbTime = 0; pthread_mutex_unlock(&mutexCb); return true; @@ -105,18 +144,16 @@ bool gnssExtendedDeregisterSatelliteDetailCallback(GNSSSatelliteDetailCallback c return false; } -bool gnssExtendedGetSatelliteDetails(TGNSSSatelliteDetail* satelliteDetails, uint16_t count, uint16_t* numSatelliteDetails) +bool gnssGetTime(TGNSSTime* time) { - if(!satelliteDetails || !count) + if(!time) { return false; } -//TODO: return full set of satellite details for one point in time pthread_mutex_lock(&mutexData); - *satelliteDetails = gSatelliteDetail; - *numSatelliteDetails = 1; + *time = gTime; pthread_mutex_unlock(&mutexData); return true; -} +}
\ No newline at end of file diff --git a/gnss-service/src/gnss-meta-data.c b/gnss-service/src/gnss-meta-data.c index bf9b192..26e7f26 100644 --- a/gnss-service/src/gnss-meta-data.c +++ b/gnss-service/src/gnss-meta-data.c @@ -18,6 +18,7 @@ #include "globals.h" #include "gnss-meta-data.h" +#include "gnss.h" const TGnssMetaData gGnssMetaData = { GENIVI_GNSS_API_MAJOR, //version @@ -27,7 +28,7 @@ const TGnssMetaData gGnssMetaData = { 4 //number of channels }; -bool gnssSimpleGetMetaData(TGnssMetaData *data) +bool gnssGetMetaData(TGnssMetaData *data) { if(!data) { @@ -38,12 +39,3 @@ bool gnssSimpleGetMetaData(TGnssMetaData *data) return true; } - - -int32_t getGnssMetaDataList(const TGnssMetaData** metadata) -{ - *metadata = &gGnssMetaData; - - return 1; - -}
\ No newline at end of file diff --git a/gnss-service/src/gnss-simple.c b/gnss-service/src/gnss-simple.c deleted file mode 100644 index 03ad012..0000000 --- a/gnss-service/src/gnss-simple.c +++ /dev/null @@ -1,146 +0,0 @@ -/************************************************************************** -* @licence app begin@ -* -* SPDX-License-Identifier: MPL-2.0 -* -* \ingroup GNSSService -* \author Marco Residori <marco.residori@xse.de> -* -* \copyright Copyright (C) 2013, XS Embedded GmbH -* -* \license -* This Source Code Form is subject to the terms of the -* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with -* this file, You can obtain one at http://mozilla.org/MPL/2.0/. -* -* @licence end@ -**************************************************************************/ - -#include "globals.h" -#include "gnss-simple.h" - -GNSSPositionCallback cbPosition = 0; -GNSSCourseCallback cbCourse = 0; -TGNSSPosition gPosition; -TGNSSCourse gCourse; -TGNSSSimpleConfiguration gConfiguration; - -bool gnssSimpleInit() -{ - gPosition.validityBits = 0; - gConfiguration.validityBits = 0; - gCourse.validityBits = 0; - - cbPosition = 0; - cbCourse = 0; - - return true; -} - -bool gnssSimpleDestroy() -{ - return true; -} - -bool gnssSimpleGetConfiguration(TGNSSSimpleConfiguration* gnssConfig) -{ - if(!gnssConfig) - { - return false; - } - - *gnssConfig = gConfiguration; - - return true; -} - -bool gnssSimpleRegisterPositionCallback(GNSSPositionCallback callback) -{ - //printf("gnssSimpleRegisterPositionCallback\n"); - if(cbPosition != 0) - { - return false; - } - - pthread_mutex_lock(&mutexCb); - cbPosition = callback; - pthread_mutex_unlock(&mutexCb); - - return true; -} - -bool gnssSimpleDeregisterPositionCallback(GNSSPositionCallback callback) -{ - //printf("gnssSimpleDeregisterPositionCallback\n"); - if (cbPosition == callback && callback != 0) - { - pthread_mutex_lock(&mutexCb); - cbPosition = 0; - pthread_mutex_unlock(&mutexCb); - - return true; - } - return false; -} - -bool gnssSimpleGetPosition(TGNSSPosition* pos) -{ - if(!pos) - { - return false; - } - - pthread_mutex_lock(&mutexData); - *pos = gPosition; - pthread_mutex_unlock(&mutexData); - - return true; -} - -bool gnssSimpleRegisterCourseCallback(GNSSCourseCallback callback) -{ - //printf("gnssSimpleRegisterCourseCallback\n"); - if(cbCourse != 0) - { - return false; - } - - pthread_mutex_lock(&mutexCb); - cbCourse = callback; - pthread_mutex_unlock(&mutexCb); - - return true; -} - -bool gnssSimpleDeregisterCourseCallback(GNSSCourseCallback callback) -{ - //printf("gnssSimpleDeregisterCourseCallback\n"); - if(cbCourse == callback && callback != 0) - { - pthread_mutex_lock(&mutexCb); - cbCourse = 0; - pthread_mutex_unlock(&mutexCb); - - return true; - } - - return false; -} - -bool gnssSimpleGetCourse(TGNSSCourse* course) -{ - if(!course) - { - return false; - } - - pthread_mutex_lock(&mutexData); - *course = gCourse; - pthread_mutex_unlock(&mutexData); - - return true; -} - - - - diff --git a/gnss-service/src/gnss-use-gpsd.c b/gnss-service/src/gnss-use-gpsd.c index dbbcaeb..bd80e57 100644 --- a/gnss-service/src/gnss-use-gpsd.c +++ b/gnss-service/src/gnss-use-gpsd.c @@ -23,10 +23,10 @@ #include <errno.h> #include <pthread.h> #include <assert.h> +#include <math.h> #include "globals.h" -#include "gnss.h" -#include "gnss-simple.h" +#include "gnss-init.h" #include "log.h" #include "gps.h" @@ -113,22 +113,87 @@ static EGNSSFixStatus convertToFixStatus(int fixMode) return status; } -bool extractAccuracy(struct gps_data_t* pGpsData, TGNSSAccuracy* pAccuracy) +bool extractPosition(struct gps_data_t* pGpsData, TGNSSPosition* pPosition) { + static float oldHSpeed = 0; + static float oldVSpeed = 0; + static float oldHeading = 0; static EGNSSFixStatus oldFixStatus = GNSS_FIX_STATUS_NO; static uint16_t oldUsedSatellites = 0; static uint16_t oldVisibleSatellites = 0; + + bool positionAvailable = false; + bool velocityAvailable = false; bool fixStatusChanged = false; bool satellitesChanged = false; - if(!pGpsData || !pAccuracy) + if(!pGpsData || !pPosition) { return false; } - pAccuracy->validityBits = 0; + pPosition->validityBits = 0; - pAccuracy->timestamp = pGpsData->fix.time; + pPosition->timestamp = pGpsData->fix.time; + + if( ((pGpsData->set & LATLON_SET) || (pGpsData->set & ALTITUDE_SET)) && + (pGpsData->set & MODE_SET) && + ((pGpsData->fix.mode == MODE_2D) || (pGpsData->fix.mode == MODE_3D)) ) + { + positionAvailable = true; + + if(pGpsData->set & LATLON_SET) + { + pPosition->validityBits |= GNSS_POSITION_LATITUDE_VALID; + pPosition->latitude = pGpsData->fix.latitude; + + pPosition->validityBits |= GNSS_POSITION_LONGITUDE_VALID; + pPosition->longitude = pGpsData->fix.longitude; + + LOG_DEBUG(gContext,"Latitude: %lf", pPosition->latitude); + LOG_DEBUG(gContext,"Longitude: %lf", pPosition->longitude); + } + + if((pGpsData->set & ALTITUDE_SET) && (pGpsData->fix.mode == MODE_3D)) + { + pPosition->validityBits |= GNSS_POSITION_ALTITUDEMSL_VALID; + pPosition->altitudeMSL = (float)pGpsData->fix.altitude; + + LOG_DEBUG(gContext,"Altitude: %lf", pPosition->altitudeMSL); + } + } + + if( ((pGpsData->set & SPEED_SET) && (oldHSpeed != (float)pGpsData->fix.speed)) || + ((pGpsData->set & CLIMB_SET) && (oldVSpeed != (float)pGpsData->fix.climb)) || + ((pGpsData->set & TRACK_SET) && (oldHeading != (float)pGpsData->fix.track)) ) + { + + velocityAvailable = true; + + if(pGpsData->set & SPEED_SET) + { + oldHSpeed = pPosition->hSpeed; + pPosition->hSpeed = (float)pGpsData->fix.speed; + pPosition->validityBits |= GNSS_POSITION_HSPEED_VALID; + LOG_DEBUG(gContext,"Speed: %lf", pPosition->hSpeed); + } + + if(pGpsData->set & CLIMB_SET) + { + oldVSpeed = pPosition->vSpeed; + pPosition->vSpeed = (float)pGpsData->fix.climb; + pPosition->validityBits |= GNSS_POSITION_VSPEED_VALID; + LOG_DEBUG(gContext,"Climb: %lf", pPosition->vSpeed); + } + + if(pGpsData->set & TRACK_SET) + { + oldHeading = pPosition->heading; + pPosition->heading = (float)pGpsData->fix.track; + pPosition->validityBits |= GNSS_POSITION_HEADING_VALID; + LOG_DEBUG(gContext,"Heading: %lf", pPosition->heading); + } + } fixStatusChanged = (oldFixStatus != convertToFixStatus(pGpsData->fix.mode)); @@ -139,139 +204,108 @@ bool extractAccuracy(struct gps_data_t* pGpsData, TGNSSAccuracy* pAccuracy) (pGpsData->set & DOP_SET) || ((pGpsData->set & SATELLITE_SET) && satellitesChanged)) { - oldFixStatus = pAccuracy->fixStatus; - pAccuracy->fixStatus = convertToFixStatus(pGpsData->fix.mode); - pAccuracy->validityBits |= GNSS_ACCURACY_STAT_VALID; - LOG_DEBUG(gContext,"FixStatus: %d", (int)pAccuracy->fixStatus); + oldFixStatus = pPosition->fixStatus; + pPosition->fixStatus = convertToFixStatus(pGpsData->fix.mode); + pPosition->validityBits |= GNSS_POSITION_STAT_VALID; + LOG_DEBUG(gContext,"FixStatus: %d", (int)pPosition->fixStatus); + + //fixTypeBits: hardcoded + pPosition->fixTypeBits |= GNSS_FIX_TYPE_SINGLE_FREQUENCY; + pPosition->validityBits |= GNSS_POSITION_TYPE_VALID; + + pPosition->pdop = (float)pGpsData->dop.pdop; + pPosition->validityBits |= GNSS_POSITION_PDOP_VALID; + LOG_DEBUG(gContext,"pdop: %lf", pPosition->pdop); + + pPosition->hdop = (float)pGpsData->dop.hdop; + pPosition->validityBits |= GNSS_POSITION_HDOP_VALID; + LOG_DEBUG(gContext,"hdop: %lf", pPosition->hdop); - pAccuracy->pdop = (float)pGpsData->dop.pdop; - pAccuracy->validityBits |= GNSS_ACCURACY_PDOP_VALID; - LOG_DEBUG(gContext,"pdop: %lf", pAccuracy->pdop); + pPosition->vdop = (float)pGpsData->dop.vdop; + pPosition->validityBits |= GNSS_POSITION_VDOP_VALID; + LOG_DEBUG(gContext,"vdop: %lf", pPosition->vdop); - pAccuracy->hdop = (float)pGpsData->dop.hdop; - pAccuracy->validityBits |= GNSS_ACCURACY_HDOP_VALID; - LOG_DEBUG(gContext,"hdop: %lf", pAccuracy->hdop); + pPosition->sigmaHPosition = (float)pGpsData->fix.epx; + pPosition->validityBits |= GNSS_POSITION_SHPOS_VALID; + LOG_DEBUG(gContext,"sigmaHorPosition: %lf", pPosition->sigmaHPosition); - pAccuracy->vdop = (float)pGpsData->dop.vdop; - pAccuracy->validityBits |= GNSS_ACCURACY_VDOP_VALID; - LOG_DEBUG(gContext,"vdop: %lf", pAccuracy->vdop); + pPosition->sigmaHSpeed = (float)pGpsData->fix.eps; + pPosition->validityBits |= GNSS_POSITION_SHSPEED_VALID; + LOG_DEBUG(gContext,"sigmaHorSpeed: %lf", pPosition->sigmaHSpeed); + + pPosition->sigmaHeading = (float)pGpsData->fix.epd; + pPosition->validityBits |= GNSS_POSITION_SHEADING_VALID; + LOG_DEBUG(gContext,"sigmaHeading: %lf", pPosition->sigmaHeading); if(pGpsData->satellites_used >= 0) { - oldUsedSatellites = pAccuracy->usedSatellites; - pAccuracy->usedSatellites = (uint16_t)pGpsData->satellites_used; - pAccuracy->validityBits |= GNSS_ACCURACY_USAT_VALID; - LOG_DEBUG(gContext,"Used Satellites: %d", pAccuracy->usedSatellites); + oldUsedSatellites = pPosition->usedSatellites; + pPosition->usedSatellites = (uint16_t)pGpsData->satellites_used; + pPosition->validityBits |= GNSS_POSITION_USAT_VALID; + LOG_DEBUG(gContext,"Used Satellites: %d", pPosition->usedSatellites); } if(pGpsData->satellites_visible >= 0) { - oldVisibleSatellites = pAccuracy->visibleSatellites; - pAccuracy->visibleSatellites = (uint16_t)pGpsData->satellites_visible; - pAccuracy->validityBits |= GNSS_ACCURACY_VSAT_VALID; - LOG_DEBUG(gContext,"Visible Satellites: %d", pAccuracy->visibleSatellites); + oldVisibleSatellites = pPosition->visibleSatellites; + pPosition->visibleSatellites = (uint16_t)pGpsData->satellites_visible; + pPosition->validityBits |= GNSS_POSITION_VSAT_VALID; + LOG_DEBUG(gContext,"Visible Satellites: %d", pPosition->visibleSatellites); } - - if(cbAccuracy != 0) + } + + if (positionAvailable || velocityAvailable || fixStatusChanged || satellitesChanged) + { + if(cbPosition != 0) { - cbAccuracy(pAccuracy,1); + cbPosition(pPosition,1); } } + return true; } -bool extractPosition(struct gps_data_t* pGpsData, TGNSSPosition* pPosition) +bool extractTime(struct gps_data_t* pGpsData, TGNSSTime* pTime) { - if(!pGpsData || !pPosition) - { - return false; - } + static timestamp_t oldTime = 0; - if( ((pGpsData->set & LATLON_SET) || (pGpsData->set & ALTITUDE_SET)) && - (pGpsData->set & MODE_SET) && - ((pGpsData->fix.mode == MODE_2D) || (pGpsData->fix.mode == MODE_3D)) ) - { - pPosition->validityBits = 0; - - pPosition->timestamp = pGpsData->fix.time; - - if(pGpsData->set & LATLON_SET) - { - pPosition->validityBits |= GNSS_ACCURACY_SLAT_VALID; - pPosition->latitude = pGpsData->fix.latitude; - - pPosition->validityBits |= GNSS_ACCURACY_SLON_VALID; - pPosition->longitude = pGpsData->fix.longitude; - - LOG_DEBUG(gContext,"Latitude: %lf", pPosition->latitude); - LOG_DEBUG(gContext,"Longitude: %lf", pPosition->longitude); - } - - if((pGpsData->set & ALTITUDE_SET) && (pGpsData->fix.mode == MODE_3D)) - { - pPosition->validityBits |= GNSS_ACCURACY_SALT_VALID; - pPosition->altitude = (float)pGpsData->fix.altitude; - - LOG_DEBUG(gContext,"Altitude: %lf", pPosition->altitude); - } - - if (cbPosition != 0) - { - cbPosition(pPosition,1); - } - } - return true; -} - -bool extractCourse(struct gps_data_t* pGpsData, TGNSSCourse* pCourse) -{ - static float oldSpeed = 0; - static float oldClimb = 0; - static float oldHeading = 0; - - if(!pGpsData || !pCourse) - { + if(!pGpsData || !pTime) + { return false; - } + } - pCourse->validityBits = 0; - - if( ((pGpsData->set & SPEED_SET) && (oldSpeed != (float)pGpsData->fix.speed)) || - ((pGpsData->set & CLIMB_SET) && (oldClimb != (float)pGpsData->fix.climb)) || - ((pGpsData->set & TRACK_SET) && (oldHeading != (float)pGpsData->fix.track)) ) + if ((pGpsData->set & TIME_SET) && (oldTime != pGpsData->fix.time)) { - if(pGpsData->set & SPEED_SET) - { - oldSpeed = pCourse->speed; - pCourse->speed = (float)pGpsData->fix.speed; - pCourse->validityBits |= GNSS_COURSE_SPEED_VALID; - LOG_DEBUG(gContext,"Speed: %lf", pCourse->speed); - } + char month [12] [4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + pTime->validityBits = 0; + pTime->timestamp = pGpsData->fix.time; - if(pGpsData->set & CLIMB_SET) - { - oldClimb = pCourse->climb; - pCourse->climb = (float)pGpsData->fix.climb; - pCourse->validityBits |= GNSS_COURSE_CLIMB_VALID; - LOG_DEBUG(gContext,"Climb: %lf", pCourse->climb); - } - - if(pGpsData->set & TRACK_SET) - { - oldHeading = pCourse->heading; - pCourse->heading = (float)pGpsData->fix.track; - pCourse->validityBits |= GNSS_COURSE_HEADING_VALID; - LOG_DEBUG(gContext,"Heading: %lf", pCourse->heading); - } - - if(cbCourse != 0) - { - cbCourse(pCourse,1); - } + if(pGpsData->set & TIME_SET) + { + oldTime = pGpsData->fix.time; + time_t unix_sec = pGpsData->fix.time; + struct tm * ptm = gmtime (&unix_sec); + pTime->year = ptm->tm_year+1900; + pTime->month = ptm->tm_mon; + pTime->day = ptm->tm_mday; + pTime->hour = ptm->tm_hour; + pTime->minute = ptm->tm_min; + pTime->second = ptm->tm_sec; + pTime->ms = 1000*fmod(pGpsData->fix.time, 1.0); + pTime->validityBits |= GNSS_TIME_TIME_VALID | GNSS_TIME_DATE_VALID; + LOG_DEBUG(gContext,"UTC: %04d-%s-%02d %02d:%02d:%02d", pTime->year, month[pTime->month%12], pTime->day, pTime->hour, pTime->minute, pTime->second); + } + + if(cbTime != 0) + { + cbTime(pTime,1); + } } return true; } + void *listen( void *ptr ) { char* server = "localhost"; @@ -317,21 +351,18 @@ void *listen( void *ptr ) { pthread_mutex_lock(&mutexData); + if(!extractPosition(&gpsdata,&gPosition)) { - LOG_ERROR_MSG(gContext,"error extracting position"); + LOG_ERROR_MSG(gContext,"error extracting position data"); } - if(!extractCourse(&gpsdata,&gCourse)) + if(!extractTime(&gpsdata,&gTime)) { - LOG_ERROR_MSG(gContext,"error extracting course"); - } - - if(!extractAccuracy(&gpsdata,&gAccuracy)) - { - LOG_ERROR_MSG(gContext,"error extracting accuracy"); + LOG_ERROR_MSG(gContext,"error extracting Time"); } + pthread_mutex_unlock(&mutexData); } } diff --git a/gnss-service/src/gnss-use-replayer.c b/gnss-service/src/gnss-use-replayer.c index 3145cac..d838ab4 100644 --- a/gnss-service/src/gnss-use-replayer.c +++ b/gnss-service/src/gnss-use-replayer.c @@ -33,8 +33,7 @@ #include <memory.h> #include "globals.h" -#include "gnss.h" -#include "gnss-simple.h" +#include "gnss-init.h" #include "log.h" #define BUFLEN 256 @@ -48,7 +47,7 @@ pthread_mutex_t mutexCb; pthread_mutex_t mutexData; bool isRunning = false; -int s = NULL; +int s = 0; void *listenForMessages( void *ptr ); @@ -100,34 +99,52 @@ void gnssGetVersion(int *major, int *minor, int *micro) } } -bool processGVGNSAC(char* data, TGNSSAccuracy* pAccuracy) +//backward compatible processing of GVGNSAC to the new TGNSSPosition +bool processGVGNSAC(char* data, TGNSSPosition* pPosition) { //parse data like: 061064000,0$GVGNSP,061064000,49.02657,12.06527,336.70000,0X07 //storage for buffered data - static TGNSSAccuracy buf_acc[MAX_BUF_MSG]; + static TGNSSPosition buf_acc[MAX_BUF_MSG]; static uint16_t buf_size = 0; static uint16_t last_countdown = 0; uint64_t timestamp; uint16_t countdown; - TGNSSAccuracy acc = { 0 }; + TGNSSPosition pos = { 0 }; uint16_t fixStatus; + uint32_t GVGNSAC_validityBits; uint32_t n = 0; - if(!data || !pAccuracy) + if(!data || !pPosition) { LOG_ERROR_MSG(gContext,"wrong parameter!"); return false; } n = sscanf(data, "%llu,%hu$GVGNSAC,%llu,%f,%f,%f,%hu,%hu,%hu,%f,%f,%f,%hu,%x,%x", - ×tamp, &countdown, &acc.timestamp, - &acc.pdop, &acc.hdop, &acc.vdop, - &acc.usedSatellites, &acc.trackedSatellites, &acc.visibleSatellites, - &acc.sigmaLatitude, &acc.sigmaLongitude, &acc.sigmaAltitude, - &fixStatus, &acc.fixTypeBits, &acc.validityBits); - acc.fixStatus = fixStatus; + ×tamp, &countdown, &pos.timestamp, + &pos.pdop, &pos.hdop, &pos.vdop, + &pos.usedSatellites, &pos.trackedSatellites, &pos.visibleSatellites, + &pos.sigmaHPosition, &pos.sigmaHPosition, &pos.sigmaAltitude, + &fixStatus, &pos.fixTypeBits, &GVGNSAC_validityBits); + //fix status: order in enum has changed + if (fixStatus == 0) { pos.fixStatus = GNSS_FIX_STATUS_NO; } + if (fixStatus == 1) { pos.fixStatus = GNSS_FIX_STATUS_2D; } + if (fixStatus == 2) { pos.fixStatus = GNSS_FIX_STATUS_3D; } + if (fixStatus == 3) { pos.fixStatus = GNSS_FIX_STATUS_TIME; } + //map the old validity bits to the new validity bits + pos.validityBits = 0; + if (GVGNSAC_validityBits&0x00000001) { pos.validityBits |= GNSS_POSITION_PDOP_VALID; } + if (GVGNSAC_validityBits&0x00000002) { pos.validityBits |= GNSS_POSITION_HDOP_VALID; } + if (GVGNSAC_validityBits&0x00000004) { pos.validityBits |= GNSS_POSITION_VDOP_VALID; } + if (GVGNSAC_validityBits&0x00000008) { pos.validityBits |= GNSS_POSITION_USAT_VALID; } + if (GVGNSAC_validityBits&0x00000010) { pos.validityBits |= GNSS_POSITION_TSAT_VALID; } + if (GVGNSAC_validityBits&0x00000020) { pos.validityBits |= GNSS_POSITION_VSAT_VALID; } + if (GVGNSAC_validityBits&0x00000040) { pos.validityBits |= GNSS_POSITION_SHPOS_VALID; } + if (GVGNSAC_validityBits&0x00000100) { pos.validityBits |= GNSS_POSITION_SALT_VALID; } + if (GVGNSAC_validityBits&0x00000200) { pos.validityBits |= GNSS_POSITION_STAT_VALID; } + if (GVGNSAC_validityBits&0x00000400) { pos.validityBits |= GNSS_POSITION_TYPE_VALID; } if (n <= 0) { @@ -135,7 +152,19 @@ bool processGVGNSAC(char* data, TGNSSAccuracy* pAccuracy) return false; } - *pAccuracy = acc; + //global Position: update the changed fields, retain the existing fields from other callbacks + pPosition->timestamp = pos.timestamp; + pPosition->pdop = pos.pdop; + pPosition->hdop = pos.hdop; + pPosition->vdop = pos.vdop; + pPosition->usedSatellites = pos.usedSatellites; + pPosition->trackedSatellites = pos.trackedSatellites; + pPosition->visibleSatellites = pos.visibleSatellites; + pPosition->sigmaHPosition = pos.sigmaHPosition; + pPosition->sigmaAltitude = pos.sigmaAltitude; + pPosition->fixStatus = pos.fixStatus; + pPosition->fixTypeBits = pos.fixTypeBits; + pPosition->validityBits |= pos.validityBits; //buffered data handling if (countdown < MAX_BUF_MSG) //enough space in buffer? @@ -144,12 +173,12 @@ bool processGVGNSAC(char* data, TGNSSAccuracy* pAccuracy) { buf_size = countdown+1; last_countdown = countdown; - buf_acc[buf_size-countdown-1] = acc; + buf_acc[buf_size-countdown-1] = pos; } else if ((last_countdown-countdown) == 1) //sequence continued { last_countdown = countdown; - buf_acc[buf_size-countdown-1] = acc; + buf_acc[buf_size-countdown-1] = pos; } else //sequence interrupted: clear buffer { @@ -163,16 +192,17 @@ bool processGVGNSAC(char* data, TGNSSAccuracy* pAccuracy) last_countdown = 0; } - if((cbAccuracy != 0) && (countdown == 0) && (buf_size >0) ) + if((cbPosition != 0) && (countdown == 0) && (buf_size >0) ) { - cbAccuracy(buf_acc,buf_size); + cbPosition(buf_acc,buf_size); buf_size = 0; - last_countdown = 0; + last_countdown = 0; } return true; } +//backward compatible processing of GVGNSP to the new TGNSSPosition static bool processGVGNSP(char* data, TGNSSPosition* pPosition) { //parse data like: 061064000,0$GVGNSP,061064000,49.02657,12.06527,336.70000,0X07 @@ -185,6 +215,7 @@ static bool processGVGNSP(char* data, TGNSSPosition* pPosition) uint64_t timestamp; uint16_t countdown; TGNSSPosition pos = { 0 }; + uint32_t GVGNSP_validityBits; uint32_t n = 0; if(!data || !pPosition) @@ -193,7 +224,13 @@ static bool processGVGNSP(char* data, TGNSSPosition* pPosition) return false; } - n = sscanf(data, "%llu,%hu$GVGNSP,%llu,%lf,%lf,%f,%x", ×tamp, &countdown, &pos.timestamp, &pos.latitude, &pos.longitude, &pos.altitude, &pos.validityBits); + n = sscanf(data, "%llu,%hu$GVGNSP,%llu,%lf,%lf,%f,%x", ×tamp, &countdown, &pos.timestamp, &pos.latitude, &pos.longitude, &pos.altitudeMSL, &GVGNSP_validityBits); + + //map the old validity bits to the new validity bits + pos.validityBits = 0; + if (GVGNSP_validityBits&0x00000001) { pos.validityBits |= GNSS_POSITION_LATITUDE_VALID; } + if (GVGNSP_validityBits&0x00000002) { pos.validityBits |= GNSS_POSITION_LONGITUDE_VALID; } + if (GVGNSP_validityBits&0x00000004) { pos.validityBits |= GNSS_POSITION_ALTITUDEMSL_VALID; } if (n <= 0) { @@ -233,34 +270,41 @@ static bool processGVGNSP(char* data, TGNSSPosition* pPosition) { cbPosition(buf_pos,buf_size); buf_size = 0; - last_countdown = 0; + last_countdown = 0; } return true; } -static bool processGVGNSC(char* data, TGNSSCourse* pCourse) +//backward compatible processing of GVGNSC to the new TGNSSPosition +static bool processGVGNSC(char* data, TGNSSPosition* pPosition) { //parse data like: 061064000,0$GVGNSC,061064000,0.00,0,131.90000,0X05 - + //storage for buffered data - static TGNSSCourse buf_course[MAX_BUF_MSG]; + static TGNSSPosition buf_course[MAX_BUF_MSG]; static uint16_t buf_size = 0; - static uint16_t last_countdown = 0; + static uint16_t last_countdown = 0; uint64_t timestamp; uint16_t countdown; - TGNSSCourse course = { 0 }; + TGNSSPosition pos = { 0 }; + uint32_t GVGNSC_validityBits; uint32_t n = 0; - if(!data || !pCourse) + if(!data || !pPosition) { LOG_ERROR_MSG(gContext,"wrong parameter!"); return false; } - n = sscanf(data, "%llu,%hu$GVGNSC,%llu,%f,%f,%f,%x", ×tamp, &countdown, &course.timestamp, &course.speed, &course.climb, &course.heading, &course.validityBits); + n = sscanf(data, "%llu,%hu$GVGNSC,%llu,%f,%f,%f,%x", ×tamp, &countdown, &pos.timestamp, &pos.hSpeed, &pos.vSpeed, &pos.heading, &GVGNSC_validityBits); + //map the old validity bits to the new validity bits + pos.validityBits = 0; + if (GVGNSC_validityBits&0x00000001) { pos.validityBits |= GNSS_POSITION_HSPEED_VALID; } + if (GVGNSC_validityBits&0x00000002) { pos.validityBits |= GNSS_POSITION_VSPEED_VALID; } + if (GVGNSC_validityBits&0x00000004) { pos.validityBits |= GNSS_POSITION_HEADING_VALID; } if (n <= 0) { @@ -268,7 +312,12 @@ static bool processGVGNSC(char* data, TGNSSCourse* pCourse) return false; } - *pCourse = course; + //global Position: update the changed fields, retain the existing fields from other callbacks + pPosition->timestamp = pos.timestamp; + pPosition->hSpeed = pos.hSpeed; + pPosition->vSpeed = pos.vSpeed; + pPosition->heading = pos.heading; + pPosition->validityBits |= pos.validityBits; //buffered data handling if (countdown < MAX_BUF_MSG) //enough space in buffer? @@ -277,12 +326,12 @@ static bool processGVGNSC(char* data, TGNSSCourse* pCourse) { buf_size = countdown+1; last_countdown = countdown; - buf_course[buf_size-countdown-1] = course; + buf_course[buf_size-countdown-1] = pos; } else if ((last_countdown-countdown) == 1) //sequence continued { last_countdown = countdown; - buf_course[buf_size-countdown-1] = course; + buf_course[buf_size-countdown-1] = pos; } else //sequence interrupted: clear buffer { @@ -296,11 +345,11 @@ static bool processGVGNSC(char* data, TGNSSCourse* pCourse) last_countdown = 0; } - if((cbCourse != 0) && (countdown == 0) && (buf_size >0) ) + if((cbPosition != 0) && (countdown == 0) && (buf_size >0) ) { - cbCourse(buf_course,buf_size); + cbPosition(buf_course,buf_size); buf_size = 0; - last_countdown = 0; + last_countdown = 0; } return true; @@ -436,11 +485,11 @@ void *listenForMessages( void *ptr ) } else if(strcmp("GVGNSC", msgId) == 0) { - processGVGNSC(buf, &gCourse); + processGVGNSC(buf, &gPosition); } else if(strcmp("GVGNSAC", msgId) == 0) { - processGVGNSAC(buf, &gAccuracy); + processGVGNSAC(buf, &gPosition); } else if(strcmp("GVGNSSAT", msgId) == 0) { diff --git a/gnss-service/test/compliance-test/gnss-service-compliance-test.c b/gnss-service/test/compliance-test/gnss-service-compliance-test.c index 16cef40..2856b4b 100644 --- a/gnss-service/test/compliance-test/gnss-service-compliance-test.c +++ b/gnss-service/test/compliance-test/gnss-service-compliance-test.c @@ -22,9 +22,8 @@ #include <stdbool.h> #include <unistd.h> +#include "gnss-init.h" #include "gnss.h" -#include "gnss-simple.h" -#include "gnss-ext.h" #include "log.h" DLT_DECLARE_CONTEXT(gCtx); @@ -33,37 +32,22 @@ DLT_DECLARE_CONTEXT(gCtx); #define TEST_PASSED EXIT_SUCCESS static int testResult = TEST_PASSED; +static int cbPositionSuccess = 0; - -static void cbPosition(const TGNSSPosition pos[], uint16_t numElements) +static void cbPosition(const TGNSSPosition position[], uint16_t numElements) { - if(pos == NULL || numElements < 1) + int i; + if(position == NULL || numElements < 1) { LOG_ERROR_MSG(gCtx,"cbPosition failed!"); testResult = TEST_FAILED; return; } + cbPositionSuccess++; + + } -static void cbCourse(const TGNSSCourse course[], uint16_t numElements) -{ - if(course == NULL || numElements < 1) - { - LOG_ERROR_MSG(gCtx,"cbCourse failed!"); - testResult = TEST_FAILED; - return; - } -} - -static void cbAccuracy(const TGNSSAccuracy accuracy[], uint16_t numElements) -{ - if(accuracy == NULL || numElements < 1) - { - LOG_ERROR_MSG(gCtx,"cbAccuracy failed!"); - testResult = TEST_FAILED; - return; - } -} bool checkMajorVersion(int expectedMajor) { @@ -96,11 +80,6 @@ bool init() return false; } - if(!gnssSimpleInit()) - { - return false; - } - return true; } @@ -116,9 +95,7 @@ int main() if(init()) { //register for GNSS - gnssSimpleRegisterPositionCallback(&cbPosition); - gnssSimpleRegisterCourseCallback(&cbCourse); - gnssExtendedRegisterAccuracyCallback(&cbAccuracy); + gnssRegisterPositionCallback(&cbPosition); //listen for events for about 10 seconds for(i = 0; i < 10; i++) @@ -127,11 +104,8 @@ int main() } //deregister - gnssSimpleDeregisterPositionCallback(&cbPosition); - gnssSimpleDeregisterCourseCallback(&cbCourse); - gnssExtendedDeregisterAccuracyCallback(&cbAccuracy); + gnssDeregisterPositionCallback(&cbPosition); - gnssSimpleDestroy(); gnssDestroy(); } @@ -142,7 +116,7 @@ int main() return EXIT_FAILURE; } - LOG_INFO_MSG(gCtx,"TEST_PASSED"); + LOG_INFO(gCtx,"TEST_PASSED with %d successful callbacks", cbPositionSuccess); return EXIT_SUCCESS; } diff --git a/gnss-service/test/gnss-service-client.c b/gnss-service/test/gnss-service-client.c index 969bfdc..c928380 100644 --- a/gnss-service/test/gnss-service-client.c +++ b/gnss-service/test/gnss-service-client.c @@ -22,71 +22,74 @@ #include <stdbool.h> #include <unistd.h> +#include "gnss-init.h" #include "gnss.h" -#include "gnss-simple.h" -#include "gnss-ext.h" #include "log.h" DLT_DECLARE_CONTEXT(gCtx); -static void cbPosition(const TGNSSPosition pos[], uint16_t numElements) +static void cbTime(const TGNSSTime time[], uint16_t numElements) { - int i; - if(pos == NULL || numElements < 1) + int i; + if(time == NULL || numElements < 1) { - LOG_ERROR_MSG(gCtx,"cbPosition failed!"); + LOG_ERROR_MSG(gCtx,"cbTime failed!"); return; } for (i = 0; i<numElements; i++) { - LOG_INFO(gCtx,"Position Update[%d/%d]: lat=%f lon=%f", + if (time[i].validityBits & GNSS_TIME_DATE_VALID) + { + char month [12] [4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + LOG_INFO(gCtx,"Time Update[%d/%d]: timestamp=%llu UTC: %04d-%s-%02d %02d:%02d:%02d", i+1, numElements, - pos[i].latitude, - pos[i].longitude); - } -} - -static void cbCourse(const TGNSSCourse course[], uint16_t numElements) -{ - int i; - if(course == NULL || numElements < 1) - { - LOG_ERROR_MSG(gCtx,"cbCourse failed!"); - return; - } - - for (i = 0; i<numElements; i++) - { - LOG_INFO(gCtx,"Course Updatee[%d/%d]: speed=%f heading=%f climb=%f", + time[i].timestamp, + time[i].year, + month[time[i].month%12], + time[i].day, + time[i].hour, + time[i].minute, + time[i].second); + } + else + { + LOG_INFO(gCtx,"Time Update[%d/%d]: Invalid Date/Time", i+1, - numElements, - course[i].speed, - course[i].heading, - course[i].climb); + numElements); + + } } - } -static void cbAccuracy(const TGNSSAccuracy accuracy[], uint16_t numElements) +static void cbPosition(const TGNSSPosition position[], uint16_t numElements) { int i; - if(accuracy == NULL || numElements < 1) + if(position == NULL || numElements < 1) { - LOG_ERROR_MSG(gCtx,"cbAccuracy failed!"); + LOG_ERROR_MSG(gCtx,"cbPosition failed!"); return; } for (i = 0; i<numElements; i++) { - LOG_INFO(gCtx,"Accuracy Update[%d/%d]: usedSatellites=%d visibleSatellites=%d fixStatus=%d fixTypeBits=0x%08X", + LOG_INFO(gCtx,"Position Update[%d/%d]: timestamp=%llu latitude=%.5f longitude=%.5f altitudeMSL=%.1f hSpeed=%.1f heading=%.1f\n hdop=%.1f usedSatellites=%d sigmaHPosition=%.1f sigmaHSpeed=%.1f sigmaHeading=%.1f fixStatus=%d fixTypeBits=0x%08X", i+1, numElements, - accuracy[i].usedSatellites, - accuracy[i].visibleSatellites, - accuracy[i].fixStatus, - accuracy[i].fixTypeBits); + position[i].timestamp, + position[i].latitude, + position[i].longitude, + position[i].altitudeMSL, + position[i].hSpeed, + position[i].heading, + position[i].hdop, + position[i].usedSatellites, + position[i].sigmaHPosition, + position[i].sigmaHSpeed, + position[i].sigmaHeading, + position[i].fixStatus, + position[i].fixTypeBits); } } @@ -131,7 +134,7 @@ bool checkMajorVersion(int expectedMajor) void init() { - if(!checkMajorVersion(2)) + if(!checkMajorVersion(3)) { exit(EXIT_FAILURE); } @@ -140,11 +143,6 @@ void init() { exit(EXIT_FAILURE); } - - if(!gnssSimpleInit()) - { - exit(EXIT_FAILURE); - } } int main() @@ -157,10 +155,9 @@ int main() LOG_INFO_MSG(gCtx,"Starting gnss-service-client..."); // register for GNSS - gnssSimpleRegisterPositionCallback(&cbPosition); - gnssSimpleRegisterCourseCallback(&cbCourse); - gnssExtendedRegisterAccuracyCallback(&cbAccuracy); - gnssExtendedRegisterSatelliteDetailCallback(&cbSatelliteDetail); + gnssRegisterTimeCallback(&cbTime); + gnssRegisterSatelliteDetailCallback(&cbSatelliteDetail); + gnssRegisterPositionCallback(&cbPosition); // enter endless loop while(1) @@ -169,12 +166,10 @@ int main() } // deregister - gnssSimpleDeregisterPositionCallback(&cbPosition); - gnssSimpleDeregisterCourseCallback(&cbCourse); - gnssExtendedDeregisterAccuracyCallback(&cbAccuracy); - gnssExtendedDeregisterSatelliteDetailCallback(&cbSatelliteDetail); + gnssDeregisterTimeCallback(&cbTime); + gnssDeregisterSatelliteDetailCallback(&cbSatelliteDetail); + gnssDeregisterPositionCallback(&cbPosition); - gnssSimpleDestroy(); gnssDestroy(); return EXIT_SUCCESS; diff --git a/sensors-service/api/sns.h b/sensors-service/api/sns-init.h index 026d6ed..026d6ed 100644 --- a/sensors-service/api/sns.h +++ b/sensors-service/api/sns-init.h diff --git a/sensors-service/src/globals.h b/sensors-service/src/globals.h index 67cadce..c9280f7 100644 --- a/sensors-service/src/globals.h +++ b/sensors-service/src/globals.h @@ -23,7 +23,7 @@ #include <pthread.h> #include <time.h> -#include "sns.h" +#include "sns-init.h" #include "wheel.h" #include "gyroscope.h" #include "vehicle-speed.h" diff --git a/sensors-service/src/sns-use-iphone.c b/sensors-service/src/sns-use-iphone.c index 6201f39..78d9c97 100644 --- a/sensors-service/src/sns-use-iphone.c +++ b/sensors-service/src/sns-use-iphone.c @@ -33,7 +33,7 @@ #include <memory.h> #include "globals.h" -#include "sns.h" +#include "sns-init.h" #include "log.h" #define BUFLEN 256 diff --git a/sensors-service/src/sns-use-replayer.c b/sensors-service/src/sns-use-replayer.c index c78132c..46df7e5 100644 --- a/sensors-service/src/sns-use-replayer.c +++ b/sensors-service/src/sns-use-replayer.c @@ -33,7 +33,7 @@ #include <memory.h> #include "globals.h" -#include "sns.h" +#include "sns-init.h" #include "log.h" #define BUFLEN 256 diff --git a/sensors-service/test/sensors-service-client.c b/sensors-service/test/sensors-service-client.c index e2dc43c..c0b9b1a 100644 --- a/sensors-service/test/sensors-service-client.c +++ b/sensors-service/test/sensors-service-client.c @@ -24,7 +24,7 @@ //include all sns header files here even if they are not yet used. //this helps us to find syntax error during compilation -#include "sns.h" +#include "sns-init.h" #include "acceleration.h" #include "gyroscope.h" #include "inclination.h" |