Created
November 30, 2013 00:22
-
-
Save jboone/7713722 to your computer and use it in GitHub Desktop.
Quick code to locate discontinuities in a test capture file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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