webrepl icon indicating copy to clipboard operation
webrepl copied to clipboard

Feature requests

Open jeffeb3 opened this issue 8 years ago • 7 comments

Great tool. In case you were looking for some things to make it better, here are two thoughts I had while using it:

  1. cli_repl: I don't like using a web page as a terminal. It's pretty slick, but I'm very good at using a terminal. I would like to be able to do the webREPL from the command line. Sort of how miniterm.py works, but over wifi. Maybe there's an easy way to do with with node.js, and the term.js? I'm not good enough with javascript to know.

  2. put mpy: I found out rather quickly that importing .py files takes a lot of RAM. I ended up converting to .mpy bytecode files. It would be nice if the webrepl_cli.py had a -m flag to convert them while transferring them. Some reasonable additional subfeatures would be: a) deleting the .py version if pushing with -m, or deleting the .mpy if pushing without -m. b) having a nice error message, with some simple instructions in case the bytecode conversion script isn't installed or available. c) warn, or refuse to do the conversion with main.py and boot.py (in my experience, they don't work if they are the .mpy versions, maybe that's really the bug here).

I would promise to help, but the Internet is riddled with my false promises. I could probably work on 2) but tty stuff always gets the best of me, so 1) is probably a lot easier for one you.

Just my $0.02. Thanks for the work so far. It's a great tool for the kit.

jeffeb3 avatar Nov 17 '16 21:11 jeffeb3

Thanks for the feedback. Re point 2, that's a bit far out of scope because it needs mpy-cross, which requires compiling from source, and so would be a heavy dependency to force on everyone.

Re point 1: if you want to try it please go ahead :) I'd start with the existing webrepl_cli.py program and add the miniterm.py features.

dpgeorge avatar Nov 18 '16 06:11 dpgeorge

Re point 1: already done by aivarannamaa: https://forum.micropython.org/viewtopic.php?f=2&t=3124&p=30156#p28051

I did fix a small flushing issue and added "-s" silent flag: https://stamm-wilbrandt.de/en/forum/webrepl_client.py

Description (inclusive aivarannamaa's suffix explanation for switching between modes and being able to interrupt remote endless loops) here: https://forum.micropython.org/viewtopic.php?f=2&t=3124&p=30156#p30156

This is mostly aivarannamaa's code, so forking and doing a pull request here does not seem right to me. But webrepl_client.py is a very useful remote console addition to webrepl_cli.py copy commands for me, and I would like to see it being part of this repo (or console functionality being integrated into webrepl_cli.py).

My first application is triggering servo bomb drop mechanism attached with ESP-01s running MicroPython to a flying drone, from mobile Pi ZeroW running webrepl_client.sh:

Hermann-SW avatar Sep 14 '18 08:09 Hermann-SW

I fixed the silent option in order to not output newly entered command a second time as seen in last screenshot: https://stamm-wilbrandt.de/en/forum/webrepl_client.py

Now a (Micro)Python session looks like webepl session in browser besides the added suffixes:

Hermann-SW avatar Sep 14 '18 16:09 Hermann-SW

Added check for ws.sock for graceful endings in some situations (ungraceful see last screenshot), and try/except for graceful ending on CTRL-C: http://stamm-wilbrandt.de/en/forum/webrepl_client.py

Hermann-SW avatar Sep 14 '18 17:09 Hermann-SW

Now "\n" command suffix is superfluous in silent mode! https://forum.micropython.org/viewtopic.php?f=2&t=3124&p=30180#p30180

$ ./webrepl_client.py -s
Password: 12345678

WebREPL connected
>>> 4**3**2
262144
>>> \x01

raw REPL; CTRL-B to exit
>\x02

MicroPython v1.9.4-481-g3cd2c281d on 2018-09-04; ESP module with ESP8266
Type "help()" for more information.
>>> 
>>> exit
### closed ###
$ 

Hermann-SW avatar Sep 15 '18 19:09 Hermann-SW

Now webrepl_client.py runs under python v2 as well as v3 as well as standalone: https://stamm-wilbrandt.de/en/forum/webrepl_client.py

$ python webrepl_client.py -s
Password: abcd

WebREPL connected
>>> 4**3**2
262144
>>> exit
$ 
$ python3 webrepl_client.py -s
Password: abcd

WebREPL connected
>>> 4**3**2
262144
>>> exit
$ 
$ ./webrepl_client.py -s
Password: abcd

WebREPL connected
>>> 4**3**2
262144
>>> exit
$ 

Hermann-SW avatar Sep 17 '18 22:09 Hermann-SW

I spent more work on getting webrepl_client.py pep8online.com compliant and provide help(). Because of all the work I changed my mind and created a pull request to add webrepl_client.py remote shell using Micropython WebREPL protocol. Documentation is provided as well: https://github.com/micropython/webrepl/pull/37

$ webrepl_client.py 
webrepl_client.py - remote shell using MicroPython WebREPL protocol
Arguments:
  <host> [-v] - open remote shell (to <host>:8266)
Examples:
  webrepl_client.py 192.168.4.1
  webrepl_client.py 192.168.4.1 -v
Special command control sequences:
  "\n"        - end of command in normal mode
  "\x01"      - switch to raw mode
  "\x02"      - switch to normal mode
  "\x03"      - interrupt
  "\x04"      - end of command in raw mode
  just "exit" - end shell

  "\n" gets auto appended without "-v".
  Therefore "-v" is needed for raw mode.
$ 

Hermann-SW avatar Sep 19 '18 00:09 Hermann-SW