From: Joseph Coffland Date: Sat, 12 Oct 2019 23:45:31 +0000 (-0700) Subject: Added log to GCode script X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=15eda9c58f38845de5049c2e43a73c0e5eb2cf8b;p=bbctrl-firmware Added log to GCode script --- diff --git a/scripts/log-position-to-gcode b/scripts/log-position-to-gcode new file mode 100755 index 0000000..7597fb4 --- /dev/null +++ b/scripts/log-position-to-gcode @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import json +import sys + +p = [0, 0, 0] + + +print('F400 G21') + +for line in sys.stdin: + try: + if not line.startswith('I:Comm:> '): continue + line = line[9:] + + data = json.loads(line) + + changed = False + for axis in range(3): + var = 'xyz'[axis] + 'p' + if var in data: + p[axis] = data[var] + changed = True + + if changed: print('G1 X%d Y%d Z%d' % tuple(p)) + + except json.decoder.JSONDecodeError: pass