Skip to content
Snippets Groups Projects
Commit 578af76e authored by Bruce Flynn's avatar Bruce Flynn
Browse files

Support packets with 0 length data.

SNPP time of day packet (APID 10) contains only headers with no
additional user data.
parent c96bb289
No related branches found
No related tags found
No related merge requests found
......@@ -5,13 +5,8 @@ import os
from collections import defaultdict, deque, namedtuple
from edosl0util import headers
from edosl0util.headers import (
GROUP_CONTINUING,
GROUP_FIRST,
GROUP_LAST,
GROUP_STANDALONE,
PrimaryHeader,
)
from edosl0util.headers import (GROUP_CONTINUING, GROUP_FIRST, GROUP_LAST,
GROUP_STANDALONE, PrimaryHeader)
from edosl0util.timecode import dt_to_cds
LOG = logging.getLogger(__name__)
......@@ -99,10 +94,10 @@ class BasicStream(object):
# data length includes h2size
total_size = h1size + h1.data_length_minus1 + 1
data_size = h1.data_length_minus1 + 1 - h2size
if self.with_data:
data = None
if self.with_data and data_size:
data = self._read(data_size)
else:
data = None
self.file.seek(data_size, os.SEEK_CUR)
self._offset += data_size
return self.Tracker(h1, h2, total_size, offset, data)
......@@ -227,8 +222,7 @@ class PacketStream(object):
if len(self._seek_cache):
return self._seek_cache.popleft()
try:
# namedtuple('Tracker', ['h1', 'h2', 'size', 'offset', 'data'])
h1, h2, data_size, offset, data = self._stream.next()
h1, h2, data_size, offset, data = next(self._stream)
except PacketTooShort as err:
if self._fail_on_tooshort:
raise
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment