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.

CCS/MSP430FR2355: Encountered Error ReferenceError: "FileWriter" is not defined. Trying to read and write data using Java methods in .js script for debug initialization

Part Number: MSP430FR2355


Tool/software: Code Composer Studio

I was attempting to follow the above post but when I tried to implement code similar it errors out.  I have included my code and highlighted the portion where the error occurs. My code seems to be the same but the import statement is not working? Thank you for your help.

// Import the DSS packages into our namespace to save on typing
importPackage(Packages.com.ti.debug.engine.scripting)
importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.java.lang)
importPackage(Packages.java.io.*);




// 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()

// Create a log file in the current directory to log script execution
script.traceBegin("test_scriptTestLog.xml", "DefaultStylesheet.xsl")
script.traceBegin("real_testscript.xml")
// Log everything
script.traceSetConsoleLevel(TraceLevel.ALL)
script.traceSetFileLevel(TraceLevel.ALL)

// Get the Debug Server and start a Debug Session
debugServer = script.getServer("DebugServer.1")
debugServer.setConfig("C:/Users/blake/ti/CCSTargetConfigurations/NewTargetConfiguration.ccxml");
debugSession = debugServer.openSession()


debugSession.target.connect();

// Set our TimeOut
script.setScriptTimeout(15000)

// Load a program
// (ScriptingEnvironment has a concept of a working folder and for all of the APIs which take
// path names as arguments you can either pass a relative path or an absolute path)

debugSession.memory.loadProgram("C:\\Users\\blake\\workspace_v10\\Asm_AddrMode3_Absolute\\Debug\\Asm_AddrMode3_Absolute.out");

//savedata
debugSession.memory.saveData(PAGE_PROGRAM,0x8000,"C:\\ti\\hex_output.txt",0x800,IOMEMORY_HEX,false);

var start_memory_dec = 32768;
var is_it_first = 0;

var fw = new FileWriter("C:\\Users\\blake\\VHD_MEMORY_JS\\program_memory.vhd"); //<------------------------------------------This is where the error occurs. Reference Error: "FileWriter" is not defined.
var writer = new BufferedWriter(fw);

writer.write("THIS IS A TEST!!");
  • Hi Blake;

    Blake Stanger said:
    var fw = new FileWriter("C:\\Users\\blake\\VHD_MEMORY_JS\\program_memory.vhd"); //<------------------------------------------This is where the error occurs. Reference Error: "FileWriter" is not defined.
    var writer = new BufferedWriter(fw);

    Try replacing the above lines with:

    var fw = new java.io.FileWriter("C:\\Temp\\program_memory.vhd");
    var writer = new java.io.BufferedWriter(fw);

    Thanks

    ki

  • OR

    get rid of the dot asterisk in:

    Blake Stanger said:
    importPackage(Packages.java.io.*);

    importPackage(Packages.java.io);