arduino/Arduino — pull request #43 by hjohnson (2011-10-09 00:32:00+00:00)
Title: A fix for issue 672: http://code.google.com/p/arduino/issues/detail?id=672

I discovered this potential issue earlier today, see the above link for more information. To fix this, I added a function called waitForBufferSpace(uint8_t) so the user can decide whether HardwareSerial should wait for buffer space when Serial.write() is called. By default, nothing has changed, and no serial data is lost. However, by calling Serial.waitForBufferSpace(0), the user can disable this waiting. This means that there is the potential for serial data that was supposed to be printed to be lost, but on the other hand, if Serial.write is called on a full buffer from inside of an ISR (a common occurrence when trying to debug ISR triggering), the entire processor won't lock up and have to be reset.