Open Kabron287 opened 4 years ago
In fact it is done consciously. File: CDC.cpp 232
size_t Serial_::write(const uint8_t *buffer, size_t size)
{
/* only try to send bytes if the high-level CDC connection itself
is open (not just the pipe) - the OS should set lineState when the port
is opened and clear lineState when the port is closed.
bytes sent before the user opens the connection or after
the connection is closed are lost - just like with a UART. */
// 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)
{
int r = USB_Send(CDC_TX,buffer,size);
if (r > 0) {
return r;
} else {
setWriteError();
return 0;
}
}
setWriteError();
return 0;
}
Commenting if( ... solved the problem. IMHO, this functionality should be left to the user's choice.
Board: Arduino Micro(ATMEGA32U4) Test Sketch:
To reproduce the issue make LoopBack connection RX-TX open Terminal Emulator(e.g. CoolTerm) and begin to send something. Switch DTR state ON/OFF. If DTR OFF transmition stops. It does not correspond with ordinary USB to serial behavior, e.g. FT232 chip, which transmits and receves regardless DTR state.
The same test runs on Teensy 2.0 with no such issue.