Serial Port / Modem Control Lines as GPIO
From Rivendell Wiki
Under Rivendell if your system has a serial port it is possible to use the serial port control lines as a quick and simple way to set up GPIO's. Specifically you can have up to 4 GPI's and 2 GPO's per serial port.
Setting up your user ID for access
First thing you need to do is make sure that the Linux user ID that runs the Rivendell services is in the dialout group. The dialout group is the one that allows access to serial ports. You can do this from a shell, you'll need to be root (so use su or sudo)
usermod -a -G dialout %userid% <-- Update this with the user id, the same one that is running your Rivendell system daemons
Once done it is a good idea to reboot to ensure that this user ID picks up the new group credentials.
Setting up Rivendell to use the serial port
Next you'll need to enable the serial port in that Rivendell host.
Go to RDAdmin --> Manage Hosts --> Select your host --> Serial Ports
Enable the serial port and put the TTY device into the needed field. On many systems the first serial port ends up as TTY device:
/dev/ttyS0
It can be different, check your system.
Next, click on Switchers GPIO, then click ADD. Select a Matrix number and in the Switcher Type pull-down list, find Serial Port Modem Control Lines
On the next screen, you can give it a description, select the serial port number you picked when you enabled your port, and you can configure the GPI's (you'll have 4 of them), and GPO's (you'll have 2 of them). You can assign macros to the ON and the Off transitions for each control line.
The device then will be in the matrix under the device matrix ID you assigned, you can control the GPO's with macros if you desire. It'll also show up in rdgpimon if you run that to monitor.
Wiring it up
The important parts of the pinout on the 9 pin serial port is:
Inputs:
CD (Carrier Detect / GPI ) - Pin 1
DSR (Data Set Ready / GPI) - Pin 6
CTS (Clear to Send / GPI) - Pin 8
RI (Ring Indicate / GPI) - Pin 9
Outputs:
DTR (Data Terminal Ready / GPO) - Pin 4
RTS (Request to Send / GPO) - Pin 7
Ground - Pin 5
The GPI's are just looking for a positive or negative voltage. The serial port specification calls for 3 to 25 volts (+ or -). For testing I generally go with a positive 5 volts with the negative to ground.
The GPO's will trigger a voltage on and off compared with ground.
Considering that there are still lots of systems on the market that have at least 1 (and often times 2) serial ports, if you don't need a lot of GPIO's then it is a reasonable way to go.