TrakHound Docs MTConnect.NET Tormach Adapter

Tormach Adapter

Read a Tormach PathPilot controller through the included PathPilot status server.
MTConnect.NET Docs Menu
  • Module name — MTConnect Tormach Adapter agent module
  • Identifier — tormach-adapter
  • NuGet package — MTConnect.NET-AgentModule-TormachAdapter
  • Source path — agent/Modules/MTConnect.NET-AgentModule-TormachAdapter/

Purpose

Reads Tormach CNC machines running PathPilot. PathPilot is based on LinuxCNC and has no network interface for machine data, so the module comes with a PathPilot status server (pathpilot/pathpilot_status_server.py). The status server runs on the controller, reads the machine status with the LinuxCNC Python API (linuxcnc.stat), and streams it to the module over TCP as JSON lines. The module builds a Device from the axes configured in PathPilot.

The status server only reads status; it never sends commands to the machine.

PathPilot Status Server

  1. Copy pathpilot_status_server.py (in the pathpilot folder next to the agent) to the PathPilot controller, for example with the controller's network file share or a USB drive.
  2. Run it on the controller: python pathpilot_status_server.py (options: --port, default 7890; --bind; --interval, default 500 ms). It uses only Python and the linuxcnc module included with PathPilot.
  3. To start it automatically, add it to the controller's startup applications. It reports UNAVAILABLE while PathPilot is not running.

PathPilot updates

PathPilot updates may remove files and startup entries added to the controller. Check the status server is running after updating PathPilot.

Messages (one JSON object per line):

{"type":"info","version":"1.0","machine":"tormach_mill_1100","coordinates":"X Y Z A","linear_units":0.03937}
{"type":"status","available":true,"task_mode":"AUTO","task_state":"ON","interp_state":"READING","estop":false,"file":"/home/operator/gcode/bracket.nc","line":120,"tool":5,"g5x_index":1,"actual_position":[1.5,-2.25,0.1,90.5,0,0,0,0,0], ...}

Configuration Schema

The module's configuration class is TormachAdapterModuleConfiguration. The keys below describe the YAML map under tormach-adapter:.

KeyTypeDefaultPermissible valuesNotes
deviceKeystringnulldevice name or UUIDRequired. The Device observations are added to.
createDevicebooltruetrue, falseWhen true, the module adds a Device named deviceKey, updated with the machine name and axes configured in PathPilot. Set false to use a Device from Devices.xml.
deviceUuidstringdeviceKeyany stringUUID of the Device created when createDevice is true.
serverstringlocalhosthostname or IP addressThe PathPilot controller.
portint78901-65535The status server port.
readIntervalint500millisecondsInterval between processing the status received.
connectionTimeoutint5000millisecondsMaximum time to wait for the connection to open.
dataTimeoutint5000millisecondsTime without data after which the connection is reopened.
workPositionsboolfalsetrue, falseAlso report work coordinate positions.

DataItems

When createDevice is false, the Device in Devices.xml needs DataItems whose id or name match these keys.

KeyDataItemSource (linuxcnc.stat)
availAVAILABILITYAVAILABLE while PathPilot is running and the status server is connected; otherwise every DataItem is UNAVAILABLE.
estopEMERGENCY_STOPestop
modeCONTROLLER_MODEtask_mode — AUTO = AUTOMATIC, MDI = MANUAL_DATA_INPUT, MANUAL = MANUAL.
executionEXECUTIONinterp_state — IDLE = READY, READING / WAITING = ACTIVE, PAUSED = FEED_HOLD; STOPPED in emergency stop or with the machine off.
programPROGRAMfile — the file name.
lineLINE_NUMBER (ABSOLUTE)current_line
toolTOOL_NUMBERtool_in_spindle
workOffsetWORK_OFFSETg5x_index — ex. 54, 59.1.
optionalStopCONTROLLER_MODE_OVERRIDE (OPTIONAL_STOP)optional_stop
feedratePATH_FEEDRATE (ACTUAL)current_vel — mm/s.
feedOverridePATH_FEEDRATE_OVERRIDE (PROGRAMMED)feedrate — percent.
rapidOverridePATH_FEEDRATE_OVERRIDE (RAPID)rapidrate — percent.
speedROTARY_VELOCITY (COMMANDED)spindle speed — RPM, 0 when the spindle is off.
spindleOverrideROTARY_VELOCITY_OVERRIDEspindle override — percent.
{axis}_actPOSITION / ANGLE (ACTUAL)actual_position — machine position, mm (inch converted) or degrees.
{axis}_workPOSITION / ANGLE (ACTUAL)actual_position minus the work, G92 and tool offsets, when workPositions is true; references the Device's work coordinate system (type OBJECT).

Not reported: alarms (PathPilot errors are only on the LinuxCNC error channel, and reading it would take them away from PathPilot), part counts (not part of the LinuxCNC status), and the measured spindle speed.

Wire Interaction

LinuxCNCPathPilot
poll
Status serverpathpilot_status_server.py on the controller
TCP
tormach-adapter moduleReads the latest status
AgentDevice and Observations
  1. Connect
  2. Module AgentAddDevice (createDevice = true)
  3. Module Status serverTCP connect to <server>:<port>
  4. Status server Module{"type":"info", "coordinates":"X Y Z A", ...}
  5. Module AgentAddDevice with the axes
  6. Every interval ms (status server)
  7. Status server LinuxCNClinuxcnc.stat().poll()
  8. Status server Module{"type":"status", ...}
  9. Every readInterval ms (module)
  10. Module AgentAddObservation(...) from the latest status
  11. PathPilot not running
  12. Status server Module{"type":"status","available":false}
  13. Module Agentavail and every DataItem set to UNAVAILABLE
The status server only reads the machine's status and never sends commands.

Example Configuration

modules:
  - tormach-adapter:
      deviceKey: PCNC1100
      server: 192.168.1.80
      port: 7890
      workPositions: true

For multiple machines, declare the module once per machine. Created DataItem IDs are prefixed with the Device name, so they do not collide.

Troubleshooting

  • Always UNAVAILABLE, connection failed — the status server is not running, or the port is blocked. Run it in a terminal on the controller to see its output.
  • UNAVAILABLE while connected — the status server is running but PathPilot (LinuxCNC) is not.
  • Positions off by a factor of 25.4 — check linear_units in the info message; positions are converted using the PathPilot machine units.
  • Missing after a PathPilot update — reinstall the status server and its startup entry.
  • Observations dropped with createDevice: false — the Device's DataItem id or name must match the keys above; verify against /probe.

Classes

The main classes in the MTConnect.NET-AgentModule-TormachAdapter package:

  • TormachAdapterModuleConfiguration — the module's configuration class.
  • TormachMessageParser — parses the status server messages.