Added hook for recieved lines
This commit is contained in:
parent
540cf4f4d9
commit
d1612e426a
1 changed files with 9 additions and 3 deletions
|
|
@ -269,6 +269,7 @@ class MachineCom(object):
|
|||
sending=self._pluginManager.get_hooks("octoprint.comm.protocol.gcode.sending"),
|
||||
sent=self._pluginManager.get_hooks("octoprint.comm.protocol.gcode.sent")
|
||||
)
|
||||
self._recieved_message_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.gcode.recieved")
|
||||
|
||||
self._printer_action_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.action")
|
||||
self._gcodescript_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts")
|
||||
|
|
@ -1399,9 +1400,6 @@ class MachineCom(object):
|
|||
self._errorValue = get_exception_string()
|
||||
self.close(is_error=True)
|
||||
return None
|
||||
if ret == '':
|
||||
#self._log("Recv: TIMEOUT")
|
||||
return ''
|
||||
|
||||
try:
|
||||
self._log("Recv: %s" % sanitize_ascii(ret))
|
||||
|
|
@ -1409,6 +1407,14 @@ class MachineCom(object):
|
|||
self._log("WARN: While reading last line: %s" % e)
|
||||
self._log("Recv: %r" % ret)
|
||||
|
||||
for name, hook in self._recieved_message_hooks.items():
|
||||
try:
|
||||
ret = hook(self, ret)
|
||||
except:
|
||||
self._logger.exception("Error while processing hook {name}:".format(**locals()))
|
||||
if ret is None:
|
||||
return ""
|
||||
|
||||
return ret
|
||||
|
||||
def _getNext(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue