Modify changes to test TCP socket.

Dependents:   EthernetInterface

Fork of lwip by mbed official

Revision:
12:963887732b7c
Parent:
0:51ac1d130fd4
--- a/api/tcpip.c	Mon Aug 19 18:37:54 2013 +0300
+++ b/api/tcpip.c	Fri Dec 13 11:39:39 2013 +0000
@@ -49,6 +49,8 @@
 #include "netif/etharp.h"
 #include "netif/ppp_oe.h"
 
+#include <stdio.h>
+
 /* global variables */
 static tcpip_init_done_fn tcpip_init_done;
 static void *tcpip_init_done_arg;
@@ -83,15 +85,26 @@
   LOCK_TCPIP_CORE();
   while (1) {                          /* MAIN Loop */
     UNLOCK_TCPIP_CORE();
+    //printf("Unlock realizado\n");
     LWIP_TCPIP_THREAD_ALIVE();
     /* wait for a message, timeouts are processed while waiting */
     sys_timeouts_mbox_fetch(&mbox, (void **)&msg);
+    /*
+    if (msg->type == 0)
+        printf("Tirou do Mbox %d Tipo %d\n\n", msg->msg.apimsg, msg->type); 
+    else
+        printf("Tirou InPackt %d Tipo %d\n\n", (int) msg, msg->type); 
+    //printf("Pegou fetch\n");
+    */
     LOCK_TCPIP_CORE();
+    //printf("Executou lock\n");
     switch (msg->type) {
 #if LWIP_NETCONN
     case TCPIP_MSG_API:
       LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg));
+      
       msg->msg.apimsg->function(&(msg->msg.apimsg->msg));
+      //printf("Executou funcao\n");
       break;
 #endif /* LWIP_NETCONN */
 
@@ -104,6 +117,7 @@
       } else
 #endif /* LWIP_ETHERNET */
       {
+        printf("AAAAAA\n");
         ip_input(msg->msg.inp.p, msg->msg.inp.netif);
       }
       memp_free(MEMP_TCPIP_MSG_INPKT, msg);
@@ -181,6 +195,7 @@
     msg->type = TCPIP_MSG_INPKT;
     msg->msg.inp.p = p;
     msg->msg.inp.netif = inp;
+    //printf("Colocou InPact %d\n", (int) msg);
     if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
       memp_free(MEMP_TCPIP_MSG_INPKT, msg);
       return ERR_MEM;
@@ -301,6 +316,7 @@
 tcpip_apimsg(struct api_msg *apimsg)
 {
   struct tcpip_msg msg;
+  int x=-1;
 #ifdef LWIP_DEBUG
   /* catch functions that don't set err */
   apimsg->msg.err = ERR_VAL;
@@ -309,8 +325,13 @@
   if (sys_mbox_valid(&mbox)) {
     msg.type = TCPIP_MSG_API;
     msg.msg.apimsg = apimsg;
+    //printf("Vai dar Post\n");
+    
     sys_mbox_post(&mbox, &msg);
-    sys_arch_sem_wait(&apimsg->msg.conn->op_completed, 0);
+    //printf("Passou Post\n");
+    //printf("Colocou no Mbox %d\n\n", apimsg);
+    x = sys_arch_sem_wait(&apimsg->msg.conn->op_completed, 0);
+    //printf("Passou Wait %d\n", x);
     return apimsg->msg.err;
   }
   return ERR_VAL;