@echo off
SET PATH=%PATH%;c:\Program Files\putty\

::mbed Serial Port
:mbed
set func=mbed
friendly_port "mbed Serial Port"
set result=%ERRORLEVEL%
if %result% EQU -1 (
  ::echo %result%
  echo mbed scan done
  goto st
) else (
  goto openputty
)

::STMicroelectronics STLink Virtual COM Port
:st
set func=st
friendly_port "STMicroelectronics STLink Virtual COM Port"
set result=%ERRORLEVEL%
if %result% EQU -1 (
  ::echo %result%
  echo st scan done
  goto fsl
) else (
  goto openputty
)

::OpenSDA - CDC Serial Port
:fsl
set func=fsl
friendly_port "OpenSDA - CDC Serial Port"
set result=%ERRORLEVEL%
if %result% EQU -1 (
  ::echo %result%
  echo freescale scan done
  goto exit
) else (
  goto openputty
)

:openputty
start /D %CD% putty.exe -serial com%result% -sercfg 9600
timeout /t 1 > NUL
goto %func%

:notfound
echo all done.
pause

:exit
