Generation 3 of the Harp project

Dependencies:   Servo TMP36 GZ buffered-serial1 chan_fatfs_sd nmea_parser watchdog mbed-rtos mbed

Fork of HARP2 by Tyler Weaver

Files at this revision

API Documentation at this revision

Comitter:
tylerjw
Date:
Thu Feb 23 04:24:23 2012 +0000
Parent:
3:9cba44dd2f2b
Child:
5:8444ec4245e7
Commit message:
openLog library and implementation in gps library

Changed in this revision

GPS/GPS.cpp Show annotated file Show diff for this revision Revisions of this file
GPS/GPS.h Show annotated file Show diff for this revision Revisions of this file
openLog/.lib Show annotated file Show diff for this revision Revisions of this file
openLog/openLog.cpp Show annotated file Show diff for this revision Revisions of this file
openLog/openLog.h Show annotated file Show diff for this revision Revisions of this file
--- a/GPS/GPS.cpp	Wed Feb 22 05:24:47 2012 +0000
+++ b/GPS/GPS.cpp	Thu Feb 23 04:24:23 2012 +0000
@@ -20,9 +20,9 @@
 
     dec_longitude = 0.0;
     dec_latitude = 0.0;
-    
+
     gll_status = ' ';
-    
+
     course_t = 0.0; // ground speed true
     course_t_unit = ' ';
     course_m = 0.0; // magnetic
@@ -30,8 +30,25 @@
     speed_k_unit = ' ';
     speed_km = 0.0; // speek km/hr
     speed_km_unit = ' ';
+#ifdef OPEN_LOG
+    is_logging = false;
+#endif
 }
 
+#ifdef OPEN_LOG
+void init_log(PinName tx, PinName rx, PinName reset_pin) : _openLog(tx, rx, reset_pin) {
+    is_logging = true;
+}
+
+void new_file(void) {
+    _openLog.newFile();
+}
+
+void stop_log(void) {
+    is_logging = false;
+}
+#endif
+
 float GPS::nmea_to_dec(float deg_coord, char nsew) {
     int degree = (int)(deg_coord/100);
     float minutes = deg_coord - degree*100;
@@ -49,6 +66,12 @@
     while (_gps.readable()) {
         getline();
 
+#ifdef OPEN_LOG
+        if (is_logging) {
+            _openLog.write(msg);
+        }
+#endif
+
         // Check if it is a GPGGA msg (matches both locked and non-locked msg)
         if (sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f,%c", &utc_time, &nmea_latitude, &ns, &nmea_longitude, &ew, &lock, &satelites, &hdop, &msl_altitude, &msl_units) >= 1) {
             line_parsed = GGA;
--- a/GPS/GPS.h	Wed Feb 22 05:24:47 2012 +0000
+++ b/GPS/GPS.h	Thu Feb 23 04:24:23 2012 +0000
@@ -1,30 +1,12 @@
-/* mbed EM-406 GPS Module Library
- * Copyright (c) 2008-2010, sford
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
 #include "mbed.h"
 
 #ifndef MBED_GPS_H
 #define MBED_GPS_H
 
+#ifdef OPEN_LOG
+#include "openLog.h"
+#endif
+
 #define NO_LOCK     1
 #define NOT_PARSED  2
 #define GGA         3
@@ -56,6 +38,11 @@
     float get_speed_km();
     int get_satelites();
     
+#ifdef OPEN_LOG
+    void init_log(PinName tx, PinName rx, PinName reset_pin);
+    void new_file(void);
+    void stop_log(void);
+#endif    
     
 private:
     float nmea_to_dec(float, char);
@@ -64,7 +51,10 @@
     
     Serial _gps;
     char msg[256];
-    
+    bool is_logging;
+#ifdef OPEN_LOG
+    Logger _openLog;
+#endif
     // calculated values
     float dec_longitude;
     float dec_latitude;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openLog/.lib	Thu Feb 23 04:24:23 2012 +0000
@@ -0,0 +1,1 @@
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openLog/openLog.cpp	Thu Feb 23 04:24:23 2012 +0000
@@ -0,0 +1,17 @@
+#include "openLog.h"
+
+Logger::Logger(PinName tx, PinName rx, PinName reset) : _openLog(tx, rx), _reset_pin(reset) {
+    _openLog.baud(9600);
+    _reset_pin.write(1);
+}
+
+void Logger::newFile(void) {
+    _reset_pin = 0;
+}
+
+int Logger::write(char* data) {
+    if(_reset_pin == 0) // if reset pin was just set
+        _reset_pin = 1;
+    
+    _openLog.printf(data);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openLog/openLog.h	Thu Feb 23 04:24:23 2012 +0000
@@ -0,0 +1,18 @@
+#ifndef OPEN_LOG
+#define OPEN_LOG
+
+#include "mbed.h"
+
+class Logger {
+public:
+
+    Logger(PinName tx, PinName rx, PinName reset);
+
+    void newFile(void);
+    int write(char*);
+
+private:
+    Serial _openLog;
+    DigitalOut _reset_pin;
+};
+#endif
\ No newline at end of file