Skip to content

Commit fecacf1

Browse files
bluemurderdevyte
authored andcommitted
Added Serial.setRxBufferSize method description in libraries reference document (#3862)
* Added null pointer check * Fixed typo * Added Serial.setRxBufferSize method description in libraries reference document
1 parent 9dcc580 commit fecacf1

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

cores/esp8266/uart.c

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ int uart_peek_char(uart_t* uart)
104104

105105
int uart_read_char(uart_t* uart)
106106
{
107+
if(uart == NULL) {
108+
return -1;
109+
}
107110
int data = uart_peek_char(uart);
108111
if(data != -1) {
109112
uart->rx_buffer->rpos = (uart->rx_buffer->rpos + 1) % uart->rx_buffer->size;

doc/boards.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ This module is sold under many names for around $6.50 on AliExpress and it's one
5858

5959
It's an open hardware design with an ESP-12E core and 4 MB of SPI flash.
6060

61-
Acording to the manufacturer, "with a micro USB cable, you can connect NodeMCU devkit to your laptop and flash it without any trouble". This is more or less true: the board comes with a CP2102 onboard USB to serial adapter which just works, well, the majority of the time. Sometimes flashing fails and you have to reset the board by holding down FLASH +
61+
According to the manufacturer, "with a micro USB cable, you can connect NodeMCU devkit to your laptop and flash it without any trouble". This is more or less true: the board comes with a CP2102 onboard USB to serial adapter which just works, well, the majority of the time. Sometimes flashing fails and you have to reset the board by holding down FLASH +
6262
RST, then releasing FLASH, then releasing RST. This forces the CP2102 device to power cycle and to be re-numbered by Linux.
6363

6464
The board also features a NCP1117 voltage regulator, a blue LED on GPIO16 and a 220k/100k Ohm voltage divider on the ADC input pin.

doc/reference.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ Serial
9494
------
9595

9696
``Serial`` object works much the same way as on a regular Arduino. Apart
97-
from hardware FIFO (128 bytes for TX and RX) HardwareSerial has
97+
from hardware FIFO (128 bytes for TX and RX) ``Serial`` has
9898
additional 256-byte TX and RX buffers. Both transmit and receive is
9999
interrupt-driven. Write and read functions only block the sketch
100-
execution when the respective FIFO/buffers are full/empty.
100+
execution when the respective FIFO/buffers are full/empty. Note that
101+
the length of additional 256-bit buffer can be customized.
101102

102103
``Serial`` uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3
103104
(RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling
@@ -121,6 +122,9 @@ instead, call ``Serial1.setDebugOutput(true)``.
121122
You also need to use ``Serial.setDebugOutput(true)`` to enable output
122123
from ``printf()`` function.
123124

125+
The method ``Serial.setRxBufferSize(size_t size)`` allows to define the
126+
receiving buffer depth. The default value is 256.
127+
124128
Both ``Serial`` and ``Serial1`` objects support 5, 6, 7, 8 data bits,
125129
odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the
126130
desired mode, call ``Serial.begin(baudrate, SERIAL_8N1)``,
@@ -142,6 +146,8 @@ current speed. For example
142146
// Will print "Serial is 57600 bps"
143147
Serial.printf("Serial is %d bps", br);
144148
149+
| ``Serial`` and ``Serial1`` objects are both instances of the
150+
``HardwareSerial`` class.
145151
| I've done this also for official ESP8266 `Software
146152
Serial <https://github.com/esp8266/Arduino/blob/master/doc/libraries.md#softwareserial>`__
147153
library, see this `pull

0 commit comments

Comments
 (0)