diff --git a/hardware/arduino/avr/cores/arduino/CDC.cpp b/hardware/arduino/avr/cores/arduino/CDC.cpp index 7168408743b..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 (_usbLineInfo.lineState > 0) { + if (USBDevice.configured() && availableForWrite()) { int r = USB_Send(CDC_TX,buffer,size); if (r > 0) { return r;