Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaef4efc

Browse files
committed
If sketch is not connected to serial - dump serial output
Current code would hang after a few Serial.print like statements happened when we are not connected tothe Serial monitor.So I put overrides in for the Serial.write(buf, cnt) and Serial.flush()That would first check to see if Serial returns true (DTR)...This appears to match the behavior of the MBED Portenta H8 code.
1 parentf2300ea commitaef4efc

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

‎cores/arduino/SerialUSB.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class SerialUSB_ : public ZephyrSerial {
1818
voidbegin(unsignedlong baudrate) {begin(baudrate, SERIAL_8N1); }
1919

2020
operatorbool()override;
21+
size_twrite(constuint8_t *buffer,size_t size)override;
22+
voidflush()override;
2123

2224
protected:
2325
uint32_t dtr =0;

‎cores/arduino/USB.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,16 @@ arduino::SerialUSB_::operator bool() {
124124
return dtr;
125125
}
126126

127+
128+
size_tarduino::SerialUSB_::write(constuint8_t *buffer,size_t size) {
129+
if (!Serial)return0;
130+
returnarduino::ZephyrSerial::write(buffer, size);
131+
}
132+
133+
voidarduino::SerialUSB_::flush() {
134+
if (!Serial)return;
135+
arduino::ZephyrSerial::flush();
136+
}
137+
127138
arduino::SerialUSB_Serial(usb_dev);
128139
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp