Page 1 of 1

Getting a REPL prompt via UART instead of via USB

Posted: Sun Jan 22, 2017 5:00 pm
by s_hatch
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.

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

Posted: Sun Jan 22, 2017 7:24 pm
by Roberthh
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)

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

Posted: Mon Jan 23, 2017 2:14 am
by s_hatch
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?

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

Posted: Mon Jan 23, 2017 2:32 am
by dhylands
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.

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

Posted: Mon Jan 23, 2017 5:07 pm
by kfricke
dhylands wrote:...
Try renaming the script to foo.py and...
"bar" might also work ;)

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

Posted: Tue Jan 24, 2017 6:57 am
by pythoncoder
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)