The old dog learned a few new tricks this morning.  Well, maybe I just applied some things I already knew.

The serial port of the RLC-3 repeater controller is connected to the Dell 860 server known as STARski (home of the 27006 node connected to port 3 of that same RLC-3 controller).    Since I can SSH into that server, this connection allows me a method for easy programming of the RLC controller.  It also allows one to execute commands.  For example:

echo 603 > /dev/ttyS0

That sends the command to execute Macro 603 to the serial port.  Works quite well too.  So we throw that into a file and then make that file executable.  I call this file timetemp since Macro 603 announces the time and the temperature reading of the inside and outside probes.  That worked so well that I created a cron job to execute this at the top of every hour from 7 am to 7 pm.

When I started this I quickly discovered that the time was off.  We had a recent daylight “savings” shift of an hour and the clock hadn’t been adjusted for that.  It was also off by several minutes as the real time clock in the controller is pretty sloppy.  The server keeps its time in sync with NTP servers, so we know it’s right.  So I modified a script someone else wrote to do this via DTMF and arranged things so it sets the time via serial port.  Again, I save it as a file, make it executable and then set it to run once a day to keep it all smooth.  Here it is:

#!/bin/bash
########################################################################
# filename: setrlcclock
# description: Reads the Linux system clock (localtime) then generates
# the sequences to set the RLC-3 repeater controller
# clock's Date and Time and puts them on the appropriate
# serial port into the controller.
########################################################################
#
SETTIME=025 # RLC-3 Set Time Command
SETDATE=028 # RLC-3 Set Date Command
AM=0
PM=1
#
# Subroutines
#
function procdate () {
# Convert the AM/PM
if [ "$7" = "AM" ] ; then
AMPM=${AM}
else
AMPM=${PM}
fi
echo "Preventing controller audio responses"
echo 050090 > /dev/ttyS0
echo -n "Setting RLC-3 clock time..."
echo ${SETTIME}$5$6${AMPM} > /dev/ttyS0
echo "DONE"
sleep 2
echo -n "Setting RLC-3 clock date..."
echo ${SETDATE}$1$2$3$[$4+1] > /dev/ttyS0
echo "DONE"
echo ""
echo "Enabling controller audio responses on Port 1"
echo 050091 > /dev/ttyS0
echo ""
echo "The RLC controller should now have correct date and time."
}
#
# Main
#
procdate `date +"%m %d %y %w %I %M %p"`