Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
e3-require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Lindh Olsson
e3-require
Commits
ff26c9b2
Commit
ff26c9b2
authored
7 years ago
by
Dirk Zimoch
Browse files
Options
Downloads
Patches
Plain Diff
make iocsh fit for EPICS 7 and other cleanup work
parent
ab1def76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iocsh
+92
-88
92 additions, 88 deletions
iocsh
with
92 additions
and
88 deletions
iocsh
+
92
−
88
View file @
ff26c9b2
...
@@ -2,30 +2,29 @@
...
@@ -2,30 +2,29 @@
help
()
{
help
()
{
{
{
echo
"usage: iocsh [options] [files]"
echo
"usage: iocsh [options] [files]
[macro=value] ...
"
echo
"Start an EPICS iocsh and load files"
echo
"Start an EPICS iocsh and load files"
echo
"Recognized filetypes: *.db *.dbt *.template *.subs *.subst *.dbd *.so"
echo
echo
echo
"Possible options:"
echo
"Possible options:"
echo
" -
3.xx.yy: Set EPICS base version.
"
echo
" -
? or -h or --help: Show this page and exit
"
echo
" -
32: Force 32 bit version (on 64 bit systems).
"
echo
" -
v or --version: Show version and exit
"
echo
" -
? or -h or --help: Show this page and exit.
"
echo
" -
32: Force 32 bit host architecture (on 64 bit systems)
"
echo
" -
v or --version: Show version and exit.
"
echo
" -
x.z.y: (Up to 3 numbers) Use specific EPICS base version
"
echo
" -c: The next string is executed as a command by the EPICS shell
.
"
echo
" -c: The next string is executed as a command by the EPICS shell"
echo
" -s: The next string is a sequencer program (and arguments), run with 'seq'
.
"
echo
" -s: The next string is a sequencer program (and arguments), run with 'seq'"
echo
" This forces an 'iocInit' before running the program."
echo
" This forces an 'iocInit' before running the program."
echo
" -r: The next string is a module (and version), loaded via 'require'
.
"
echo
" -r: The next string is a module (and version), loaded via 'require'"
echo
" -n: The next string is the IOC name (used for prompt)
.
"
echo
" -n: The next string is the IOC name (used for prompt)"
echo
" Default: dirname if parent dir is
\"
ioc
\"
otherwise hostname
.
"
echo
" Default: dirname if parent dir is
\"
ioc
\"
otherwise hostname"
echo
echo
echo
"Supported filetypes:"
echo
"Supported filetypes:"
echo
"*.db, *.dbt and *.template are loaded via 'dbLoadRecords'
.
"
echo
"*.db, *.dbt and *.template are loaded via 'dbLoadRecords'"
echo
"
After the filename, you can specify substitutions like MACRO=value.
"
echo
"
*.subs and *.subst are loaded via 'dbLoadTemplate'
"
echo
"*.
subs and *.subst are
loaded via 'dbLoad
Templat
e'
.
"
echo
"*.
dbd is
loaded via 'dbLoad
Databas
e'"
echo
"
*.dbd is loaded via 'dbLoadDatabase'.
"
echo
"
After the above files, you can specify macro substitutions like m1=v1 m2=v1
"
echo
"*.so is loaded via '
l
d' or '
dlload' (3.14.12 or higer).
"
echo
"*.so is loaded via '
dlloa
d'
(
or '
ld' before 3.14.12)
"
echo
"If an argument is @file, more arguments are read from that file
.
"
echo
"If an argument is @file, more arguments are read from that file"
echo
"All other files are executed as startup scripts by the EPICS shell
.
"
echo
"All other files are executed as startup scripts by the EPICS shell"
}
>
&2
}
>
&2
exit
exit
}
}
...
@@ -37,20 +36,6 @@ version () {
...
@@ -37,20 +36,6 @@ version () {
exit
exit
}
}
case
$1
in
(
-h
|
"-?"
|
-help
|
--help
)
help
;;
(
-v
|
-ver
|
--ver
|
-version
|
--version
)
version
;;
(
-3
.
*
)
unset
EPICS_BASE
BASE
=
${
1
#-
}
shift
;;
esac
# realpath and readlink are not available on all systems, let's try what works...
# realpath and readlink are not available on all systems, let's try what works...
rp
()
{
rp
()
{
(
realpath
$1
||
readlink
-f
$1
||
readlink
$1
||
(
cd
-P
$1
&&
echo
$PWD
)
||
(
x
=
$(
\l
s
-ld
$1
)
&&
echo
${
x
##*
}
)
||
echo
$1
)
2>/dev/null
(
realpath
$1
||
readlink
-f
$1
||
readlink
$1
||
(
cd
-P
$1
&&
echo
$PWD
)
||
(
x
=
$(
\l
s
-ld
$1
)
&&
echo
${
x
##*
}
)
||
echo
$1
)
2>/dev/null
...
@@ -59,23 +44,31 @@ rp() {
...
@@ -59,23 +44,31 @@ rp() {
# if EPICS_HOST_ARCH is not set guess it
# if EPICS_HOST_ARCH is not set guess it
if
[
-z
"
$EPICS_HOST_ARCH
"
]
if
[
-z
"
$EPICS_HOST_ARCH
"
]
then
then
echo
"EPICS_HOST_ARCH is not set"
EPICS_HOST_ARCH
=
$(
basename
$(
dirname
$(
rp
$(
which caRepeater
))))
EPICS_HOST_ARCH
=
$(
basename
$(
dirname
$(
rp
$(
which caRepeater
))))
if
[
-n
"
$EPICS_HOST_ARCH
"
]
if
[
-n
"
$EPICS_HOST_ARCH
"
]
then
then
echo
"Guessing EPICS_HOST_ARCH=
$EPICS_HOST_ARCH
"
echo
"Guessing EPICS_HOST_ARCH=
$EPICS_HOST_ARCH
"
>
&2
else
else
echo
"EPICS_HOST_ARCH is not set"
>
&2
exit
1
exit
1
fi
fi
fi
fi
# check if user requested 32 bit version on a 64 bit system
while
true
case
$1
in
do
(
-32
)
case
$1
in
EPICS_HOST_ARCH
=
${
EPICS_HOST_ARCH
%_64
}
(
-32
)
shift
EPICS_HOST_ARCH
=
${
EPICS_HOST_ARCH
%_64
}
;;
;;
esac
(
-[1-9]
*
)
unset
EPICS_BASE
BASE
=
${
1
#-
}
;;
(
*
)
break
;;
esac
shift
done
# Either EPICS or EPICS_BASE should be set to the install directory
# Either EPICS or EPICS_BASE should be set to the install directory
if
[
-z
"
$EPICS_BASE
"
]
if
[
-z
"
$EPICS_BASE
"
]
...
@@ -87,25 +80,44 @@ then
...
@@ -87,25 +80,44 @@ then
do
do
if
[
-d
$EPICS
]
if
[
-d
$EPICS
]
then
then
break
2
break
fi
fi
echo
"Cannot find any EPICS installation directory."
>
&2
echo
"Try setting EPICS_BASE environment variable to full path"
>
&2
exit
1
done
done
if
[
!
-d
"
$EPICS
"
]
then
EPICS
=
$(
dirname
$(
dirname
$(
dirname
$(
dirname
$(
ldd
$(
which caRepeater
)
|
awk
'/libca/ {print $3}'
)))))
echo
"Guessing EPICS=
$EPICS
"
fi
if
[
!
-d
"
$EPICS
"
]
then
echo
"Cannot find EPICS installation directory."
>
&2
echo
"Try setting EPICS environment variable."
>
&2
exit
1
fi
fi
if
[
-z
"
$BASE
"
]
then
EPICS_BASE
=
$(
\l
s
-1vrd
$EPICS
/base/bin/
{
${
EPICS_HOST_ARCH
}
,
${
EPICS_HOST_ARCH
%_64
}
}
2>/dev/null |
head
-n1
)
else
# find highest (requested) EPICS version that supports our architecture (or its 32 bit version)
EPICS_BASE
=
$(
\l
s
-1vrd
$EPICS
/base-
$BASE
*
/bin/
{
${
EPICS_HOST_ARCH
}
,
${
EPICS_HOST_ARCH
%_64
}
}
2>/dev/null |
head
-n1
)
fi
fi
# find highest (requested) EPICS version that supports our architecture (or its 32 bit version)
EPICS_BASE
=
$(
\l
s
-1vrd
$EPICS
/base
*
$BASE
*
/bin/
{
${
EPICS_HOST_ARCH
}
,
${
EPICS_HOST_ARCH
%_64
}
}
2>/dev/null |
head
-n1
)
if
[
-z
$EPICS_BASE
]
if
[
-z
$EPICS_BASE
]
then
then
echo
Cannot find any
$BASE
EPICS version
for
$EPICS_HOST_ARCH
.
>
&2
if
[
-z
"
$(
\l
s
-1vrd
$EPICS
/base-
$BASE
*
/ 2>/dev/null
)
"
]
then
echo
"No EPICS
$BASE
installed."
>
&2
exit
1
fi
echo
EPICS
$BASE
not available
for
EPICS_HOST_ARCH
=
$EPICS_HOST_ARCH
.
>
&2
exit
1
exit
1
fi
fi
# maybe we need to change from 64 bit to 32 bit
# maybe we need to change from 64 bit to 32 bit
if
[
$EPICS_HOST_ARCH
!=
${
EPICS_BASE
#*/bin/
}
]
if
[
$EPICS_HOST_ARCH
!=
${
EPICS_BASE
#*/bin/
}
]
then
then
EPICS_HOST_ARCH
=
${
EPICS_BASE
#*/bin/
}
EPICS_HOST_ARCH
=
${
EPICS_BASE
#*/bin/
}
echo
"No 64 bit version in
${
EPICS_BASE
%bin*
}
. Switch to 32 bit version
$EPICS_HOST_ARCH
"
echo
"No 64 bit version in
${
EPICS_BASE
%bin*
}
."
>
&2
echo
"Switching to 32 bit version
$EPICS_HOST_ARCH
."
>
&2
fi
fi
EPICS_BASE
=
$(
rp
${
EPICS_BASE
%bin*
}
)
EPICS_BASE
=
$(
rp
${
EPICS_BASE
%bin*
}
)
fi
fi
...
@@ -116,28 +128,13 @@ then
...
@@ -116,28 +128,13 @@ then
exit
1
exit
1
fi
fi
# Check revision
# Get actual EPICS revision
if
[
-r
$EPICS_BASE
/configure/CONFIG_BASE_VERSION
]
eval
$(
awk
-F
'[ \t]*=[ \t]*'
'
then
BASE
=
$(
awk
-F
'[ \t]*=[ \t]*'
'
/^[ \t]*EPICS_VERSION[ \t]*=/ {v=$2}
/^[ \t]*EPICS_VERSION[ \t]*=/ {v=$2}
/^[ \t]*EPICS_REVISION[ \t]*=/ {r=$2}
/^[ \t]*EPICS_REVISION[ \t]*=/ {r=$2}
/^[ \t]*EPICS_MODIFICATION[ \t]*=/ {m=$2}
/^[ \t]*EPICS_MODIFICATION[ \t]*=/ {m=$2+0}
END {print v"."r"."m}'
<
$EPICS_BASE
/configure/CONFIG_BASE_VERSION
)
END {print "BASE="v"."r"."m";BASECODE="v*10000+r*100+m}
else
'
<
$EPICS_BASE
/configure/CONFIG_BASE_VERSION
)
BASE
=
$(
basename
$(
rp
$EPICS_BASE
))
BASE
=
${
BASE
#*base-
}
fi
if
[
"
${
BASE
#3.
}
"
=
"
$BASE
"
]
then
echo
"Cannot find any EPICS base version"
>
&2
echo
"Try setting EPICS_BASE environment variable to full path"
>
&2
exit
1
fi
export
BASE
BASEMINOR
=
${
BASE
#3.
}
BASEPATCH
=
${
BASEMINOR
#*.
}
BASEMINOR
=
${
BASEMINOR
%.*
}
# IOC name derives from hostname
# IOC name derives from hostname
# (trailing possible '\r' under cygwin)
# (trailing possible '\r' under cygwin)
...
@@ -154,7 +151,7 @@ export IOC
...
@@ -154,7 +151,7 @@ export IOC
# Check for 64 bit versions, default to 32 bit
# Check for 64 bit versions, default to 32 bit
if
[
!
-d
$EPICS_BASE
/lib/
${
EPICS_HOST_ARCH
}
-a
-d
$EPICS_BASE
/lib/
${
EPICS_HOST_ARCH
%_64
}
]
if
[
!
-d
$EPICS_BASE
/lib/
${
EPICS_HOST_ARCH
}
-a
-d
$EPICS_BASE
/lib/
${
EPICS_HOST_ARCH
%_64
}
]
then
then
echo
"No 64 bit EPICS installation found. Defaulting to 32 bit"
echo
"No 64 bit EPICS installation found. Defaulting to 32 bit"
>
&2
EPICS_HOST_ARCH
=
${
EPICS_HOST_ARCH
%_64
}
EPICS_HOST_ARCH
=
${
EPICS_HOST_ARCH
%_64
}
fi
fi
export
EPICS_HOST_ARCH
export
EPICS_HOST_ARCH
...
@@ -207,6 +204,14 @@ while [ "$#" -gt 0 ]
...
@@ -207,6 +204,14 @@ while [ "$#" -gt 0 ]
do
do
file
=
$1
file
=
$1
case
$file
in
case
$file
in
(
-32
)
echo
"-32 option must be set earlier"
>
&2
exit
1
;;
(
-[1-9]
*
)
echo
"EPICS version
$file
option must be set earlier"
>
&2
exit
1
;;
(
-h
|
"-?"
|
-help
|
--help
)
(
-h
|
"-?"
|
-help
|
--help
)
help
help
;;
;;
...
@@ -216,7 +221,7 @@ do
...
@@ -216,7 +221,7 @@ do
(
@
*
)
(
@
*
)
loadFiles
$(
cat
${
file
#@
}
)
loadFiles
$(
cat
${
file
#@
}
)
;;
;;
(
*
.db
|
*
.template
)
(
*
.db
|
*
.template
|
*
.subs
|
*
.subst
|
*
.dbd
)
subst
=
""
subst
=
""
while
[
"$#"
-gt
1
]
while
[
"$#"
-gt
1
]
do
do
...
@@ -229,17 +234,19 @@ do
...
@@ -229,17 +234,19 @@ do
;;
;;
esac
esac
done
done
;;
&
(
*
.db
|
*
.template
)
echo
"dbLoadRecords
\"
$file
\"
,
\"
${
subst
#,
}
\"
"
echo
"dbLoadRecords
\"
$file
\"
,
\"
${
subst
#,
}
\"
"
;;
;;
(
*
.subs
|
*
.subst
)
(
*
.subs
|
*
.subst
)
echo
"dbLoadTemplate
\"
$file
\"
"
echo
"dbLoadTemplate
\"
$file
\"
,
\"
${
subst
#,
}
\"
"
;;
;;
(
*
.dbd
)
(
*
.dbd
)
# some dbd files must be loaded before main to take effect
# some dbd files must be loaded before main to take effect
echo
"dbLoadDatabase
\"
$file
\"
,
\"
$DBD
\"
"
echo
"dbLoadDatabase
\"
$file
\"
,
\"
$DBD
\"
,
\"
${
subst
#,
}
\"
"
;;
;;
(
*
.so
)
(
*
.so
)
if
[
$BASE
MINOR
-ge
15
-o
$BASEPATCH
-ge
12
]
if
[
$BASE
CODE
-ge
314
12
]
then
then
echo
"dlload
\"
$file
\"
"
echo
"dlload
\"
$file
\"
"
else
else
...
@@ -279,19 +286,9 @@ do
...
@@ -279,19 +286,9 @@ do
shift
shift
IOC
=
"
$1
"
IOC
=
"
$1
"
;;
;;
(
-3
.
*
)
echo
"Version
$file
must be first argument"
>
&2
exit
1
;;
(
-32
)
echo
"-32 option must come before all others (except -3.xx.yy)"
>
&2
exit
1
;;
(
-
*
)
(
-
*
)
{
echo
"Unknown option
$1
"
>
&2
echo
"unknown option
$1
"
echo
"Try:
$(
basename
$0
)
--help"
>
&2
echo
"try:
$(
basename
$0
)
--help"
}
>
&2
exit
1
exit
1
;;
;;
(
*
)
(
*
)
...
@@ -311,7 +308,7 @@ trap "kill -s SIGTERM 0; stty sane; echo; rm -f $startup; " EXIT
...
@@ -311,7 +308,7 @@ trap "kill -s SIGTERM 0; stty sane; echo; rm -f $startup; " EXIT
{
{
echo
"# date=
\"
$(
date
)
\"
"
echo
"# date=
\"
$(
date
)
\"
"
echo
"# user=
\"
${
USER
:-
$(
whoami
)
}
\"
"
echo
"# user=
\"
${
USER
:-
$(
whoami
)
}
\"
"
for
var
in
PWD BASE EPICS_HOST_ARCH SHELLBOX EPICS_CA_ADDR_LIST EPICS_DRIVER_PATH
for
var
in
IOC
PWD BASE EPICS_HOST_ARCH SHELLBOX EPICS_CA_ADDR_LIST EPICS_DRIVER_PATH
do
do
echo
"#
$var
=
\"
${
!var
}
\"
"
echo
"#
$var
=
\"
${
!var
}
\"
"
done
done
...
@@ -329,7 +326,7 @@ else # old driver pool model
...
@@ -329,7 +326,7 @@ else # old driver pool model
REQUIRE_DBD
=
$INSTBASE
/iocBoot/R
$BASE
/dbd/
$REQUIRE
.dbd
REQUIRE_DBD
=
$INSTBASE
/iocBoot/R
$BASE
/dbd/
$REQUIRE
.dbd
fi
fi
if
[
$BASE
MINOR
-ge
15
-o
$BASEPATCH
-ge
12
]
if
[
$BASE
CODE
-ge
314
12
]
then
then
EXE
=
$EPICS_BASE
/bin/
$EPICS_HOST_ARCH
/softIoc
EXE
=
$EPICS_BASE
/bin/
$EPICS_HOST_ARCH
/softIoc
ARGS
=
"-D
$EPICS_BASE
/dbd/softIoc.dbd"
ARGS
=
"-D
$EPICS_BASE
/dbd/softIoc.dbd"
...
@@ -346,6 +343,12 @@ else
...
@@ -346,6 +343,12 @@ else
echo
"
${
APP
}
_registerRecordDeviceDriver(pdbbase)"
echo
"
${
APP
}
_registerRecordDeviceDriver(pdbbase)"
fi
fi
if
[
!
-x
$EXE
]
then
echo
"
$EXE
not found or not executable."
>
&2
exit
1
fi
if
[
!
-f
"
$REQUIRE_LIB
"
]
if
[
!
-f
"
$REQUIRE_LIB
"
]
then
then
echo
"Library
$REQUIRE_LIB
not found."
>
&2
echo
"Library
$REQUIRE_LIB
not found."
>
&2
...
@@ -388,5 +391,6 @@ then
...
@@ -388,5 +391,6 @@ then
fi
fi
echo
$EXE
$ARGS
$startup
echo
$EXE
$ARGS
$startup
#enable core dumps
ulimit
-c
unlimited
ulimit
-c
unlimited
eval
"
$LOADER
$LOADERARGS
$EXE
"
$ARGS
"
$startup
"
2>&1
eval
"
$LOADER
$LOADERARGS
$EXE
"
$ARGS
"
$startup
"
2>&1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment