A funny thing happened to me
on the way to the serial port

Vaudeville comedians often used to begin with: "A funny thing happened on the way to the theater".
So too, I started my journey of discovery.

A client was bringing over an old PC/AT from which I needed to copy all the files from the ST506/MFM interface hard drive.
I planned for several approaches in case one didn't work.
It turned out the first method worked: copy to a SCSI disk.
But I wanted several alternatives just in case it didn't.
I figured I'd recreate the environment I used for dialups: I felt like I was playing the game "landmine". Every step blew up in my face.
  1. My Fedora system didn't have sz or rz
    (required to send & receive files using X/Y/Z modem file transfer protocol).
    I had to locate, download & install rzsz.rpm despite already having installed "minicom" which ought to have a depency on sz and rz since they're external programs used for file transfer. I've been using minicom for years and never knew that sz and rz were missing because minicom never gave any useful error like "external command for zmodem is missing!"

  2. System V init enabled serial line logins with a line in /etc/inittab such as
    1:2345:respawn:/sbin/getty 9600 tty1
    
    but NOOOOOOOOOOOOOO! Everything has changed!

    1. getty is now "agetty" (advanced getty).
      "mingetty" is a minimal getty just for virtual terminals.
      Actually, that's a nice improvement because all the parameters are now args
      such as what speeds to try, what file to use for the greeting.
      No more gettydefs/gettytab for chaining the speeds.

    2. "init" is now "upstart",
      replacing /etc/inittab with separate files for each "event handler" in /etc/event.d.
      For information on how to write upstart event handlers, or how upstart works,
      see init(8), initctl(8), and events(5).
After I got over the culture shock, I must admit that the new systems are really nice. They allow for the natural evolution of Linux by adding really nice fine-grained administrative control that the classic /etc/init and inittab never had.

So I added the /etc/event.d/ttyS0 (shown below) and started it with
initctl start ttyS0
and all was good again!

Other Linux serial line controls


stty(1) change and print terminal line settings
Good old stty works on any terminal line, real or virtual.
It's the primary way to view and set the erase, kill and other special characters.

setserial(8) get/set Linux serial port information
setserial(8) is separate from stty since it's concerned with the kernel serial driver:
setting the device address, interrupt, speed and other low level parameters of physical serial ports.

setserial(8) only applies to real serial ports, not virtual ones
(whereas stty is valid for pseudo-terminals such as x-term or via the network).

setserial(8) can be invoked interactively from the shell to view serial line parameters.
Superuser/root privilege is required to alter most settings.
For persistent settings, add the setserial command to
/etc/rc.local or /etc/rc.serial for init to automatically run upon startup.


I'm pleasantly surprised to find there's still support for multiport serial cards.
setserial fourport
configures the port as an AST Fourport card (yes, I still have some).
Citing the man page
Due to the limitations in the design of the AT/ISA bus architecture,
normally an IRQ line may not be shared between two or more serial ports.
If you attempt to do this, one or both serial ports
will become unreliable if you try to use both simultaneously.

This limitation can be overcome by special multi-port serial port boards,
which are designed to share multiple serial ports over a single IRQ line.
Multi-port serial cards supported by Linux include
  1. the AST FourPort
  2. the Accent Async board
  3. the Usenet Serial II board
  4. the Bocaboard BB-1004, BB-1008, and BB-2016 boards
  5. and the HUB-6 serial board
This web page lists the AST 4 port card's DIP settings and configuration
/etc/setserial -v /dev/ttyS4 uart 16450 port Ox1AO irq 9
/etc/setserial -v /dev/ttyS5 uart 16450 port Ox1A8 irq 9
/etc/setserial -v /dev/ttyS6 uart 16450 port Ox1BO irq 9
/etc/setserial -v /dev/ttyS7 uart 16450 port Ox1B8 irq 9
and now the ports are ready for agetty too!
HEAVYMETAL: support for really old vintage terminals
Infoage's electronic warfare museum runs their 5 level teletype from a PC running HEAVYMETAL,
which handles the slow baud rate and code translations such as baudot.
Additional hardware is required for current loop interfaces.
HeavyMetal was developed by Bill Buzbee from 2001 to 2006.
Between May and November 2010, I [Javier Albinarrate]
took the task of entirely rewriting the code into a more expandable codebase,
while adding support for sessions and many new cool features.
At the same time I kept the GUI more or less as it was.

Now in 2012 I was forced to give another jump
due to changes in the ActivePerl distribution
(they dropped the Tk extension I was using),
so as I had to rewrite pretty much the whole GUI into a new module (Tkx).
I obviously took the chance to make many changes that were in the ToDo list.
SEE ALSO


My /etc/event.d/ttyS0 is:
# ttyS0 - getty
#
# This service maintains a getty on ttyS0
# from the point the system is started until it is shut down again.

start on runlevel [2345]

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec /sbin/agetty -8 -L -f /etc/issue_agetty 38400,19200,9600 ttyS0

# -8: the line is 8 bit clean (no parity)
# -L: no CD (carrier detect) required (it's hardwired, not a modem)
# -f: select the alternate greeting with "\b" to show baud rate
# -h: hardware handshake


My /etc/issue_agetty is:
\l (\n) \d \t  speed \b
Fedora release 12 (Constantine) Kernel \r on an \m

agetty/mingetty makes substitutions:

\l is the name of the current tty line
\n is the nodename
\d is the current date
\t is the current time
\b is the baud rate for a real tty (agetty) remains \b for pseudo-terminals (mingetty)
\r is the OS release number
\m is the machine architecture identifier


My /etc/issue for mingetty is nearly the same, but no \b