![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
FINAL PROJECT isn't it
Fork of ELEC351 by
SERIAL_COMMANDS.cpp@47:6d128e500875, 2018-01-08 (annotated)
- Committer:
- thomasmorris
- Date:
- Mon Jan 08 21:53:40 2018 +0000
- Revision:
- 47:6d128e500875
- Child:
- 48:244d6d81bb52
FINAL working copy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 47:6d128e500875 | 1 | #include "SERIAL_COMMANDS.hpp" |
thomasmorris | 47:6d128e500875 | 2 | |
thomasmorris | 47:6d128e500875 | 3 | extern 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 | 47:6d128e500875 | 11 | if(Log_Value == 1){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 | 47:6d128e500875 | 21 | if(Log_Value == 1){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 | 47:6d128e500875 | 31 | |
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 | 47:6d128e500875 | 51 | if(Log_Value == 1){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 | 47:6d128e500875 | 59 | if(x_Delete_All < 0){x_Delete_All = x_Delete_All + mailsize;} |
thomasmorris | 47:6d128e500875 | 60 | else {x_Delete_All = x_Delete_All;} |
thomasmorris | 47:6d128e500875 | 61 | |
thomasmorris | 47:6d128e500875 | 62 | Delete_Data(x_Delete_All); |
thomasmorris | 47:6d128e500875 | 63 | |
thomasmorris | 47:6d128e500875 | 64 | if(x_Delete_All == mailsize - 1){x_Delete_All = 0;} |
thomasmorris | 47:6d128e500875 | 65 | else {x_Delete_All = x_Delete_All + 1;} |
thomasmorris | 47:6d128e500875 | 66 | |
thomasmorris | 47:6d128e500875 | 67 | } |
thomasmorris | 47:6d128e500875 | 68 | pc.printf("DELETED %d RECORDS\n",mailsize); |
thomasmorris | 47:6d128e500875 | 69 | } |
thomasmorris | 47:6d128e500875 | 70 | |
thomasmorris | 47:6d128e500875 | 71 | //READ |
thomasmorris | 47:6d128e500875 | 72 | else if(input[0] == 'R' & input[1] == 'E' & input[2] == 'A' & input[3] == 'D' & input[4] == ' ') |
thomasmorris | 47:6d128e500875 | 73 | { |
thomasmorris | 47:6d128e500875 | 74 | int NumberOfChars = 0; int ArrayAddress = 0; string ReadNumber; int NumberToRead; |
thomasmorris | 47:6d128e500875 | 75 | while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;} |
thomasmorris | 47:6d128e500875 | 76 | for(int x=5; x < NumberOfChars; x++){ReadNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 77 | stringstream Number(ReadNumber); |
thomasmorris | 47:6d128e500875 | 78 | Number >> NumberToRead; |
thomasmorris | 47:6d128e500875 | 79 | |
thomasmorris | 47:6d128e500875 | 80 | if(NumberToRead > mailsize) |
thomasmorris | 47:6d128e500875 | 81 | { |
thomasmorris | 47:6d128e500875 | 82 | NumberToRead = mailsize; |
thomasmorris | 47:6d128e500875 | 83 | } |
thomasmorris | 47:6d128e500875 | 84 | |
thomasmorris | 47:6d128e500875 | 85 | if(Log_Value == 1){pc.printf("Getting Data\n");} |
thomasmorris | 47:6d128e500875 | 86 | |
thomasmorris | 47:6d128e500875 | 87 | Data_Buffer_Lock.lock();//Lock data buffer due to critical section |
thomasmorris | 47:6d128e500875 | 88 | int Start_Address = Write_Pointer; |
thomasmorris | 47:6d128e500875 | 89 | Data_Buffer_Lock.unlock();//unLock data buffer due to critical section |
thomasmorris | 47:6d128e500875 | 90 | |
thomasmorris | 47:6d128e500875 | 91 | for(int x = (Start_Address - NumberToRead); x != Start_Address; x = x ) |
thomasmorris | 47:6d128e500875 | 92 | { |
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 | 47:6d128e500875 | 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 | 47:6d128e500875 | 110 | if(Log_Value == 1){pc.printf("Read %d samples\n",NumberToRead);} |
thomasmorris | 47:6d128e500875 | 111 | |
thomasmorris | 47:6d128e500875 | 112 | } |
thomasmorris | 47:6d128e500875 | 113 | |
thomasmorris | 47:6d128e500875 | 114 | //DELETE look into this mgiht need to turn off sampling |
thomasmorris | 47:6d128e500875 | 115 | 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 | 116 | { |
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 | 47:6d128e500875 | 127 | if(Log_Value == 1){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 | 47:6d128e500875 | 135 | if(x_Delete < 0){x_Delete = x_Delete + mailsize;} |
thomasmorris | 47:6d128e500875 | 136 | else {x_Delete = x_Delete;} |
thomasmorris | 47:6d128e500875 | 137 | |
thomasmorris | 47:6d128e500875 | 138 | Delete_Data(x_Delete); |
thomasmorris | 47:6d128e500875 | 139 | |
thomasmorris | 47:6d128e500875 | 140 | if(x_Delete == mailsize - 1){x_Delete = 0;} |
thomasmorris | 47:6d128e500875 | 141 | else {x_Delete = x_Delete + 1;} |
thomasmorris | 47:6d128e500875 | 142 | |
thomasmorris | 47:6d128e500875 | 143 | } |
thomasmorris | 47:6d128e500875 | 144 | pc.printf("DELETED %d RECORDS\n",NumberToDelete); |
thomasmorris | 47:6d128e500875 | 145 | if(Log_Value == 1){pc.printf("Deleted %d samples\n",NumberToDelete);} |
thomasmorris | 47:6d128e500875 | 146 | } |
thomasmorris | 47:6d128e500875 | 147 | |
thomasmorris | 47:6d128e500875 | 148 | //STATE |
thomasmorris | 47:6d128e500875 | 149 | else if(input[0] == 'S' & input[1] == 'T' & input[2] == 'A' & input[3] == 'T' & input[4] == 'E' & input[5] == ' ') |
thomasmorris | 47:6d128e500875 | 150 | { |
thomasmorris | 47:6d128e500875 | 151 | int NumberOfChars = 0; int ArrayAddress = 0; string StateNumber; int NumberToState; |
thomasmorris | 47:6d128e500875 | 152 | while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;} |
thomasmorris | 47:6d128e500875 | 153 | for(int x=6; x < NumberOfChars; x++){StateNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 154 | stringstream Number(StateNumber); |
thomasmorris | 47:6d128e500875 | 155 | Number >> NumberToState; |
thomasmorris | 47:6d128e500875 | 156 | |
thomasmorris | 47:6d128e500875 | 157 | if(NumberToState==0) {Sampling_Timer.detach(); Console_Output_Timer.detach(); pc.printf("SAMPLING 0\n");}//Stop Sampling |
thomasmorris | 47:6d128e500875 | 158 | else if(NumberToState==1) {Sampling_Timer.attach(&Sampling_ISR,Sample_Rate); pc.printf("SAMPLING 1\n");}//Start Sampling |
thomasmorris | 47:6d128e500875 | 159 | else {pc.printf("Invalid State\n");} |
thomasmorris | 47:6d128e500875 | 160 | |
thomasmorris | 47:6d128e500875 | 161 | } |
thomasmorris | 47:6d128e500875 | 162 | |
thomasmorris | 47:6d128e500875 | 163 | //SETDATE |
thomasmorris | 47:6d128e500875 | 164 | 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 | 165 | { |
thomasmorris | 47:6d128e500875 | 166 | //int NumberOfChars = 0; int ArrayAddress = 0; |
thomasmorris | 47:6d128e500875 | 167 | string DayNumber, MonthNumber, YearNumber; |
thomasmorris | 47:6d128e500875 | 168 | int NumberToDay, NumberToMonth, NumberToYear; |
thomasmorris | 47:6d128e500875 | 169 | |
thomasmorris | 47:6d128e500875 | 170 | for(int x=8; x < 10; x++){DayNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 171 | stringstream Number_1(DayNumber); |
thomasmorris | 47:6d128e500875 | 172 | Number_1 >> NumberToDay; |
thomasmorris | 47:6d128e500875 | 173 | |
thomasmorris | 47:6d128e500875 | 174 | for(int x=11; x < 13; x++){MonthNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 175 | stringstream Number_2(MonthNumber); |
thomasmorris | 47:6d128e500875 | 176 | Number_2 >> NumberToMonth; |
thomasmorris | 47:6d128e500875 | 177 | |
thomasmorris | 47:6d128e500875 | 178 | for(int x=14; x < 18; x++){YearNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 179 | stringstream Number_3(YearNumber); |
thomasmorris | 47:6d128e500875 | 180 | Number_3 >> NumberToYear; |
thomasmorris | 47:6d128e500875 | 181 | |
thomasmorris | 47:6d128e500875 | 182 | set_new_date(NumberToDay,NumberToMonth,NumberToYear); |
thomasmorris | 47:6d128e500875 | 183 | pc.printf("DATE UPDATED TO %02d %02d %d\n",NumberToDay,NumberToMonth,NumberToYear); |
thomasmorris | 47:6d128e500875 | 184 | } |
thomasmorris | 47:6d128e500875 | 185 | |
thomasmorris | 47:6d128e500875 | 186 | //SETTIME |
thomasmorris | 47:6d128e500875 | 187 | 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 | 188 | { |
thomasmorris | 47:6d128e500875 | 189 | //int NumberOfChars = 0; int ArrayAddress = 0; |
thomasmorris | 47:6d128e500875 | 190 | string HourNumber, MinuteNumber, SecondNumber; |
thomasmorris | 47:6d128e500875 | 191 | int NumberToHour, NumberToMinute, NumberToSecond; |
thomasmorris | 47:6d128e500875 | 192 | |
thomasmorris | 47:6d128e500875 | 193 | for(int x=8; x < 10; x++){HourNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 194 | stringstream Number_1(HourNumber); |
thomasmorris | 47:6d128e500875 | 195 | Number_1 >> NumberToHour; |
thomasmorris | 47:6d128e500875 | 196 | |
thomasmorris | 47:6d128e500875 | 197 | for(int x=11; x < 13; x++){MinuteNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 198 | stringstream Number_2(MinuteNumber); |
thomasmorris | 47:6d128e500875 | 199 | Number_2 >> NumberToMinute; |
thomasmorris | 47:6d128e500875 | 200 | |
thomasmorris | 47:6d128e500875 | 201 | for(int x=14; x < 16; x++){SecondNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 202 | stringstream Number_3(SecondNumber); |
thomasmorris | 47:6d128e500875 | 203 | Number_3 >> NumberToSecond; |
thomasmorris | 47:6d128e500875 | 204 | |
thomasmorris | 47:6d128e500875 | 205 | set_new_time(NumberToHour,NumberToMinute,NumberToSecond); |
thomasmorris | 47:6d128e500875 | 206 | pc.printf("TIME UPDATED TO %02d %02d %02d\n",NumberToHour,NumberToMinute,NumberToSecond); |
thomasmorris | 47:6d128e500875 | 207 | } |
thomasmorris | 47:6d128e500875 | 208 | |
thomasmorris | 47:6d128e500875 | 209 | //SETT |
thomasmorris | 47:6d128e500875 | 210 | else if(input[0] == 'S' & input[1] == 'E' & input[2] == 'T' & input[3] == 'T' & input[4] == ' ') |
thomasmorris | 47:6d128e500875 | 211 | { |
thomasmorris | 47:6d128e500875 | 212 | |
thomasmorris | 47:6d128e500875 | 213 | int NumberOfChars = 0; int ArrayAddress = 0; |
thomasmorris | 47:6d128e500875 | 214 | string SettNumber; double NumberToSett; |
thomasmorris | 47:6d128e500875 | 215 | int Decimal_Divider = 10; |
thomasmorris | 47:6d128e500875 | 216 | float Sample_Rate_Integer = 0; string Sample_Rate_Integer_String; |
thomasmorris | 47:6d128e500875 | 217 | float Sample_Rate_Decimal = 0; string Sample_Rate_Decimal_String; |
thomasmorris | 47:6d128e500875 | 218 | while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;} |
thomasmorris | 47:6d128e500875 | 219 | |
thomasmorris | 47:6d128e500875 | 220 | |
thomasmorris | 47:6d128e500875 | 221 | if (Decimal_Check(input) == true) |
thomasmorris | 47:6d128e500875 | 222 | { |
thomasmorris | 47:6d128e500875 | 223 | for(int x = 5; x < Decimal_Position(input); x++){Sample_Rate_Integer_String += input[x];} |
thomasmorris | 47:6d128e500875 | 224 | stringstream Number_1(Sample_Rate_Integer_String); |
thomasmorris | 47:6d128e500875 | 225 | Number_1 >> Sample_Rate_Integer; |
thomasmorris | 47:6d128e500875 | 226 | |
thomasmorris | 47:6d128e500875 | 227 | for(int x = Decimal_Position(input) + 1; x < NumberOfChars; x++){Sample_Rate_Decimal_String += input[x];} |
thomasmorris | 47:6d128e500875 | 228 | stringstream Number_2(Sample_Rate_Decimal_String); |
thomasmorris | 47:6d128e500875 | 229 | Number_2 >> Sample_Rate_Decimal; |
thomasmorris | 47:6d128e500875 | 230 | |
thomasmorris | 47:6d128e500875 | 231 | for(int tens_power = 1; tens_power != NumberOfChars - Decimal_Position(input) - 1; tens_power++) |
thomasmorris | 47:6d128e500875 | 232 | { |
thomasmorris | 47:6d128e500875 | 233 | Decimal_Divider = Decimal_Divider * 10; |
thomasmorris | 47:6d128e500875 | 234 | } |
thomasmorris | 47:6d128e500875 | 235 | NumberToSett = Sample_Rate_Integer + (Sample_Rate_Decimal / float(Decimal_Divider)); |
thomasmorris | 47:6d128e500875 | 236 | } |
thomasmorris | 47:6d128e500875 | 237 | else |
thomasmorris | 47:6d128e500875 | 238 | { |
thomasmorris | 47:6d128e500875 | 239 | for(int x=5; x < NumberOfChars; x++){SettNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 240 | stringstream Number_3(SettNumber); |
thomasmorris | 47:6d128e500875 | 241 | Number_3 >> NumberToSett; |
thomasmorris | 47:6d128e500875 | 242 | } |
thomasmorris | 47:6d128e500875 | 243 | |
thomasmorris | 47:6d128e500875 | 244 | if(NumberToSett >= 0.1 & NumberToSett <= 60) |
thomasmorris | 47:6d128e500875 | 245 | { |
thomasmorris | 47:6d128e500875 | 246 | Sample_Rate = NumberToSett; |
thomasmorris | 47:6d128e500875 | 247 | pc.printf("T UPDATED TO %1.1f \n",NumberToSett); |
thomasmorris | 47:6d128e500875 | 248 | } |
thomasmorris | 47:6d128e500875 | 249 | else |
thomasmorris | 47:6d128e500875 | 250 | { |
thomasmorris | 47:6d128e500875 | 251 | Sample_Rate = Sample_Rate;//No change |
thomasmorris | 47:6d128e500875 | 252 | pc.printf("OUT OF RANGE\n"); |
thomasmorris | 47:6d128e500875 | 253 | } |
thomasmorris | 47:6d128e500875 | 254 | Sampling_Timer.detach(); |
thomasmorris | 47:6d128e500875 | 255 | Console_Output_Timer.detach(); |
thomasmorris | 47:6d128e500875 | 256 | Sampling_Timer.attach(&Sampling_ISR,Sample_Rate); |
thomasmorris | 47:6d128e500875 | 257 | } |
thomasmorris | 47:6d128e500875 | 258 | //LOGGING |
thomasmorris | 47:6d128e500875 | 259 | 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 | 260 | { |
thomasmorris | 47:6d128e500875 | 261 | int NumberOfChars = 0; int ArrayAddress = 0; string LoggingNumber; int NumberToLogging; |
thomasmorris | 47:6d128e500875 | 262 | while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;} |
thomasmorris | 47:6d128e500875 | 263 | for(int x=8; x < NumberOfChars; x++){LoggingNumber += input[x];} |
thomasmorris | 47:6d128e500875 | 264 | stringstream Number(LoggingNumber); |
thomasmorris | 47:6d128e500875 | 265 | Number >> NumberToLogging; |
thomasmorris | 47:6d128e500875 | 266 | if(NumberToLogging != 1) |
thomasmorris | 47:6d128e500875 | 267 | { |
thomasmorris | 47:6d128e500875 | 268 | NumberToLogging = 0; |
thomasmorris | 47:6d128e500875 | 269 | } |
thomasmorris | 47:6d128e500875 | 270 | Log_Value = NumberToLogging; |
thomasmorris | 47:6d128e500875 | 271 | pc.printf("LOGGING %d\n",NumberToLogging); |
thomasmorris | 47:6d128e500875 | 272 | } |
thomasmorris | 47:6d128e500875 | 273 | |
thomasmorris | 47:6d128e500875 | 274 | //HELP |
thomasmorris | 47:6d128e500875 | 275 | 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 | 276 | { |
thomasmorris | 47:6d128e500875 | 277 | HELP();//Run HELP Command |
thomasmorris | 47:6d128e500875 | 278 | } |
thomasmorris | 47:6d128e500875 | 279 | else |
thomasmorris | 47:6d128e500875 | 280 | { |
thomasmorris | 47:6d128e500875 | 281 | pc.printf("Please enter an acceptable command\n"); |
thomasmorris | 47:6d128e500875 | 282 | } |
thomasmorris | 47:6d128e500875 | 283 | |
thomasmorris | 47:6d128e500875 | 284 | } |