Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Revision:
113:d9666fe4d0ed
Parent:
112:30172f36bd33
Child:
114:8a5d70bbc1b2
--- a/main.cpp	Fri Aug 04 21:26:19 2017 +0000
+++ b/main.cpp	Sat Aug 05 08:45:32 2017 +0000
@@ -515,6 +515,7 @@
         snprintf(dstIP,16, "%d.%d.%d.%d", dstAdr[0],dstAdr[1],dstAdr[2],dstAdr[3]);
         debug("IP %s %s v%d h%d d%d e%d L%03d ",srcIP,dstIP,versionIP,headerSizeIP,dscpIP,ecnIP,packetLength);
         debug("i%04x f%d t%d p%d C%04x\n",identIP,flagsIP,ttlIP,protocolIP,checksumIP);
+        while ( pc.readable() ) fillbuf();
     }
 }
 
@@ -538,16 +539,17 @@
         memset(flagInfo,'.', 9); // fill string with "........."
         memset(flagInfo+9,0,1); // null terminate string
 
-        if (flags & (1<<0)) flagInfo[0]='F';
-        if (flags & (1<<1)) flagInfo[1]='S';
-        if (flags & (1<<2)) flagInfo[2]='R';
-        if (flags & (1<<3)) flagInfo[3]='P';
+        if (flags & (1<<0)) flagInfo[8]='F';
+        if (flags & (1<<1)) flagInfo[7]='S';
+        if (flags & (1<<2)) flagInfo[6]='R';
+        if (flags & (1<<3)) flagInfo[5]='P';
         if (flags & (1<<4)) flagInfo[4]='A';
-        if (flags & (1<<5)) flagInfo[5]='U';
-        if (flags & (1<<6)) flagInfo[6]='E';
-        if (flags & (1<<7)) flagInfo[7]='C';
-        if (flags & (1<<8)) flagInfo[8]='N';
+        if (flags & (1<<5)) flagInfo[3]='U';
+        if (flags & (1<<6)) flagInfo[2]='E';
+        if (flags & (1<<7)) flagInfo[1]='C';
+        if (flags & (1<<8)) flagInfo[0]='N';
         debug("TCP Flags %s Seq %u Ack %u\n", flagInfo, seq, ack); // show the flags in debug
+        while ( pc.readable() ) fillbuf();
     }
 }
 
@@ -785,6 +787,9 @@
     checksumtcp[1]=pseudoHeaderSum;
     memcpy( tcp-12, tempHold, 12); // restore the 12 bytes that the pseudo-header overwrote
 
+//    dumpHeaderIP();
+//    dumpHeaderTCP();
+
     send_pppFrame(); // All preparation complete - send the TCP response
 
     if (doFin==1) { // they want to shut down the link, so we have to send another packet to close our side of the link
@@ -792,8 +797,6 @@
         flagsOut = TCP_FLAG_ACK | TCP_FLAG_FIN; // tell them we are also finished
         goto sendTCP; // send our final packet for this conversation.
     }
-    dumpHeaderIP();
-    dumpHeaderTCP();
 }
 
 void dumpDataTCP()
@@ -988,7 +991,6 @@
     xx.baud(115200); // second serial port for debug messages
     xx.puts("\x1b[2J\x1b[HReady\n"); // VT100 code for clear screen & home
 #endif
-while(1){};
     pppInitStruct(); // initialize all the PPP properties
     while(1) {
         scanForConnectString(); // respond to connect command from windows dial up networking