Skip to content

Added Serial.setRxBufferSize method description in libraries reference document #3862

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

Merged
merged 3 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cores/esp8266/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ int uart_peek_char(uart_t* uart)

int uart_read_char(uart_t* uart)
{
if(uart == NULL) {
return -1;
}
int data = uart_peek_char(uart);
if(data != -1) {
uart->rx_buffer->rpos = (uart->rx_buffer->rpos + 1) % uart->rx_buffer->size;
Expand Down
2 changes: 1 addition & 1 deletion doc/boards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ This module is sold under many names for around $6.50 on AliExpress and it's one

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

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 +
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 +
RST, then releasing FLASH, then releasing RST. This forces the CP2102 device to power cycle and to be re-numbered by Linux.

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.
Expand Down
10 changes: 8 additions & 2 deletions doc/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ Serial
------

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

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

The method ``Serial.setRxBufferSize(size_t size)`` allows to define the
receiving buffer depth. The default value is 256.

Both ``Serial`` and ``Serial1`` objects support 5, 6, 7, 8 data bits,
odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the
desired mode, call ``Serial.begin(baudrate, SERIAL_8N1)``,
Expand All @@ -142,6 +146,8 @@ current speed. For example
// Will print "Serial is 57600 bps"
Serial.printf("Serial is %d bps", br);

| ``Serial`` and ``Serial1`` objects are both instances of the
``HardwareSerial`` class.
| I've done this also for official ESP8266 `Software
Serial <https://github.com/esp8266/Arduino/blob/master/doc/libraries.md#softwareserial>`__
library, see this `pull
Expand Down