请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
部件号:CODECOMPOSER 您好,专家,
在GCv2中,联机编辑器为实现自定义编解码器提供了样板文件
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);
}
*/
};
我可以通过UART为我的自定义程序进行修改。
然而,GCv3中的内容似乎有所不同,也有 一个样板 ,但它是针对如下json数据, 我不清楚如何调整它。

我的问题是:
1.对于解码函数,我只需读取变量数据中的字符,打包所需的信息,然后通过调用“this.targetDecoder.decode"?”发送 对于数据绑定,是否应执行任何其他操作?
2.在UART流中,我将浮点数封装为四个字节,并且将有许多浮点数,因此我需要有效的解码方法来从这些字节恢复浮点数。 我注意到ArrayBuffer是一种很好的方式来将字节数转换为浮点,如C中的方法。 我可以 在 这里将变量数据更改为ArrayBuffer吗?
3.是否可以使用GUI编辑器处理~2Mbps UART流?
非常感谢!