test_file()

Tests a G-code file for validity.

This function loads the specified G-code file and then validates the G-code lines.

Syntax

planetcnc.test_file(filename)

Parameters

Parameter Type Description
filename str A string specifying the name of the G-code file to be tested.

Return Value

Examples

#! /usr/bin/env python 
 
import planetcnc
 
# Test the validity of a G-code file "square.nc".
result = planetcnc.test_file("square.nc")
if result == 0:
    print("G-code file is valid.")
elif result > 0:
    print(f"G-code file is invalid. Error on line {result}.")
else:
    print("G-code file test failed or an unspecified error occurred.")

See also

open_file
open_code
start_file
start_code
test_file
test_code