3rd Repo, trying to figure this out.
Fork of SOFT253_Template_Weather_OS_54 by
Diff: main.cpp
- Revision:
- 74:749727490f44
- Parent:
- 73:cfad270d2f2c
- Child:
- 75:b44645bbf2d2
--- a/main.cpp Fri Apr 21 19:55:45 2017 +0000 +++ b/main.cpp Mon Apr 24 13:15:51 2017 +0000 @@ -1,14 +1,18 @@ #include "mbed.h" #include "rtos.h" +#include "hts221.h" +#include "LPS25H.h" + +#include "CircularArray.h" +#include "FakeSensor.h" +#include "MessageLogger.h" + #include <string.h> #include <stdio.h> #include <ctype.h> -#include "hts221.h" -#include "LPS25H.h" -#include "CircularArray.h" -#include "FakeSensor.h" #include <iostream> +#include <sstream> #define SIGNAL_doMeasure 1 #define SWITCH1_RELEASE 90 @@ -37,6 +41,7 @@ Thread *produceThread; Thread *measureThread; Thread *consumeThread; +Thread *loggingThread; Ticker timer; Ticker realTimeDate; // @@ -45,9 +50,14 @@ Mail<Measure, 16> mail_box; CircularArray buffer(BUFFER_SIZE); LocalDate *localDate; +//Mail<> bool logging = true; float sampleRate = 1; +// Logging objects +std::ostringstream oss; +MessageLogger logger(loggingThread); + // // Called by a TICKER // Adds 1 second every second to the clock @@ -147,6 +157,7 @@ } return 1; } + // // Reads commands through PUTTY and 'consumes the data' accordingly // A.K.A. Consumer Thread @@ -191,7 +202,7 @@ //Check if it's a "LIST ALL" command if(CompareCommands(charPos, "all",3) == 1) { - printf("\r\n Printing all measures performed so far: \r\n"); + printf("\r\nPrinting all measures performed so far: \r\n"); // Changed to use circular buffer rather than list buffer buffer.readAll(); @@ -201,7 +212,7 @@ else if(strtol(charPos,NULL,10) != 0) { int num = atoi(charPos); - printf("\r\n Printing %i measures: \r\n",num); + printf("\r\nPrinting %i measures: \r\n",num); // Changed to use circular buffer rather than list buffer buffer.readX(num); @@ -219,7 +230,7 @@ //Check if it's a "DELETE ALL" command if(CompareCommands(charPos,"all",3) == 1) { - printf("\r\n Deleting all measures performed so far: \r\n"); + printf("\r\nDeleting all measures performed so far: \r\n"); // Changed to use circular buffer rather than list buffer buffer.deleteAll(); @@ -396,6 +407,7 @@ void LoggingThread() { + Thread::wait(300000); // ARRON: TODO // - Printing messages @@ -429,6 +441,9 @@ measureThread->start(MeasureThread); consumeThread = new Thread(); consumeThread->start(ConsumeThread); + loggingThread = new Thread(); + loggingThread->start(LoggingThread); + printf("Main Thread\n"); while(1)