Tests a G-code program provided as a string for validity without executing it.
planetcnc.test_code(gcode)
#! /usr/bin/env python # Test a G-code program provided as a string. gcode_program = "G00 X0 Y0\nG01 X100 Y100\nM03" result = planetcnc.test_code(gcode_program) if result == 0: print("G-code is valid.") elif result > 0: print(f"G-code error detected at line {result}.") else: print("G-code test failed or an unspecified error occurred.")