MODSERIAL with support for more devices. Added support for LPC4330

Dependents:   HC05_AT_mode GPS_U-blox_NEO-6M_Test_Code GPS_U-blox_NEO-6M_Code UbloxGPSWithThread ... more

Fork of MODSERIAL by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Fri Oct 11 18:31:01 2013 +0000
Parent:
30:b04ce87dc424
Child:
32:f42def64c4ee
Commit message:
Added claim function to redirect stdout (or similar)

Changed in this revision

ChangeLog.c Show annotated file Show diff for this revision Revisions of this file
MODSERIAL.cpp Show annotated file Show diff for this revision Revisions of this file
MODSERIAL.h Show annotated file Show diff for this revision Revisions of this file
--- a/ChangeLog.c	Sun Sep 01 12:24:12 2013 +0000
+++ b/ChangeLog.c	Fri Oct 11 18:31:01 2013 +0000
@@ -1,4 +1,7 @@
 /* $Id:$
+1.31    11th October 2013
+    * Added claim function to redirect for example stdout
+
 1.30    1st September 2013
     * Removed all DMA related code (not supported in this version currently)
     * Minor bug fix
--- a/MODSERIAL.cpp	Sun Sep 01 12:24:12 2013 +0000
+++ b/MODSERIAL.cpp	Fri Oct 11 18:31:01 2013 +0000
@@ -93,4 +93,27 @@
 }
 
 
+bool MODSERIAL::claim (FILE *stream) {
+    if ( _name == NULL) {
+        error("claim requires a name to be given in the instantiator of the MODSERIAL instance!\r\n");
+    }
+    
+    //Add '/' before name:
+    char *path = new char[strlen(_name) + 2];
+    sprintf(path, "/%s", _name);
+    
+    if (freopen(path, "w", stream) == NULL) {
+        // Failed, should not happen
+        return false;
+    }
+    
+    delete(path);
+    
+    //No buffering
+    setvbuf(stdout, NULL, _IONBF, buffer_size[TxIrq]);
+    return true;
+} 
+
+
+
 }; // namespace AjK ends
--- a/MODSERIAL.h	Sun Sep 01 12:24:12 2013 +0000
+++ b/MODSERIAL.h	Fri Oct 11 18:31:01 2013 +0000
@@ -729,6 +729,19 @@
         return move(s, max, auto_detect_char);
     }
     
+    /**
+    * Function: claim
+    *
+    * Redirect a stream to this MODSERIAL object
+    *
+    * Important: A name parameter must have been added when creating the MODSERIAL object
+    *
+    * @ingroup API
+    * @param FILE *stream The stream to redirect (default = stdout)
+    * @return true if succeeded, else false
+    */    
+    bool claim(FILE *stream = stdout);
+    
     #if 0 // Inhereted from Serial/Stream, for documentation only
     /**
      * Function: putc