Merge pull request #3799 from dhalbert/wifi-radio-gc-collect

Include wifi.radio singleton in gc
This commit is contained in:
Scott Shawcroft 2020-12-07 12:26:16 -08:00 committed by GitHub
commit 7ac200017d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 0 deletions

8
main.c
View File

@ -95,6 +95,10 @@
#include "common-hal/canio/CAN.h"
#endif
#if CIRCUITPY_WIFI
#include "shared-bindings/wifi/__init__.h"
#endif
#if MICROPY_ENABLE_PYSTACK
static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)]);
#endif
@ -560,6 +564,10 @@ void gc_collect(void) {
common_hal_bleio_gc_collect();
#endif
#if CIRCUITPY_WIFI
common_hal_wifi_gc_collect();
#endif
// This naively collects all object references from an approximate stack
// range.
gc_collect_root((void**)sp, ((uint32_t)port_stack_get_top() - sp) / sizeof(uint32_t));

View File

@ -31,6 +31,7 @@
#include "common-hal/wifi/__init__.h"
#include "lib/utils/interrupt_char.h"
#include "py/gc.h"
#include "py/runtime.h"
#include "shared-bindings/ipaddress/IPv4Address.h"
#include "shared-bindings/wifi/ScannedNetworks.h"
@ -262,3 +263,8 @@ mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address,
return elapsed_time;
}
void common_hal_wifi_radio_gc_collect(wifi_radio_obj_t *self) {
// Only bother to scan the actual object references.
gc_collect_ptr(self->current_scan);
}

View File

@ -59,4 +59,6 @@ typedef struct {
uint8_t last_disconnect_reason;
} wifi_radio_obj_t;
extern void common_hal_wifi_radio_gc_collect(wifi_radio_obj_t *self);
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_RADIO_H

View File

@ -160,3 +160,7 @@ void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t* esp_ip_addre
IP_ADDR4(esp_ip_address, bytes[0], bytes[1], bytes[2], bytes[3]);
}
void common_hal_wifi_gc_collect(void) {
common_hal_wifi_radio_gc_collect(&common_hal_wifi_radio_obj);
}

View File

@ -34,5 +34,6 @@
extern wifi_radio_obj_t common_hal_wifi_radio_obj;
void common_hal_wifi_init(void);
void common_hal_wifi_gc_collect(void);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI___INIT___H