genccode - Linux


Overview

genccode generates C source code from a given CNC code file. CNC (Computer Numerical Control) code is a language used to control machines that cut or shape materials, such as CNC routers, laser cutters, and 3D printers. G-code is a widely used CNC code dialect that genccode supports. This tool converts G-code to C arrays which can be easily used within embedded systems or other applications that require the execution of CNC code.

Syntax

genccode [options] [input.nc] [output.c]

Options/Flags

  • -v, --version: Display version information.
  • -h, --help: Display help message.
  • -o, --output: Specify the output filename.
  • --array-name: Specify the name of the output array. Default: cnc_code.
  • --suppress-comments: Suppress comment generation in the output code.
  • --include-header: Include a header file in the output code.
  • --header-file: Specify the header file to include. Default: <stdio.h>.
  • --coordinate-type: Specify the coordinate type used in the output code. Default: float.
  • --debug: Enable debug mode to display additional information during processing.

Examples

Simple Example:

genccode example.nc output.c

This will generate a C source file named "output.c" from the CNC code file "example.nc".

Complex Example:

genccode \
  --coordinate-type double \
  --include-header my_header.h \
  --output cnc.c \
  complex.nc

This will generate a C source file named "cnc.c" with double precision coordinates, including the header file "my_header.h".

Common Issues

  • Incorrect G-code syntax: Ensure that the input CNC code is syntactically correct.
  • Invalid coordinate type: The specified coordinate type must be either float or double.
  • Missing output filename: If no output filename is specified, the default name cnc_code.c will be used.

Integration

genccode can be combined with other commands for automation or advanced tasks. For example, it can be used with a scripting language to generate code dynamically or integrated into a build system to automatically generate code from CNC files.

Related Commands

  • gcode-sender: Sends G-code to a CNC machine.
  • ncpath: Generates toolpaths from CNC code.
  • OpenGCode: A cross-platform library for parsing and executing G-code.