1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 <2025> | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 <2025> |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: "Inject" code into IOC startup files? |
From: | Han Lee via Tech-talk <tech-talk at aps.anl.gov> |
To: | EPICS Tech Talk <tech-talk at aps.anl.gov>, "Blomley, Edmund (IBPT)" <edmund.blomley at kit.edu> |
Date: | Thu, 26 Jun 2025 11:54:33 -0700 |
Hi Eddy,
I like to use the iocshLoad() command rather than “<” because it can be passed arguments rather than requiring the use of environment variables.
This file
https://github.com/CARS-UChicago/GSECARS-EPICS/blob/master/iocBoot/ioc13idc_linux/st.cmd
uses these commands:
iocshLoad("serial.cmd", "P=$(PREFIX), TS=gsets20")
iocshLoad("MeasComp.cmd", "P=$(PREFIX)")
iocshLoad("motors.cmd", "P=$(PREFIX)")
# User calc stuff
iocshLoad("../calc_GSECARS.iocsh", "P=$(PREFIX)")
calc_GSECARS.iocsh is in the upper-level iocBoot directory because it is shared with many iocXXX directories beneath.
Mark
From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Pearson, Matthew via Tech-talk
Sent: Thursday, June 26, 2025 10:14 AM
To: Blomley, Edmund (IBPT) <edmund.blomley at kit.edu>; EPICS Tech Talk <tech-talk at aps.anl.gov>
Subject: RE: "Inject" code into IOC startup files?
Hi Eddy,
I usually just source externally managed commands using ‘<’ before and/or after iocInit.
I pasted an example below, where I source IOC shell commands from $(MOXA) which is defined in envPaths. So you can update the commands in that file without touching the IOC.
Cheers,
Matt
#!../../bin/linux-x86_64/cs-genio
#- You may have to change cs-genio to something else
#- everywhere it appears in this file
< envPaths
cd "${TOP}"
## Register all support components
dbLoadDatabase "dbd/cs-genio.dbd"
cs_genio_registerRecordDeviceDriver pdbbase
## Load record instances
dbLoadRecords("db/cs-genio.db")
# Instantiate standard ports and names
< $(MOXA)/st_scripts/st_genIO.cmd
cd "${TOP}/iocBoot/${IOC}"
iocInit
From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Blomley, Edmund (IBPT) via Tech-talk
Sent: Thursday, June 26, 2025 5:27 AM
To: EPICS Tech Talk <tech-talk at aps.anl.gov>
Subject: [EXTERNAL] "Inject" code into IOC startup files?
Dear all,
Most of our IOCs use the (current?) "default" IOC structure created by the `makeBaseApp.pl` script.
Now there are several scenarios where we currently add the same line of code or same „functionality" to each start up file "by convention“. (For new IOCs we have some scripts adjusting the results of `makeBaseApp.pl` from the beginning).
One example: we export the list of PVs after IOC init. Because we use a custom ENV variables set by our systemd script for each IOC, this line is 100% identical for each IOC and looks something like that:
cd ${TOP}/iocBoot/${IOC}iocInit
# Write list of records.
dbl > "${EPICS_AUTOPVLIST_IOC_FILE}"
The second scenario is to do some things _before_ IOC init: For example load the iocStats records.
Adding these lines of code once is one thing… But for example, now I would like to add recCaster to each startup file… if that is done, we might also can get rid of the dbl export…
So the question: Is there a way to define some generic „hook-in“ behavior which allows to „add code“ _before_ AND _after_ IOC init, where the actual code is managed outside of the IOC structure and could be used across multiple IOCs? Also due to our orchestration and systemd files, we can do some „customization“ during IOC deployment if necessary.
Our current „brain-storming“ idea is maybe through a module, we could add an IOC shell function that allows registering files for later execution. But before we start working on that… other ideas? Is there already a built-in option? Have other labs already created some custom code to allow for something like that?
Cheers
Eddy