From 22b5eb42732c5fb867da24f0a6d6961b1b4d273d Mon Sep 17 00:00:00 2001 From: "tridge60@gmail.com" Date: Sun, 31 Jul 2011 22:34:37 +0000 Subject: [PATCH] GPS: added delay hook for GPS detection this allows for MAVLink to be up during GPS detection git-svn-id: https://arducopter.googlecode.com/svn/trunk@2987 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- libraries/AP_GPS/AP_GPS_Auto.cpp | 5 ++++- libraries/AP_GPS/GPS.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_GPS/AP_GPS_Auto.cpp b/libraries/AP_GPS/AP_GPS_Auto.cpp index b411fe408e..6afc23cb23 100644 --- a/libraries/AP_GPS/AP_GPS_Auto.cpp +++ b/libraries/AP_GPS/AP_GPS_Auto.cpp @@ -37,6 +37,7 @@ void AP_GPS_Auto::init(void) { idleTimeout = 1200; + if (callback == NULL) callback = delay; } // Called the first time that a client tries to kick the GPS to update. @@ -116,6 +117,7 @@ AP_GPS_Auto::_detect(void) _port->flush(); then = millis(); do { + callback(1); if (_port->available()) { then = millis(); _port->read(); @@ -129,6 +131,7 @@ AP_GPS_Auto::_detect(void) // This will normally only be the case where there is no GPS attached. // while (_port->available() < 4) { + callback(1); if ((millis() - then) > 1200) { Serial.print('!'); return NULL; @@ -193,7 +196,7 @@ AP_GPS_Auto::_detect(void) _fs->println_P((const prog_char_t *)_sirf_set_binary); // give the GPS time to react to the settings - delay(100); + callback(100); continue; } else { Serial.print('?'); diff --git a/libraries/AP_GPS/GPS.h b/libraries/AP_GPS/GPS.h index 02d5632b5f..eeff6a5fad 100644 --- a/libraries/AP_GPS/GPS.h +++ b/libraries/AP_GPS/GPS.h @@ -24,6 +24,8 @@ public: /// void update(void); + void (*callback)(unsigned long t); + /// GPS status codes /// /// \note Non-intuitive ordering for legacy reasons