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
Diff: io/MTSSerial.cpp
- Revision:
- 144:52cb5b6667cc
- Parent:
- 142:3b40320f3f73
- Child:
- 145:6a65bc3e1310
diff -r c7d8fe37981b -r 52cb5b6667cc io/MTSSerial.cpp --- a/io/MTSSerial.cpp Sun Jan 05 05:49:42 2014 +0000 +++ b/io/MTSSerial.cpp Wed Jan 15 19:24:38 2014 +0000 @@ -43,18 +43,9 @@ void MTSSerial::handleRead() { - while (serial.readable()) { - char byte = serial.getc(); - if(rxBuffer.write(byte) != 1) { - 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; - } + char byte = serial.getc(); + if(rxBuffer.write(byte) != 1) { + printf("[ERROR] Serial Rx Byte Dropped [%c][0x%02X]\r\n", byte, byte); } } @@ -65,7 +56,9 @@ if (serial.writeable()) { char byte; if(txBuffer.read(byte) == 1) { + serial.attach(NULL, Serial::RxIrq); serial.putc(byte); + serial.attach(this, &MTSSerialFlowControl::handleRead, Serial::RxIrq); } } else { return;