if [ $# -lt 3 ]; then
  echo "  updatess: update remote SSerial device"
  echo "  Usage: updatess remotecard fpgacard sserialchan [firmwarename]"
  echo "  Example 1 ./updatess 7i73 5i23 4 svss6_6.bit"
  echo "  Example 2 ./updatess 7i84 5i25 3"
  echo "  Remote SSerial firmware must be installed in /lib/firmware/hm2/sserial"
  echo "  Firmware name is same as used normally by linuxcnc"
  exit
fi  
echo set jumper on  remote device to setup mode
echo cycle remote device power and then hit return
read
if [ $4 ]; 
then  
  config="config=\"firmware=hm2/$2/$4\""
fi
lremote="$(echo $1 | tr '[A-Z]' '[a-z]')"
uremote="$(echo $1 | tr '[a-z]' '[A-Z]')"
sed < updategeneric.hal -e s/@REMOTE@/$lremote/ -e s/@REMOTE@/$uremote/ -e s/@CARD@/$2/ -e s/@CHANNEL@/$3/ -e s#@CONFIG@#$config# > updatess.hal
halrun -f updatess.hal
echo set jumper on remote device back to operate mode
echo and cycle remote device power
