EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Creating a record and using its instance.
From: "Wang, Andrew via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Mon, 12 Apr 2021 18:46:30 +0000

All,

 

This will be a lengthy post, so please bear with me.

 

I am currently trying to create my own record called “sample”, then create a record instance of “sample” for use in an IOC. The manual helped immensely, but I am still a bit stuck and would appreciate some insight.

 

For creating the record, what I did first was first create a support application by using the command:

 

makeBaseApp.pl -t support sample

 

Then, I modified the configure/RELEASE file so that the correct path for EPICS is specified. Next, I went to sampleApp/src and created two files: sampleRecord.dbd and sampleRecord.c. Here is what I currently have for them.

 

sampleRecord.dbd:

 

recordtype(sample)

{

      include "dbCommon.dbd"

      field(VAL, DBF_DOUBLE)

      {

            asl(ASL0)

            pp(TRUE)

      }

      field(OVAL, DBF_DOUBLE)

      {

      }

}

 

sampleRecord.c:

 

// EPICS IOC header files

#include "callback.h"

#include "dbAccess.h"

#include "dbBase.h"

#include "dbDefs.h"

#include "dbFldTypes.h"

#include "dbScan.h"

#include "dbStaticLib.h"

#include "devLib.h"

#include "devSup.h"

#include "drvSup.h"

#include "epicsExport.h"

#include "initHooks.h"

#include "link.h"

#include "recSup.h"

#include "special.h"

#include "taskwd.h"

 

// Record support header files

#include "sampleRecord.h"

 

// C standard library header files

#include <stdio.h>

static long init_record(void*, int);

static long process(void*);

rset sampleRSET={

    RSETNUMBER,

    NULL,

    NULL,

    init_record,

    process,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL

};

epicsExportAddress(rset, sampleRSET);

 

static long init_record(void* precord, int pass)

{

      //long status;

      //int size_desc;

      sampleRecord *r;

     

      r = (sampleRecord *) precord;

     

      if (!pass)

      {

            //size_desc = sizeof(r->desc) / sizeof(char);

            //snprintf(r->desc, size_desc, "%s", "Hello");

            printf("I've been initialized!\n");

           

            return 0;

      }

     

      return 0;

}

 

static long process(void* precord)

{

      printf("I've been processed!\n");

     

      return 0;

}

 

My goal is to use channel access and see those two messages printed when running iocBoot. For instance, when I run caput sample_record_instance.PROC 1, hopefully it will print “I’ve been processed”.

 

In my following steps, I modified the Makefile in sampleApp/src to be:

 

TOP=../..

 

include $(TOP)/configure/CONFIG

#----------------------------------------

#  ADD MACRO DEFINITIONS AFTER THIS LINE

#=============================

 

#==================================================

# build a support library

 

LIBRARY_IOC += sample

 

# xxxRecord.h will be created from xxxRecord.dbd

DBDINC += sampleRecord.h

 

# install sample.dbd into <top>/dbd

DBD += sampleRecord.dbd

 

# specify all source files to be compiled and added to the library

sample_SRCS += sampleRecord.c

 

sample_LIBS += $(EPICS_BASE_IOC_LIBS)

 

#===========================

 

include $(TOP)/configure/RULES

#----------------------------------------

#  ADD RULES AFTER THIS LINE

 

So after making these modifications and additions, I ran make in TOP and no errors were produced.

 

Finally, I created an IOC application and iocBoot type called “test_sample”. In the configure/RELEASE file, I included:

 

SAMPLE = ${HOME}/myepics/support/sample

 

Then, I created a record instance for “sample” in a database file within test_sampleApp/Db:

 

record(sample, “sample_record_instance”)

{

      field(DESC, “Yay”)

}

 

Finally, I modified the Makefile in test_sampleApp/src to be:

 

TOP=../..

 

include $(TOP)/configure/CONFIG

#----------------------------------------

#  ADD MACRO DEFINITIONS AFTER THIS LINE

#=============================

 

#=============================

# Build the IOC application

 

PROD_IOC = test_sample

 

# test_sample.dbd will be created and installed

DBD += test_sample.dbd

 

# test_sample.dbd will be made up from these files:

test_sample_DBD += base.dbd

 

# Include dbd files from all support applications:

test_sample_DBD += sampleRecord.dbd

 

# Add all the support libraries needed by this IOC

test_sample_LIBS += sample

 

# test_sample_registerRecordDeviceDriver.cpp derives from test_sample.dbd

test_sample_SRCS += test_sample_registerRecordDeviceDriver.cpp

 

# Build the main IOC entry point on workstation OSs.

test_sample_SRCS_DEFAULT += test_sampleMain.cpp

test_sample_SRCS_vxWorks += -nil-

 

# Add support from base/src/vxWorks if needed

#test_sample_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary

 

# Finally link to the EPICS Base libraries

test_sample_LIBS += $(EPICS_BASE_IOC_LIBS)

 

#===========================

 

include $(TOP)/configure/RULES

#----------------------------------------

#  ADD RULES AFTER THIS LINE

 

However, when I run make in TOP, I receive the following error:

 

test_sample_registerRecordDeviceDriver.o: In function `_GLOBAL__sub_I_test_sample_registerRecordDeviceDriver':

test_sample_registerRecordDeviceDriver.cpp:(.text.startup+0x2b5): undefined reference to `pvar_func_sampleRecordSizeOffset'

 

Any thoughts?

 

Thank you,

Andy


Replies:
Re: Creating a record and using its instance. Hu, Yong via Tech-talk
Re: Creating a record and using its instance. Johnson, Andrew N. via Tech-talk

Navigate by Date:
Prev: Re: streamdevice error messages Ben Franksen via Tech-talk
Next: Re: line scan camera with ADAravis driver skips frames Katie Matusik via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
Navigate by Thread:
Prev: Driver for Agilent TwisTorr 305-IC Gay, Gregory (DLSLtd, RAL, LSCI) via Tech-talk
Next: Re: Creating a record and using its instance. Hu, Yong via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
ANJ, 12 Apr 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·