← index #5456PR #5469
Related · high · value 1.209
QUERY · ISSUE

pyboard.py: add "delay" argument in CLI

openby ShenTengTuopened 2019-12-25updated 2021-05-29
tools

I used ampy to interact with ESP32 before. In my case, I need to give a delay (3 sencods) to enter raw REPL successfully.

ampy --port com14 --delay 3 ls

If I use pyboard.py CLI, I can't enter raw REPL, even if I set the --wait argument to 3.

pyboard.py --device com14 -w 3 -f ls

In ampy source code, --delay parameter is applied to the top of the enter_raw_repl () function to control the delay before enter raw REPL:

ampy/pyboard.py#L175

    def enter_raw_repl(self):
        # Brief delay before sending RAW MODE char if requests
        if _rawdelay > 0:
            time.sleep(_rawdelay)
       # ...

I use a simple script to test orginal pyboard.py, and it is work:

import pyboard
import time
pyb = pyboard.Pyboard('COM14')
time.sleep(3) # delay before enter
pyb.enter_raw_repl()
ret = pyb.exec_('print(1+1)')
print(ret)
pyb.exit_raw_repl()

I hope pyboard.py CLI can provide a parameter to control the delay.

CANDIDATE · PULL REQUEST

tools/pyboard: Split Ctrl-C into two separate steps with small delay

closedby mbueschopened 2019-12-28updated 2020-02-07
port-esp32tools

This makes pyboard.py successfully enter raw-repl on an ESP32 board.
Without the split the running program won't always successfully abort and thus entering raw-repl fails.

I'm not completely sure, if this also depends on the actual program that is running on the device and whether this also happens on a real pyboard.
So for reference, here's the program running on the device which triggers the behaviour for me:

from machine import Pin
from time import sleep
import micropython

p = Pin(0, Pin.OUT)

#@micropython.native
def func():
	for _ in range(1000):
		p.value(not p.value())
while 1:
	func()

This change has not been tested on an actual pyboard, because I don't have one.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied