Repo. for the ELEC351 Coursework - Oliver Thompson
Dependencies: BMP280 ELEC350-Practicals-FZ429- TextLCD watchdog_RTOS BME280 ntp-client
Diff: SerialComms.hpp
- Revision:
- 9:654e14de9d74
- Parent:
- 8:7d218affea71
- Child:
- 10:08c366434f2b
--- a/SerialComms.hpp Fri Nov 30 13:15:30 2018 +0000 +++ b/SerialComms.hpp Fri Nov 30 15:01:03 2018 +0000 @@ -1,14 +1,23 @@ #include "mbed.h" +#include <vector> +#define ERROR_LCD_EXIT 1 +#define ERROR_SERIAL_EXIT 2 +#define ERROR_SD_EXIT 3 +#define ERROR_NET_EXIT 4 +#define ERROR_SAMPLER_EXIT 5 + +//enum ErrorCodes {ERROR_LCD_EXIT,ERROR_SERIAL_EXIT,ERROR_SD_EXIT,ERROR_NET_EXIT}; class Serialcomms { private: float fTemp; //current temperature of sensor float fPressure; //current pressure of sensor - float fLDR; //current light level from LDR + float fLDR; //current light level from LDR + vector<int> ErrorCodes; public: - EventQueue SERIAL_Queue; //Initialise the EventQueue + EventQueue SERIAL_Queue; //Initialise the EventQueue void setsampledata(sample_message msg) // Update internal values { @@ -17,7 +26,7 @@ fLDR = msg.ldr; } - sample_message getsampledata() // Retrieves the data + sample_message getsampledata() // Retrieves the data { sample_message msg; msg.temp = fTemp; @@ -28,11 +37,74 @@ void updateTerminal() // Print internal values of sensors { + //printf("\033[2J"); + printf("\033[H"); printf("======= Sensor Update ========\n"); printf("Temperate: %5.2f\n", fTemp); printf("Pressure: %5.2f\n", fPressure); printf("Light Level: %5.2f\n", fLDR); - printf("==============================\n"); + printf("==============================\n"); + printf("Error Codes: "); + if (ErrorCodes.size() == 0) + { + printf("No Error Codes Raised\n"); + } + else + { + for (int idx = 0; idx < ErrorCodes.size(); idx++) + { + printf("%d: %d\n", idx, ErrorCodes[idx]); + } + } + printf("Thread Health: \n\n"); + // Add code to receive feedback from watchdog + } + + void displayFrame() + { + + + } + + void handleInput(char[] Input) + { + if (Input == "READ ALL") // Sends a comma seperate list of all measurements. + { + } + else if(Input == "DELETE ALL") + { + } + else if(Input == "READ") + { + } + else if(Input == "DELETE") + { + } + else if(Input == "SETDATE") + { + } + else if(Input == "SETTIME") + { + } + else if(Input == "SETT") + { + } + else if(Input == "STATE") + { + } + else if(Input == "LOGGING") // Verbose logging + { + } + } + + + + void updateErrors(vector<int> ErrorsIn) + { + for (int idx = 0; idx < ErrorsIn.size() ; idx++) // Add the Error Codes to the vector + { + ErrorCodes.push_back(ErrorsIn[idx]); + } } void updateTimeDate()