chipKIT® Development Platform

Inspired by Arduino™

Flushing HardwareSerial: flush RX on USB, TX on USART?

Created Fri, 22 Nov 2013 20:37:48 +0000 by ChristopheDupriez


ChristopheDupriez

Fri, 22 Nov 2013 20:37:48 +0000

Hi!

Am I right that Serial.flush() is not doing at all the same thing than Serial0.flush()?: ... void HardwareSerial::flush() { while ((uart->uxSta.reg & (1 << _UARTSTA_TMRT)) == 0) //check the TRMT bit { //* wait for the transmitter to be clear } } .... void USBSerial::flush() { _rx_buffer->head = _rx_buffer->tail; } .... A flush TX on USBSerial would be very useful to ensure that debugging messages are sent before putting the PIC to sleep (for instance)

Have a nice w.e.!

Christophe


majenko

Fri, 22 Nov 2013 20:43:49 +0000

Yes, you are right. The HardwareSerial's flush() was brought into line with Arduino 1.x.x, but USB's wasn't. On HardwareSerial the old flush() functionality is now called purge().

It's in my todo list ;)