1) HALLIB_DIR: new directory for system-wide hal files (*.hal,*.tcl and
supporting files).
Locations:
RIP: HALLIB = lib/hallib/
DEB: HALLIB = /usr/share/linuxcnc/hallib/
2) HALLIB_PATH: search path for locating halfiles:
HALLIB_PATH = .:HALLIB_DIR (e.g., ini directory then system library)
3) LIB: prefix to explicitly specify a system library halfile (with
no search of the ini file directory)
[HAL]
...
HALFILE = LIB:filename.[hal|tcl]
...
This patch addresses a general issue of the multiple copies (or links) of
halfiles throughout the config tree and makes it simple to explicitly specify a
library halfile so that a user does not need to copy these files when modifying
a configuration. For example, one can instruct a user with:
'Include the line HALFILE = LIB:xhc-hb04.tcl in the [HAL] stanza of
your ini file'
Signed-off-by: Dewey Garrett <dgarrett@panix.com>
95 lines
2.4 KiB
Bash
95 lines
2.4 KiB
Bash
#!/bin/bash
|
|
# maintainer: when adding items update three places:
|
|
# usage(), show_all(), and show_item()
|
|
#
|
|
# note: report LINUXCNVERSION=$EMC2VERSION (as does linuxcnc.in)
|
|
|
|
# Copyright: 2014
|
|
# Author: Dewey Garrett <dgarrett@panix.com>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
function usage () {
|
|
cat <<EOF
|
|
|
|
Retrieve Linuxcnc Variables
|
|
Usage:
|
|
$(basename $0) [ varname | all ]
|
|
|
|
Varnames supported:
|
|
LINUXCNCVERSION
|
|
REALTIME
|
|
RTS
|
|
HALLIB_DIR
|
|
|
|
Option 'all' returns varname=value for all supported varnames
|
|
EOF
|
|
exit 1
|
|
}
|
|
|
|
function show_all () {
|
|
echo "LINUXCNCVERSION=@EMC2VERSION@
|
|
REALTIME=@REALTIME@
|
|
RTS=@RTS@
|
|
HALLIB_DIR=@HALLIB_DIR@"
|
|
}
|
|
|
|
function show_item () {
|
|
case $1 in
|
|
LINUXCNCVERSION) echo @EMC2VERSION@;;
|
|
REALTIME) echo @REALTIME@;;
|
|
RTS) echo @RTS@;;
|
|
HALLIB_DIR) echo @HALLIB_DIR@;;
|
|
all) show_all;;
|
|
*) echo UNKNOWN; exit 1;;
|
|
esac
|
|
}
|
|
|
|
case $# in
|
|
0) usage;;
|
|
1) show_item $1;;
|
|
*) usage;;
|
|
esac
|
|
exit 0
|
|
|
|
# Example shell usage to populate environment in a sourced script:
|
|
# for line in $(linuxcnc_var all) ; do
|
|
# name=${line%%=*}
|
|
# value=${line##*=}
|
|
# echo "name=$name value=$value"
|
|
# export "$name"="$value"
|
|
# done
|
|
|
|
# Example tcl usage:
|
|
# foreach line [exec linuxcnc_var all] {
|
|
# set l [split $line =]
|
|
# set name [lindex $l 0]
|
|
# set value [lindex $l 1]
|
|
# set V($name) $value
|
|
# }
|
|
# parray V
|
|
|
|
# Example python usage:
|
|
# import subprocess
|
|
# s = subprocess.Popen(['linuxcnc_var','all']
|
|
# ,stdout=subprocess.PIPE
|
|
# ,stderr=subprocess.PIPE
|
|
# p,e = s.communicate()
|
|
# v={}
|
|
# for line in p.split('\n'):
|
|
# if line == '': continue
|
|
# name = line.split('=')[0]
|
|
# value = line.split('=')[1]
|
|
# v[name] = value
|
|
# print(v)
|