9 years, 8 months ago.

Why Serial port write method is protected ?

Hello everybody,

I don't understand why the write method of the serial port is protected ?

Any reason ?

2 Answers

9 years, 8 months ago.

can u further explain it ??

write method of Stream (inherited by Serial) is declared virtual protected.

It would be nice if i could send a binary buffer in one one shot directly without making a putc() loop or deriving from Serial.

posted by Jacques Charreyron 20 Mar 2015
9 years, 8 months ago.

All the write method does is call putc in a while loop. Defining your own function to do that may be a tiny bit messier but isn't really that much of an issue and shouldn't cause any performance hit.