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: gui composer to a .txt text file

Tool/software: Code Composer Studio

I'm working on a collect data project, and I need to save the tables send to a textbox as a file text.
Have anyone know how to save a file from gui composer to a .txt text file?

  • Hi Lucas,
    Could you let us know which target communication method you are using to get your data from the device? Is it just ASCII data or binary data saved in a text file?

    Thanks,
    martin
  • Hi Martin.
    Thank you for response. I'm using Json protocol to send ASCII data to a ti_tile_textbox. I'd like to use a button to download the data shown in the textbox.

  • Hi Lucas, 

    My apologies for delayed response. We have put together an example that hopefully will help. URL below points to an application that is visible in Gallery that has a sample implementation of how to save data to a file. I would suggest that you first click on link below, which should show the sample application in Gallery, and then click on App tile to activate the application. There are some instructions in Readme that should pop up to help guide you. After you verify its functionality, please import it into GC Designer. You would do this by clicking in dial icon (GUI Composer icon) to import it into designer, on first screen after clicking on link below. You will then be able to perform actions that are described in readme, which you can access from Project->Edit Readme menu. 

  • Thank you very much for the example you developed.
    It has helped me a lot, and it's working perfectly.
    But, I have now another question, how to write in the text area via uart using JSON?
    I need to make a Message Console.
    Thanks for the help.

  • customCodec_0.js
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /*
    * gc global variable provides access to GUI Composer infrastructure components and project information.
    * For more information, please see the Working with Javascript guide in the online help.
    */
    var gc = gc || {};
    gc.services = gc.services || {};
    /*
    * Boilerplate code for encoding and decoding data transmitted to / received from TI devices.
    */
    /**
    * This code implements the IPacketCodec interface.
    *
    * @constructor
    * @implements gc.databind.IPacketCodec
    */
    CustomCodec = function()
    {
    };
    CustomCodec.prototype.rxPktCtr = 0;
    CustomCodec.prototype.rxMsgCtr = 0;
    CustomCodec.prototype.txPktCtr = 0;
    CustomCodec.prototype.txMsgCtr = 0;
    CustomCodec.prototype.strRxBuffer = "";
    CustomCodec.prototype.strTxBuffer = "";
    CustomCodec.prototype.isConnect = false;
    CustomCodec.prototype.initComplete = false;
    /**
    * Encodes data into a packet for sending to the target device.
    *
    * @param target - function to call to pass on the encoded data towards the target
    * @param data - The data object from the GUI that is to be encoded into a packet for sending.
    */
    CustomCodec.prototype.encode = function(target,data){
    this.txPktCtr++;
    /* The following example code shows how to decode JSON strings going down to the target
    into a Javascript object. You would use this if you wanted to intercept data from the GUI
    and rework it before passing it on to the target device.
    this.txMsgCtr++;
    if (this.txMsgCtr % 256){
    console.log("Number of tx messages to target: "+this.txMsgCtr);
    }
    var strToSend = JSON.stringify(jsonObj) +"\n";
    // send the string to the target
    target(strToSend);
    }
    catch(ex){
    console.log("CustomCodec.encode (to target): exception="+ex);
    }
    }
    */
    };
    /**
    * Decodes packets from the target device into data objects. One object for each packet of data.
    * Unless you have chained your custom codec with the CR codec, the packet data is not framed,
    * so this method is responsible for decoding partial packets as well as multiple packets. Partial packets
    * should not be returned, but deferred until the next decode method call with more raw data to process. As a
    * result, this method may return 0 or more packets of data on each invocation.
    *
    * @param target - function to call to pass on the encoded data towards the GUI
    * @param data - The raw data received that needs to be decoded from packets into objects.
    * @return - true if connected (i.e. valid data received), false if not connected
    */
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Hi Lucas,

    This is a bit tricky to provide instructions, but hopefully I will not miss a step.

    You would need open project properties and click on Next to get to Target Communication page and click on uart node (where you pick the device) and change the protocol to "custom". You would then go to File->New ->Custom Codec File ,which will add a new file to your project.

    You would then need to open that (click on Folder toolbar button to show projects view) and double click on customCodec_0.js file to open it in editor.  Copy entire line #127 (templateObj=...) and paste it just below line #111 (inside init function).

    Now uncomment lines 76 -96. This sample code parses JSON objects thus you do not need to change this code. However, you can now insert your own code to update textarea in this function. e.g. insert

        templateObj.$.textArea.value += strMessage;

    on line #89.   textArea is the widgetID, thus it needs to match whatever widget you are trying to send data to.

    I have attached a .js that should have all these changes