Epics Tips And Tricks New Ioc Command
new IOC command
The general way how to add a new IOC command, which can be used inside the IOC Shell is described in Chapter 18.3
IOC Shell - IOC Shell Programming of the
IOC Application Developer's Guide (3.14.9).
Here is an example (with the help of
BK) to make the command
dumpTable(mbo, dac, channel, type)
available at the IOC shell.
#include <epicsExport.h>
/* ... */
/***************************************************************************/
static void dumpTable(int mbo, int dac, int channel, short type)
{
/* some function code */
/* ... */
}
/***************************************************************************/
/* Information needed by iocsh */
/* Argument definition */
static const iocshArg dumpTableArg0 = {"mbo number", iocshArgInt};
static const iocshArg dumpTableArg1 = {"dac number", iocshArgInt};
static const iocshArg dumpTableArg2 = {"channel number", iocshArgInt};
static const iocshArg dumpTableArg3 = {"table type", iocshArgInt};
static const iocshArg *dumpTableArgs[] =
{
&dumpTableArg0,
&dumpTableArg1,
&dumpTableArg2,
&dumpTableArg3
};
/* Function definition */
static const iocshFuncDef dumpTableFuncDef = {"dumpTable", 4, dumpTableArgs};
/* Wrapper called by iocsh, selects the argument types that dumpTable needs */
static void dumpTableCallFunc(const iocshArgBuf *args) {
dumpTable(args[0].ival, args[1].ival, args[2].ival, args[3].ival);
}
/* Registration routine, runs at startup */
static void dumpTableRegister(void) {
iocshRegister(&dumpTableFuncDef, dumpTableCallFunc);
}
epicsExportRegistrar(dumpTableRegister);
variable(mySubDebug)
...
registrar(dumpTableRegister)
--
PeterZumbruch - 2017-03-31