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
> [email protected]#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;