[Microbit-Python] Multiplexing UART between GPIO and REPL

Nevil Hunt nevil.hunt at hotmail.co.uk
Tue Nov 22 03:12:30 EST 2016


Hi,


This is just thinking out loud after following Marc-Andre's attempts to get the WiFi module talking to the micro:bit.


The conclusion seemed to be...


"it's so much easier to just use the UART between the two devices, that should just work out of the box."


but...


"Probably, yes, but we didn't want to give up the UART on the MB, since we'd then no longer be able to monitor whether the script is
 working correctly (via print() output)."

I have a few m:bit applications where I would like to use the UART to connect to external h/w but I was aware if programmed in Python I would loose the REPL, and debugging without the REPL to display 'print' commands and/or report syntax/memory errors would be difficult, so I wondered if this idea would be possible:-

Could the UART be assigned to GPIO pins for communicating with the external h/w but, just before a 'print' command, could the UART Tx be reassigned to the USB? The text would then be sent to the REPL before the UART would need to be reassigned back to the GPIO pin.

If so, could it be achieved without changing the current Micro Python / DAL. i.e. just within the user's Python code?

The next stage would be to also send syntax error messages to the REPL.

Does anyone have a view as to whether in theory this could be done within Micro Python or would it also require DAL changes?



Cheers,

Nevil


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20161122/264d5896/attachment.html>


More information about the Microbit mailing list