From 02afb3acea1f3cba73a90fbededd34f09d3e35ca Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 22 Sep 2015 16:21:54 +0200 Subject: [PATCH 1/2] Fix CDC write() when DTR is not set Fix https://github.com/arduino/Arduino/issues/1182 --- hardware/arduino/avr/cores/arduino/CDC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/arduino/avr/cores/arduino/CDC.cpp b/hardware/arduino/avr/cores/arduino/CDC.cpp index 7168408743b..0467693a3be 100644 --- a/hardware/arduino/avr/cores/arduino/CDC.cpp +++ b/hardware/arduino/avr/cores/arduino/CDC.cpp @@ -206,7 +206,7 @@ size_t Serial_::write(const uint8_t *buffer, size_t size) // TODO - ZE - check behavior on different OSes and test what happens if an // open connection isn't broken cleanly (cable is yanked out, host dies // or locks up, or host virtual serial port hangs) - if (_usbLineInfo.lineState > 0) { + if (USBDevice.configured()) { int r = USB_Send(CDC_TX,buffer,size); if (r > 0) { return r; From b4fd19c57997dd3147c91209ab026a151a8e3499 Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 22 Sep 2015 20:41:08 +0200 Subject: [PATCH 2/2] Avoid long CDC write timeout if host isnt listening --- hardware/arduino/avr/cores/arduino/CDC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/arduino/avr/cores/arduino/CDC.cpp b/hardware/arduino/avr/cores/arduino/CDC.cpp index 0467693a3be..f569f790488 100644 --- a/hardware/arduino/avr/cores/arduino/CDC.cpp +++ b/hardware/arduino/avr/cores/arduino/CDC.cpp @@ -206,7 +206,7 @@ size_t Serial_::write(const uint8_t *buffer, size_t size) // TODO - ZE - check behavior on different OSes and test what happens if an // open connection isn't broken cleanly (cable is yanked out, host dies // or locks up, or host virtual serial port hangs) - if (USBDevice.configured()) { + if (USBDevice.configured() && availableForWrite()) { int r = USB_Send(CDC_TX,buffer,size); if (r > 0) { return r;