Skip to content

Commit eea20ce

Browse files
committed
Reset transmit timeout on terminal re-connect.
1 parent 9373462 commit eea20ce

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: cores/arduino/USBSerial.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ size_t USBSerial::write(uint8_t ch)
6666
size_t USBSerial::write(const uint8_t *buffer, size_t size)
6767
{
6868
size_t rest = size;
69-
while (rest > 0) {
69+
while (rest > 0 && CDC_connected()) {
7070
// Determine buffer size available for write
7171
auto portion = (size_t)CDC_TransmitQueue_WriteSize(&TransmitQueue);
7272
// Truncate it to content size (if rest is greater)
@@ -83,8 +83,6 @@ size_t USBSerial::write(const uint8_t *buffer, size_t size)
8383
buffer += portion;
8484
// After storing data, start transmitting process
8585
CDC_continue_transmit();
86-
} else if (!CDC_connected()) {
87-
break;
8886
}
8987
}
9088
return size - rest;

Diff for: cores/arduino/stm32/usb/cdc/usbd_cdc_if.c

+3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ static int8_t USBD_CDC_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
179179
case CDC_SET_CONTROL_LINE_STATE:
180180
lineState =
181181
(((USBD_SetupReqTypedef *)pbuf)->wValue & 0x01) != 0; // Check DTR state
182+
if (lineState) { // Reset the transmit timeout when the port is connected
183+
transmitStart = 0;
184+
}
182185
break;
183186

184187
case CDC_SEND_BREAK:

0 commit comments

Comments
 (0)