#!/bin/sh # # ser_cmd v0.1 - Robert Pectol - kk7av node 3515 # Simple script for sending a, 'one-shot' command over # the serial port to an external device (controller). # ############################################################ ################################ # USER CONFIGURABLE SETTINGS # ################################ ## The only required variables are, "baud_rate", "device", ## and, "command." The contents of the, "command" variable ## are what get sent over the serial port. # set baud rate baud_rate="9600" # set com port device device="/dev/ttyS0" # example - form the command string curtime=`date +%I%M` ampm=`date +%p` if [ "$ampm" == "AM" ]; then ampm="0" else ampm="1" fi command="058${curtime}${ampm}" ############################## # END USER CONFIG SETTINGS # ############################## ### ############# NO MODS BELOW HERE ############# ### # set up the serial port parameters stty -F $device ispeed $baud_rate ospeed $baud_rate -echo # send the data and get the response back exec 3<>$device printf "$command\r" >&3 read response <&3 echo "$response" exec 3>&- exit 0