REMOTE CONNECTIVITY FOR PORTABLE TERMINALS: PART II

Developing the VT100 terminal emulation application

Dan Troy

Dan is software manager at Murata Hand-Held Terminals and is currently developing more operating system firmware and application software for the Links product line. He can be reached at Murata HHT, 9 Columbia Dr., Amherst, NH 03031.


Last month I described the development of the software that processed the standard VT100 commands and screen data, resulting in the 24 x 80-character VT100 image. The resulting image was virtual, because the Links terminal can physically display a maximum of only 12 x 20 fixed-width characters. This logically leads to the question: How can we present the 24 x 80-character VT100 image on a hand-held terminal in an easily usable and readable way? Furthermore, what other screens are needed to allow a user to connect to the host and configure the terminal? With these questions in mind, this month I'll discuss the development of an application that emulates a VT100 terminal using just about every feature of the Links touch-sensitive display, including graphics.

Screen Logic and Hierarchy

To display a series of screens using the special Links functions, we implemented the pseudocode shown in Example 1. As you can see, the display and processing of the Setup/Connect screen is repeated whenever the user returns from either of the two possible choices, setup or connect.

Example 1: Pseudocode that describes how screens are displayed

  void setup_connect_screen (void)
  {
       while(TRUE)
       {
           Clear screen
           Display LINKS100 connect screen title and revision
           Display and activate SETUP and CONNECT keys
           Wait until a key is pressed and get it
           IF key is SETUP then perform LINKS100 setup
           ELSE attempt to connect to host (CONNECT key)
       }
  }

The logic for all screens on the Links terminal except for the while(TRUE) is similar. The programmer must clear the previous screen and paint the current screen. The terminal does not remember previous screens; to redisplay them, they must be repainted.

The first phase in developing the Links100 application was to layout the screen hierarchy depicted in Figure 1. Setup/Connect is the initial screen on power-up. From this screen, the user can either attempt to connect to the host or select the setup option. If Setup Keyboard is selected, the user is presented with key click on/off and key repeat on/off. If Setup Ports is selected, the user can choose to setup either the Links modem or the RS-232 port. Setting up the RS-232 port allows you to setup parity, the number of stop bits, and the baud rate. Setting up the modem allows you to setup only parity and stop bits, because the internal modem is fixed at 1200 baud.

We found that most systems require some sort of character or series of characters upon physical connection. If the host doesn't get what it expects, it won't respond. To accommodate this, we modified the Links100 setup to allow the user to enter a connect string that would be sent upon an attempt to connect to the host. Many systems require only a single carriage return character (ASCII 13), although others may require more than one character.

Because the Links terminal has two ports, modem and RS-232, we decided to implement two paths within the software to establish each of these linkages. If users wish to connect to the host through the modem, they can select the active port option (modem or RS-232). When the modem is selected, a dial screen appears in the Links100 application. This allows users to input or edit the phone number, along with adding Hayes compatible commands (pause, wait for dial tone, pulse/tone selection, and flash hook) to it. Upon modem connection, the connect string is sent to the host, but because the host may not be ready to accept it immediately, connect string transmission repeats for several seconds, until connection is made. Direct connection to a host via the RS-232 port is the same as through a modem, except that dialing and modem connection are not required. The connect string is sent in the same manner, and if a connection isn't made, a message screen notifies the user that the Links100 was unable to connect to the host. The user can then return to the primary screen and try to reconnect.

If a connection is made, then the next screen displayed would be the Section Information screen that presents to the user the data currently being received from the host. The user can then proceed to the Greeking/View Port Access screen, the various emulated VT100 keyboards, or back to the Connect/Setup screen.

It's Greek to Me (the Greeking Screen)

Our engineering team came up with the idea of "Greeking" in order to allow the user to immediately see the general character layout of the screen. Greeking is used in many word processing and desktop publishing packages to represent text that cannot be displayed legibly due to insufficient screen pixel resolution. By representing characters as pixels, we were able to present an approximate picture of the text on a full 24 x 80 screen; see Figure 2(a). Because the Links terminal consists of 96 rows of pixels, we can represent each of the 24 VT100 character rows as a single row of pixels, each separated by a blank line of pixels. This would utilize a total of 49 pixel rows (a blank line above the first row and one below the last one), leaving room for control keys at the bottom of the Links touchscreen, a title at the top, and a miniaturized terminal around the Greeked text.

The representation of the columns was more difficult. Even though the Links terminal has 120 columns of pixels, there was insufficient room to allow a one-to-one correspondence between the 80 VT100 virtual-image characters and the column of pixels on the Links. Space was needed on the Links screen to accommodate the miniaturized terminal, as well as future control keys. We determined that we had three pixels available for every four characters in the VT100 image. To compress four characters into three pixels, a simple algorithm was developed. For every four characters, the first two where translated directly -- each was represented by a pixel. The next two characters were evaluated as follows: If either was non-blank, the result would be a pixel that was turned on; otherwise, it was turned off. This simple method was found to be very practical because the representation was not only sufficiently accurate, but also fast to process, albeit the large number of characters. (It was coded in assembly language because C would be too sluggish.) The assembly routine processes each of the global VT100 images' 24 x 80 characters and sets the appropriate pixels in other global variables. These other global variables can then be accessed by the Links100 application to display the Greeked text. The miniaturized terminal was displayed using the graphics functions of the Links Speed C package, which allows for customized pixel settings.

We then added iconified control keys on the bottom row of touch key areas. Figure 2(b) shows the stop, reverse image, view mode, and cursor section keys. The stop key gave us the ability to terminate the current session, logging off if attached to a modem. The reverse image key allows the Links100 to toggle between white-on-black and black-on-white. (This was a relatively simple addition because the Links operating system has a global "reverse video" flag.) The view mode key toggles between two ways of presenting the segmented VT100 image (described in the next section), and the cursor section key shows in which section the cursor is currently located. Each section represents an 8-row by 20-column section of the VT100 image, for a total of 12 sections. The small black square within the cursor section key indicates which of the 12 sections the cursor is currently situated in. We found this to be very informative to the user, because the cursor could not be practically presented on the Greeked screen.

View Modes

Our primary customer requirement was to present the VT100 virtual image in discrete sections, which we call "field" mode. In field mode, horizontal and vertical scrolling enables traversal among the 12 sections. In the other operating mode, "wrap" mode, an entire 80-column VT100 line is displayed in a discrete section without the need for horizontal scrolling by wrapping each Links line down onto the next Links line. The field and wrap modes are shown in Figure 3 and Figure 4, respectively.

As mentioned earlier, each field mode section is 8 rows by 20 columns. This allows space for control and VT100 keyboard-access touch keys, while at the same time maximizing screen usage. But how do we access a specific section?

The easiest way that we could find was to make the VT100 miniaturized icon touch sensitive in 12 discrete locations. Each specific touch sensitive area, or viewport, is defined (using Links C language extensions to the operating system) as a unique key, and corresponds to a unique section. When the desired section on the VT100 icon is touched, the Links100 application detects a key-press, and processes the appropriate section key. The special functions used are char key_pressed(void), returning a boolean, and char get_key(void), returning the ASCII key value assigned to the key. We sized the VT100 icon to contain the 12 keys necessary to simply "point and shoot" for quick and easy section access. This works out perfectly with condensing four characters into three for the Greeking, because an 80-character row can be represented by 60 pixels. Each touch sensitive key area is 15 pixels wide, so four keys across give us exactly 60 pixels! A section information screen display similar to that in Figure 3 appears once a particular touch sensitive area is selected. (We have applied for a patent for this "zooming in" technique.) A Section Information Display screen contains the keys for scrolling left, right, up, and down (represented by an appropriate arrow) and selecting an alphabetic, numeric, auxiliary, or control keyboard. The section icon, Figure 2(b), displays the currently selected section for the user's easy reference.

To provide text continuity when scrolling the currently displayed screen, we decided that each scroll key actuation would scroll only half a section. To redisplay the VT100 icon, it seemed logical to use the current screen section icon as a touch sensitive key. When pressed, the Links100 application detects this key and redisplays the VT100 icon screen. Each unique screen corresponds to a C language function. This allows the Links100 application code to redisplay any screen by simply returning from one screen function, or calling another screen function from the current one.

Wrap Text Mode

Wrap text mode is particularly useful in applications such as electronic mail, as it does not require right and left scrolling. Instead of dividing the VT100 image into 12 sections as we did in field mode, we divided it into five primary sections, each representing five rows. Each section is further divided into two subsections, giving a total of ten. Each of the primary sections is accessed by its appropriate section icon (see Figure 4), and each subsection can contain up to 200 characters (10 rows by 20 characters). By selecting the appropriate section icon, the user can read the first half of the corresponding text; remaining text in the primary section is accessed by scrolling down.

The view mode icon allows the selection of wrap mode. When wrap mode is selected, the VT100 icon becomes touch insensitive. The wrap mode icons will disappear once the view mode is toggled back to field mode. Pressing the cursor section icon will cause the section containing the cursor to appear. This is frequently where the end of the incoming text is located.

Because many lines of text in wrap mode may have trailing spaces, we introduced space compression. Any such line of text taken from the VT100 image will have the spaces removed, so that the text on screen is substantially more readable. Many times, a selected section will contain all the text for both of its subsections, reducing the need for scrolling.

VT100 Keyboard Emulation

The emulated VT100 terminal keyboard consists of separate alphabetic, numeric, control, and auxiliary keyboards which are individually displayed on the screen. To process entered keystrokes from the keyboards, we used the special key_pressed and get_key Links operating system functions. As data is entered from the alphabetic and numeric keyboards, the characters are displayed in the space available above the keyboards on the Links screen, and is not immediately sent to the host. This allows message editing using the backspace/delete key. When the Enter key is pressed, the entered data is sent to the host through the modem or RS-232 port, whichever has been selected in the VT100 setup portion of the Links100. It is also possible to move from alphabetic to numeric before sending the message to the host. The control and auxiliary keyboards send each keystroke immediately.

Dynamicicity

Dynamicicity is the degree to which a particular process is regularly updated, and we decided to implement a way to "dynamically" update the VT100 Greeking screen icon, the current cursor section icon, and the Information section display screens. We discovered, however, that if they were updated continuously as data came in, it was often impossible to understand any of the information because it was changing so rapidly. The screen was never static, unless characters stopped coming into the Links from the host. Therefore, we decreased the degree of dynamicicity to allow for short term display stability. The icon and text section screens are now updated approximately every two seconds, allowing the user to watch the VT100 and cursor section location icons and wait until they become stable. At that point there is a high probability that the host is waiting for a response from the Links100.


Copyright © 1991, Dr. Dobb's Journal