This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

3 bytes to 2 bytes
#1
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)
Reply


Messages In This Thread
3 bytes to 2 bytes - by savaskorkmaz - 23.01.2024, 11:35
RE: 3 bytes to 2 bytes - by admin - 23.01.2024, 12:28

Forum Jump: