Buffered fields in packets #88
Closed
tloubrieu-jpl
started this conversation in
General
Replies: 2 comments 4 replies
-
Hi @tloubrieu-jpl, You can write a converter that loops through the array and sets the accumulated element on the complete==1 index. When you use the array, just skip over the elements where complete==0 (or just check the element is not None if you use the code I wrote below). Right now I believe this is necessary because converters must retain the same number of elements along the first dimension. So your solution would be something like this: from ccsdspy import FixedLength, converters
class AccumulatedBufferConverter(converters.Converter):
def __init__(self):
pass
def convert(self, complete_array, data_array):
converted = np.zeros(data_array.shape, dtype=object)
converted[:] = None
buff = b''
for i in range(data_array.shape[0]):
buff += data_array[i].tobytes()
if completed_array[i]:
converted[i] = buff
buff = b''
return converted
...
pkt.add_converted_field(
("complete", "data"),
"accumulated_data",
AccumulatedBufferConverter()
) |
Beta Was this translation helpful? Give feedback.
3 replies
-
Good, thanks Daniel ! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have packets with this structure:
The
complete
field tells if thedata
field is complete yet or not.So if
complete==no
that means the data value to be considered needs to be concatenated with the next packetdata
field value, as long as the complete value is stillno
.So in this case, the data value we want to packet 2 is
aaaaaabbbbbcccccc
.It is important to get the values from multiple packets together as specified here because we want to apply a decompression algorithm on top of this value (we were thinking of the CCSDSpy converters) and the algorithm only works on the full data stream, in this example the value
aaaaaabbbbbcccccc
.In our case, the values for
field_A
andfield_C
of packets 3 or 4 do not matter and can be ignored, but I don't know if this would be true in similar use cases.Do you know how this could be implemented in CCSDSpy ? Maybe the converter could be an object instance which is persisted for the full CCSDS packet streams ? So that we can buffer the
data
field value until the field is complete and decompression can be applied to it ? From the documentation there https://docs.ccsdspy.org/en/latest/user-guide/converters.html is sounds to be the case.Beta Was this translation helpful? Give feedback.
All reactions