A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

Revision:
144:52cb5b6667cc
Parent:
142:3b40320f3f73
--- a/io/MTSSerialFlowControl.cpp	Sun Jan 05 05:49:42 2014 +0000
+++ b/io/MTSSerialFlowControl.cpp	Wed Jan 15 19:24:38 2014 +0000
@@ -63,23 +63,12 @@
 
 void MTSSerialFlowControl::handleRead()
 {
-    while (serial.readable()) {
-        char byte = serial.getc();
-        if(rxBuffer.write(byte) != 1) {
-            rts.write(1);
-            rxReadyFlag = false;
-            printf("[ERROR] Serial Rx Byte Dropped [%c][0x%02X]\r\n", byte, byte);
-            if(byte == 0xFF) {
-                // hack so we dont hang - fix later
-                puts("[ERR] Comm errors, must reboot");
-                fflush(stdout);
-                NVIC_SystemReset();
-            }
-            return;
-        }
-        if (rxBuffer.size() > highThreshold) {
-            notifyStopSending();
-        }
+    char byte = serial.getc();
+    if(rxBuffer.write(byte) != 1) {
+        printf("[ERROR] Serial Rx Byte Dropped [%c][0x%02X]\r\n", byte, byte);
+    }
+    if (rxBuffer.size() > highThreshold) {
+        notifyStopSending();
     }
 }
 
@@ -89,7 +78,9 @@
         if (serial.writeable() && cts.read() == 0) {
             char byte;
             if(txBuffer.read(byte) == 1) {
+                serial.attach(NULL, Serial::RxIrq);
                 serial.putc(byte);
+                serial.attach(this, &MTSSerialFlowControl::handleRead, Serial::RxIrq);
             }
         } else {
             return;