如何从uint8_t类型的ctype指针访问javascript中的数据 [英] How to access the data in javascript from the ctype pointer of type uint8_t
问题描述
我在ctype uint8_t类型指针中有一些数据,我想将其读入javascript的var数组中。
I am having some data in ctype uint8_t type pointer which I want to read into the var array in javascript.
我已经做了简单的for循环来复制数据,
I have done simple for loop to copy the data,
for(var j = 0x00; j <5; j ++){
var dataReceived [j] = ptr [j];
}
但是当尝试在警报窗口中显示数据时,它显示为未定义。
but when tried to display data in alert window, it is showing "undefined".
有人可以帮助我将ctype uint8_t指针中的数据复制到var数组吗?
Can anybody help me to copy data from ctype uint8_t pointer to var array?
有没有复制数据的机制?
Is there any mechanism to copy data?
Vishal N
推荐答案
我发现a的[contents]属性指针ctypes对象可用于访问其指向的对象。
I've found that [contents] property of a pointer ctypes object can be used to access the object it points to.
尝试以下操作:
for(var j = 0x00; j < 5; j ++) {
var dataReceived[j] = ptr[j].contents;
}
这篇关于如何从uint8_t类型的ctype指针访问javascript中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!