Skip to content

If sketch is not connected to serial - dump serial output #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: arduino
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cores/arduino/SerialUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class SerialUSB_ : public ZephyrSerial {
void begin(unsigned long baudrate) { begin(baudrate, SERIAL_8N1); }

operator bool() override;
size_t write(const uint8_t *buffer, size_t size) override;
void flush() override;

protected:
uint32_t dtr = 0;
Expand Down
11 changes: 11 additions & 0 deletions cores/arduino/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,16 @@ arduino::SerialUSB_::operator bool() {
return dtr;
}


size_t arduino::SerialUSB_::write(const uint8_t *buffer, size_t size) {
if (!Serial) return 0;
return arduino::ZephyrSerial::write(buffer, size);
}

void arduino::SerialUSB_::flush() {
if (!Serial) return;
arduino::ZephyrSerial::flush();
}

arduino::SerialUSB_ Serial(usb_dev);
#endif
Loading