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

Not Windows Compatible #17

Open
ghost opened this issue Nov 23, 2016 · 14 comments
Open

Not Windows Compatible #17

ghost opened this issue Nov 23, 2016 · 14 comments

Comments

@ghost
Copy link

ghost commented Nov 23, 2016

This cannot be used out-of-the-box on Windows because the readline module is needed, which is not available for a Windows shell. Maybe you could detect OS and load a similar module for Windows users?

Thanks

@dhylands
Copy link
Owner

It does work on windows under cygwin.

Are you aware of a similar module for windows?

I've managed to find pyreadline: https://pypi.python.org/pypi/pyreadline and I found this blog post on using it with rlcompleter:
http://www.farmckon.net/2009/08/rlcompleter-how-do-i-get-it-to-work/

Would you be able to test this?

@Arrowana
Copy link

Arrowana commented Jun 1, 2017

I tried to had some minor tweaks to make the rshell work on windows.
It does, I can use rshell. Absolute windows path don't seem to work though, but relative ones work fine
However pyreadline breaks the CPython REPL.

With pyreadline installed if I press TAB in the CPython REPL it will throw
>>> def test(): ... Readline internal error Traceback (most recent call last): File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23 res = ensure_str(readline_hook(prompt)) File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\rlmain.py", line 571, in readline self._readline_from_keyboard() File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard if self._readline_from_keyboard_poll(): File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll result = self.mode.process_keyevent(event.keyinfo) File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent r = self.process_keyevent_queue[-1](keyinfo) File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent r = dispatch_func(keyinfo) File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete completions = self._get_completions() File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions r = self.completer(ensure_unicode(text), i) File "C:\Users\Arowana\AppData\Local\Programs\Python\Python35\lib\rlcompleter.py", line 80, in complete readline.redisplay() AttributeError: module 'readline' has no attribute 'redisplay' File "<stdin>", line 2

Obviously a pyreadline bug

@ccooper21
Copy link

I just learned about rshell on the uPy forums and thought I'd give it a try (on Windows). Pretty cool! As expected, I had to install the pyreadline library to get it working. Other than that, the only change I had to make is to replace the 'libedit' in readline.__doc__ reference in main.py with readline.__doc__ and 'libedit' in readline.__doc__. I did not observe the error that @Arrowana reported.

ccooper21 added a commit to ccooper21/rshell that referenced this issue Dec 4, 2017
@Jim43
Copy link

Jim43 commented May 4, 2018

@ccooper21 it works,thanks

@jumblies
Copy link

jumblies commented Jun 16, 2018

Working through another issue, I reinstalled and it occurred to me a minor change could prevent manual editing. I'm a gitidiot so here is what did starting at line 67

if os.name == "nt":
    if readline.__doc__ and 'libedit' in readline.__doc__:
        readline.parse_and_bind ("bind ^I rl_complete")
        BROKEN_READLINE = True
    else:
        readline.parse_and_bind("tab: complete")

I guess all that's needed is an else to use the standard line in *nix systems.

@RSabet
Copy link

RSabet commented Sep 8, 2018

see #62

@clifforddw
Copy link

Hi All, I managed to get rshell working on windows through the Linux Subsystem for windows.
install rshell as per the documentation and then enable the requires serial port with this command :

stty -F /dev/ttyS2 -a

Good article here with the background https://blogs.msdn.microsoft.com/wsl/2017/04/14/serial-support-on-the-windows-subsystem-for-linux/

@karelv
Copy link

karelv commented Dec 20, 2018

@dhylands ,

I've managed to find pyreadline: https://pypi.python.org/pypi/pyreadline and I found this blog post on using it with rlcompleter:
http://www.farmckon.net/2009/08/rlcompleter-how-do-i-get-it-to-work/

I did this:
pip install rshell
(rshell-0.0.16)
I run rshell, I got:

....
ModuleNotFoundError: No module named 'readline'

Then I've installed pyreadline:
pip install pyreadline
(pyreadline-2.1)

$ rshell
Welcome to rshell. Use the exit command to exit rshell.

No MicroPython boards connected - use the connect command to add one

C:\Users\karelv\micropython

Note: I used git-sh as shell and python from anaconda on my win7 pc.
Note2: the prompt is in green, so I guess the colors are working
Note3: I entered repl, but no clue how to exit it... exit() is not working... I found it; ctrl-X, thanks, now I can start my blinking app :-)

@dhylands
Copy link
Owner

You should be able to exit the REPL by using Control-X. I didn't want to use Control-D since Control-D does a soft reset under MicroPython. It should print a line mentioning Control-X when you enter the REPL.

@dhylands
Copy link
Owner

To exit from rshell (rather then the micropython repl within rshell) I normally use Control-D, but that didn't seem to work under Windows, so I added an exit command (no parenthesis).

@karelv
Copy link

karelv commented Dec 21, 2018

Hello @dhylands, ctrl-X indeed exits the repl, while ctrl-D exits the rshell (when in git-sh).
Thanks a lot. Now I have another question, off-topic. I'm new to micropython and ESP32. I just now have a ESP32 module. I want to create an application with CAN bus 2.0, but I have misread the micropython doc, CAN is only implemented for pyboard. What would you suggest me to do? Go arduino, or go ESP-IDF as development platform? Is it possible to 'port' arduino to micropython? Or I go better with ESP-IDF?

@karelv
Copy link

karelv commented Dec 21, 2018

Again ontopic... I tried rshell also on cmd.exe (win7).

  • help works
  • exit works, when type twice exit, it also exits cmd.exe.
  • ctrl-D works as well.
  • rshell prompt is in color(green).

@dhylands
Copy link
Owner

I have'n't really used ESP-IDF directly, and I rarely use arduino, so I'm not really sure which would be more appropriate.

As for help and exit being built-in commands to cmd.exe, I don't understand the issue. Those commands will only be interpreted by cmd.exe if you're at the cmd prompt. If you're at the rshell prompt, then the commands will be interpreted by rshell.

So yeah, if you type the command twice, the first one will be interpreted by rshell and when it exits, the second buffered command will be executed by cmd.exe.

@ghost
Copy link
Author

ghost commented Dec 21, 2018 via email

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

8 participants