HALCMD(1)
π HALCMD(1) β the HAL User's Manual, but make it a group chat π
okay bestie, so this is halcmd, from the LinuxCNC HAL User's Manual, and honestly? she's iconic. she runs the whole Hardware Abstraction Layer from your command line and she does NOT need a GUI to slay. let's get into it. π«Ά
β¨ NAME β¨
halcmd β manipulate the LinuxCNC HAL from the command line. that's it, that's the girl. π
πΈ SYNOPSIS πΈ
halcmd [OPTIONS] [COMMAND [ARG]]
π¦ DESCRIPTION π¦
so like, halcmd is what you use to manipulate the HAL (Hardware Abstraction Layer, keep up π) straight from the command line. and the best part? halcmd can optionally read commands from a file, which means you can set up whole complex HAL configurations with a single command. no cap, one command. π
and if the readline library was available when LinuxCNC got compiled? then halcmd gives you commandline editing and completion when you're running interactively. hit the up arrow to recall your previous commands (your history, your lore β¨), and press tab to complete the names of things like pins and signals. it's giving autocomplete luxury. π
β¨ OPTIONS β¨
-Iβ before tearing down the realtime environment, run an interactivehalcmd. halrun only. and if you're using-I, it has to come before all other commandline arguments. it's the line leader, periodt. π-f [<file>]β ignore the commands on the command line, take input from a file instead. if file isn't specified, take input fromstdin. π-i <INI file>β use variables from the specified INI file for substitutions. peep SUBSTITUTION below, bestie, it's down there. π-kβ keep going after failed command(s). the default is to stop and return failure if any command fails, so this one is the "we don't stop, we keep it pushing" flag. π₯-qβ display errors only (this is the default, so if you did nothing, this is what you got πΈ)-Qβ display nothing, execute commands silently. stealth mode. π-sβ script-friendly mode. in this mode,showwill not output titles for the items shown. also, module names get printed instead of ID codes inpin,param, andfunctlistings. threads get printed on a single line, with the thread period, FP usage and name first, followed by all of the functions in the thread, in execution order. signals get printed on a single line too, with the type, value, and signal name first, followed by a list of pins connected to the signal, showing both the direction and the pin name. it's giving compact, it's giving parseable. β¨-Rβ release the HAL mutex. this is the rescue flag π β useful for recovering when a HAL component has crashed while holding the HAL mutex.-vβ display results of each command-Vβ display lots of debugging junk π-h [<command>]β display a help screen and exit. and if you pass a command, it displays extended help on that command. π«Ά
π COMMANDS π
commands are what tell halcmd what to do. normally halcmd reads a single command from the command line and executes it. but if you used the -f option to read commands from a file, halcmd reads each line of the file as a new command. and anything following # on a line? that's a comment, bestie. π
π§ loadrt modname
(load realtime module) loads a realtime HAL module called modname. halcmd looks for the module in a directory specified at compile time.
on systems with kernel-based realtime support (e.g. RTAI), halcmd calls the linuxcnc_module_helper to load realtime modules. linuxcnc_module_helper is a setuid program and it's compiled with a whitelist of modules it's allowed to load. currently that's just a list of LinuxCNC-related modules. the linuxcnc_module_helper execs insmod, so the return codes and error messages are the ones from insmod. and admins who want to restrict which users can load these LinuxCNC-related kernel modules can do that by setting the permissions and group on linuxcnc_module_helper appropriately. π
on systems with userspace-based realtime support (e.g. Preempt-RT) and on systems with no realtime support at all, halcmd calls the rtapi_app which creates the realtime environment (simulated realtime, on systems with no userspace realtime support) if it didn't exist yet, and then loads the requested component with a call to dlopen(3). π
π¦ unloadrt modname
(unload realtime module) unloads a realtime HAL module called modname. if modname is "all", it will unload all currently loaded realtime HAL modules. unloadrt also works by execing linuxcnc_module_helper or rtapi_app, just like loadrt. symmetric queen. β¨
π loadusr [flags] unix-command
(load Userspace component) executes the given unix-command, usually to load a non-realtime component. [flags] may be one or more of:
-Wβ to wait for the component to become ready. the component is assumed to have the same name as the first argument of the command.-Wn nameβ to wait for the component, which will have the given name.-wβ to wait for the program to exit-iβ to ignore the program return value (with-w)
π waitusr name
(wait for Userspace component) waits for non-realtime component name to disconnect from HAL (usually on exit). the component must already be loaded. super useful near the end of a HAL file, to wait until the user closes some user interface component before cleaning up and exiting. it's giving "we don't leave until she leaves." π
πΈ unloadusr compname
(unload Userspace component) unloads a non-realtime component called compname. if compname is "all", it will unload all non-realtime components. unloadusr works by sending SIGTERM to all non-realtime components. π
π unload compname
unloads a non-realtime component or realtime module. if compname is "all", it will unload all non-realtime components and realtime modules. she does both, she contains multitudes. π
β newsig signame type
OBSOLETE β use net instead
(new signal) creates a new HAL signal called signame that may later be used to connect two or more HAL component pins. type is the data type of the new signal, and must be one of "bit", "s32", "u32", or "float". fails if a signal of the same name already exists. π
π
delsig signame
(delete signal) deletes HAL signal signame. any pins currently linked to the signal will be unlinked. fails if signame doesn't exist.
π₯ sets signame value
(set signal) sets the value of signal signame to value. fails if signame doesn't exist, if it already has a writer, or if value isn't a legal value. legal values depend on the signal's type. π«Ά
π stype name
(signal type) gets the type of signal name. fails if name doesn't exist as a signal.
β¨ gets signame
(get signal) gets the value of signal signame. fails if signame doesn't exist.
π§ linkps pinname [arrow] signame
OBSOLETE β use net instead
(link pin to signal) establishes a link between a HAL component pin pinname and a HAL signal signame. any previous link to pinname will be broken. arrow can be "=>", "<=", "<=>", or omitted. halcmd ignores arrows, but they can be useful in command files to document the direction of data flow. arrows should not be used on the command line since the shell might try to interpret them. fails if either pinname or signame doesn't exist, or if they aren't the same type. π
π¦ linksp signame [arrow] pinname
OBSOLETE β use net instead
(link signal to pin) works like linkps but reverses the order of the arguments. halcmd treats both link commands exactly the same. use whichever you prefer, bestie, no judgement here. π
π linkpp pinname1 [arrow] pinname2
OBSOLETE β use net instead
(link pin to pin) shortcut for linkps that creates the signal (named like the first pin), then links them both to that signal. halcmd treats this just as if it were:
halcmd newsig pinname1
halcmd linksp pinname1 pinname1
halcmd linksp pinname1 pinname2
π net signame pinname ...
create signname to match the type of pinname if it doesn't yet exist. then, link signame to each pinname in turn. arrows may be used as in linkps. when linking a pin to a signal for the first time, the signal value will inherit the pin's default value. the modern main character. β
πΈ unlinkp pinname
(unlink pin) breaks any previous link to pinname. fails if pinname doesn't exist. an unlinked pin will retain the last value of the signal it was linked to. she remembers. π
π
setp name value
(set parameter or pin) sets the value of parameter or pin name to value. fails if name doesn't exist as a pin or parameter, if it's a parameter that isn't writable, if it's a pin that's an output, if it's a pin that's already attached to a signal, or if value isn't a legal value. legal values depend on the type of the pin or parameter. and heads up: if both a pin and a parameter exist with the given name, the parameter is acted on. π«Ά
π paramname = value
π pinname = value
identical to setp. this alternate form of the command may be more convenient and readable when used in a file. yes bestie, it's just vibes and an equals sign. β¨
π ptype name
(parameter or pin type) gets the type of parameter or pin name. fails if name doesn't exist as a pin or parameter. if a pin and a parameter both exist with the given name, the parameter is acted on. π
β getp name
(get parameter or pin) gets the value of parameter or pin name. fails if name doesn't exist as a pin or parameter. and yeah β if a pin and a parameter both exist with the given name, the parameter is acted on. π₯
π§ addf functname threadname
(add function) adds function functname to realtime thread threadname. functname will run after any functions that were previously added to the thread. fails if either functname or threadname doesn't exist, or if they're incompatible. it's giving queue energy. π
π¦ delf functname threadname
(delete function) removes function functname from realtime thread threadname. fails if either functname or threadname doesn't exist, or if functname isn't currently part of threadname. π
π₯ start
starts execution of realtime threads. each thread periodically calls all of the functions that were added to it with the addf command, in the order in which they were added. go girl, go. π
π stop
stops execution of realtime threads. the threads will no longer call their functions. sit down, bestie. π
πΈ show [item]
prints HAL items to stdout in human readable format. item can be one of "comp" (components), "pin", "sig" (signals), "param" (parameters), "funct" (functions), "thread", or "alias". the type "all" can be used to show matching items of all the preceding types. if item is omitted, show will print everything. everything. all of it. no notes. β¨
π save [item]
prints HAL items to stdout in the form of HAL commands. these commands can be redirected to a file and later executed using halcmd -f to restore the saved configuration. item can be one of the following:
compβ spits out aloadrtcommand for a realtime component. β¨aliasβ spits out analiascommand for every pin or parameter alias pairing. πsig(orsignal) β spits out anewsigcommand for every signal. Andsiguspits out anewsigcommand for every unlinked signal (that's the one you want when you're pairing it withnetlandnetla). π¦linkandlinkaβ both spit outlinkpscommands for each link. (linkaincludes arrows,linkdoes not. that's literally the whole difference bestie.)netandnetaβ both spit out onenewsigcommand for each signal, followed bylinkspcommands for every pin linked to that signal. (netaincludes arrows.) πnetlβ spits out onenetcommand for each linked signal.netla(ornetal) β same vibe but with arrows. πΉparam(orparameter) β spits out onesetpcommand for each parameter.threadβ spits out oneaddfcommand for each function in each realtime thread. π§΅unconnectedinpinsβ spits out asetpcommand for each unconnected HAL input pin.- If item is
allu),savedoes the equivalent ofcomp,alias,sigu,netla,param,thread, andunconnectedinpins. - If item is omitted (or
all),savedoes the equivalent ofcomp,alias,sigu,netla,param, andthread.
sourcefilename.hal β runs the commands infilename.hal. go read your little script, king πaliastype name alias β gives alias a second name for the pin or parameter name. For most operations an alias is just a second name you can use to refer to a pin or parameter β both the original name and the alias will work. π- type must be
pinorparam. - name must be an existing name or alias of the specified type. Heads up though: the
showcommand will only show the aliased name, but the original name is still valid to use in HAL. You can still peep the original names withshow allorshow alias. And no cap β existing nets are preserved when a pin name gets aliased. π«Ά
- type must be
unaliastype alias β removes any alias from the pin or parameter alias.- type must be
pinorparam. - alias must be an existing name or alias of the specified type.
- type must be
listtype [pattern] β prints the names of HAL items of the specified type. type iscomp,pin,sig,param,funct, orthread. If pattern is specified it prints only the names that match the pattern, which may be ashell glob. π
For sig, pin and param, the first pattern may be -tdatatype where datatype is the data type (e.g., float). In that case, the listed pins, signals, or parameters are restricted to the given data type. Names are printed on a single line, space separated. π
print[message] β prints the filename, linenumber and an optional message. wrap the message in quotes if it has spaces, bestie.lock[all|tune|none] β locks HAL to some degree. πnoneβ no locking done.tuneβ some tuning is possible (setp& such).allβ HAL completely locked.
unlock[all|tune] β unlocks HAL to some degree. πtuneβ some tuning is possible (setp& such).allβ HAL completely unlocked.
status[type] β prints status info about HAL. type islock,mem, orall. If type is omitted, it assumesall.debug[level] β sets the rtapi messaging level (see man3rtapi_set_msg_level).help[command] β gives help information for command. If command is omitted, it lists the command and a brief description. the little built-in tutorial, we love her π
β¨ SUBSTITUTION β¨
After a command is read but before it is executed, several types of variable substitution take place. it's giving β¨magicβ¨ but make it documented.
π Environment Variables
Environment variables have the following formats:
$ENVVAR followed by end-of-line or whitespace
$(ENVVAR)
π INI file variables
INI file variables are available only when an INI file was specified with the halcmd -i flag. They have the following formats:
[SECTION]VAR followed by end-of-line or whitespace
[SECTION](VAR)
β€΅οΈ LINE CONTINUATION ‡οΈ
The backslash character (\) may be used to indicate the line is extended to the next line. The backslash character must be the last character before the newline. no sneaky trailing spaces, she WILL notice π
π BUGS π
None known at this time. (iconic behaviour, honestly. zero notes.)
π AUTHOR π
Original version by John Kasunich, as part of the LinuxCNC project. Now includes major contributions by several members of the project. π«Ά
π¨ REPORTING BUGS π¨
Report bugs to the LinuxCNC bug tracker β¨https://github.com/LinuxCNC/linuxcnc/issuesβ©.
π COPYRIGHT π
Copyright Β© 2003 John Kasunich.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
π SEE ALSO π
halrun(1) β a convenience script to start a realtime environment, process a HAL or a .tcl file, and optionally start an interactive command session using halcmd (described here) or haltcl(1). π
and that's the whole page, bestie! π This lil' slice of LinuxCNC Documentation, dated 2003-12-18, belongs to the HALCMD(1) manual β go forth and save allu) responsibly. π
β¨π
π¦ where this page comes from
- 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
- Copyright (c) 2003 John Kasunich
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms