Open peterhinch opened 8 years ago
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
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
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 ;-)
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()