#!/bin/sh

##variables, change them according your needs
buad_rate="9600"		#buad rate of the pc terminal and hc12
serial_port0="/dev/ttyUSB0"	#device filename of your PC serial port connected to hc12 sci0
serial_port1="/dev/ttyUSB1"	#device filename of your PC serial port connected to hc12 sci1
start_point="2000" 		#set according to memory.x file. In my case I start at 2000. So we should run "g 2000"





##go back project folder and make the files
cd ..
make clean
make

#set the terminal buad rate
stty $buad_rate


#if hc12 is using D-Bug12 we need to issue a "load" command before we can upload our s19 file
echo load > $serial_port0
./bin/send_new_line $serial_port0

#wait and make sure hc12 got everything
./bin/sleep 1s

#upload s19 file to hc12 board
cat ./000.s19 > $serial_port0
./bin/send_new_line $serial_port0

#wait and make sure hc12 got everything
./bin/sleep 1s

#if hc12 is using D-Bug12 we need to issue a "g ####" command before we can upload our s19 file
#in my case, according to memory.x file I will start at 2000 ("g 2000")
echo "g $start_point" > $serial_port0
./bin/send_new_line $serial_port0

