Skip to content

Commit fe9e040

Browse files
authored
Merge pull request #123 from KurtE/no_usb_no_hang
If sketch is not connected to serial - dump serial output
2 parents f2300ea + aef4efc commit fe9e040

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
void begin(unsigned long baudrate) { begin(baudrate, SERIAL_8N1); }
1919

2020
operator bool() override;
21+
size_t write(const uint8_t *buffer, size_t size) override;
22+
void flush() 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_t arduino::SerialUSB_::write(const uint8_t *buffer, size_t size) {
129+
if (!Serial) return 0;
130+
return arduino::ZephyrSerial::write(buffer, size);
131+
}
132+
133+
void arduino::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)