For coursework of group 3 in SOFT564Z

Dependencies:   Motordriver ros_lib_kinetic

Revision:
7:2796f0b5228d
Parent:
5:207e0cd8b9de
Child:
8:e406c6f728bd
--- a/Debug.cpp	Mon Dec 02 13:13:15 2019 +0000
+++ b/Debug.cpp	Thu Dec 05 13:02:10 2019 +0000
@@ -5,7 +5,7 @@
 #include "mbed.h"
 #include "rtos.h"
 #include "Debug.hpp"
-#include "dateTime.hpp"
+//#include "dateTime.hpp"
 #include "General.hpp"
 #include "Pins.h"
 
@@ -53,7 +53,7 @@
     // Print DATA table to present data
     pc.printf("|      PROJ515      :      DEBUG MENU    |                                                      |\n\r"
               "|***********************************************************************************************|\n\r"
-              "|     Error Level       |      Time Stamp       |                 Error MSG                     |\n\r"
+              "|      Error Code       |      Time Stamp       |                 Error MSG                     |\n\r"
               "|-----------------------|-----------------------|-----------------------------------------------|\n\r");
     for(char idx = 0; idx < Rows; idx++) {
         pc.printf("|                       |                       |                                               |\n\r");
@@ -149,6 +149,7 @@
     }
     // re attach the interupt on the serial input flag
     pc.attach(this, &Terminal::Input_Handler,pc.RxIrq);
+    wait_ms(100);
 }
 
 /*------------------------------------------------------------------------------
@@ -193,15 +194,11 @@
 ------------------------------------------------------------------------------*/
 void Terminal::Input_Handler(void)
 {
-    // remove the interupt from the serial input flag
-    pc.attach(NULL,pc.RxIrq);
     // if data is in the buffer call function to check which key has been entered
     if(pc.readable()!= 0) {
+        // remove the interupt from the serial input flag
+        pc.attach(NULL,pc.RxIrq);
         TerminalQueue.call(&PC, &Terminal::checkKEY);
-
-        // if no data present in the buffer re attach the interupt
-    } else {
-        pc.attach(this, &Terminal::Input_Handler,pc.RxIrq);
     }
 }
 
@@ -228,12 +225,15 @@
     Cursor(3,(Rows+8));
     pc.printf("                                                                                              ");
     Cursor(3,(Rows+8));
+    
+    char buffer[20];
+    sprintf(buffer, "%d", msgs.ErrorCode);
 
     // Print diferent messages dependent on the Error code attached in the struct Error
     switch(msgs.ErrorCode) {
         case warning :
             Colour(ColourYELLOW);
-            PrintDATA(" Warning" , CurrentIDX);
+            PrintDATA(buffer , CurrentIDX);
             PrintDATA(msgs.TimeStamp , CurrentIDX+1);
             PrintDATA(msgs.ErrorMSGS , CurrentIDX+2);
             CurrentIDX += 4;
@@ -241,7 +241,7 @@
 
         case fault :
             Colour(ColourAMBER);
-            PrintDATA(" Fault" , CurrentIDX);
+            PrintDATA(buffer , CurrentIDX);
             PrintDATA(msgs.TimeStamp , CurrentIDX+1);
             PrintDATA(msgs.ErrorMSGS , CurrentIDX+2);
             CurrentIDX += 4;
@@ -249,7 +249,7 @@
 
         case criticalERROR :
             Colour(ColourRED);
-            PrintDATA(" Critical ERROR" , CurrentIDX);
+            PrintDATA(buffer , CurrentIDX);
             PrintDATA(msgs.TimeStamp , CurrentIDX+1);
             PrintDATA(msgs.ErrorMSGS , CurrentIDX+2);
             CurrentIDX += 4;
@@ -257,7 +257,7 @@
 
         case criticalFAILURE :
             Colour(ColourRED);
-            PrintDATA(" Critical FAILURE" , CurrentIDX);
+            PrintDATA(buffer , CurrentIDX);
             PrintDATA(msgs.TimeStamp , CurrentIDX+1);
             PrintDATA(msgs.ErrorMSGS , CurrentIDX+2);
             CurrentIDX += 4;
@@ -327,11 +327,11 @@
 void Flag_Error(int ErrorCode, char* ErrorMSG)
 {
     BYTE SampleTimeTag [20];   
-    strcpy(SampleTimeTag, getSystemDateTime());
+    //strcpy(SampleTimeTag, getSystemDateTime());
     
     Error msgs;
     msgs.ErrorCode = ErrorCode;
-    msgs.TimeStamp = SampleTimeTag;
+    msgs.TimeStamp = "Temp";
     msgs.ErrorMSGS = ErrorMSG;
     TerminalQueue.call(&PC, &Terminal::ERROR_MSGS, msgs);
 }
\ No newline at end of file