chipKIT® Development Platform

Inspired by Arduino™

HardwareSerial::flush() doesn't do what it should

Created Sat, 16 Mar 2013 10:46:32 +0000 by majenko


Sat, 16 Mar 2013 10:46:32 +0000

The current HardwareSerial::flush() facility differs massively to the current Arduino version.

The ChipKit version is still the pre-noah's ark version which purges the buffer. This is now completely wrong.

What flush() should actually do is wait for the transmit buffer to finish emptying into the hardware transmit bufer, and then wait for the hardware transmit buffer to finish transmitting down the wire. (pre-1.0.4 didn't wait on the hardware buffer, which caused problems)

This is an essential bit of functionality for anyone who wants to use an industry standard RS-485 interface which has a RE#/DE signal for switching between receive and drive. Without it they have no way of synchronising the serial transmissions with the drive enable signal.


Sat, 16 Mar 2013 13:16:05 +0000

Wow! Yeah, that's a great find.

Can you write this up as an issue on Github? Go to [url][/url] and go to the issues tab and press "o" top open a new issue.

Thanks for helping to contribute to chipKIT!



Sat, 16 Mar 2013 15:03:36 +0000

Done :) I have re-worded a bit of it too.