Liam Grazier
/
WORKINGCOURSEWORK
ladsidfs
Fork of 0NicksCoursework_copywithserialtime by
serialtx/stx.cpp
- Committer:
- liam_grazier
- Date:
- 2018-01-09
- Revision:
- 8:582ac4c5a524
File content as of revision 8:582ac4c5a524:
#include "mbed.h" #include "stx.hpp" #include "components.hpp" Mutex Sx; char buffer[255]; int empty = 0; void welcomemsg(void){ printf("WELCOME TO ELEC351 ENVIRONMENTAL SERIAL INTERFACE\n\rFOR ASSISTANCE TYPE HELP\n\r"); } void datain(void){ if(empty == 0){ Sx.lock(); scanf("%s", &buffer); Sx.unlock(); } } void printcommandlist(){ Sx.lock(); printf("Command List:\n\r READALL\n\r DELETEALL\n\r SETDATE\n\r DISPLAYTIME\n\r SETTIME\n\r SETT\n\r STATEON(Sampling State)\n\r STATEOFF(Sampling State)\n\r LOGGINGON\n\r LOGGINGOFF\n\r COMMANDLIST\n\r" ); Sx.unlock(); } void readdata(){ if (buffer != ""){ if (strstr(buffer, "READALL")){ readalldata(); } else if(strstr(buffer, "COMMANDLIST")){ printcommandlist(); } else if(strstr(buffer, "DISPLAYTIME")){ printcommandlist(); } else if(strstr(buffer, "HELP")){ help(); } else if(strstr(buffer, "DELETEALL")){ deletealldata(); } else if(strstr(buffer, "SETDATE")){////////COME BACK HERE LATE rundate(); } else if(strstr(buffer, "SETTIME")){////////COME BACK HERE LATE runtime(); } else if(strstr(buffer, "SETT")){////////COME BACK HERE LATE setT(); } else if(strstr(buffer, "STATEON")){ stateon(); } else if(strstr(buffer, "STATEOFF")){ stateoff(); } else if(strstr(buffer, "LOGGINGON")){ loggingon(); } else if(strstr(buffer, "LOGGINGOFF")){ loggingoff(); } else { printf("UNRECOGNISED\n\r"); } } } void help(){ printf("HELP: \n\rFOR COMMAND LIST, type COMMANDLIST\n\r"); } void readalldata(){ printf("read all data\n\r"); } //displays date, tim, temperature, presure, ligt void deletealldata(){ printf("delete all data \n\r"); } //deletes all memory from th iternal memory void setdate(){ printf("Set Date\n\r"); } //sets the day month and year void settime(){ printf("Set Time\n\r"); } //sets the clock hours, minutes, seconds void setT() { printf("Set Sampling Period 'T'\n\r"); } //sets the sampling period to <T> seconds void stateon(){ printf("Set Sampling ON\n\r"); } //turns ampling ON and OFF void stateoff(){ printf("Set Sampling OFF\n\r"); } void loggingon(){ printf("Logging On\n\r"); } void loggingoff(){ printf("Logging Off\n\r"); } //turns diagnostic logging ON and OFF void useseriel(){ help(); while(true){ Thread::signal_wait(SIG_SX); datain(); readdata(); } }