linuxcncrsh(1)
β¨ linuxcncrsh(1) β¨
okay bestie, buckle up π«Ά this is the manual page for linuxcncrsh(1) β the text-mode interface for commanding LinuxCNC over the network β brought to you by The Enhanced Machine Controller herself, and she is iconic. no GUI window, no drama, just vibes and TCP packets. let's go π
π NAME π
linuxcncrsh β text-mode interface for commanding LinuxCNC over the network π
π SYNOPSIS π
linuxcncrsh [OPTIONS] [-- LINUXCNC_OPTIONS]
π¦ DESCRIPTION π¦
So linuxcncrsh is a user interface for LinuxCNC, but make it text-mode π
. Instead of popping up a GUI window like AXIS(1) and Touchy(1) do, it processes text-mode commands that it receives via the network. A human (or honestly, a program β no judgment π«Ά) can interface with linuxcncrsh using telnet(1), nc(1) or similar programs.
And the tea? β All features of LinuxCNC are available via the linuxcncrsh interface. literally all of them. main character energy only π.
β¨ OPTIONS β¨
-p,--portPORT_NUMBER β tellslinuxcncrshwhich port to listen on. Defaults to5007if you don't say anything π-n,--nameSERVER_NAME β sets the server name thatlinuxcncrshwill use to identify itself during handshaking with a new client. Defaults toEMCNETSVRif omitted β¨-w,--connectpwPASSWORD β the connection password to use during handshaking with a new client. β οΈ heads up bestie: the password is sent in the clear, so it can be read by anyone who can read packets on the network between the server and the client π. Defaults toEMCif omitted.-e,--enablepwPASSWORD β the password required to enable LinuxCNC vialinuxcncrsh. β οΈ also sent in the clear, so same situation: anyone reading packets on the network between server and client can see it π. Defaults toEMCTOOif omitted.-s,--sessionsMAX_SESSIONS β the maximum number of simultaneous connections. Defaults to-1(which means no limit π) if not specified.
In addition to the options listed above, linuxcncrsh accepts an optional special LINUXCNC_OPTION at the end:
-iniLINUXCNC_INI_FILE β the LinuxCNC INI file to use. π¨ the-inioption must be preceded by two dashes:--. Defaults toemc.iniif omitted.
πΈ Starting linuxcncrsh πΈ
To use linuxcncrsh instead of a normal LinuxCNC GUI like AXIS or Touchy, specify it in your INI file like this:
[DISPLAY]
DISPLAY=linuxcncrsh
To use linuxcncrsh in addition to a normal GUI, you can either start it at the end of your HAL file, or run it by hand in a terminal window π
To start it from HAL, add a line like this to the end of your HAL file:
loadusr linuxcncrsh [OPTIONS] [-- LINUXCNC_OPTIONS]
To start it from the terminal, run linuxcncrsh manually like this:
linuxcncrsh [OPTIONS] [-- LINUXCNC_OPTIONS]
π Connecting π
Once LinuxCNC is up and linuxcncrsh is running, you can connect to it using telnet or nc or similar:
telnet HOST PORT
- HOST is the hostname or IP address of the computer running
linuxcncrsh - PORT is the port it's listening on (
5007if you did not givelinuxcncrshthe--portoption)
π Network protocol π
linuxcncrsh accepts TCP connections on the port specified by the --port option, or 5007 if not specified.
The client sends requests, and the linuxcncrsh server returns replies. Requests consist of a command word followed by optional command-specific parameters. Requests and most request parameters are case insensitive. The exceptions are passwords, file paths and text strings π₯
Requests to linuxcncrsh are terminated with line endings β any combination of one or more '\r' and '\n' characters. Replies from linuxcncrsh are terminated with the sequence '\r\n'.
The supported commands are as follows:
hello <password> <client> <version>β<password>must matchlinuxcncrsh's connect password, or"EMC"if no--connectpwwas supplied. The three arguments may not contain whitespace. If a valid password was entered the server will respond with:
HELLO ACK <ServerName> <ServerVersion>
If an invalid password or any other syntax error occurs then the server responds with:
HELLO NAK
get <subcommand> [<parameters>]β thegetcommand takes one of the LinuxCNC sub-commands (described in the section LinuxCNC Subcommands, below) and zero or more additional subcommand-specific parameters πset <subcommand> <parameters>β thesetcommand takes one of the LinuxCNC sub-commands (described in the section LinuxCNC Subcommands, below) and one or more additional parameters.quitβ thequitcommand disconnects the associated socket connection. bye bestie πshutdownβ theshutdowncommand tells LinuxCNC to shutdown and disconnect the session. β οΈ this command may only be issued if the Hello has been successfully negotiated and the connection has control of the CNC (seeenablesubcommand in the LinuxCNC Subcommands section, below).helpβ thehelpcommand will return help information in text format over the connection. If no parameters are specified, it will itemize the available commands. If a command is specified, it will provide usage information for the specified command. Help will respond regardless of whether a "Hello" has been successfully negotiated π
π LinuxCNC Subcommands π
Subcommands for get and set are:
echo {on|off}β withget, any on/off parameter is ignored and the current echo state is returned. Withset, sets the echo state as specified. Echo defaults toonwhen the connection is first established. When echo is on, all commands will be echoed upon receipt. This state is local to each connection πverbose {on|off}β withget, any on/off parameter is ignored and the current verbose state is returned. Withset, sets the verbose state as specified. When verbose mode is on, allsetcommands return positive acknowledgement in the formSET <COMMAND> ACK, and text error messages will be issued (FIXME: I don't know what this means). The verbose state is local to each connection, and starts outOFFon new connections.enable {<passwd>|off}β the session's enable state indicates whether the current connection is enabled to perform control functions. Withget, any parameter is ignored, and the current enable state is returned. Withsetand a valid password matchinglinuxcncrsh's--enablepw(EMCTOOif not specified), the current connection is enabled for control functions."OFF"may not be used as a password and disables control functions for this connection.config [TBD]β unused, ignore for now πcomm_mode {ascii|binary}β withget, any parameter is ignored and the current communications mode is returned. Withset, will set the communications mode to the specified mode. The ASCII mode is the text request/reply mode, the binary protocol is not currently designed or implemented π«comm_prot <version>β withget, any parameter is ignored and the current protocol version used by the server is returned. Withset, sets the server to use the specified protocol version, provided it is lower than or equal to the highest version number supported by the server implementation.inifileβ β οΈ not currently implemented! Withget, returns the string"emc.ini". Should return the full path and file name of the current configuration INI file. Setting this does nothing.platβ withget, returns the string"Linux"π§ini <var> <section>β β οΈ not currently implemented, do not use! Should return the string value of<var>in section<section>of the INI file.debug <value>β withget, any parameter is ignored and the current integer value ofEMC_DEBUGis returned. Note that the value ofEMC_DEBUGreturned is the from the UI's INI file, which may be different than emc's INI file. Withset, sends a command to the EMC to set the new debug level, and sets theEMC_DEBUGglobal here to the same value. This will make the two values the same, since they really ought to be the same π―set_wait {received|done}β theset_waitsetting controls the wait after receiving a command. It can be"received"(after the command was sent and received) or"done"(after the command was done). Withget, any parameter is ignored and the currentset_waitsetting is returned. Withset, set theset_waitsetting to the specified value.wait {received|done}β withset, force a wait for the previous command to be received, or done.set_timeout <timeout>β withset, set the timeout for commands to return to<timeout>seconds. Timeout is a real number. If it's<= 0.0, it means wait forever. Default is0.0, wait forever π°οΈupdate {none|auto}β the update mode controls whether to return fresh or stale values for "get" requests. When the update mode is"none"it returns stale values, when it's"auto"it returns fresh values. Defaults to"auto"for new connections. Set this to"none"if you like to be confused πerrorβ withget, returns the current error string, or"ok"if no error.operator_displayβ withget, returns the current operator display string, or"ok"if none.operator_textβ withget, returns the current operator text string, or"ok"if none.timeβ withget, returns the time, in seconds, from the start of the epoch. This starting time depends on the platform.estop {on|off}β withget, ignores any parameters and returns the current estop setting as"on"or"off". Withset, sets the estop as specified. E-stop"on"means the machine is in the estop state and won't run πmachine {on|off}β withget, ignores any parameters and returns the current machine power setting as"on"or"off". Withset, sets the machine on or off as specified.mode {manual|auto|mdi}β withget, ignores any parameters and returns the current machine mode. Withset, sets the machine mode as specified.mist {on|off}β withget, ignores any parameters and returns the current mist coolant setting. Withset, sets the mist setting as specified. π¦flood {on|off}β withget, ignores any parameters and returns the current flood coolant setting. Withset, sets the flood setting as specified. πlube {on|off}β withget, ignores any parameters and returns the current lube pump setting. Withset, sets the lube pump setting as specified. π’οΈ
to be continuedβ¦ part 2 incoming, don't go anywhere bestie π
lube_levelβ Withget, hands you the lubricant level sensor reading as"ok"or"low". Withset... it just mocks you for wishful thinking. like bestie you can't SET the lube level πspindle {forward|reverse|increase|decrease|constant|off}β Withget, whatever parameter you throw at it gets ignored and you get the current spindle state back as"forward","reverse","increase","decrease", or"off". Withset, the spindle gets set exactly as you said. Heads up tho:"increase"and"decrease"keep changing the speed in that direction until you send a"constant"command. It does not stop on its own, no cap. π₯brake {on|off}β Withget, any parameter is ignored and the current brake setting comes back. Withset, the brake is set as specified.toolβ Withget, returns the id of the currently loaded tool. That's it, that's the whole vibe. πtool_offsetβ Withget, returns the currently applied tool length offset.load_tool_table <file>β Withset, loads the tool table that<file>points at.home {0|1|2|...} | -1β Withset, homes the indicated joint. Pass-1and it homes all joints. go big or go home, literally.jog_stop joint_number|axis_letterβ Withset, stops any in-progress jog on the joint or axis you named. IfTELEOP_ENABLEisNO, usejoint_number. IfTELEOP_ENABLEisYES, useaxis_letter. pick the right one, bestie, they are NOT interchangeable.jog joint_number|axis_letter <speed>β Withset, jogs the specified joint or axis at<speed>; the sign of speed is the direction. IfTELEOP_ENABLEisNO, usejoint_number. IfTELEOP_ENABLEisYES, useaxis_letter.jog_incr jog_number|axis_letter <speed> <incr>β Withset, jogs the indicated joint or axis by the increment<incr>at the<speed>; again, the sign of speed is the direction. IfTELEOP_ENABLEisNO, usejoint_number. IfTELEOP_ENABLEisYES, useaxis_letter.feed_override <percent>β Withget, any parameter is ignored and the current feed override comes back (as a percentage of commanded feed). Withset, the feed override is set as specified.spindle_override <percent>β Withget, any parameter is ignored and the current spindle override comes back (as a percentage of commanded speed). Withset, the spindle override is set as specified.abs_cmd_pos [{0|1|...}]β Withget, returns the specified axis' commanded position in absolute coordinates. No axis specified? You get all axes' commanded absolute position. πabs_act_pos [{0|1|...}]β Withget, returns the specified axis' actual position in absolute coordinates. No axis specified? All axes' actual absolute position.rel_cmd_pos [{0|1|...}]β Withget, returns the specified axis' commanded position in relative coordinates, tool length offset included. No axis specified? All axes' commanded relative position.rel_act_pos [{0|1|...}]β Withget, returns the specified axis' actual position in relative coordinates, tool length offset included. No axis specified? All axes' actual relative position.joint_pos [{0|1|...}]β Withget, returns the specified joint's actual position in absolute coordinates, tool length offset excluded. No joint specified? All joints' actual absolute position.pos_offset [{X|Y|Z|R|P|W}]β Withget, returns the position offset that goes with the world coordinate you provided.joint_limit [{0|1|...}]β Withget, returns the limit status of the specified joint as"ok","minsoft","minhard","maxsoft", or"maxhard". No joint number specified? It returns the limit status of all joints.joint_fault [{0|1|...}]β Withget, returns the fault status of the specified joint as"ok"or"fault". No joint number specified? Fault status of all joints.joint_homed [{0|1|...}]β Withget, returns the homed status of the specified joint as"homed"or"not". No joint number specified? Homed status of all joints.mdi <string>β Withset, sends<string>as an MDI command. typing your whole life into one line, iconic.task_plan_initβ Withset, initializes the program interpreter.open <filename>β Withset, opens the named file. The<filename>is opened by linuxcnc, so it should either be an absolute path or a relative path starting in the LinuxCNC working directory (that's the directory of the active INI file). don't get cute with relative paths and then act surprised, bestie.run [<StartLine>]β Withset, runs the opened program. NoStartLinegiven? It runs from the beginning. Give aStartLineand it starts from that line. A start line of-1runs in verify mode. βpauseβ Withset, pauses program execution.resumeβ Withset, resumes program execution.abortβ Withset, aborts program or MDI execution. πstepβ Withset, steps the program one line. slow and steady, one line at a time, we love a careful queen.programβ Withget, returns the name of the currently opened program, or"none".program_lineβ Withget, returns the currently executing line of the program.program_statusβ Withget, returns"idle","running", or"paused". vibe check on your program fr fr.program_codesβ Withget, returns the string for the currently active program codes.joint_type [<joint>]β Withget, returns"linear","angular", or"custom"for the type of the specified joint (or for all joints if none is specified).joint_units [<joint>]β Withget, returns"inch","mm","cm", or"deg","rad","grad", or"custom", for the corresponding native units of the specified joint (or for all joints if none is specified). The type of the axis (linear or angular) is what decides which type of units come back. The units are obtained heuristically, based on theEMC_AXIS_STAT::unitsnumerical value of user units per mm or deg. For linear joints, something close to0.03937is deemed"inch",1.000is"mm",0.1is"cm", otherwise it's"custom". For angular joints, something close to1.000is deemed"deg",PI/180is"rad",100/90is"grad", otherwise it's"custom". yes bestie it's vibes-based math and that's just how it is β¨program_unitsβ Synonym forprogram_linear_units.program_linear_unitsβ Withget, returns"inch","mm","cm", or"none", for the corresponding linear units that are active in the program interpreter.program_angular_unitsβ Withget, returns"deg","rad","grad", or"none"for the corresponding angular units that are active in the program interpreter.user_linear_unitsβ Withget, returns"inch","mm","cm", or"custom", for the corresponding native user linear units of the LinuxCNC trajectory level. This one is obtained heuristically, based on theEMC_TRAJ_STAT::linearUnitsnumerical value of user units per mm. Something close to0.03937is deemed"inch",1.000is"mm",0.1is"cm", otherwise it's"custom".user_angular_unitsβ Returns"deg","rad","grad", or"custom"for the corresponding native user angular units of the LinuxCNC trajectory level. Like with linear units, this is obtained heuristically. same energy, different axis.display_linear_unitsβ Withget, returns"inch","mm","cm", or"custom", for the linear units that are active in the display. This is effectively the value oflinearUnitConversion.display_angular_unitsβ Withget, returns"deg","rad","grad", or"custom", for the angular units that are active in the display. This is effectively the value ofangularUnitConversion.linear_unit_conversion {inch|mm|cm|auto}β Withget, any parameter is ignored and the active unit conversion comes back. Withset, sets the unit to be displayed. If it's"auto", the units displayed match the program units.angular_unit_conversion {deg|rad|grad|auto}β Withget, any parameter is ignored and the active unit conversion comes back. Withset, sets the units to be displayed. If it's"auto", the units displayed match the program units.probe_clearβ Withset, clears the probe tripped flag.probe_trippedβ Withget, returns the probe state β has the probe tripped since the last clear? πprobe_valueβ Withget, returns the current value of the probe signal.probeβ Withset, moves toward a certain location. If the probe gets tripped on the way, stop motion, record the position and raise the probe tripped flag.teleop_enable [on|off]β Withget, any parameter is ignored and the current teleop mode comes back. Withset, the teleop mode is set as specified.kinematics_typeβ Withget, returns the type of kinematics functions used (identity=1,serial=2,parallel=3,custom=4).override_limits {on|off}β Withget, any parameter is ignored and theoverride_limitssetting comes back. Withset, theoverride_limitsparameter is set as specified. Ifoverride_limitsison, it disables end of travel hardware limits so you can jog off of a limit. If parameters isoff, then hardware limits are enabled. this one moves you off a limit, so know what you're doing, bestie.optional_stop {0|1}β Withget, any parameter is ignored and the current "optional stop onM1" setting comes back. Withset, the setting is set as specified.
π¬ Example Session π¬
Okay bestie, this is the part where we actually do the thing. Picture it: a whole little session, start to finish, connecting to the local machine (localhost). β¨
Quick legend before we dive in: bold stuff = you typed it, and the non-bold stuff = the machine talking back. And just so you know what's what, the default values are shown here for --port PORT_NUMBER (5007), --conectpw PASSWORD (EMC), and --enablepw PASSWORD (EMCTOO). π
So here's the plot: the user connects to linuxcncrsh, handshakes with the server (hello), enables machine commanding from this session (set enable), brings the machine out of E-stop (set estop off), and turns it on (set machine on). Then they home all the axes, switch the machine to mdi mode, send an MDI G-code command, and finally disconnect and shut down LinuxCNC. The whole arc. π¦
Heads up: every command shows up twice in the transcript below β that's just how it rolls, command in, reply out. Not a glitch, not you being extra. π
> telnet localhost 5007
Trying 127.0.0.1...
Connected to 127.0.0.1
Escape character is '^]'.
hello EMC user-typing-at-telnet 1.0
HELLO ACK EMCNETSVR 1.1
set enable EMCTOO
set enable EMCTOO
set mode manual
set mode manual
set estop off
set estop off
set machine on
set machine on
set home 0
set home 0
set home 1
set home 1
set home 2
set home 2
set mode mdi
set mode mdi
set mdi g0x1
set mdi g0x1
help
help
Available commands:
Hello <password> <client name> <protocol version>
Get <emc command>
Set <emc command>
Shutdown
Help <command>
help get
help get
Usage: Get <emc command>
Get commands require that a hello has been successfully negotiated.
Emc command may be one of:
Abs_act_pos
Abs_cmd_pos
...
shutdown
shutdown
Connection closed by foreign host.
And that's a wrap, bestie. π«Ά This page is from the linuxcncrsh manual, dated May 31, 2011, sourced from the LinuxCNC distribution. Go forth and command your machine, you absolute icon. ππ
π¦ where this page comes from
- debian bookworm: linuxcnc-uspace 2.9.0~pre1+git20230208.f1270d6ed7-1+deb12u2 Β· GFDL-1.1-or-later
- debian trixie: linuxcnc-uspace 1:2.9.4-2+deb13u1 Β· GFDL-1.1-or-later
- ubuntu questing: linuxcnc-uspace 1:2.9.4-2ubuntu2
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms