Skip to content

Instantly share code, notes, and snippets.

@n055
Last active September 21, 2021 02:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n055/208f3c05344e49c1f3cca24cf43b14b5 to your computer and use it in GitHub Desktop.
Save n055/208f3c05344e49c1f3cca24cf43b14b5 to your computer and use it in GitHub Desktop.
Connecting a VT420 to a Linux PC

Connecting a VT420 to a Linux PC

Hardware

The DEC VT420 terminal only has 6P6C MMJ connectors. We need a converter to make this work with a standard serial to USB adapter. The originals are hard to find or expensive, but we can assemble one new.

  • D9 Female to DEC MMJ. You need to wire up the DE-9/DB9 plug's wires to the adapter's MMJ jack yourself. They actually sent me a DE-9 male adapter by mistake, so I ended up just using an easily obtainable DE-9 gender changer once I'd wired up the adapter.

  • MMJ Null Modem Cable. You could also use a cable that isn't a null modem cable, and use a null modem adapter/cable on the DE-9 side. Or, you could wire up the D9 to MMJ adapter to be null modem.

  • If you're using a male DE-9 connector on your adapter, you need one of these to stick the pins into the connector. I think you also use the same tool on a female DE-9 connector, but I've never actually done it so IDK.

  • One of those USB to RS-232 cables. Both the Prolific and FTDI ones seemed to work fine with my system.

  • Soldering iron, wire strippers

DE-9 pinout diagrams are pretty easy to find if for some reason your plug doesn't say the numbers on it. Here's how that connector's pins map to the MMJ. NOTE: This is what I figured out and scribbled down on a sticky note. I'm pretty sure I typed it up correctly, but look up other sources online to sanity check my wiring before doing it yourself. I'm not responsible if you short circuit your vintage terminal or something.


 1 2 3 4 5 6            MMJ                 DE-9
+-----------+
|           |           6  +--------+-----> 6
|   Female  |                       |
|           |           2  +-----+  +-----> 8
+-------+   |                    |
        +---+           3  +--+  ---------> 3
                              |
                        4  +--+-----------> 5

                        5  +--------------> 2

                        1  +--------------> 7

                        

As you see, you'll need to splice some of the cables together. For my male DE-9 plug, each cable from the female MMJ had a pin on the end. Using some wire strippers and a soldering iron, get everything wired up like in the diagram and insert each pin into the correct spot. Three holes will be left empty in the DE-9 connector.

When everything is soldered and pins injected, triple check your wiring make sure bare wire is covered with heat shrink or electrical tape, plug it all together, and hope no smoke comes out.

The DE-9 connector snaps into the plastic housing once you're done, making it a self-contained, sturdy adapter.

Software

These are my config files for making the terminal play nice with Ubuntu. I have a Tilda terminal accessible by hotkey that is really just a screen session that the VT420 is also attached to. I tried tmux but it didn't play nice with an actual terminal. I also have it set to a fairly low baud rate because higher ones seemed to lead to corrupted output on the terminal screen.

karl@knx:~$ cat /etc/systemd/system/getty.target.wants/serial-getty@ttyUSB0.service 
#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Serial Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
BindsTo=dev-%i.device
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service

[Service]
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
#ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM
#ExecStart=-/sbin/agetty -a sshuser -p ttyUSB0 19200 vt420
ExecStart=-/sbin/agetty -a vt420 -h -L 9600  %I vt100
Type=idle
Restart=always
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

[Install]
WantedBy=getty.target

karl@knx:~$ grep vt420 /etc/passwd
vt420:x:1001:1001::/home/vt420:/usr/local/bin/vt420sh

karl@knx:~$ cat /usr/local/bin/vt420sh 
#!/usr/bin/env bash
sudo -H -u karl /usr/local/bin/vt420-connect-screen

karl@knx:~$ sudo cat /etc/sudoers | grep vt420
# Added by Karl: Allow vt420 to run vt420-connect-screen
vt420 ALL=(ALL) NOPASSWD: /usr/local/bin/vt420-connect-screen

karl@knx:~$ cat /usr/local/bin/vt420-connect-screen 
#!/usr/bin/env bash
cd
while true
do
	# dispose of existing screens
	rm -f /run/screen/S-$USER/*.vt420
	sleep 1
	screen -S vt420 -dm
	screen -x vt420 -X stuff "vlock\n"
	screen -x vt420
	sleep 1
done


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment