From 3c46b65d0bcff676d295238e3de27dbf0f1a2b5c Mon Sep 17 00:00:00 2001
From: Bruce Flynn <brucef@ssec.wisc.edu>
Date: Wed, 5 Apr 2017 09:24:17 -0500
Subject: [PATCH] fix issue with prune_packet script

---
 edosl0util/stream.py     |  1 +
 scripts/prune_packets.py | 14 ++++----------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/edosl0util/stream.py b/edosl0util/stream.py
index 6b26b20..757a9d3 100644
--- a/edosl0util/stream.py
+++ b/edosl0util/stream.py
@@ -211,6 +211,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()
         except PacketTooShort as err:
             if self._fail_on_tooshort:
diff --git a/scripts/prune_packets.py b/scripts/prune_packets.py
index 4d110db..b242766 100755
--- a/scripts/prune_packets.py
+++ b/scripts/prune_packets.py
@@ -14,25 +14,19 @@ parser.add_argument('outfile')
 
 args = parser.parse_args()
 
-
-def pack_hdr_bytes(hdr):
-    return c.string_at(c.byref(hdr), c.sizeof(hdr))
-
-
 with open(args.outfile, 'wb') as fptr:
     idx = 0
-    for pkt in stream.PacketStream(open(args.pdsfile)):
+    for pkt in stream.jpss_packet_stream(open(args.pdsfile)):
         h1 = pkt.primary_header
         h2 = pkt.secondary_header
         if h2:
-            h1.data_length_minus1 = c.sizeof(h2) - 1
+            h1.data_length_minus1 = c.sizeof(h2)
             fptr.write(h1)
-            if pkt.stamp:
-                h2.packet_count = 0
             fptr.write(h2)
+            fptr.write('\xff')
         else:
             h1.data_length_minus1 = 0
             fptr.write(h1)
-            fptr.write('x')
+            fptr.write('\xff')
 
         idx += 1
-- 
GitLab