K64F based data logger for GPS (ublox MAX M8Q) & 6 Axis Sensor (FXOS8700Q) - Outputs to SD + UDP - Uses FRDM K64F + ublox "Cellular and positioning shield" (3G version)

Dependencies:   MAX_M8Q_Capture EthernetInterface FXOS8700Q SDFileSystem eCompass_FPU_Lib mbed-rtos mbed

Revision:
2:bcd60a69583f
Parent:
0:77857a36b4ff
--- a/main.cpp	Fri Mar 27 08:40:00 2015 +0000
+++ b/main.cpp	Thu Apr 02 20:09:44 2015 +0000
@@ -1,54 +1,53 @@
 #include "mbed.h"
 #include "meta.h"
+#include "debug.h"
 
 extern int eCompass_init(void);
-
+extern int EthernetInit(void);
 
 Serial pc(USBTX, USBRX);
-
+DigitalOut ledr(LED_RED,1);
+DigitalOut ledb(LED_BLUE,1);
+DigitalOut ledg(LED_GREEN,1);
 
 int main(void)
 {
-    printf("Setting up eComapss\r\n");   
-    if (eCompass_init())
-        printf("Issue setting up compass\r\n");
+    ledr=0;     // Status that project has started (LED=Red)
     
-    while(1){    
+    // Wait for SD Card to stabalise
+    wait(5);
+            
+    D(printf("Setting up eComapss\r\n"));   
+    if (eCompass_init() != NULL)
+        D(printf("##!!## Issue setting up compass\r\n"));
+
+    D(printf("Setting up Ethernet Port\r\n"));
+    if (EthernetInit() != NULL)
+        D(printf("##!!## Issue setting up Ethernet Port\r\n"));
+    
+    while(1){
+        
+        ledg=0;      // Status that main loop was reached
+            
         printf("Creating MetaData Object\r\n");
         MetaData _metadata;
         
-        printf("Creating CSV Output");
+        D(printf("Creating CSV Output\r\n"));
         _metadata.outputToCVSstring();
     
-        printf("Save to CSV file");
-        _metadata.appendSDcard();
+        ledb=!ledb;      // Status that sensor data was gathered
+        
+        D(printf("Save to CSV file\r\n"));
+        if(_metadata.appendSDcard() != NULL)
+            D(printf("##!!## Issue writing to SD Card\r\n"));
         
-        printf("###done####\r\n");
-        
-        wait(1);
+        D(printf("Transmit to UDP\r\n"));
+        if(_metadata.transmitUDP() != NULL)
+            D(printf("##!!## Issue transmitting over UDP\r\n"));
+            
+        printf("###done####\r\n\n\n\n\n\n\n");
+
     }
     
-//    while(1);
-}
-
-/*
-
-- Init routines for 6axis + GPS (none) + UDP + Filesystem
-
-- Wait some time to let system settle
-
---> (loop re-entry)
-- Create new MetaData object that goes off and samples 6axis and all GPS components (mainly RMC message)
---- In object code (constructor), include the code for 6axis + GPS
-- Create string in CSV format from MetaData
-
-#Improvement - add push button/led to start/stop data logging
-- Append string to file
-- Create new UDP frame from string
-- Wait for 1 sec, loop to re-entry point.
-
-*/
-
-/* ### Error Log ###
-e001 - GPS/Compass Function did not complete on MetaData class constructor
- */
\ No newline at end of file
+    return -1;
+}
\ No newline at end of file