whaleygeek / bitio

A micro:bit I/O device library for Python
Other
92 stars 31 forks source link

Have to reset Microbit after each 'run' #2

Closed martinohanlon closed 7 years ago

martinohanlon commented 7 years ago

When I was testing, I quite often received the error:

Traceback (most recent call last):
  File "C:\Users\marti\Desktop\AdventuresInMinecraft-PC\MyAdventures\button.py", line 2, in <module>
    import microbit
  File "C:\Users\marti\Desktop\AdventuresInMinecraft-PC\MyAdventures\microbit\__init__.py", line 93, in <module>
    repl.to_raw()
  File "C:\Users\marti\Desktop\AdventuresInMinecraft-PC\MyAdventures\microbit\repl\repl.py", line 104, in to_raw
    raise REPLException("could not get a prompt")
microbit.repl.repl.REPLException: could not get a prompt

To reproduce the error, I needed to do this:

To get the microbit to respond again, I had to reset it, either by using the button on the back or by disconnecting and reconnecting it.

whaleygeek commented 7 years ago

Fixed in https://github.com/whaleygeek/bitio/commit/48dfc14d9e22bc41e4f9e0002c43bb623b87feba

When the program exits, the micro:bit does not reset, so it is left at the Raw REPL prompt. Running it again causes the startup state machine to get confused.

I added an extra CTRL-B into the startup state machine, so that it will exit the raw REPL if it is running. I tested this on Mac and it seems to work fine.