Saturday, March 9, 2019

Retro Computing: TRS-80 Model 100 as a Serial Terminal

Retro Computing
TRS-80 Model 102 as a Serial Terminal


The TRS-80 Model 102 was one of the computers I really wanted but couldn't afford (original price $1134 for the 32K model). Not a just married community college student anyway. I saw it when a kid I knew from high school showed up in the college computer lab with one. The sysadmin let him connect it to the PDP 11 computer "just for fun".

It wasn't the first "laptop" computer, but it was one of the better ones. The 80c85 CPU only needed 5 volts, which allowed it to last about 20 hours on four AA batteries. How many portable computers could do that in the 80's? You can learn more about it on https://en.wikipedia.org/wiki/TRS-80_Model_100.

I finally picked one up on eBay. Not a bad purchase for supposedly obsolete electronics. Not only did it have a full 32 kilobytes of memory, the prior owner had added an Interactive Solutions ROM with four applications (original price $149.95) and a PG Design CMOS Expansion RAM module (original price $499). 

The applications stored on ROM allowed more complex applications that wouldn't normally fit in the available RAM. The expansion module let you switch between multiple groups of applications and data stored in additional RAM chips.


26-3844/RS Model 102 - Software - Interactive SolutionsThe Interactive Solutions ROM module provides the user with three integrated programs: Data Manager, Data Calc, and Word Processor. Information stored in Data Manager can be utilized by the spreadsheet and word processor. Data Manager forms can have up to 20 fields per record. You may perform addition or subtraction on numeric fields and sort information in ascending or descending order. Data Calc, the spreadsheet, offers standard math functions plus averages, square roots, sines, cosines, and the constant pi. The work-sheet can be a maximum of 99 rows long and 99 columns wide. The word processor uses the functions of TEXT and adds more printing parameters such as Page length; Page width; Top, Bottom, Right, Left margins; Justification; Line Spacing; and Headers and Footers can be specified before printing. The date and page number can be automatically printed. Uses optional ROM socket so that it does not occupy RAM.
PG Designs 224K RAM Expansion Module for Model 100User-installable upgrade is like having 8 Model 100s at your command! Comes with transfer program on cassette. Includes battery for battery backup. 

A M100 Serial Terminal

So, how do you setup a serial to usb null modem connection between a TRS-80 Model 102 and a Raspberry PI desktop Debian computer?


There are some websites that were very helpful in figuring this out. 



The screen for the M100 is only 40 characters wide and 8 lines high. For Debian to send text to the M100 correctly, it needs to know what its capable of displaying. For example, colors are unavailable on the M100. In *nix system, terminfo handles this with a termcap file. Fortunately, the open source community likes to keep everything. We can still get a termcap file for obsolete terminals. 

Eric S. Raymond, long-time hacker and participant in the open source movement, is the maintainer of the BSD terminal-type database. If you search out his website www.catb.org, you will find various files including the "Unidentified Feeping Objects" file which contains mysterious, obsolescent, and junk termcap entries. For some reason I haven't figured out yet, the files I downloaded from the site are not recognized as gzip'd files. Fortunately, I found a couple of references to the M100 termcap around the Internet.


Here's how I setup my Raspbian laptop. 

Create a termcap file named trs100.ti containing the following text. The "trs100" in the first line before the first vertical line is what we need to reference the termcap settings.

trs100|Radio Shack Model 100:\
        :am:bs:xt:\
        :co#40:li#8:\
        :al=\EL:bl=^G:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :\
        :cr=^M:dl=\EM:do=^J:ho=\EH:kb=^H:kd=^_:kl=^]:kr=^\:\
        :ku=^^:le=^H:nd=\034:se=\Eq:sf=^J:so=\Ep:up=\EA:\
        :ve=\EP:vi=\EQ:

As root, use tic to convert and install the termcap file for use by terminfo.

sudo tic trs100.ti

Change to the /lib/systemd/system directory and copy the serial-getty@.service template to a new file using the name of the port you are using. In my case the USB port is ttyUSB0. I confirmed this by plugging in my serial-to-usb cable and running:

sudo dmesg | grep tty

My cable uses the pl2303 chipset. The output was pretty obvious.

[    0.000000] console [tty0] enabled
[   10.884475] systemd[1]: Created slice system-serial\x2dgetty.slice.
[   14.509182] usb 3-1: pl2303 converter now attached to ttyUSB0

cd /lib/systemd/system
cp serial-getty@.service serial-getty@ttyUSB0.service

Next, edit the file. We're going to make a few changes. We need to enable 1200 baud and user our new trs100 termcap settings.Use whatever text editor you want. I prefer vi.

sudo vi serial-getty@ttyUSB0.service

Change the following line:

ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM

to read:

ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600,1200 %I trs100

I added 1200 baud to the list of possible baud rates and set terminfo to the trs100 termcap.

Here's the full file:


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

[Service]
ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600,1200 %I trs100
Type=idle
Restart=always
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

[Install]
WantedBy=getty.target

Then create a symbolic link so systemd can pick up the modified configuration.

sudo ln -s /etc/systemd/system/serial-getty@ttyUSB0.service /etc/systemd/system/getty.target.wants/

Start and enable the service so that it will be available after reboot. I had to also reload the daemon. I think this was due to prior attempts to setup the service. If you're doing this the right way from the start, you may not need to do so or maybe you do. 

systemctl daemon-reload
systemctl start serial-getty@ttyUSB0.service
systemctl enable serial-getty@ttyUSB0.service

Connecting the M100

Connect the DB25 end of your null modem cable to your M100 serial port, the DB9 end to your usb-to-serial adapter cable, then plug the into your laptop's USB port.

On your M100, start the TELCOM program. 
Press F3, enter 58N1E, and press ENTER. This sets the communication parameters to 1200 baud, 8 bit, no parity, 1 stop bit, and XON/XOFF enabled.

The possible settings for the M100 are: 
The first character is the baud rate
    1 = 75
    2 = 110
    3 = 300
    4 = 600
    5 = 1200
    6 = 2400
    7 = 4800
    8 = 9600
    9 = 19200
Second is the size of the data sent over the connection, 7 or 8 bit
Third is parity bit used for error checking
    E = even
    O = odd
    N = none
    I = ignore
Forth is the number of stop bits, 1 or 2
And fifth is to enable or disable XON/XOFF, E = enabled or D = disabled.

Press F4 and press ENTER. This starts terminal communication. You may need to press the ENTER key a few times, but eventually you will be prompted to enter your user name and password.
If the bottom line over F4 says "Half". You want to change it to full duplex. Otherwise, every character you type will be echoed back to the screen, doubling the characters displayed. For example, if your user name is "pi", you'll end up with "ppii" displayed on the screen. Press F4 so that it says "Full".  

Honestly, there's not much to do with such a limited terminal. I just enjoy the challenge of making it work. 

Happy retro computing!