FINAL PROJECT isn't it

Fork of ELEC351 by Plymouth ELEC351 Group T

Committer:
thomasmorris
Date:
Tue Jan 09 00:37:01 2018 +0000
Revision:
48:244d6d81bb52
Parent:
47:6d128e500875
Child:
52:99915f5240b2
HOLY SHIT IT WORKS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 47:6d128e500875 1 #include "SERIAL_COMMANDS.hpp"
thomasmorris 48:244d6d81bb52 2 int NetworkWaitTime;
thomasmorris 48:244d6d81bb52 3 char input[100] = {};
thomasmorris 47:6d128e500875 4
thomasmorris 47:6d128e500875 5 Ticker Console_Output_Timer;
thomasmorris 47:6d128e500875 6 Ticker Sampling_Timer;//Controls Sampling
thomasmorris 47:6d128e500875 7
thomasmorris 47:6d128e500875 8 void Serial_Commands_Output()//Used for getting input from the user to determine the opperations to perform
thomasmorris 47:6d128e500875 9 {
thomasmorris 47:6d128e500875 10
thomasmorris 48:244d6d81bb52 11 if(Log_Value == 4){pc.printf("In Serial_Commands\n");}
thomasmorris 47:6d128e500875 12 for (int x = 0; x < 100; x++){input[x] = ' ';};
thomasmorris 47:6d128e500875 13
thomasmorris 47:6d128e500875 14 pc.printf("Please type in a command\n");//Log this
thomasmorris 47:6d128e500875 15
thomasmorris 47:6d128e500875 16 cin.getline(input,sizeof(input),'\r');
thomasmorris 47:6d128e500875 17
thomasmorris 47:6d128e500875 18 //READ ALL
thomasmorris 47:6d128e500875 19 if(input[0] == 'R' & input[1] == 'E' & input[2] == 'A' & input[3] == 'D' & input[4] == ' ' & input[5] == 'A' & input[6] == 'L' & input[7] == 'L')
thomasmorris 47:6d128e500875 20 {
thomasmorris 48:244d6d81bb52 21 if(Log_Value == 4){pc.printf("READ ALL Confirmed\n");}
thomasmorris 47:6d128e500875 22
thomasmorris 47:6d128e500875 23 Data_Buffer_Lock.lock();//Lock data buffer due to critical section
thomasmorris 47:6d128e500875 24 int Start_Address_Read_All = Write_Pointer;
thomasmorris 47:6d128e500875 25 Data_Buffer_Lock.unlock();//unLock data buffer due to critical section
thomasmorris 47:6d128e500875 26
thomasmorris 47:6d128e500875 27 for(int x_Read_All = (Start_Address_Read_All - mailsize); x_Read_All != Start_Address_Read_All; x_Read_All = x_Read_All )
thomasmorris 47:6d128e500875 28 {
thomasmorris 47:6d128e500875 29 if(x_Read_All < 0){x_Read_All = x_Read_All + mailsize;}
thomasmorris 47:6d128e500875 30 else {x_Read_All = x_Read_All;}
thomasmorris 48:244d6d81bb52 31 if(Log_Value == 4){pc.printf("Address Reading From: %d\n",x_Read_All);}
thomasmorris 47:6d128e500875 32 DATA Serial_Read_Data = Read_Data(x_Read_All);
thomasmorris 47:6d128e500875 33
thomasmorris 47:6d128e500875 34 time_t Time = Serial_Read_Data.get_time();
thomasmorris 47:6d128e500875 35 tm* Time_Pointer = localtime(&Time);
thomasmorris 47:6d128e500875 36
thomasmorris 47:6d128e500875 37 pc.printf("Date = %02d %02d %d ,\t", Time_Pointer->tm_mday, (Time_Pointer->tm_mon+1),(Time_Pointer->tm_year+1900));
thomasmorris 47:6d128e500875 38 pc.printf("Time = %02d:%02d:%02d ,\t", Time_Pointer->tm_hour, Time_Pointer->tm_min, Time_Pointer->tm_sec); //Print the string formatted time
thomasmorris 47:6d128e500875 39 pc.printf("Temperature = %f ,\t", Serial_Read_Data.get_temperature()); //Print Temperature
thomasmorris 47:6d128e500875 40 pc.printf("Pressure = %f ,\t", Serial_Read_Data.get_pressure()); //Print Pressure
thomasmorris 47:6d128e500875 41 pc.printf("Light = %f ,\n", Serial_Read_Data.get_light()); //Print Light
thomasmorris 47:6d128e500875 42
thomasmorris 47:6d128e500875 43 if(x_Read_All == mailsize - 1){x_Read_All = 0;}
thomasmorris 47:6d128e500875 44 else {x_Read_All = x_Read_All + 1;}
thomasmorris 47:6d128e500875 45 }
thomasmorris 47:6d128e500875 46 }
thomasmorris 47:6d128e500875 47
thomasmorris 47:6d128e500875 48 //DELETE ALL FIX THIS - Might need to disable sampling during the delete
thomasmorris 47:6d128e500875 49 else if(input[0] == 'D' & input[1] == 'E' & input[2] == 'L' & input[3] == 'E' & input[4] == 'T' & input[5] == 'E' & input[6] == ' ' & input[7] == 'A' & input[8] == 'L' & input[9] == 'L')
thomasmorris 47:6d128e500875 50 {
thomasmorris 48:244d6d81bb52 51 if(Log_Value == 4){pc.printf("DELETE ALL Confirmed\n");}
thomasmorris 47:6d128e500875 52
thomasmorris 47:6d128e500875 53 Data_Buffer_Lock.lock();
thomasmorris 47:6d128e500875 54 int Start_Address = Write_Pointer;
thomasmorris 47:6d128e500875 55 Data_Buffer_Lock.unlock();
thomasmorris 47:6d128e500875 56
thomasmorris 47:6d128e500875 57 for(int x_Delete_All = (Start_Address - mailsize); x_Delete_All != Start_Address; x_Delete_All = x_Delete_All)
thomasmorris 47:6d128e500875 58 {
thomasmorris 48:244d6d81bb52 59 if(Log_Value == 4){pc.printf("Address Deleting From: %d\n",x_Delete_All);}
thomasmorris 47:6d128e500875 60 if(x_Delete_All < 0){x_Delete_All = x_Delete_All + mailsize;}
thomasmorris 47:6d128e500875 61 else {x_Delete_All = x_Delete_All;}
thomasmorris 47:6d128e500875 62
thomasmorris 47:6d128e500875 63 Delete_Data(x_Delete_All);
thomasmorris 47:6d128e500875 64
thomasmorris 47:6d128e500875 65 if(x_Delete_All == mailsize - 1){x_Delete_All = 0;}
thomasmorris 47:6d128e500875 66 else {x_Delete_All = x_Delete_All + 1;}
thomasmorris 47:6d128e500875 67
thomasmorris 47:6d128e500875 68 }
thomasmorris 47:6d128e500875 69 pc.printf("DELETED %d RECORDS\n",mailsize);
thomasmorris 47:6d128e500875 70 }
thomasmorris 47:6d128e500875 71
thomasmorris 47:6d128e500875 72 //READ
thomasmorris 47:6d128e500875 73 else if(input[0] == 'R' & input[1] == 'E' & input[2] == 'A' & input[3] == 'D' & input[4] == ' ')
thomasmorris 47:6d128e500875 74 {
thomasmorris 48:244d6d81bb52 75 if(Log_Value == 4){pc.printf("READ n Confirmed\n");}
thomasmorris 47:6d128e500875 76 int NumberOfChars = 0; int ArrayAddress = 0; string ReadNumber; int NumberToRead;
thomasmorris 47:6d128e500875 77 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 47:6d128e500875 78 for(int x=5; x < NumberOfChars; x++){ReadNumber += input[x];}
thomasmorris 47:6d128e500875 79 stringstream Number(ReadNumber);
thomasmorris 47:6d128e500875 80 Number >> NumberToRead;
thomasmorris 48:244d6d81bb52 81 if(Log_Value == 4){pc.printf("Number of samples to Read %d\n",NumberToRead);}
thomasmorris 47:6d128e500875 82 if(NumberToRead > mailsize)
thomasmorris 47:6d128e500875 83 {
thomasmorris 47:6d128e500875 84 NumberToRead = mailsize;
thomasmorris 47:6d128e500875 85 }
thomasmorris 47:6d128e500875 86 Data_Buffer_Lock.lock();//Lock data buffer due to critical section
thomasmorris 47:6d128e500875 87 int Start_Address = Write_Pointer;
thomasmorris 47:6d128e500875 88 Data_Buffer_Lock.unlock();//unLock data buffer due to critical section
thomasmorris 47:6d128e500875 89
thomasmorris 47:6d128e500875 90 for(int x = (Start_Address - NumberToRead); x != Start_Address; x = x )
thomasmorris 47:6d128e500875 91 {
thomasmorris 48:244d6d81bb52 92 if(Log_Value == 4){pc.printf("Address Reading From: %d\n",x);}
thomasmorris 47:6d128e500875 93 if(x < 0){x = x + mailsize;}
thomasmorris 47:6d128e500875 94 else {x = x;}
thomasmorris 47:6d128e500875 95
thomasmorris 47:6d128e500875 96 DATA Serial_Read_Data = Read_Data(x);
thomasmorris 47:6d128e500875 97
thomasmorris 47:6d128e500875 98 time_t Time = Serial_Read_Data.get_time();
thomasmorris 47:6d128e500875 99 tm* Time_Pointer = localtime(&Time);
thomasmorris 47:6d128e500875 100
thomasmorris 47:6d128e500875 101 pc.printf("Date = %02d %02d %d ,\t", Time_Pointer->tm_mday, (Time_Pointer->tm_mon+1),(Time_Pointer->tm_year+1900));
thomasmorris 48:244d6d81bb52 102 pc.printf("Time = %02d:%02d:%02d ,\t", Time_Pointer->tm_hour, Time_Pointer->tm_min, Time_Pointer->tm_sec);//Print the string formatted time
thomasmorris 47:6d128e500875 103 pc.printf("Temperature = %f ,\t", Serial_Read_Data.get_temperature()); //Print Temperature
thomasmorris 47:6d128e500875 104 pc.printf("Pressure = %f ,\t", Serial_Read_Data.get_pressure()); //Print Pressure
thomasmorris 47:6d128e500875 105 pc.printf("Light = %f ,\n", Serial_Read_Data.get_light()); //Print Light
thomasmorris 47:6d128e500875 106
thomasmorris 47:6d128e500875 107 if(x == mailsize - 1){x = 0;}
thomasmorris 47:6d128e500875 108 else {x = x + 1;}
thomasmorris 47:6d128e500875 109 }
thomasmorris 48:244d6d81bb52 110 if(Log_Value == 4){pc.printf("Read %d samples\n",NumberToRead);}
thomasmorris 47:6d128e500875 111 }
thomasmorris 47:6d128e500875 112
thomasmorris 47:6d128e500875 113 //DELETE look into this mgiht need to turn off sampling
thomasmorris 47:6d128e500875 114 else if(input[0] == 'D' & input[1] == 'E' & input[2] == 'L' & input[3] == 'E' & input[4] == 'T' & input[5] == 'E' & input[6] == ' ')
thomasmorris 47:6d128e500875 115 {
thomasmorris 48:244d6d81bb52 116 if(Log_Value == 4){pc.printf("DELETE N Confirmed\n");}
thomasmorris 47:6d128e500875 117 int NumberOfChars = 0; int ArrayAddress = 0; string DeleteNumber; int NumberToDelete;
thomasmorris 47:6d128e500875 118 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 47:6d128e500875 119 for(int x=7; x < NumberOfChars; x++){DeleteNumber += input[x];}
thomasmorris 47:6d128e500875 120 stringstream Number(DeleteNumber);
thomasmorris 47:6d128e500875 121 Number >> NumberToDelete;
thomasmorris 47:6d128e500875 122
thomasmorris 47:6d128e500875 123 if(NumberToDelete > mailsize)
thomasmorris 47:6d128e500875 124 {
thomasmorris 47:6d128e500875 125 NumberToDelete = mailsize;
thomasmorris 47:6d128e500875 126 }
thomasmorris 48:244d6d81bb52 127 if(Log_Value == 4){pc.printf("Deleted %d samples\n",NumberToDelete);}
thomasmorris 47:6d128e500875 128
thomasmorris 47:6d128e500875 129 Data_Buffer_Lock.lock();
thomasmorris 47:6d128e500875 130 int Start_Address = Write_Pointer;
thomasmorris 47:6d128e500875 131 Data_Buffer_Lock.unlock();
thomasmorris 47:6d128e500875 132
thomasmorris 47:6d128e500875 133 for(int x_Delete = (Start_Address - NumberToDelete); x_Delete != Start_Address; x_Delete = x_Delete )
thomasmorris 47:6d128e500875 134 {
thomasmorris 48:244d6d81bb52 135 if(Log_Value == 4){pc.printf("Address Deleting From: %d\n",x_Delete);}
thomasmorris 47:6d128e500875 136 if(x_Delete < 0){x_Delete = x_Delete + mailsize;}
thomasmorris 47:6d128e500875 137 else {x_Delete = x_Delete;}
thomasmorris 47:6d128e500875 138
thomasmorris 47:6d128e500875 139 Delete_Data(x_Delete);
thomasmorris 47:6d128e500875 140
thomasmorris 47:6d128e500875 141 if(x_Delete == mailsize - 1){x_Delete = 0;}
thomasmorris 47:6d128e500875 142 else {x_Delete = x_Delete + 1;}
thomasmorris 47:6d128e500875 143
thomasmorris 47:6d128e500875 144 }
thomasmorris 47:6d128e500875 145 pc.printf("DELETED %d RECORDS\n",NumberToDelete);
thomasmorris 48:244d6d81bb52 146 if(Log_Value == 4){pc.printf("Deleted %d samples\n",NumberToDelete);}
thomasmorris 47:6d128e500875 147 }
thomasmorris 47:6d128e500875 148
thomasmorris 47:6d128e500875 149 //STATE
thomasmorris 47:6d128e500875 150 else if(input[0] == 'S' & input[1] == 'T' & input[2] == 'A' & input[3] == 'T' & input[4] == 'E' & input[5] == ' ')
thomasmorris 47:6d128e500875 151 {
thomasmorris 48:244d6d81bb52 152 if(Log_Value == 4){pc.printf("STATE Confirmed\n");}
thomasmorris 47:6d128e500875 153 int NumberOfChars = 0; int ArrayAddress = 0; string StateNumber; int NumberToState;
thomasmorris 47:6d128e500875 154 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 47:6d128e500875 155 for(int x=6; x < NumberOfChars; x++){StateNumber += input[x];}
thomasmorris 47:6d128e500875 156 stringstream Number(StateNumber);
thomasmorris 47:6d128e500875 157 Number >> NumberToState;
thomasmorris 48:244d6d81bb52 158 if(Log_Value == 4){pc.printf("STATE Set to %d\n",NumberToState);}
thomasmorris 47:6d128e500875 159
thomasmorris 47:6d128e500875 160 if(NumberToState==0) {Sampling_Timer.detach(); Console_Output_Timer.detach(); pc.printf("SAMPLING 0\n");}//Stop Sampling
thomasmorris 47:6d128e500875 161 else if(NumberToState==1) {Sampling_Timer.attach(&Sampling_ISR,Sample_Rate); pc.printf("SAMPLING 1\n");}//Start Sampling
thomasmorris 47:6d128e500875 162 else {pc.printf("Invalid State\n");}
thomasmorris 47:6d128e500875 163
thomasmorris 47:6d128e500875 164 }
thomasmorris 47:6d128e500875 165
thomasmorris 47:6d128e500875 166 //SETDATE
thomasmorris 47:6d128e500875 167 else if(input[0] == 'S' & input[1] == 'E' & input[2] == 'T' & input[3] == 'D' & input[4] == 'A' & input[5] == 'T' & input[6] == 'E' & input[7] == ' ' & input[10] == ' ' & input[13] == ' ')
thomasmorris 47:6d128e500875 168 {
thomasmorris 48:244d6d81bb52 169 if(Log_Value == 4){pc.printf("SETDATE Confirmed\n");}
thomasmorris 47:6d128e500875 170 //int NumberOfChars = 0; int ArrayAddress = 0;
thomasmorris 47:6d128e500875 171 string DayNumber, MonthNumber, YearNumber;
thomasmorris 47:6d128e500875 172 int NumberToDay, NumberToMonth, NumberToYear;
thomasmorris 47:6d128e500875 173
thomasmorris 47:6d128e500875 174 for(int x=8; x < 10; x++){DayNumber += input[x];}
thomasmorris 47:6d128e500875 175 stringstream Number_1(DayNumber);
thomasmorris 47:6d128e500875 176 Number_1 >> NumberToDay;
thomasmorris 47:6d128e500875 177
thomasmorris 47:6d128e500875 178 for(int x=11; x < 13; x++){MonthNumber += input[x];}
thomasmorris 47:6d128e500875 179 stringstream Number_2(MonthNumber);
thomasmorris 47:6d128e500875 180 Number_2 >> NumberToMonth;
thomasmorris 47:6d128e500875 181
thomasmorris 47:6d128e500875 182 for(int x=14; x < 18; x++){YearNumber += input[x];}
thomasmorris 47:6d128e500875 183 stringstream Number_3(YearNumber);
thomasmorris 47:6d128e500875 184 Number_3 >> NumberToYear;
thomasmorris 48:244d6d81bb52 185 if(Log_Value == 4){pc.printf("Year Input %d Month Input %d Day Input %d\n",NumberToYear,NumberToMonth,NumberToDay);}
thomasmorris 47:6d128e500875 186 set_new_date(NumberToDay,NumberToMonth,NumberToYear);
thomasmorris 47:6d128e500875 187 pc.printf("DATE UPDATED TO %02d %02d %d\n",NumberToDay,NumberToMonth,NumberToYear);
thomasmorris 47:6d128e500875 188 }
thomasmorris 47:6d128e500875 189
thomasmorris 47:6d128e500875 190 //SETTIME
thomasmorris 47:6d128e500875 191 else if(input[0] == 'S' & input[1] == 'E' & input[2] == 'T' & input[3] == 'T' & input[4] == 'I' & input[5] == 'M' & input[6] == 'E' & input[7] == ' ' & input[10] == ' ' & input[13] == ' ')
thomasmorris 47:6d128e500875 192 {
thomasmorris 48:244d6d81bb52 193 if(Log_Value == 4){pc.printf("SETTIME Confirmed\n");}
thomasmorris 47:6d128e500875 194 //int NumberOfChars = 0; int ArrayAddress = 0;
thomasmorris 47:6d128e500875 195 string HourNumber, MinuteNumber, SecondNumber;
thomasmorris 47:6d128e500875 196 int NumberToHour, NumberToMinute, NumberToSecond;
thomasmorris 47:6d128e500875 197
thomasmorris 47:6d128e500875 198 for(int x=8; x < 10; x++){HourNumber += input[x];}
thomasmorris 47:6d128e500875 199 stringstream Number_1(HourNumber);
thomasmorris 47:6d128e500875 200 Number_1 >> NumberToHour;
thomasmorris 47:6d128e500875 201
thomasmorris 47:6d128e500875 202 for(int x=11; x < 13; x++){MinuteNumber += input[x];}
thomasmorris 47:6d128e500875 203 stringstream Number_2(MinuteNumber);
thomasmorris 47:6d128e500875 204 Number_2 >> NumberToMinute;
thomasmorris 47:6d128e500875 205
thomasmorris 47:6d128e500875 206 for(int x=14; x < 16; x++){SecondNumber += input[x];}
thomasmorris 47:6d128e500875 207 stringstream Number_3(SecondNumber);
thomasmorris 47:6d128e500875 208 Number_3 >> NumberToSecond;
thomasmorris 48:244d6d81bb52 209 if(Log_Value == 4){pc.printf("Hour Input %d Minute Input %d Seconds Input %d",NumberToHour,NumberToMinute,NumberToSecond);}
thomasmorris 47:6d128e500875 210 set_new_time(NumberToHour,NumberToMinute,NumberToSecond);
thomasmorris 47:6d128e500875 211 pc.printf("TIME UPDATED TO %02d %02d %02d\n",NumberToHour,NumberToMinute,NumberToSecond);
thomasmorris 47:6d128e500875 212 }
thomasmorris 47:6d128e500875 213
thomasmorris 47:6d128e500875 214 //SETT
thomasmorris 47:6d128e500875 215 else if(input[0] == 'S' & input[1] == 'E' & input[2] == 'T' & input[3] == 'T' & input[4] == ' ')
thomasmorris 47:6d128e500875 216 {
thomasmorris 48:244d6d81bb52 217 if(Log_Value == 4){pc.printf("SETT Confirmed\n");}
thomasmorris 47:6d128e500875 218 int NumberOfChars = 0; int ArrayAddress = 0;
thomasmorris 47:6d128e500875 219 string SettNumber; double NumberToSett;
thomasmorris 47:6d128e500875 220 int Decimal_Divider = 10;
thomasmorris 47:6d128e500875 221 float Sample_Rate_Integer = 0; string Sample_Rate_Integer_String;
thomasmorris 47:6d128e500875 222 float Sample_Rate_Decimal = 0; string Sample_Rate_Decimal_String;
thomasmorris 47:6d128e500875 223 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 47:6d128e500875 224
thomasmorris 47:6d128e500875 225
thomasmorris 47:6d128e500875 226 if (Decimal_Check(input) == true)
thomasmorris 47:6d128e500875 227 {
thomasmorris 47:6d128e500875 228 for(int x = 5; x < Decimal_Position(input); x++){Sample_Rate_Integer_String += input[x];}
thomasmorris 47:6d128e500875 229 stringstream Number_1(Sample_Rate_Integer_String);
thomasmorris 47:6d128e500875 230 Number_1 >> Sample_Rate_Integer;
thomasmorris 47:6d128e500875 231
thomasmorris 47:6d128e500875 232 for(int x = Decimal_Position(input) + 1; x < NumberOfChars; x++){Sample_Rate_Decimal_String += input[x];}
thomasmorris 47:6d128e500875 233 stringstream Number_2(Sample_Rate_Decimal_String);
thomasmorris 47:6d128e500875 234 Number_2 >> Sample_Rate_Decimal;
thomasmorris 47:6d128e500875 235
thomasmorris 47:6d128e500875 236 for(int tens_power = 1; tens_power != NumberOfChars - Decimal_Position(input) - 1; tens_power++)
thomasmorris 47:6d128e500875 237 {
thomasmorris 47:6d128e500875 238 Decimal_Divider = Decimal_Divider * 10;
thomasmorris 47:6d128e500875 239 }
thomasmorris 47:6d128e500875 240 NumberToSett = Sample_Rate_Integer + (Sample_Rate_Decimal / float(Decimal_Divider));
thomasmorris 47:6d128e500875 241 }
thomasmorris 47:6d128e500875 242 else
thomasmorris 47:6d128e500875 243 {
thomasmorris 47:6d128e500875 244 for(int x=5; x < NumberOfChars; x++){SettNumber += input[x];}
thomasmorris 47:6d128e500875 245 stringstream Number_3(SettNumber);
thomasmorris 47:6d128e500875 246 Number_3 >> NumberToSett;
thomasmorris 47:6d128e500875 247 }
thomasmorris 48:244d6d81bb52 248
thomasmorris 48:244d6d81bb52 249 if(Log_Value == 4){pc.printf("Sample Rate Input %d\n",NumberToSett);}
thomasmorris 48:244d6d81bb52 250 if(Log_Value == 4){pc.printf("Decimal Rate Input %d\n",Sample_Rate_Decimal);}
thomasmorris 48:244d6d81bb52 251 if(Log_Value == 4){pc.printf("Integer Rate Input %d\n",Sample_Rate_Integer);}
thomasmorris 48:244d6d81bb52 252
thomasmorris 47:6d128e500875 253 if(NumberToSett >= 0.1 & NumberToSett <= 60)
thomasmorris 47:6d128e500875 254 {
thomasmorris 47:6d128e500875 255 Sample_Rate = NumberToSett;
thomasmorris 47:6d128e500875 256 pc.printf("T UPDATED TO %1.1f \n",NumberToSett);
thomasmorris 47:6d128e500875 257 }
thomasmorris 47:6d128e500875 258 else
thomasmorris 47:6d128e500875 259 {
thomasmorris 47:6d128e500875 260 Sample_Rate = Sample_Rate;//No change
thomasmorris 47:6d128e500875 261 pc.printf("OUT OF RANGE\n");
thomasmorris 47:6d128e500875 262 }
thomasmorris 47:6d128e500875 263 Sampling_Timer.detach();
thomasmorris 47:6d128e500875 264 Console_Output_Timer.detach();
thomasmorris 47:6d128e500875 265 Sampling_Timer.attach(&Sampling_ISR,Sample_Rate);
thomasmorris 47:6d128e500875 266 }
thomasmorris 47:6d128e500875 267 //LOGGING
thomasmorris 47:6d128e500875 268 else if(input[0] == 'L' & input[1] == 'O' & input[2] == 'G' & input[3] == 'G' & input[4] == 'I' & input[5] == 'N' & input[6] == 'G' & input[7] == ' ')
thomasmorris 47:6d128e500875 269 {
thomasmorris 47:6d128e500875 270 int NumberOfChars = 0; int ArrayAddress = 0; string LoggingNumber; int NumberToLogging;
thomasmorris 47:6d128e500875 271 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 47:6d128e500875 272 for(int x=8; x < NumberOfChars; x++){LoggingNumber += input[x];}
thomasmorris 47:6d128e500875 273 stringstream Number(LoggingNumber);
thomasmorris 47:6d128e500875 274 Number >> NumberToLogging;
thomasmorris 48:244d6d81bb52 275 if (NumberToLogging == 0){pc.printf("NOT LOGGING\n");}
thomasmorris 48:244d6d81bb52 276 else if (NumberToLogging == 1){pc.printf("LOGGING LCD\n");}
thomasmorris 48:244d6d81bb52 277 else if (NumberToLogging == 2){pc.printf("LOGGING NETWORKING\n");}
thomasmorris 48:244d6d81bb52 278 else if (NumberToLogging == 3){pc.printf("LOGGING SAMPLING\n");}
thomasmorris 48:244d6d81bb52 279 else if (NumberToLogging == 4){pc.printf("LOGGING SERIAL COMMANDS\n");}
thomasmorris 48:244d6d81bb52 280 else if (NumberToLogging == 5){pc.printf("LOGGING SD CARD\n");}
thomasmorris 48:244d6d81bb52 281 else if (NumberToLogging >= 6){pc.printf("INVALID LOGGING COMMAND\n");}
thomasmorris 48:244d6d81bb52 282
thomasmorris 48:244d6d81bb52 283 if (NumberToLogging <= 5){Log_Value = NumberToLogging;}
thomasmorris 47:6d128e500875 284 }
thomasmorris 47:6d128e500875 285
thomasmorris 47:6d128e500875 286 //HELP
thomasmorris 47:6d128e500875 287 else if(input[0] == 'H' & input[1] == 'E' & input[2] == 'L' & input[3] == 'P')// Use this to display all of the availble commands
thomasmorris 47:6d128e500875 288 {
thomasmorris 48:244d6d81bb52 289 pc.printf("Avalible Commands are: \n");
thomasmorris 48:244d6d81bb52 290
thomasmorris 48:244d6d81bb52 291 pc.printf("READ ALL\nDELETE ALL\nREAD <n>\nDELETE <n>\nSETDATE <dd> <mm> <yyyy>\nSETTIME <hh> <mm> <ss>\nSETT <T>\nSTATE <x>\nLOGGING <x>\nNETSET <n>\nHELP\n");
thomasmorris 48:244d6d81bb52 292
thomasmorris 47:6d128e500875 293 }
thomasmorris 48:244d6d81bb52 294
thomasmorris 48:244d6d81bb52 295 //NETSET
thomasmorris 48:244d6d81bb52 296 else if(input[0] == 'N' & input[1] == 'E' & input[2] == 'T' & input[3] == 'S' & input[4] == 'E' & input[5] == 'T' & input[6] == ' ')// Use this to display all of the availble commands
thomasmorris 48:244d6d81bb52 297 {
thomasmorris 48:244d6d81bb52 298 if(Log_Value == 4){pc.printf("NETSET confirmed\n");}
thomasmorris 48:244d6d81bb52 299 int NumberOfChars = 0; int ArrayAddress = 0; string NetSetNumber; int NumberToNetSet;
thomasmorris 48:244d6d81bb52 300 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 48:244d6d81bb52 301 for(int x=7; x < NumberOfChars; x++){NetSetNumber += input[x];}
thomasmorris 48:244d6d81bb52 302 stringstream Number(NetSetNumber);
thomasmorris 48:244d6d81bb52 303 Number >> NumberToNetSet;
thomasmorris 48:244d6d81bb52 304 if(Log_Value == 4){pc.printf("NETSET Number %d",NumberToNetSet);}
thomasmorris 48:244d6d81bb52 305 if(NumberToNetSet < 1)
thomasmorris 48:244d6d81bb52 306 {
thomasmorris 48:244d6d81bb52 307 NumberToNetSet = 1;
thomasmorris 48:244d6d81bb52 308 }
thomasmorris 48:244d6d81bb52 309 else
thomasmorris 48:244d6d81bb52 310 {
thomasmorris 48:244d6d81bb52 311 NumberToNetSet = NumberToNetSet;
thomasmorris 48:244d6d81bb52 312 }
thomasmorris 48:244d6d81bb52 313 NetworkWaitTime = (NumberToNetSet * 1000);
thomasmorris 48:244d6d81bb52 314 }
thomasmorris 48:244d6d81bb52 315
thomasmorris 47:6d128e500875 316 else
thomasmorris 47:6d128e500875 317 {
thomasmorris 47:6d128e500875 318 pc.printf("Please enter an acceptable command\n");
thomasmorris 47:6d128e500875 319 }
thomasmorris 47:6d128e500875 320
thomasmorris 47:6d128e500875 321 }