SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Revision:
22:973f53a0e5fd
Parent:
19:c93f7fab165d
Child:
25:6f63053cee81
--- a/PCConnector/SWUSBServer.cpp	Sun Feb 12 22:29:45 2017 +0000
+++ b/PCConnector/SWUSBServer.cpp	Mon Feb 13 17:17:50 2017 +0000
@@ -149,6 +149,7 @@
             
             if(tempStr.compare(TICK_MSG_PC) == 0)
             {
+                PushReliableMsg('D', "Got Tick!");
                 tickTimer.reset();
             }
         }
@@ -166,19 +167,28 @@
 
 void USBServer::RxCallback()
 {
+    char ch = this->_getc();
+    if(m_bufPos >= RECEIVE_BUF_SIZE)
+    {
+        return;
+    }
     
-    if(!m_isReading && !m_hasMsgIn)
+    if(m_hasMsgIn)
     {
-        char ch = this->_getc();
+        return;
+    }
+    
+    if(!m_isReading)
+    {
+        //char ch = this->_getc();
         if(ch == '\x02')
         {
             m_isReading = true;
         }
     }
-    
-    while(this->readable())
+    else
     {
-        char ch = this->_getc();
+        //char ch = this->_getc();
         if(ch == '\x03')
         {
             m_isReading = false;
@@ -189,6 +199,8 @@
             m_recvBuf[m_bufPos++] = ch;
         }
     }
+    
+    //fflush(_file);
 }
     
 void USBServer::ConnectingThread()