mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
fix(uart): enlarged task stack size for uart_async_rxtxtasks example
Meanwhile, added CI pytest for some UART examples Closes https://github.com/espressif/esp-idf/issues/15363
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
menu "Example Configuration"
|
||||||
|
|
||||||
|
orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps"
|
||||||
|
|
||||||
|
config EXAMPLE_UART_BAUD_RATE
|
||||||
|
int "UART communication speed"
|
||||||
|
range 1200 115200
|
||||||
|
default 115200
|
||||||
|
help
|
||||||
|
UART communication speed for the example.
|
||||||
|
|
||||||
|
config EXAMPLE_UART_RXD
|
||||||
|
int "UART RXD pin number"
|
||||||
|
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
|
||||||
|
default 5
|
||||||
|
help
|
||||||
|
GPIO number for UART RX pin. See UART documentation for more information
|
||||||
|
about available pin numbers for UART.
|
||||||
|
|
||||||
|
config EXAMPLE_UART_TXD
|
||||||
|
int "UART TXD pin number"
|
||||||
|
range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
|
||||||
|
default 4
|
||||||
|
help
|
||||||
|
GPIO number for UART TX pin. See UART documentation for more information
|
||||||
|
about available pin numbers for UART.
|
||||||
|
|
||||||
|
config EXAMPLE_TASK_STACK_SIZE
|
||||||
|
int "Example task stack size"
|
||||||
|
range 1024 16384
|
||||||
|
default 3072
|
||||||
|
help
|
||||||
|
Defines stack size for UART TX and RX tasks. Insufficient stack size can cause crash.
|
||||||
|
|
||||||
|
endmenu
|
@@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
static const int RX_BUF_SIZE = 1024;
|
static const int RX_BUF_SIZE = 1024;
|
||||||
|
|
||||||
#define TXD_PIN (GPIO_NUM_4)
|
#define TXD_PIN (CONFIG_EXAMPLE_UART_TXD)
|
||||||
#define RXD_PIN (GPIO_NUM_5)
|
#define RXD_PIN (CONFIG_EXAMPLE_UART_RXD)
|
||||||
|
|
||||||
void init(void)
|
void init(void)
|
||||||
{
|
{
|
||||||
const uart_config_t uart_config = {
|
const uart_config_t uart_config = {
|
||||||
.baud_rate = 115200,
|
.baud_rate = CONFIG_EXAMPLE_UART_BAUD_RATE,
|
||||||
.data_bits = UART_DATA_8_BITS,
|
.data_bits = UART_DATA_8_BITS,
|
||||||
.parity = UART_PARITY_DISABLE,
|
.parity = UART_PARITY_DISABLE,
|
||||||
.stop_bits = UART_STOP_BITS_1,
|
.stop_bits = UART_STOP_BITS_1,
|
||||||
@@ -72,6 +72,6 @@ static void rx_task(void *arg)
|
|||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
xTaskCreate(rx_task, "uart_rx_task", 1024 * 2, NULL, configMAX_PRIORITIES - 1, NULL);
|
xTaskCreate(rx_task, "uart_rx_task", CONFIG_EXAMPLE_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL);
|
||||||
xTaskCreate(tx_task, "uart_tx_task", 1024 * 2, NULL, configMAX_PRIORITIES - 2, NULL);
|
xTaskCreate(tx_task, "uart_tx_task", CONFIG_EXAMPLE_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 2, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,10 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.supported_targets
|
||||||
|
@pytest.mark.generic
|
||||||
|
def test_uart_async_rxtxtasks_example(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('TX_TASK: Wrote 11 bytes')
|
14
examples/peripherals/uart/uart_events/pytest_events.py
Normal file
14
examples/peripherals/uart/uart_events/pytest_events.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.supported_targets
|
||||||
|
@pytest.mark.generic
|
||||||
|
def test_uart_events_example(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('Returned from app_main()')
|
||||||
|
dut.write('a')
|
||||||
|
dut.expect_exact('uart_events: [UART DATA]: 2') # dut.write will add an extra '\n'
|
||||||
|
dut.write('HA')
|
||||||
|
dut.expect_exact('uart_events: [UART DATA]: 3') # dut.write will add an extra '\n'
|
12
examples/peripherals/uart/uart_select/pytest_uart_select.py
Normal file
12
examples/peripherals/uart/uart_select/pytest_uart_select.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.supported_targets
|
||||||
|
@pytest.mark.generic
|
||||||
|
def test_uart_select_example(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('uart_select_example: Timeout has been reached and nothing has been received')
|
||||||
|
dut.write('a')
|
||||||
|
dut.expect_exact('uart_select_example: Received: a')
|
Reference in New Issue
Block a user