Skip to content

bool HardwareSerial::writeable(void) #62

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

Closed
wants to merge 1 commit into from
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
6 changes: 6 additions & 0 deletions hardware/arduino/cores/arduino/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ void HardwareSerial::flush()
;
}

bool HardwareSerial::writeable()
{
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
return (i != _tx_buffer->tail);
}

size_t HardwareSerial::write(uint8_t c)
{
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
Expand Down
1 change: 1 addition & 0 deletions hardware/arduino/cores/arduino/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class HardwareSerial : public Stream
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual bool writeable(void);
virtual size_t write(uint8_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
};
Expand Down