Skip to content
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] Ignore stdin when no program is running #303

Closed
laurensvalk opened this issue Apr 13, 2021 · 3 comments
Closed

[Bug] Ignore stdin when no program is running #303

laurensvalk opened this issue Apr 13, 2021 · 3 comments
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application

Comments

@laurensvalk
Copy link
Member

laurensvalk commented Apr 13, 2021

At the moment, programs downloads and user input/output happen on the same Bluetooth characteristic.

So when no program is running and you type something (anything) in the terminal, the hub interprets it as a program, which usually gives:

ValueError: incompatible .mpy file

As a workaround, perhaps Pybricks Code could ignore user input when no program is running.

Example: stopped a program and then press UP or DOWN button, shows:

SystemExit: stop button pressed
ValueError: incompatible .mpy file
ValueError: incompatible .mpy file
ValueError: incompatible .mpy file
ValueError: incompatible .mpy file
ValueError: incompatible .mpy file

No idea why I would want to press UP or DOWN though 😃
And do not know what the cursor keys are supposed to do.
Most browsing keys act the same.

Originally posted by @BertLindeman in #297 (comment)

@laurensvalk laurensvalk added bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application labels Apr 13, 2021
@laurensvalk
Copy link
Member Author

We could also accept this as-is, knowing that we will revisit it in the next version.

As long as program downloads still work after getting this error, this may be acceptable.

@laurensvalk
Copy link
Member Author

This should be fixed by pybricks/pybricks-micropython#109 when it gets merged.

@laurensvalk
Copy link
Member Author

laurensvalk commented Sep 1, 2022

This should be fixed by pybricks/pybricks-micropython#109 when it gets merged.

This is done, so we can close this.

dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 21, 2022
When no hub is connected, the terminal input handler loop would get
stuck waiting for didWrite or didFailToWrite which would never come
because handleWriteUart in ble/sagas only runs when a hub is connected.

This is fixed by only dispatching a write action if a user program is
running on the hub. By using this state, it also fixes characters being
buffered before the user program starts, e.g.

- connect hub
- type into terminal - no echo
- start the repl
- previously typed characters are echoed after the repl prompt

Now, anything typed before the user program is just ignored.

Fixes: pybricks/support#865
Also properly fixes pybricks/support#303
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application
Projects
None yet
Development

No branches or pull requests

1 participant