@@ -151,12 +151,25 @@ milliseconds is not recommended.
151
151
Serial
152
152
------
153
153
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.
160
173
161
174
``Serial `` uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3
162
175
(RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling
@@ -180,14 +193,13 @@ instead, call ``Serial1.setDebugOutput(true)``.
180
193
You also need to use ``Serial.setDebugOutput(true) `` to enable output
181
194
from ``printf() `` function.
182
195
183
- The method ``Serial.setRxBufferSize(size_t size) `` allows to define the
184
- receiving buffer depth. The default value is 256.
185
-
186
196
Both ``Serial `` and ``Serial1 `` objects support 5, 6, 7, 8 data bits,
187
197
odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the
188
198
desired mode, call ``Serial.begin(baudrate, SERIAL_8N1) ``,
189
199
``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
+
191
203
A new method has been implemented on both ``Serial `` and ``Serial1 `` to
192
204
get current baud rate setting. To get the current baud rate, call
193
205
``Serial.baudRate() ``, ``Serial1.baudRate() ``. Return a ``int `` of
@@ -206,7 +218,7 @@ current speed. For example
206
218
207
219
| ``Serial`` and ``Serial1`` objects are both instances of the
208
220
``HardwareSerial`` class.
209
- | I've done this also for official ESP8266 `Software
221
+ | This is also done for official ESP8266 `Software
210
222
Serial <libraries.rst#softwareserial>`__
211
223
library, see this `pull
212
224
request <https://github.com/plerup/espsoftwareserial/pull/22>`__.
0 commit comments