mdavidsaver / pyDevSup

EPICS Device Support in Python
GNU General Public License v2.0
13 stars 16 forks source link

Questioning whether pySetupReg is registering #15

Closed dcrisp2 closed 5 years ago

dcrisp2 commented 5 years ago

Hello there! So we have pydevsup packaged, and generally it's working fine. But it seems that the py() functions aren't getting registered in the st.cmd, as the IOCshell can't find them. What can I do to fix this? I'm trying to make some edits to my syncCalc.py file, and would enjoy some python logging from the iocshell.

As is, we have an IOC made with iocBoot and ${IOC}App directories. pyDevSup is pulled into the ioc with the ${IOC}App/src/Makefile line: ${IOC}_DBD += pyDevSup.dbd. So instead of pointing to softIocPy2.7, the st.cmd is pointing to the relevant ${TOP}/dbd/${IOC}.dbd.

Is this the wrong way to go about it?

I have tried not using an app folder at all, and having my st.cmd use /usr/bin/softIocPy2.7, but it spit out errors about not finding files from what looked like core support packages. If I can help it, for now at least, I'd like to avoid getting lost in fixes to our pydevsup packaging.

mdavidsaver commented 5 years ago

Does your dbd/$(IOC).dbd contain the line registrar(pySetupReg)?

grep 'registrar(pySetupReg)'  ${TOP}/dbd/${IOC}.dbd

A quick way to check if your generated .dbd includes a particular piece, and that there isn't some Makefile typo, is to check that the contents of the piece is present. In this case, pyDevSup.dbd contains registrar(pySetupReg) which is what should do the work of registering the py() ioc shell function.

dcrisp2 commented 5 years ago

I'd actually already grepped for pySetupReg, after realizing you mentioned it in the first line of your documentation on environment. The line 'registrar(pySetupReg)' is indeed in my ${IOC}.dbd. Other suggestions?

mdavidsaver commented 5 years ago

Can I see your st.cmd script? Also the output of help, which will list the registered commands. FYI. there is some ordering restriction. Most commands only become available after the *_registerRecordDeviceDriver pdbbase line.

dcrisp2 commented 5 years ago

Sure thing. You'll see that I have a few attempts at using python in there. Please forgive my poor comment formatting.

In the meantime, your note about ordering makes a lot of sense, I'll try moving the commands to AFTER the '*_registerRecordDeviceDriverp(dbbase)' line.

`#!../../bin/linux-x86_64/secar-sync

You may have to change secar-sync to something else

everywhere it appears in this file

< envPaths

epicsEnvSet("EPICS_CA_AUTO_ADDR_LIST","YES") epicsEnvSet("ENGINEER", "crispd") epicsEnvSet("LOCATION", "rea-hlapps")

epicsEnvSet("EPICS_IOC_LOG_INET", "facility-syslog.cts")

epicsEnvSet("EPICS_IOC_LOG_PORT", "7004")

epicsEnvSet("AS_PATH", "/mnt/iocdata/autosave/${IOC}")

epicsEnvSet("IOCNAME", "${IOC}") epicsEnvSet("AS_PATH", "${TOP}/as/${IOC}")

/usr/bin/python -c 'import logging; logging.basicConfig(level=logging.DEBUG)' py "import logging" py "logging.basicConfig(level=logging.DEBUG)" py("import logging") py("logging.basicConfig(level=logging.DEBUG)")

Register all support components

dbLoadDatabase("${TOP}/dbd/secar-sync.dbd",0,0) secar_sync_registerRecordDeviceDriver(pdbbase)

Load record instances

dbLoadTemplate "syncdevs.substitutions" dbLoadRecords("${TOP}/db/secar.db")

picks up IOC, ENGINEER, LOCATION from environment vars

dbLoadRecords("${EPICS_BASE}/db/save_restoreStatus.db", "P=${IOC}:") dbLoadRecords("${EPICS_BASE}/db/iocAdminScanMon.db", "IOC=${IOC}") dbLoadRecords("${EPICS_BASE}/db/iocAdminSoft.db", "IOC=${IOC}") dbLoadRecords("${EPICS_BASE}/db/softIocExit.db", "IOC=${IOC}")

dbLoadRecords("${EPICS_BASE}/db/reccaster.db", "P=${IOC}:")

Channel Access Security config

asSetFilename("${TOP}/iocBoot/${IOC}/asrules.cfg")

autosave/restore machinery

save_restoreSet_Debug(0) save_restoreSet_IncompleteSetsOk(1) save_restoreSet_DatedBackupFiles(1)

set_savefile_path("${AS_PATH}") set_requestfile_path("${AS_PATH}") set_requestfile_path("${EPICS_BASE}/as/req")

set_pass0_restoreFile("info_positions.sav") set_pass0_restoreFile("info_settings.sav") set_pass1_restoreFile("info_settings.sav")

iocInit() iocLogInit()

secar-sync IOC started:

system('date')

catalog of caPutLogInit levels:

define caPutLogNone -1 / no logging (disable) /

define caPutLogOnChange 0 / log only on value change /

define caPutLogAll 1 / log all puts /

define caPutLogAllNoFilter 2 / log all puts no filtering on same PV/

caPutLogInit("${EPICS_IOC_LOG_INET}:${EPICS_IOC_LOG_PORT}", 1)

more autosave/restore machinery

system "test -d ${AS_PATH} || mkdir -p ${AS_PATH}" makeAutosaveFileFromDbInfo("${AS_PATH}/info_positions.req", "autosaveFields_pass0") makeAutosaveFileFromDbInfo("${AS_PATH}/info_settings.req", "autosaveFields") create_monitor_set("info_positions.req", 5 , "") create_monitor_set("info_settings.req", 15 , "") create_monitor_set("ioc_stats_settings.req", 15 , "IOC=${IOC}") `

dcrisp2 commented 5 years ago

You were absolutely right, I just had to move the python commands to AFTER I load my ioc.dbd, and registerRecordDeviceDriver(pdbbase).

mdavidsaver commented 5 years ago

Ok, no problem.