Add offset to binary dump filename to fix clashes with multiple binaries
of e.g. component firmwares.
This commit is contained in:
parent
e07338c882
commit
28480970c4
@ -141,22 +141,25 @@ class Gcd:
|
|||||||
f.write("# Lengths are informational only, they will be calculated upon reassembly.\n")
|
f.write("# Lengths are informational only, they will be calculated upon reassembly.\n")
|
||||||
for tlv in self.struct:
|
for tlv in self.struct:
|
||||||
if tlv.is_binary:
|
if tlv.is_binary:
|
||||||
outfile = "{}_{:04x}.bin".format(output_basename, tlv.type_id)
|
if outfile is None:
|
||||||
if outfile != last_filename:
|
outfile = "{}_{:04x}_{:x}.bin".format(output_basename, tlv.type_id, tlv.offset)
|
||||||
self.write_dump_block(f, str(ctr))
|
self.write_dump_block(f, str(ctr))
|
||||||
self.write_dump_param(f, "from_file", outfile)
|
self.write_dump_param(f, "from_file", outfile)
|
||||||
for item in tlv.dump():
|
for item in tlv.dump():
|
||||||
self.write_dump_param(f, item[0], item[1], item[2])
|
self.write_dump_param(f, item[0], item[1], item[2])
|
||||||
last_filename = outfile
|
|
||||||
with open(outfile, "wb") as of:
|
with open(outfile, "wb") as of:
|
||||||
of.write(tlv.value)
|
of.write(tlv.value)
|
||||||
else:
|
else:
|
||||||
with open(outfile, "ab") as of:
|
with open(outfile, "ab") as of:
|
||||||
of.write(tlv.value)
|
of.write(tlv.value)
|
||||||
|
# if tlv.length < MAX_BLOCK_LENGTH:
|
||||||
|
# # Reset outfile name, so should new binary block begin, dump that to new file
|
||||||
|
# outfile = None
|
||||||
elif tlv.type_id == 0xffff:
|
elif tlv.type_id == 0xffff:
|
||||||
# EOF marker
|
# EOF marker
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
outfile = None
|
||||||
tlvinfo = tlv.dump()
|
tlvinfo = tlv.dump()
|
||||||
if len(tlvinfo) > 0:
|
if len(tlvinfo) > 0:
|
||||||
self.write_dump_block(f, str(ctr))
|
self.write_dump_block(f, str(ctr))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user