Ryo Iizuka / libMiMic

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Revision:
58:03b89038b21a
Parent:
57:bc4330dfa62f
Child:
63:157ee3202edb
--- a/core/uip/NyLPC_cTcpSocket.c	Fri Sep 13 06:38:16 2013 +0000
+++ b/core/uip/NyLPC_cTcpSocket.c	Fri Sep 27 12:47:51 2013 +0000
@@ -292,7 +292,7 @@
 {
     int i;
     struct NyLPC_TcTcpSocket_TxQItem* q=i_inst->txbuf.txq;
-    while(!NyLPC_cStopwatch_isExpired(i_timer)){
+    do{
         //クローズドに遷移してしまったら、エラーである。
         if(i_inst->tcpstateflags==UIP_CLOSED){
             return NULL;
@@ -310,7 +310,7 @@
         i=i_inst->txbuf.wp;
         i_inst->txbuf.wp=(i+1)%NyLPC_TcTcpSocket_NUMBER_OF_TXQ;
         return &(q[i]);
-    }
+    }while(!NyLPC_cStopwatch_isExpired(i_timer));
     //失敗。タイムアウト。
     return NULL;
 }
@@ -424,7 +424,7 @@
 {
     NyLPC_TUInt8 f;
     lockResource(i_inst);
-    while(!NyLPC_cStopwatch_isExpired(i_timer)){
+    do{
         //パケットが送信中か調べる。
         if(!isPacketAcked(i_inst,i_sq)){
             //まだある場合は、タスクスイッチを繰り返して消失を待つ。
@@ -437,7 +437,7 @@
         f=i_inst->tcpstateflags;
         unlockResource(i_inst);
         return (f==UIP_CLOSED)?NyLPC_TBool_FALSE:NyLPC_TBool_TRUE;
-    }
+    }while(!NyLPC_cStopwatch_isExpired(i_timer));
     unlockResource(i_inst);
     return NyLPC_TBool_FALSE;
 }
@@ -591,7 +591,7 @@
  * Public function
  */
 
-NyLPC_TBool NyLPC_cTcpSocket_connect(NyLPC_TcTcpSocket_t* i_inst,struct NyLPC_TIPv4Addr* i_addr,NyLPC_TUInt16 i_peer_port,NyLPC_TUInt32 i_wait_in_msec)
+NyLPC_TBool NyLPC_cTcpSocket_connect(NyLPC_TcTcpSocket_t* i_inst,const struct NyLPC_TIPv4Addr* i_addr,NyLPC_TUInt16 i_peer_port,NyLPC_TUInt32 i_wait_in_msec)
 {
     volatile NyLPC_TUInt8 f;
     NyLPC_TUInt32 sq;
@@ -729,10 +729,8 @@
 
     //ESTABLISHED以外の場合は、エラー。
     NyLPC_cStopwatch_setNow(&sw);
-    while(NyLPC_cStopwatch_elapseInMsec(&sw)<i_wait_msec)
-    {
+    do{
         //読み出しバッファ情報のコピー
-
         //MUTEX LOCK
         lockResource(i_inst);
         st=i_inst->tcpstateflags;
@@ -764,7 +762,7 @@
         }
         //タスクスイッチ
         NyLPC_cThread_yield();
-    };
+    }while(NyLPC_cStopwatch_elapseInMsec(&sw)<i_wait_msec);
     //規定時間内に受信が成功しなかった。
     NyLPC_cStopwatch_finalize(&sw);
     return 0;
@@ -998,7 +996,7 @@
                 //再ロック
                 lockResource(i_inst);
                 //タイムアウトするか、UIP_CLOSED、もしくはTIME_WAITに遷移するのを待つ。(遷移はRxprocで自動的に実行。)
-                while(!NyLPC_cStopwatch_isExpired(&sw)){
+                do{
                     switch(i_inst->tcpstateflags)
                     {
                     case UIP_TIME_WAIT:
@@ -1017,7 +1015,7 @@
                     default:
                         break;
                     }
-                }
+                }while(!NyLPC_cStopwatch_isExpired(&sw));
                 unlockResource(i_inst);
             }
         }