Problem with cursor keys with VScode

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Problem with cursor keys with VScode

Post by andymouse » Fri Apr 12, 2019 8:55 am

Hi,All

I have Micropython correctly installed on my LOLIN/ Wemos D1 Mini and am using Visual Studio Code to program it. When I open the terminal I am met with a command line and I type this and hit return :-

C:\Users\andy>python -m serial.tools.miniterm COM3 115200
--- Miniterm on COM3 115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

>>>
All is well until I try to use the cursor keys, and then I get upper case characters like this :-

>>> KHPHPMMMKKKPPMMHKM
and if I use the backspace and delete keys I also get strange characters :-

>>> ␛[KSS␛[␛[␛[KSSSSSS␛[␛[␛[␛[␛[␛[␛[KOOOIIQ␛[K
Has anyone got any thoughts on what I'm doing wrong as I'm not sure what to do next?

Andy

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Problem with cursor keys with VScode

Post by dhylands » Fri Apr 12, 2019 2:51 pm

It seems to be something to do with serial.tools.miniterm.

I tried serial.tools.miniterm in Power Shell, CMD, and powershell within vscode and it behaved the same in all of those places.

I tried rshell in the same 3 places and things worked properly.

So it seems that miniterm is doing something to mess up the sequences being sent back from the micropython board (because I know that rshell doesn't have any special handling for those escape sequences).

I also tried miniterm under linux, and it behaves the same way as it does under windows (i.e. not working with backspace)

User avatar
marfis
Posts: 215
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

Re: Problem with cursor keys with VScode

Post by marfis » Fri Apr 12, 2019 7:07 pm

miniterm filters out escape sequences. The question was asked before, see here
https://github.com/pyserial/pyserial/is ... -311126372

for a response of the maintainer.

You could use his mpy-repl-tools that fires up a patched version of miniterm, as explained by his answer.

Or use ˋ—rawˋ as option to call miniterm. But according to the thread above this might have other issues with cr/lf

andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Re: Problem with cursor keys with VScode

Post by andymouse » Sat Apr 13, 2019 1:01 am

Hi, All
So how can I install and use Rshell if this is what I need ? Is it some thing that exists already? Please could you explain what is happening and perhaps walk me through a work around, your help has been invaluable, and would love to put this final issue to bed! Im sort of glad its real and something I did wrong!
I now have rshell and it is asking me to use the "connect " command but I dont no the syntax for my board to get rshell I used :-

Collecting rshell
Downloading https://files.pythonhosted.org/packages ... .21.tar.gz (42kB) 100% |████████████████████████████████| 51kB 117kB/s
Requirement already satisfied: pyserial in c:\users\andy\appdata\local\programs\python\python37-32\lib\site-packages (from rshell) (3.4)
Collecting pyudev>=0.16 (from rshell) Downloading https://files.pythonhosted.org/packages ... 1.0.tar.gz (89kB)
100% |████████████████████████████████| 92kB 1.0MB/s
Collecting pyreadline (from rshell) Downloading https://files.pythonhosted.org/packages ... ne-2.1.zip (109kB)
100% |████████████████████████████████| 112kB 965kB/s
Collecting six (from pyudev>=0.16->rshell)
Downloading https://files.pythonhosted.org/packages ... Installing collected packages: six, pyudev, pyreadline, rshell
Running setup.py install for pyudev ... done
Running setup.py install for pyreadline ... done
Running setup.py install for rshell ... done
Successfully installed pyreadline-2.1 pyudev-0.21.0 rshell-0.0.21 six-1.12.0

C:\>rshell
Welcome to rshell. Use the exit command to exit rshell.

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

C:\>
I just tried this:-
C:\> connect serial port
Connecting to port (buffer-size 512)...
failed to access port
C:\>
last thing I tried :-
rshell
Welcome to rshell. Use the exit command to exit rshell.

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

C:\Users\andy> connect serial port3 115200
Connecting to port3 (buffer-size 512)...
failed to access port3
C:\Users\andy>

Where do I go from here please?
Thanks

Andy

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Problem with cursor keys with VScode

Post by dhylands » Sat Apr 13, 2019 5:37 am

rshell --help shows the command line options.

You can use rshell -p COM3 (replace COM3 with the name of the serial port)

Documentation is available here: https://github.com/dhylands/rshell

andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Re: Problem with cursor keys with VScode

Post by andymouse » Sat Apr 13, 2019 9:53 pm

Hi all,
Firstly, I have my install to the Lolin/Wemos D1 Mini complete, thanks to all for your help and patience regarding my questions, Rshell is fine and I am working with Visual studio code.
My problems are down to coming from an Arduino environment and not knowing much about command line work, basically, the brass tacks off it all, but I am learning! slowly but surely.
I am now looking forward to getting going and having fun with Micropython. Without this forum it would have took a hell of a lot longer so thanks again!
Oh yeah, the command line I needed to find my board was :-
connect serial com3
which is one combination that I thought I had tried but clearly had not, I think case sensitivity got me! it was a valuable lesson.
I expect to be back when the "TinyPico" starts to ship :P

Andy

Post Reply