Skip to content

[Bug] Pressing stop button during long print reboots Technic Hub. #1152

Closed

Description

@laurensvalk

Describe the bug
I was debugging sensors and came across something that was ultimately not related to sensors at all. But since it can happen with sensors, it is somewhat likely for users to encounter it.

To reproduce

Install this program on the hub and stay connected to Pybricks Code.

Press the hub button repeatedly. Eventually you will press it while the green light is on. Then it stays on and the hub reboots with PBDRV_RESET_REASON_WATCHDOG

from pybricks.hubs import ThisHub
from pybricks.parameters import Color

hub = ThisHub()
hub.light.on(Color.GREEN)
print("""
Traceback (most recent call last):
  File "sensorinit.py", line 10, in <module>
OSError: [Errno 19] ENODEV: 

A sensor or motor is not connected to the specified port:
--> Check the cables to each motor and sensor.
--> Check the port settings in your script.
--> Check the line in your script that matches
    the line number given in the 'Traceback' above.
""")

Expected behavior
No crash.

Addional notes
I think I was able to reproduce this on Prime Hub at least once, but it is much less likely to occur.

Activity

  1. added
    hub: technichub
    software: pybricks-micropython
    on Jul 10, 2023
  2. laurensvalk commented on Feb 27, 2024

    @laurensvalk
    MemberAuthor

    This is still happening in V3.4.0b2.

  3. laurensvalk commented on Oct 1, 2024

    @laurensvalk
    MemberAuthor

    This was still happening in v3.4.0 but no longer in v3.5.0.

  4. laurensvalk commented on Oct 1, 2024

    @laurensvalk
    MemberAuthor

    After trying out surrounding commits, this turns out to be fixed by pybricks/pybricks-micropython@ce8a7c9. This makes sense since we added waiting for pbsys_bluetooth_tx_is_idle when stopping the program.

  5. added theissue type on Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hub: technichubsoftware: pybricks-micropython

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions