Skip to content

Commit 8b6dbc4

Browse files
committed
parent 0ae125d
author Venelin Efremov <[email protected]> 1550459642 -0800 committer Venelin Efremov <[email protected]> 1551218346 -0800 Return the correct bytes written. Also check the DTR value, when deciding to drop data. Update cores/arduino/stm32/usb/cdc/usbd_cdc_if.c Co-Authored-By: ghent360 <[email protected]> Update cores/arduino/stm32/usb/cdc/usbd_cdc_if.h Co-Authored-By: ghent360 <[email protected]> Revert CDC_connected back to unit8_t, to maintain "C" compatibility. Add isConnected() methor to USBSerial. Switch CDC_connected() to bool - final answer. Remove redundant variable.
1 parent 0ae125d commit 8b6dbc4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Diff for: cores/arduino/USBSerial.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ size_t USBSerial::write(const uint8_t *buffer, size_t size)
8484
// After storing data, start transmitting process
8585
CDC_continue_transmit();
8686
} else if (!CDC_connected()) {
87-
return size;
87+
return size - rest;
8888
}
8989
}
9090
return size;
@@ -187,6 +187,11 @@ bool USBSerial::rts(void)
187187
return false;
188188
}
189189

190+
bool USBSerial::isConnected()
191+
{
192+
return CDC_connected();
193+
}
194+
190195
USBSerial::operator bool()
191196
{
192197
bool result = false;

Diff for: cores/arduino/USBSerial.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class USBSerial : public Stream {
5353
uint8_t numbits();
5454
bool dtr();
5555
bool rts();
56+
bool isConnected();
5657
enum {
5758
ONE_STOP_BIT = 0,
5859
ONE_AND_HALF_STOP_BIT = 1,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void CDC_continue_transmit(void);
5050
void CDC_resume_receive(void);
5151
void CDC_init(void);
5252
void CDC_deInit(void);
53-
uint8_t CDC_connected();
53+
bool CDC_connected();
5454

5555
#ifdef __cplusplus
5656
}

0 commit comments

Comments
 (0)