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, --port PORT_NUMBER β€” tells linuxcncrsh which port to listen on. Defaults to 5007 if you don't say anything πŸ’…
  • -n, --name SERVER_NAME β€” sets the server name that linuxcncrsh will use to identify itself during handshaking with a new client. Defaults to EMCNETSVR if omitted ✨
  • -w, --connectpw PASSWORD β€” 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 to EMC if omitted.
  • -e, --enablepw PASSWORD β€” the password required to enable LinuxCNC via linuxcncrsh. ⚠️ also sent in the clear, so same situation: anyone reading packets on the network between server and client can see it 😭. Defaults to EMCTOO if omitted.
  • -s, --sessions MAX_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:

  • -ini LINUXCNC_INI_FILE β€” the LinuxCNC INI file to use. 🚨 the -ini option must be preceded by two dashes: --. Defaults to emc.ini if 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 (5007 if you did not give linuxcncrsh the --port option)

🌈 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 match linuxcncrsh's connect password, or "EMC" if no --connectpw was 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>] β€” the get command 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> β€” the set command takes one of the LinuxCNC sub-commands (described in the section LinuxCNC Subcommands, below) and one or more additional parameters.
  • quit β€” the quit command disconnects the associated socket connection. bye bestie πŸ‘‹
  • shutdown β€” the shutdown command 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 (see enable subcommand in the LinuxCNC Subcommands section, below).
  • help β€” the help command 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} β€” with get, any on/off parameter is ignored and the current echo state is returned. With set, sets the echo state as specified. Echo defaults to on when 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} β€” with get, any on/off parameter is ignored and the current verbose state is returned. With set, sets the verbose state as specified. When verbose mode is on, all set commands return positive acknowledgement in the form SET <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 out OFF on new connections.
  • enable {<passwd>|off} β€” the session's enable state indicates whether the current connection is enabled to perform control functions. With get, any parameter is ignored, and the current enable state is returned. With set and a valid password matching linuxcncrsh's --enablepw (EMCTOO if 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} β€” with get, any parameter is ignored and the current communications mode is returned. With set, 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> β€” with get, any parameter is ignored and the current protocol version used by the server is returned. With set, 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! With get, returns the string "emc.ini". Should return the full path and file name of the current configuration INI file. Setting this does nothing.
  • plat β€” with get, 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> β€” with get, any parameter is ignored and the current integer value of EMC_DEBUG is returned. Note that the value of EMC_DEBUG returned is the from the UI's INI file, which may be different than emc's INI file. With set, sends a command to the EMC to set the new debug level, and sets the EMC_DEBUG global 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} β€” the set_wait setting 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). With get, any parameter is ignored and the current set_wait setting is returned. With set, set the set_wait setting to the specified value.
  • wait {received|done} β€” with set, force a wait for the previous command to be received, or done.
  • set_timeout <timeout> β€” with set, 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 is 0.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 β€” with get, returns the current error string, or "ok" if no error.
  • operator_display β€” with get, returns the current operator display string, or "ok" if none.
  • operator_text β€” with get, returns the current operator text string, or "ok" if none.
  • time β€” with get, returns the time, in seconds, from the start of the epoch. This starting time depends on the platform.
  • estop {on|off} β€” with get, ignores any parameters and returns the current estop setting as "on" or "off". With set, sets the estop as specified. E-stop "on" means the machine is in the estop state and won't run πŸ›‘
  • machine {on|off} β€” with get, ignores any parameters and returns the current machine power setting as "on" or "off". With set, sets the machine on or off as specified.
  • mode {manual|auto|mdi} β€” with get, ignores any parameters and returns the current machine mode. With set, sets the machine mode as specified.
  • mist {on|off} β€” with get, ignores any parameters and returns the current mist coolant setting. With set, sets the mist setting as specified. πŸ’¦
  • flood {on|off} β€” with get, ignores any parameters and returns the current flood coolant setting. With set, sets the flood setting as specified. 🌊
  • lube {on|off} β€” with get, ignores any parameters and returns the current lube pump setting. With set, sets the lube pump setting as specified. πŸ›’οΈ

to be continued… part 2 incoming, don't go anywhere bestie πŸ’–

  • lube_level β€” With get, hands you the lubricant level sensor reading as "ok" or "low". With set... it just mocks you for wishful thinking. like bestie you can't SET the lube level 😭
  • spindle {forward|reverse|increase|decrease|constant|off} β€” With get, whatever parameter you throw at it gets ignored and you get the current spindle state back as "forward", "reverse", "increase", "decrease", or "off". With set, 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} β€” With get, any parameter is ignored and the current brake setting comes back. With set, the brake is set as specified.
  • tool β€” With get, returns the id of the currently loaded tool. That's it, that's the whole vibe. πŸ’…
  • tool_offset β€” With get, returns the currently applied tool length offset.
  • load_tool_table <file> β€” With set, loads the tool table that <file> points at.
  • home {0|1|2|...} | -1 β€” With set, homes the indicated joint. Pass -1 and it homes all joints. go big or go home, literally.
  • jog_stop joint_number|axis_letter β€” With set, stops any in-progress jog on the joint or axis you named. If TELEOP_ENABLE is NO, use joint_number. If TELEOP_ENABLE is YES, use axis_letter. pick the right one, bestie, they are NOT interchangeable.
  • jog joint_number|axis_letter <speed> β€” With set, jogs the specified joint or axis at <speed>; the sign of speed is the direction. If TELEOP_ENABLE is NO, use joint_number. If TELEOP_ENABLE is YES, use axis_letter.
  • jog_incr jog_number|axis_letter <speed> <incr> β€” With set, jogs the indicated joint or axis by the increment <incr> at the <speed>; again, the sign of speed is the direction. If TELEOP_ENABLE is NO, use joint_number. If TELEOP_ENABLE is YES, use axis_letter.
  • feed_override <percent> β€” With get, any parameter is ignored and the current feed override comes back (as a percentage of commanded feed). With set, the feed override is set as specified.
  • spindle_override <percent> β€” With get, any parameter is ignored and the current spindle override comes back (as a percentage of commanded speed). With set, the spindle override is set as specified.
  • abs_cmd_pos [{0|1|...}] β€” With get, returns the specified axis' commanded position in absolute coordinates. No axis specified? You get all axes' commanded absolute position. 🌈
  • abs_act_pos [{0|1|...}] β€” With get, returns the specified axis' actual position in absolute coordinates. No axis specified? All axes' actual absolute position.
  • rel_cmd_pos [{0|1|...}] β€” With get, 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|...}] β€” With get, 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|...}] β€” With get, 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}] β€” With get, returns the position offset that goes with the world coordinate you provided.
  • joint_limit [{0|1|...}] β€” With get, 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|...}] β€” With get, 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|...}] β€” With get, returns the homed status of the specified joint as "homed" or "not". No joint number specified? Homed status of all joints.
  • mdi <string> β€” With set, sends <string> as an MDI command. typing your whole life into one line, iconic.
  • task_plan_init β€” With set, initializes the program interpreter.
  • open <filename> β€” With set, 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>] β€” With set, runs the opened program. No StartLine given? It runs from the beginning. Give a StartLine and it starts from that line. A start line of -1 runs in verify mode. ⭐
  • pause β€” With set, pauses program execution.
  • resume β€” With set, resumes program execution.
  • abort β€” With set, aborts program or MDI execution. πŸ’€
  • step β€” With set, steps the program one line. slow and steady, one line at a time, we love a careful queen.
  • program β€” With get, returns the name of the currently opened program, or "none".
  • program_line β€” With get, returns the currently executing line of the program.
  • program_status β€” With get, returns "idle", "running", or "paused". vibe check on your program fr fr.
  • program_codes β€” With get, returns the string for the currently active program codes.
  • joint_type [<joint>] β€” With get, returns "linear", "angular", or "custom" for the type of the specified joint (or for all joints if none is specified).
  • joint_units [<joint>] β€” With get, 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 the EMC_AXIS_STAT::units numerical value of user units per mm or deg. For linear joints, something close to 0.03937 is deemed "inch", 1.000 is "mm", 0.1 is "cm", otherwise it's "custom". For angular joints, something close to 1.000 is deemed "deg", PI/180 is "rad", 100/90 is "grad", otherwise it's "custom". yes bestie it's vibes-based math and that's just how it is ✨
  • program_units β€” Synonym for program_linear_units.
  • program_linear_units β€” With get, returns "inch", "mm", "cm", or "none", for the corresponding linear units that are active in the program interpreter.
  • program_angular_units β€” With get, returns "deg", "rad", "grad", or "none" for the corresponding angular units that are active in the program interpreter.
  • user_linear_units β€” With get, 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 the EMC_TRAJ_STAT::linearUnits numerical value of user units per mm. Something close to 0.03937 is deemed "inch", 1.000 is "mm", 0.1 is "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 β€” With get, returns "inch", "mm", "cm", or "custom", for the linear units that are active in the display. This is effectively the value of linearUnitConversion.
  • display_angular_units β€” With get, returns "deg", "rad", "grad", or "custom", for the angular units that are active in the display. This is effectively the value of angularUnitConversion.
  • linear_unit_conversion {inch|mm|cm|auto} β€” With get, any parameter is ignored and the active unit conversion comes back. With set, sets the unit to be displayed. If it's "auto", the units displayed match the program units.
  • angular_unit_conversion {deg|rad|grad|auto} β€” With get, any parameter is ignored and the active unit conversion comes back. With set, sets the units to be displayed. If it's "auto", the units displayed match the program units.
  • probe_clear β€” With set, clears the probe tripped flag.
  • probe_tripped β€” With get, returns the probe state β€” has the probe tripped since the last clear? πŸ‘€
  • probe_value β€” With get, returns the current value of the probe signal.
  • probe β€” With set, 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] β€” With get, any parameter is ignored and the current teleop mode comes back. With set, the teleop mode is set as specified.
  • kinematics_type β€” With get, returns the type of kinematics functions used (identity=1, serial=2, parallel=3, custom=4).
  • override_limits {on|off} β€” With get, any parameter is ignored and the override_limits setting comes back. With set, the override_limits parameter is set as specified. If override_limits is on, it disables end of travel hardware limits so you can jog off of a limit. If parameters is off, then hardware limits are enabled. this one moves you off a limit, so know what you're doing, bestie.
  • optional_stop {0|1} β€” With get, any parameter is ignored and the current "optional stop on M1" setting comes back. With set, 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. πŸ‘‘πŸ’–