Skip to content

Commit b2462a5

Browse files
committed
Remove line state check in Serial_::write
It’s no longer needed with the timeout mechanism in USBCore.
1 parent 8f7873c commit b2462a5

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

cores/arduino/USB/CDC.cpp

+6-20
Original file line numberDiff line numberDiff line change
@@ -205,28 +205,14 @@ void Serial_::flush(void)
205205

206206
size_t Serial_::write(const uint8_t *buffer, size_t size)
207207
{
208-
/* only try to send bytes if the high-level CDC connection itself
209-
is open (not just the pipe) - the OS should set lineState when the port
210-
is opened and clear lineState when the port is closed.
211-
bytes sent before the user opens the connection or after
212-
the connection is closed are lost - just like with a UART. */
213-
214-
// TODO - ZE - check behavior on different OSes and test what happens if an
215-
// open connection isn't broken cleanly (cable is yanked out, host dies
216-
// or locks up, or host virtual serial port hangs)
217-
if (_usbLineInfo.lineState > 0) // Problem with Windows(R)
218-
{
219-
uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size);
208+
uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size);
220209

221-
if (r > 0) {
222-
return r;
223-
} else {
224-
setWriteError();
225-
return 0;
226-
}
210+
if (r > 0) {
211+
return r;
212+
} else {
213+
setWriteError();
214+
return 0;
227215
}
228-
setWriteError();
229-
return 0;
230216
}
231217

232218
size_t Serial_::write(uint8_t c) {

0 commit comments

Comments
 (0)