add gps character count.

this problem happens when the mtk ends up in nmea mode at 10hz. there is no 50ms window of no activity
This commit is contained in:
Michael Oborne 2011-12-31 13:05:33 +08:00
parent e66e21cf20
commit 6a279138e9

View File

@ -99,6 +99,7 @@ AP_GPS_Auto::_detect(void)
unsigned long then; unsigned long then;
int fingerprint[4]; int fingerprint[4];
int tries; int tries;
int charcount;
GPS *gps; GPS *gps;
// //
@ -114,14 +115,16 @@ AP_GPS_Auto::_detect(void)
// XXX We can detect babble by counting incoming characters, but // XXX We can detect babble by counting incoming characters, but
// what would we do about it? // what would we do about it?
// //
charcount = 0;
_port->flush(); _port->flush();
then = millis(); then = millis();
do { do {
if (_port->available()) { if (_port->available()) {
then = millis(); then = millis();
_port->read(); _port->read();
charcount++;
} }
} while ((millis() - then) < 50); } while ((millis() - then) < 50 && charcount < 5000);
// //
// Collect four characters to fingerprint a device // Collect four characters to fingerprint a device