SNICInterface for ThingPlug Example

Dependents:   ThingPlug_WiFi_Example ThingPlug_WiFi_Example_2

Fork of SNICInterface by muRata

Revision:
43:d80bbb12ffe6
Parent:
41:1c1b5ad4d491
Child:
52:29b4d0adddf3
diff -r 17d89443d899 -r d80bbb12ffe6 SNIC/SNIC_UartCommandManager.cpp
--- a/SNIC/SNIC_UartCommandManager.cpp	Fri Sep 19 01:46:17 2014 +0000
+++ b/SNIC/SNIC_UartCommandManager.cpp	Fri Nov 14 00:52:31 2014 +0000
@@ -160,6 +160,8 @@
     
     // Get socket id from payload
     socket_id = payload_p[2];
+    
+//  DEBUG_PRINT("bufferredPacket socket id:%d\r\n", socket_id);
     // Get Connection information
     C_SNIC_Core::tagCONNECT_INFO_T *con_info_p = instance_p->getConnectInfo( socket_id );
     if( con_info_p == NULL )
@@ -175,20 +177,30 @@
     
     // Get receive length from payload
     recv_len= ((payload_p[3]<<8) & 0xFF00) | payload_p[4];
-    for( int i = 0; i < recv_len; i++ )
+    
+    while( con_info_p->is_receive_complete == false )
+    {
+        Thread::yield();
+    }
+    
+//  DEBUG_PRINT("bufferredPacket recv_len:%d\r\n", recv_len);
+    int i;
+    for(i = 0; i < recv_len; i++ )
     {
         if( con_info_p->recvbuf_p->isFull() )
         {
             DEBUG_PRINT("Receive buffer is full.\r\n");
             break;
         }
-        
         // Add to receive buffer
         con_info_p->recvbuf_p->queue( payload_p[5+i] );
     }
+    //DEBUG_PRINT("###Receive queue[%d]\r\n", i);
     con_info_p->mutex.lock();
+    con_info_p->is_receive_complete = false;
     con_info_p->is_received = true;
     con_info_p->mutex.unlock();
+//  Thread::yield();
 }
 
 void C_SNIC_UartCommandManager::connectedTCPClient( unsigned char *payload_p, int payload_len )