Helpful logging and error format

Dependents:   Waldo_Embed_V2

Inspired by this blog post.

Work in Progress

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Fri May 10 18:36:27 2013 +0000
Parent:
6:163b9d47fa87
Child:
8:509ffcfb849f
Commit message:
Changed Serial member to be a pointer rather than a object. Caused contention when using .attach for interrupt handling

Changed in this revision

LogUtil.cpp Show annotated file Show diff for this revision Revisions of this file
LogUtil.h Show annotated file Show diff for this revision Revisions of this file
--- a/LogUtil.cpp	Wed May 01 03:51:03 2013 +0000
+++ b/LogUtil.cpp	Fri May 10 18:36:27 2013 +0000
@@ -23,14 +23,15 @@
  #include "LogUtil.h"
  #include "mbed.h"
  
- LogUtil::LogUtil() : debug(USBTX, USBRX)
- {
-    debug.baud(921600);
-    debug.printf("\033[2J");  // clear the terminal
-    debug.printf("\033[1;1H");// and set the cursor to home
+LogUtil::LogUtil(Serial &serial, uint32_t baudrate)
+{
+    _serial = &serial;
+    (baudrate > 0) ? _serial->baud(baudrate) : __nop();
+    _serial->printf("\033[2J");  // clear the terminal
+    _serial->printf("\033[1;1H");// and set the cursor to home
     wait(0.5f);
     return;
- }
- 
+}
+     
  
  
\ No newline at end of file
--- a/LogUtil.h	Wed May 01 03:51:03 2013 +0000
+++ b/LogUtil.h	Fri May 10 18:36:27 2013 +0000
@@ -75,13 +75,14 @@
  */ 
 class LogUtil
 {
+private:
+    Serial *_serial;
 public:
     
     /** Construct the LogUtil class and configure
      */
-    LogUtil();
-    Serial debug;
-    
+    LogUtil(Serial &serial, uint32_t baudrate = 0);
+        
 };