#!/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 "0:0:80001cb2:8a38:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0"
echo "Downloading \"$1\" on COM1 at 115200 bps."
cat "$1" > /dev/ttyS0
