EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Terminal emulators

Started by rickman January 17, 2009
I have been working on a program which will use a terminal emulator as
the user interface.  One thing I am finding is that there seem to be
different command formats in the different emulators.  I tried using
the telnet program that came with Windows.  Then I tried Putty.  The
characters sent from keypresses seem to be different for the various
function keys.  For example, under telnet, the DEL key is the single
code 127 while the Putty program sends a sequence of ESC [ 3 ~   The
function keys F1 to F4 are sent as similar sequences in Putty when in
"ESC[n~" mode and sends VT52 sequences (e.g. ESC O P) in VT100 mode.
The telnet program only seems to send the VT52 sequences.  Neither
program sends the VT100/52 sequence for the cursor control keys
(arrows).

I can't find documentation on the ESC[n~ sequences anywhere.  It seems
that there is overlap in that a command can be ESC[n~ or ESC[nm~.  So
the ~ serves as a command terminator which makes the command a bit
harder to parse.

I can make the program work with any of these formats, but I would
like to understand where they come from and to make sure that I am
using them correctly by finding the appropriate documentation.  Are
the "ANSI" keyboard sequences documented anywhere?  I can find docs on
the commands *sent* to ANSI terminals, but I only find info on VT52,
VT100 etc keyboards.  Even if I try to use the VT100 formats, they are
not uniformly supported.

Rick
On 2009-01-17, rickman <gnuarm@gmail.com> wrote:
> The > function keys F1 to F4 are sent as similar sequences in Putty when in > "ESC[n~" mode and sends VT52 sequences (e.g. ESC O P) in VT100 mode.
Actually, a VT52 just sends ESC P. ESC O P is what the VT100 sends.
> I can't find documentation on the ESC[n~ sequences anywhere.
These are the sequences sent by the VT220 function keys. Try poking about at http://www.vt100.net/ specifically http://www.vt100.net/docs/vt220-rm/table3-4.html -- roger ivie rivie@ridgenet.net
On Jan 16, 11:22 pm, rickman <gnu...@gmail.com> wrote:
> I have been working on a program which will use a terminal emulator as > the user interface. One thing I am finding is that there seem to be > different command formats in the different emulators. I tried using > the telnet program that came with Windows. Then I tried Putty. The > characters sent from keypresses seem to be different for the various > function keys. For example, under telnet, the DEL key is the single > code 127 while the Putty program sends a sequence of ESC [ 3 ~ The > function keys F1 to F4 are sent as similar sequences in Putty when in > "ESC[n~" mode and sends VT52 sequences (e.g. ESC O P) in VT100 mode. > The telnet program only seems to send the VT52 sequences. Neither > program sends the VT100/52 sequence for the cursor control keys > (arrows). > > I can't find documentation on the ESC[n~ sequences anywhere. It seems > that there is overlap in that a command can be ESC[n~ or ESC[nm~. So > the ~ serves as a command terminator which makes the command a bit > harder to parse. > > I can make the program work with any of these formats, but I would > like to understand where they come from and to make sure that I am > using them correctly by finding the appropriate documentation. Are > the "ANSI" keyboard sequences documented anywhere? I can find docs on > the commands *sent* to ANSI terminals, but I only find info on VT52, > VT100 etc keyboards. Even if I try to use the VT100 formats, they are > not uniformly supported. > > Rick
A long long time ago, I wrote a terminal emulator based on modified termcap. Termcap is a terminal driving library on every Unix/BSD/ Linux system. Almost all existing terminals are described there. So, terminal emulator based on modified termcap is possible. I thought this whole business of termcap died with window. What are you using it for?
On Jan 17, 1:20 pm, linnix <m...@linnix.info-for.us> wrote:
> On Jan 16, 11:22 pm, rickman <gnu...@gmail.com> wrote: > > > > > I have been working on a program which will use a terminal emulator as > > the user interface. One thing I am finding is that there seem to be > > different command formats in the different emulators. I tried using > > the telnet program that came with Windows. Then I tried Putty. The > > characters sent from keypresses seem to be different for the various > > function keys. For example, under telnet, the DEL key is the single > > code 127 while the Putty program sends a sequence of ESC [ 3 ~ The > > function keys F1 to F4 are sent as similar sequences in Putty when in > > "ESC[n~" mode and sends VT52 sequences (e.g. ESC O P) in VT100 mode. > > The telnet program only seems to send the VT52 sequences. Neither > > program sends the VT100/52 sequence for the cursor control keys > > (arrows). > > > I can't find documentation on the ESC[n~ sequences anywhere. It seems > > that there is overlap in that a command can be ESC[n~ or ESC[nm~. So > > the ~ serves as a command terminator which makes the command a bit > > harder to parse. > > > I can make the program work with any of these formats, but I would > > like to understand where they come from and to make sure that I am > > using them correctly by finding the appropriate documentation. Are > > the "ANSI" keyboard sequences documented anywhere? I can find docs on > > the commands *sent* to ANSI terminals, but I only find info on VT52, > > VT100 etc keyboards. Even if I try to use the VT100 formats, they are > > not uniformly supported. > > > Rick > > A long long time ago, I wrote a terminal emulator based on modified > termcap. Termcap is a terminal driving library on every Unix/BSD/ > Linux system. Almost all existing terminals are described there. So, > terminal emulator based on modified termcap is possible. I thought > this whole business of termcap died with window. What are you using > it for?
Thanks for the reply, but I'm almost afraid to answer your question. It seems like any time I ask for help with something and describe fully what I am doing, I get all sorts of criticism saying that I am doing the wrong thing. I posted about this here a few days ago and got a lot of that. Still, you asked, so you must be interested. I am writing a program to control a test fixture. The basics are to provide a display and control of a set of registers on the board under test as well as a few features in the test fixture. I chose to use a terminal emulator because it gives me a very simple interface to program to... or so it seems to me. I think it also makes the program more portable to a range of target systems including the possibility of putting the program on the text fixture itself and still using the serial port to control it. I am using a telnet program because that seemed like the easiest way to link the Forth program to a terminal emulation. Originally I expected to be able to find an ANSI terminal emulator in Forth, but what I found was some code to talk to sockets which links me to a telnet program. The one I have tried that I like best so far is Putty. Of the three I have tried, no two handle the keyboard quite the same way. I find that very odd. So that is why I am looking for documentation to see if I can figure out why they are different and how best to code that part. Rick
On Jan 17, 3:54=A0am, Roger Ivie <ri...@ridgenet.net> wrote:
> On 2009-01-17, rickman <gnu...@gmail.com> wrote: > > > The > > function keys F1 to F4 are sent as similar sequences in Putty when in > > "ESC[n~" mode and sends VT52 sequences (e.g. ESC O P) in VT100 mode. > > Actually, a VT52 just sends ESC P. ESC O P is what the VT100 sends. > > > I can't find documentation on the ESC[n~ sequences anywhere. =A0 > > These are the sequences sent by the VT220 function keys. Try poking > about athttp://www.vt100.net/specificallyhttp://www.vt100.net/docs/vt220-=
rm/table3-4.html Thanks for the info. I have found some useful stuff there. Rick
On Jan 17, 11:48 am, rickman <gnu...@gmail.com> wrote:
> On Jan 17, 1:20 pm, linnix <m...@linnix.info-for.us> wrote: > > > > > On Jan 16, 11:22 pm, rickman <gnu...@gmail.com> wrote: > > > > I have been working on a program which will use a terminal emulator as > > > the user interface. One thing I am finding is that there seem to be > > > different command formats in the different emulators. I tried using > > > the telnet program that came with Windows. Then I tried Putty. The > > > characters sent from keypresses seem to be different for the various > > > function keys. For example, under telnet, the DEL key is the single > > > code 127 while the Putty program sends a sequence of ESC [ 3 ~ The > > > function keys F1 to F4 are sent as similar sequences in Putty when in > > > "ESC[n~" mode and sends VT52 sequences (e.g. ESC O P) in VT100 mode. > > > The telnet program only seems to send the VT52 sequences. Neither > > > program sends the VT100/52 sequence for the cursor control keys > > > (arrows). > > > > I can't find documentation on the ESC[n~ sequences anywhere. It seems > > > that there is overlap in that a command can be ESC[n~ or ESC[nm~. So > > > the ~ serves as a command terminator which makes the command a bit > > > harder to parse. > > > > I can make the program work with any of these formats, but I would > > > like to understand where they come from and to make sure that I am > > > using them correctly by finding the appropriate documentation. Are > > > the "ANSI" keyboard sequences documented anywhere? I can find docs on > > > the commands *sent* to ANSI terminals, but I only find info on VT52, > > > VT100 etc keyboards. Even if I try to use the VT100 formats, they are > > > not uniformly supported. > > > > Rick > > > A long long time ago, I wrote a terminal emulator based on modified > > termcap. Termcap is a terminal driving library on every Unix/BSD/ > > Linux system. Almost all existing terminals are described there. So, > > terminal emulator based on modified termcap is possible. I thought > > this whole business of termcap died with window. What are you using > > it for? > > Thanks for the reply, but I'm almost afraid to answer your question. > It seems like any time I ask for help with something and describe > fully what I am doing, I get all sorts of criticism saying that I am > doing the wrong thing. I posted about this here a few days ago and > got a lot of that. Still, you asked, so you must be interested. > > I am writing a program to control a test fixture. The basics are to > provide a display and control of a set of registers on the board under > test as well as a few features in the test fixture. I chose to use a > terminal emulator because it gives me a very simple interface to > program to... or so it seems to me. I think it also makes the program > more portable to a range of target systems including the possibility > of putting the program on the text fixture itself and still using the > serial port to control it. > > I am using a telnet program because that seemed like the easiest way > to link the Forth program to a terminal emulation. Originally I > expected to be able to find an ANSI terminal emulator in Forth, but > what I found was some code to talk to sockets which links me to a > telnet program. The one I have tried that I like best so far is > Putty. Of the three I have tried, no two handle the keyboard quite > the same way. I find that very odd. So that is why I am looking for > documentation to see if I can figure out why they are different and > how best to code that part. > > Rick
Again, everything you need is in the termcap file. Putty uses xterm. See below. # X11R6 xterm. This is known good for the XFree86 version under Linux. # It is *way* more featureful than the stock X consortium entry. # The kmous key is actually the \E[M prefix returned by xterm's internal # mouse-tracking facility. ncurses will interpret the following three bytes # of mouse status information. # From: Eric S. Raymond <esr@snark.thyrsus.com> 9 Nov 1995 # (untranslatable capabilities removed to fit entry within 1023 bytes) # (sgr removed to fit entry within 1023 bytes) # (terminfo-only capabilities suppressed to fit entry within 1023 bytes) xterm|vs100|xterm terminal emulator (X11R6 Window System):\ :am:km:mi:ms:xn:xo:\ :co#80:it#8:li#65:\ :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\ :LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:\ :bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:\ :cr=^M:cs=\E[%i%d;%dr:ct=\E[3k:dc=\E[P:dl=\E[M:do=^J:\ :ei=\E[4l:ho=\E[H:ic=\E[@:im=\E[4h:\ :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\ :k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:\ :k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:kI=\E[2~:\ :kN=\E[6~:kP=\E[5~:kb=^H:kd=\EOB:ke=\E[?1l\E>:\ :kh=\E[@:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:\ :md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:\ :se=\E[m:sf=^J:so=\E[7m:sr=\EM:ta=^I:\ :te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:ue=\E[m:up=\E[A:\ :us=\E[4m:
rickman escreveu:
[snipped]

> Thanks for the reply, but I'm almost afraid to answer your question. > It seems like any time I ask for help with something and describe > fully what I am doing, I get all sorts of criticism saying that I am > doing the wrong thing. I posted about this here a few days ago and > got a lot of that. Still, you asked, so you must be interested.
Incurring into the risk of being classified in this group...
> > I am writing a program to control a test fixture. The basics are to > provide a display and control of a set of registers on the board under > test as well as a few features in the test fixture. I chose to use a > terminal emulator because it gives me a very simple interface to > program to... or so it seems to me. I think it also makes the program > more portable to a range of target systems including the possibility > of putting the program on the text fixture itself and still using the > serial port to control it. >
Using the serial port was OK some years ago, but presently you may get your fingers burned as some newer machines do not come with this port anymore. Also the 'simple interface' is in the beholder's eye (in this case the programmer), ans as you're discovering a so low level interface requires some massaging which is not portable (or better spelled not standard as one would like).
> I am using a telnet program because that seemed like the easiest way > to link the Forth program to a terminal emulation. Originally I > expected to be able to find an ANSI terminal emulator in Forth, but > what I found was some code to talk to sockets which links me to a > telnet program. The one I have tried that I like best so far is > Putty.
You could create a simple protocol to control your device (even via serial port) and on the host side use some scripting language (like Tcl/Tk, but feel free to use whatever you feel comfortable instead of Tcl [it seems you could even use Forth, although I've no experience with that]) or perhaps with a little effort (needed to learn the Windows GUI part) Win32Forth.
> Of the three I have tried, no two handle the keyboard quite > the same way. I find that very odd. So that is why I am looking for > documentation to see if I can figure out why they are different and > how best to code that part. >
In the long run the system you're developing will be easier to use and less prone to errors than letting the final user type commands in a telnet session. HTH -- Cesar Rabak GNU/Linux User 52247. Get counted: http://counter.li.org/
On 2009-01-17, Cesar Rabak <csrabak@bol.com.br> wrote:
> Using the serial port was OK some years ago, but presently you may get > your fingers burned as some newer machines do not come with this port > anymore.
You can always buy a USB serial port. -- roger ivie rivie@ridgenet.net
Roger Ivie escreveu:
> On 2009-01-17, Cesar Rabak <csrabak@bol.com.br> wrote: >> Using the serial port was OK some years ago, but presently you may get >> your fingers burned as some newer machines do not come with this port >> anymore. > > You can always buy a USB serial port.
Always is a strong word. I agree buying a USB serial port could be atractive to keep legacy apps/boards/devices available, but IMHO not a great idea for new developments. -- Cesar Rabak GNU/Linux User 52247. Get counted: http://counter.li.org/
Cesar Rabak wrote:
> Roger Ivie escreveu: > > On 2009-01-17, Cesar Rabak <csrabak@bol.com.br> wrote: > >> Using the serial port was OK some years ago, but presently you may get > >> your fingers burned as some newer machines do not come with this port > >> anymore. > > > > You can always buy a USB serial port. > > Always is a strong word. I agree buying a USB serial port could be > atractive to keep legacy apps/boards/devices available, but IMHO not a > great idea for new developments.
Can I ask what you would suggest? How would you interface to the test fixture? Rick

Memfault Beyond the Launch