fork of VodafoneUSBModem with updated USBHost library
Dependencies: Socket USBHost lwip-sys lwip
Dependents: VodafoneUSBModemSMSTest
Diff: at/ATCommandsInterface.cpp
- Revision:
- 61:0bcb8c5216d4
- Parent:
- 60:763eefc845b1
- Child:
- 62:6f42a974eea6
--- a/at/ATCommandsInterface.cpp Wed Oct 24 14:15:53 2012 +0000 +++ b/at/ATCommandsInterface.cpp Thu Nov 01 13:01:03 2012 +0000 @@ -110,6 +110,12 @@ } DBG("Closing AT interface"); + + //Lock transaction mutex + m_transactionMtx.lock(); + + //Disable events handling and advertize this to the events handlers + disableEvents(); //Stop processing m_processingThread.signal_set(AT_SIG_PROCESSING_STOP); @@ -123,9 +129,9 @@ m_pStream->abortRead(); //This is thread-safe m_processingMtx.lock(); m_open = false; - - //Disable events handling and advertize this to the events handlers - disableEvents(); + + //Unlock transaction mutex + m_transactionMtx.unlock(); DBG("AT interface closed"); return OK; @@ -250,6 +256,15 @@ DBG("Trying to enter abortRead()"); //Unlock process routine (abort read) m_pStream->abortRead(); //This is thread-safe + + //Wait for acknowledge + int msgResult; + do + { + evt = m_AT2Env.get(osWaitForever); + msgResult = *((int*) evt.value.p); + m_AT2Env.free((int*)evt.value.p); + } while(msgResult != AT_TIMEOUT); WARN("Command returned no message"); return NET_TIMEOUT; @@ -564,8 +579,12 @@ m_pStream->write((uint8_t*)&cr, 1, osWaitForever); //Carriage return line terminator m_transactionState = COMMAND_SENT; } - else + else //Timeout { + //Acknowledge + int* msg = m_AT2Env.alloc(osWaitForever); + *msg = AT_TIMEOUT; + m_AT2Env.put(msg); //Command has timed out m_transactionState = IDLE; //State-machine reset } m_env2AT.free(msg);