Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  <20022003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  Index 1994  1995  1996  1997  1998  1999  2000  2001  <20022003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017 
<== Date ==> <== Thread ==>

Subject: Re: How do I use registryFunctionAdd
From: Rozelle Wright <rwright@lanl.gov>
To: Marty Kraimer <mrk@aps.anl.gov>
Cc: tech-talk@aps.anl.gov
Date: Tue, 30 Jul 2002 11:52:55 -0600
Thanks, Marty
With a little help from Jeff on C++,
(I needed to surround the genSubUtil.h header file with
#ifdef __cpluplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
to keep c++ from mangling the subroutine names.
)
my genSub record is now working.
Rozelle


At 08:22 AM 7/30/2002 -0500, Marty Kraimer wrote:
I am attaching an example that works for subRecord.

The Makefile will just contain one extra statement similar to


example_SRCS += dbSubExample.cpp



Please note that the example works because constructors for static C++ objects get called when a application starts (on vxWorks when ld command is executed). The end of the example has the statements:

/*
 * Register commands on application startup
 */
class mySubRegister {
  public:
    mySubRegister() { mySubRecordFunctionsRegister(); }
};
static mySubRegister mySubRegisterObj;


mySubRegisterObj is a static object. At application startup its constructor is executed. In this example the constructor just calls mySubRecordFunctionsRegister.

Marty Kraimer

Rozelle Wright wrote:
>
> I am attempting to make a genSub record work with EPICS 3.14.beta1 using an
> example application and iocsh running on a pc with WINDOWS XP.  I see that
> registry information is automatically generated for the record, device and
> driver support from the dbd file, but I don't know how to persuade iocinit
> to find the functions that I need for the initialization and processing of
> the subroutine record.
> The genSubRecord code calls  registryFunctionFind to retrieve the address
> of the function from the name in the record (and fails because the
> functions are not registered).
> According to the registry section of the application developers guide, I
> should be using registryFunctionAdd to register the function, but I am not
> sure where to put this call.
> Has anyone done this who could give me an example?
>
> Thanks for any help you can give me.
> Rozelle Wright
> rwright@lanl.gov#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

#include <registryFunction.h>
#include <subRecord.h>

extern "C" {
typedef long (*processMethod)(subRecord *precord);
long mySubInit(subRecord *precord,processMethod process);
long mySubProcess(subRecord *precord);
void mySubRecordFunctionsRegister(void);
}

long mySubInit(subRecord *precord,processMethod process)
{
    printf("%s mySubInit process %p\n",precord->name,process);
    return(0);
}

long mySubProcess(subRecord *precord)
{
    printf("%s mySubProcess\n",precord->name);
    return(0);
}

void mySubRecordFunctionsRegister(void)
{

if(!registryFunctionAdd("mySubInit",(REGISTRYFUNCTION)mySubInit))
errlogPrintf("mySubRecordFunctionsRegister registryFunctionAdd failed\n");
if(!registryFunctionAdd("mySubProcess",(REGISTRYFUNCTION)mySubProcess))
errlogPrintf("mySubRecordFunctionsRegister registryFunctionAdd failed\n");
}


/*
 * Register commands on application startup
 */
class mySubRegister {
  public:
    mySubRegister() { mySubRecordFunctionsRegister(); }
};
static mySubRegister mySubRegisterObj;



References:
How do I use registryFunctionAdd Rozelle Wright
Re: How do I use registryFunctionAdd Marty Kraimer

Navigate by Date:
Prev: Re: side-effect of malloc() in startup file Korhonen Timo
Next: GPIB + vxStats hangs IOC Benjamin Franksen
Index: 1994  1995  1996  1997  1998  1999  2000  2001  <20022003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017 
Navigate by Thread:
Prev: Re: How do I use registryFunctionAdd Marty Kraimer
Next: GPIB + vxStats hangs IOC Benjamin Franksen
Index: 1994  1995  1996  1997  1998  1999  2000  2001  <20022003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·