Skip to content

Commit 336612d

Browse files
committed
Update circularbuffer.py
1 parent 11cf114 commit 336612d

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

wscodec/decoder/circularbuffer.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,27 @@ class CircularBufferURL:
1111
This includes at least a circular buffer with a long string of base64 encoded sample data and
1212
a short status field.
1313
14-
Instantiation decodes the status string. This must be done first because it contains error information.
14+
Instantiation decodes the status string first. It contains error information from the microcontroller running
15+
the encoder.
16+
17+
Next it locates the :ref:`ENDSTOP_BYTE` in the circular buffer string. Characters to its left are the newest.
18+
Characters to its right are the oldest. The circular buffer is unwrapped into a string where :ref:`ENDSTOP_BYTE` is
19+
the last character and the oldest data is in the first.
20+
21+
The linearised buffer is further divided into two parts:
22+
The endstop string (including the endstop itself) are at the end. It contains metadata such as the number of
23+
samples in the payload. This is preceded by the payload string, which contains a list base64-encocded
24+
environmental sensor readings. These are in chronological order oldest-to-newest reading left-to-right.
25+
26+
The decoding of the payload string is handled elsewhere.
1527
1628
Parameters
1729
----------
1830
statb64 : str
31+
Base64 encoded status string extract from a URL parameter.
1932
circb64 : str
33+
A long string containing base64 encoded samples that are organised as a circular buffer.
34+
2035
"""
2136
ELAPSED_LEN_BYTES = 4 #: Length of the endstop elapsed minutes field in bytes (including the endstop itself).
2237
ENDSTOP_LEN_BYTES = 16 #: Length of the endstop in bytes.
@@ -57,15 +72,15 @@ def _linearise(self):
5772

5873
def _decode_status(self):
5974
"""
60-
61-
:return:
75+
Instantiate a Status object. This can be over-ridden by a child of this class
76+
if the Status data needs to change in future.
6277
"""
6378
self.status = Status(self.statb64)
6479

6580
def _decode_endstop(self):
6681
"""
67-
Decodes the endstop
68-
:return:
82+
Decode the circular buffer endstop. This can be over-ridden by a child of this class
83+
if the endstop data needs to change in future.
6984
"""
7085
endstopstr = self.endstopstr
7186

0 commit comments

Comments
 (0)