How to get 20 of 24 bits in a LITTLE-ENDIAN Coding?
I am writing my LUA-Code in order to decode a UDP-Payload. I need to read JUST the first 20 bits of the following 3 bytes in a LITTLE-ENDIAN decoding:
I tried with the following function:
::subtree:add_le((buffer:range(79, 3):bitfield(0, 20)):le_uint())
But I get this error:
::Lua Error: ...oftware\WiresharkPortable\App\Wireshark\diagnose_118.lua:94: attempt to index a number value
The bytes seen in the payload of the UDP-Message may be the following:
BIG-ENDIAN -->FF 35 50
LITTLE-ENDIAN -->50 35 FF
The hexadecimal-data interesting for me is --> 0 35 FF --> 0000 0011 0101 1111 1111
The problem appears when I introduce the function bitfield - I cannot avoid it as I just want the first 20 bits and not the whole 24. Do you know another different way to fulfill my purpose? Many thanks in advance! :)