-
Notifications
You must be signed in to change notification settings - Fork 178
Add UnbufferedSerial and BufferedSerial API documentation #1220
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
Conversation
bb9b660
to
f5a2ad6
Compare
f5a2ad6
to
b14e6f6
Compare
2df22e5
to
fb589a8
Compare
fb589a8
to
b0e23ec
Compare
Make initial copy edits, mostly for active voice, correct links and consistent style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some edits and queries. Please review my changes to make sure I didn't accidentally change the meaning of anything.
docs/api/io/BufferedSerial.md
Outdated
|
||
<span class="images"><span>`BufferedSerial` class hierarchy</span></span> | ||
|
||
The `BufferedSerial` class provides UART functionality. We recommend you use this class for serial data transfers. You can use it to send and receive bytes of data in a sequence using separate transmit (TX) and receive pins (RX). Communication can be between two processors or for sending text to a console. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this last sentence mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means that a device can interface with another device (such as sensors, printers, or another board) to exchange data or to send text to be displayed on a text-based computer interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would either remove the original sentence or replace it with the explanation in your comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Done.
docs/api/io/BufferedSerial.md
Outdated
|
||
Serial channels have the following characteristics: | ||
|
||
- TX and RX pins - can be specified as Not Connected (NC) for simplex (unidirectional) communication or as valid pins for full duplex (bidirectional) communication. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be specified by whom or by what? You, the user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest the text from RawSerial: The physical serial transmit and receive pins. You can specify a TX or RX pin as Not Connected (NC) to get simplex communication, or specify both to get full duplex communication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be specified by whom or by what? You, the user?
The user can.
docs/api/io/BufferedSerial.md
Outdated
Serial channels have the following characteristics: | ||
|
||
- TX and RX pins - can be specified as Not Connected (NC) for simplex (unidirectional) communication or as valid pins for full duplex (bidirectional) communication. | ||
- Baud rate - predefined speed at which data is sent and received. Standard baud rates include 9600, 119200 and 115200. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who or what sends the data? The BufferedSerial class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UART
docs/api/io/BufferedSerial.md
Outdated
|
||
The `BufferedSerial` calls the underlying HAL API functions. Please see the [porting guide](../porting/serial-port.html) for target serial support. | ||
|
||
When the RX interrupt is trigged, the `BufferedSerial` class stores the byte(s) available to read from the hardware buffer to an internal intermediary buffer. When a read request is made, the `BufferedSerial` class uses a mutex lock and enters a critical section to read out the number of bytes requested if as many are available in the intermediary buffer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we mean by "the RX is trigged," and who or what trigged it?
Who or what makes the read request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RX
is explained in the first paragraph of the page. It is triggered when receiving data from whatever is connected to that interface (a sensor, a console, etc...).
docs/api/io/BufferedSerial.md
Outdated
When the RX interrupt is trigged, the `BufferedSerial` class stores the byte(s) available to read from the hardware buffer to an internal intermediary buffer. When a read request is made, the `BufferedSerial` class uses a mutex lock and enters a critical section to read out the number of bytes requested if as many are available in the intermediary buffer. | ||
|
||
To transmit multiple bytes, the class uses an intermediary buffer to store the bytes to send and monitors the serial interface to transfer them to the hardware buffer as soon as it is available. However, all bytes are written unbuffered if in a critical section. | ||
Using intermediary buffers allows it to be used reliably for input from noninterrupt context while avoiding excess spinning waiting for transmission buffer space. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using intermediary buffers allows us to use what reliably? The class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UART interface.
|
||
The RX and TX buffers are circular buffers with preallocated sizes configurable using the configuration parameters `uart-serial-rxbuf-size` and `uart-serial-txbuf-size`. You can find both configuration parameters in `drivers/mbed_lib.json`. | ||
|
||
## Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these the same configuration parameters you get by running the --config -v
command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to configure a UART interface via the BufferedSerial class for the user application.
Nothing to do with Mbed CLI.
docs/api/io/BufferedSerial.md
Outdated
|
||
Mbed OS redefines target-dependent I/O functions in the C library to allow you to use the C standard I/O library functions (`s\v\f\n\printf`, `scanf` and so on) in your application for printing to the console. | ||
|
||
You can refigure the system I/O retarget code to be buffered or unbuffered, depending on the configuration of the parameter `stdio-buffered-serial` in `platform/mbed_lib.json`. When it is buffered, the retarget code uses an instance of a `BufferedSerial` class to perform the actual printing. This is where `BufferedSerial`'s `Filehandle` inheritance is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who or what uses the Filehandle
inheritance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says BufferedSerial's
.
You see in the diagram at the top of the page that BufferedSerial
inherits from FileHandle
. Because it inherits from FileHandle
it can be used for the re-target code.
Edit file, mostly for accurate links and active voice.
|
||
You can view more information about the configurable settings and functions in the class reference. | ||
|
||
## Class reference | ||
## BufferedSerial class reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This edit seems redundant since the page is about BufferedSerial
.
|
||
## BufferedSerial examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This edit seems redundant since the page is about BufferedSerial
.
@AnotherButler |
@AnotherButler Please review after the last edits. Note that the code for the examples has been merged so this PR is ready for merge once you are happy with it. |
Delete extra space and extra comma.
Merge only after ARMmbed/mbed-os-examples-docs_only#66
The example code snippet URLs need to be amended prior to merging!