Skip to content

Commit

Permalink
iocutca, service: use a single afc-ioc service.
Browse files Browse the repository at this point in the history
This means we need to use decode-reg in run.sh to know what type of
board is being used, in order to launch the appropriate st.cmd file.
  • Loading branch information
ericonr committed Aug 9, 2023
1 parent d91cf5d commit 2babe96
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 84 deletions.
42 changes: 42 additions & 0 deletions iocBoot/iocutca/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

set -eu

export SLOT=$1

CRATE=$(./getCrate.sh)
VSLOT=$(./getSlot.sh $SLOT)

cmd=
case "$(decode-reg build_info -q --slot ${SLOT})" in
afc-tim-receive*)
CRATE=${CRATE#0}

. ./tim-slot-mapping
val_name=CRATE_${CRATE}_TIM_RX_${VSLOT}_PV_AREA_PREFIX
eval "export AREA_PREFIX=\$${val_name}"
val_name=CRATE_${CRATE}_TIM_RX_${VSLOT}_PV_DEVICE_PREFIX
eval "export DEVICE_PREFIX=\$${val_name}"

case $(hostname) in
ia-*) ;;
*) export EPICS_CA_ADDR_LIST=10.0.38.59:60000
esac

cmd=TIM
;;
afcv4_fofb_ctrl*)
. ./fofb-slot-mapping
val_name=CRATE_${CRATE}_FOFB_${VSLOT}_PV_AREA_PREFIX
eval "export AREA_PREFIX=\$${val_name}"
val_name=CRATE_${CRATE}_FOFB_${VSLOT}_PV_DEVICE_PREFIX
eval "export DEVICE_PREFIX=\$${val_name}"
export RTM_PREFIX=SI-${CRATE}

cmd=FOFB
;;
esac

if [ -n "$cmd" ]; then
exec procServ -f -n afc-ioc-${SLOT} -L- -i ^C^D -P $(expr 1700 + ${SLOT%-*}) ./st${cmd}.cmd
fi
17 changes: 0 additions & 17 deletions iocBoot/iocutca/runFOFB.sh

This file was deleted.

23 changes: 0 additions & 23 deletions iocBoot/iocutca/runTIM.sh

This file was deleted.

2 changes: 1 addition & 1 deletion service/95-erics.rules → service/95-afc.rules
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUBSYSTEM=="pci", ATTR{vendor}=="0x10ee", ATTR{subsystem_device}=="0x0007", RUN+="/usr/bin/setpci -s %k COMMAND=0x2", RUN+="/bin/sh -c 'chmod 666 /sys/bus/pci/devices/%k/resource*'", RUN+="/opt/erics/service/erics-start.sh %k"
SUBSYSTEM=="pci", ATTR{vendor}=="0x10ee", ATTR{subsystem_device}=="0x0007", RUN+="/usr/bin/setpci -s %k COMMAND=0x2", RUN+="/bin/sh -c 'chmod 666 /sys/bus/pci/devices/%k/resource*'", RUN+="/opt/afc-epics-ioc/service/ioc-start.sh %k"
11 changes: 11 additions & 0 deletions service/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=AFC EPICS IOC %i

[Service]
User=iocs
Group=iocs

MemoryAccounting=yes

WorkingDirectory=/opt/afc-epics-ioc/iocBoot/iocutca
ExecStart=/opt/afc-epics-ioc/iocBoot/iocutca/run.sh %i
11 changes: 0 additions & 11 deletions service/[email protected]

This file was deleted.

21 changes: 0 additions & 21 deletions service/erics-start.sh

This file was deleted.

11 changes: 0 additions & 11 deletions service/[email protected]

This file was deleted.

19 changes: 19 additions & 0 deletions service/ioc-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
set -eu

DEV=$1

devslot=
for slot in /sys/bus/pci/slots/* ; do
ADDR=$(cat ${slot}/address)
if [ "${ADDR}.0" = "${DEV}" ]; then
devslot=$(basename ${slot})
break
fi
done

case "$(decode-reg build_info -q --slot ${devslot})" in
afc-tim-receive*|afcv4_fofb_ctrl*)
systemctl restart afc-ioc@${devslot}.service
;;
esac

0 comments on commit 2babe96

Please sign in to comment.