[[cha:hal-tools]] (((HAL Tools)))

= HAL Tools

[[sec:halcmd]]

== Halcmd

Halcmd is a command line tool for manipulating the HAL. There is a
rather complete man page for halcmd, which will be installed if you
have installed LinuxCNC from either source or a package. The manpage
provides usage info:

----
man halcmd
----

If you have compiled LinuxCNC for “run-in-place”, you must source
the rip-environment script to make the man page available:

----
cd toplevel_directory_for_rip_build
. scripts/rip-environment
man halcmd
----

The <<cha:hal-tutorial,HAL Tutorial>> has a number of examples of halcmd
usage, and is a good tutorial for halcmd.

[[sec:halmeter]](((Halmeter)))

== Halmeter

Halmeter is a 'voltmeter' for the HAL. It lets you look at a pin,
signal, or parameter, and displays the current value of that item. It
is pretty simple to use. Start it by typing *halmeter* in an X 
windows shell. Halmeter is a GUI application. It will pop up
a small window, with two buttons labeled 'Select' and 'Exit'. Exit is
easy - it shuts down the program. Select pops up a larger window, with
three tabs. One tab lists all the pins currently defined in the HAL.
The next lists all the signals, and the last tab lists all the
parameters. Click on a tab, then click on a pin/signal/parameter. Then
click on 'OK'. The lists will disappear, and the small window will
display the name and value of the selected item. The display is updated
approximately 10 times per second. If you click 'Accept' instead of
'OK', the small window will display the name and value of the selected
item, but the large window will remain on the screen. This is
convenient if you want to look at a number of different items quickly.

You can have many halmeters running at the same time, if you want to
monitor several items. If you want to launch a halmeter without tying
up a shell window, type 'halmeter &' to run it in the background.
You can also make halmeter start 
displaying a specific item immediately, by adding 'pin|sig|par[am]
<name>' to the command line. It will display the pin, signal, or
parameter 
<name> as soon as it starts. (If there is no such item, it will simply
start normally.) And finally, if you specify an item to display, you
can add '-s' before the pin|sig|param to tell halmeter to use a small
window. The item name will be displayed in the title bar instead of
under the value, and there will be no buttons. Useful when you want a
lot of meters in a small amount of screen space.

Refer to <<sec:tutorial-halmeter,Halmeter Tutorial>> section for more
information.

Halmeter can be loaded from a terminal or from Axis. Halmeter is
faster than Halshow at displaying values. Halmeter has two windows, one
to pick the pin, signal, or parameter to monitor and one that displays
the value. Multiple Halmeters can be open at the same time. If you use
a script to open multiple Halmeters you can set the position of each
one with -g X Y relative to the upper left corner of your screen. 
For example: 

----
loadusr halmeter pin hm2.0.stepgen.00.velocity-fb -g 0 500
----

See the man page for more options. See section <<sec:halmeter,Halmeter>>.
  
.Halmeter

image::images/hal-meter01.png[]

image::images/hal-meter02.png[]

== Halshow

Halshow (see separate section for complete usage description)
can be started from the command line to show details for selected
components, pins, parameters, signals, functions, and threads of a running HAL.
The WATCH tab provides a continuous display of selected pin, parameters, and
signal items.  The File menu provides buttons to 1) save the watch items to
a watch list and to load and existing watch list.  The watch list items can
also be loaded automatically on startup.  For command line usage:
----
halshow --help
Usage:
  halshow [Options] [watchfile]
  Options:
           --help  (this help)

Notes:
       Create watchfile in halshow using: 'File/Save Watch List'
       linuxcnc must be running for standalone usage
----

[[sec:halscope]]

== Halscope

Halscope is an 'oscilloscope' for the HAL. It lets you capture the
value of pins, signals, and parameters as a function of time. Complete
operating instructions should be located here eventually. For now,
refer to section  <<sec:tutorial-halscope>> in the tutorial chapter,
which explains the basics.

The halscope File menu selector provides buttons to save a configuration
or open a previously saved configuration.  When halscope is terminated,
the last configuration is saved in a file named autosave.halscope.

Configuration files may also be specified when starting halscope from
the commandline.  Commandline help (-h) usage:
----
halscope -h
Usage:
  halscope [-h] [-i infile] [-o outfile] [num_samples]
----

== Sim Pin

sim_pin is a command line utility to display and update any number of
writable pins, parameters or signals.  Usage:
----
sim_pin
  Usage:
         sim_pin name1 [name2 ...] &

  Note:  linuxcnc must be running
         A named item can specify a pin, param, or signal
         The item must be writable, e.g.:
            pin:    IN or I/O (and not connected to a signal)
            param:  RW
            signal: connected to a writable pin
----
For complete information, see the man page:
----
man sim_pin
----
Example (with LinuxCNC running):
----
halcmd loadrt mux2 names=example; halcmd net sig_example example.in0
sim_pin example.sel example.in1 sig_example &
----
image::images/sim_pin.png[]

== Simulate Probe

simulate_probe is a simple gui to simulate activation of the pin
motion.probe-input.  Usage:
----
simulate_probe &
----

image::images/simulate_probe.png[]

== Hal Histogram

hal-histogram is a command line utility to display histograms for hal pins.
----
Usage:
   hal-histogram --help | -?
or
   hal-histogram [Options] [pinname]

Options:
  --minvalue  minvalue (minimum bin, default: 0)
  --binsize   binsize  (binsize, default: 100)
  --nbins     nbins    (number of bins, default: 50)

  --logscale  0|1      (y axis log scale, default: 1)
  --text      note     (text display, default: "" )
  --show               (show count of undisplayed nbins, default off)
  --verbose            (progress and debug, default off)

Notes:
  1) LinuxCNC (or another Hal application) must be running
  2) If no pinname is specified, default is: motion-command-handler.time
  3) This app may be opened for 5 pins
  4) pintypes float, s32, u32, bit are supported
  5) The pin must be associated with a thread supporting floating point
     For a base thread, this may require using:
     loadrt motmod ... base_thread_fp=1
----
image::images/hal-histogram.png[]

