fix dumpLog.py
This commit is contained in:
@@ -31,29 +31,35 @@ def readLogFile(filename, verbose = True):
|
|||||||
print('Columns:'),
|
print('Columns:'),
|
||||||
print(ncols)
|
print(ncols)
|
||||||
|
|
||||||
# Read data
|
lenChunk = sz
|
||||||
wholeFile = f.read()
|
|
||||||
# split by alignment word
|
|
||||||
chunks = wholeFile.split(b'\xaa\xbb')
|
|
||||||
log = list()
|
log = list()
|
||||||
if verbose:
|
|
||||||
print("num chunks:")
|
|
||||||
print(len(chunks))
|
|
||||||
chunkIndex = 0
|
chunkIndex = 0
|
||||||
for chunk in chunks:
|
while (lenChunk):
|
||||||
print("len(chunk)=",len(chunk)," sz = ", sz)
|
check = f.read(2)
|
||||||
if len(chunk) == sz:
|
lenChunk = 0
|
||||||
print("chunk #",chunkIndex)
|
if (check == b'\xaa\xbb'):
|
||||||
chunkIndex=chunkIndex+1
|
mychunk = f.read(sz)
|
||||||
values = struct.unpack(fmt, chunk)
|
lenChunk = len(mychunk)
|
||||||
record = list()
|
chunks = [mychunk]
|
||||||
for i in range(ncols):
|
if verbose:
|
||||||
record.append(values[i])
|
print("num chunks:")
|
||||||
if verbose:
|
print(len(chunks))
|
||||||
print(" ",keys[i],"=",values[i])
|
|
||||||
|
for chunk in chunks:
|
||||||
log.append(record)
|
print("len(chunk)=",len(chunk)," sz = ", sz)
|
||||||
|
if len(chunk) == sz:
|
||||||
|
print("chunk #",chunkIndex)
|
||||||
|
chunkIndex=chunkIndex+1
|
||||||
|
values = struct.unpack(fmt, chunk)
|
||||||
|
record = list()
|
||||||
|
for i in range(ncols):
|
||||||
|
record.append(values[i])
|
||||||
|
if verbose:
|
||||||
|
print(" ",keys[i],"=",values[i])
|
||||||
|
|
||||||
|
log.append(record)
|
||||||
|
else:
|
||||||
|
print("Error, expected aabb terminal")
|
||||||
return log
|
return log
|
||||||
|
|
||||||
|
|
||||||
@@ -64,11 +70,11 @@ print ('Argument List:', str(sys.argv))
|
|||||||
fileName = "log.bin"
|
fileName = "log.bin"
|
||||||
|
|
||||||
if (numArgs>1):
|
if (numArgs>1):
|
||||||
fileName = sys.argv[1]
|
fileName = sys.argv[1]
|
||||||
|
|
||||||
print("filename=")
|
print("filename=")
|
||||||
print(fileName)
|
print(fileName)
|
||||||
|
|
||||||
verbose = True
|
verbose = True
|
||||||
|
|
||||||
readLogFile(fileName,verbose)
|
readLogFile(fileName,verbose)
|
||||||
|
|||||||
Reference in New Issue
Block a user