-
-
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] Prime Hub broadcast does not work properly if broadcasting too fast #1151
Comments
On Prime Hub, we could add a Having this method (a)wait would make it consistent with the other hubs, which is probably a good thing. |
The PT_THREAD for this is already set up in the right form. It probably just needs a short wait in it (but only if recently called, as per above). |
I can reproduce this problem consistently as follows: SPIKE Prime receiver with this script, running disconnected from PC: from pybricks.hubs import ThisHub
from pybricks.parameters import Color
from pybricks.tools import wait, StopWatch
hub = ThisHub(observe_channels=[12])
watch = StopWatch()
while True:
data = hub.ble.observe(12)
if data:
hub.display.number(data)
wait(10) SPIKE Essential sender: from pybricks.hubs import EssentialHub
from pybricks.pupdevices import ColorLightMatrix
from pybricks.parameters import Color, Port
from pybricks.tools import wait, StopWatch
hub = EssentialHub(broadcast_channel=12)
watch = StopWatch()
while True:
for i in range(100):
data = i
color = Color.RED if i % 2 else Color.GREEN
hub.ble.broadcast(data)
print(watch.time())
hub.light.on(color)
# wait(10) <--- Needed to make it work when disconnected from PC |
This fix had to be undone via pybricks/pybricks-micropython@da7565e because it wasn't the right fix. So we should also revert pybricks/pybricks-micropython@cf73380 which can now hang the hub. We should probably implement the todo/fixme mentioned in there to await setting the broadcast data instead of waiting 10 ms anyway. |
It should also be possible to use the BTStack timer API instead, if needed. |
Originally posted by @Potato-eater in #1149
The text was updated successfully, but these errors were encountered: