Skip to content

Commit 39524ba

Browse files
authored
Fixes #7484
1 parent 683b8e6 commit 39524ba

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

doc/reference.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,25 @@ milliseconds is not recommended.
151151
Serial
152152
------
153153

154-
``Serial`` object works much the same way as on a regular Arduino. Apart
155-
from hardware FIFO (128 bytes for TX and RX) ``Serial`` has
156-
additional 256-byte TX and RX buffers. Both transmit and receive is
157-
interrupt-driven. Write and read functions only block the sketch
158-
execution when the respective FIFO/buffers are full/empty. Note that
159-
the length of additional 256-bit buffer can be customized.
154+
The ``Serial`` object works much the same way as on a regular Arduino. Apart
155+
from the hardware FIFO (128 bytes for TX and RX), ``Serial`` has an
156+
additional customizable 256-byte RX buffer. The size of this software buffer can
157+
be changed by the user. It is suggested to use a bigger size at higher receive speeds.
158+
159+
The ``::setRxBufferSize(size_t size`` method changes the RX buffer size as needed. This
160+
should be called before ``::begin()``. The size argument should be at least large enough
161+
to hold all data received before reading.
162+
163+
For transmit-only operation, the buffer can be switched off by passing mode SERIAL_TX_ONLY
164+
to Serial.begin(). Other modes are SERIAL_RX_ONLY and SERIAL_FULL (the default).
165+
166+
Receive is interrupt-driven, but transmit polls and busy-waits. Both are
167+
blocking:
168+
The ``::write()`` call blocks if the TX FIFO is full and waits until there is room
169+
in the FIFO before writing more bytes into it.
170+
The ``::read()`` call does not block if there are no bytes available for reading.
171+
The ``::readBytes()`` call blocks until the number of bytes read complies with the
172+
number of bytes required by the argument passed in.
160173

161174
``Serial`` uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3
162175
(RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling
@@ -180,14 +193,13 @@ instead, call ``Serial1.setDebugOutput(true)``.
180193
You also need to use ``Serial.setDebugOutput(true)`` to enable output
181194
from ``printf()`` function.
182195

183-
The method ``Serial.setRxBufferSize(size_t size)`` allows to define the
184-
receiving buffer depth. The default value is 256.
185-
186196
Both ``Serial`` and ``Serial1`` objects support 5, 6, 7, 8 data bits,
187197
odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the
188198
desired mode, call ``Serial.begin(baudrate, SERIAL_8N1)``,
189199
``Serial.begin(baudrate, SERIAL_6E2)``, etc.
190-
200+
Default configuration mode is SERIAL_8N1. Possibilities are SERIAL_[5678][NEO][12].
201+
Example: ``SERIAL_8N1`` means 8bits No parity 1 stop bit.
202+
191203
A new method has been implemented on both ``Serial`` and ``Serial1`` to
192204
get current baud rate setting. To get the current baud rate, call
193205
``Serial.baudRate()``, ``Serial1.baudRate()``. Return a ``int`` of
@@ -206,7 +218,7 @@ current speed. For example
206218
207219
| ``Serial`` and ``Serial1`` objects are both instances of the
208220
``HardwareSerial`` class.
209-
| I've done this also for official ESP8266 `Software
221+
| This is also done for official ESP8266 `Software
210222
Serial <libraries.rst#softwareserial>`__
211223
library, see this `pull
212224
request <https://github.com/plerup/espsoftwareserial/pull/22>`__.

0 commit comments

Comments
 (0)