Files
hla_framework_bd/docs/developer/python/epics.md
T
Benjamin Labrecque ee57cf146c
Build and Publish Site / docker (push) Successful in 4s
docs: update epics docs
2026-08-26 16:06:19 +02:00

3.2 KiB

EPICS

Where is EPICS Base (https://gitea.psi.ch/epics) installed?

echo $EPICS

Host architecture that EPICS Base runs on:

echo $EPICS_HOST_ARCH

Which channel access lib is being used in python?

[sls-vserv-bd-hla01-dev ~]$ which python
/bin/python
[sls-vserv-bd-hla01-dev playground]$ python3 -c "import ctypes; import epics.ca; print(epics.ca.find_libca())"
/usr/local/epics/base-7.0.9/lib/RHEL9-x86_64/libca.so
[sls-vserv-bd-hla01-dev ~]$ source /opt/gfa/python-3.10/latest/bin/activate
(base) [sls-vserv-bd-hla01-dev ~]$ which python
/opt/gfa/python-3.10/20220602/bin/python
(base) [sls-vserv-bd-hla01-dev ~]$  python3 -c "import ctypes; import epics.ca; print(epics.ca.find_libca())"
/opt/gfa/python-3.10/20220602/epics/lib/linux-x86_64/libca.so

How does the conda env configure which EPICS to use?

(base) [sls-vserv-bd-hla01-dev ~]$ cat /opt/gfa/python-3.10/20220602/etc/conda/activate.d/epics-base_activate.sh
export EPICS_BASE="/opt/gfa/python-3.10/20220602/epics"
export EPICS_HOST_ARCH="linux-x86_64"
export EPICS_BASE_HOST_BIN="/opt/gfa/python-3.10/20220602/epics/bin/linux-x86_64"
export EPICS_BASE_VERSION="7.0.5.0"
export PATH=$EPICS_BASE_HOST_BIN:$PATH

How does the conda env configure which EPICS python uses?

(base) [sls-vserv-bd-hla01-dev ~]$ cat /opt/gfa/python-3.10/20220602/etc/conda/activate.d/pyepics_activate.sh
export PYEPICS_LIBCA="${EPICS_BASE}/lib/${EPICS_HOST_ARCH}/libca.so"

Example reading from a PV:

[sls-vserv-bd-hla01-dev ~]$ /bin/python
Python 3.9.25 (main, Apr 17 2026, 00:00:00)
[GCC 11.5.0 20240719 (Red Hat 11.5.0-14)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from epics import PV
>>> pv = PV("AGEBD-PLAYGROUND-DEV:AO")
>>> pv.get()
5.0
>>>

System python installed packages

/bin/python -m pip list -v

Systemd Services

When ssh-ing into a machine, /etc/profile.d/* automatically gets sourced. And thus we have:

[sls-vserv-bd-hla01-dev ~]$ env | grep EPICS
EPICS_CA_ADDR_LIST=sls-cagw.psi.ch:5062

When running a systemd service, this does not happen.

Note -- it seems that the following does not work as expected:

That's why we need to source `/etc/profile.d/cas_12_epics.sh` in our startup script
to make sure that `EPICS` is configured properly. 

After sourcing the script, we still have: EPICS_CA_ADDR_LIST= (i.e. the script does not set EPICS_CA_ADDR_LIST=sls-cagw.psi.ch:5062) in systemd service.

Whereas in the shell unset EPICS_CA_ADDR_LIST and then . /etc/profile/cas_12_epics.sh properly sets EPICS_CA_ADDR_LIST=sls-cagw.psi.ch:5062.

Check which env variables a systemd service is running with:

[sls-vserv-bd-hla01-dev ~]$ systemctl --user restart AGEBD-SERVICE-SCRUBBING.service && sleep 1 &&   PID=$(systemctl --user show -p MainPID --value AGEBD-SERVICE-SCRUBBING.service)
[sls-vserv-bd-hla01-dev ~]$   tr '\0' '\n' < /proc/$PID/environ | grep EPICS
EPICS_CAS_IGNORE_ADDR_LIST=
EPICS_CA_ADDR_LIST= 129.129.146.255
EPICS_HOST_ARCH=linux-x86_64
EPICS_BASE_HOST_BIN=/opt/gfa/python-3.10/20220602/epics/bin/linux-x86_64
PYEPICS_LIBCA=/opt/gfa/python-3.10/20220602/epics/lib/linux-x86_64/libca.so
EPICS_BASE_VERSION=7.0.5.0
EPICS_BASE=/opt/gfa/python-3.10/20220602/epics