Article: Wiring a vintage teletype to the Internet using Linux
Aug 20, 2003 — by LinuxDevices Staff — from the LinuxDevices Archive — 15 viewsThere are a number of electronic projects I have been wanting to build which require an embedded computer system. Among of these are:
- Networked audio player for our home entertainment center
- Networked electronic picture frame
- Video and audio home security system
- A web/email gateway for an antique Model 28 Teletype machine.
A common requirement for all of these projects is to make a system which I can treat like an appliance, sometimes leaving the device turned on for extended periods, sometimes powering up and down suddenly. These systems would be in our house, sitting on a shelf or on a table. For this reason, I required a system with low power consumption, low noise, and small size.
Up until now, to get the capabilities I wanted meant either having to use a full-blown desktop system, with its size, expense, noise, and power consumption (or find a scavenged laptop), or look for a custom embedded single-board computer, which for these hobby projects generally might be too expensive, not powerful enough, lack some of the desired I/O, and have an unfamiliar development environment.
Enter the EPIA Mini-ITX motherboard from VIA Technologies. The Mini-ITX motherboard is completely compatible with the industry standard IBM PC, and contains all the common I/O (and then some) of a desktop PC, including audio (analog and digital), ethernet, video, USB, IEEE-1394, RS232 serial, and EPP/ECP parallel. And it has a very small form-factor, only 17cm x 17cm (6.5 x 6.5 in).
The Mini-ITX also includes a set of goodies targeted specfically for building appliances and embedded applications. Depending on the model, the motherboard sports a composite and s-video output for playback on a television, stereo digital audio, and interfaces for IR remote controls. The high-end M model even has MPEG-2 video decoding hardware for movie playback.
In this article I am going to describe how I built the the teletype server, because it illustrates a good example of the basics needed for an embedded internet-enabled application. It is also an interesting example because while the only I/O I only needed for this project were Ethernet and RS232 serial-port, the Mini-ITX board was still the system of choice over other single board computers.
Web-Enabled Teletype Server
I acquired a vintage Model 28 Teletype, still in the original packing crate, from eBay. The Model 28 is an entirely electromechanical keyboard and printer unit, with an enormous number of mechanical parts. It uses a 5-bit serial code called ITA-2, which is the historical ancestor of the RS-232 serial protocol that we are familiar with today. The Unix system at Bell Labs was developed using the Model 35 Teletype, which was the next model produced after the Model 28, and was capable of handling 8 bit ASCII characters. In fact, the Unix device name “/dev/tty” stands for “Teletype”.
My desire was to interface the teletype to the Internet, with a server daemon which would allow bidrectional communication between the network and the printer. Messages and alerts could be printed to the teletype automatically from remote locations (such as our Yahoo calendar), while a user could send messages and access services such as weather and news headlines from the teletype keyboard.
In this age of network services, the most natural framework for interacing to the teletype was to set up an HTTP service, with an SMTP gateway for direct email support.
The teletype server performs the following tasks:
- Listens to TCP port 80 for HTTP requests. POSTing data to a URL causes a message to be printed to the teletype.
- Listens to the serial port for characters typed by a user on the teletype keyboard. They are handled by an interactive command processor which allows the user to access to network services such as weather reports, news headlines, and phone directory lookup.
- Turning the teletype motor on and off.
To put together software to handle these tasks, I had two alternatives:
- Use two separate processes; a web server listening for remote printing requests, and an interactive command listener process to handle the serial port and process user input from the teletype keyboard.
- Use a single process with a top level loop handling both web service and interaction with the keyboard.
I chose the second alternative, writing a monolithic server application, because I preferred the simplicity of a single process to debug. I looked around for a free-software web server to start with and modify for my teletype server system. The Apache httpd server, while very featureful, is also quite complex for the relatively simple needs of the teletype server. I decided to use a simpler web server, named Boa, as a software base to start with. Boa is a free-software web server, written in ANSI C. It is small, simple, reliable and easily extensible. The source code for my modified Boa server is available here.
I modified the top-level loop of Boa to listen for data coming from the serial port in addition to listening for incoming TCP connections. As a bonus from its simple design, since Boa is single-threaded, there was no need to worry about locking to prevent multiple network threads from trying to print to the teletype serial port simultaneously.
While many people are moving away from programming in C towards more high-level and rapid development environments (such as Java, Python, or Javascript), programming in C still gives the fullest access to the Linux hardware and OS services, in this case to the serial port driver. This kind of low level access was needed when dealing with the oddball serial hardware I am using; to speak to a Model 28 Teletype, the serial port must be configured to send 5 bit characters at 75 baud. I also needed to operate an X-10 powerline controller, which is installed in-line with the serial port to the teletype, and is operated via manual clocking of the RS232 DTR/RTS handshake lines.
For the teletype server project, I originally was going to use the Axis ETRAX Linux development board. That single-board Linux system is extremely small and low power, running entirely out of 2 MB of FLASH ROM. But its serial port driver would not support the ancient 5-bit character format required by the teletype. Luckily, the IBM PC-compatible hardware in the Mini-ITX system still supports the settings needed to drive a teletype (75 baud, 5 data bits).
But one of the most important features of the Mini-ITX board is the low price. The basic model can be had for less than $100 in single quantities, and contains far more built-in I/O devices than the Axis boards. This makes the Mini-ITX an alternative to industrial single-board systems, even when you may only need to use one or two of its numerous capabilities (such as an ethernet to serial port gateway).
Also, unlike many industrial embedded boards, the Mini-ITX has all the I/O connectors attached to the board, making it much easier to get a complete system running without hunting for special cabling and mechanical parts. Only the relatively high power consumption of the Mini-ITX, perhaps 15-20 watts, would make me consider an industrial single-board computer for an application.
I bought a “bare bones” system from CaseOutlet with case, motherboard, and power supply for under $200. If you just purchase a bare motherboard, the Mini-ITX board does a require custom power supply connector, but low cost DC-DC converter supplies for it are easily available from vendors such as mini-box.com.
A significant added benefit of using the Mini-ITX is that because it is completely PC compatible, you can develop, compile and debug your app on a desktop system, without the need for a cross compiler or other special development environment. Or, you can develop your application directly on the target Mini-ITX system, if you have a text editor and compiler installed. If you are building a diskless Flash-based installation, you can program a Compact Flash card on your desktop PC and insert it into the Mini-ITX system as if it were a regular IDE hard drive, using an inexpensive adapter available from vendors such as ACS or Mesa Electronics. The motherboard is jumperless and uses the Award BIOS, so tinkering with hardware settings is about as easy as it can get.
Wireless Networking
I wanted to put the Mini-ITX system on the home network via 802.11 wireless ethernet. Linksys has a very nice device, the WET11 Wireless Ethernet Bridge. This is avaiable for under $100, and can simply be plugged into the ethernet port of the Mini-ITX motherboard. The advantage is that it requires no special driver configuration; any Linux distribution can run the Mini-ITX's generic ethernet hardware, whereas trying to use a USB 802.11 adapter under Linux might require much more careful attention to hardware model and driver installation.
For operating system software, I started with a Debian GNU/Linux installation, because while it has rather rough-and-ready installation process, you can start with a very minimal base systems to which you can easily add or update modules over the network with a single “apt get” command. And Debian is justly known for the stability and quality control of its core and optional software packages.
If you plan to use X windows on your system, and have a hard drive with one or two gigabytes of free disk space on your Mini-ITX system (and it's getting hard to find any disk drive less than 40 GB these days) Mini-ITX, then I recommend starting with a Red Hat distribution. The Red Hat installation is as effortless as installing Windows, and provides an enormous number of bells and whistles. Without the Red Hat installer, I found it challenging to install and configure XFree86 from scratch to work with the Mini-ITX's video hardware.
Red Hat 8.0 installs with the option for the ext3 journaling filesystem, which I highly recommend. This is a huge advantage for a system which may be powered down suddenly, as it is far less prone to corruption in that case, and does not require the lengthy fsck filesystem check at reboot. Note, all journaling filesystems are not created equal. After doing some research on the net, it became clear that the ReiserFS filesystem was designed with performance goals which do not include robustness in the face of unexpected system shutdown, and will not provide the protection you may expect from a journaling filesystem.
A stock Red Hat or other 'workstation' style distribution will also need some customization before it is appropriate for long term unattended use. Without proper housekeeping, log files may eventually fill up the disk someplace. For unattended operation, you will need to pay attention to which daemon processes are actually running, and what resources they consume over the long term. For that reason, it may be easier again to start with a barebones install like Debian, and build up services as you need them, rather than starting with “the works” and removing packages.
After doing development of the teletype server with a hard drive in the system, I ended up just leaving a hard drive there, rather than putting together a Compact Flash based Linux. The Maxtor drive I was using was already very quiet, and the extra power consumption was not a real concern.
Power Consumption
For a system which will be left powered on all the time, power consumption is an important consideration. The lowest speed Mini-ITX system (500 MHz) consumes around 10 watts at idle (see VIA EPIA V-Series Mini-ITX Mainboard Operation Guidelines). With my electric rates, that comes out to about 50 cents per month.
Power drain on a battery powered device is the only reason I would consider using a less powerful system than the Mini-ITX. The gap is shrinking between the very low end for embedded applications, which might use a PIC, Atmel AVR, or 68HC11, and applications which can use something like the Mini-ITX. If your application requires TCP/IP connectivity, but still needs extremely low power, something like the Rabbit might be appropriate. It won't necessarily be cheaper, but it will consume less power and be physically smaller.
Noise
The following noise data comes from the VIA EPIA V-Series Mini-ITX Mainboard Operation Guidelines:
Common Sounds | dBA Level |
---|---|
Threshold of hearing | 0 dBA |
EPIA VE5000 | 0 dBA |
Normal breathing | 10 dBA |
Whispering at 1 meter | 20 dBA |
EPIA V10000 | 25 dBA |
EPIA V8000 | 35 dBA |
Conventional PC 35 | 50 dBA |
Rainfall | 50 dBA |
Normal speech | 60 dBA |
The dBA scale is logarithmic, i.e. 10 dBA represents a doubling in volume. dBA values are measured at a distance of one meter.
Conclusion
The teletype server project had hardware requirements of ethernet, TCP/IP stack, web server, and serial port. The Mini-ITX proved to be the cheapest off-the-shelf hardware solution, and Linux provided the stable and high performance operating system. The software was easily cobbled together using existing free software and development tools.
While this project required few of the many capabilities of the Mini-ITX system, the other projects on my list are all great candidates for using this board; high quality video and audio, as well as low power consumption, low noise, and most importantly low price will make this my platform of choice for future midnight engineering projects.
Copyright copyright © 2003 Henry Minsky. All rights reserved. Reproduced by LinuxDevices.com with permission.
About the author: Henry Minsky has extensive experience with a range of software and hardware development, including network services, mobile computing, machine intelligence, and electronic publishing. He most recently worked for an NTT DoCoMo research project at Keio University in Japan, on protoype mobile computing platforms. Henry has bachelor of science and master of science degrees from MIT in Electrical Engineering.
This article was originally published on LinuxDevices.com and has been donated to the open source community by QuinStreet Inc. Please visit LinuxToday.com for up-to-date news and articles about Linux and open source.