From 58fc0d17cc2d7c5dfb4ce268b7e43d35eebac342 Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Sun, 18 Dec 2011 17:52:35 -0500 Subject: added asynchronous buffering of received CDC characters This fixes the issue Federico reported where bytes written by host but not read by sketch would cause serial connection to lock up. Ring buffer implementation is based on HardwareSerial.cpp. Adds public accept() method to CDC. --- cores/arduino/USBCore.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cores/arduino/USBCore.cpp') diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 398bc73..7924078 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -599,6 +599,8 @@ ISR(USB_GEN_vect) { #ifdef CDC_ENABLED USB_Flush(CDC_TX); // Send a tx frame if found + while (USB_Available(CDC_RX)) // Handle received bytes (if any) + Serial.accept(); #endif // check whether the one-shot period has elapsed. if so, turn off the LED -- cgit v1.2.3-18-g5258