local fork
Dependencies: Socket USBHostWANDongle_bleedingedge lwip-sys lwip
Fork of VodafoneUSBModem_bleedingedge by
Diff: at/ATCommandsInterface.cpp
- Revision:
- 51:54ca82a7644c
- Parent:
- 50:8ad4cb12749d
- Child:
- 54:f9b1f5444963
--- a/at/ATCommandsInterface.cpp Thu Sep 27 13:11:44 2012 +0000 +++ b/at/ATCommandsInterface.cpp Thu Sep 27 14:48:19 2012 +0000 @@ -387,10 +387,21 @@ } } //Process line - processReadLine(); - //Shift remaining data to beginning of buffer - memmove(m_inputBuf, m_inputBuf + crPos + lfOff + 1, (m_inputPos + 1) - (crPos + lfOff + 1)); //Move null-terminating char as well - m_inputPos = m_inputPos - (crPos + lfOff + 1); //Adjust m_inputPos + int ret = processReadLine(); + if(ret) + { + m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer + lineDetected = false; + return ret; + } + + //If sendData has been called, all incoming data has been discarded + if(m_inputPos > 0) + { + memmove(m_inputBuf, m_inputBuf + crPos + lfOff + 1, (m_inputPos + 1) - (crPos + lfOff + 1)); //Move null-terminating char as well + m_inputPos = m_inputPos - (crPos + lfOff + 1); //Adjust m_inputPos + } DBG("One line was successfully processed"); lineProcessed = true; //Line was processed with success lineDetected = false; //Search now for a new line @@ -442,6 +453,7 @@ if(ret) { m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer lineDetected = false; return ret; } @@ -490,6 +502,7 @@ if(ret) { m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer lineDetected = false; return ret; } @@ -515,6 +528,7 @@ { //Discard everything m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer WARN("Incoming buffer is too short to process incoming line"); //Look for a new line lineDetected = false; @@ -721,13 +735,17 @@ if(ret) { WARN("Could not read from stream (returned %d)", ret); + m_inputPos = 0; //Reset input buffer state + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer return ret; - }; + } if( memcmp(m_inputBuf, data + dataPos, readLen) != 0 ) { //Echo does not match output WARN("Echo does not match output"); + m_inputPos = 0; //Reset input buffer state + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer return NET_DIFF; } @@ -739,6 +757,7 @@ DBG("String sent successfully"); m_inputPos = 0; //Reset input buffer state + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer return OK; }