diff options
author | Zach Eveland <zeveland@blacklabel-development.com> | 2011-08-30 17:25:35 -0400 |
---|---|---|
committer | Zach Eveland <zeveland@blacklabel-development.com> | 2011-08-30 17:25:35 -0400 |
commit | df068274f4a383ce6c944168ce41f859f3bc22c9 (patch) | |
tree | 91398691bd927d908b8a879910a51ce9108c220d /cores/arduino/CDC.cpp | |
parent | af635024db2b5d46d57eb5f5da959f6b4f4bf42c (diff) |
on a CDC or HID write() error, call setWriteError(). better handling of USB_Send errors in CDC.
Diffstat (limited to 'cores/arduino/CDC.cpp')
-rw-r--r-- | cores/arduino/CDC.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index b229cb5..0d04b9c 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -166,9 +166,15 @@ size_t Serial_::write(uint8_t c) // 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) { - USB_Send(CDC_TX,&c,1); - return 1; + int r = USB_Send(CDC_TX,&c,1); + if (r > 0) { + return r; + } else { + setWriteError(); + return 0; + } } + setWriteError(); return 0; } |