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:
110:8f3149c99112
Parent:
91:9439ad14d7f0
Child:
141:571e0ef6c8dc
--- a/io/MTSBufferedIO.cpp	Mon Dec 30 23:57:23 2013 +0000
+++ b/io/MTSBufferedIO.cpp	Tue Dec 31 17:30:07 2013 +0000
@@ -20,6 +20,7 @@
     int bytesWritten = 0;
     Timer tmr;
     tmr.start();
+    length = MAX(0,length);
     do {
         int bytesWrittenSwBuffer = txBuffer.write(&data[bytesWritten], length - bytesWritten);
         if(bytesWrittenSwBuffer > 0) {
@@ -36,6 +37,7 @@
 {   
     //Blocks until all bytes are written (different implementation planned once tx isr is working)
     int bytesWritten = 0;
+    length = MAX(0,length);
     do {
         int bytesWrittenSwBuffer = txBuffer.write(&data[bytesWritten], length - bytesWritten);
         handleWrite();
@@ -65,6 +67,7 @@
     int bytesRead = 0;
     Timer tmr;
     tmr.start();
+    length = MAX(0,length);
     do {
         bytesRead += rxBuffer.read(&data[bytesRead], length - bytesRead);
     } while(tmr.read_ms() <= timeoutMillis && bytesRead < length);
@@ -74,6 +77,7 @@
 int MTSBufferedIO::read(char* data, int length)
 {
     int bytesRead = 0;
+    length = MAX(0,length);
     while(bytesRead < length) {
         bytesRead += rxBuffer.read(&data[bytesRead], length - bytesRead);
     }