Own fork of C027_Support

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of C027_Support by u-blox

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Tue Jul 01 06:41:26 2014 +0000
Parent:
100:5e8b69232ea2
Child:
102:fb982ff9da82
Commit message:
improve purge at wakeup

Changed in this revision

MDM.cpp Show annotated file Show diff for this revision Revisions of this file
MDM.h Show annotated file Show diff for this revision Revisions of this file
Pipe.h Show annotated file Show diff for this revision Revisions of this file
--- a/MDM.cpp	Tue Jul 01 05:46:06 2014 +0000
+++ b/MDM.cpp	Tue Jul 01 06:41:26 2014 +0000
@@ -309,12 +309,11 @@
             pin = 1; ::wait_ms(100);
             
             // purge any messages 
-            while (WAIT != waitFinalResp(NULL,NULL,0))
-                /* nothing */;
+            purge();
             
-            // check interface and disable local echo
+            // check interface
             sendFormated("AT\r\n");
-            int r = waitFinalResp(NULL,NULL,500);
+            int r = waitFinalResp(NULL,NULL,1000);
             if(RESP_OK == r) break;
         }
         if (i < 0) {
--- a/MDM.h	Tue Jul 01 05:46:06 2014 +0000
+++ b/MDM.h	Tue Jul 01 06:41:26 2014 +0000
@@ -409,6 +409,10 @@
     */ 
     virtual int getLine(char* buf, int len) = 0; 
     
+    /* clear the pending input data
+    */
+    virtual void purge(void) = 0;
+    
     /** Write data to the device 
         \param buf the buffer to write
         \param buf size of the buffer to write
@@ -596,6 +600,13 @@
                 NOT_FOUND if nothing was found
     */ 
     virtual int getLine(char* buffer, int length);
+    
+    /* clear the pending input data */
+    virtual void purge(void) 
+    { 
+        while (readable())
+            getc();
+    }
 protected:
     /** Write bytes to the physical interface.
         \param buf the buffer to write
@@ -617,6 +628,7 @@
     //! Destructor          
     virtual ~MDMUsb(void);
     virtual int getLine(char* buffer, int length);
+    virtual void purge(void) { }
 protected:
     virtual int _send(const void* buf, int len);
 };
--- a/Pipe.h	Tue Jul 01 05:46:06 2014 +0000
+++ b/Pipe.h	Tue Jul 01 06:41:26 2014 +0000
@@ -212,13 +212,13 @@
         return t; 
     }
     
-    /** commit the index, mrk the current parsing index as consumed data.
+    /** commit the index, mark the current parsing index as consumed data.
     */
     void done(void) 
     {
         _r = _o; 
     } 
-    
+
 private:
     /** increment the index
         \param i index to increment