:: :: _connect_target_scarlett.bat :: :: Initialize connection with scarlett devkit prior to attempting launch :: if not exist "%GameDK%\bin" ( echo Scarlett GDK support tools not installed as expected exit 1 ) :: Make sure Scarlett GDK is in the path set PATH=%GameDK%\bin;%PATH% if not exist "%exename%.exe" ( echo Can't find Scarlett executable [%exename%.exe] exit 1 ) :: If no target was specified, then get the address of the default target. if "%target_ip%" == "" ( echo No ip address specied, looking up default target. rem :: What is this ridiculous syntax? See rem :: http://stackoverflow.com/questions/7516064/escaping-double-quote-in-delims-option-of-for-f rem :: Why ^"^" instead of just ^"? Because having just one " confuses Emacs syntax highlighting. for /F usebackq^ tokens^=2^ delims^=^"^" %%a in (`xbconnect ^| find "Default console set to "`) do set target_ip=%%a if "!target_ip!" == "" ( echo No default Scarlett target selected exit 1 ) ) :: Strip off the optional access key from the target ip address for /F "tokens=1* delims=+" %%a in ("%target_ip%") do set target_ip_bare=%%a :: Kill any currently running game. ::call "%batch_dir%..\..\script\util\kill_scarlett_processes.bat" [%target_ip%] set rebootscarlett= :: Before we start R*TM, make sure that kernel debugging is enabled. Otherwise R*TM will try :: to enable it and in the process reboot the console while we are trying to deploy to it. :: This should only really happen when running on a new kit for the first time. set enablekerneldebugging=false for /F "usebackq tokens=1,2" %%a in (`xbconfig /x%target_ip% EnableKernelDebugging`) do set enablekerneldebugging=%%b if not "%enablekerneldebugging%" == "true" ( echo %target_ip% kernel debugging not yet enabled echo Enabling and console will be rebooted... echo. xbconfig /x%target_ip% EnableKernelDebugging=true >nul set rebootscarlett=yes ) set consolemode= for /F "usebackq tokens=1,2" %%a in (`xbconfig /x%target_ip% consolemode`) do set consolemode=%%b if /i not "%consolemode%"=="anacondaprofiling" if /i not "%consolemode%"=="lockhartprofiling" ( echo %target_ip% console mode unsupported [%consolemode%] echo Setting to Anaconda mode and console will be rebooted... echo. xbconfig /x%target_ip% consolemode=anacondaprofiling >nul set rebootscarlett=yes ) set sandboxid= for /F "usebackq tokens=1,2" %%a in (`xbconfig /x%target_ip% sandboxid`) do set sandboxid=%%b if not "%sandboxid:~0,4%"=="RKTR" if /i not "%sanboxid:~0,4%"=="CERT" ( echo %target_ip% sandbox ID unsupported [%sandboxid%] echo Setting to RKTR.1 and console will be rebooted... echo. xbconfig /x%target_ip% sandboxid=RKTR.1 >nul set rebootscarlett=yes ) if not "%rebootscarlett%"=="" ( echo. echo Rebooting %target_ip% ... xbreboot /x%target_ip% rem :: Wait a bit before calling xbconnect, as if we call it too quickly it can succeed before the reboot has started. ping -w 5000 -n 2 127.0.0.1 >nul rem :: Call xbconnect continiously until it returns without error. :wait_reboot xbconnect /q %target_ip% > nul if errorlevel 1 goto wait_reboot echo Reboot complete. ) :: If not running with R*TM, determine what type of console this is, devkit or testkit. if not "%RS_RTM_DISABLE%" == "" ( set tooltype=TestKit for /F "usebackq tokens=2" %%a in (`xbDiagInfo /x%target_ip% ^| find "CCat2"`) do set tooltype=DevKit if errorlevel 1 ( echo Failed to determine if running on a testkit or a devkit. exit 1 ) echo Console type = !tooltype! echo. if "!tooltype!" == "DevKit" ( set autoGeneratedCmdline=!autoGeneratedCmdline! -devkit ) )