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

REPL: could not get a prompt #44

Open
RadoTheProgrammer opened this issue Mar 9, 2024 · 2 comments
Open

REPL: could not get a prompt #44

RadoTheProgrammer opened this issue Mar 9, 2024 · 2 comments

Comments

@RadoTheProgrammer
Copy link

I, i got an error when i try running import microbit

>>> import microbit
connecting...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alain/RR/Rpy-mc/bitio/microbit/__init__.py", line 130, in <module>
    repl.to_raw()
  File "/Users/alain/RR/Rpy-mc/bitio/microbit/repl/repl.py", line 105, in to_raw
    raise REPLException("could not get a prompt")
microbit.repl.repl.REPLException: could not get a prompt

How to fix that error ?

@whaleygeek
Copy link
Owner

whaleygeek commented Mar 10, 2024

The usual cause for this is where you have either not loaded the provided bitio.hex file onto the micro:bit, there is a problem with the version of the .hex file, or you are connecting to a different COM port that doesn't have a micro:bit on it.

1.&2. Sometimes the micro:bit foundation update the runtime code that is stored inside .hex files, and bitio.hex gets out of date. e.g. see this (old) issue: #33

You can regenerate the bitio.hex file that is cached in this repository (so that it has all the right hardware drivers for newer micro:bits) by drag-dropping it into https://python.microbit.org and then pressing the DOWNLOAD button - then flash that new .hex file to your micro:bit by drag-dropping it onto the MICROBIT drive that appears when you plug the micro:bit into the computer.

  1. The COM port detected is stored inside a file called portscan.cache file, then follow the documented workflow in the README whereby you unplug and plug in the micro:bit and it discovers the port.

If you have issues with your USB lead, try this: https://support.microbit.org/support/solutions/articles/19000037633-what-type-of-usb-lead-do-i-need-for-the-micro-bit-

You can verify that your micro:bit is flashed/connected correctly by attaching it to your computer, going to python.microbit.org, connecting, and then opening the serial window, you should get a REPL prompt printed and be able to send commands like print("hello") and it will respond. If it does not respond in this way, bitio will not be able to communicate with the micro:bit

https://support.microbit.org/support/solutions/articles/19000135210-python-editor-guide#serial

@whaleygeek
Copy link
Owner

This has been reported by another user too.

I suspect if you wind back the Python version on your host computer it might be a workaround. I suspect Python3.12 has broken the embedded Pyserial by deprecating some methods or something. We embeeded pyserial so that it was a zero-install package (file copy) on Raspberry Pi (for kids in schools) to make the install dependency free. It might be time to upgrade the embedded pyserial, or use a different way of deploying with dependencies I suspect.

I will try to investigate this further over the Easter hols

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

No branches or pull requests

2 participants