From dc73f9df159e389131bb095d2b4d22df8642095f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 16 Apr 2018 11:00:53 -0700 Subject: gps_ctrl: Replace boost::this_thread::sleep() Use std::this_thread::sleep_for() instead. --- host/lib/usrp/gps_ctrl.cpp | 58 +++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'host/lib/usrp/gps_ctrl.cpp') 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 #include #include +#include +#include #include #include -#include - -#include "boost/tuple/tuple.hpp" +#include +#include 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 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; }; /*********************************************************************** -- cgit v1.2.3