aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/gps_ctrl.cpp58
1 files changed, 32 insertions, 26 deletions
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp
index bca62204c..a50261851 100644
--- a/host/lib/usrp/gps_ctrl.cpp
+++ b/host/lib/usrp/gps_ctrl.cpp
@@ -18,17 +18,27 @@
#include <boost/format.hpp>
#include <boost/regex.hpp>
#include <boost/thread/mutex.hpp>
+#include <boost/date_time.hpp>
+#include <boost/tuple/tuple.hpp>
#include <ctime>
#include <string>
-#include <boost/date_time.hpp>
-
-#include "boost/tuple/tuple.hpp"
+#include <thread>
+#include <chrono>
using namespace uhd;
using namespace boost::posix_time;
using namespace boost::algorithm;
using namespace boost::this_thread;
+namespace {
+ constexpr int GPS_COMM_TIMEOUT_MS = 1300;
+ constexpr int GPS_NMEA_NORMAL_FRESHNESS = 1000;
+ constexpr int GPS_SERVO_FRESHNESS = 1000;
+ constexpr int GPS_LOCK_FRESHNESS = 2500;
+ constexpr int GPS_TIMEOUT_DELAY_MS = 200;
+ constexpr int GPSDO_COMMAND_DELAY_MS = 200;
+}
+
/*!
* A control for GPSDO devices
*/
@@ -90,7 +100,7 @@ private:
break;
}
- sleep(boost::posix_time::milliseconds(1));
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
now = boost::get_system_time();
}
@@ -293,22 +303,24 @@ public:
private:
void init_gpsdo(void) {
- //issue some setup stuff so it spits out the appropriate data
- //none of these should issue replies so we don't bother looking for them
- //we have to sleep between commands because the JL device, despite not acking, takes considerable time to process each command.
- sleep(milliseconds(GPSDO_COMMAND_DELAY_MS));
- _send("SYST:COMM:SER:ECHO OFF\r\n");
- sleep(milliseconds(GPSDO_COMMAND_DELAY_MS));
- _send("SYST:COMM:SER:PRO OFF\r\n");
- sleep(milliseconds(GPSDO_COMMAND_DELAY_MS));
- _send("GPS:GPGGA 1\r\n");
- sleep(milliseconds(GPSDO_COMMAND_DELAY_MS));
- _send("GPS:GGAST 0\r\n");
- sleep(milliseconds(GPSDO_COMMAND_DELAY_MS));
- _send("GPS:GPRMC 1\r\n");
- sleep(milliseconds(GPSDO_COMMAND_DELAY_MS));
- _send("SERV:TRAC 1\r\n");
- sleep(milliseconds(GPSDO_COMMAND_DELAY_MS));
+ //issue some setup stuff so it spits out the appropriate data
+ //none of these should issue replies so we don't bother looking for them
+ //we have to sleep between commands because the JL device, despite not
+ //acking, takes considerable time to process each command.
+ const std::vector<std::string> init_cmds = {
+ "SYST:COMM:SER:ECHO OFF\r\n",
+ "SYST:COMM:SER:PRO OFF\r\n",
+ "GPS:GPGGA 1\r\n",
+ "GPS:GGAST 0\r\n",
+ "GPS:GPRMC 1\r\n",
+ "SERV:TRAC 1\r\n"
+ };
+
+ for (const auto& cmd : init_cmds) {
+ _send(cmd);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(GPSDO_COMMAND_DELAY_MS));
+ }
}
//helper function to retrieve a field from an NMEA sentence
@@ -408,12 +420,6 @@ private:
GPS_TYPE_NONE
} _gps_type;
- static const int GPS_COMM_TIMEOUT_MS = 1300;
- static const int GPS_NMEA_NORMAL_FRESHNESS = 1000;
- static const int GPS_SERVO_FRESHNESS = 1000;
- static const int GPS_LOCK_FRESHNESS = 2500;
- static const int GPS_TIMEOUT_DELAY_MS = 200;
- static const int GPSDO_COMMAND_DELAY_MS = 200;
};
/***********************************************************************