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

pyboard.py Fix for rshell issue #7 #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

pyboard.py Fix for rshell issue #7 #12

wants to merge 1 commit into from

Conversation

peterhinch
Copy link

For some reason my recent HP zbook takes some 15 seconds before the Pyboard is recognized. If invoked during this time rshell threw an exception. This patch fixes this: it behaves sensibly whether the Pyboard is plugged in before or after invoking rshell.

I'm puzzled why I have to do sys.stdout.flush()

@dhylands
Copy link
Owner

The need for a flush is because stdout is line buffered by default, so characters just accumulate in memory until a newline is seen and then the call write is made. This is C runtime library behaviour and not specific to python. Adding the flush call causes the accumulated data to be written before the newline is seen.

I'll take a look at this. Thanks

@dhylands
Copy link
Owner

If for some reason, they don't take the patch, I'm pretty sure I can do something similar in rshell when it constructs the Pyboard object. (the loop just moves into rshell.py instead of being in pyboard.py

@peterhinch
Copy link
Author

I've submitted a PR. I used your suggestion re else, but had to make a few other changes when I tested pyboard.py on its own because it uses Python 2.x by default. Hopefully it will be accepted because in my view it improves pyboard too.

As for flush I should have remembered that - I was assuming a complicated reason when a simple one sufficed ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants