13.07.2020, 13:10
Since the input is split into bytes you only get bits 0..7 for each byte. The value in object logs is how the binary string looks like. You can try switching data type to 14 byte HEX.
Code:
value = event.getvalue()
function getbit(value, nr)
value = bit.rshift(value, nr)
return bit.band(value, 1) == 1
end
bytes = { value:byte(1, #value) }
b1 = bytes[ 1 ]
if b1 then
grp.checkupdate('32/1/1', getbit(b1, 0))
grp.checkupdate('32/1/2', getbit(b1, 1))
grp.checkupdate('32/1/3', getbit(b1, 2))
grp.checkupdate('32/1/4', getbit(b1, 3))
grp.checkupdate('32/1/5', getbit(b1, 4))
end
b2 = bytes[ 2 ]
if b2 then
grp.checkupdate('32/1/6', getbit(b2, 0))
grp.checkupdate('32/1/7', getbit(b2, 1))
grp.checkupdate('32/1/8', getbit(b2, 2))
grp.checkupdate('32/1/9', getbit(b2, 3))
grp.checkupdate('32/1/10', getbit(b2, 4))
grp.checkupdate('32/1/11', getbit(b2, 5))
grp.checkupdate('32/1/12', getbit(b2, 6))
grp.checkupdate('32/1/13', getbit(b2, 7))
end
grp.checkupdate('32/1/14', bytes[ 3 ])
grp.checkupdate('32/1/15', bytes[ 4 ])
grp.checkupdate('32/1/16', bytes[ 5 ])
grp.checkupdate('32/1/17', bytes[ 6 ])
grp.checkupdate('32/1/18', bytes[ 7 ])
grp.checkupdate('32/1/19', bytes[ 8 ])
grp.checkupdate('32/1/20', bytes[ 9 ])
grp.checkupdate('32/1/21', bytes[ 10 ])