From 37f4a726d616f6b1eae87ed516c510b24a372177 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Wed, 6 Jan 2021 16:31:31 +0100 Subject: [PATCH] Add option to configure the set of used GNSS systems Functionality not implemented yet, see issue #68 for details --- src/ashtech.cpp | 2 +- src/ashtech.h | 2 +- src/emlid_reach.cpp | 2 +- src/emlid_reach.h | 2 +- src/femtomes.cpp | 2 +- src/femtomes.h | 2 +- src/gps_helper.h | 21 ++++++++++++++++++++- src/mtk.cpp | 2 +- src/mtk.h | 2 +- src/sbf.cpp | 2 +- src/sbf.h | 2 +- src/ubx.cpp | 2 +- src/ubx.h | 2 +- 13 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/ashtech.cpp b/src/ashtech.cpp index 76dcf75..b56f455 100644 --- a/src/ashtech.cpp +++ b/src/ashtech.cpp @@ -942,7 +942,7 @@ int GPSDriverAshtech::waitForReply(NMEACommand command, const unsigned timeout) return _command_state == NMEACommandState::received ? 0 : -1; } -int GPSDriverAshtech::configure(unsigned &baudrate, OutputMode output_mode) +int GPSDriverAshtech::configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) { _output_mode = output_mode; _correction_output_activated = false; diff --git a/src/ashtech.h b/src/ashtech.h index 9a2d53d..ad338ce 100644 --- a/src/ashtech.h +++ b/src/ashtech.h @@ -59,7 +59,7 @@ class GPSDriverAshtech : public GPSBaseStationSupport virtual ~GPSDriverAshtech(); - int configure(unsigned &baudrate, OutputMode output_mode) override; + int configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) override; int receive(unsigned timeout) override; diff --git a/src/emlid_reach.cpp b/src/emlid_reach.cpp index c8ddb66..36515d1 100644 --- a/src/emlid_reach.cpp +++ b/src/emlid_reach.cpp @@ -78,7 +78,7 @@ GPSDriverEmlidReach::GPSDriverEmlidReach(GPSCallbackPtr callback, void *callback int -GPSDriverEmlidReach::configure(unsigned &baudrate, OutputMode output_mode) +GPSDriverEmlidReach::configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) { // TODO RTK if (output_mode != OutputMode::GPS) { diff --git a/src/emlid_reach.h b/src/emlid_reach.h index 0b8f05b..9106ef9 100644 --- a/src/emlid_reach.h +++ b/src/emlid_reach.h @@ -147,7 +147,7 @@ class GPSDriverEmlidReach : public GPSHelper virtual ~GPSDriverEmlidReach() = default; int receive(unsigned timeout) override; - int configure(unsigned &baudrate, OutputMode output_mode) override; + int configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) override; private: diff --git a/src/femtomes.cpp b/src/femtomes.cpp index a74f9ce..5c4ee5c 100644 --- a/src/femtomes.cpp +++ b/src/femtomes.cpp @@ -322,7 +322,7 @@ int GPSDriverFemto::writeAckedCommandFemto(const char *command, const char *repl return -1; } -int GPSDriverFemto::configure(unsigned &baudrate, OutputMode output_mode) +int GPSDriverFemto::configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) { if (output_mode != OutputMode::GPS) { diff --git a/src/femtomes.h b/src/femtomes.h index 90b8c28..1533e95 100644 --- a/src/femtomes.h +++ b/src/femtomes.h @@ -148,7 +148,7 @@ class GPSDriverFemto : public GPSHelper virtual ~GPSDriverFemto() = default; int receive(unsigned timeout) override; - int configure(unsigned &baudrate, OutputMode output_mode) override; + int configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) override; private: diff --git a/src/gps_helper.h b/src/gps_helper.h index 614a975..faa8e2d 100644 --- a/src/gps_helper.h +++ b/src/gps_helper.h @@ -161,6 +161,18 @@ class GPSHelper SPI }; + /** + * Bitmask for GPS_1_GNSS and GPS_2_GNSS + * No bits set should keep the receiver's default config + */ + enum class GNSSSystemsMask : int32_t { + ENABLE_GPS = 1 << 0, + ENABLE_SBAS = 1 << 1, + ENABLE_GALILEO = 1 << 2, + ENABLE_BEIDOU = 1 << 3, + ENABLE_GLONASS = 1 << 4 + }; + GPSHelper(GPSCallbackPtr callback, void *callback_user); virtual ~GPSHelper() = default; @@ -169,9 +181,11 @@ class GPSHelper * configure the device * @param baud Input and output parameter: if set to 0, the baudrate will be automatically detected and set to * the detected baudrate. If not 0, a fixed baudrate is used. + * @param output_mode Output protocol + * @param gnssSystems Bit set of GNSS systems to enable, 0 for no change of config * @return 0 on success, <0 otherwise */ - virtual int configure(unsigned &baud, OutputMode output_mode) = 0; + virtual int configure(unsigned &baud, OutputMode output_mode, GNSSSystemsMask gnssSystems) = 0; /** * receive & handle new data from the device @@ -278,3 +292,8 @@ class GPSHelper uint64_t _interval_rate_start{0}; }; + +inline bool operator&(GPSHelper::GNSSSystemsMask a, GPSHelper::GNSSSystemsMask b) +{ + return static_cast(a) & static_cast(b); +} diff --git a/src/mtk.cpp b/src/mtk.cpp index 9dfc366..5fba123 100644 --- a/src/mtk.cpp +++ b/src/mtk.cpp @@ -55,7 +55,7 @@ GPSDriverMTK::GPSDriverMTK(GPSCallbackPtr callback, void *callback_user, sensor_ } int -GPSDriverMTK::configure(unsigned &baudrate, OutputMode output_mode) +GPSDriverMTK::configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) { if (output_mode != OutputMode::GPS) { GPS_WARN("MTK: Unsupported Output Mode %i", (int)output_mode); diff --git a/src/mtk.h b/src/mtk.h index 557774b..760a1c6 100644 --- a/src/mtk.h +++ b/src/mtk.h @@ -92,7 +92,7 @@ class GPSDriverMTK : public GPSHelper virtual ~GPSDriverMTK() = default; int receive(unsigned timeout) override; - int configure(unsigned &baudrate, OutputMode output_mode) override; + int configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) override; private: /** diff --git a/src/sbf.cpp b/src/sbf.cpp index c0b80a5..3d8d120 100644 --- a/src/sbf.cpp +++ b/src/sbf.cpp @@ -73,7 +73,7 @@ GPSDriverSBF::~GPSDriverSBF() } int -GPSDriverSBF::configure(unsigned &baudrate, OutputMode output_mode) +GPSDriverSBF::configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) { _configured = false; diff --git a/src/sbf.h b/src/sbf.h index a63d572..c230147 100644 --- a/src/sbf.h +++ b/src/sbf.h @@ -316,7 +316,7 @@ class GPSDriverSBF : public GPSBaseStationSupport virtual ~GPSDriverSBF() override; int receive(unsigned timeout) override; - int configure(unsigned &baudrate, OutputMode output_mode) override; + int configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) override; int reset(GPSRestartType restart_type) override; private: diff --git a/src/ubx.cpp b/src/ubx.cpp index 04c66fd..8bbd26b 100644 --- a/src/ubx.cpp +++ b/src/ubx.cpp @@ -89,7 +89,7 @@ GPSDriverUBX::~GPSDriverUBX() } int -GPSDriverUBX::configure(unsigned &baudrate, OutputMode output_mode) +GPSDriverUBX::configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) { _configured = false; _output_mode = output_mode; diff --git a/src/ubx.h b/src/ubx.h index d9f3048..160ea0f 100644 --- a/src/ubx.h +++ b/src/ubx.h @@ -826,7 +826,7 @@ class GPSDriverUBX : public GPSBaseStationSupport virtual ~GPSDriverUBX(); - int configure(unsigned &baudrate, OutputMode output_mode) override; + int configure(unsigned &baudrate, OutputMode output_mode, GNSSSystemsMask gnssSystems) override; int receive(unsigned timeout) override; int reset(GPSRestartType restart_type) override;