adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.11k stars 1.22k forks source link

ESPNow recovery from "invalid buffer" #9816

Open stanelie opened 3 hours ago

stanelie commented 3 hours ago

CircuitPython version

Adafruit CircuitPython 9.2.0 on 2024-10-28; Waveshare ESP32-S3-Zero with ESP32S3

Code/REPL

def read_packet():
    global packet
    try:
        packet = e.read()
    except ValueError as error:
        print(f"{error}")

Behavior

Hello. This is more a support question then a bug report. I cannot find anywhere in the documentation how to purge the ESPNow buffer, or how to destroy the ESPNow object so that I can recreate it (to recover from errors).

I run this code where a ESP32 is receiving packets from 2 different senders, and I guess the packets interfere when they arrive at the same time? When that happens, I receive an Invalid buffer error and I cannot recover from this. I can catch the error so the code keeps going, but the buffer keeps saying it is invalid.

Description

No response

Additional information

No response

anecdata commented 2 hours ago

@stanelie you can try deinit (or as a workaround reload or reset if that doesn't work): https://docs.circuitpython.org/en/latest/shared-bindings/espnow/index.html#espnow.ESPNow.deinit (I saw this In some early testing, and opted to reload onInvalid buffer.)