-
Notifications
You must be signed in to change notification settings - Fork 3k
Stream::write and Stream::read are not public #9338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-409 |
I really do not recommend using
Documentation about On the subject of
The problem is just
No, it requires the underlying driver to implement I did try deprecating |
The reason I used I see that the I feel like an abstraction for async and/or buffered reads and writes is needed to properly support what I'm looking for. Right now it seems like the only option is using the |
Closing this since using the Stream class directly indeed seems to be an anti-pattern. |
I missed your last comment - you should be able to achieve everything you need via
Although convenient, having something as complex as C++ core guidelines reference: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-member I'm also fascinated by the suggestion linked to there by Stroustrup and Sutter, which I'd not seen before: Unified Call Syntax. That would eliminate any visible difference between methods and non-methods to the user in general (although this particular case isn't quite so simple, due to C compatibility issues).. Generic code can and should use |
Description
Mbed features the
Stream
class. This class provides "streaming" functionality toFileLike
drivers like e.g the Serial driver, allowing them to use things likeprintf
andscanf
.Using the
Stream
class in device drivers for e.g a UART device offers a lot of flexibility vs using the overloading class like theSerial
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 thewrite
andread
functions, but since these functions are private, only theprintf
,putc
,scanf
,gets
andgetc
(and va_list alternatives) functions can be used. Theprintf
,scanf
andgets
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, theprintf
andscanf
functions come with a lot of overhead (see #4830).Making the
read
andwrite
functions public would allow theSteam
interface to be used without losing the ability to do efficient bulk transfers.Issue request type
The text was updated successfully, but these errors were encountered: