Skip to content

Commit f2aab04

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

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

cores/arduino/USB/CDC.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,28 +256,14 @@ void Serial_::flush(void)
256256

257257
size_t Serial_::write(const uint8_t *buffer, size_t size)
258258
{
259-
/* only try to send bytes if the high-level CDC connection itself
260-
is open (not just the pipe) - the OS should set lineState when the port
261-
is opened and clear lineState when the port is closed.
262-
bytes sent before the user opens the connection or after
263-
the connection is closed are lost - just like with a UART. */
264-
265-
// TODO - ZE - check behavior on different OSes and test what happens if an
266-
// open connection isn't broken cleanly (cable is yanked out, host dies
267-
// or locks up, or host virtual serial port hangs)
268-
if (_usbLineInfo.lineState > 0) // Problem with Windows(R)
269-
{
270-
uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size);
259+
uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size);
271260

272-
if (r > 0) {
273-
return r;
274-
} else {
275-
setWriteError();
276-
return 0;
277-
}
261+
if (r > 0) {
262+
return r;
263+
} else {
264+
setWriteError();
265+
return 0;
278266
}
279-
setWriteError();
280-
return 0;
281267
}
282268

283269
size_t Serial_::write(uint8_t c) {

0 commit comments

Comments
 (0)