SNICInterface for ThingPlug Example

Dependents:   ThingPlug_WiFi_Example ThingPlug_WiFi_Example_2

Fork of SNICInterface by muRata

Revision:
39:a1233ca02edf
Parent:
33:33f1bc919486
Child:
40:b6b10c22a121
diff -r f13e4e563d65 -r a1233ca02edf SNIC/SNIC_UartCommandManager.cpp
--- a/SNIC/SNIC_UartCommandManager.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/SNIC_UartCommandManager.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -1,16 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_UartCommandManager.cpp
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has implementation of function for management of 
-               SNIC UART Command.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #include "SNIC_UartCommandManager.h"
 #include "SNIC_Core.h"
 
@@ -181,7 +186,9 @@
         // Add to receive buffer
         con_info_p->recvbuf_p->queue( payload_p[5+i] );
     }
+    con_info_p->mutex.lock();
     con_info_p->is_received = true;
+    con_info_p->mutex.unlock();
 }
 
 void C_SNIC_UartCommandManager::connectedTCPClient( unsigned char *payload_p, int payload_len )
@@ -238,8 +245,9 @@
 //        printf( "create recv buffer[socket:%d]\r\n", payload_p[2]);
         con_info_p->recvbuf_p = new CircBuffer<char>(SNIC_UART_RECVBUF_SIZE);
     }
-
+    con_info_p->mutex.lock();
     con_info_p->is_received = true;
+    con_info_p->mutex.unlock();
     
     // Set remote IP address and remote port
     con_info_p->from_ip   = ((payload_p[3] << 24) | (payload_p[4] << 16) | (payload_p[5] << 8) | payload_p[6]);