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 <2021> 2022 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 <2021> 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Creating a record and using its instance. |
From: | "Hu, Yong via Tech-talk" <tech-talk at aps.anl.gov> |
To: | "Wang, Andrew" <wang126 at llnl.gov>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Mon, 12 Apr 2021 22:29:07 +0000 |
Firstly, this will make your build pass. Replace this line #include "sampleRecord.h" with these lines: #define GEN_SIZE_OFFSET #include "sampleRecord.h" #undef GEN_SIZE_OFFSET #include "epicsExport.h" Now, let’s back to the other business.
1) It seems you are new to EPICS. Why do you want to create a customized record type? Just for learning purpose? I did this kind of thing when I was a graduate student, but never did it again after I started
my real career job. Hope your purpose is not for a real production application. 2) I think the built-in record types should be enough for 99% (if not 100%) EPICS applications. If your application is really unique, you could describe your requirements, your purpose, etc. so that other
people here can help you find a reasonably practical solution. Cheers, Yong From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> 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 |