aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/HardwareSerial.cpp
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2011-08-23 19:12:03 -0400
committerDavid A. Mellis <d.mellis@arduino.cc>2011-08-23 19:12:03 -0400
commitf282cbaf968f7142ef5abb68a92e970c3d5eea35 (patch)
treeacade7dcd31f50c66ca331775fb1cdc2b392f971 /cores/arduino/HardwareSerial.cpp
parentf5a15cb62f7257bf26cdedf30ce13f8cff802f79 (diff)
write(), print(), and println() now return number of bytes written.
The type is long, and negative values indicate errors. Needs more testing. http://code.google.com/p/arduino/issues/detail?id=551
Diffstat (limited to 'cores/arduino/HardwareSerial.cpp')
-rw-r--r--cores/arduino/HardwareSerial.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index db6b149..a200da5 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -352,12 +352,13 @@ void HardwareSerial::flush()
;
}
-void HardwareSerial::write(uint8_t c)
+long HardwareSerial::write(uint8_t c)
{
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit
+ // ???: return 0 here instead?
while (i == _tx_buffer->tail)
;
@@ -365,6 +366,8 @@ void HardwareSerial::write(uint8_t c)
_tx_buffer->head = i;
sbi(*_ucsrb, _udrie);
+
+ return 1;
}
// Preinstantiate Objects //////////////////////////////////////////////////////