From 208feef3c99310dc6170a6fe87ce460a8637f7a0 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 8 Nov 2019 14:56:25 +0100 Subject: [PATCH 1/2] asio: fix asio test code to start the test after ip address received from common example code Previously set to wait until IP address got from tcpip_adapter, but since common example connect code blocks until both IP4 and IPv6 address received it could happen that test code might have started connection to the ASIO counter-part while ESP32 still waiting for IPv6 address --- examples/protocols/asio/chat_client/asio_chat_client_test.py | 2 +- examples/protocols/asio/chat_server/asio_chat_server_test.py | 2 +- examples/protocols/asio/tcp_echo_server/asio_tcp_server_test.py | 2 +- examples/protocols/asio/udp_echo_server/asio_udp_server_test.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/protocols/asio/chat_client/asio_chat_client_test.py b/examples/protocols/asio/chat_client/asio_chat_client_test.py index f5581796d1..4325806a36 100644 --- a/examples/protocols/asio/chat_client/asio_chat_client_test.py +++ b/examples/protocols/asio/chat_client/asio_chat_client_test.py @@ -82,7 +82,7 @@ def test_examples_protocol_asio_chat_client(env, extra_data): thread1.start() # 2. start the dut test and wait till client gets IP address dut1.start_app() - dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30) + dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30) # 3. send host's IP to the client i.e. the `dut1` dut1.write(host_ip) # 4. client `dut1` should receive a message diff --git a/examples/protocols/asio/chat_server/asio_chat_server_test.py b/examples/protocols/asio/chat_server/asio_chat_server_test.py index 5d53a89467..ccdd4a5570 100644 --- a/examples/protocols/asio/chat_server/asio_chat_server_test.py +++ b/examples/protocols/asio/chat_server/asio_chat_server_test.py @@ -37,7 +37,7 @@ def test_examples_protocol_asio_chat_server(env, extra_data): # 1. start test dut1.start_app() # 2. get the server IP address - data = dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30) + data = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30) # 3. create tcp client and connect to server cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) cli.settimeout(30) diff --git a/examples/protocols/asio/tcp_echo_server/asio_tcp_server_test.py b/examples/protocols/asio/tcp_echo_server/asio_tcp_server_test.py index aeb7faced5..d5ee5cf077 100644 --- a/examples/protocols/asio/tcp_echo_server/asio_tcp_server_test.py +++ b/examples/protocols/asio/tcp_echo_server/asio_tcp_server_test.py @@ -39,7 +39,7 @@ def test_examples_protocol_asio_tcp_server(env, extra_data): # 1. start test dut1.start_app() # 2. get the server IP address - data = dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30) + data = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30) # 3. create tcp client and connect to server cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) cli.settimeout(30) diff --git a/examples/protocols/asio/udp_echo_server/asio_udp_server_test.py b/examples/protocols/asio/udp_echo_server/asio_udp_server_test.py index dac320068f..726a39f4fa 100644 --- a/examples/protocols/asio/udp_echo_server/asio_udp_server_test.py +++ b/examples/protocols/asio/udp_echo_server/asio_udp_server_test.py @@ -39,7 +39,7 @@ def test_examples_protocol_asio_udp_server(env, extra_data): # 1. start test dut1.start_app() # 2. get the server IP address - data = dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30) + data = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30) # 3. create tcp client and connect to server cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) cli.settimeout(30) From 2e0d6d0e6ab8e157653a0fa0f1718b7c93ebcad1 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 8 Nov 2019 20:27:31 +0100 Subject: [PATCH 2/2] uart: make uart_driver_install() more backward compatible, so if the interrupt handler configured to be in IRAM and not flagged in intr_alloc_flags argument, then the flag is gracefully updated rather then error return --- components/driver/include/driver/uart.h | 4 ++-- components/driver/uart.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/driver/include/driver/uart.h b/components/driver/include/driver/uart.h index 7e82b82c66..0e1f6c0b17 100644 --- a/components/driver/include/driver/uart.h +++ b/components/driver/include/driver/uart.h @@ -522,8 +522,8 @@ esp_err_t uart_intr_config(uart_port_t uart_num, const uart_intr_config_t *intr_ * @param uart_queue UART event queue handle (out param). On success, a new queue handle is written here to provide * access to UART events. If set to NULL, driver will not use an event queue. * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred) - * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info. Do not set ESP_INTR_FLAG_IRAM here - * (the driver's ISR handler is not located in IRAM) + * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info. No need to set ESP_INTR_FLAG_IRAM here, as this flag + * will be enabled based on CONFIG_UART_ISR_IN_IRAM (i.e. if the handler located in IRAM or not) * * @return * - ESP_OK Success diff --git a/components/driver/uart.c b/components/driver/uart.c index 788788e29d..ebb6d0f1b7 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -1440,11 +1440,15 @@ esp_err_t uart_driver_install(uart_port_t uart_num, int rx_buffer_size, int tx_b UART_CHECK((rx_buffer_size > UART_FIFO_LEN), "uart rx buffer length error(>128)", ESP_FAIL); UART_CHECK((tx_buffer_size > UART_FIFO_LEN) || (tx_buffer_size == 0), "uart tx buffer length error(>128 or 0)", ESP_FAIL); #if CONFIG_UART_ISR_IN_IRAM - UART_CHECK((intr_alloc_flags & ESP_INTR_FLAG_IRAM) != 0, - "should set ESP_INTR_FLAG_IRAM flag when CONFIG_UART_ISR_IN_IRAM is enabled", ESP_FAIL); + if ((intr_alloc_flags & ESP_INTR_FLAG_IRAM) == 0) { + ESP_LOGI(UART_TAG, "ESP_INTR_FLAG_IRAM flag not set while CONFIG_UART_ISR_IN_IRAM is enabled, flag updated"); + intr_alloc_flags |= ESP_INTR_FLAG_IRAM; + } #else - UART_CHECK((intr_alloc_flags & ESP_INTR_FLAG_IRAM) == 0, - "should not set ESP_INTR_FLAG_IRAM when CONFIG_UART_ISR_IN_IRAM is not enabled", ESP_FAIL); + if ((intr_alloc_flags & ESP_INTR_FLAG_IRAM) != 0) { + ESP_LOGW(UART_TAG, "ESP_INTR_FLAG_IRAM flag is set while CONFIG_UART_ISR_IN_IRAM is not enabled, flag updated"); + intr_alloc_flags &= ~ESP_INTR_FLAG_IRAM; + } #endif if (p_uart_obj[uart_num] == NULL) {