aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/buildcommands.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/buildcommands.py')
-rw-r--r--scripts/buildcommands.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/buildcommands.py b/scripts/buildcommands.py
index 5cd2f9d3..37e47f85 100644
--- a/scripts/buildcommands.py
+++ b/scripts/buildcommands.py
@@ -283,7 +283,8 @@ class HandleCommandGeneration:
def create_message_ids(self):
# Create unique ids for each message type
msgid = max(self.msg_to_id.values())
- for msgname in self.commands.keys() + [m for n, m in self.encoders]:
+ mlist = list(self.commands.keys()) + [m for n, m in self.encoders]
+ for msgname in mlist:
msg = self.messages_by_name.get(msgname, msgname)
if msg not in self.msg_to_id:
msgid += 1
@@ -546,17 +547,17 @@ class HandleIdentify:
# Write data dictionary
if options.write_dictionary:
- f = open(options.write_dictionary, 'wb')
+ f = open(options.write_dictionary, 'w')
f.write(datadict)
f.close()
# Format compressed info into C code
- zdatadict = zlib.compress(datadict, 9)
+ zdatadict = bytearray(zlib.compress(datadict.encode(), 9))
out = []
for i in range(len(zdatadict)):
if i % 8 == 0:
out.append('\n ')
- out.append(" 0x%02x," % (ord(zdatadict[i]),))
+ out.append(" 0x%02x," % (zdatadict[i],))
fmt = """
const uint8_t command_identify_data[] PROGMEM = {%s
};
@@ -595,7 +596,7 @@ def main():
# Parse request file
ctr_dispatch = { k: v for h in Handlers for k, v in h.ctr_dispatch.items() }
- f = open(incmdfile, 'rb')
+ f = open(incmdfile, 'r')
data = f.read()
f.close()
for req in data.split('\n'):
@@ -609,7 +610,7 @@ def main():
# Write output
code = "".join([FILEHEADER] + [h.generate_code(options) for h in Handlers])
- f = open(outcfile, 'wb')
+ f = open(outcfile, 'w')
f.write(code)
f.close()