I am porting some arduino code over to the photon and ran into an issue where the serial method
availableForWrite is not available. I am wondering if there are any plans to add serial
availableForWrite functionality to the firmware and if not, does anyone have ideas on how to workaround this using the currently available firmware?
What would be a use case for this function?
Since sending TX is not blocking anyhow. But a pull request for a fn that returns the difference between head and tail of the TX buffer might be pulled.
The use case is LED control via serial tx, so the timing is important. I suppose if I knew the write buffer length I could code around it?
The RX & TX buffers are 64 byte ring buffers.
You could find these infos in the open source repo
Can I follow up on this…Just tried to use ‘availableForWrite()’ as I need to send a block of 600x (0x55) characters.
This function always simply responds with 0
int i = 60; //send 600 wakeup bytes
while (i-- > 0)
if (sermbus.availableForWrite() > 1)
currently shortened to 60 for debugging…
Code runs and simply prints a set of 0’s
Am I to guess that this ACTUALLY returns the number of bytes IN the buffer and not ‘remaining space’ ???.
NB sermbus is #defined as Serial1 in the header file.
This also prints zero’s
b = Serial1.availableForWrite();