Epics@GSI Webhome

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.

  • application.c
      #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);
      

  • application.dbd
      variable(mySubDebug)
      ...
      registrar(dumpTableRegister)
      
-- PeterZumbruch - 08 May 2008


-- PeterZumbruch - 2017-03-31
-- PeterZumbruch - 2018-01-08

This topic: Epics > WebHome > DevelopersCorner > EpicsTipsAndTricksAndExamples > EpicsTipsAndTricksNewIocCommand
Topic revision: 2018-01-08, PeterZumbruch
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback | Legal notice | Privacy Policy (german)