pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
199 stars 167 forks source link

After CTRL F, GPy closes all ports but does not reset the board requires manual reset #431

Open DG12 opened 4 years ago

DG12 commented 4 years ago

`(sysname='GPy', nodename='GPy', release='1.20.2.rc2',

version='v1.11-605f40f on 2020-02-04', machine='GPy with ESP32', pybytes='1.3.1')`

Connecting via telnet and entering CTRL F on a new line closes all ports, telnet reports Connection closed by foreign host. ping reports "ping: sendto: Host is down" and ftp times out.

Board continues with heartbeat but does not reset.

Pressing the reset button is the only way to recover.

robert-hh commented 4 years ago

That's an intended behavior, a so-called feature. Pushing Ctrl-F in REPL causes a safe-boot, which is permanent until the reset button is pressed or machine.reset() is called. When that was introduced first, it caused me some trouble, because it could not be disabled. Calling micropython.kbd_intr(-1) disables this special behavior of both Ctrl-F and Ctr-C, again until restart. You can call kbd_int() with two arguments. Then the second will set the soft-reset char, like kbd_intr(3, -1) will disable Ctrl-F, but only until the REPL prompt comes back.

peter-pycom commented 4 years ago

As robert said, this is intentional. Ctrl-F puts it in safe-boot

robert-hh commented 4 years ago

Even if there is a mechanism to disable safe-boot after Ctrl-F, this is not implemented for Telnet. Telnet still checks for a hard-coded CHAR_CTRL_F constant, instead of referring to mp_reset_char. I had implemented the latter in my PR, but it was not pulled in by Pycom, whether intentionally or as omission. I asked a few times w/o feedback.

peter-pycom commented 4 years ago

I can't find the PR. Can you point me to it?

robert-hh commented 4 years ago

That's quite a while ago. I make a new one.

DG12 commented 4 years ago

Thank you for that clarification. Perhaps a warning in the help and documentation would be helpful since the system does not boot when issuing a CTRL-F but simply continues with no ports open (including ping!)

robert-hh commented 4 years ago

I see what you mention. Push Ctrl-F in Telnet causes the device to freeze. I would consider that a bug. So the question is, whether response to Ctrl-F should not be removed at all in telnet. The purpose of Ctrl-F is to enforce a well defined counterpart when used with Pymakr & VSC/Atom. b.t.w.: The response to Ctrl-D in telnet is weird as well.

DG12 commented 4 years ago

I noticed that CTRL-D also does not work as ( I ) expected.

Perhaps reopen this issue?

robert-hh commented 4 years ago

To have Ctrl-F result in a (safe) reboot is easy. Just change in line 541 false -> true. The Ctrl-D stuff is more weird. Because, when Telnet is opened, Ctrl-D will not result in a reboot, until enter is pressed in the telnet session; even when Ctrl-D was pushed in the UART session. OK. found a brute-force fix, which closes the telnet session upon Ctrl-D and reboots.

robert-hh commented 4 years ago

OK. The PR #432 is updated.