-1

I have a batch file that compiles a project and then runs a JS that connects to a DSP, runs the program and reads the results from the DSP's memory (more detailed info about the DSP etc. is at the end of my question). My problem is that the compiling and JS running is run in a loop inside my batch file and sometimes, for some reason, the build is stuck, an exception in the DSP is thrown or the DSP is stuck in a condition that is preventing the batch to continue to the next step in the loop. What I want to implement is some kind of a watchdog in my batch file that lets the current loop step last for a limited time and if that time expires, continue to the next step.

the DSP is TI6678EVM, using CodeComposer v5.3 and DSS. The batch file's loop:

:CREATE_TEST_DIR
SET "test_dir=%cur_dir%%proj_name%"
ECHO %test_dir%
IF NOT EXIST %test_dir% GOTO INC_TESTN

ECHO ************************************************************************
ECHO Copying headers from %headers_folder_name%%test_num%
ECHO ************************************************************************
SET /a Idx=10
:CHANGE_HEADERS
REM Delete the header files from project dir
del %test_dir%\HeaderFiles\R_Main_%Idx%.h"
REM Copy test vectors header file to workspace
COPY /y "%test_dir%\%headers_folder_name%%test_num%\R_Main_%Idx%_%test_num%.h" "%test_dir%\HeaderFiles\R_Main_%Idx%.h"
SET /a Idx+=1
IF %Idx% leq 16 GOTO CHANGE_HEADERS


ECHO ************************************************************************
ECHO Building project
ECHO ************************************************************************
REM Create and build project
CALL "%eclipsec_path%" -noSplash -data "%test_dir%" -application com.ti.ccstudio.apps.projectBuild -ccs.workspace -ccs.buildType clean > "%test_dir%\p_build.log" || GOTO FAIL_BUILD
CALL "%eclipsec_path%" -noSplash -data "%test_dir%" -application com.ti.ccstudio.apps.projectBuild -ccs.workspace > "%test_dir%\p_build.log" || GOTO FAIL_BUILD
REM ECHO Project build successful


FOR /r "%test_dir%" %%a in (*.ccxml) do set CCXML_path=%%~dpnxa
IF "%CCXML_path%"=="" GOTO BAD_CCXML
ECHO Found .ccxml file %CCXML_path%
FOR /r "%test_dir%" %%a in (*.out) do set OUT_path=%%~dpnxa
IF "%OUT_path%"=="" GOTO BAD_OUT
ECHO Found .out file %OUT_path%

SET "testVecPath=%test_dir%\%headers_folder_name%%test_num%"
ECHO ************************************************************************
ECHO Runing tet
ECHO ************************************************************************
CALL "%dss_path%" "ccsRunTestVectors.js" %ccs_path% %test_dir% %CCXML_path% %OUT_path% %datetimef% %testVecPath%|| GOTO FAIL_BASIC
ECHO ************************************************************************
ECHO Test Done.
ECHO ************************************************************************
GOTO INC_TESTN

:FAIL_CREATE
ECHO Failed

:INC_TESTN
SET /a test_num+=1
REM pause
IF %test_num% gtr %TestNumEnd% GOTO DONE
GOTO CREATE_TEST_DIR

:DONE
AnR
  • 81
  • 7
  • `timeout 10 /nobreak >nul` – Gerhard Aug 19 '20 at 09:13
  • @Gerhard This would pause the batch from running. What I need is the batch to continue running as long as the timeout hasn't been reached – AnR Aug 23 '20 at 05:58
  • Create a batch file which this file calls, use `timeout` in that batch file and give it a tittle, use `tasklist` in your loopto see if that windowtitled process is still running, if not then exit. – Gerhard Aug 23 '20 at 06:43

1 Answers1

0

Here is an example of what I mean, it will run the main loop, as long as the timer.cmd file is active with the title Timer. You can copy this as is and call it something like test_wait.cmd then run it, you will see that it will continue looping, echoing Still running as long as the script timer.cmd is running, which by the way this script creates for you.

You can then incorporate it into your script as you please.

@echo off
echo title Timer>timer.cmd
echo timeout 20 /NOBREAK ^>nul>>timer.cmd
echo exit>>timer.cmd
start /min timer.cmd & timeout 1 /NOBREAK>nul
:start
tasklist /FI "windowtitle eq Timer" | findstr /i "cmd.exe">nul 2>&1
if errorlevel 1 goto del timer.cmd /Q & goto :eof
echo Still running..
(timeout /t 1)>nul
goto :start
Gerhard
  • 22,678
  • 7
  • 27
  • 43