3rd Repo, trying to figure this out.

Dependencies:   LPS25H hts221

Fork of SOFT253_Template_Weather_OS_54 by Stage-1 Students SoCEM

Revision:
75:b44645bbf2d2
Parent:
74:749727490f44
Child:
76:ee1f132e5744
--- a/main.cpp	Mon Apr 24 13:15:51 2017 +0000
+++ b/main.cpp	Tue Apr 25 16:06:35 2017 +0000
@@ -15,6 +15,7 @@
 #include <sstream>
 
 #define SIGNAL_doMeasure 1
+#define SIGNAL_printMessage 2
 #define SWITCH1_RELEASE 90
 #define BUFFER_SIZE 120
  
@@ -29,11 +30,11 @@
 // SENSOR DECLARATIONS
 // MAKE SURE ONE OF THESE IS COMMENTED OUT
 // Real sensor
- LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR);
- HTS221 measurer(I2C_SDA, I2C_SCL);
+// LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR);
+// HTS221 measurer(I2C_SDA, I2C_SCL);
 // Fake sensor
-//FakeBarometer barometer(1029.0, 1031.0);
-//FakeMeasurer measurer(20.0, 25.0, 30.0, 50.0);
+FakeBarometer barometer(1029.0, 1031.0);
+FakeMeasurer measurer(20.0, 25.0, 30.0, 50.0);
 
 //
 // THREADS DECLARATION
@@ -56,7 +57,7 @@
 
 // Logging objects
 std::ostringstream oss;
-MessageLogger logger(loggingThread);
+MessageLogger logger;
 
 // 
 //  Called by a TICKER
@@ -387,6 +388,12 @@
                     printf("    state - <ON|OFF> - Turn sampling on or OFF.\r\n");
                     printf("    logging <ON|OFF> - Turn logging on or OFF.\r\n");
                 }
+                else if(CompareCommands(charPos, "test", 4) == 1)
+                {
+                    //logger.SendError("DIE");
+                    logger.SendMessage("Ur Ded m9");  
+                    //logger.GetMessage();  
+                }
                 // If command not recognized
                 else
                 {
@@ -407,7 +414,7 @@
 
 void LoggingThread()
 {
-     Thread::wait(300000);
+     //Thread::wait(300000);
      // ARRON: TODO
      
      // - Printing messages
@@ -417,6 +424,19 @@
      
      // Some queue system holding lines to print
      // If the queue has something to print, print it.
+     
+     while(true)
+     {
+        Thread::signal_wait(SIGNAL_printMessage);
+            if(logger.GetError())
+            {
+                // Kill EVERYTHING
+            }
+            else if(!logger.GetMessage())
+            {
+            }
+        
+     }
 }
  
 // Main thread
@@ -444,11 +464,12 @@
     loggingThread = new Thread();
     loggingThread->start(LoggingThread);
     
+    logger.SetThread(loggingThread);
     
     printf("Main Thread\n");
-    while(1) 
+    while(true) 
     {
         // Is there a sleep method that could be used instead or waiting and awaking every 3 seconds?
-        Thread::wait(3000);
+        Thread::wait(300);
     }
 } 
\ No newline at end of file