I will, thanks! So there is absolutely no way to send keystrokes to a microcontroller over WiFi?aivarannamaa wrote: ↑Fri Nov 13, 2020 10:18 pmNope, Thonny's Shell does not support capturing keystrokes. Actually, I don't see how you could capture keystrokes in MicroPython even if you were using a proper terminal emulator.
> Far fewer exceptions that in the previous build I tried
Do you mean misbehaviors of Thonny? Please report them at https://github.com/thonny/thonny/issues/new
Using webrepl instead of USB connection with Thonny IDE
Re: Using webrepl instead of USB connection with Thonny IDE
- aivarannamaa
- Posts: 171
- Joined: Fri Sep 22, 2017 3:19 pm
- Location: Estonia
- Contact:
Re: Using webrepl instead of USB connection with Thonny IDE
I'm not entirely sure, but I don't know how.
In a terminal emulator you probably can send combinations with Ctrl -- eg. Ctrl+F should send byte 0x06 (smaller values are special for MicroPython REPL). I haven't tried it, though and it won't work in Thonny.
Aivar Annamaa
https://thonny.org
https://thonny.org
Re: Using webrepl instead of USB connection with Thonny IDE
I think laukejas is referring to viewtopic.php?f=2&t=9303aivarannamaa wrote: ↑Sat Nov 14, 2020 8:45 pmIn a terminal emulator you probably can send combinations with Ctrl -- eg. Ctrl+F should send byte 0x06 (smaller values are special for MicroPython REPL). I haven't tried it, though and it won't work in Thonny.
See my reply there. Admittedly this was tested on STM32 not ESP8266 but from MicroPython's perspective it's just bytes arriving on the UART, so it should be similar.
How does Thonny's shell work differently to, say, screen or miniterm.py? Is it line buffered?
- aivarannamaa
- Posts: 171
- Joined: Fri Sep 22, 2017 3:19 pm
- Location: Estonia
- Contact:
Re: Using webrepl instead of USB connection with Thonny IDE
Yes, I think this is the right term for this. It doesn't send anything to the back-end until you press ENTER.
Actually, I thought that the same happens with terminal emulator + screen/tio/miniterm. Doesn't it? When MP code does `sys.stdout.read(2)` and I'm pressing "x", "y", "backspace", "z" in miniterm, what gets read? (Sorry, I don't have a device with me at the moment to try it out)
Aivar Annamaa
https://thonny.org
https://thonny.org
Re: Using webrepl instead of USB connection with Thonny IDE
The characters get sent directly. This is what allows things like tab completion to work on the REPL.aivarannamaa wrote: ↑Sun Nov 15, 2020 6:43 amYes, I think this is the right term for this. It doesn't send anything to the back-end until you press ENTER.
Actually, I thought that the same happens with terminal emulator + screen/tio/miniterm. Doesn't it? When MP code does `sys.stdout.read(2)` and I'm pressing "x", "y", "backspace", "z" in miniterm, what gets read? (Sorry, I don't have a device with me at the moment to try it out)
I assume you mean sys.stdin.read though?
To put it more concretly, the example code I gave in the other thread works exactly like you'd expect -- you can sys.stdin.read(1) and receive the characters exactly as the user types them (including control characters etc).
How does Thonny avoid the echo on the MicroPython REPL?
- aivarannamaa
- Posts: 171
- Joined: Fri Sep 22, 2017 3:19 pm
- Location: Estonia
- Contact:
Re: Using webrepl instead of USB connection with Thonny IDE
Indeed. I never thought about tab-completion and arrow up/down, but now I understand that it must work like this.
Yes, my mistake.
It just consumes the echo after submitting the input (which is always a single line ending with CRLF).
Aivar Annamaa
https://thonny.org
https://thonny.org
Re: Using webrepl instead of USB connection with Thonny IDE
I don't fully understand everything that you guys here discussed, so I'm kind of unsure - so, what is the best way to go around sending direct keystrokes via Thonny to ESP?aivarannamaa wrote: ↑Mon Nov 16, 2020 11:24 amIndeed. I never thought about tab-completion and arrow up/down, but now I understand that it must work like this.
Yes, my mistake.
It just consumes the echo after submitting the input (which is always a single line ending with CRLF).
- aivarannamaa
- Posts: 171
- Joined: Fri Sep 22, 2017 3:19 pm
- Location: Estonia
- Contact:
Re: Using webrepl instead of USB connection with Thonny IDE
Unfortunately there is no way for it. What you can do is
* use Thonny for saving your code to main.py
* select "Tools => Open system shell" which (starting from Thonny 3.3) opens your MicroPython repl in the Terminal
* press Ctrl+D to soft reboot and start your scrip
* send your keystrokes in normal way
I'm considering enabling "Run => Run current script in Terminal" in a future version and implementing automatic reconnect in Thonny when you have closed the terminal.
Aivar Annamaa
https://thonny.org
https://thonny.org
Re: Using webrepl instead of USB connection with Thonny IDE
Pressing "Open system shell" opens the shell, but I don't think WebREPL is running. All I'm seeing is plain command line, waiting for regular inputs, not like WebREPL. Am I missing some dependency or something?aivarannamaa wrote: ↑Fri Nov 20, 2020 6:49 amUnfortunately there is no way for it. What you can do is
* use Thonny for saving your code to main.py
* select "Tools => Open system shell" which (starting from Thonny 3.3) opens your MicroPython repl in the Terminal
* press Ctrl+D to soft reboot and start your scrip
* send your keystrokes in normal way
I'm considering enabling "Run => Run current script in Terminal" in a future version and implementing automatic reconnect in Thonny when you have closed the terminal.
Also, I am not quite sure I understand what you meant by "send your keystrokes in normal way", could you please explain?
- aivarannamaa
- Posts: 171
- Joined: Fri Sep 22, 2017 3:19 pm
- Location: Estonia
- Contact:
Re: Using webrepl instead of USB connection with Thonny IDE
Oops, I forgot that we were talking about WebREPL. In this case I can't offer any work-arounds at the moment.
I meant just pressing the keys in terminal window and doing sys.stdin.read(1) in your MicroPython code. But at the moment Thonny provides terminal window for MicroPython REPL only via serial connection.
Aivar Annamaa
https://thonny.org
https://thonny.org