chiark / gitweb /
Fix serial communication issues due to buffer overflow
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Fri, 2 Jan 2015 08:15:38 +0000 (03:15 -0500)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Fri, 2 Jan 2015 08:21:23 +0000 (03:21 -0500)
This issue is caused by the Marlin firmware filling up its command buffer queue
and then keeping commands on the serial buffer (which is limited to 64 bytes)
which eventually causes a buffer overflow and data is lost.
By sending only 2 commands to be queued, we ensure that we are not always catching up
but we also make sure that we cause no checksum issues.
Anyways, when a checksum issue happens and Marlin asks for a resend,
we end up sending one command at a time with nothing in Marlin's queue,
so this makes it even more efficient.
Note: Pronterface only sends one command at a time and does not fill up
Marlin's queue, that's why it doesn't have the checksum issues.
This really fixes the underlying cause for issue #66

Cura/util/machineCom.py

index fbe609c2fa7f08e9af7226ce10c68a008b38284c..5fe86611c4aacdfe77b14981a1b54bd74c74f0da 100644 (file)
@@ -619,7 +619,7 @@ class MachineCom(object):
                self._printSection = 'CUSTOM'
                self._changeState(self.STATE_PRINTING)
                self._printStartTime = time.time()
-               for i in xrange(0, 4):
+               for i in xrange(0, 2):
                        self._sendNext()
        
        def cancelPrint(self):
@@ -629,7 +629,7 @@ class MachineCom(object):
        def setPause(self, pause):
                if not pause and self.isPaused():
                        self._changeState(self.STATE_PRINTING)
-                       for i in xrange(0, 6):
+                       for i in xrange(0, 2):
                                self._sendNext()
                if pause and self.isPrinting():
                        self._changeState(self.STATE_PAUSED)