使用无限循环时 NodeMCU (ESP8266) 无响应(当 True 时)

NodeMCU (ESP8266) unresponsive when using endless loop (while True)

当我在 main.py 中包含 while True: 时,我无法再覆盖它并上传新版本。

许多新手指南和教程,例如:this one and this one,使用while True。所以我想应该是可能的。

我已经尝试使用 Thonnyampy 上传(覆盖)main.py 而板子是 运行 无限循环。

我当前的解决方法是使用 picocom 连接到 REPL 并使用 os.remove.

删除文件

Micropython 版本:esp8266-20210618-v1.16

注意。我知道计时器可以减少无限循环的需要。

看看您链接到的第一个示例, 在引入 while true 循环后准确描述您的当前情况:

You might be worried to see the >>> REPL prompt never appears again and you can't enter code. Remember this is because MicroPython can only do one thing at a time and the infinite loop means the board is busy blinking the LED.

Luckily you can tell the board to stop whatever it's doing and return back to the REPL prompt. Press the Ctrl-c key on your keyboard and you should see the code stop with a KeyboardInterrupt error like this:

当你有一个无限循环 运行ning 时,没有别的可以 运行。 如果您希望能够与 REPL(这正是 ampy 所做的,例如)。