-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Primehub "hangs" in mid program run on Pybricks beta.12 and firmware 3.0.0b4 #297
Comments
Was busy on coverage test for Spike ColorSensor |
After a reboot of the primehub, and ctrl-F5 on the code webpage:
|
Once more same hang; running: Same hardware / software / environment. [EDIT]: Does not seem to be memory-related.
Log at the start shows:
Log at the end shows:
|
The same happened on Linux Google Chrome and Chromium after some more time. |
Does this happen on other hubs? |
Did not (yet) try. Will try a technic hub now. [EDIT] added program used: from pybricks.pupdevices import UltrasonicSensor
from pybricks.parameters import Port
from pybricks.tools import wait
# Initialize the sensor.
eyes = UltrasonicSensor(Port.C)
counter = 0
max = 0
min = 9999
while True:
counter += 1
# Print the measured distance.
dist = eyes.distance()
if dist > max:
max = dist
if dist < min:
min = dist
if counter % 5000 == 0:
print("%12d Distance:%5d Min:%5d Max:%5d" % (counter, dist, min, max))
max = 0
min = 9999
# # If an object is detected closer than 500mm:
# if eyes.distance() < 500:
# # Turn the lights on.
# eyes.lights.on(100)
# else:
# # Turn the lights off.
# eyes.lights.off()
# Wait some time so we can read what is printed.
# wait(100) |
There have been quite a few times recently where I had to reboot Windows because it seems that the Bluetooth stack got in a bad state (i.e. restarting the web browser was not enough). |
My feeling is that it is more than the Bluetooth stack. Win10 - MS EDGE test on TechnicHub is running - just passed the 10.000.000 mark. |
got a "hang" after reboot win10 Maybe it's getting reproducible.
Then running Will try the same on Linux Mint tomorrow. |
Since |
Could not reboot by long-press the middle button. (did I forget a reboot button combination?)
Was that what you asked @dlech ?. Could recreate the freeze on beta-14 on:
The scenario from above :
Then running Could be that there is a shorter recreate scenario, but this scenario now worked a number of times. |
Adapted # SPDX-License-Identifier: MIT
# Copyright (c) 2020 The Pybricks Authors
"""
Hardware Module: 1
Description: This tests the lights on the Ultrasonic Sensor. No external
sensors are used to verify that it works.
"""
from pybricks.pupdevices import UltrasonicSensor
from pybricks.parameters import Port
from pybricks.tools import wait
from urandom import randint
# Initialize devices.
lights = UltrasonicSensor(Port.C).lights
count = 0
while True:
count += 1
print("Start iteration", count)
# Turn on all lights at full brightness.
lights.on()
wait(500)
# Turn on all lights.
for i in range(-50, 150, 2):
lights.on(i)
wait(20)
# Turn of all lights.
lights.off()
wait(500)
# Turn on all lights.
for i in range(50):
lights.on([randint(0, 100) for j in range(4)])
wait(50) Ran a three times with this as result:
Each time eventually a freeze occurred. |
Thanks a lot for your detailed investigation!
I have a hunch that switching modes and writing to the sensor (for the lights) is wreaking havoc here. |
A shorter script also does the freeze, but not as fast: while True:
count += 1
print("Start iteration", count, end="")
# Turn on all lights.
for i in range(50):
lights.on([randint(0, 100) for j in range(4)])
# wait(50)
print("; ended") This does no mode switching, just write light values to the sensor.
Note that I removed the wait after the lights switch for speed sake |
Indeed, both can be an issue, separately and combined. I'll add a test that does this specifically, thanks. And just to confirm, you no longer see this, right?
|
Well . . . If I do no funny things.
No idea why I would want to press UP or DOWN though 😃 |
Ah, yes, good one. That reminds me of a separate issue 😄 |
I've split the remaining open problems in this thread into separate issues. Thanks for reporting! |
Yes thanks. Just wanted to verify that even if the hub has problems that Pybricks Code can recover without having to be restarted. |
Describe the bug
Sometimes (unpredictable for me at the moment) a running program hangs
To reproduce
Steps to reproduce the behavior (NO fixed scenario, just sometimes)
Describing the last situation I had:
except ultrasonic_presence.py
It is such a small program, I do not understand what's wrong.
Expected behavior
The test to run successfully
Screenshots
Stationery so no animation, display looks like:
versions
additional info
have to take the battery out to get it back to normal.
The program
[EDIT] added precise firmware level
The text was updated successfully, but these errors were encountered: