Connecting to the PC

The VT has three serial ports. The first one is accessible via two plugs, both a male and a female D-Sub with 25 pins. They are wired together and cannot be used independently. The second and third port has a RJ12 (or RJ11?) with its nose shifted to the side - a DEC specific modification. I ordered the RJ jacks from amazon, but until they are there, im going with the D-Sub accessible port.

For serial communication, there are two endpoint types:

  • DTE - Terminal equipment, this is a Terminal or a Modem
  • DCE - Computer equipment, the PC

The DTE usually has a female connector, while the DCE has a male connector. So if your machine has a D-Sub 25 for use as serial port, connecting the VT520 is just a matter of an extension cord (opposite genders at each end).

For some reason, its 2019 now, and most devices only offer an 9-pin D-Sub port for serial communication, if at all. I own a 25-pin to 9-pin adapter, so its fine for me. Caveat: Its for the DCE side, to make an 25-pin DCE port available as 9-pin DCE.

This is where the second connector for serial port 1 of the VT520 comes into play. Its wired to make the VT520 connectable like an DCE, even if its technically not one. So if i use my adapter on the VT520, i end up with a 9-pin DCE connector on both the terminal and the computer side. They are connected then like two normal DCEs via nullmodem cable.

When using the serial port on the mainboard, the device node in linux is usually ttyS0. When using a USB-to-serial converter (like FTDI or CH340), the device is named ttyUSB0 or likewise.

I’ll go with ttyS0 in this post.

Configuring the VT520

You can get into the internal menu py pressing the SysRq-Sequence, which is usually Alt+PrintScr. From there you can configure the baud rate and data format settings.

As customary in my household, everything is 9600 baud with no parity and a single stopbit.

Setting up getty

I used an busybox system, so the getty configuration is done in /etc/inittab.

ttyS0::respawn:/sbin/getty -h ttyS0 9600 vt520

The important things that need to be specified here:

  • -h: Enable hardware flow control
  • ttyS0: name of the terminal device
  • 9600: baud rate
  • vt520: content of the $TERM variable

Other init systems are not covered here.

Restart to launch the getty.

Linux boot console

Add console=ttyS0 to the kernel command line. This is specific to your bootloader.

Syslinux bootloader output

Syslinux supports interfacing via serial to allow interaction with the boot menu.

Add the following to you syslinux config:

SERIAL 0 9600

0 is the same number as in ttyS0. 9600 is the baud rate.

Note: Other serial devices are not supported at this stage.

Unicode

Its likely necessary to disable unicode support via stty -utf8, since the terminal applications and VT520 will likely disagree about the length of non-ASCII character sequences, which will lead to confusion while editing your input lines.

Also i recommend to replace the UTF-8 string in your $LANG variables with US-ASCII. This is not a problem for me since my system doesn’t support locales anyways.

Shell colors

The VT520 takes ANSI color sequences like any other terminal. If you followed the ANSI specs when adding colors to your prompt, you will have no problems here.

That the VT520 accepts those sequences does not mean you get colors - the CRT is only monochrome and will instead print greyscale.

Applications using ncurses

If you configured $TERM correctly, applications will have no trouble interfacing with the VT520.

If you have trouble with an application, wrap your terminal session into tmux. Inside tmux, you have the screen terminal type per default and tmux will strip unicode if the attached client doesn’t support it.

Window title

Since its an actual terminal, we don’t have an window title we could display data on. The VT520 has a status bar which can be used instead. In fact, the ncurses database already attempted to make use of it, but with different semantics between the xterm and vt520 sequences. For xterm, the behavior is to replace the window title with the newly given string. For the VT520, the status bar is like an regular terminal area that the write cursor can be switched into. When writing to the status bar, its previous contents are not removed, like in the regular terminal character area. The ncurses database as of 2019 does not work around this.

I downloaded the ncurses database (also named terminfo), and edited it to make the VT520 status line behave like a window title.

In the dec+sl section in the terminfo.src, the tsl must be as follows:

tsl=\E[2$~\E[1$}\E[G\E[K

This removes an superfluous backtick and ands a sequence to

  • always start at the beginning of the status line
  • and clear all data after our text was written

Use tic to compile the database, you now have a fixed terminfo db binary in your ~/.terminfo directory.

Conclusion

While there are still some troubles around multi-line editing in mksh, the VT520 is good enough to write this blog post.

Some tmux keys are broken, when using then tmux clipboard, i cant input Alt+w directly. Instead i have to go via pressing ESC and w in sequence.

Also, the terminfo db has some other bugs when used with the VT520. Maybe i’ll hunt them down later.