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.

DSS read data from text file

Part Number: TMS320C6748
Other Parts Discussed in Thread: CCSTUDIO, OMAPL138

Tool/software: Code Composer Studio

Hi Ki Soo Lee,

Thank you so much for helped me for my previous issues. Now I am working for automation of unit testing using DSS in CCSV6.2. I am able to load my project and add the break point using "getaddress".

Here my question is how can load and read the data from text file (I have 2 text files which are having input coefficients feed to my function) ?

//#############################################################################################################################//

I have gone through one example provided by ti i.e. memoryDump.js. In this script there are some variables like page, address, ..etc 

// Values for a C6x Sim
var page = 0;
var address = 0x20;
var addrUnits = 1;
var byteSize = 8;
var wordSize = 32;

// Load a Jpg
var SAMPLE_JPG_LOAD = "tidotcom.jpg";
debugSession.memory.loadRaw(page, address, SAMPLE_JPG_LOAD, wordSize, false);

// Open the Jpg
var fis = new FileInputStream(script.toAbsolutePath(SAMPLE_JPG_LOAD));

//#############################################################################################################################//

For my function i have some text files which have window coefficients that I need to feed so could you please guide me how can I open and read the data and store the results to one text file.

Kindly consider my request and resolve my problem.

Thanking you.

Regards,

koti.

  • Koti - you seem to have a similar duplicate post below:
    https://e2e.ti.com/support/development_tools/code_composer_studio/f/81/p/605126/2227324

    And you seem to have two user accounts. Please try to consolidate your threads and accounts

    Thanks
    ki

  • Hi Ki,

    I am sorry for that and this is my main account. I have seen your answer to my question which is not helpful to me. Following is my script.

    /##########################################################################################/
    // 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);
    importPackage(Packages.java.io.file);


    var READ_BUFFER = 100; // Read 100 bytes at a time.

    // Create our scripting environment object - which is the main entry point
    // into any script and the factory for creating other Scriptable Servers and Sessions
    var script = ScriptingEnvironment.instance();

    // Create a log file to log script execution
    script.traceBegin("phasecompLOG.xml", "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("D:/target_configuration/OMAPL138_c6748.ccxml");
    var debugSession = debugServer.openSession("Blackhawk XDS560v2-USB System Trace Emulator_0/C674X_0");

    // Connect to the CPU
    debugSession.target.connect();

    // Load a program
    debugSession.memory.loadProgram("D:/Sandboxes/DRP_Previous/04_Engineering/03_Workspace/algo/drp_sim/Debug_L138/drp_c6748.out");

    //Values for a C6x Sim
    var page = 0;
    var address = 0x20;
    var addrUnits = 1;
    var byteSize = 8;
    var wordSize = 32;

    // Load a Jpg
    var INPUT_PHASE_COEFF_LOAD = "D:/test_Vectors/PhaseComp_Array.dat";
    debugSession.memory.loadRaw(page, address, INPUT_PHASE_COEFF_LOAD, wordSize, false);

    var page = 0;
    var address = 0x40;
    var addrUnits = 1;
    var byteSize = 8;
    var wordSize = 32;

    var INPUT_WINCH_COEFF_LOAD = "D:/test_Vectors/WinCh_Array.dat";
    debugSession.memory.loadRaw(page, address, INPUT_WINCH_COEFF_LOAD, wordSize, false);

    // Open the Jpg
    var Inp1 = new FileInputStream((INPUT_PHASE_COEFF_LOAD));
    var Inp2 = new FileInputStream((INPUT_WINCH_COEFF_LOAD));


    gotFromFile = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, READ_BUFFER);
    var gotFromMem;
    var bytesRead;
    var index = 0;
    var errorCount = 0;
    var prevMatched = false;

    // Keep reading until we hit the end of the file
    do {
    // Read bytes into an array
    bytesRead = Inp1.readData(gotFromFile);

    // Read bytes from memory
    if (bytesRead > 0) {

    gotFromMem = debugSession.memory.readData(page, address + (index * addrUnits), byteSize, bytesRead);

    for (var i = 0; i < bytesRead; i++) {

    // Cast from signed byte to (unsigned) in a long
    var fromFile;
    if (gotFromFile[i] < 0) {
    fromFile = gotFromFile[i] + 0x100;
    }
    else {
    fromFile = gotFromFile[i];
    }

    var fromMem = gotFromMem[i];

    previousLine = currentLine;
    currentLine = (index + i) + "\t\t" +
    "0x" + Long.toHexString(address + ((index + i) * addrUnits)) + "\t\t" +
    "0x" + Long.toHexString(fromFile) + "\t\t" +
    "0x" + Long.toHexString(fromMem);

    // Compare the values
    if (fromFile != fromMem) {

    // Generate a message from the memory operation
    //memErrors.add("<Byte " + String.valueOf(index + i) + "> Original JPG: 0x" + Long.toHexString(fromFile) + " From Memory: 0x" + Long.toHexString(fromMem));
    errorCount++;

    // Write to the output log
    // If this is a failure and the previous was a match - then display the prev. too
    if (prevMatched) {
    testLog.println("========================================================================================");
    testLog.println(previousLine);
    testLog.println("========================================================================================");
    }

    testLog.println(currentLine);
    prevMatched = false;

    } else {
    prevMatched = true;
    }
    }
    }

    // Skip ahead
    index += bytesRead;

    } while (bytesRead > 0);

    Inp1.close();


    //Add a breakpoint at the printf() statement
    var Compute_Phase_Comp_Address = debugSession.symbol.getAddress("Compute_Phase_Comp")
    var ComputePhaseComp_Process = debugSession.breakpoint.add(Compute_Phase_Comp_Address);

    //Restart our Target
    debugSession.target.restart()

    // Run if already not automatically halted at main. Should halt at first BP
    if(debugSession.expression.evaluate("PC") != Compute_Phase_Comp_Address)
    {
    debugSession.target.run();
    }

    // Using an expression - get the current value of the PC
    var nPC = debugSession.expression.evaluate("PC")

    // Verify we halted at the correct address. Use the Static Java method Long.toHexString() to convert the
    // result to a hex string when logging messages
    if (nPC == Compute_Phase_Comp_Address)
    {
    script.traceWrite("SUCCESS: Halted at correct location");
    }
    else
    {
    script.traceWrite("FAIL: Expected halt at 0x" + Long.toHexString(Compute_Phase_Comp_Address) + ", actually halted at 0x" + Long.toHexString(nPC))

    script.traceSetConsoleLevel(TraceLevel.INFO)
    script.traceWrite("TEST FAILED!")
    script.traceEnd()
    java.lang.System.exit(1);
    }


    //All done
    debugServer.stop();

    script.traceSetConsoleLevel(TraceLevel.INFO)
    script.traceWrite("Test Succeeded");

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

    /##################################################################################################/

    Ki, Could you please look at my script and I am facing the issue like

    "TypeError: Cannot find function readData. "

    Here I request you to please resolve my issue to read data from a file existing in local path and write the data to output file.

    I have gone through your previous replies for the same question is e2e.ti.com/.../418590 & e2e.ti.com/.../710641 and I am unable to solve the issue.

    Please help me out


    Thanking you

    Regards,
    koti.
  • koti - you didn't answer my question about what kind of data file you are working with:
    e2e.ti.com/.../2227324

    Thanks
    ki