diff --git a/devices/SDP_statistics.py b/devices/SDP_statistics.py index 53e478a2adadd62f0d4073a19ce73d4a1c83dce7..bb9106290b67de2b1b4f9944cbea5708ee5faa1e 100644 --- a/devices/SDP_statistics.py +++ b/devices/SDP_statistics.py @@ -4,8 +4,13 @@ import numpy __all__ = ["StatisticsPacket"] -def extract_bits(value, first, last=None): - """ Return bits [first:last] from value. If last is not given, the value of bit 'first' is returned. Bit 0 = LSB. """ +def extract_bits(value: bytes, first: int, last:int=None) -> int: + """ Return bits [first:last] from value, and return their integer value. Bit 0 = LSB. + + For example, extracting bits 2-3 from b'01100' returns 11 binary = 3 decimal: + extract_bits(b'01100', 2, 3) == 3 + + If last is not given, just the value of bit 'first' is returned. """ # default last to first if last is None: @@ -161,7 +166,7 @@ class StatisticsPacket(object): } @property - def payload_sst(self): + def payload_sst(self) -> numpy.array: """ The payload of this packet, interpreted as SST data. """ # derive which and how many elements to read from the packet header