energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
794 stars 672 forks source link

Implementation of HardwareSerial::availableForWrite() (MSP430) #1071

Open brawner opened 3 years ago

brawner commented 3 years ago

Greetings, this is a feature request to implement Arduino's HardwareSerial::availableForWrite(). Because of the limited ring buffer size, any call to HardwareSerial::write() that exceeds the available space in the ring buffer will cause that function call to block. https://github.com/energia/Energia/blob/master/hardware/msp430/cores/msp430/HardwareSerial.cpp#L231

On other boards, I typically have large amounts of serial traffic to send periodically and will store it in a byte array. I use the availableToWrite() to check whether bytes can be written and only write until the ring buffer is full so write() itself won't block.