PaulStoffregen / AltSoftSerial

Software emulated serial using hardware timers for improved compatibility
http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
328 stars 131 forks source link

Added missing `availableForWrite()` method. #56

Closed falahati closed 5 years ago

falahati commented 5 years ago

availableForWrite() is part of Print class which is the parent of Stream class and declared as virtual expecting subclasses to define it. However AltSoftSerial seems to have missed that and therefore essentially made it impossible to do non-blocking serial communication.

This PR solves this by defining this method.

falahati commented 5 years ago

Also, TX_BUFFER_SIZE should be equal to SERIAL_TX_BUFFER_SIZE so the library users can check out if the write buffer is completely empty by comparing it to the returned value of availableForWrite(). I don't yet know why TX_BUFFER_SIZE is bigger than SERIAL_TX_BUFFER_SIZE; but if there is a good reason for this, the minimum we can do is to define it in the header file so that it is public to the library users.

The same thing is true for the RX_BUFFER_SIZE and the SERIAL_RX_BUFFER_SIZE values.

These changes, however, are not part of this commit and I am just suggesting these changes here.

falahati commented 5 years ago

@PaulStoffregen, do you have any comment regarding the topic I mentioned above?

PaulStoffregen commented 5 years ago

No, not at this time. Ping me after Teensy 4.0 is released...