From 77fe3484374837cecf2dd8387f3a62b1d5c832f9 Mon Sep 17 00:00:00 2001 From: driverblock Date: Wed, 2 Aug 2017 11:24:18 -0400 Subject: [PATCH] Add hardware serial locus erase example Added GPS_HardwareSerial_LOCUS_Erase. Increased timeout value on waitForSentence function updated library version to 1.0.3 --- Adafruit_GPS.cpp | 2 +- Adafruit_GPS.h | 2 +- .../GPS_HardwareSerial_LOCUS_DumpBasic.ino | 2 +- .../GPS_HardwareSerial_LOCUS_Erase.ino | 69 +++++++++++++++++++ library.properties | 2 +- 5 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 examples/GPS_HardwareSerial_LOCUS_Erase/GPS_HardwareSerial_LOCUS_Erase.ino diff --git a/Adafruit_GPS.cpp b/Adafruit_GPS.cpp index 76c1a94..9e7c713 100755 --- a/Adafruit_GPS.cpp +++ b/Adafruit_GPS.cpp @@ -411,7 +411,7 @@ boolean Adafruit_GPS::waitForSentence(const char *wait4me, uint8_t max) { str[19] = 0; i++; - if (strstr(str, wait4me)) + if (strstr(str, wait4me)) return true; } } diff --git a/Adafruit_GPS.h b/Adafruit_GPS.h index 2ee02ae..dc9cb71 100755 --- a/Adafruit_GPS.h +++ b/Adafruit_GPS.h @@ -88,7 +88,7 @@ All text above must be included in any redistribution #define PGCMD_NOANTENNA "$PGCMD,33,0*6D" // how long to wait when we're looking for a response -#define MAXWAITSENTENCE 5 +#define MAXWAITSENTENCE 10 #if ARDUINO >= 100 #include "Arduino.h" diff --git a/examples/GPS_HardwareSerial_LOCUS_DumpBasic/GPS_HardwareSerial_LOCUS_DumpBasic.ino b/examples/GPS_HardwareSerial_LOCUS_DumpBasic/GPS_HardwareSerial_LOCUS_DumpBasic.ino index f15477b..9e1dec8 100644 --- a/examples/GPS_HardwareSerial_LOCUS_DumpBasic/GPS_HardwareSerial_LOCUS_DumpBasic.ino +++ b/examples/GPS_HardwareSerial_LOCUS_DumpBasic/GPS_HardwareSerial_LOCUS_DumpBasic.ino @@ -36,7 +36,7 @@ void setup() // also spit it out Serial.begin(115200); delay(1000); - Serial.println("Adafruit GPS logging start test!"); + Serial.println("Adafruit GPS logging data dump!”); // 9600 NMEA is the default baud rate for MTK - some use 4800 GPS.begin(9600); diff --git a/examples/GPS_HardwareSerial_LOCUS_Erase/GPS_HardwareSerial_LOCUS_Erase.ino b/examples/GPS_HardwareSerial_LOCUS_Erase/GPS_HardwareSerial_LOCUS_Erase.ino new file mode 100644 index 0000000..156ebbd --- /dev/null +++ b/examples/GPS_HardwareSerial_LOCUS_Erase/GPS_HardwareSerial_LOCUS_Erase.ino @@ -0,0 +1,69 @@ +// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver +// +// This code erases the LOCUS built-in datalogger storage +// +// Tested and works great with the Adafruit Ultimate GPS module +// using MTK33x9 chipset +// ------> http://www.adafruit.com/products/746 +// Pick one up today at the Adafruit electronics shop +// and help support open source hardware & software! -ada + +//This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos + +#include + +// Connect the GPS Power pin to 5V +// Connect the GPS Ground pin to ground +// If using software serial (sketch example default): +// Connect the GPS TX (transmit) pin to Digital 8 +// Connect the GPS RX (receive) pin to Digital 7 +// If using hardware serial: +// Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0) +// Connect the GPS RX (receive) pin to matching TX1 (Digital 1) + +// If using software serial, keep these lines enabled +// (you can change the pin numbers to match your wiring): + +// what's the name of the hardware serial port? +#define GPSSerial Serial1 + +// Connect to the GPS on the hardware port +Adafruit_GPS GPS(&GPSSerial); + +// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console +// Set to 'true' if you want to debug and listen to the raw GPS sentences +#define GPSECHO true + + +void setup() +{ + while (!Serial) ; //wait for serial port on Leonardo + + // connect at 115200 so we can read the GPS fast enuf and + // also spit it out + Serial.begin(115200); + Serial.println("Adafruit GPS erase FLASH!"); + + // 9600 NMEA is the default baud rate for MTK + GPS.begin(9600); + + GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF); + + Serial.println("This code will ERASE the data log stored in the FLASH - Permanently!"); + Serial.print("Are you sure you want to do this? [Y/N]: "); + while (Serial.read() != 'Y') delay(10); + Serial.println("\nERASING! UNPLUG YOUR ARDUINO WITHIN 5 SECONDS IF YOU DIDNT MEAN TO!"); + delay(5000); + GPS.sendCommand(PMTK_LOCUS_ERASE_FLASH); + Serial.println("Erased"); +} + +void loop() // run over and over again +{ + if (GPSSerial.available()) { + char c = GPSSerial.read(); + if (GPSECHO) + Serial.write(c); + } +} + diff --git a/library.properties b/library.properties index ebc7483..69416b6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit GPS Library -version=1.0.2 +version=1.0.3 author=Adafruit maintainer=Adafruit sentence=An interrupt-based GPS library for no-parsing-required use