diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-04-16 11:00:53 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-04-17 16:48:53 -0700 |
commit | dc73f9df159e389131bb095d2b4d22df8642095f (patch) | |
tree | 1111f3cdedf31a9aae35fa520a7f3b10171d0728 /host/lib/usrp/gps_ctrl.cpp | |
parent | 27f5e9151c1621f25948a579c1cf7aa0e156e323 (diff) | |
download | uhd-dc73f9df159e389131bb095d2b4d22df8642095f.tar.gz uhd-dc73f9df159e389131bb095d2b4d22df8642095f.tar.bz2 uhd-dc73f9df159e389131bb095d2b4d22df8642095f.zip |
gps_ctrl: Replace boost::this_thread::sleep()
Use std::this_thread::sleep_for() instead.
Diffstat (limited to 'host/lib/usrp/gps_ctrl.cpp')
-rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 58 |
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; }; /*********************************************************************** |