@echo off

set COMPORT=COM17
set BAUD=115200
::set COMPORT=%1
:START

LHA_UART_Programmer.exe --port=%COMPORT% --invert-reset --reset --debug -vvvvv --control-delay=0.1
CLS
color 0F
LHA_UART_Programmer.exe --port=%COMPORT% --speed=%BAUD% --invert-reset --debug -vvvvv --time --progress --mass-erase --program --control-delay=0.1 --verify RFWallstat.txt
::python -m msp430.bsl5.uart --port=%COMPORT% --speed=%BAUD%  -invert-reset --debug -vvvvv --time --progress --mass-erase --program --control-delay=0.1 --verify RFWallstat.txt
if %errorlevel% LEQ 0 (
		color 2F 
		goto RESET
) else (
		color 4F
		goto RESET 	
)

:RESET
LHA_UART_Programmer.exe --port=%COMPORT% --invert-reset --reset --debug -vvvvv  --control-delay=0.1
::python -m msp430.bsl5.uart --port=%COMPORT% --debug -vvvvv --invert-reset --reset --control-delay=0.1
if %errorlevel% LEQ 0 (
		color 2F 
		goto PASS
) else (
		color 4F
		goto FAIL 
) 


:FAIL
echo "FAILED: Press ENTER to restart TEST"
pause
goto START

:PASS
echo "PASS: Press ENTER to restart TEST"
pause
goto START