code wiki / (root) / nx_gcode_emit_test.nx

nx_gcode_emit_test.nx

buildroot/runtime/nx_gcode_emit_test.nx

4216 B111 linesdepth 10pulls 23 transitivereach 0 importersview sourcekind gate/prooftopic gcode
docsdependenciesstructsconstsfunctions

about

nx_gcode_emit_test.nx -- end-to-end compose: hand-built unit square contour + Qidi X-Max 3 + Generic PLA -> emit full G-code file structure (preamble + layer + postamble) + verify the output contains expected G-code keywords. Closed-form invariants: (a) Emitter constructs OK; filament_xsect precomputed sane (positive Q14 value, ~39408 for 1.75mm filament). (b) Preamble emits successfully; output contains "M104 S215" (Generic PLA first-layer hotend) and "G28" (home all). (c) Per-layer emit produces non-zero output length growth. (d) Output contains "G1 X" (print moves). (e) Output contains "E" (extruder accumulation). (f) Postamble adds "M104 S0" (hotend off) and "M84" (motors off). (g) E_acc_q14 is non-zero after layer emit (filament was fed). (h) E_acc_q14 ~= perimeter_mm * E_per_mm; for a 1mm square perimeter = 4mm, E_per_mm ~= 0.0333 mm filament/mm move, so total E ~= 0.1332 mm ~= 2182 Q14 (±100 tolerance). (i) Final length is reasonable (200..10000 bytes for this case). expect_exit: 0 license_tier: ORIGINAL

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_polygon.nx nx_slice_contour.nx nx_machine_graph.nx nx_material_profile.nx nx_gcode_emit.nx nx_gcode_extrude.nx nx_gcode_emit_test.nx

imports: nx_syscalls.nxnx_polygon.nxnx_slice_contour.nxnx_machine_graph.nxnx_material_profile.nxnx_gcode_emit.nxnx_gcode_extrude.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_machine_graph_qidi_xmax nx_machine_graph_alloc sys_mmap nx_material_profile_generi nx_material_profile_alloc sys_mmap ↻ nx_gemit_new sys_mmap ↻ nx_gcex_filament_xsect_q14 nx_muldiv_i64 nx_i128_alloc nx_i128_mul_i64 nx_i128_mul_u64 nx_i128_neg nx_i128_div_i64 nx_i128_is_neg nx_i128_neg ↻ nx_i128_udiv_u64 nx_gemit_preamble nx_gemit_cstr nx_gemit_byte nx_gemit_int sys_mmap ↻ nx_int_to_decimal nx_fmt_reverse nx_gemit_bytes nx_gemit_byte ↻ nx_gemit_q14 sys_mmap ↻ nx_q14_to_decimal nx_int_to_decimal ↻ nx_gemit_bytes ↻ smoke_contains nx_polygon_make_square nx_polygon_alloc sys_mmap ↻ nx_polygon_add_vert nx_polygon_set_vert nx_polygon_vert_ptr

structs

none

consts

32const Q14: i64 = 16384

functions

35func smoke_contains(buf: *u8, len: i64, needle: *u8) -> i64
called by 1: main
54func main() -> i64