Skip to content

MatrixPortal hangs and disconnects from USB after reading URL multiple times #6205

Closed
@jldeon

Description

@jldeon

CircuitPython version

Adafruit CircuitPython 7.2.0 on 2022-02-24; Adafruit Matrix Portal M4 with samd51j19
Board ID:matrixportal_m4

Code/REPL

import time
import board
import traceback

from adafruit_matrixportal.matrixportal import MatrixPortal
from secrets import secrets

matrix_portal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=True)
network = matrix_portal.network
display = matrix_portal.graphics.display

url = "http://example.com"

while True:
    try:
        print(f"Reading url: {url}")
        matrix_portal.set_background(0x400000)
        resp = network.fetch(url)
        matrix_portal.set_background(0x000000)
        print(resp.content.decode('utf-8')[:64])
    except (ValueError, RuntimeError) as e:
        print("Likely data read error:")
        traceback.print_exception(None, e, e.__traceback__)
    except OSError as e:
        print("Likely wifi connection error:")
        traceback.print_exception(None, e, e.__traceback__)
    except Exception as e:
        print("Unknown error:")
        traceback.print_exception(None, e, e.__traceback__)
    time.sleep(1)

Behavior

After some time passes (random, but typically less than an hour), the device stops responding.

The last thing printed is "Retrieving data..." (which is a print that can't be turned off in the CircuitPython libraries). The LED matrix is stuck on red (so the call to fetch hasn't returned.)

After some time passes, USB disconnects. The board has to be hard-reset to recover.

There is no Python backtrace or any other error message printed via the serial port.

Description

No response

Additional information

I tested this initially with a text file hosted on an Apache server on the local LAN. I then tested with example.com just to rule out anything weird on my Apache instance. (So you ought to be able to repro this with various URLs, basically)

You can probably omit most of the exception handling from my example code. I've found that sometimes the MatrixPortal doesn't want to connect to wifi or the response gets screwy on occasion, so I handle those. However, I haven't hit those exceptions when performing this test, so it's likely not needed.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions