diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 8fb0bf23..24b9c838 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2036,11 +2036,21 @@ class MachineCom(object): old_written = written try: - written += self._serial.write(to_send) + result = self._serial.write(to_send) + if result is None or not isinstance(result, int): + # probably some plugin not returning the written bytes, assuming all of them + written += len(cmd) + else: + written += result except serial.SerialTimeoutException: self._log("Serial timeout while writing to serial port, trying again.") try: - written += self._serial.write(to_send) + result = self._serial.write(to_send) + if result is None or not isinstance(result, int): + # probably some plugin not returning the written bytes, assuming all of them + written += len(cmd) + else: + written += result except: if not self._connection_closing: self._logger.exception("Unexpected error while writing to serial port")