Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new parameter for GNSS system selection #69

Merged
merged 3 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/ashtech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,9 @@ 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, const GPSConfig &config)
{
_output_mode = output_mode;
_output_mode = config.output_mode;
_correction_output_activated = false;
_configure_done = false;

Expand Down Expand Up @@ -1069,7 +1069,7 @@ int GPSDriverAshtech::configure(unsigned &baudrate, OutputMode output_mode)
// Enable dual antenna mode (2: both antennas are L1/L2 GNSS capable, flex mode, avoids the need to determine
// the baseline length through a prior calibration stage)
// Needs to be set before other commands
const bool use_dual_mode = output_mode == OutputMode::GPS && _board == AshtechBoard::trimble_mb_two;
const bool use_dual_mode = _output_mode == OutputMode::GPS && _board == AshtechBoard::trimble_mb_two;

if (use_dual_mode) {
ASH_DEBUG("Enabling DUO mode");
Expand Down Expand Up @@ -1118,7 +1118,7 @@ int GPSDriverAshtech::configure(unsigned &baudrate, OutputMode output_mode)
}


if (output_mode == OutputMode::RTCM && _board == AshtechBoard::trimble_mb_two) {
if (_output_mode == OutputMode::RTCM && _board == AshtechBoard::trimble_mb_two) {
SurveyInStatus status{};
status.latitude = status.longitude = (double)NAN;
status.altitude = NAN;
Expand Down
2 changes: 1 addition & 1 deletion src/ashtech.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class GPSDriverAshtech : public GPSBaseStationSupport

virtual ~GPSDriverAshtech();

int configure(unsigned &baudrate, OutputMode output_mode) override;
int configure(unsigned &baudrate, const GPSConfig &config) override;

int receive(unsigned timeout) override;

Expand Down
6 changes: 3 additions & 3 deletions src/emlid_reach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ GPSDriverEmlidReach::GPSDriverEmlidReach(GPSCallbackPtr callback, void *callback


int
GPSDriverEmlidReach::configure(unsigned &baudrate, OutputMode output_mode)
GPSDriverEmlidReach::configure(unsigned &baudrate, const GPSConfig &config)
{
// TODO RTK
if (output_mode != OutputMode::GPS) {
GPS_WARN("EMLIDREACH: Unsupported Output Mode %i", (int)output_mode);
if (config.output_mode != OutputMode::GPS) {
GPS_WARN("EMLIDREACH: Unsupported Output Mode %i", (int)config.output_mode);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/emlid_reach.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, const GPSConfig &config) override;

private:

Expand Down
6 changes: 3 additions & 3 deletions src/femtomes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ int GPSDriverFemto::writeAckedCommandFemto(const char *command, const char *repl
return -1;
}

int GPSDriverFemto::configure(unsigned &baudrate, OutputMode output_mode)
int GPSDriverFemto::configure(unsigned &baudrate, const GPSConfig &config)
{

if (output_mode != OutputMode::GPS) {
FEMTO_DEBUG("Femto: Unsupported Output Mode %i", (int)output_mode);
if (config.output_mode != OutputMode::GPS) {
FEMTO_DEBUG("Femto: Unsupported Output Mode %i", (int)config.output_mode);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/femtomes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, const GPSConfig &config) override;

private:

Expand Down
26 changes: 25 additions & 1 deletion src/gps_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ 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 {
jbeyerstedt marked this conversation as resolved.
Show resolved Hide resolved
RECEIVER_DEFAULTS = 0,
ENABLE_GPS = 1 << 0,
ENABLE_SBAS = 1 << 1,
ENABLE_GALILEO = 1 << 2,
ENABLE_BEIDOU = 1 << 3,
ENABLE_GLONASS = 1 << 4
};

struct GPSConfig {
OutputMode output_mode;
GNSSSystemsMask gnss_systems;
};


GPSHelper(GPSCallbackPtr callback, void *callback_user);
virtual ~GPSHelper() = default;
Expand All @@ -169,9 +187,10 @@ 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 config GPS Config
* @return 0 on success, <0 otherwise
*/
virtual int configure(unsigned &baud, OutputMode output_mode) = 0;
virtual int configure(unsigned &baud, const GPSConfig &config) = 0;

/**
* receive & handle new data from the device
Expand Down Expand Up @@ -278,3 +297,8 @@ class GPSHelper

uint64_t _interval_rate_start{0};
};

inline bool operator&(GPSHelper::GNSSSystemsMask a, GPSHelper::GNSSSystemsMask b)
{
return static_cast<int32_t>(a) & static_cast<int32_t>(b);
}
6 changes: 3 additions & 3 deletions src/mtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ GPSDriverMTK::GPSDriverMTK(GPSCallbackPtr callback, void *callback_user, sensor_
}

int
GPSDriverMTK::configure(unsigned &baudrate, OutputMode output_mode)
GPSDriverMTK::configure(unsigned &baudrate, const GPSConfig &config)
{
if (output_mode != OutputMode::GPS) {
GPS_WARN("MTK: Unsupported Output Mode %i", (int)output_mode);
if (config.output_mode != OutputMode::GPS) {
GPS_WARN("MTK: Unsupported Output Mode %i", (int)config.output_mode);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/mtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, const GPSConfig &config) override;

private:
/**
Expand Down
6 changes: 3 additions & 3 deletions src/sbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ GPSDriverSBF::~GPSDriverSBF()
}

int
GPSDriverSBF::configure(unsigned &baudrate, OutputMode output_mode)
GPSDriverSBF::configure(unsigned &baudrate, const GPSConfig &config)
{
_configured = false;

setBaudrate(SBF_TX_CFG_PRT_BAUDRATE);
baudrate = SBF_TX_CFG_PRT_BAUDRATE;

_output_mode = output_mode;
_output_mode = config.output_mode;

if (output_mode != OutputMode::RTCM) {
if (_output_mode != OutputMode::RTCM) {
sendMessage(SBF_CONFIG_FORCE_INPUT);
}

Expand Down
2 changes: 1 addition & 1 deletion src/sbf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, const GPSConfig &config) override;
int reset(GPSRestartType restart_type) override;

private:
Expand Down
Loading