Error messages and the GUI

LinuxCNC’s error channel is one queue, and reading a message removes it. Each operator or NML error message goes to exactly one reader: the machine’s GUI or the server, never both. Nothing can look at a message without taking it or put it back, so the server cannot read invisibly. It reads in one place, shares what it read with every client, and lets you choose whether it reads at all.

Somebody has to read the queue

The queue holds 25 messages. Once it is full, LinuxCNC’s task waits 5 seconds for every further message and then drops it. During that wait the task takes no command from anyone, stops included, and the status does not change. Motion already queued goes on, so a stop sent then takes effect seconds late. One reader taking one message ends the wait.

The GUIs that ship with LinuxCNC (AXIS, gmoccapy, gscreen, Touchy, QtVCP screens, tklinuxcnc) read the queue all the time. halui and mdro never read it, and linuxcncrsh reads it only when its client asks.

On a machine with one of those GUIs the GUI is the reader. On a machine without one, only the server can be, and without it the machine stalls from the 26th message on: a few dozen refused MDI lines are enough.

The modes

The --error-channel option chooses when the server reads:

ModeThe server reads
auto (default)As on-demand with a display known to read errors, as always otherwise.
on-demandOnly while at least one StreamErrors client is connected.
alwaysFrom the connect to LinuxCNC on, so a GUI loses most of its error popups.
offNever, and StreamErrors is refused with FAILED_PRECONDITION.

status.errors holds what the server read, so it stays empty with off. With always, replay_buffered also returns messages from before the client connected.

How auto decides

When the server connects to LinuxCNC, and again on a reconnect, it reads [DISPLAY]DISPLAY from LinuxCNC’s INI file. It takes the first word of the value, without its directory, in lower case. These displays mean on-demand:

[DISPLAY]DISPLAY starts withGUI
axis, profile_axisAXIS
gmoccapygmoccapy
gscreengscreen
touchyTouchy
qtvcpEvery QtVCP screen, such as qtvcp qtdragon.
tklinuxcnc, tkemctklinuxcnc
qtpyvcpQtPyVCP screens started through QtPyVCP’s launcher.
probe_basic, probe_basic_latheProbe Basic
tncTurBoNC
monokrom_mill, monokrom_plasmaMonokrom
flexguiFlex GUI

Anything else means always: dummy, halui, linuxcncrsh, a headless stand-in, your own program, an empty value, no [DISPLAY] section, or an INI file the server cannot read. The list holds displays known to read errors, not every one that does. A display reads them if it shows LinuxCNC’s error popups; try an MDI line such as M999.

The server logs the decision in one INFO line starting Error channel auto:. GetServerInfo.error_channel_mode reports the mode in use: on-demand, always or off, and auto until the server has connected.

Connected while in cycle

If the server connects while the machine is in cycle, it does not read the INI file yet, and auto reads as always for now:

  • The log has a WARNING line saying so, and GetServerInfo reports always.
  • The server checks every 2 seconds. Once the machine is out of cycle, it reads the INI file and decides as usual. A paused program counts as in cycle, so this lasts as long as the pause.
  • Meanwhile a GUI can miss some of its popups. Start the server with --error-channel on-demand on a machine with a GUI to avoid this.

What the server reads from the INI file

The server reads LinuxCNC’s INI file once per connection: [DISPLAY]DISPLAY for auto and the values GetMachineConfig reports. LinuxCNC reads its INI file only at startup, so the values hold for the whole connection, unless the status names a different INI file: the server then drops the settings it has and reads that file, a read that can again be deferred.

  • The machine is in cycle when it is on and busy: a program running or paused, an MDI command, motion not in position, a jog, or a joint homing. A machine in E-stop or off is not in cycle. A task state the server does not know counts as in cycle.
  • The read is deferred while the machine is in cycle. Until then GetMachineConfig answers FAILED_PRECONDITION with the reason ini-not-read-in-cycle (errors), which is about the settings of the INI file the status names now.
  • The check uses the last status the server has, so a cycle that starts just before the read is not excluded.
  • The log line Reading LinuxCNC's INI file <path> (<n> values) marks each read.
  • A read freezes every RPC, stops included, until the file system answers. Keep the INI file on local storage, not a network mount.
  • If the joints or axes in the status change under the same INI file name, GetMachineConfig reports ini_readable false.
  • An INI file the server cannot read is not tried again on that connection. Fix it, then restart the server.
  • The explicit modes do not use [DISPLAY]DISPLAY; the server still reads the other values.

Which to use

A machine with a listed GUI

Keep the default. Don’t call StreamErrors unless your client is meant to take over error display, and use off to make sure no client can. Watch the status instead: task.exec_state, task.task_state, task.interpreter_errcode, limits and joint faults.

A GUI that is not in the list

This covers your own GUI, a vendor screen, or a listed GUI started by a wrapper script under another name. If it shows LinuxCNC’s error popups, start the server with --error-channel on-demand. Otherwise auto reads as always and the GUI loses most of its popups.

A headless machine, or one driven entirely over gRPC

Keep the default or say always. If the INI file names a listed GUI that is not running, such as an AXIS configuration started headless, auto chooses on-demand and nothing reads the queue: start the server with --error-channel always. Never use off or on-demand here unless something else reads the queue.

Buffers and sequence numbers

  • While both the server and a GUI read, each message goes to whichever polls first.
  • In on-demand mode, a message already waiting when the first stream starts is delivered. When the last stream ends, the server may still take one more message, which then appears in status.errors and in later replays.
  • The server keeps the newest 256 messages. A StreamErrors client that falls more than 256 behind loses the older ones; the only sign is a jump in ErrorMessage.sequence.
  • status.errors carries the newest 20 messages in every GetStatus and StreamStatus message. Use sequence to tell a new message from one you have handled. Gaps between polls are normal; use StreamErrors if you need every message.
  • timestamp is when the server read the message, not when LinuxCNC raised it.