The Scripting Console can be opened using the 'View->Scripting Console' menu option.
From the console, a full list of the loaded console commands can be displayed by pressing the 'TAB' button. The 'TAB' button can also be used for partially typed commands in the console for the auto-complete feature. Documentation for each command can be displayed using the 'help' command (js:> help ).
###Loading and saving memory###
Memory and program load operations such as loadRaw, loadData, loadProg have the basic syntax below.
- Do not insert spaces between the commas and the parameters inside the parenthesis
- When passing a reference to a file, use double quotes and use C-syntax parameters, including escaping special characters
- Boolean values must be passed with the constants false and true these must be in lowercase.
- The constants that designate the memory page of the target are optional: PAGE\_PROGRAM, PAGE\_DATA and PAGE\_IO can be replaced with 0, 1 and 2 respectively.
Memory save operations are slightly different
- The forward slash syntax for the filename designator does not work in this case.
- The length parameter (0x400 in this example) specifies the total number of elements to be read, which is dependent on the target device. For MSP430, F28x and C55x each element consists of 16 bits or two bytes (in the example above 0x800 bytes will be read). For all other architectures it is 32 bits or four bytes (0x1000 bytes for the example above).
To build a project the project must exist in the current workspace.
- The return value is always true, regardless of the success of the build.
- When using version control, projects with changes must be preceded with the ">" signal:
buildProject "> myProject"
##Custom Console Commands##
## Services ##
Within the Scripting Console, several services are available to be used from the console. Using the 'services' command will echo the list of services to the console. Many are just used internally and not meant for public use. However, there are some that can be used publicly, such as:
- env: Scripting Environment (this is similar to the scripting environment object - that gets returned by the DSS ScriptingEnvironment.instance() call)
- ds: Debug Server (this is similar to the debug server object that gets returned by the ScriptingEnvironment getServer( "DebugServer.1" ) call)
These services can be used with DSS APIs from the console.
For example you could use APIs to create a Scripting Environment and Debug Server:
js:> script = ScriptingEnvironment.instance();
js:> debugServer = script.getServer("DebugServer.1");
js:> debugSession = debugServer.openSession(".*");
Or instead you can leverage the existing services for the Scripting Environment (env) and Debug Server (ds):
js:> debugSession = ds.openSession(".*");
Note that these services will not be recognized when running the script outside the Scripting Console.
// Check to see if running from within CCSv4 Scripting Console
var withinCCS = (ds !== undefined);
// Create scripting environment and get debug server if running standalone
// Import the DSS packages into our namespace to save on typing
// Create our scripting environment object - which is the main entry point into any script and
// the factory for creating other Scriptable ervers and Sessions
var script = ScriptingEnvironment.instance();
// Get the Debug Server and start a Debug Session
debugServer = script.getServer("DebugServer.1");
else // otherwise leverage existing scripting environment and debug server
var debugServer = ds;
var script = env;
##Script execution from a menu##
Scripts may contain a command that will create a menu item under "Scripts" menu that will allow execution of that function when menu is pressed. Scripting Console allows to automatically reload scripts when CCS is restarted. This may be accomplished by passing "true" parameter to loadJSFile command. Combining these two features may be used to create scripts that perform complex sequence of tasks with a single user action.
// Change timeout from the default (infinite) to 15 seconds
// Create a log file in the current directory to log script execution
... //rest of script
The example above will create a 'Load' menu under Scripts that will call load_out function when pressed.