API Reference
Overview
The GCode API is a library for streaming G-code commands to Galil DMC motion controllers. It provides both a C API for cross-language compatibility and a C++ wrapper for convenient RAII-based resource management.
The API works seamlessly with G-Code specified in inches or millimeters.
Simply ensure your project maintains consistent units throughout all commands and configurations.
Setup
To use the GCode API in your project:
- Add the appropriate header to your include path:
gcode_api.hfor C projectsgcode_api.hppfor C++ projects (includes the C header automatically)
- Link against
gcode_api.lib(Release) orgcode_apid.lib(Debug).
Both headers and libraries are located in the root of your installation directory. The path is available via the GALIL_GCODES environment variable set during installation.
API Documentation
C API
Low-level C interface suitable for cross-language bindings and direct integration.
C++ Wrapper
Header-only C++ wrapper with RAII resource management and convenient method syntax.
Python API
ctypes-based Python wrapper with context manager support and Pythonic error handling.
Error Codes
Complete reference of error codes returned by API functions.
Callbacks
Event callbacks for monitoring command execution, errors, and state changes.
Quick Example
Here's a minimal C++ example to get started:
#include "gcode_api.hpp"
int main() {
GCode gcode("your-license-key-here");
if (gcode.Connect("192.168.1.100") != GCODE_OK) {
return 1;
}
gcode.ConfigureLinearAxis('X', 'A', 1000.0, 100.0);
gcode.ConfigureLinearAxis('Y', 'B', 1000.0, 100.0);
gcode.AddCommand("G1 X10 Y10 F100");
gcode.Start();
gcode.WaitForQueueEmpty();
return 0;
}See the C++ Wrapper documentation for complete examples.