Skip to content

Add Print::availableForWrite #5789

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

Merged
merged 1 commit into from
May 16, 2017
Merged
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: 1 addition & 1 deletion hardware/arduino/avr/cores/arduino/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class HardwareSerial : public Stream
virtual int available(void);
virtual int peek(void);
virtual int read(void);
int availableForWrite(void);
virtual int availableForWrite(void);
virtual void flush(void);
virtual size_t write(uint8_t);
inline size_t write(unsigned long n) { return write((uint8_t)n); }
Expand Down
7 changes: 6 additions & 1 deletion hardware/arduino/avr/cores/arduino/Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <inttypes.h>
#include <stdio.h> // for size_t
#include <limits.h> // for INT_MAX
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, this wasn't needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! fixed here: d4a9452


#include "WString.h"
#include "Printable.h"
Expand Down Expand Up @@ -57,7 +58,11 @@ class Print
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}


// default to zero, meaning "a single write may block"
// should be overriden by subclasses with buffering
virtual int availableForWrite() { return 0; }

size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
Expand Down
2 changes: 1 addition & 1 deletion hardware/arduino/avr/cores/arduino/USBAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Serial_ : public Stream
virtual int available(void);
virtual int peek(void);
virtual int read(void);
int availableForWrite(void);
virtual int availableForWrite(void);
virtual void flush(void);
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t*, size_t);
Expand Down