EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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  <20252026  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  <20252026 
<== Date ==> <== Thread ==>

Subject: RE: power off/on ioc recovery
From: "Pearson, Matthew via Tech-talk" <[email protected]>
To: "Tran, Phi Dung" <[email protected]>, Mark Rivers via Tech-talk <[email protected]>
Date: Fri, 19 Dec 2025 16:35:42 +0000

Hi,

 

For the system command, there is documentation on it here:

https://docs.epics-controls.org/en/latest/appdevguide/IOCShell.html

that explains you need to add the function registration to the database definition file. Was that done?

 

For your work-around, it could be automated by instead of executing the IOC st.cmd file directly to start the IOC, execute a bash script that first runs the Python program, and then the IOC st.cmd.

 

However, autosave should be working for the position restore. Can you us which version of the motor record you’re using? And does it have the RSTM field? The RSTM field was added in order to improve the options regarding position restore:

 

(0:"Never", 1:"Always", 2:"NearZero", 3:"Conditional")

 

RSTM=2 is the default, and that reproduces the old behavior of restoring the position only if the controller position is zero (+/-MRES). So, make sure RSTM is not being set to 0.

 

There may be a version of the motor support module where the autosave restore method was changed, and before RSTM was added.  

 

For some controllers and drivers you may need a short sleep (1s) after loading the driver and before executing the autosave functions and iocInit.

 

Also make sure you’re autosaving DVAL and not VAL.

 

Cheers,

Matt

 

From: Tech-talk <[email protected]> On Behalf Of Tran, Phi Dung via Tech-talk
Sent: Friday, December 19, 2025 10:30 AM
To: Mark Rivers via Tech-talk <[email protected]>
Subject: [EXTERNAL] power off/on ioc recovery

 

Hello, I'm trying to run a Python script from within my IOC startup script (st.cmd) to auto-generate a configuration file before iocInit(). However, I'm finding that the system() command is not available in my EPICS build. Background - Motor

Hello,

 

  I'm trying to run a Python script from within my IOC startup script (st.cmd) to auto-generate a configuration file before iocInit(). However, I'm finding that the system() command is not available in my EPICS build.

 

  Background - Motor Position Restoration Problem:

 

  I need to restore motor positions after a Galil motor controller power cycle. I discovered that:

 

  - Pass0 restore alone works when only restarting the IOC (controller stays powered on)

  - Pass0 restore fails when the controller is power cycled - the controller resets to 0, and motor record initialization overwrites the restored VAL field with the controller's position (0)

 

  My Solution:

  I use SET mode after iocInit() to restore positions without motor movement. To avoid hardcoded values, I wrote a Python script (generate_restore.py) that reads the latest autosave file and generates the restoration script with

  current saved values.

 

  What I'm trying to do:

  Run this Python script automatically during IOC startup (before iocInit) to ensure the restoration script always has the latest saved positions.

 

  What I've tried:

  system("cd /path/to/script && /usr/bin/python3 generate_restore.py")

 

  Error received:

  st.cmd line X: Command system not found.

 

  Also tried:

  - shell "command" - Command not found

  - ! command - Command not found

  - iocshCmd and iocshRun - Only execute EPICS commands, not shell commands

 

  Environment:

  - EPICS Base: R7.0.5

  - OS: Red Hat Enterprise Linux 8.10

  - IOC built from Galil motor driver (Galil-3-0/3-6)

 

  Questions:

  1. Is there a way to execute shell commands from within st.cmd in EPICS 7.0.5?

  2. Is system() command availability dependent on build configuration or compile-time options?

  3. Are there alternative approaches to run external scripts during IOC initialization?

  4. Is there a better approach to handle motor position restoration after controller power cycle?

 

  Current workaround:

  Running python3 generate_restore.py && ./st.cmd manually before each IOC start, but I'd prefer an automated solution.

 

  Any suggestions would be greatly appreciated!

 

  Thanks,

Alex


Replies:
Re: power off/on ioc recovery Tran, Phi Dung via Tech-talk
References:
power off/on ioc recovery Tran, Phi Dung via Tech-talk

Navigate by Date:
Prev: power off/on ioc recovery Tran, Phi Dung via Tech-talk
Next: Re: power off/on ioc recovery Tran, Phi Dung via Tech-talk
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  <20252026 
Navigate by Thread:
Prev: power off/on ioc recovery Tran, Phi Dung via Tech-talk
Next: Re: power off/on ioc recovery Tran, Phi Dung via Tech-talk
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  <20252026 
ANJ, 19 Mar 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·