Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Revision:
125:ea88200b1df6
Parent:
124:18ef53f1d8b7
Child:
126:4e1058fa2128
diff -r 18ef53f1d8b7 -r ea88200b1df6 main.cpp
--- a/main.cpp	Wed Aug 09 12:37:01 2017 +0000
+++ b/main.cpp	Wed Aug 09 12:56:59 2017 +0000
@@ -191,7 +191,7 @@
 #endif
 }
 
-void printWhileCheckingInput( char * data )
+void putsWhileCheckingInput( char * data )
 {
 #ifdef SERIAL_PORT_MONITOR_YES
     char * nextChar = data;
@@ -205,7 +205,7 @@
 // a sniffer tool to assist in figuring out where in the code we are having characters in the input buffer
 void qq()
 {
-    if ( pc.readable() ) printWhileCheckingInput( "Character available!\n" );
+    if ( pc.readable() ) putsWhileCheckingInput( "Character available!\n" );
 }
 
 void crcReset()
@@ -247,12 +247,12 @@
         fillbuf();
         sprintf(pbuf, "%02x ", ppp.pkt.buf[i]);
         fillbuf();
-        printWhileCheckingInput(pbuf);
+        putsWhileCheckingInput(pbuf);
     }
     fillbuf();
     sprintf(pbuf, " CRC=%04x Len=%d\n", ppp.pkt.crc, ppp.pkt.len);
     fillbuf();
-    printWhileCheckingInput(pbuf);
+    putsWhileCheckingInput(pbuf);
 }
 
 void processPPPFrame(int start, int end)   // process received frame
@@ -297,7 +297,7 @@
             fillbuf();
             sprintf(pbuf, "\nPPP FCS(crc) Error CRC=%x Length = %d\n",ppp.pkt.crc,ppp.pkt.len); // print a debug line
             fillbuf();
-            printWhileCheckingInput( pbuf );
+            putsWhileCheckingInput( pbuf );
             if(0) dumpPPPFrame(); // set to 1 to dump frames with errors in them
 #endif        
     }
@@ -482,15 +482,15 @@
 #ifdef SERIAL_PORT_MONITOR_YES
         int icmpIdent = (icmpType[4]<<8)|icmpType[5];
         int icmpSequence = (icmpType[6]<<8)|icmpType[7];
-        if(0) {
+        if(1) {
             char pbuf[50];
             fillbuf();
             sprintf(pbuf, "ICMP PING %d.%d.%d.%d %d.%d.%d.%d ", srcAdr[0],srcAdr[1],srcAdr[2],srcAdr[3],dstAdr[0],dstAdr[1],dstAdr[2],dstAdr[3]);
-            printWhileCheckingInput( pbuf );
+            putsWhileCheckingInput( pbuf );
             fillbuf();
-            sprintf(pbuf, "Ident %04x Sequence %04d ",icmpIdent,icmpSequence);
+            sprintf(pbuf, "Ident %04x Sequence %04d \n",icmpIdent,icmpSequence);
             fillbuf();
-            printWhileCheckingInput( pbuf );
+            putsWhileCheckingInput( pbuf );
         }
 #endif        
         char src[4];
@@ -578,9 +578,9 @@
     char * dstAdr =     ipPkt+16; // 4 bytes = total of 20 bytes
     n=n+sprintf(pbuf+n, " %d.%d.%d.%d %d.%d.%d.%d ",srcAdr[0],srcAdr[1],srcAdr[2],srcAdr[3], dstAdr[0],dstAdr[1],dstAdr[2],dstAdr[3]); // full ip addresses
 #endif
-    printWhileCheckingInput( pbuf );
+    putsWhileCheckingInput( pbuf );
 #ifndef TCP_HEADER_DUMP_YES
-    printWhileCheckingInput('\x1b[30m\n'); // there is no TCP header dump, so terminate the line with \n and VT100 code for black
+    putsWhileCheckingInput('\x1b[30m\n'); // there is no TCP header dump, so terminate the line with \n and VT100 code for black
 #endif
 #endif
 }
@@ -620,10 +620,10 @@
     flagInfo[1]=0; // ' '
     flagInfo[2]=0;
 #endif
-    printWhileCheckingInput( flagInfo );
+    putsWhileCheckingInput( flagInfo );
 #define EVERY_PACKET_ON_A_NEW_LINE_YES
 #ifdef EVERY_PACKET_ON_A_NEW_LINE_YES
-    putcWhileCheckingInput('\n'); // write a newline after every packet
+    putsWhileCheckingInput("\x1b[30m\n"); // write a black color and newline after every packet
 #endif
     if( outGoing && ( flags == 0x11 ) ) { // ACK/FIN - if this is an outgoing ACK/FIN its the end of a tcp conversation
         putcWhileCheckingInput('\n'); // insert an extra new line to mark the end of an HTTP the conversation
@@ -880,12 +880,12 @@
         fillbuf();
         sprintf(pbuf, "TCP %d ipHeader %d tcpHeader %d Data %d\n", ipPktLen, ipHeaderLen, headerSizeTCP, dataLen);    // 1 for more verbose
         fillbuf();
-        printWhileCheckingInput( pbuf );
+        putsWhileCheckingInput( pbuf );
     }
     if (dataLen > 0) {
         ppp.pkt.buf[4+ipHeaderLen+headerSizeTCP+dataLen]=0; // insert a null after the data so debug printf stops printing after the data
-        printWhileCheckingInput( ppp.pkt.buf+4+ipHeaderLen+headerSizeTCP );    // print the tcp payload data
-        printWhileCheckingInput("\n");
+        putsWhileCheckingInput( ppp.pkt.buf+4+ipHeaderLen+headerSizeTCP );    // print the tcp payload data
+        putsWhileCheckingInput("\n");
     }
 }