aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-09-22 11:34:58 -0700
committerJosh Blum <josh@joshknows.com>2011-09-28 10:32:05 -0700
commit0d9421b7ab57471d0bb223117413d01ac8299240 (patch)
tree7dddf373f20442d4945ca89c968d35af1a5c3402 /host
parent80827397048ee8fcb7e1a14b3a0030b10eb554d2 (diff)
downloaduhd-0d9421b7ab57471d0bb223117413d01ac8299240.tar.gz
uhd-0d9421b7ab57471d0bb223117413d01ac8299240.tar.bz2
uhd-0d9421b7ab57471d0bb223117413d01ac8299240.zip
gps: use absolute timeout for communication
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/gps_ctrl.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp
index 96cb76ffc..c645d2948 100644
--- a/host/lib/usrp/gps_ctrl.cpp
+++ b/host/lib/usrp/gps_ctrl.cpp
@@ -55,8 +55,8 @@ public:
sleep(milliseconds(FIREFLY_STUPID_DELAY_MS));
//then we loop until we either timeout, or until we get a response that indicates we're a JL device
- int timeout = GPS_TIMEOUT_TRIES;
- while(timeout--) {
+ const boost::system_time comm_timeout = boost::get_system_time() + milliseconds(GPS_COMM_TIMEOUT_MS);
+ while(boost::get_system_time() < comm_timeout) {
reply = _recv();
if(reply.find("Command Error") != std::string::npos) {
gps_type = GPS_TYPE_JACKSON_LABS;
@@ -64,7 +64,7 @@ public:
}
else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response
else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate
- sleep(milliseconds(200));
+ sleep(milliseconds(GPS_TIMEOUT_DELAY_MS));
}
if((i_heard_some_nmea) && (gps_type != GPS_TYPE_JACKSON_LABS)) gps_type = GPS_TYPE_GENERIC_NMEA;
@@ -156,8 +156,8 @@ private:
_flush(); //flush all input before waiting for a message
- int timeout = GPS_TIMEOUT_TRIES;
- while(timeout--) {
+ const boost::system_time comm_timeout = boost::get_system_time() + milliseconds(GPS_COMM_TIMEOUT_MS);
+ while(boost::get_system_time() < comm_timeout) {
reply = _recv();
if(reply.substr(0, 6) == msgtype)
return reply;
@@ -263,7 +263,7 @@ private:
GPS_TYPE_NONE
} gps_type;
- static const int GPS_TIMEOUT_TRIES = 10;
+ static const int GPS_COMM_TIMEOUT_MS = 1500;
static const int GPS_TIMEOUT_DELAY_MS = 200;
static const int FIREFLY_STUPID_DELAY_MS = 200;
};