Skip to content

Commit

Permalink
[Bugfix] Fix "ok" handling in G30.
Browse files Browse the repository at this point in the history
Signed-off-by: Juri Berlanda <[email protected]>
  • Loading branch information
j-be committed Oct 14, 2021
1 parent aa8e4c8 commit 42d865d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion octoprint_autobim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AutobimPlugin(
def __init__(self):
super(AutobimPlugin, self).__init__()
self.g30 = None
self.g30_tester = None
self.m503 = None
self.handlers = []
self.running = False
Expand All @@ -38,11 +39,15 @@ def __init__(self):

def on_after_startup(self):
self.g30 = G30Handler(self._printer)
self.g30_tester = G30Handler(self._printer, False)
self.m503 = M503Handler(self._printer)

self.handlers = [
self.g30,
self.g30_tester,
self.m503,
]

self._logger.info("AutoBim *ring-ring*")

##~~ AssetPlugin mixin
Expand Down Expand Up @@ -120,7 +125,7 @@ def on_api_command(self, command, data):

def on_test_point(self, point):
self._logger.info("Got X%s, Y%s" % point)
result = self.g30.do(point, 30)
result = self.g30_tester.do(point, 30)
if result.has_value():
self._plugin_manager.send_plugin_message(
self._identifier,
Expand Down
5 changes: 3 additions & 2 deletions octoprint_autobim/g30.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@


class G30Handler(AsyncCommand):
def __init__(self, printer):
def __init__(self, printer, ignore_ok=True):
super(G30Handler, self).__init__()
self._printer = printer
self._ok_is_error = not ignore_ok
# TODO: Move pattern to settings
self.pattern = re.compile(r"^Bed X: -?\d+\.\d+ Y: -?\d+\.\d+ Z: (-?\d+\.\d+)$")

Expand All @@ -19,7 +20,7 @@ def _start(self, point):
self._printer.commands("G30 X%s Y%s" % point)

def _handle_internal(self, line):
if "ok" == line:
if self._ok_is_error and "ok" == line.strip():
self._register_result(Result.error())
return

Expand Down

0 comments on commit 42d865d

Please sign in to comment.