Getting a REPL prompt via UART instead of via USB

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
s_hatch
Posts: 15
Joined: Wed Nov 25, 2015 6:50 pm

Getting a REPL prompt via UART instead of via USB

Postby s_hatch » Sun Jan 22, 2017 5:00 pm

I am trying to untether from my laptop and run the pboard over a serial UART signal. I am building an embedded data acquisition system, using the pboard. I have created a serial to VGA board and I will use that to display data, just need access to the REPL prompt. Can't find any information on the micro python.org site. Please help me. I think I should be able to redirect the REPL to one of the UARTs. I am currently using UART(3,9600) to connect to my terminal.

User avatar
Roberthh
Posts: 577
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Getting a REPL prompt via UART instead of via USB

Postby Roberthh » Sun Jan 22, 2017 7:24 pm

For PyBoard, use pyb.repl_uart. An example is here: http://docs.micropython.org/en/latest/p ... =repl_uart

or os.dupterm()

Code: Select all

from pyb import UART
import os

uart = UART(0, baudrate=115200)
os.dupterm(uart)

s_hatch
Posts: 15
Joined: Wed Nov 25, 2015 6:50 pm

Re: Getting a REPL prompt via UART instead of via USB

Postby s_hatch » Mon Jan 23, 2017 2:14 am

Thank you. I can get it to work from the USB REPL but when I put it into boot.py or main.py it doesn't work. What am I missing?

User avatar
dhylands
Posts: 2313
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: Getting a REPL prompt via UART instead of via USB

Postby dhylands » Mon Jan 23, 2017 2:32 am

You probably have an error in the script someplace.

Try renaming the script to foo.py and then from the REPL do:

Code: Select all

import foo
that will typically show you your error.

User avatar
kfricke
Posts: 312
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Getting a REPL prompt via UART instead of via USB

Postby kfricke » Mon Jan 23, 2017 5:07 pm

dhylands wrote:...
Try renaming the script to foo.py and...
"bar" might also work ;)

User avatar
pythoncoder
Posts: 1426
Joined: Fri Jul 18, 2014 8:01 am

Re: Getting a REPL prompt via UART instead of via USB

Postby pythoncoder » Tue Jan 24, 2017 6:57 am

I use the following boot.py (which disables USB). Adapt for your UART and baudrate:

Code: Select all

import pyb
pyb.usb_mode(None)
uart = pyb.UART(2, 115200)
pyb.repl_uart(uart)
Peter Hinch


Return to “Programs, Libraries and Tools”

Who is online

Users browsing this forum: No registered users and 2 guests