#!/usr/bin/env sh
BV=/dev/ttyACM2

#echo "reset" > $BV
#sleep 3

echo "quit" > $BV
sleep 0.5
echo "" > $BV
sleep 0.1

BAUDRATES=( 1200 1800 2400 4800 9600 19200 38400 57600 115200 230400 460800 576000 921600 )
BAUD=$(( ( $RANDOM % 13 ) ))
BAUDRATE=${BAUDRATES[$BAUD]}
DATABITS=$(( ( $RANDOM % 4 ) + 5 ))
PARITY=$(( ( $RANDOM % 5 ) + 1 ))
PARITIES=( "?" "N" "E" "O" "M" "S" )

echo "$BAUDRATE ${DATABITS}${PARITIES[$PARITY]}1"
for cmd in "mode uart" "$BAUDRATE" "$DATABITS" "$PARITY" "" "" "" "t hello" "t world" "t how" "t are" "t you" "t today" "t ?" "t The quick brown fox jumps over the lazy dog"; do
  echo $cmd > $BV
  sleep 0.2
done

exit 0

for i in `seq 1 100`; do
  echo "scan" > $BV
  sleep 1
done
