Skip to content

Commit

Permalink
Do not allow CONFIG macro in addSlave.cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
anderssandstrom committed Mar 8, 2024
1 parent 09dd781 commit c98b0da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions scripts/addSlave.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#-d \param NELM (optional) Used for oversampling cards. Defaults to 1
#-d \param DEFAULT_SUBS (optional) option to disble default PVs for mapped PDOs
#-d \param DEFAULT_SLAVE_PVS (optional, caution!) basic slave PVs, i.e. ${ECMC_P}-Operational will be suppressed
#-d \param CALLED_FROM_CFG_SLAVE (optional) Set if called by configureSlave.cmd, default 0
#-d \note Example calls:
#-d \note - call w/o SLAVE_ID
#-d \code
Expand All @@ -35,6 +36,11 @@
#-d \post After all slaves have been added to the bus configuration, \b applyConfig.cmd has to be called.
#-d */

#- Only allow macro CONFIG if called from configureSlave.cmd (avoid copy paste errors)
ecmcIf("'${CONFIG=NAN}'!='NAN' and ${CALLED_FROM_CFG_SLAVE=0}!=1")
${IF_TRUE}ecmcExit : Error: addSlave.script is not accepting CONFIG macro. Use configureSlave.cmd instead
ecmcEndIf()

epicsEnvSet("ECMC_EC_SLAVE_NUM", "${SLAVE_ID=0}")
epicsEnvSet("HW_DESC", "${HW_DESC}")
epicsEnvSet("P_SCRIPT", "${P_SCRIPT=${ECMC_P_SCRIPT}}")
Expand Down
3 changes: 2 additions & 1 deletion scripts/configureSlave.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
epicsEnvSet("ECMC_EC_SLAVE_NUM", "${SLAVE_ID=0}")
epicsEnvSet("HW_DESC", "${HW_DESC}")
ecmcFileExist("${ECMC_CONFIG_ROOT}addSlave.cmd",1)
${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}addSlave.cmd "SLAVE_ID=${ECMC_EC_SLAVE_NUM}, HW_DESC=${HW_DESC}, NELM=${NELM=1}"
${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}addSlave.cmd "SLAVE_ID=${ECMC_EC_SLAVE_NUM}, HW_DESC=${HW_DESC}, NELM=${NELM=1},CALLED_FROM_CFG_SLAVE=1"
# apply config ${CONFIG} for ${HW_DESC}
ecmcFileExist("${ECMC_CONFIG_ROOT}ecmc${HW_DESC}${CONFIG}.cmd",1)
${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}ecmc${HW_DESC}${CONFIG}.cmd "${CFG_MACROS=""}"
epicsEnvUnset(CALLED_FROM_CFG_SLAVE)

0 comments on commit c98b0da

Please sign in to comment.