REPL Pyboard over serial not USB
REPL Pyboard over serial not USB
I'm working on a project that requires I communicate with my Pyboard over a serial port (tx, rx) not the built in USB.
I hope to have access to REPL, rshell functionality and perhaps DFU-util. I have had success with an ESP32-dev_board because it has tx and rx pins exposed behind usb-serial chip. Looking at the schematic for Pyboard all the USB stuff is handled by the MCU. Please tell me this can be done as I need good quality Pyboard hardware for this project.
I hope to have access to REPL, rshell functionality and perhaps DFU-util. I have had success with an ESP32-dev_board because it has tx and rx pins exposed behind usb-serial chip. Looking at the schematic for Pyboard all the USB stuff is handled by the MCU. Please tell me this can be done as I need good quality Pyboard hardware for this project.
Re: REPL Pyboard over serial not USB
That's possible. Look in the manual for uos.dupterm().http://docs.micropython.org/en/latest/p ... os.dupterm
Re: REPL Pyboard over serial not USB
Many thanks to Roberthh for some direction here. I put this code in my boot.py and rebooted - instant results.
This may be crude but I'm pleased the Pyboard USB connection is now duplicated on UART 6.
Enter REPL from Raspberry Pi over serial adapter in picocom:
Enter
>>>
Code: Select all
import pyb
import uos
from pyb import UART
uart = UART(6)
uart.init(baudrate=115200, bits=8, parity=None, stop=1)
uos.dupterm(uart)
Enter REPL from Raspberry Pi over serial adapter in picocom:
Code: Select all
$ picocom -b115200 /dev/ttyUSB0
>>>
Re: REPL Pyboard over serial not USB
Ran in to a small snag. It seems REPL can't break out of a while loop using ctrl-c. REPL is not responding to keyboard interrupt. Is this something to do with sys.stdin perhaps? What if anything can be done to remedy this?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: REPL Pyboard over serial not USB
Might this issue be with picocom? I've used rshell with several targets over a serial interface and not encountered this.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: REPL Pyboard over serial not USB
Thank you pythoncoder, the issue does not seem to be with picocom. I tested rshell and it connects to the pyboard over serial no problem I can enter REPL and ctrl-x out of REPL. Ctrl-a, ctrl-b, ctrl-d and ctrl-e work as expected in REPL but ctrl-c will not break or interrupt a running loop. Also, I have attached an LED indicator to the UART rx pin and see it flash on keyboard strokes including ctrl-c. The message appears to arrive at the rx pin but is ignored somehow. Perhaps I have initiated the UART incorrectly.
Pyboard: MicroPython v1.9.2 on 2017-08-23; PYBLITEv1.0 with STM32F411RE.
Pyboard: MicroPython v1.9.2 on 2017-08-23; PYBLITEv1.0 with STM32F411RE.
Re: REPL Pyboard over serial not USB
This is just to confirm the issue, that Ctrl-C on dupterm does not interrupt code. A first glance into the code shows, that, in contrast to USB, Ctrl-C for UART is indeed not handled by the interrupt routine, but only when getting characters form the buffer.
This is an open issue since two years: https://github.com/micropython/micropython/issues/1568
This is an open issue since two years: https://github.com/micropython/micropython/issues/1568
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: REPL Pyboard over serial not USB
Ah, apologies - this issue is specific to dupterm. My testing was on devices where the interface is serial only rather than USB.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: REPL Pyboard over serial not USB
Thank you both. The apollogies are all mine to make because RT*M. Issue #1568 describes the same problem
Re: REPL Pyboard over serial not USB
Bumping this thread.
Looking for solution to Pyboard Repl over UART, where Ctrl-C break doesn't work.
Been a recognized problem for a long time.
https://github.com/micropython/micropython/issues/1568
Need to have REPL access to remote pyboards via wireless minicom UART terminal, have this working but without CTRL-C program break.
Is there a non blocking equivalent of scanning for keyboard key-press?
Looking for solution to Pyboard Repl over UART, where Ctrl-C break doesn't work.
Been a recognized problem for a long time.
https://github.com/micropython/micropython/issues/1568
Need to have REPL access to remote pyboards via wireless minicom UART terminal, have this working but without CTRL-C program break.
Is there a non blocking equivalent of scanning for keyboard key-press?
sys.stdin.read(1), this is blocking waiting for keypress