RealtimeCompLab2

Dependencies:   mbed

Fork of PPP-Blinky by Nicolas Nackel

Revision:
49:2213f9c132b2
Parent:
48:6352c1411c5f
Child:
50:ad4e7c3c88e5
--- a/main.cpp	Thu Jan 19 20:40:42 2017 +0000
+++ b/main.cpp	Tue Jan 24 19:34:28 2017 +0000
@@ -50,7 +50,7 @@
 
 // the serial port receive buffer and packet buffer
 #define BUFLEN (1<<12)
-char rxbuf[BUFLEN];
+char rxbufppp[BUFLEN]; // BUFLEN must be a power of two because we use & operator for fast wrap-around in rxHandler
 char frbuf[2000]; // send/receive buffer for ppp frames
 
 // a structure to keep all our ppp globals in
@@ -78,7 +78,7 @@
 void pppInitStruct()
 {
     ppp.online=0;
-    ppp.rx.buf=rxbuf;
+    ppp.rx.buf=rxbufppp;
     ppp.rx.tail=0;
     ppp.rx.head=0;
     ppp.pkt.buf=frbuf;
@@ -157,18 +157,18 @@
     int idx = start;
     while(1) {
         if (unstuff==0) {
-            if (rxbuf[idx]==0x7d) unstuff=1;
+            if (rxbufppp[idx]==0x7d) unstuff=1;
             else {
-                *dest = rxbuf[idx];
+                *dest = rxbufppp[idx];
                 ppp.pkt.len++;
                 dest++;
-                crcDo(rxbuf[idx]);
+                crcDo(rxbufppp[idx]);
             }
         } else { // unstuff
-            *dest = rxbuf[idx]^0x20;
+            *dest = rxbufppp[idx]^0x20;
             ppp.pkt.len++;
             dest++;
-            crcDo(rxbuf[idx]^0x20);
+            crcDo(rxbufppp[idx]^0x20);
             unstuff=0;
         }
         idx = (idx+1) & (BUFLEN-1);
@@ -844,7 +844,7 @@
 void scanForConnectString()
 {
     if ( ppp.online==0 ) {
-        char * clientFound = strstr( (char *)rxbuf, "CLIENTCLIENT" ); // look for PC string
+        char * clientFound = strstr( (char *)rxbufppp, "CLIENTCLIENT" ); // look for PC string
         if( clientFound ) {
             strcpy( clientFound, "FOUND!FOUND!" ); // overwrite so we don't get fixated
             pc.printf("CLIENTSERVER"); // respond to PC
@@ -858,7 +858,7 @@
 {
     pc.baud(115200); // USB virtual serial port
 #ifndef SERIAL_PORT_MONITOR_NO
-    xx.baud(115200); // second serial port for debug(((((((( messages
+    xx.baud(115200); // second serial port for debug messages
     xx.puts("\x1b[2J\x1b[HReady\n"); // VT100 code for clear screen & home
 #endif
     pppInitStruct(); // initialize all the PPP properties