From deef2c00fffc446d894bdd553eeca0749b2d130b Mon Sep 17 00:00:00 2001 From: Tony DiCola Date: Thu, 7 Aug 2014 11:45:27 -0700 Subject: [PATCH] Fix #29 by adjusting interrupt code's serial handling. --- examples/shield_sdlog/shield_sdlog.ino | 30 +++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/examples/shield_sdlog/shield_sdlog.ino b/examples/shield_sdlog/shield_sdlog.ino index 3e92e90..6491318 100644 --- a/examples/shield_sdlog/shield_sdlog.ino +++ b/examples/shield_sdlog/shield_sdlog.ino @@ -140,18 +140,14 @@ void setup() { // Interrupt is called once a millisecond, looks for any new GPS data, and stores it SIGNAL(TIMER0_COMPA_vect) { - char c; - while (mySerial.available()) - { - c = GPS.read(); - // if you want to debug, this is a good time to do it! -#ifdef UDR0 - if (GPSECHO) - if (c) UDR0 = c; - // writing direct to UDR0 is much much faster than Serial.print - // but only one character can be written at a time. -#endif - } + char c = GPS.read(); + // if you want to debug, this is a good time to do it! + #ifdef UDR0 + if (GPSECHO) + if (c) UDR0 = c; + // writing direct to UDR0 is much much faster than Serial.print + // but only one character can be written at a time. + #endif } void useInterrupt(boolean v) { @@ -170,12 +166,12 @@ void useInterrupt(boolean v) { } void loop() { - char c; - while (mySerial.available()) - { - c = GPS.read(); + if (! usingInterrupt) { + // read data from the GPS in the 'main loop' + char c = GPS.read(); + // if you want to debug, this is a good time to do it! if (GPSECHO) - if (c) Serial.print(c); + if (c) Serial.print(c); } // if a sentence is received, we can check the checksum, parse it...