From 298bd16529235a7b478818e4feb45c667071c8ad Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Thu, 4 May 2023 15:55:33 -0400 Subject: [PATCH 1/2] Fix creating virtual environment for stub creation --- tools/test-stubs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-stubs.sh b/tools/test-stubs.sh index c977ad26d9..6c6c991015 100755 --- a/tools/test-stubs.sh +++ b/tools/test-stubs.sh @@ -1,6 +1,6 @@ #!/bin/sh -e rm -rf test-stubs -python3 -mvenv test-stubs +python3 -m venv test-stubs . test-stubs/bin/activate pip install mypy isort black adafruit-circuitpython-typing wheel rm -rf circuitpython-stubs .mypy_cache From 66411fdd38b95e3b0d3ae6fad7dbe35c873569a4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 May 2023 17:09:20 -0500 Subject: [PATCH 2/2] espressif: check return value from esp_ping_new_session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit esp_ping_new_session can fail, particularly if ping is called quickly many times in succession. This is because `esp_ping_new_session` has to do a bunch of stuff including creating a task and a socket. Calling `esp_ping_delete_session` doesn't clean up these resources immediately. Instead, it signals the task to clean up resources and exit 'soon', but 'soon' is defined as 1 second. When the calls are frequent, the in-use sockets and tasks fill up available slots—I didn't actually check which resource gets used up first. With this change, the ping call will raise an exception instead of continuing with a call to esp_ping_start that crashes. Closes #5980 based on my testing on an ESP32S3-N8R2. --- ports/espressif/common-hal/wifi/Radio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 0ce535899a..851e1bea25 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -29,6 +29,7 @@ #include +#include "bindings/espidf/__init__.h" #include "common-hal/wifi/__init__.h" #include "shared/runtime/interrupt_char.h" #include "py/gc.h" @@ -497,7 +498,7 @@ mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address, size_t timeout_ms = timeout * 1000; esp_ping_handle_t ping; - esp_ping_new_session(&ping_config, NULL, &ping); + CHECK_ESP_RESULT(esp_ping_new_session(&ping_config, NULL, &ping)); esp_ping_start(ping); uint32_t received = 0;