C027 updated to work with latest mBed libraries

Dependents:   Cellular_HelloMQTT UBLOXModemDriver UBLOXMQTTDriver

Fork of C027_Support by u-blox

Revision:
15:5eda64e5b9d1
Parent:
14:69c3e57ef0f5
Child:
16:4a7ba1887e81
--- a/SerialPipe.cpp	Tue Nov 19 09:02:35 2013 +0000
+++ b/SerialPipe.cpp	Fri Nov 22 08:23:30 2013 +0000
@@ -2,8 +2,8 @@
 
 #include "SerialPipe.h"
 
-SerialPipe::SerialPipe(PinName tx, PinName rx, int rxSize, int txSize, const char* name) 
-    : Serial(tx,rx,name), _pipeRx(rxSize), _pipeTx(txSize)
+SerialPipe::SerialPipe(PinName tx, PinName rx, int rxSize, int txSize) 
+    : _SerialPipeBase(tx,rx), _pipeRx(rxSize), _pipeTx(txSize)
 {
     attach(this, &SerialPipe::rxIrqBuf, RxIrq);
     attach(this, &SerialPipe::txIrqBuf, TxIrq);
@@ -23,36 +23,35 @@
 
 int SerialPipe::putc(int c)    
 {
-    return _putc(c);
+    c = _pipeTx.putc(c);
+    txStart();
+    return c;
 }
 
 int SerialPipe::put(const void* buffer, int length, bool blocking)    
 { 
     int count = length;
     const char* ptr = (const char*)buffer;
-    while (count && blocking)
+    if (count)
     {
-        int written = _pipeTx.put(ptr, count, false);
-        ptr += written;
-        count -= written;
-        txStart();
+        do
+        {
+            int written = _pipeTx.put(ptr, count, false);
+            ptr += written;
+            count -= written;
+            txStart();
+        }
+        while (count && blocking);
     }
     return (length - count);
 }
 
-int SerialPipe::_putc(int c)    
-{
-    c = _pipeTx.putc(c);
-    txStart();
-    return c;
-}
-
 void SerialPipe::txIrqBuf(void)
 {
-    while (Serial::writeable() && _pipeTx.readable())
+    while (_SerialPipeBase::writeable() && _pipeTx.readable())
     {
         char c = _pipeTx.getc();
-        Serial::_putc(c);
+        _SerialPipeBase::_base_putc(c);
     }
 }
 
@@ -71,7 +70,9 @@
 
 int SerialPipe::getc(void)                          
 { 
-    return _getc(); 
+    if (!_pipeRx.readable())
+        return EOF;
+    return _pipeRx.getc(); 
 } 
 
 int SerialPipe::get(void* buffer, int length, bool blocking) 
@@ -79,16 +80,11 @@
     return _pipeRx.get((char*)buffer,length,blocking); 
 }
 
-int SerialPipe::_getc(void)                          
-{ 
-    return _pipeRx.getc(); 
-} 
-
 void SerialPipe::rxIrqBuf(void)
 {
-    while (Serial::readable())
+    while (_SerialPipeBase::readable())
     {
-        char c = Serial::_getc();
+        char c = _SerialPipeBase::_base_getc();
         if (_pipeRx.writeable())
             _pipeRx.putc(c);
         else 
@@ -98,8 +94,8 @@
 
 // -----------------------------------------------------------------------
 
-SerialPipeEx::SerialPipeEx(PinName tx, PinName rx, int rxSize, int txSize, const char* name) 
-    : SerialPipe(tx,rx,rxSize,txSize,name)
+SerialPipeEx::SerialPipeEx(PinName tx, PinName rx, int rxSize, int txSize) 
+    : SerialPipe(tx,rx,rxSize,txSize)
 {}
 
 int SerialPipeEx::getLine(char* buffer, int length)