ihex: fix writer str/bytes confusion

The HEX writer was never tested/used before and didn't work. Some
leftovers from the Python 2 conversion are the culprit.
This commit is contained in:
Grigori Goronzy 2021-01-03 15:51:48 +01:00
parent b3741af045
commit ad5a532ab9

View File

@ -155,8 +155,8 @@ class IHex:
def make_line(self, line_type, addr, data):
line = struct.pack(">BHB", len(data), addr, line_type)
line += data
line += chr(self.calc_checksum(line))
return ":" + line.encode("hex").upper() + "\r\n"
line += bytes([self.calc_checksum(line)])
return ":" + line.hex().upper() + "\r\n"
def write(self):
"""Write Intel HEX data to string"""
@ -207,7 +207,7 @@ class IHex:
output += self.make_line(
0x05, 0, struct.pack(">I", self.start))
output += self.make_line(0x01, 0, "")
output += self.make_line(0x01, 0, b"")
return output
def write_file(self, fname):