This class provides an API to communicate with a u-blox GNSS chip. The files here were originally part of the C027_Support library (https://developer.mbed.org/teams/ublox/code/C027_Support/ at revision 138:dafbbf31bf76) but have been separated out, primarily for use on the u-blox C030 board where the cellular interace portion of the C027_Support library will instead be provided through the new mbed Cellular API.

Dependents:   example-ublox-at-cellular-interface-ext example-low-power-sleep example-C030-out-of-box-demo example-C030-out-of-box-demo ... more

Revision:
2:b10ca4aa2e5e
Parent:
1:ef70a58a6c98
--- a/serial_pipe.cpp	Mon Apr 10 11:28:24 2017 +0100
+++ b/serial_pipe.cpp	Thu Apr 13 14:45:17 2017 +0000
@@ -20,8 +20,9 @@
             _pipeRx( (rx!=NC) ? rxSize : 0), 
             _pipeTx( (tx!=NC) ? txSize : 0)
 {
-    if (rx!=NC)
-        attach(this, &SerialPipe::rxIrqBuf, RxIrq);
+    if (rx!=NC) {
+        attach(callback(this, &SerialPipe::rxIrqBuf), RxIrq);
+    }
 }
 
 SerialPipe::~SerialPipe(void)
@@ -47,29 +48,28 @@
 { 
     int count = length;
     const char* ptr = (const char*)buffer;
-    if (count)
-    {
-        do
-        {
+    if (count) {
+        do {
             int written = _pipeTx.put(ptr, count, false);
             if (written) {
                 ptr += written;
                 count -= written;
                 txStart();
             }
-            else if (!blocking)
+            else if (!blocking) {
+                /* nothing / just wait */;
                 break;
-            /* nothing / just wait */;
+            }
         }
         while (count);
     }
+    
     return (length - count);
 }
 
 void SerialPipe::txCopy(void)
 {
-    while (_SerialPipeBase::writeable() && _pipeTx.readable())
-    {
+    while (_SerialPipeBase::writeable() && _pipeTx.readable()) {
         char c = _pipeTx.getc();
         _SerialPipeBase::_base_putc(c);
     }
@@ -79,8 +79,9 @@
 {
     txCopy();
     // detach tx isr if we are done 
-    if (!_pipeTx.readable())
+    if (!_pipeTx.readable()) {
         attach(NULL, TxIrq);
+    }
 }
 
 void SerialPipe::txStart(void)
@@ -89,8 +90,9 @@
     attach(NULL, TxIrq);
     txCopy();
     // attach the tx isr to handle the remaining data
-    if (_pipeTx.readable())
-        attach(this, &SerialPipe::txIrqBuf, TxIrq);
+    if (_pipeTx.readable()) {
+        attach(callback(this, &SerialPipe::txIrqBuf), TxIrq);
+    }
 }
 
 // rx channel
@@ -101,8 +103,10 @@
 
 int SerialPipe::getc(void)                          
 { 
-    if (!_pipeRx.readable())
+    if (!_pipeRx.readable()) {
         return EOF;
+    }
+
     return _pipeRx.getc(); 
 } 
 
@@ -116,10 +120,10 @@
     while (_SerialPipeBase::readable())
     {
         char c = _SerialPipeBase::_base_getc();
-        if (_pipeRx.writeable())
+        if (_pipeRx.writeable()) {
             _pipeRx.putc(c);
-        else 
-            /* overflow */;
+        } else {
+            /* overflow */
+        }
     }
 }
-