Skip to content

Instantly share code, notes, and snippets.

@jboone
Created November 30, 2013 00:22
Show Gist options
  • Save jboone/7713722 to your computer and use it in GitHub Desktop.
Save jboone/7713722 to your computer and use it in GitHub Desktop.
Quick code to locate discontinuities in a test capture file.
#!/usr/bin/env python
import sys
import numpy
f = open(sys.argv[1], 'rb')
d = f.read(2)
test_data = numpy.arange(-128, 126, dtype=numpy.int8)
n = 2
last_n = 2
while True:
d = numpy.fromfile(f, dtype=numpy.int8, count=254)
if len(d) != 254:
break
if numpy.array_equal(d, test_data) != True:
print('%d: %d' % (n, n - last_n))
last_n = n
while f.read(1) != '\x7d':
n += 1
n += 1
n += len(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment