Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Modbus:在nodejs中将十六进制值转换为dword_Node.js_Hex_Dword - Fatal编程技术网

Node.js Modbus:在nodejs中将十六进制值转换为dword

Node.js Modbus:在nodejs中将十六进制值转换为dword,node.js,hex,dword,Node.js,Hex,Dword,使用modbus作为通信协议的仪表手册中给出的规范: “dword” refers to 32-bit unsigned integer using two data addresses and 4 bytes of memory with high word at the front and low word at the end, it varies from 0 to 4294967295. rx = high word *65536+low word 我有这个十六进制值:00003ef

使用modbus作为通信协议的仪表手册中给出的规范:

“dword” refers to 32-bit unsigned integer using two data addresses and 4 bytes
of memory with high word at the front and low word at the end, it varies from 0
to 4294967295. rx = high word *65536+low word
我有这个十六进制值:
00003ef5

其中
highword=0000
lowword=3ef5

因此,rx将是
3ef5
,并将其转换为十进制,得到
16117

目前,我使用了以下方法:

var rx = hexValue.substr(0,4)*65536 + hexValue.substr(4,8);
console.log(parseInt(rx,16));

有没有一种方法可以使用nodejs缓冲库或其他更好的方法将我的十六进制值直接转换为dword?

有没有解决方法,我有一个c代码
(BYTE*)&buf[0]
,我想将它转换为javascript。我使用了缓冲区,但如何将其转换为
字节
单词
DWORD