Twice as fast checksum calculation

Thanks @nophead!
This commit is contained in:
Gina Häußge 2016-03-12 09:40:33 +01:00
parent 38a47bb2a8
commit 56caa7750c

View file

@ -1854,7 +1854,9 @@ class MachineCom(object):
def _do_send_with_checksum(self, command, linenumber):
command_to_send = "N" + str(linenumber) + " " + command
checksum = reduce(lambda x, y: x ^ y, map(ord, command_to_send))
checksum = 0
for c in command_to_send:
checksum ^= ord(c)
command_to_send = command_to_send + "*" + str(checksum)
self._do_send_without_checksum(command_to_send)