21.09.2018, 10:26
(21.09.2018, 10:04)admin Wrote: Use this event script to get specific bits from an integer value. Make sure to create bit objects manually before running it.
Code:function getbit(value, nr)
value = bit.rshift(value, nr)
return bit.band(value, 1) == 1
end
value = event.getvalue()
grp.checkupdate('1/1/1', getbit(value, 0))
grp.checkupdate('1/1/2', getbit(value, 1))
grp.checkupdate('1/1/3', getbit(value, 2))
grp.checkupdate('1/1/4', getbit(value, 3))
grp.checkupdate('1/1/5', getbit(value, 4))
grp.checkupdate('1/1/6', getbit(value, 5))
Thank you for your quick reply. What about decoding 2 or 3 byte objects?