Nextnbits() – Teledyne LeCroy FireInspector - File Based Decoding User Manual
Page 48

42
CATC S
CRIPTING
L
ANGUAGE
1.0
C
HAPTER
12
Reference Manual
Primitives
result = C
# The result is given in
hexadecimal. The result in binary is 1100.
In the call to
GetNBits
: starting at bit 2, reads 4 bits (1100), and returns the value
0xC.
NextNBits()
NextNBits (
Return value
None.
Comments
Reads
bit_count
bits from the data source specified in the last call to
GetNBits
, starting after the last bit that the previous call to
GetNBits
or
NextNBits
returned. If called without a previous call to
GetNBits
, the result is
undefined. Note that bits are indexed starting at bit 0.
Example
raw = 'FOFO';# 1111000011110000 binary
result1 = GetNBits ( raw, 2, 4 );
result2 = NextNBits(5);
result3 = NextNBits(2);
Trace ( "result1 = ", result1, "result2 = ", result2,
"result3 = ", result3 );
This will generate this trace output:
result1 = C result2 = 7 result3 = 2
In the call to
GetNBits
: starting at bit 2, reads 4 bits (1100), and returns the value
0xC.
In the first call to
NextNBits
: starting at bit 6, reads 5 bits (00111), and returns
the value 0x7.
In the second call to
NextNBits
: starting at bit 11 ( = 6 + 5 ), reads 2 bits (10),
and returns the value 0x2.
Parameter
Meaning
Default Value
Comments
bit_count integer