count_packets

ccsdspy.utils.count_packets(file, return_missing_bytes=False)[source]

Count the number of packets in a file and check if there are any missing bytes in the last packet.

This function works with mixed files containing multiple APIDs, which may include both fixed length and variable length packets. When used with multiple APIDs, it simply returns the total number of packets of any APID.

If end of last packet doesn’t align with end of file, a warning is issued.

Parameters:
filestr, file-like

Path to file on the local file system, or file-like object

return_missing_bytesbool, optional

Also return the number of missing bytes at the end of the file. This is the number of bytes which would need to be added to the file to complete the last packet expected (as set by the packet length in the last packet’s primary header).

Returns:
num_packetsint

Number of complete packets in the file

missing_bytesint, optional

The number of bytes which would need to be added to the file to complete the last packet expected (as set by the packet length in the last packet’s primary header).