#!/bin/sh

# Check that a filename was specified.
if test -z "$1"
then
    echo "No filename specified!"
    exit 1
fi

# Check that the file exists.
if ! test -e "$1"
then
    echo "The file \"$1\" does not exist."
    exit 1
fi

# Check that the file can be read.
if ! test -r "$1"
then
    echo "The file \"$1\" cannot be read."
    exit 1
fi

# Ensure that the file is in the cache before beginning.
cat "$1" > /dev/null

# Perform the file transfer.
stty -F /dev/ttyS0 speed 115200 raw crtscts > /dev/null
echo "Downloading \"$1\" on COM1 at 115200 bps."
cat "$1" > /dev/ttyS0
