#!/bin/bash
#
# Hoverboard programming script
#
# Carrick Detweiler, 2011


#Set the serial port to the correct settings
stty -F /dev/ttyUSB0 19200 -opost -onlcr -brkint -icrnl -imaxbel -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke -ixon -ixoff
echo "Sending program string"
#Send "reboot" so that if a program is running that has that command we will reboot
#into the bootloader
echo -e "reboot\r\n" > /dev/ttyUSB0
sleep 1

#The string "pr" is needed to enter programming mode on the bootloader
echo pr > /dev/ttyUSB0
echo "Starting avrdude"
avrdude -F -V -D -c stk500v1 -p m1284p -b 19200 -P /dev/ttyUSB0 -U flash:w:main.hex
