-
-
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
Move hub Bluetooth can disconnect randomly while running a program #320
Comments
I assume this item to be a better one than #304 for this post @dlech would you share the program you run (on the movehub?) for this issue? On my movehub I tried the build 1020 and 1022.
The last time it froze at iteration 356 My current program on the movehub: #
# source Z:\home\bert\py\pybricks\issue\issue_#304_movehub_randint.py
#
from pybricks import version
print(version)
from pybricks.pupdevices import ColorSensor
from pybricks.parameters import Port
# from urandom import randint
from pybricks.hubs import MoveHub
hub = MoveHub()
_rand = hub.battery.voltage() + hub.battery.current() # seed
print("Battery:", str(hub.battery.voltage()) + "mV", str(hub.battery.current()) + "mA at start")
# Return a random integer N such that a <= N <= b.
def randint(a, b):
global _rand
_rand = 75 * _rand % 65537 # Lehmer
return _rand * (b - a + 1) // 65537 + a
lights = ColorSensor(Port.D).lights # MoveHub has a fixed motor on Port.B
count = 0
print("") # start at a new line
while True:
count += 1
print("Start iteration", count, end="")
for i in range(50):
lights.on([randint(0, 100) for j in range(3)])
print(".", end="")
print("; ended") |
I would, but it is essentially already the same as the one you have posted. 😉
Interesting, I never waited this long. So it seems like Bluetooth isn't completely stuck then. |
Retired systemsprogrammer nowadays has the opportunity to wait some time 😄 . Do you know if there is a 4 minutes or maybe 250 seconds timeout in the bluetooth stack? |
Probably. We don't have any timeouts like that in our code that I recall. |
I've had this running for hours today and haven't had the Bluetooth quit yet. Not sure what could be different between yesterday and today. The fact that Bert was able to reproduce the problem shows there is still some problem here. But I'm stuck until we can find a more consistent way to reproduce the problem. |
Most of the tests I run on win10 with Microsoft Edge - Versie 90.0.818.49 (Officiële build) (64-bits). |
Intermediate report. The test on Linux Mint is now running at iteration 18000 plus. |
The first attempt on Linux Mint with Google Chrome ended, at iteration 134,915 So second attempt with fresh reloaded batteries:
This all seen at 9:37 I had enough time to wait for a Bluetooth disconnect, as I am building the Landrover next to the Linux PC. No idea how to qualify this behavior |
@dlech would a hang in environment As seen before, but really clear here, there is data missing from the print.
count 104 is the last printed data this time. [EDIT] On Linux Mint printing stops at about 4500 and Bluetooth connection dropped at that moment. |
If it just causes the Bluetooth to hang and the hub does not reboot itself, then yes this is the right place. The missing data is most likely caused by losses beyond our firmware. We are using GATT "notifications" which make no guarantee that the data is actually received on the other end (related: #274). We would need a Bluetooth sniffer to tell for sure though. |
Is the Linux test running in a virtual machine on the same hardware as Windows? |
Do you mean like in
The run on windows is relatively small. To be sure I will reboot windows and re-try first. |
In this case, no. It could be that the hub is sending the data over the air, but Windows is not able to receive it due to background noise or something like that. |
It would be good to start a new issue for the data loss. I am curious to know how often it affects other people. I haven't really seen it myself. |
No The Linux Mint runs as separate PC (My LEGO PC to show building instructions and such)
Will do. |
This could be my imagination or a coincidence, but it seems that more RF interference helps to reproduce this problem. I was having trouble reproducing this problem, but by enabling advertising on 3 other hubs while the Move hub is connected seems to significantly increase the likelihood of Bluetooth stopping on the Move hub. Also, as Bert has already observed, another distinguishing feature of this bug compared to #306 is that Bluetooth disconnects rather than just "locking up". It is possible to press the button on the hub to stop the program and go back to advertising. The Pybricks Code is able to reconnect and read the device info characteristics, but the UART characteristics no longer seems usable until rebooting the Move hub (Pybricks Code says "timeout waiting for checksum" in the console log). |
I also noticed that after this disconnection are reconnection that the Bluetooth address is sometimes set to FF:FF:FF:FF:FF:FF, so it seems that the Bluetooth chip is not being fully reset as it should be, maybe? After reconnection, the status notifications from the Pybricks GATT characteristic are received but the UART characteristics don't seem to work. After reconnection, pressing the hub button to start the in-flash-memory program works once. But after stopping it, it won't start again. |
The reconnection issue seems to be independent of the random disconnection issue, so I have opened #325 to track the reconnection issue. |
Since pybricks/pybricks-micropython@efda5d0 I am no longer able to reproduce the issue even with 4 other hubs advertising, so hopefully that means this issue has been resolved. |
As reported in #304 (comment), the Move hub Bluetooth seems to lock up occasionally somewhat similar to #306.
Symptoms are that Bluetooth becomes disconnected while running a program and pressing the hub button to stop the program works and makes the light blink (Bluetooth advertising) since the hub is now disconnected. Reconnection may be affected by #325, but that is a separate issue.
The text was updated successfully, but these errors were encountered: