First steps with halrun, hostmod2 and mesa - PeterMue/ZX45-LinuxCNC GitHub Wiki
This article covers the very basics on how to interact with the LinuxCNC HAL System. It's required to understand the basics of the HAL system before we can set up a LinuxCNC machine.
There is a great tutorial that covers this topic in more detail here LinuxCNC Docs: Basic HAL and here LinuxCNC Docs: HAL Tutorial.
The halrun
command is a simple command line tool to interact with the HAL (Hardware Abstraction Layer) of LinuxCNC.
Basically we're able to setup the entire LinuxCNC HAL configuration interactively in the halrun environment. Later we're saving all these commands in an configuration file that gets loaded when LinuxCNC starts (instead of building the config hal file from scratch, we use a sample machine configuration as base).
Especially for debugging purposes and to get a better insight whats going on, the halrun command is a very handy tool.
To start halrun, open a terminal and type halrun
.
peter@LinuxCNC:~$ halrun
.
halcmd: help
Use 'help <command>' for more details about each command
Available commands:
loadrt Load realtime module(s)
loadusr Start user space program
waitusr Waits for userspace component to exit
unload Unload realtime module or terminate userspace component
lock, unlock Lock/unlock HAL behaviour
linkps Link pin to signal
linksp Link signal to pin
net Link a number of pins to a signal
unlinkp Unlink pin
newsig, delsig Create/delete a signal
getp, gets Get the value of a pin, parameter or signal
ptype, stype Get the type of a pin, parameter or signal
setp, sets Set the value of a pin, parameter or signal
addf, delf Add/remove function to/from a thread
show Display info about HAL objects
list Display names of HAL objects
source Execute commands from another .hal file
status Display status information
save Print config as commands
start, stop Start/stop realtime threads
alias, unalias Add or remove pin or parameter name aliases
echo, unecho Echo commands from stdin to stderr
quit, exit Exit from halcmd
Now we're in the halrun environment. To show the available commands, type help
as shown above.
There is also a tab completion, so just hit once to do a autocompletion or hit twice to show all current valid commands.
There is a HAL driver called hostmod2 to interact with the Mesa Firmware. The first step to talk to a mesa card is to load this driver. This can be done with these commands:
.
halcmd: loadrt hostmot2
halcmd: loadrt hm2_pci
To show what functions, pins, etc. the mesa card (a 5i25) provides, we can use the command show
: