Closed 0xfgarcia closed 7 years ago
Hi, thank you for this tip. In a newer version a upper 'V' is used. the lower 'v' only returns a 16 bit value.
P.S.: The real bug were missing brackets around the shift operations. Now also fixed for INT48 and INT64.
3
Hi,
I'm trying to decode wmbus packet from HCA, BMETER's manufacturer:
44B0097502005851087A8C0020252F2F036E072C000F10000040559A2200007008072C000046082D00331C3A4800
From manufacturer telegram specifications:
DIF: 0x03 (3B INTEGER) VIF: 0x6E HCA VALUE: 072C00 (0x2C07 = 1127,1)
Returned VIF field value are incorrect:
{"number":1,"unit":"","tariff":0,"devUnit":0,"storageNo":0,"functionField":0,"functionFieldText":"Instantaneous value","dataField":3,"type":"VIF_HCA","exponent":0,"valueFactor":1,"VIFExtensions":[],"value":855638016}
wmbus-decoder.js
case cc.DIF_INT24:
var bytes = unpackF('Ca0/Ca1/Ca2/', payload.substr(offset, 3));
offset += 3;
value = bytes['a0'] + bytes['a1'] << 8 + bytes['a2'] << 16;
break;
I changed for:
case cc.DIF_INT24:
value = this.unpack('v', payload.substr(offset, 3));
offset += 3;
break;
With this code returned values are as expected, but I don't know if this change breaks code when parse another wmbus telegrams... New code is correct ?
{"number":1,"unit":"","tariff":0,"devUnit":0,"storageNo":0,"functionField":0,"functionFieldText":"Instantaneous value","dataField":3,"type":"VIF_HCA","exponent":0,"valueFactor":1,"VIFExtensions":[],"value":11271}
Thanks!