Brother EP44 as Linux serial terminal

Once upon a time, computers were enormous things that you used via a terminal on which the output device was a printer — a remote typer, a teletype. A TTY. This is long gone apart from computing museums. But it is interesting — if not useful — to discover that a battery-powered typewriter from the mid-80s can be used, today, in 2021, as a paper-based terminal for modern Linux. In fact, you really ought to look at this or this or this for something much more exotic. (For example, it can be a useful terminal for a headless single board computer.)

The EP44 is an electronic typewriter that uses a thermal print head to print on thermal paper or to transfer thermal-transfer ink to regular paper, if you put a ribbon cassette in it. (These cassettes are now rare and expensive, so thermal paper — usually as fax rolls — is the best solution.)

Most interestingly, the typewriter also includes a 3500-character memory, a 16-character LCD display, and a DB-25 RS232 port, capable of communication at 75, 110, 300, 600 and 1200 baud. Here’s another related link. Not sure about this one.

The main purpose of the RS232 connection is to use the machine as a printer. This is relatively straightforward, especially if you have a hardware serial port (DE-9, usually), but it will also work with a USB-to-serial adapter. The printer part of the EP44 was modified a bit and made available as the Brother HR-5 thermal printer.

Because the EP44 runs off batteries and can store some text, you can type on it when you’re out and about, and download that text into a computer when you get to the office or home. There are various ways to do this, but a very simple one involves the UNIX cat command, and the SEND button on the EP44.

Because MSDOS and FreeDOS (but not the WIndows CMD.EXE) have the CTTY command (change TTY), and are both single-user, single-tasking operating systems, it is trivially easy to pass control of the DOS computer to the EP44. This does need a hardware serial port, because DOS cannot drive the USB-to-serial adapters. Doing this allows you to send the text to the computer, and also allow it so work as a serial terminal for DOS.

So, last thing — how about a serial login on Linux?

Turns out it is remarkably easy.

Step one is to enable login from a serial TTY by editing /etc/inittab. Let’s say we are going to use the EP44 at 300 baud on /dev/ttyS0; then we  add this line, or uncomment an example line and modify:

T0:23:respawn:/sbin/getty -L ttyS0 300 vt100

This just tells it to create login T0. It has run levels 2 and 3 (no GUI, of course) and uses ttyS0 at 300 baud with vt100 emulation.

Most of these settings can be played with. For example, if using a USB-to-serial adapter, it might create a serial port of the form /dev/ttySX, but it is more likely to give you /dev/ttyUSB0. getty is just the program that does it (the are others — getty on Linux is really agetty, usually, but you can find others including mgetty). -L says this is a local line. Anyway, I created this entry and I rebooted, with the EP44 attached via a null modem serial cable and set to Terminal and 300 baud.

And this is what we see on the little LCD screen on the EP44:

devuan login prompt on the 16-character display

We’re in! The text flowing back and forth as you talk to the computer scrolls across the little screen, for what that is worth … but it is also captured on the printer. Long lines do get truncated… but still, it works. Here is a little session (scanned and thresholded to make it blacker):

Small Linux session. run df, see who's logged in, exit.So as we use the Linux box, the thermal paper rolls through. If I don’t want to capture the session, I just flip the paper release, so it does not wind through the typewriter. This was done on a desktop box as a test, but you could also connect to a SOC board, like a RPi or something, and do actual system admin using the EP44.

300 bored

The Brother EP44 as a serial terminal for DOS

This is so nerdy.

I made up a printer cable for my EP-44 – it is the ‘Common serial printer cable’ taken from this page. I don’t normally take images from the web, but since pages do sometimes vanish, this is the wiring diagram I followed:

DB-9 (actually DE-9) to DB-25 serial printer cable wiring diagram

And it works very well as a serial printer cable from Linux (using a hardware DE-9 port). In fact, it works very well from DOS. I installed FreeDOS on a partition on an old Compaq Armada E500; it has a hardware serial port (DE-9) so is very nice for monkeying around.

Plugged the EP-44 into the computer and turned both on. Hint: this won’t work if this step is omitted!

Photo
The EP-44 connected to the Armada by a home-made cable

Set the EP44 to 1200 baud, N parity, 8-bit data and used the DOS MODE command to set the port to the same.

C:\> mode com1:1200,n,8,1,b

And I could print by copying stuff to COM1. Can also try:

C:\> mode lpt1:=com1:

This assigns COM1 as the printer port. The problem is that the EP44 has a very small buffer (160 bytes, IIRC), so as once before, it is a good idea to send the file a line at a time, using a little script. Slowing the baud rate right down (the computer can go as low as 110) helps, but even 110 baud is still a lot faster than the typewriter can print.

Now, I recently found out that using a full null-modem cable (uses more than the 4 wires in the diagram above) as a printer cable works really well with Linux — it allows for XON/XOFF flow control and line-by-line printing is not needed. DOS is not able to make use of the same cable, for some reason (or at least I could not do it), but works well with the simpler cable. So the EP44 (with and without hyphen) acts as a battery-powered 24-pin (NLQ) thermal printer that can be transported around with your laptop. How very 1990s!

But it gets funkier. If you like that sort of thing.

DOS has a little-used command called ctty, ‘change tty’. It can be used to make DOS look somewhere other than the console (ie keyboard and screen) for input and output. I found that it works with the EP-44, though the baud rate has to be set right down or the EP44 keystrokes don’t get captured (most worked, but the Enter key was flaky at higher baud. Who knows?).

On the DOS PC typed:

C:\> mode com1:110,n,8,1,b
C:\> ctty com1

with the EP-44 set at 110 baud, 8-bit data, no parity.
This gave me this on the EP44 screen (and on the fax roll I was printing onto):

photo
DOS prompt on the EP-44 screen

I could then type commands on the EP44 and get the output on the printer (it also appeared, uselessly, on the 16-character screen), with the console (screen) on the computer looking frozen and the computer keyboard not taking input. Here is a scan of a brief DOS session, as it happened on the EP-44.

scan of printout
DOS session on paper

At the end, as you can see, I typed

C:\> ctty con

and control went back to the computer and its keyboard. As you can see, during the session I can get listings, create and view files, and move around the directory structure. I’m sure I could do lots more. Anything that uses graphics, or addresses the video RAM directly, or even addresses the screen out of order, won’t work. I read somewhere that a DOS Elvis version worked on a DOS serial terminal; how it would work with a paper roll, I don’t know. I guess you’d have to use EDLIN or something! When I tried to use FreeDOS’s edit to look at a file, the screen on the computer lit up. The EP-44 printed the console output that firing up the editor gives (see below), but the editor screen itself appeared on the computer screen and could be used on the computer via the computer keyboard. When I exited edit (using the computer keyboard), control passed back to the EP44.

It would be possible to use a normal DOS session to put the commands that initiate the serial session into autoexec.bat, such that the machine would boot into that state. Then you’d have headless DOS. Kind of.

scan of output
Running edit

I found that many but not all of the special characters (accents, pound sign, that sort of thing) that the EP44 could generate could be written to a file and would then show up when viewing the file on the computer.

scan of printout
Non-keyboard characters that worked

It depends on where they sit in the ASCII table, I guess.

You can backspace over a mistyped command or file name (like the word ‘symbol’ above), and fix it before sending it to the computer, but of course the typewriter has already printed your mistake, giving overwritten results.

The typewriter lets you choose between CR and CR+LF for line endings, so if you get too many empty lines, try adjusting that setting. DOS uses CR+LF, so if the typewriter is just expecting CR it will not eat the LF and you get double-spaced output.

photo
The scanned output as it came out of the typewriter

Of course, this is just a toy. I tried playing with agetty under Linux, but I could not get the same results, not with the simple cable nor the full null-modem cable. Probably some serial port settings are not right, but I ran out of enthusiasm when trying to sort it out.

Anyway, useless but nifty.