Skip to content

Instantly share code, notes, and snippets.

@albertfilice
Last active September 13, 2020 21:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save albertfilice/0f12dc87f8d1ec02ef14 to your computer and use it in GitHub Desktop.
Save albertfilice/0f12dc87f8d1ec02ef14 to your computer and use it in GitHub Desktop.
VT220 Setup
#####
IF YOU'RE COMING HERE BECAUSE OF PROBLEMS MAKE SURE YOU HAVE THE PROPPER ADAPTER
I tried several adapters and the one from Tripplite works the best. Some don't work at all, others create a lot of gibberish on the VT220.
Link: http://www.amazon.com/gp/product/B0000VYJRY/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1
#####
1. Installed drivers for USB -> Serial adapter
2. Run ls /dev/tty.*
I see my adapter as: '/dev/tty.usbserial'
3. Edit /etc/gettytab
Add the following lines at the end of gettytab:
std.ttyUSB:\
:np:im=\r\n:sp#19200:tt=vt220:
4. Create /Library/LaunchDaemons/serialconsole.plist with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>serialconsole</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/getty</string>
<string>std.ttyUSB</string>
<string>cu.usbserial</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
Communications Set-Up on the VT220 V2.3:
---------------------------------------
Transmit=19200
Recieve=Transmit
XOFF at 64
8 Bits, No Parity
1 Stop Bit
No Local Echo
EIA Port, Data Leads Only
Disconnect, 2 s Delay
Limited Transmit
I have the serial adapter -> a DB9 to DB25 Male Null Cable -> DB25/DB25 gender changer -> COMM port on the back of the VT220
Running `sudo launchctl load /Library/LaunchDaemons/serialconsole.plist` does nothing. VT220 cursor blinking in top left.
Rebooting the computer with the VT220 plugged in and nothing happens.
I tried this:
Open the console and type `screen /dev/tty.usbserial 19200' and I get a blank screen with solid non-blinking cursor at the top.
Nothing changes on the VT220.
I saw this post: http://jstn.cc/post/8692501831
He mentions:
'Eventually I found this page (http://www.club.cc.cmu.edu/~mdille3/doc/mac_osx_serial_console.html), which explains the problem and how to fix it. After adding a line in /etc/gettytab to manually set the terminal type to vt220 everything works perfectly!'
However I can't seem to find out what he's talking about on (http://www.club.cc.cmu.edu/~mdille3/doc/mac_osx_serial_console.html).
1. Get a USB to Serial adapter.
I tried several, the only one that worked was a Tripp Lite Keyspan
Link: http://www.amazon.com/gp/product/B0000VYJRY/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1
Drivers: http://www.tripplite.com/high-speed-usb-to-serial-adapter-keyspan~USA19HS/
2. Install drivers for USB to Serial adapter
3. Run the following command to see your device: `ls /dev/tty.*`
The result of the command is below:
/dev/tty.Bluetooth-Incoming-Port /dev/tty.KeySerial1
/dev/tty.Bluetooth-Modem /dev/tty.USA19H142P1.1
I'm going to guess that "/dev/tty.KeySerial1" is the correct device
4. You need to add to the file '/etc/gettytab'
You can edit it using the program vi:
`sudo vi /etc/gettytab`
Add the following two lines to the end of the file:
std.ttyUSB:\
:np:im=\r\n:sp#19200:tt=vt220:
5. Now you have to create the launch daemon that will give the login prompt to the terminal:
You can create the file using the program vi and name it whatever you want, I'm calling it "serialconsole.plist":
`sudo vi /Library/LaunchDaemons/serialconsole.plist`
Add the following 16 lines to "serialconsole.plist":
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>serialconsole</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/getty</string>
<string>std.ttyUSB</string>
<string>cu.KeySerial1</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
Replacing the line "<string>cu.KeySerial1</string>" specifically the "KeySerial1" part with the name of your device
6. Now you have to load up the daemon:
You can do that by restarting your computer or running the following:
`sudo launchctl load /Library/LaunchDaemons/serialconsole.plist`
If everything went smoothly your VT220 should present you with a login prompt
###########################
Some things to keep in mind
###########################
If cu.YourSerialDevice doesn't work then try tty.YourSerialDevice
@jstn
Copy link

jstn commented Jul 29, 2014

did you set up the daemon with launchctl?

@albertfilice
Copy link
Author

Yeah I did. Tried putting it in /Library/LaunchDaemons/ and nothing happened with a reboot.

Tried loading it manually with sudo launchctl load /Library/LaunchDaemons/serialconsole.plist and nothing happens.

@juhokuu
Copy link

juhokuu commented Jul 29, 2014

If you can't get anything across the serial line with screen /dev/tty.usbserial 19200 then it's likely the fault lies in either the USB dongle or the null modem cable. You need to sort that out first because if that doesn't work, then nothing will.

Try accessing the serial line with miniterm or CoolTerm to rule out any issues with screen itself and if it's still a no go, look into replacing the cable/dongle.

EDIT: When you're trying to access the serial line directly, make sure the daemon you set up isn't active. It might be blocking the dev file.

@albertfilice
Copy link
Author

I'm using a Dynex USB -> Serial adapter cable

I downloaded the drivers from Prolific

Here's the Null Modem cable I'm using with a DB25-DB25 gender changer:

I downloaded CoolTerm.
In the settings I set:
Port: usbserial
Baudrate: 19200
Data Bits: 8
Parity: None
Stop Bits: 1
Flow Control: [Nothing checked]
Initial Line States when Port opens:
DTS On [X]
RTS On [X]

When I click "Connect" it says "Connected" in the bottom left with an increasing time.
RTS and DTR lights are on.
When I type, nothing appears, but the TX light flashes at each keystroke.

With CoolTerm open and connected, I opened a Terminal window and tried to start a screen session (I think that's what I'm doing)
Macintosh-442:~ speedmark9$ screen /dev/cu.usbserial 19200
[screen is terminating]
Macintosh-442:~ speedmark9$ screen /dev/tty.usbserial 19200
[screen is terminating]

When I enter the command at the bottom of the screen it says:
Cannot open line '/dev/tty.usbserial' for R/W: Resource busy
or
Cannot open line '/dev/cu.usbserial' for R/W: Resource busy
then
Sorry, could not find a PTY.

I don't think I have any daemon loaded, I removed the .plist file from the /Library/LaunchDaemons/ folder and rebooted before trying this.

@juhokuu
Copy link

juhokuu commented Jul 30, 2014

What I meant was try communicating with the VT220 with either miniterm.py or CoolTerm, in case screen is at fault.

If that doesn't work then what I'd do is first check the null modem cable and be sure it is and does what it is suppose to. If the cable is working, then I'd replace the USB dongle with one that uses an FTDI chip, or one that is known to work for sure.

If you can't communicate with the VT220 using screen, miniterm, or CoolTerm then, barring any issues with the VT220 itself, the problem has to be with the USB dongle or the cable. Do you know what chip the USB dongle uses? What's the name of the tty device under /dev?

You can check for the daemon by grepping the output of ps aux for getty. Might be a good idea to launchctl unload the daemon and remove it from LauncDaemons until you're able to communicate with the VT220.

EDIT: Missed the Prolific bit. Have you tried the drivers from casbi.nl?

@albertfilice
Copy link
Author

Thanks for the response. I'll try using CoolTerm to try to communicate with the VT220, but I couldn't tell if it was working...

In CoolTerm:
When I click "Connect" it says "Connected" in the bottom left with an increasing time.
RTS and DTR lights are on.
When I type, nothing appears, but the TX light flashes at each keystroke. Nothing appears on the VT220.

I'm guessing that isn't the expected output.

The drivers from Casbi.ni say open source but I believe you have to pay for them? Their $10 but that might be worth it... I'll let you know...

@juhokuu
Copy link

juhokuu commented Jul 30, 2014

Yeah, everything you type should appear on the VT220's screen. The "Connected" status in CoolTerm probably just means it is able to access the serial line, it's not aware of anything that might be at the other end of that line.

Where did you get the DB25-DB25 gender changer? Are you sure it's not a crossover/null modem too, and turning your first null modem cable back to straight through?

@albertfilice
Copy link
Author

Here's a link to the gender changer I got which is labeled as a DB25F/F Adapter. It's got a sticker on it: "GENDER CHANGER U.S. PAT: 5190481"

I downloaded the drivers from Casbi.ni and installed them after removing the drivers I got from Prolific. Now my USB device shows up as:
/dev/tty.NoZAP-PL2303-00002006
and
/dev/cu.NoZAP-PL2303-00002006

CoolTerm still behaves the same way.

I tried reloading the .plist file after changing <string>cu.usbserial</string> to <string>cu.NoZAP-PL2303-00002006</string> but nothing happened. I checked the console and this was the most recent entry that looked relevant:
7/30/14 11:01:13.000 AM kernel[0]: me_nozap_driver_PL2303(0xffffff80266ea600)::dequeueDataGated - INTERRUPTED

@albertfilice
Copy link
Author

I also have a Linux machine, if you're familiar with that at all, I could possibly try to connect from there. However there aren't any drivers for the USB -> Serial adapter I have for Linux, thought I'm not positive they would be needed.

@juhokuu
Copy link

juhokuu commented Jul 31, 2014

Trying to load the .plist and getty before being able to type to the serial line and have it appear on the VT220's screen is futile and will only complicate things if it happens to block something when it would have had otherwise worked.

If you've got a Linux box at hand then absolutely, try it on that first. Use screen or miniterm.py. It's very likely the Linux kernel has support for the USB dongle you're using... as long as it's a stock kernel from any of the major distros. Check for an existing COMM port too if you haven't already.

If it doesn't work from the Linux box then you need to do a loopback test with the USB dongle by shorting the TX pin to the RX pin and running screen <dev file> <baud>. If the dongle works, everything you type should appear on the screen. You could do the same for the VT220 too but I'm assuming you're sure it's a working unit.

Then you also need to test the null modem cable. Easy enough if you have a multimeter on hand but might be easier to just get a new one if you don't. Check the correct pinout for a null modem cable and compare with yours. The same page has an easy to read pinout for female connectors.

@albertfilice
Copy link
Author

So really I should be able to talk to the terminal without a .plist file or getty or any of that? Meaning I should be able to connect to the terminal and output text to the terminal from the host machine.

I do have a multimeter on hand, so I'll check out the Null Modem Cable.

  • Got multimeter, put in sound wave mode, attach little copper wire to one probe to get it inside the female DB9 end
  • If I'm reading the chart right...
  • DB9 pin-2 -> DB25 pin-2
  • DB9 pin-3 -> DB25 pin-3
  • DB9 pin-4 -> DB25 pin-6 and pin-8
  • DB9 pin-6 and pin-1 -> DB25 pin-20
  • DB9 pin-7 -> DB25 pin-5
  • DB9 pin-8 -> DB25 pin-4
  • DB9 pin-5 -> DB25 pin-7
  • DB9 pin-9 -> DB25 pin-22
  • other pins should not be connected
    My testing leads me to believe the wiring goes like this for my cable:
  • DB9 pin-1 -> DB25 pin-6
  • DB9 pin-2 -> DB25 pin-3
  • DB9 pin-3 -> Nothing
  • DB9 pin-4 -> DB25 pin-20
  • DB9 pin-5 -> Nothing
  • DB9 pin-6 -> DB25 pin-6
  • DB9 pin-7 -> DB25 pin-4
  • DB9 pin-8 -> Nothing
  • DB9 pin-9 -> DB25 pin-22

I tried a few times, and occasionally the pins were even different than above, almost like a pin I put in one hole can touch connectors of the holes next to it. I'm going to go try to return the cable and get a new Null Modem Cable and see if that fixes anything.

I got a new Null Modem Cable

  • I attached the VT220 with the new cable, opened up CoolTerm and set the settings, clicked "Connect"
  • Typing into the Mac now appears on the VT220!
  • Make sure to check your cables potential readers!

I'm going to try to get it up and running with getty now.

I GOT IT
Spawned a login prompt. I think there's something the matter with the character encoding?
Here's an image of the screen: https://www.dropbox.com/s/ue3botskoqnqgaf/2014-07-31%2014.34.08.jpg

@juhokuu
Copy link

juhokuu commented Jul 31, 2014

Glad to hear it :) Let me know if you need help with any of the launchctl stuff.

EDIT: This happens with mine too sometimes, not as bad as yours though, and only with OSX machines, never with other unices. Start by turning off smooth scrolling from the VT220 settings and playing with the shell's locale settings. I'm off to bed now but I'll check my setup tomorrow and post here.

@albertfilice
Copy link
Author

You were a major help, thank you so much! If you're ever in San Francisco I'll buy you a beer.

Interesting that you have the same problem, when dealing with OS X. I think I saw a post about something similar where they managed to get around it by telling the connection to use ASCII encoding or something.

The gibberish makes things pretty unusable from an OS X standpoint. I haven't played around too much with a Linux system hooked up yet though. Do you use the terminal with Linux mainly?

I'll tinker around and edit this post to update.

@juhokuu
Copy link

juhokuu commented Aug 2, 2014

Went through my setup but there's nothing really worth mentioning. Setting locale to en_US.US-ASCII didn't seem to make much of a difference either. All my *nix servers have integrated serial ports and they work flawlessly so I'd like to pin it on the USB dongle. I got another unit some time after I posted the video and it behaves the same with OS X – as does a VT320 I tried.

It only seems to happen when there's a lot of output so maybe it's something to do with flow control. Second thought I had is that perhaps the old dumb terminals are more strict with what the correct voltage levels are and the USB dongles, while compliant with the RS232 standard, just don't hit those levels. Haven't looked into it any deeper than that though.

I could still see it being useful on OS X for logging to console or being part of a notification system of some sort where the output is a few lines per sec at most. The units I have don't see a lot of use, not even with the *nix servers. I'm on a move a lot though so not really practical for me but I'd definitely set something up if I had a desktop setup that I used a lot. And even with OS X I think it's just looks too cool not to have it set up.

@albertfilice
Copy link
Author

Humm ok cool thanks for the tips, I'll probably end up getting the same USB -> Serial adapter that JSTN used in his post, since that seemed to work for him. Which adapter did you use when you tried it with your Mac?

Even commands with minimal output seem to produce gibberish like pwd

The TOP command doesn't give me gibberish...
I just logged in again, to try to fiddle with things. I got the gibberish I usually do but decided to see what it would look like running top and surprisingly there doesn't seem to be any gibberish there.

I also tried man top and was able to move through the man pages without any gibberish...

I also tried playing around with the Ruby Gem "t" which can stream a twitter feed on the command line. When initially running the command there's a bunch of gibberish but once the stream moves on a bit everything smooths out.
Maybe the gibberish has something to do with the beginning and end of commands somehow?

@colegleason
Copy link

Hey, @albertfilice, I'm trying to get the same setup working and I could use some help. I have a Macbook Pro (2015) running macOS Catalina. I have connected the VT220 (with keyboard) to the Mac using the Tripp Lite Keyspan adapter you linked. The adapter is plugged into a DB9 to DB25 adapter (https://www.amazon.com/gp/product/B00066HJCA/ref=ppx_yo_dt_b_asin_title_o06_s00?ie=UTF8&psc=1) and into the COM port.

I can see the tty.KeySerial1, but I can't connect to it in CoolTerm or with screen. In CoolTerm I get a 100 error with "Access Denied" and in screen I get a window with a solid, un-blinking white cursor in the top left (I don't know the meaning).

I'm using the Keyspan drivers from Tripp-Lite. Any suggestions on how I could move forward and get connected?

@albertfilice
Copy link
Author

@colegleason Sorry I can't be of more help, but after reading your post and looking back I can't remember having that issue. Did you check your DB9 to DB25 adapter?

I don't have my terminal out anymore, I used to have it set up at work but was laid off from that job, and now it's in the closet of my small apartment.

I'm not sure how changes in macOS since I got mine working might impact things. Not sure what access denied means either. You could try to find somebody has one running on Catalina, but that probably isn't easy.

If I ever get mine out and working again I'll be sure to post the info.

@colegleason
Copy link

colegleason commented Sep 13, 2020 via email

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