For coursework of group 3 in SOFT564Z
Dependencies: Motordriver ros_lib_kinetic
Diff: Debug.cpp
- Revision:
- 5:207e0cd8b9de
- Parent:
- 4:8afc50a3e4ac
- Child:
- 6:3872858b7844
- Child:
- 7:2796f0b5228d
diff -r 8afc50a3e4ac -r 207e0cd8b9de Debug.cpp --- a/Debug.cpp Sat Nov 30 10:59:09 2019 +0000 +++ b/Debug.cpp Mon Dec 02 13:13:15 2019 +0000 @@ -5,14 +5,18 @@ #include "mbed.h" #include "rtos.h" #include "Debug.hpp" +#include "dateTime.hpp" #include "General.hpp" #include "Pins.h" // queue for Terminal events EventQueue TerminalQueue(32 * EVENTS_EVENT_SIZE); +/* The EventQueue object is part of mbed's rtos.h */ + // Create Object PC of class Terminal with Set SERIAL_TX and SERIAL_RX pins Terminal PC(SERIAL_TX, SERIAL_RX); +/* Terminal object defined in Debug.hpp */ /*------------------------------------------------------------------------------ Thread for handiling the terminal @@ -225,14 +229,12 @@ pc.printf(" "); Cursor(3,(Rows+8)); - char *TimeStamp = " 10:55-30/11/2019 "; - // Print diferent messages dependent on the Error code attached in the struct Error switch(msgs.ErrorCode) { case warning : Colour(ColourYELLOW); PrintDATA(" Warning" , CurrentIDX); - PrintDATA(TimeStamp , CurrentIDX+1); + PrintDATA(msgs.TimeStamp , CurrentIDX+1); PrintDATA(msgs.ErrorMSGS , CurrentIDX+2); CurrentIDX += 4; break; @@ -240,7 +242,7 @@ case fault : Colour(ColourAMBER); PrintDATA(" Fault" , CurrentIDX); - PrintDATA(TimeStamp , CurrentIDX+1); + PrintDATA(msgs.TimeStamp , CurrentIDX+1); PrintDATA(msgs.ErrorMSGS , CurrentIDX+2); CurrentIDX += 4; break; @@ -248,7 +250,7 @@ case criticalERROR : Colour(ColourRED); PrintDATA(" Critical ERROR" , CurrentIDX); - PrintDATA(TimeStamp , CurrentIDX+1); + PrintDATA(msgs.TimeStamp , CurrentIDX+1); PrintDATA(msgs.ErrorMSGS , CurrentIDX+2); CurrentIDX += 4; break; @@ -256,9 +258,12 @@ case criticalFAILURE : Colour(ColourRED); PrintDATA(" Critical FAILURE" , CurrentIDX); - PrintDATA(TimeStamp , CurrentIDX+1); + PrintDATA(msgs.TimeStamp , CurrentIDX+1); PrintDATA(msgs.ErrorMSGS , CurrentIDX+2); CurrentIDX += 4; + break; + + default : // This point should never be reached as it would indicate a full // failure which would cause the watchdog to reset the system break; @@ -321,8 +326,12 @@ ------------------------------------------------------------------------------*/ void Flag_Error(int ErrorCode, char* ErrorMSG) { + BYTE SampleTimeTag [20]; + strcpy(SampleTimeTag, getSystemDateTime()); + Error msgs; msgs.ErrorCode = ErrorCode; + msgs.TimeStamp = SampleTimeTag; msgs.ErrorMSGS = ErrorMSG; TerminalQueue.call(&PC, &Terminal::ERROR_MSGS, msgs); } \ No newline at end of file