From 15eda9c58f38845de5049c2e43a73c0e5eb2cf8b Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sat, 12 Oct 2019 16:45:31 -0700 Subject: [PATCH] Added log to GCode script --- scripts/log-position-to-gcode | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 scripts/log-position-to-gcode 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 -- 2.27.0