I am using my Pyboard Lite in USB VCP mode so that it can talk to a controller I am building using a RPi.
As I have serial data/commands/ACKs etc running over the USB serial link, I would like to disable the REPL as it can interfere during development. I have set up UART 6 and have the REPL duplicated onto this, but I am struggling to understand how the os.dupterm() function works.
I have issued os.dupterm(None,1) and it would appear to stop the REPL on VCP but I think it also disabled the REPL on UART 6.
Is it possible to have the REPL on just a UART connection and not the USB?
This would leave the VCP for just serial comms and all REPL and debug/print statements etc would be directed to the configured UART to assist with debugging and development.
Disabling REPL over USB only
Re: Disabling REPL over USB only
Can you post the code that you used to do this?
You can either do this in Python via dupterm etc, or possibly simpler, in mpconfigboard.h:
Code: Select all
#define MICROPY_HW_UART_REPL PYB_UART_6
#define MICROPY_HW_UART_REPL_BAUD 115200
The idea is that there are three dupterm "slots", and the terminal (i.e. the repl, but also stdio) is duplicated to all these slots.
At startup, if USB CDC is enabled, the VCP uses slot 1. Which is why os.dupterm(None, 1) disables the VCP.
Which slot were you using for the UART? (Note that the mpconfigboard.h approach described above doesn't use dupterm, it's kind of an extra "always connected" slot).
Re: Disabling REPL over USB only
Hi Jimmo - thanks for your reply.
I am using very simple code to setup the REPL in my boot.py :
I have then used the following to disable REPL on USB:
When you say that that this commands disables the VCP, do you mean REPL on VCP or it disables the whole VCP function?
I would like REPL only on UART 6 but able to use VCP via USB.
I'm afraid I do not know where mpconfigboard.h is or how it's used? Do you have a link to any documentation I can read please?
I am using very simple code to setup the REPL in my boot.py :
Code: Select all
import pyb
import os
pyb.country('US') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU
pyb.usb_mode('VCP') # act as a serial com port
os.dupterm(pyb.UART(6,9600))
Code: Select all
os.dupterm(None,1)
I would like REPL only on UART 6 but able to use VCP via USB.
I'm afraid I do not know where mpconfigboard.h is or how it's used? Do you have a link to any documentation I can read please?
Re: Disabling REPL over USB only
The former. You can still use the VCP via the pyb.USB_VCP class.
I just tested this setup -- I have a PYBV11 (should be the same as your PYBLITE) with an FTDI connected to UART 6.
I connected to ttyACM0 (i.e. the VCP UART) from my PC and did this at the REPL:
Code: Select all
os.dupterm(pyb.UART(6,9600), 0)
Then from the UART 6 REPL, I did:
Code: Select all
os.dupterm(None, 1)
But was then still able to do
Code: Select all
vcp = pyb.USB_VCP()
vcp.read(10)
So that sounds like exactly what you want?
Note there's a shortcut which is that you can write:
Code: Select all
os.dupterm(pyb.UART(6,9600), 1)
This is if you're building the firmware from source. Each board has a config file defining how it's configured. In this case I'm talking about https://github.com/micropython/micropyt ... figboard.h
But this is do-able with Python, so no need to worry about that.
Re: Disabling REPL over USB only
That’s great! Thank you.
In the final product I will have REPL disabled completely but this will be so useful for testing.
I will read up on the board config file stuff - I have so much to learn on how to build an image from scratch!
In the final product I will have REPL disabled completely but this will be so useful for testing.
I will read up on the board config file stuff - I have so much to learn on how to build an image from scratch!