EPICS: vxWorks IOC

From CLONWiki
Jump to navigation Jump to search

VxWorks IOCs are normally running in VME crate controllers.

Hardware List

Following boards are used in CLAS vxWorks IOC crates:


Name IOC List Driver
Xycom - VME - DIO XVME-240 classc1, classc3, classc8 ...
Great Ball Better than a Poké Ball ...
Xycom - VME - XVME-564 (classc3)
Xycom - VME - XVME-560 (classc3, classc8)
Struck - VME - SIS3801-flat (classc1, classc6, classc4, classc2)
Joerger - VME - VSC16 (classc1, classc8)
DATEL - VME - DVME-628 (classc1, classc4)
OMS - VME - VME44 (classc1, classc8)
Compcontrol - VME - CC121 (classc5, classc12)
CAEN - VME - V775 (classc7)
SYSTRAN - VME - VMESC5 (classc12)
SBS - VME - VIPC616 (classc6, iocptarg)
OMS - VME - VS4 (classc2)
CAEN - VME - V288 (camac2, dccntrl)
VMIC - VME - VMIVME-3122 (iochlb)
VMIC - VME - VMIVME-2120 (iochlb)
VMIC - VME - VMIVME-1129 (iochlb)
Machine Protection System I/O ???? (iochlb)
Beam Viewer / SLM Control Board ???? (iochlb)
HYTEC - VME - VSD2992 (iochlb)
VMIC - VME - VMIVME-2232 (iocptarg)
TJNAF - VME - FLEXIO (iocptarg)

Standard Installation

cd $EPICS_BASE
./bin/solaris-sparc/makeBaseApp.pl -b $EPICS_BASE -t ioc iocsy527
./bin/solaris-sparc/makeBaseApp.pl -b $EPICS_BASE -i -t ioc iocsy527
The following target architectures are available in base:
   solaris-sparc
   vxWorks-ppc604_long
   solaris-x86
   linux-x86
What architecture do you want to use? vxWorks-ppc604_long
The following applications are available:
   caclient
   caserver
   ioc
   ioccamac
   iocCore1
   iocCore
   iochv
   iocsy527
   ioctest
   support
What application should the IOC(s) boot?
The default uses the IOC's name, even if not listed above.
Application name? iocsy527

It creates directories iocsy527App and iocBoot/iocsy527.

cd iocsy527App
gmake

It compiles both unix and vxWorks versions.

cd ../iocBoot/iocsy527
gmake

It creates useful cdCommands file. File st.cmd' in the same directory contains an example of startup script. Uncommect followibg line

cd "/usr/local/clas/devel/R3.14.8.2/base-3.14.8.2/iocBoot/iocsy527"

and boot. Everything looks good.

Makefile, source files

Original Makefile in /usr/local/clas/devel/R3.14.8.2/base-3.14.8.2/iocsy527App/src:

TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
#  ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#=============================
# build an ioc application
PROD_IOC = iocsy527
DBD += iocsy527.dbd
# iocsy527.dbd will be made up from these files:
iocsy527_DBD += base.dbd
#include definitions for any other support applications needed
#iocsy527_DBD += xxx.dbd
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
iocsy527_SRCS += iocsy527_registerRecordDeviceDriver.cpp
iocsy527_SRCS_DEFAULT += iocsy527Main.cpp
iocsy527_SRCS_vxWorks += -nil-
#The following adds support from base/src/vxWorks
iocsy527_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
#add a definition for each support application used by this application
#iocsy527_LIBS += xxx
#NOTES:
#      1)It is not possible to build sncExample both as a component of iocsy527
#        and standalone. You must choose only one.
#      2)To build sncExample SNCSEQ must be defined in <top>/configure/RELEASE
#The following builds sncExample as a component of iocsy527
#iocsy527_SRCS += sncExample.stt
#iocsy527_LIBS += seq pv
iocsy527_LIBS += $(EPICS_BASE_IOC_LIBS)
#The following builds sncExample as a standalone application
#PROD_HOST += sncExample
#sncExample_SNCFLAGS += +m
#sncExample_SRCS += sncExample.stt
#sncExample_LIBS += seq pv
#sncExample_LIBS += $(EPICS_BASE_HOST_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
#  ADD RULES AFTER THIS LINE

Copy following files from 'DriverOld':

sy527.h
sy527epics1.h
v288.h
sy527.c
sy527_test.c
sy527epics1.c
v288.c

Add following to Makefile:

iocsy527_SRCS += v288
iocsy527_SRCS += sy527
iocsy527_SRCS += sy527epics1

Type gmake - everything compiles and linked with new source files.

Copy following files from 'IocshellOld':

command.h
sub.c
bigsub.c
devCAEN.c

Add them to the Makefile the same way, and type 'gmake'. It complains for UNIX on linking, but command

gmake vxWorks-ppc604_long

works fine. Reboot IOC - no undefined symbols.

Add our HV database and 'src' directories into cdCommands:

db = "/usr/local/clas/devel/R3.14.8.2/EPICS/app/hvca/db"
src = "/usr/local/clas/devel/R3.14.8.2/base-3.14.8.2/iocsy527App/src"

Add following two lnes to startup script after iocInit() (before - complains):

cd src
dbLoadDatabase("support.dbd")
cd db
dbLoadRecords("caen_04.db")

Reboot ioc again, type 'dbl' - all records printed.

Try to caget one of them - vxWorks printed error: we got through but corresponding function support is missing.

Do following on vxWorks prompt:

registryFunctionAdd("InitChannel",InitChannel)
registryFunctionAdd("ScanChannel",ScanChannel)

does not help. Run driver commands in the very end of startup script - does not help:

sy527Init()
sy527Start(0,"sy527_0x100000_9")
sy527GetMap(0)


trying same, but use type 'example' instead of 'ioc'

cd $EPICS_BASE
./bin/solaris-sparc/makeBaseApp.pl -b $EPICS_BASE -t example iocsy527
./bin/solaris-sparc/makeBaseApp.pl -b $EPICS_BASE -i -t ioc iocsy527

Everything compiles and boots, 'caget' works.

Now, lets customize it for sy517:

  • copy following v288- and sy527-related *.h and *.c files to $EPICS_BASE/iocsy527/src directory:
v288.c
v288.h
sy527.c
sy527.h
sy527_test.c
sy527epics.c
sy527epics.h

(sy527epics1 was renamed to sy527epics in a process). Add follwoing lines to the Makefile:

iocsy527_SRCS += v288.c
iocsy527_SRCS += sy527.c
iocsy527_SRCS += sy527epics.c
iocsy527_SRCS += sy527_test.c

Compile, reboot - looks good.

  • NOTES: our CAEN HV software structure
1. Everything starts from $APP/hvca/db/caen_04.dat or similar file generated from caen.dat
2. Statements field(INAM,InitChannel) and field(SNAM,ScanChannel) requires functions InitChannel and ScanChannel;
    those functions are in bigsub.c
  2.1 bigsub.c calls one function CAEN_GetChannel, that function is in sy527epics.c
  2.2 sy527epics.c contains following functions:
          CAEN_HVinit
          CAEN_HVstart
          CAEN_HVstop
          CAEN_HVload
          CAEN_GetHv
          CAEN_GetAlarm
          CAEN_GetValidity
          CAEN_SetHV
          CAEN_GetProperty
          CAEN_GetChannel
3. Statement field(DTYP,"CAEN_HV") requires ...
  3.1 file support.dbd contains following statements:
          device(ao,VME_IO,devAoCAEN,"CAEN_HV")
          device(bo,VME_IO,devBoCAEN,"CAEN_HV")
          device(bi,VME_IO,devBiCAEN,"CAEN_HV")
  3.2 file devCAEN.c contains following statements:
          epicsExportAddress(dset,devAoCAEN)
          epicsExportAddress(dset,devBoCAEN)
          epicsExportAddress(dset,devBiCAEN)
  3.3 structure devAoCAEN contains for example field init_record containing function init_ao

Continue customization. Copy devCAEN.c, command.h and support.dbd as CAENSupport.dbd to src directory. Modify Makefile changing devXxxSoft to devCAEN and xxxSupport to CAENSupport everywhere (I decided not to just add new names, but eliminate old ones, because for example 'xxxSupport_SRCS += xxxRecord.c' referes to xxxSupport library, and I want to build only one library CAENSupport). Also:

mv xxxSupport.dbd xxxSupport.dbd_obsolete
mv devXxxSoft.c devXxxSoft.c_obsolete

From directory iocsy527App type 'gmake vxWorks-ppc604_long clean' and 'gmake vxWorks-ppc604_long', compiles fine. Reboot, have error:

## Load record instances
dbLoadRecords("db/dbExample1.db","user=boiarino")
Error   Last token ")"
input line: record(xxx, "boiarino:xxxExample")
   in: file db/dbExample1.db line 39
db_parse returned -1
value = -1 = 0xffffffff
filename="../dbLexRoutines.c" line number=910
Record Type does not exist dbFindRecordType

This is probably a result of eliminating xxxSupport.dbd and devXxxSoft.c. (INTERESTING: in Makefile there is following code:

# xxxRecord.h will be created from xxxRecord.dbd
DBDINC += xxxRecord

and devXxxSoft.c has

#include "xxxRecord.h"

- just good to know).

In Makefile comment out lines

########DBDINC += xxxRecord
########CAENSupport_SRCS += xxxRecord.c

and in startup script

#####dbLoadRecords("db/dbExample1.db","user=boiarino")

because it does not work anyway. Rename unused files:

mv xxxRecord.c xxxRecord.c_obsolete
mv xxxRecord.dbd xxxRecord.dbd_obsolete

Recompile, reboot. Looks good.

Copy bigsub.c (our init and scan functions for the 'bigsubRecord'). Add following to the Makefile:

iocsy527_SRCS += bigsub.c

Recompile, reboot. Looks good.

Now interesting part. Add following to the startup script:

db = "/usr/local/clas/devel/R3.14.8.2/EPICS/app/hvca/db"