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
Diff: PCConnector/SWUSBServer.cpp
- Revision:
- 13:7dcb1642ef99
- Parent:
- 11:676ea42afd56
- Child:
- 16:66c7a09e71ee
--- a/PCConnector/SWUSBServer.cpp Wed Feb 08 18:00:33 2017 +0000 +++ b/PCConnector/SWUSBServer.cpp Wed Feb 08 23:47:02 2017 +0000 @@ -10,7 +10,7 @@ USBServer::USBServer(uint16_t vendor_id, uint16_t product_id) : //m_hid(HID_REPORT_LENGTH, HID_REPORT_LENGTH, vendor_id, product_id), m_shouldTerminate(false), - m_stat(HID_SER_STAT_STOPPED), + m_stat(SER_STAT_STOPPED), m_usbThread(NULL), m_usb(NULL) { @@ -36,7 +36,7 @@ void USBServer::Update(float deltaTime) { - if(!m_shouldTerminate && m_stat == HID_SER_STAT_STOPPED) + if(!m_shouldTerminate && m_stat == SER_STAT_STOPPED) { if(m_usbThread) { @@ -46,7 +46,7 @@ //m_hidThread.start(callback(this, &USBServer::HIDConnectingThread)); } - if(!m_shouldTerminate && m_stat == HID_SER_STAT_CONNECTED) + if(!m_shouldTerminate && m_stat == SER_STAT_CONNECTED) { if(m_usbThread) { @@ -63,7 +63,7 @@ { m_qlocker.lock(); m_msgQueue.push_back(type + msg); - if(m_stat == HID_SER_STAT_RUNNING && m_usbThread) + if(m_stat == SER_STAT_RUNNING && m_usbThread) m_usbThread->signal_set(THREAD_SIGNAL_QUEUE); m_qlocker.unlock(); return true; @@ -76,14 +76,14 @@ bool USBServer::PushUnreliableMsg(const char type, const std::string & msg) { - if(m_stat != HID_SER_STAT_RUNNING || m_msgQueue.size() >= UNRELIABLE_QUEUE_MAX_SIZE) + if(m_stat != SER_STAT_RUNNING || m_msgQueue.size() >= UNRELIABLE_QUEUE_MAX_SIZE) return false; if(msg.length() <= HID_REPORT_LENGTH) { m_qlocker.lock(); m_msgQueue.push_back(type + msg); - if(m_stat == HID_SER_STAT_RUNNING && m_usbThread) + if(m_stat == SER_STAT_RUNNING && m_usbThread) m_usbThread->signal_set(THREAD_SIGNAL_QUEUE); m_qlocker.unlock(); return true; @@ -96,7 +96,7 @@ void USBServer::RunningThread() { - m_stat = HID_SER_STAT_RUNNING; + m_stat = SER_STAT_RUNNING; while(!m_shouldTerminate) { @@ -122,14 +122,20 @@ void USBServer::ConnectingThread() { - m_stat = HID_SER_STAT_CONNECTING; + m_stat = SER_STAT_CONNECTING; m_usb = new Serial(USBTX, USBRX, "SmartWheels"); m_usb->printf("%s\n", HANDSHAKE_MSG_TER); - m_stat = HID_SER_STAT_CONNECTED; + m_stat = SER_STAT_CONNECTED; } + +uint8_t USBServer::GetStatus() const +{ + return m_stat; +} + } \ No newline at end of file