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.

CODECOMPOSER: GUI Composer v3: How to implement custom codec in GCv3?

Part Number: CODECOMPOSER


Hi Expert,

In GCv2, the online editor gives a boilerplate for implementing custom codec as

CustomCodec.prototype.encode = function(target, jsonObj) {
    this.txPktCtr++;

/* TODO: Rework the following example code as required for your app:
   // The following example code shows how to encode property values from the GUI into
   // a JSON formatted string.  You would use this if you wanted to intercept data from the GUI
   // and rework it before passing it on to the target device.
   try{
        this.txMsgCtr++;
        if (this.txMsgCtr % 256){
            gc.console.log("CustomCodec","Number of tx messages to target: "+this.txMsgCtr);
        }
        var strToSend = ""; //JSON.stringify(jsonObj) +"\n";
        // send the string to the target
        target(strToSend);
    }
    catch(ex){
        gc.console.log("CustomCodec","CustomCodec.encode (to target): exception="+ex);
    }

*/
};

and I was able to modify it for my custom procotol over uart.

However, things seem getting different in GCv3, there is also a boilerplate but it is for json data as below, I am not clear how to adapt it.

My questions are:

1. For the decode function, is that I just read the characters in variable data, packet the information I needed and send it by invoking "this.targetDecoder.decode"? Is there any other things should be carried out for data binding?

2. I will packet float number as four bytes in the uart stream, and there will be many float numbers, so I need efficient decoding method to restore floats from the bytes. I notice the ArrayBuffer would be a nice way to cast the bytes to float as in C. Can I change the variable data to ArrayBuffer here?

3. Is it possible to dealing with ~2Mbps uart stream with GUI composer?

Many thanks!