Skip to content
Closed
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
7 changes: 6 additions & 1 deletion hardware/arduino/cores/arduino/CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ void Serial_::flush(void)
}

size_t Serial_::write(uint8_t c)
{
return write(&c, 1);
}

size_t Serial_::write(const uint8_t *buffer, size_t size)
{
/* only try to send bytes if the high-level CDC connection itself
is open (not just the pipe) - the OS should set lineState when the port
Expand All @@ -210,7 +215,7 @@ size_t Serial_::write(uint8_t c)
// open connection isn't broken cleanly (cable is yanked out, host dies
// or locks up, or host virtual serial port hangs)
if (_usbLineInfo.lineState > 0) {
int r = USB_Send(CDC_TX,&c,1);
int r = USB_Send(CDC_TX,buffer,size);
if (r > 0) {
return r;
} else {
Expand Down
1 change: 1 addition & 0 deletions hardware/arduino/cores/arduino/USBAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Serial_ : public Stream
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t*, size_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
};
Expand Down