From f4eb60dc6aa48c8475bcbf114d3d474ebd1ebc3a Mon Sep 17 00:00:00 2001 From: alex-gh Date: Thu, 23 Nov 2017 13:53:01 +0100 Subject: [PATCH] Improved the checksumming speed by a factor of 1.4-3.4 --- AUTHORS.md | 1 + src/octoprint/util/comm.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 4fb77ffb..a0860229 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -85,6 +85,7 @@ date of first contribution): * [Luke McKechnie](https://github.com/galamdring) * [Peter Backx](https://github.com/pbackx) * [Josh Major](https://github.com/astateofblank) + * ["alex-gh"](https://github.com/alex-gh) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 394f9cc9..44a6605a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2472,8 +2472,8 @@ class MachineCom(object): def _do_send_with_checksum(self, command, linenumber): command_to_send = "N" + str(linenumber) + " " + command checksum = 0 - for c in command_to_send: - checksum ^= ord(c) + for c in bytearray(command_to_send): + checksum ^= c command_to_send = command_to_send + "*" + str(checksum) self._do_send_without_checksum(command_to_send)