pybricks / pybricksdev

pybricksdev: Python Package with Pybricks developer tools
https://pypi.org/project/pybricksdev/
MIT License
48 stars 15 forks source link

Expected checksum #16

Closed laurensvalk closed 3 years ago

laurensvalk commented 3 years ago

On Ubuntu 20.04 and ('primehub', '3.0.0b4', 'a0856ec1 on 2021-04-09'), I'm getting this:

pybricksdev run ble "Pybricks Hub" ~/git-pybricks/pybricks-micropython/tests/pup/sensors/color_color.py 
Searching for Pybricks Hub
Downloading 748 bytes in 8 steps.
Progress: 12%
Progress: 25%
Progress: 38%
Progress: 50%
Progress: 62%
Progress: 75%
Progress: 88%
Progress: 100%
2021-04-09 11:59:19,975: WARNING: Expected checksum 197 but got 13
2021-04-09 11:59:19,976: WARNING: Expected checksum 197 but got 32

...done.

It does run despite this.

This was working before.

dlech commented 3 years ago

Is the program supposed to print something?

thesynman commented 3 years ago

I'm seeing the same issue on Win10 with the latest pybricksdev and latest firmware. I get the occasional checksum error but the program seems to install OK.

laurensvalk commented 3 years ago

Is the program supposed to print something?

Yes and no. No prints in this demo, but the "Running program..." seems to get gobbled up.

dlech commented 3 years ago

Of course. (Why didn't I notice that? :smile:)

dlech commented 3 years ago

Should be fixed now. Not 100% sure since I could only rarely reproduce the problem.

thesynman commented 3 years ago

@dlech Something seems to have gone seriously wrong with program output in the latest version of pybricksdev - I'm not seeing any!

With latest (34ac155fda24b86eaeda685104cb6651f2d66720):

C:\PycharmProjects\pybricksdev>poetry run pybricksdev run ble "Pybricks Hub" "print('hi there')"
Searching for Pybricks Hub
Downloading 45 bytes in 1 steps.

Progress: 100%
Running downloaded program...

C:\PycharmProjects\pybricksdev>

With v1.0.0-alpha.1 (29b1bee32dc44bf85480781eff4e12b1245b712b):

C:\PycharmProjects\pybricksdev>poetry run pybricksdev run ble "Pybricks Hub" "print('hi there')"
Searching for Pybricks Hub
Downloading 45 bytes in 1 steps.
Progress: 100%

Running downloaded program...
hi there

...done.

C:\PycharmProjects\pybricksdev>
thesynman commented 3 years ago

Further to my last comment, I've discovered that a short wait after the print allows the program to execute correctly:

C:\PycharmProjects\pybricksdev>poetry run pybricksdev run ble "Pybricks Hub" "from pybricks.tools import wait; print('hi there'); wait(200)"
Searching for Pybricks Hub
Downloading 84 bytes in 1 steps.
Progress: 100%

Running downloaded program...
hi there

...done.

C:\PycharmProjects\pybricksdev>
laurensvalk commented 3 years ago

It's possible that the final program output hasn't been fully processed and printed by the time the "program-completed" signal comes in. Like you've found, a short delay should be good enough. I've just pushed something like it to the master branch.

We expect to revise this part of Bluetooth a bit more in the next release, so a workaround like this should be good for now.