Terminal emulators

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

Reply to
rickman
Loading thread data ...

Actually, a VT52 just sends ESC P. ESC O P is what the VT100 sends.

These are the sequences sent by the VT220 function keys. Try poking about at

formatting link
specifically
formatting link

--
roger ivie
rivie@ridgenet.net
Reply to
Roger Ivie

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?

Reply to
linnix

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

Reply to
rickman

rm/table3-4.html

Thanks for the info. I have found some useful stuff there.

Rick

Reply to
rickman

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 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:

Reply to
linnix

rickman escreveu: [snipped]

Incurring into the risk of being classified in this group...

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).

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.

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/
Reply to
Cesar Rabak

Yes, there is a problem with compatibility to the different terminals, especially the ones which are trying to do the auto detect.

I use the primitive terminal I/O for debug and test purpose quite often, and I avoid using anything except the ASCII characters. "Press 1 to do this, press 2 to do that... etc. If the advanced user interface is required, then the best way is developing a binary protocol and the host GUI application of your own. If this GUI has to be platform independent, it can be done in Java.

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

So, your answer is to build the USB serial port into the target hardware? I loled.

--
roger ivie
rivie@ridgenet.net
Reply to
Roger Ivie

It's a frequently-used approach.

Reply to
larwe

If

The question was directed to you. What is your solution?

Rick

Reply to
rickman

=A0If

Sorry, I got you mixed up with Cesar. I'm waiting to hear what he suggests as a solution for a good interface.

Rick

Reply to
rickman

Cesar Rabak schrieb:

This may be true for IBM-compatibles (PCs) but many other devices with some "intelligence" use UARTs. The reason is simple: It's cheap, easy to use and everybody knows how it works.

Falk P.S.: I was surprised, that a UMTS-Cardbus-Card contained a USB-Hub with two serial converters. The internal modems answered "OK" to "AT" ;-)

--
http://cc.aljazeera.net/
http://ie.youtube.com/user/idfnadesk
Reply to
Falk Willberg

Well, yes - kinda. HID, modem and mass-storage are fairly unambiguous. Not every application fits into the mold of a supported class though.

Reply to
larwe

But if you're uneasy enough with the future availability of USB serial ports to hassle me about saying "you can always buy one", how is building one of them into the device a solution?

--
roger ivie
rivie@ridgenet.net
Reply to
Roger Ivie

For a HID device you can transfer anything you want, see e.g. this article:

formatting link

In short: You can transfer 64 bytes each millisecond, for which you can define your own format.

If you are going to build your own mouse or special input device, of course you can create your own HID descriptors. The HID specification shows the details:

formatting link

They defined a very complicated, universal concept how to encode many physical properties, and how they are connected to the human body, in a generic way, but you don't need it, if your application knows your device.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

That's interesting, thanks. Saved for later study.

64 bytes per millisecond is pretty fast actually, compared to traditional RS232 say. If the latency on the link is 1 millisecond, that is also much better than you get with a typical USB-RS232 converter.

Is it actually possible for ones program to access such a device without installing any drivers? The ideal would be a single win32 executable that could run on any (USB capable) windows system without modification.

--

John Devereux
Reply to
John Devereux

Yes, this is possible. I've written such a program for a commercial project some time ago, which works without problems from Windows 98 SE to Vista (unlike some serial port programs with virtual COM port drivers) and will publish a modified and more general version on my web page, when I have some time. Should be no problem with Linux and MacOS, too.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

I've downloaded the sample program from the EDN article and looks like a good starting point. They've used multithreading and overlapped IO, which is important, if you don't want to hang your program, if the user removes the USB device while you are waiting in a ReadFile. This is the way I've used for my commercial project, too.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

Whatever. Imagine my dismay.

Reply to
Nobby Anderson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.