Enums and messages

Enums

TaskMode

enum TaskMode {
  TASK_MODE_UNSPECIFIED = 0;
  MODE_MANUAL = 1;  // Manual/jog mode
  MODE_AUTO = 2;    // Auto/program mode
  MODE_MDI = 3;     // MDI mode
}

TaskState

enum TaskState {
  TASK_STATE_UNSPECIFIED = 0;
  STATE_ESTOP = 1;        // E-stop active
  STATE_ESTOP_RESET = 2;  // E-stop reset, machine off
  STATE_ON = 3;           // Machine on
  STATE_OFF = 4;          // Machine off
}

InterpState

enum InterpState {
  INTERP_STATE_UNSPECIFIED = 0;
  INTERP_IDLE = 1;     // Interpreter idle
  INTERP_READING = 2;  // Reading program
  INTERP_PAUSED = 3;   // Program paused
  INTERP_WAITING = 4;  // Waiting for input
}

ExecState

enum ExecState {
  EXEC_STATE_UNSPECIFIED = 0;
  EXEC_ERROR = 1;
  EXEC_DONE = 2;
  EXEC_WAITING_FOR_MOTION = 3;
  EXEC_WAITING_FOR_MOTION_QUEUE = 4;
  EXEC_WAITING_FOR_IO = 5;
  EXEC_WAITING_FOR_MOTION_AND_IO = 6;
  EXEC_WAITING_FOR_DELAY = 7;
  EXEC_WAITING_FOR_SYSTEM_CMD = 8;
  EXEC_WAITING_FOR_SPINDLE_ORIENTED = 9;
}

RcsStatus

enum RcsStatus {
  RCS_STATUS_UNSPECIFIED = 0;
  RCS_DONE = 1;   // SendCommand: dispatched; WaitComplete: finished, a later command echoed, or nothing to wait on
  RCS_EXEC = 2;   // WaitComplete: not seen to finish
  RCS_ERROR = 3;  // Refused, failed or not known
}

JogType

enum JogType {
  JOG_STOP = 0;       // Stop jogging
  JOG_CONTINUOUS = 1; // Continuous jog at velocity
  JOG_INCREMENT = 2;  // Incremental jog
}

HalType

enum HalType {
  HAL_TYPE_UNSPECIFIED = 0;
  HAL_BIT = 1;    // Boolean
  HAL_FLOAT = 2;  // Double precision float
  HAL_S32 = 3;    // Signed 32-bit integer
  HAL_U32 = 4;    // Unsigned 32-bit integer
  HAL_S64 = 5;    // Signed integer that does not fit 32 bits
  HAL_U64 = 6;    // Unsigned integer that does not fit 32 bits
  HAL_PORT = 7;   // Port type (advanced)
}
  • HAL_S64 and HAL_U64 are only reported for a value that does not fit 32 bits. HAL itself has no separate 64-bit types.
  • A port has no value the server can read, so a port pin is reported with an empty value. Its type is HAL_PORT where LinuxCNC’s hal module reports the type, and HAL_TYPE_UNSPECIFIED where it does not (LinuxCNC 2.9).
  • Where HAL lists no type for a name (parameters on LinuxCNC 2.9), the type is worked out from the value: an integer up to 2147483647 is HAL_S32, a larger one HAL_U32. An unsigned parameter holding 2147483647 or less is therefore reported as HAL_S32.

PinDirection

enum PinDirection {
  PIN_DIR_UNSPECIFIED = 0;
  HAL_IN = 1;   // Input (component reads)
  HAL_OUT = 2;  // Output (component writes)
  HAL_IO = 3;   // Bidirectional
}

Messages

Position

9-axis position (X, Y, Z, A, B, C, U, V, W).

message Position {
  double x = 1;
  double y = 2;
  double z = 3;
  double a = 4;
  double b = 5;
  double c = 6;
  double u = 7;
  double v = 8;
  double w = 9;
}

PositionStatus

All position-related information.

message PositionStatus {
  Position position = 1;         // Commanded position
  Position actual_position = 2;  // Actual/feedback position
  Position probed_position = 3;  // Probe trip position
  Position dtg = 4;              // Distance to go
  Position g5x_offset = 5;      // Work offset (G54-G59.3)
  Position g92_offset = 6;      // G92 offset
  Position tool_offset = 7;     // Tool offset
  int32 g5x_index = 8;           // Work coordinate index
}

JointStatus

Per-joint status information.

message JointStatus {
  int32 joint_number = 1;
  JointType joint_type = 2;   // LINEAR or ANGULAR
  double output = 11;         // Commanded position
  double input = 12;          // Feedback position
  double velocity = 13;
  bool homed = 16;
  bool enabled = 18;
  bool fault = 17;
  bool min_hard_limit = 21;
  bool max_hard_limit = 22;
  // ... additional fields
}

SpindleStatus

Per-spindle status information.

message SpindleStatus {
  int32 spindle_number = 1;
  bool brake = 2;
  int32 direction = 3;    // -1=reverse, 0=stopped, 1=forward
  bool enabled = 4;
  double speed = 6;       // Commanded RPM
  double override = 7;    // Override scale
  // ... additional fields
}

ToolEntry

One tool in tool.tool_table.

message ToolEntry {
  int32 id = 1;                    // Tool number
  double x_offset = 2;
  double z_offset = 4;
  double diameter = 11;
  int32 orientation = 14;
  optional int32 table_index = 16; // Index in LinuxCNC's own tool table
  // ... additional fields
}
  • tool_table holds only the entries with a tool (a tool number other than 0), so an entry’s position in the list is not its position in LinuxCNC’s tool table.
  • An entry’s id can be -1 for an empty slot: index 0 is the spindle, and LinuxCNC gives it id -1 when no tool is loaded. Ignore entries whose id is not positive.
  • table_index is the entry’s index in the tool table as LinuxCNC’s status lists it. tool.pocket_prepped is an index into that same table (-1 when nothing is prepared), so the tool prepared for the next change is the entry whose table_index equals pocket_prepped. If no entry matches, the prepared slot is empty.
  • table_index is unset in a status from a 1.0 server. Check for presence (HasField("table_index") in Python, TableIndex != nil in Go, tableIndex !== undefined in TypeScript, table_index.is_some() in Rust) rather than comparing with 0, which is a real index.
status = stub.GetStatus(linuxcnc_pb2.GetStatusRequest())
prepped_tool = next(
    (entry for entry in status.tool.tool_table
     if entry.HasField("table_index")
     and entry.table_index == status.tool.pocket_prepped),
    None,
)

HalPinInfo

Information about a HAL pin.

message HalPinInfo {
  string name = 1;            // Full name (component.pin)
  string short_name = 2;      // Pin name only
  string component = 3;       // Parent component
  HalType type = 4;           // Data type
  PinDirection direction = 5; // IN/OUT/IO
  HalValue value = 6;         // Current value
  string signal = 7;          // Always empty
  bool has_writer = 8;        // The pin's signal has a writer
}
  • signal is always empty: LinuxCNC’s hal Python module does not say which signal a pin is connected to. HalSignalInfo.driver names the pin that drives a signal.
  • has_writer is HAL’s own answer (hal.pin_has_writer): true when the pin is connected to a signal that an output pin drives. See StreamStatus for how often a stream refreshes it.
  • direction is PIN_DIR_UNSPECIFIED if HAL does not report one.

HalValue

One HAL value; the field set depends on the type.

message HalValue {
  oneof value {
    bool bit_value = 1;
    double float_value = 2;
    int32 s32_value = 3;
    uint32 u32_value = 4;
    int64 s64_value = 5;
    uint64 u64_value = 6;
    string port_value = 7;       // Never set by the server
  }
}

No field is set for a port, or for a value the server could not read.

64-bit integers in Node.js/TypeScript

The Node.js/TypeScript client gives every int64 and uint64 field as a JavaScript number, which holds whole numbers exactly only up to 2^53 - 1 (Number.MAX_SAFE_INTEGER). The Python, Go and Rust clients use 64-bit integer types and get every value exactly, with timestamps in nanoseconds.

Timestamps (the timestamp and modified_timestamp fields) are sent in nanoseconds. When the client decodes a message, a timestamp outside the safe range ±(2^53 - 1) becomes whole milliseconds, truncated toward zero, so new Date(status.timestamp) works as it is. A timestamp inside the range (0, or a time before mid-April 1970) keeps its nanoseconds. Encoding a message and the JSON conversions (toJSON, fromJSON) do no scaling.

Every other 64-bit field (s64_value and u64_value in HalValue, ErrorMessage.sequence, file sizes and offsets) is not scaled. A value beyond 2^53 arrives as the nearest number, so 9007199254740993 arrives as 9007199254740992. A 1.0 client divided such a value by 1,000,000.

Values near the 64-bit maximum round out of range: the int64 maximum arrives as 2^63 and the uint64 maximum as 2^64. Encoding a message that holds such a value again (to forward it, say) throws. The HAL service is read-only, so a client never sends one back to this server.

These fields stay number in every 1.x release.