 # Decimal offset bufer.parser

Hi,

The buffer parser node doesn't allow decimal values at box length and offset box. I need to get the value in group of bits smaller than 8 bits=1byte, in this example, 3 bits representation. How can I do it?

Hi.

That makes no sense. If you want a value from parts of a byte, then either use the mask and scale or do it outside of the buffer parser.

E.g a mask of 0x07 will give you the value of first 3 bits.
so value `1111 1111` + mask `0000 0111` will become `0000 0111` == 7

E.g. a mask of 0xe0 will give you the value in 3 msb bits. You then scale that by `0.03125` (to shift bits 5 places to the right)
so value `1111 1111` + mask `1110 0000` will become (`1110 0000` * `0.03125`) == `0000 0111` == 7

NOTE:
Scale `0.25` is the same as Right Shift 2 or `1 / Math.pow(2,2)` - i.e. shift right 2 bits
Scale `0.125` is the same as Right Shift 3 or `1 / Math.pow(2,3)` - i.e. shift right 3 bits
Scale `0.0625` is the same as Right Shift 4 or `1 / Math.pow(2,4)` - i.e. shift right 4 bits
Scale `0.03125` is the same as Right Shift 5 or `1 / Math.pow(2,5)` - i.e. shift right 5 bits
Scale `0.015625` is the same as Right Shift 6 or `1 / Math.pow(2,5)` - i.e. shift right 6 bits

EDIT - just noticed I dont offer the `scale` option for single byte values (not sure why my node doesnt permit that!). So, for now, you will need to bit shift the byte values in a function node. So in otherwords, use the MASK options in the buffer parser (to drop bits you are not interested in) then in the function node, right shift the values by the required amount.

And what if the shift takes another byte? for instance.

00 00000000
59 00111011

preamble takes first 3 bits so:

stationtype takes the rest byte and part of the next with a total of 1 length so,

(mask 3 0s and 13 1s)

However, it doesn't work. I cannot offset 67 because it will pass a required byte.

The logic is:

pre stationtype other
000 00000001 11011

no bold offset 66 and bold offset 67. The value of stationtype should be 5, however, I'm getting values above 60

^ This suggests the data is actually 16 bits - so we can use UINT16BE for both pre-amble and station type...

• set both entries to UINT16 (BE)
• set preable to Offset 66 and mask to `0xE000` and scale to `0.0001220703125` (shift right 13 bits)
• set stationType to Offset 66 and mask to `0x1FFF` and scale to `0`

For some reason, the scale value in station type doesn't set to 0.

`0` or `1` (doesnt matter)

• `0` means - dont scale.
• `1` means multiply by 1 e.g. `1 x 100 == 100`, `1 x 69.123 = 69.123`, etc etc.

It gives me value 89

Sorry, I am not psychic. I have no idea how your flow is written, nor what values you are sending in, nor do I know what value you should be getting.

1 Like