added G4 hook to increase the timeout for serial communication

This commit is contained in:
Giles Hall committed 2014-11-28 19:28:03 +00:00
1 parent e55f11c5b9
commit e844d42275
2 files changed
+22 -6

No files matched your search

+1
View File
@@ -62,6 +62,7 @@ class Events(object):
HOME = "Home"
Z_CHANGE = "ZChange"
WAITING = "Waiting"
DWELL = "Dwelling"
COOLING = "Cooling"
ALERT = "Alert"
CONVEYOR = "Conveyor"
+21 -6
View File
@@ -77,6 +77,8 @@ gcodeToEvent = {
"M226": Events.WAITING,
"M0": Events.WAITING,
"M1": Events.WAITING,
# dwell command
"G4": Events.DWELL,
# part cooler
"M245": Events.COOLING,
@@ -637,7 +639,7 @@ class MachineCom(object):
self._changeState(self.STATE_CONNECTING)
#Start monitoring the serial port.
timeout = getNewTimeout("communication")
self.timeout = getNewTimeout("communication")
tempRequestTimeout = getNewTimeout("temperature")
sdStatusRequestTimeout = getNewTimeout("sdStatus")
startSeen = not settings().getBoolean(["feature", "waitForStartOnConnect"])
@@ -651,7 +653,7 @@ class MachineCom(object):
if line is None:
break
if line.strip() is not "":
timeout = getNewTimeout("communication")
self.timeout = getNewTimeout("communication")
##~~ Error handling
line = self._handleErrors(line)
@@ -823,7 +825,7 @@ class MachineCom(object):
### Baudrate detection
if self._state == self.STATE_DETECT_BAUDRATE:
if line == '' or time.time() > timeout:
if line == '' or time.time() > self.timeout:
if len(self._baudrateDetectList) < 1:
self.close()
self._errorValue = "No more baudrates to test, and no suitable baudrate found."
@@ -843,7 +845,7 @@ class MachineCom(object):
self._log("Trying baudrate: %d" % (baudrate))
self._baudrateDetectRetry = 5
self._baudrateDetectTestOk = 0
timeout = getNewTimeout("communication")
self.timeout = getNewTimeout("communication")
self._serial.write('\n')
self._sendCommand("M105")
self._testingBaudrate = True
@@ -879,7 +881,7 @@ class MachineCom(object):
else:
self.initSdCard()
eventManager().fire(Events.CONNECTED, {"port": self._port, "baudrate": self._baudrate})
elif time.time() > timeout:
elif time.time() > self.timeout:
self.close()
### Operational
@@ -901,7 +903,7 @@ class MachineCom(object):
### Printing
elif self._state == self.STATE_PRINTING:
if line == "" and time.time() > timeout:
if line == "" and time.time() > self.timeout:
self._log("Communication timeout during printing, forcing a line")
line = 'ok'
@@ -1246,6 +1248,19 @@ class MachineCom(object):
self.cancelPrint()
return cmd
def _gcode_G4(self, cmd):
# we are intending to dwell for a period of time, increase the timeout to match
cmd = cmd.upper()
p_idx = cmd.find('P')
s_idx = cmd.find('S')
_timeout = 0
if p_idx != -1:
# dwell time is specified in milliseconds
_timeout = int(cmd[p_idx+1:]) / 1000.0
elif s_idx != -1:
# dwell time is specified in seconds
_timeout = int(cmd[s_idx+1:])
self.timeout = getNewTimeout("communication") + _timeout
### MachineCom callback ################################################################################################