Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature requests #24

Open
jeffeb3 opened this issue Nov 17, 2016 · 7 comments
Open

Feature requests #24

jeffeb3 opened this issue Nov 17, 2016 · 7 comments

Comments

@jeffeb3
Copy link

jeffeb3 commented Nov 17, 2016

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.

@dpgeorge
Copy link
Member

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.

@Hermann-SW
Copy link

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
Copy link

Hermann-SW commented Sep 14, 2018

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
Copy link

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
Copy link

Hermann-SW commented Sep 15, 2018

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
Copy link

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
Copy link

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:
#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.
$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants