From f82b7bdec11ec8a6fa70ee09dae9bf0ae88ac443 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 27 May 2021 17:26:15 +0200
Subject: [PATCH] L2SS-192: Added more comments, type annotation

---
 devices/SDP_statistics.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/devices/SDP_statistics.py b/devices/SDP_statistics.py
index 53e478a2a..bb9106290 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
-- 
GitLab