My take on Pico_Robustness_Test

Dependencies:   PicoTCP lpc1768-picotcp-eth mbed-rtos mbed

Fork of Pico_Robustness_Test by TASS Belgium

Files at this revision

API Documentation at this revision

Comitter:
daniele
Date:
Thu Jul 25 09:37:32 2013 +0000
Parent:
1:97b1710fd9c3
Commit message:
Daniele's take on this test;

Changed in this revision

PicoTCP.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 97b1710fd9c3 -r 6da40f9e8301 PicoTCP.lib
--- a/PicoTCP.lib	Thu Jul 25 05:44:19 2013 +0000
+++ b/PicoTCP.lib	Thu Jul 25 09:37:32 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/daniele/code/PicoTCP/#ca30069e49bb
+http://mbed.org/users/daniele/code/PicoTCP/#ed8f44fa8db9
diff -r 97b1710fd9c3 -r 6da40f9e8301 main.cpp
--- a/main.cpp	Thu Jul 25 05:44:19 2013 +0000
+++ b/main.cpp	Thu Jul 25 09:37:32 2013 +0000
@@ -8,7 +8,7 @@
 
 
 #define SENDING_RETRIES    3u
-#define READING_RETRIES    3u
+#define READING_RETRIES    7u
 #define DHCP_RETRIES       10u
 #define BUFFER_SIZE        256
 
@@ -162,35 +162,41 @@
             retries = 0;
             
             // sending request
-            while(1)
+
+            ret = client.send_all(webStatistics[i].request,strlen(webStatistics[i].request));
+            if (ret <= 0) 
             {
-                if( (ret = client.send_all(webStatistics[i].request,strlen(webStatistics[i].request))) <= 0) 
-                {
-                    printf("Retry sending no %d, return :%d, error code :%d\n",retries,ret,pico_err);
-                    retries++;
-                }
-                else break;
+                printf("This test failed big time, ret=%d, err=%d!!\n", ret, pico_err);
+                while(1);;;
+            }
             
-                if(retries == SENDING_RETRIES+1)
-                {
-                    printf("Failed sending. Bailing out this connection\n");
-                    continue;
-                }            
-            }
             retries = 0;
-            
             // start reading
             while(true)
             {
-                if( (ret = client.receive(tmpBuffer,sizeof(tmpBuffer))) <= 0) 
+                ret = client.receive(tmpBuffer,sizeof(tmpBuffer));
+                if (ret == 0) {
+                    printf("Read timeout: ret = %d, err = %d, retry = %d\n", ret, pico_err, retries);
                     retries++;
-                else
+                } else if (ret < 0) {
+                    if (pico_err != PICO_ERR_ESHUTDOWN) {
+                        printf("Read error, bailing out. Ret = %d, err = %d\n", ret, pico_err);
+                        while(1);;;
+                    }
+                    client.close();
+                    break;
+                } else {
                     received += ret;
+                }
                 
-                if(retries == READING_RETRIES)
-                    break;                            
+                if(retries == READING_RETRIES) {
+                    printf("Read operation failed too many times. Giving up.\n");
+                    break;
+                }      
             }
             
+            
+            
             //Snapshot!
             time = PICO_TIME_MS() - time;
             
@@ -204,6 +210,10 @@
                 webStatistics[i].minReceived = received;
             }
             printf("Received : %d bytes\n",received);
+            if (received <= 0) {
+               printf("Test FAILED!\n"); 
+               while(1);;;  
+            }
             webStatistics[i].avgDuration = ((webStatistics[i].avgDuration *(webStatistics[i].snapshots++) ) + time)/webStatistics[i].snapshots;
             totalTime += time;
             memoryStamp();