## EIOC-LI24-BL01 RTEMS startup script for Bunch Length Coldfire App in LAB 

## Set common environment variables
< /boot/epics/iocCommon/All/Dev/pre_st.cmd
epicsEnvSet ("EPICS_CA_MAX_ARRAY_BYTES", "600000")

############################################## 
# Dedicated ethernet + network stack driver
#setenv("IPADDR1","192.168.1.101",1)
#setenv("NETMASK1","255.255.255.0",1)
setenv("IPADDR1","172.25.160.21",1)
setenv("NETMASK1","255.255.255.192",1)
setenv("PADSLOT","3",1)
setenv("LOCAs","LI24",1)
setenv("UNITs","886",1)
ld("lanIpBasic_ln9.obj")  #check that it finds this
# Turning on lanIpDebug shows you all the ARP requests on the console
lanIpDebug    = 0
lanIpSetup(getenv("IPADDR1"),getenv("NETMASK1"),0,0)
############################################## 

# Set some abbreviations 
ld    = cexpModuleLoad
unld  = cexpModuleUnload

cd("../..")
# load app
ld("bin/RTEMS-uC5282/BunchLengthCF.obj") 

## Register all support components
dbLoadDatabase("dbd/BunchLengthCF.dbd")
BunchLengthCF_registerRecordDeviceDriver(pdbbase) 

## Load record instances
dbLoadRecords("db/EIOC-LI24-BL01.db")

## Set to 2 so that we see errors
devLongoutBunchLengthCFFlag=2
devLonginBunchLengthCFFlag=2
devWaveformBunchLengthCFFlag=2
devMbboBunchLengthCFFlag=2
devBoBunchLengthCFFlag=2
drvBunchLengthCFFlag=2
drvBlmLan9118Flag=4
drvBunchLengthCFCfgFlag=2
drvBunchLengthCFScalFlag=2
drvBunchLengthCFIntrFlag=2

gNumChanToAcq=2
# multicast addr 239.27.99.4
padgMcastAddr=0xEF1B6304

# change directory to local mountpoint so that files don't need path to dir in their name
cd("/data/eioc-li24-bl01")

iocInit()

# Set the offset to the windows for each channel here.
# Note: that "3" is always added to what you set to allow for the fact
# that it takes 3 clock cycles before any data shows up to be read from FIFOs
dbpf("BLEN:LI24:886:BL21A_OFST","0")
dbpf("BLEN:LI24:886:BL21B_OFST","0")
dbpf("BLEN:LI25:883:BL22A_OFST","0")
dbpf("BLEN:LI25:883:BL22B_OFST","0")
# Set the offset to the windows for each channel's calibration mode here
dbpf("BLEN:LI24:886:BL21A_RC_OFST","0")
dbpf("BLEN:LI24:886:BL21B_RC_OFST","0")
dbpf("BLEN:LI25:883:BL22A_RC_OFST","0")
dbpf("BLEN:LI25:883:BL22B_RC_OFST","0")

# Set the sizes of the windows for each channel here
dbpf("BLEN:LI24:886:BL21A_SIZE","512")
dbpf("BLEN:LI24:886:BL21B_SIZE","512")
dbpf("BLEN:LI25:883:BL22A_SIZE","512")
dbpf("BLEN:LI25:883:BL22B_SIZE","512")
# Set the sizes of the windows for each channel's calibration mode here
dbpf("BLEN:LI24:886:BL21A_RC_SIZE","65536")
dbpf("BLEN:LI24:886:BL21B_RC_SIZE","65536")
dbpf("BLEN:LI25:883:BL22A_RC_SIZE","65536")
dbpf("BLEN:LI25:883:BL22B_RC_SIZE","65536")

##blcSetDataFileStem("Sheng")  # The stem to start all data files with
                                # Format is "<stem><secPastEpoch>.dat"


