Fix #29 by adjusting interrupt code's serial handling.

This commit is contained in:
Tony DiCola 2014-08-07 11:45:27 -07:00
parent 91295fa8e2
commit deef2c00ff
1 changed files with 13 additions and 17 deletions

View File

@ -140,10 +140,7 @@ void setup() {
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it // Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect) { SIGNAL(TIMER0_COMPA_vect) {
char c; char c = GPS.read();
while (mySerial.available())
{
c = GPS.read();
// if you want to debug, this is a good time to do it! // if you want to debug, this is a good time to do it!
#ifdef UDR0 #ifdef UDR0
if (GPSECHO) if (GPSECHO)
@ -152,7 +149,6 @@ SIGNAL(TIMER0_COMPA_vect) {
// but only one character can be written at a time. // but only one character can be written at a time.
#endif #endif
} }
}
void useInterrupt(boolean v) { void useInterrupt(boolean v) {
if (v) { if (v) {
@ -170,10 +166,10 @@ void useInterrupt(boolean v) {
} }
void loop() { void loop() {
char c; if (! usingInterrupt) {
while (mySerial.available()) // read data from the GPS in the 'main loop'
{ char c = GPS.read();
c = GPS.read(); // if you want to debug, this is a good time to do it!
if (GPSECHO) if (GPSECHO)
if (c) Serial.print(c); if (c) Serial.print(c);
} }