Commit 8a095870 authored by Zhukov, Alexander P's avatar Zhukov, Alexander P
Browse files

Troubleshooting incorrect recored table in the epilog

parent 33955d51
......@@ -2,6 +2,7 @@
*.lvlps
/test.bin
/BPMDataRaw
/BCMData
/.idea
/venv
*.zip
......
......@@ -8,12 +8,24 @@ Created on Mon Jan 27 16:11:06 2020
from read_storage import BinaryStorage
# file = BinaryStorage('/data/BinStorage/BCMData/200210_1512_00110000_DCM.bin')
# file = BinaryStorage('/data/BinStorage/BCMData/200210_1538_00110000_DCM.bin')
file = BinaryStorage('/data/BinStorage/test.bin')
def show(record):
if 'value' in record:
value = record['value']
record['value'] = value[0]
print(record)
while True:
record = file.read()
if 'EOF' in record:
break
print(record)
show(record)
print('++++++++++++++++')
show(file[9])
file.close()
......@@ -18,7 +18,7 @@ class BinaryStorage:
def __init__(self, path):
self.file = open('/data/BinStorage/test.bin','rb')
self.file = open(path,'rb')
bytes = self.file.read(HEADER_SZ)
# print(bytes.decode())
self.rec_table = read_epilog(self.file)
......@@ -184,7 +184,7 @@ def read_record(file):
while True:
field_type = read_byte(file)
# print('Field type', field_type, hex(field_type))
print('Field type', field_type, hex(field_type))
func = parser.get(field_type, lambda file, rec: True)
result = func(file, record)
if not result:
......@@ -198,13 +198,14 @@ def read_epilog(file):
raw = array('I',file.read(4))
raw.byteswap()
num_records = raw[0]
print(num_records)
file.seek(-4-OFST_SIZE*num_records,os.SEEK_END)
# the last record is EOF, and the very last offset has nothing
raw = array('L',file.read(OFST_SIZE*(num_records-2)))
raw = array('L', file.read(OFST_SIZE*(num_records-2)))
raw.byteswap()
print('Number of records: ', len(raw))
# print(raw.itemsize)
# print(raw)
print(raw)
return raw
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment