ANSI Terminal support?

46 views
Skip to first unread message

Collin Kidder

unread,
Mar 11, 2015, 3:55:39 PM3/11/15
to developers
It seems to have been suggested by some people in the past, and
recently to me, that maybe it would be cool if the built-in Arduino
terminal could interpret ANSI console commands. This way it becomes
far easier to implement nice textual interfaces in the terminal. As it
stands now it can be hard to use debugging output because it all
scrolls by so quickly. If instead values could just update their
positions on a terminal screen then debugging with the IDE would
become far easier. I'm not really asking someone else to do it. I can
probably figure out how to extend the terminal code to make this
happen. But, is it something that could feasibly make it into mainline
Arduino or would I be wasting my time? Has anyone ever tried to do
something like this? It seems like it could be a nice thing to have. I
know that there exist a wide range of other terminals that can already
do this. It's just handy if the built-in terminal can do it so that
more people end up with the ability to use the terminal as a debugging
console.

Adrian Godwin

unread,
Mar 11, 2015, 6:18:22 PM3/11/15
to devel...@arduino.cc
Although ANSI processing is moderately useful, it needs fairly good support.  A restricted implementation would just be annoying unless very well documented.

The feature I would like  more than anything would be automatic switching between download and terminal  mode. If the terminal is open when a download is started, I would like it to restore the session when completed - ideally before reset is released.
 


--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

Andrew Kroll

unread,
Mar 11, 2015, 6:19:59 PM3/11/15
to devel...@arduino.cc
I would be happy with just a working backspace '\b'. A working bell '\a\ would be a bonus.
Neither currently works.

--
Visit my github for awesome Arduino code @ https://github.com/xxxajk

Peter Olson

unread,
Mar 11, 2015, 8:51:46 PM3/11/15
to developers
> On March 11, 2015 at 6:18 PM Adrian Godwin <artg...@gmail.com> wrote:
>

> The feature I would like more than anything would be automatic switching
> between download and terminal mode. If the terminal is open when a
> download is started, I would like it to restore the session when completed
> - ideally before reset is released.

I saw some comments about this recently, so I think it is in the works.

What I would like to see is a preference option to use an external terminal
program in lieu of the internal one, much as we have for editing.

That would solve the ANSI issue, and would also work for me (I like to write
custom Python code on the host to communicate with the Arduino).

Peter Olson

Andrew Kroll

unread,
Mar 11, 2015, 8:53:10 PM3/11/15
to devel...@arduino.cc
screen /dev/ttyACM0 115200


--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
361.gif

Loren M. Lang

unread,
Mar 11, 2015, 9:18:37 PM3/11/15
to devel...@arduino.cc
I am generally against reinventing the wheel and it can take a lot of time to properly implement a full ANSI terminal. It sounds like the original poster was interested in support for commands that are used for explicitly positioning the cursor on the screen. However, I expect that will be tricky for most users to benefit from as it requires certain knowledge such as the terminal window’s size that is not easily available to a sketch and often uses relative command for modifying the screen knowing what was previously there. I do believe, however, that there is some benefit to supporting some of the basic ASCII control characters such as carriage return, newline, backspace, and bell. I can’t remember if carriage return is supported, but it is a handy way for redrawing the last line without shifting the whole screen. If this is combined with a library that supports basic formatting of numbers (fixed-width spacing), it can potentially be less visually disturbing.

One other comment, while directly supporting an external terminal is a nice idea, it would require a way to cleanly close it when it’s time to re-program the Arduino to provide any real convenience. Unfortunately, there’s not an easy and cross-platform solution to that currently. My solution to that has been running the Arduino build externally from a custom Makefile which finished by calling avrdude to program and screen to bring up the terminal. I can get a solid ANSI terminal which starts automatically, but I still have to close it manually.


On Mar 11, 2015, at 5:53 PM, Andrew Kroll <xxx...@gmail.com> wrote:

screen /dev/ttyACM0 115200
<361.gif>

Peter Olson

unread,
Mar 11, 2015, 11:26:39 PM3/11/15
to developers
> On March 11, 2015 at 9:18 PM "Loren M. Lang" <pengu...@gmail.com> wrote:

> One other comment, while directly supporting an external terminal is a nice
> idea, it would require a way to cleanly close it when it’s time to re-program
> the Arduino to provide any real convenience. Unfortunately, there’s not an
> easy and cross-platform solution to that currently.

I had supposed that spawning the external terminal program would result in a pid
(modulo operating system) that could be killed before starting the program. Can
you explain the complication?

Peter Olson

William Westfield

unread,
Mar 12, 2015, 2:52:06 AM3/12/15
to devel...@arduino.cc
>
> it would be cool if the built-in Arduino terminal could interpret ANSI console commands.

I looked at doing this once. The current “Terminal” is a modern Java-esque “text pane” with attributes like “font” and “scrollbar” and such, completely lacking in old fashioned ideas like “row” and “column.”
As such, adding old-style console commands is next to impossible - I’m pretty sure you’d be better off starting from scratch rather than attempting such an “addition.”

(and at that point, you might as well implement an interface to an external Monitor application instead; it would probably make more people happy.)

BillW/WestfW

Collin Kidder

unread,
Mar 12, 2015, 9:03:20 AM3/12/15
to developers
It seems like this is the consensus: it would be better to not
reinvent the wheel and instead create a method for Arduino to call an
external terminal program and use that program for the terminal
instead of the built-in version. That sounds reasonable. I still kind
of like the idea of using old school ANSI to create easier to read
debugging screens but many terminal programs already support ANSI and
all it would require on the sketch side is a library to encapsulate
the ANSI calls into something easier to work with. Such libraries
already exist. So, this all seems the path of least resistance since
the built-in Java console isn't likely to do what I'd want any way you
cut it.

Jim Leonard

unread,
Mar 12, 2015, 11:13:33 AM3/12/15
to devel...@arduino.cc
On Thu, Mar 12, 2015 at 09:03:11AM -0400, Collin Kidder wrote:
> It seems like this is the consensus: it would be better to not
> reinvent the wheel and instead create a method for Arduino to call an
> external terminal program and use that program for the terminal
> instead of the built-in version. That sounds reasonable. I still kind
> of like the idea of using old school ANSI to create easier to read
> debugging screens but many terminal programs already support ANSI and
> all it would require on the sketch side is a library to encapsulate
> the ANSI calls into something easier to work with. Such libraries
> already exist. So, this all seems the path of least resistance since
> the built-in Java console isn't likely to do what I'd want any way you
> cut it.


I'm curious, is there a reasonable way to (cross-platform) forward the serial port data to another pseudo-device so that the terminal program doesn't need to be killed when you want to upload a new program to the arduino?

--jim

Andrew Kroll

unread,
Mar 12, 2015, 4:30:51 PM3/12/15
to devel...@arduino.cc
There is a way. You would just simply send a message to the other thread to stop using it, do the upload, then send another signal to reopen. You can't have a device open twice without bad things happening, plus some arduino models when reset need to be re-enumerated by the host OS.


--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

Britton Kerin

unread,
Mar 13, 2015, 3:55:13 PM3/13/15
to devel...@arduino.cc
In case it should be useful to anyone, I use make like this:

SCREEN_SESSION_NAME = cduino_run_screen_mk

run_screen:
(sleep 0.5 && screen -S $(SCREEN_SESSION_NAME) -X stuff ^M &) ; \
screen -S $(SCREEN_SESSION_NAME) $(ACTUAL_ARDUINO_PORT)

writeflash: $(HEXTRG)
# First kill any screen session started from run_screen.mk.
screen -S $(SCREEN_SESSION_NAME) -X kill || true
# all the other upload commands)

Note that that's a literal Cntrl-M (you can compose it in vi by typing C-v C-m).

writeflash gets rid of the screen session automagically.
Then I just hit up-arrow return or so in the screen window to restart
screen after a flash. This works great until you have two arduinos
under devel. at once then writeflash doesn't know which session to
kill or something.

Britton

James Cloos

unread,
Mar 16, 2015, 11:42:29 AM3/16/15
to devel...@arduino.cc
Supporting enough escape sequences shouldn't take much code.

There is a tiny X11 terminal program at http://git.suckless.org/st under
the MIT/X11 license which could form the basis of one. And the terminal
code in the Linux and BSD kernels have reasonably small footprints.

Based on this thread it should be a replacement for the existing
terminal, but it should be reasonably doable.

-JimC
--
James Cloos <cl...@jhcloos.com> OpenPGP: 0x997A9F17ED7DAEA6

Jack Rickard

unread,
Mar 17, 2015, 4:43:52 AM3/17/15
to devel...@arduino.cc
So why not bail on the current Java based console and do a new ANSI terminal as the standard item? 

Jack

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.



--
--------------------------------
---------------------------------

Andrew Kroll

unread,
Mar 17, 2015, 4:48:02 AM3/17/15
to devel...@arduino.cc
Stuff like this begins with YOU.
If you want it bad enough, why not start writing it?

361.gif

Trannie Carter

unread,
Mar 23, 2015, 6:35:29 PM3/23/15
to devel...@arduino.cc
On Wed, Mar 11, 2015 at 03:55:32PM -0400, Collin Kidder wrote:
> It seems to have been suggested by some people in the past, and
> recently to me, that maybe it would be cool if the built-in Arduino
> terminal could interpret ANSI console commands. This way it becomes
[...]
> Arduino or would I be wasting my time? Has anyone ever tried to do
> something like this? It seems like it could be a nice thing to have. I

Back when I was starting my BasicTerm library for controlling ANSI
terminals (http://github.com/nottwo/BasicTerm), I looked into what it
would take to extend the Arduino SerialMonitor to support ANSI control
sequences.

It turns out there are a few FOSS pure-java libraries that implement an
ANSI/VT100 terminal and I had some success in integrating them into the
SerialMonitor.

This was back in the 1.0.2 days. I've been able to bring one
implementation up-to-date for the ide-1.0.x branch, but ran into some
merge conflicts trying to integrate with ide-1.5.x.

Evaluating the two implementations today, the JTA branch is the more
robust. The JCTerm branch tends to hang the Arduino SerialMonitor & IDE
when changing serial port parameters.

I've only tried the code on Linux.

Anyway, take a look.

https://github.com/nottwo/Arduino/tree/jta-1.0.x
https://github.com/nottwo/Arduino/tree/jcterm-1.0.2


trannie
Reply all
Reply to author
Forward
0 new messages