// Inport DSS and Java Package

importPackage(Packages.com.ti.debug.engine.scripting);
importPackage(Packages.com.ti.ccstudio.scripting.environment);
importPackage(Packages.com.ti.dvt.engine.scripting);
importPackage(Packages.java.lang);

// Modify these viriables to match your environment. use forward slashes
var ccs7InstallDir = "C:/ti/ccs7.4.0.00015/ccsv7";
var DSSWorkshopDir = "C:/ti/xdctools_3_50_02_20_core/packages/xdc/rov/dss";
var deviceCCXMLFile = "C:/Users/a0389327/ti/CCSTargetConfigurations/28035.ccxml";
var programToLoad = "C:/ti/workspaces/740/Example_2803xGpioToggle/Debug/Example_2803xGpioToggle.out";
var LogFile = "log.xml";

//Create the Scripting Environment Object
var script = ScriptingEnvironment.instance();

// Create a log file to log script execution
script.traceBegin(LogFile, "DefaultStylesheet.xsl");

// Set trace levels for console and logs
script.traceSetConsoleLevel(TraceLevel.INFO);
script.traceSetFileLevel(TraceLevel.ALL);
script.traceWrite("Begin scripting session");

// Get the Debug Server and start a Debug Session
var debugServer = script.getServer("DebugServer.1");
debugServer.setConfig(deviceCCXMLFile);
var debugSession = debugServer.openSession("*","C28xx");

// Connect to the CPU
debugSession.target.connect();
script.traceWrite("Connecting to device...");

//session.target.connect();
script.traceWrite("Connected");

// Load a program
debugSession.memory.loadProgram(programToLoad);
print(["debugSession.target.run"])

// Run the target
debugSession.target.runAsynch();

// read deta
var result = debugSession.memory.readData(0,0x00009a02,8);

// All done
debugServer.stop();

script.traceWrite("End scripting session");

// Stop logging and exit.
script.traceEnd();
