Deals with user inputs

Dependents:   ELEC350_Project2

Files at this revision

API Documentation at this revision

Comitter:
Swabey89
Date:
Thu Jan 03 12:18:45 2019 +0000
Parent:
28:2673cf270bf0
Commit message:
Updates

Changed in this revision

serial_terminal.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2673cf270bf0 -r 708d7f9def1f serial_terminal.cpp
--- a/serial_terminal.cpp	Thu Jan 03 10:32:48 2019 +0000
+++ b/serial_terminal.cpp	Thu Jan 03 12:18:45 2019 +0000
@@ -11,7 +11,7 @@
 {
         serial_tout.attach(serial_toutISR,TOUT_TIME_DEF);
         
-        static time_t seconds;
+        //static time_t seconds;
         
         //change these sizes
         char cmnd[30];
@@ -31,7 +31,7 @@
             pc->printf("INVALID COMMAND\r\n");   
             printlock.unlock();
             */
-            printQueue.call(printf, "INVALID COMMAND\r\n");
+            printQueue.call(puts, "INVALID COMMAND\r");
         }
         else
         {
@@ -40,15 +40,15 @@
             e_cmnd = stringconv(cmnd);
             e_arg = stringconv(arg);
             
+            /*
             if(logging)
             {
-                /*
                 printlock.lock();
                 pc->printf("Command %s recieved with argument of %s, containing %d readable numbers\r\n\n",cmnd,arg,argnum);
                 printlock.unlock();   
-                */
                 printQueue.call(printf,"Command %s recieved with argument of %s, containing %d readable numbers\r\n\n",cmnd,arg,argnum);
             }
+            */
             
             switch (e_cmnd)
             {
@@ -61,8 +61,8 @@
                         pc->printf("INVALID COMMAND\n\n\r"); 
                         printlock.unlock(); 
                         */
-                        printQueue.call(printf, "INVALID COMMAND\n\n\r");
-                        break;
+                        printQueue.call(puts, "INVALID COMMAND\r\n");
+                        //break;
                     }
                     else if (e_arg == ALL || val >= (BUFFERSIZE-Nspaces))
                     {
@@ -82,10 +82,10 @@
                         pc->printf("INVALID COMMAND\n\n\r"); 
                         printlock.unlock(); 
                         */
-                        printQueue.call(printf,"INVALID COMMAND\n\n\r");
-                        break;
+                        printQueue.call(puts,"INVALID COMMAND\r\n");
+                        //break;
                     }
-                    if (e_arg == ALL || val > (BUFFERSIZE-Nspaces)) SDqueue.call(SDdelete,-1); //delete all
+                    else if (e_arg == ALL || val > (BUFFERSIZE-Nspaces)) SDqueue.call(SDdelete,-1); //delete all
                     else SDqueue.call(SDdelete,val);
                     break;
                     
@@ -106,7 +106,7 @@
                         pc->printf("SETDATE failed\n\n\r");
                         printlock.unlock();   
                         */
-                        printQueue.call(printf,"SETDATE failed\n\n\r");
+                        printQueue.call(puts,"SETDATE FAILED\r\n");
                     }
                     else
                     {
@@ -119,7 +119,7 @@
                         pc->printf("Date updated to %s\n\n\r", ctime(&seconds));
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"Date updated to %s\n\n\r", ctime(&seconds));
+                        printQueue.call(printf,"DATE UPDATED TO %s\r\n\n", ctime(&seconds));
                     }
                     break;
                     
@@ -140,7 +140,7 @@
                         pc->printf("SETTIME FAILED\n\n\r");
                         printlock.unlock();   
                         */
-                        printQueue.call(printf, "SETTIME FAILED\n\n\r");
+                        printQueue.call(puts, "SETTIME FAILED\r\n");
                     }
                     else
                     {
@@ -153,7 +153,7 @@
                         pc->printf("TIME UPDATED TO %s\n\n\r", ctime(&seconds));
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"TIME UPDATED TO %s\n\n\r", ctime(&seconds));
+                        printQueue.call(printf,"TIME UPDATED TO %s\r\n\n", ctime(&seconds));
                         
                     }
                     break;
@@ -167,8 +167,8 @@
                         pc->printf("OUT OF RANGE\n\n\r"); 
                         printlock.unlock();
                         */
-                        printQueue.call(printf, "OUT OF RANGE\n\n\r");
-                        break;
+                        printQueue.call(puts, "OUT OF RANGE\r\n");
+                        //break;
                     }
                     else 
                     {
@@ -182,9 +182,10 @@
                         pc->printf("Sample rate set to %5.2f\n\n\r", sample_rate); 
                         printlock.unlock();}                
                         */
-                        printQueue.call(printf, "Sample rate set to %5.2f\n\n\r", sample_rate);
-                        break;
+                        printQueue.call(printf, "SAMPLE RATE SET TO %5.2f\r\n\n", sample_rate);
+                        //break;
                     }
+                    break;
                     
                 case (STATE) :
                     if (e_arg == ON)
@@ -196,8 +197,8 @@
                         pc->printf("Sampling ON\n\n\r");
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"Sampling ON\n\n\r");
-                        break;
+                        printQueue.call(puts,"SAMPLING ENABLED\r\n");
+                        //break;
                     }
                     else if (e_arg == OFF)
                     {
@@ -209,8 +210,8 @@
                         pc->printf("Sampling OFF\n\n\r");
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"Sampling OFF\n\n\r");
-                        break; 
+                        printQueue.call(puts,"SAMPLING DISABLED\r\n");
+                        //break; 
                     }
                     else
                     {
@@ -219,10 +220,10 @@
                         pc->printf("Invalid command\n\n\r"); 
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"Invalid command\n\n\r");
-                        break;
+                        printQueue.call(puts,"INVALID COMMAND\r\n");
+                        //break;
                     }
-                      
+                    break;
                     
                 case (LOGGING) :
                    if (e_arg == ON)
@@ -233,8 +234,8 @@
                         pc->printf("LOGGING ON\n\n\r");
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"LOGGING ON\n\n\r");
-                        break;
+                        printQueue.call(puts,"LOGGING ENABLED\r\n");
+                        //break;
                     }
                     else if (e_arg == OFF)
                     {
@@ -244,8 +245,8 @@
                         pc->printf("LOGGING OFF\n\n\r");
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"LOGGING OFF\n\n\r");
-                        break; 
+                        printQueue.call(puts,"LOGGING DISABLED\r\n");
+                        //break; 
                     }
                     else
                     {
@@ -254,10 +255,10 @@
                         pc->printf("INVALID COMMAND\n\n\r"); 
                         printlock.unlock();
                         */
-                        printQueue.call(printf,"INVALID COMMAND\n\n\r");
-                        break;
+                        printQueue.call(puts,"INVALID COMMAND\r\n");
+                        //break;
                     }
-                    //break;
+                    break;
                     
                 default :
                     /*
@@ -265,7 +266,7 @@
                     pc->printf("INVALID COMMAND\n\n\r");
                     printlock.unlock();
                     */
-                    printQueue.call(printf,"INVALID COMMAND\n\n\r");
+                    printQueue.call(puts,"INVALID COMMAND\r\n");
                     break;            
             }    
         }