23.01.2024, 11:35
Hi ,
I need to get value of the last 2 bytes of a 3 bytes object. I had a function for converting byte to byte shown below. I need to get byte 1 and byte 2 ( Not 0 ) as single variable.
Thanks
value = event.getvalue()
function getbyte(value, byte)
return bit.band(bit.rshift(value, byte * 8), 0xFF)
end
b0 = getbyte(value, 0)
b1 = getbyte(value, 1)
b2 = getbyte(value, 2)
I need to get value of the last 2 bytes of a 3 bytes object. I had a function for converting byte to byte shown below. I need to get byte 1 and byte 2 ( Not 0 ) as single variable.
Thanks
value = event.getvalue()
function getbyte(value, byte)
return bit.band(bit.rshift(value, byte * 8), 0xFF)
end
b0 = getbyte(value, 0)
b1 = getbyte(value, 1)
b2 = getbyte(value, 2)