通信プロトコルとして 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
私はこの hexValue を持っています: 00003ef5
.
どこhighword = 0000
とlowword = 3ef5
したがって、rx は になり3ef5
、これを 10 進数に変換すると が得られ16,117
ます。
今のところ私はこれを使用しました:
var rx = hexValue.substr(0,4)*65536 + hexValue.substr(4,8);
console.log(parseInt(rx,16));
nodejsバッファライブラリまたはこれよりも優れた他の方法を使用して、16進値を直接dwordに変換する方法はありますか?