This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hello,
I make extensive use of java scripting in CCS, to connect, build, run, etc. I've been using full paths for commands in the java script, for loading and commands, ex: load( "c:\some-path-to-java-script-directory\runtime.js" ). But I need to use relative paths, to allow for different paths to the script directory, e.g. load( "..\some-relative-path\runtime.js" ). So I'm trying to determine what the root path is of the java script?, so I can figure out the correct relative path. It doesn't appear to be the path to where the java script resides.
Please advise,
Robert
Hi Robert,
It should be the script location. Can you try using forward slashes like:
load( "../some-relative-path/runtime.js" )
Thanks
ki
Hi Ki,
Yeah, finally figured that out. On my machine, it is c:\ti\ccs920\ccs\eclipse", and I can do a bunch of relative paths up the directory chain, then back down to my build location. But that is unwieldy, and someone else's build location might be different than mine. Is there any way that you know of to set the root/current directory?, for instance to the project main build directory. Each user could then do that set at the beginning of the script operations, and all the remainder of the script operations would use simple relative paths.
Thanks,
Robert
Robert Wolfe said:Is there any way that you know of to set the root/current directory?, for instance to the project main build directory. Each user could then do that set at the beginning of the script operations, and all the remainder of the script operations would use simple relative paths.
It's a bit of a known limitation regarding setting the current directory. What I have done in the past to workaround it is to use system environment variables. The user would have a variable defined to specific path on their system. Then the variable can be used in the script.
For example, "ROOT_DIR" can be an environment variable set by each user. Then it can be used in the script.
load(java.lang.System.getenv("ROOT_DIR") + "/path/to/myScript.js");
I some have my custom bat file set my custom environment variables and then have the same bat file call dss,bat to run my js script.
Thanks
ki
Ki,
Maybe that'll be corrected in some future release, thanks for the work-around. A related question - I can't seem to use anything but a hard-coded path for GEL operations within the script, for instance these:
debugSession.expression.evaluate( 'GEL_UnloadGel( "c:/some_dir/a.gel" )' );
and
debugSession.expression.evaluate( 'GEL_LoadGel( "c:/some_dir/a.gel" )' );
Even if I set a var to the exact path and file, it doesn't work
var dir_gel = "c:/some_dir/a.gel"
debugSession.expression.evaluate( 'GEL_UnloadGel( dir_gel )' );
Do you know any way around this?
Robert
GEL is more limited. There is really only one good option to avoid absolute paths in GEL:
https://software-dl.ti.com/ccs/esd/documents/users_guide/gel/macros.html
Thanks
ki
Thanks. I don't think that'll work in my case, because I'm trying to use it to load and unload the gel itself:
debugSession.expression.evaluate( 'GEL_UnloadGel( "$(GEL_file_dir)\a.gel" )' );
debugSession.expression.evaluate( 'GEL_LoadGel( "$(GEL_file_dir)\a.gel" )' );
Keeps telling me the unload and load fail.
Does the gel need to be loaded first, before it assigns the value for GEL_file_dir, or how else would it be initially defined?
If I just try to print it in the script:
print( $GEL_file_dir )
it says:
ReferenceError: "$" is not defined.
Robert
Shoot, yeah you are right. That macro must be used from a GEL file.
In your case, I would stick to the environment variable thing:
debugSession.expression.evaluate( 'GEL_LoadGel( "' + java.lang.System.getenv("ROOT_DIR") + '\\a.gel" )' );
Thanks. That syntax didn't work for me. I've also tried:
debugSession.expression.evaluate( 'GEL_LoadGel( java.lang.System.getenv( "ROOT_DIR" ) + "/a.gel" )' );
without luck.
Your style of formatting:
debugSession.expression.evaluate( 'GEL_LoadGel( "'+java.lang.System.getenv( "ROOT_DIR" ) + '/a.gel" )' );
resulted in the error:
TMS320C671X: GEL: Error loading file 'C:\ti\ccs920\ccs\eclipse\null\a.gel': unable to open GEL file 'C:\ti\ccs920\ccs\eclipse\null\a.gel'
Robert
P.S. This worked, for setting a ccxml, but the GEL above didn't
debugServer.setConfig( java.lang.System.getenv( "ROOT_DIR") + "/a.ccxml" );
hmmm... i think it is issues with the paths. Try the following:
make sure you use forward slashes for the path specified in your environment variable:
set ROOT_DIR=C:/ti/ccs920/ccs/ccs_base/scripting/examples/DebugServerExamples
then try:
debugSession.expression.evaluate( 'GEL_LoadGel( "' + java.lang.System.getenv("ROOT_DIR") + '/a.gel" )' );
This worked for me. Here is my verbose console output. the "I'm in a.gel" text is executed from a.gel.
Thanks
ki
That worked Ki, after we removed spaces in the directory name.
Thanks much,
Robert