Terminal S - a super simple serial terminal

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Yhui
Posts: 4
Joined: Tue May 19, 2020 5:01 am

Terminal S - a super simple serial terminal

Post by Yhui » Tue May 19, 2020 6:02 am

When playing with MicroPython on Windows, using PuTTY to open the serial REPL needs to open "Device Manager" to get the serial port number (I always forget a device's port name as I have several devices).
So I wrote a new serial terminal - Terminal S https://github.com/makerdiary/terminal-s. It has about 100 lines of Python code.

Install & Run

Code: Select all

pip install terminal-s
terminal-s
On Windows, we can also type Win + r and enter "terminal-s" to launch it

Image

scruss
Posts: 2
Joined: Sat Aug 12, 2017 2:27 pm

Re: Terminal S - a super simple serial terminal

Post by scruss » Tue May 19, 2020 2:52 pm

Nice!

I tend to just use

Code: Select all

python3 -m serial.tools.miniterm
when I know I'm on a system that doesn't have minicom, c-kermit or screen on it.

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

Re: Terminal S - a super simple serial terminal

Post by dhylands » Tue May 19, 2020 3:28 pm

I also have a tool which will search for USB ports by name, serial number etc. https://github.com/dhylands/dotfiles/bl ... nd_port.py

It works on Windows/Mac/Linux. You can use it in a script to say open the port with Micropython by doing something like:

Code: Select all

$ find_port.py -n MicroPython
/dev/ttyACM0

Yhui
Posts: 4
Joined: Tue May 19, 2020 5:01 am

Re: Terminal S - a super simple serial terminal

Post by Yhui » Wed May 20, 2020 12:00 am

scruss wrote:
Tue May 19, 2020 2:52 pm
Nice!

I tend to just use

Code: Select all

python3 -m serial.tools.miniterm
when I know I'm on a system that doesn't have minicom, c-kermit or screen on it.
I also use the miniterm, but it can not handle arrow keys and terminal color, which is one of the reason to write a new one.

User avatar
pythoncoder
Posts: 4147
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Terminal S - a super simple serial terminal

Post by pythoncoder » Wed May 20, 2020 8:55 am

Yhui wrote:
Wed May 20, 2020 12:00 am
...I also use the miniterm, but it can not handle arrow keys and terminal color, which is one of the reason to write a new one.
It supports both here under Linux. I invoke it with:

Code: Select all

miniterm.py /dev/pyboard 115200 --raw
(There is a udev rule that creates the /dev/pyboard device.)

I suspect there is something wrong with your configuration, but I have no recent experience of Windows.

To test colours I ran this (taken from one of my test programs):

Code: Select all

def print_tests():
    st = '''Available functions:
test(0)  Print this list.
test(1)  Test message acknowledge.
test(2)  Test Messge and Lock objects.
test(3)  Test the Barrier class.
test(4)  Test Semaphore
test(5)  Test BoundedSemaphore.
test(6)  Test the Condition class.
test(7)  Test the Queue class.
'''
    print('\x1b[32m')
    print(st)
    print('\x1b[39m')

print_tests()
Peter Hinch

Yhui
Posts: 4
Joined: Tue May 19, 2020 5:01 am

Re: Terminal S - a super simple serial terminal

Post by Yhui » Thu May 21, 2020 1:56 am

On windows, miniterm.py raw mode doesn't support arrow keys. For example, left arrow key will be convert to

Code: Select all

[b'\x00',  b'K']
or

Code: Select all

[b'\xe0', b'K']
, but it need to be convert to

Code: Select all

[b'\x1b', b'[', b'D']

User avatar
pythoncoder
Posts: 4147
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Terminal S - a super simple serial terminal

Post by pythoncoder » Thu May 21, 2020 6:04 am

If this is a bug in miniterm it should be reported. But I'd first investigate if this is a Windows configuration issue. I'd be astonished if such a crippling failure didn't have a fix: a terminal that doesn't support arrow keys is essentially useless.
Peter Hinch

Yhui
Posts: 4
Joined: Tue May 19, 2020 5:01 am

Re: Terminal S - a super simple serial terminal

Post by Yhui » Thu May 21, 2020 10:10 am

I don't think it's a bug of miniterm.py. miniterm.py raw mode just sends what it gets. Different cli environments have different escape sequences. Not every terminal supports VT100. It's just like that backspace don't work properlyon linux if you use miniterm.py without --raw. I didn't know the parameter --raw before you mentioned it.

Code: Select all

--raw                 Do no apply any encodings/transformations
Maybe add a new parameter similar with the parameter --raw.

User avatar
tve
Posts: 184
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: Terminal S - a super simple serial terminal

Post by tve » Thu May 21, 2020 8:13 pm

miniterm.py raw mode doesn't support arrow keys
have you tried

Code: Select all

--filter direct
instead of raw

Post Reply