Description
Description
Mbed features the Stream
class. This class provides "streaming" functionality to FileLike
drivers like e.g the Serial driver, allowing them to use things like printf
and scanf
.
Using the Stream
class in device drivers for e.g a UART device offers a lot of flexibility vs using the overloading class like the Serial
class since it allows to use the same driver for multiple types of drivers. E.g a device that is e.g connected to a SPI to UART bridge instead of directly to a UART port could be used very easily.
The Stream
class requires the underlying driver to implement the write
and read
functions, but since these functions are private, only the printf
, putc
, scanf
, gets
and getc
(and va_list alternatives) functions can be used. The printf
, scanf
and gets
functions rely on C strings, making them useless for devices requiring a binary interface. This means these devices are stuck using character-per-character reads and writes, even if the underlying driver supports more efficient bulk transfer methods. Also, the printf
and scanf
functions come with a lot of overhead (see #4830).
Making the read
and write
functions public would allow the Steam
interface to be used without losing the ability to do efficient bulk transfers.
Issue request type
[ ] Question
[x] Enhancement
[ ] Bug