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

Revision:
17:4927053e120f
Parent:
16:653df0cfe6ee
Child:
18:29b19a25a963
--- a/main.cpp	Wed Dec 12 17:16:08 2012 +0000
+++ b/main.cpp	Wed Dec 12 17:54:04 2012 +0000
@@ -3,6 +3,7 @@
 #include "buffered_serial.h"
 #include "ff.h"
 #include "BMP085.h"
+#include "GPS_parser.h"
 
 I2C i2c(p9, p10); // sda, scl
 BMP085 alt_sensor(i2c);
@@ -15,6 +16,8 @@
 AnalogIn gps_battery(p20);
 AnalogIn mbed_battery(p19);
 
+GPS_Parser nmea_parser;
+
 typedef struct {
     char    line[80];
 } gps_line;
@@ -38,6 +41,7 @@
     while(true) {
         gps_led = 1;
         gps.read_line(buffer);
+        nmea_parser.sample(buffer);
         //pc.puts(buffer);
         // send to log...
         gps_led = 0;
@@ -56,7 +60,7 @@
 
     f_mount(0, &fs);
     f_open(&fp_gps, "0:gps.txt", FA_CREATE_ALWAYS | FA_WRITE);
-    f_open(&fp_sensor, "0:sensor.txt", FA_CREATE_ALWAYS | FA_WRITE);
+    f_open(&fp_sensor, "0:sensors.csv", FA_CREATE_ALWAYS | FA_WRITE);
 
     while(1) {
         log_led = 1;
@@ -87,10 +91,13 @@
 {
     DigitalOut sensor_led(LED2);
     Timer t;
-    t.start();
+    
+    //while(!nmea_parser.get_lock())  Thread::wait(100); // wait for lock
+    
+    t.start(); // start timer after lock
     
     sensor_line *message = mpool_sensor_line.alloc();
-    strcpy(message->line, "Time(s),GPS Battery(V),mbed Battery(V),BMP085 Temperature(C),Pressure,Altitude(ft)\r\n");
+    sprintf(message->line, "Date: %d, Time: %f\r\nTime(s),GPS Battery(V),mbed Battery(V),BMP085 Temperature(C),Pressure,Altitude(ft)\r\n", nmea_parser.get_date(), nmea_parser.get_time());
     queue_sensor_line.put(message);
     
     while(true)
@@ -119,12 +126,19 @@
     }
 }
 
+void parachute_thread(const void *args)
+{
+    
+    while(true) Thread::wait(1000);
+}
+
 int main()
 {
     pc.baud(9600);
     Thread thread(gps_thread, NULL, osPriorityHigh);
     Thread thread2(log_thread, NULL, osPriorityNormal);
     Thread thread3(sensor_thread, NULL, osPriorityNormal);
+    Thread thread4(parachute_thread, NULL, osPriorityRealtime);
 
     while(true) {
     }