- Sponsor
-
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] Connecting to remote suppresses standard output #417
Comments
This is probably a separate issue. I think this happens because we disconnect the handset at the end of the program. When we send a message, it is using write without response. We only block until this message has been sent to the local Bluetooth chip. But there are already other messages queued there from printing to stdout. The disconnect command probably doesn't wait for these queued messages to be sent and drops them. If you add a delay to the end of the program, the name will change as expected. Printing to stdout still works after the program has ended since that is a different connection that is not disconnected. So I think the solution for that one is to figure out if there is any kind of feedback from the Bluetooth chips to see if all pending messages have been sent before disconnecting after the user program has ended. Another possibility could be to use write with response instead of write without response. This would make communication slower since we always have to wait for the response. And the user would have to handle the error if they don't want the program to crash when a message failed. As a workaround, adding a We can also compare the behavior to the SPIKE/RI large hub since it currently uses write with response (but it doesn't raise an error on failure yet). |
This is fixed on City and Technic hubs now (fix for #432 fixes this). Similar changes still need to be made to the Move hub. |
Fix for Move hub has been committed now as well. |
It looks like this is not entirely fixed. The original test case works now, but when I run the following program on the Move hub, the output ends at from pybricks.hubs import ThisHub
from pybricks.pupdevices import Remote
from pybricks import version
from pybricks.parameters import Color
from pybricks.tools import StopWatch
print(version)
hub = ThisHub()
print("Connecting...")
remote = Remote()
print("Connected to:", remote.name())
timer = StopWatch()
for h in range(360):
c = Color.BLUE << h
remote.light.on(c)
hub.light.on(c)
print(timer.time())
print("Done!") |
Copied from #736 Print output not OK on the MoveHub. Even on a simple print does not get correct output. print(" 1 2 3 4 5 6 7 8")
print("0123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 ") produces:
With a
|
After some reworking of the BlueNRG driver, the reproducible case from #417 (comment) is fixed. There were probably multiple contributing factors to the various symptoms, but the commit pybricks/pybricks-micropython@04d548a is the first commit where the symptom "When the program ends, the IDE doesn't update (stop button is still active)." is fixed. |
Describe the bug
Some output gets suppressed after connecting to the remote and reading the name.
Changing the name also appears to fail.
This happens consistently, so may provide some debugging starting points,
To reproduce
Gives
Expected behavior
The text was updated successfully, but these errors were encountered: