Today, Zen presented a talk on asynportdriver. During the discussion, we talked about aai, aao and waveform and Steph suggested a codeathon task to


combine  them all into waveform and have a flag to define your own bptr. I  mentioned that this can be done in waveform as is, by freeing bptr.

Here is the init routine that does that (in orange)
\\

/\* $Id: devWaveformLlrf.c,v 1.20 2009/06/05 00:43:09 dayle Exp $ \*/

/*=============================================================================
 
  Name: devWaveformLlrf.c

  Abs:  Device support for saving raw digitizer data into a waveform
        (4 channels into a single, row-major array).

  Auth: 10-nov-2006, Till Straumann (TSS)
  Rev:  2008 Dayle Kotturi: adapt read_waveform contents to LLRF app

\-----------------------------------------------------------------------------*/

\#if 0
\#include "copyright_SLAC.h"    /\* SLAC copyright comments \*/
\#endif
 
/*----------------------------------------------------------------------------\-
 
  Mod:  (see CVS log)

 
=============================================================================*/

...

static long
init_record(void \*record_p)
{
waveformRecord      \*waveform_ps = record_p;
DevWfRawSigDpvt_tps    dpvt_ps;

    /\* Check DB configuration \*/

    if ( waveform_ps->ftvl \!= menuFtypeSHORT ) {
        epicsPrintf
                (DEVSUPNAM": Error \-\- FTVL should be SHORT (is %i)\n",
                waveform_ps->ftvl);
        goto egress;
    }
    epicsPrintf(DEVSUPNAM": FTVL is SHORT\n");

    /\* Set NELM to what the driver is configured for \*/
{color:#993366} {color}{color:#ff6600}   free(waveform_ps->bptr);{color}

        waveform_ps->nelm = 4*drvPadUdpCommGetNsamples(/*dpvt_ps->station_type*/);
    epicsPrintf(DEVSUPNAM": NELM is %d\n", (int) waveform_ps->nelm);

    if ( \!(waveform_ps->bptr = calloc(waveform_ps->nelm, sizeof(short))) ) {
        /\* If there's no memory we are unlikely to be able to print something \*/
        goto egress;
    }


    if ( VME_IO \!= waveform_ps->inp.type ) {
        epicsPrintf(DEVSUPNAM": Error \-\- INP is not VME_IO (but type %i)\n",
                    waveform_ps->inp.type);
        goto egress;
    }
    epicsPrintf(DEVSUPNAM": INP is VME_IO\n");

    if ( \!(dpvt_ps = calloc(1, sizeof(*dpvt_ps))) ) {
        epicsPrintf(DEVSUPNAM": Error \-\- no memory\n");
        goto egress;
    }
    waveform_ps->dpvt = dpvt_ps;

    if ( drvPadUdpCommDpvtInit(&dpvt_ps->drvPadUdpCommPart, waveform_ps->inp.value.vmeio.card) )
        goto egress;
    epicsPrintf(DEVSUPNAM": DPVT initialized\n");

        dpvt_ps->station_type = waveform_ps->inp.value.vmeio.card;
        #ifdef DEBUG_PRINT
        DEBUGPRINT(DP_INFO, devWaveformLlrfFlag,
          ("init_waveform: Record %s setting station to card #%d\n",
          waveform_ps->name, dpvt_ps->station_type));
        #endif

    return 0;

egress:
    waveform_ps->pact = 1;
    return \-1;
}