#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* We need features that epicsThread does not provide */ #include #include #include #include #include #include /* Min. size of 'header' */ #define MINHDRSZ (sizeof(Sis8300DigiPktHdrRec) + UDPCOMM_DATA_ALGN_OFF) /* Up-align to UDPCOMM alignment boundary */ #define __DO_ALIGN(x,a) ( ( (x) + (a) - 1 ) & ~ ((a)-1) ) #define HDRSZ __DO_ALIGN(MINHDRSZ, UDPCOMM_DATA_ALGN) #define PADSZ (HDRSZ - MINHDRSZ) #define MAX_DIGIS MAX_BPM /* If more samples are desired then this can be increased; could even be bigger than a page * but then some of the code below (checking against page size and initializing the buffer * free list) must be changed. */ #define PKT_TOT_SZ 2048 #define NPKTS_DFLT 10 /* per digitizer */ #define QDEPTH (MAX_BPM*2 + MAX_BPM/2) typedef struct Sis8300DigiRec_ { char *devnam; int fd; /* system file descriptor */ unsigned chnl; epicsMutexId mtx; /* protects packet free list */ volatile int running; epicsEventId syncStart; epicsEventId syncStop; UdpCommPkt freeList; epicsThreadId tid; size_t nbytes; int kindMax; Sis8300ChannelSel channelSelector; AfeData afe; } Sis8300DigiRec, *Sis8300Digi; #define STMD 10 typedef struct Sis8300DigiPktHdrRec_ { struct Sis8300DigiPktHdrRec_ *next; Sis8300Digi digi; void **stk; int refcnt; } Sis8300DigiPktHdrRec, *Sis8300DigiPktHdr; typedef struct Sis8300DigiPktRec_ { Sis8300DigiPktHdrRec digiInfo; uint8_t pad[PADSZ]; union { uint8_t raw[PKT_TOT_SZ - PADSZ - sizeof(Sis8300DigiPktHdrRec)]; PadReplyRec padrply; } pkt; } Sis8300DigiPktRec, *Sis8300DigiPkt; typedef union PadReqU_ { char raw[sizeof(PadRequestRec) + sizeof(PadCommandRec)]; struct { PadRequestRec hdr; PadCommandRec cmd; } req; } PadReqU; static Sis8300Digi sis8300Digis[MAX_DIGIS] = { 0 }; static MsgQ sckq = 0; volatile DrvPadUdpCommHWTime digiMaxDiff = 0; volatile DrvPadUdpCommHWTime digiMinDiff = -1; static struct { uint32_t timestampHi; uint32_t timestampLo; uint32_t xid; } timestampInfo; static void hdrInitAdd(Sis8300DigiPktHdr h, Sis8300Digi digi) { h->refcnt = 0; h->digi = digi; h->next = digi->freeList; h->stk = calloc( STMD, sizeof(*h->stk) ); digi->freeList = h; } static int sis8300_padIoReq(int fd, int chnl, int type, uint32_t xid, uint32_t tsHi, uint32_t tsLo, void *cmdData, UdpCommPkt *rply, int timeout_ms); #define CHNL_STOP 0 #define CHNL_KILL (-1) static void chnlStop(Sis8300Digi digi, int val); static void chnlThread(void *arg); static void freeDigi(Sis8300Digi digi) { if ( ! digi ) { return; } if ( digi->tid ) chnlStop( digi, CHNL_KILL ); if ( digi->mtx ) epicsMutexDestroy( digi->mtx ); if ( digi->syncStart ) epicsEventDestroy( digi->syncStart ); if ( digi->fd >= 0 ) close( digi->fd ); if ( digi->devnam ) free( digi->devnam ); free( digi ); } /* This routine is not thread-safe (intended to be called from single-threaded * initialization script) */ int sis8300DigiCommConfig(unsigned udpCommChnl, const char *devnam, unsigned sel_in, unsigned fclk, int nPkts, AfeAttachFunc afe_attach) { Sis8300Digi digi = 0; int rval = -1; int i,j,n; Sis8300DigiPkt rbuf; char buf[30]; Si5326ParmsRec si5326; Si5326Parms si5326_p = &si5326; unsigned clkhl = SIS8300_BYPASS_9510_DIVIDER; unsigned long fmax; Sis8300ChannelSel sel; if ( nPkts <= 0 ) nPkts = NPKTS_DFLT; /* Only support 4 channels */ sel = sel_in & 0xffff; if ( sizeof(Sis8300DigiPktRec) != PKT_TOT_SZ ) { cantProceed("Internal error: unexpected package size (bad padding?)\n"); } if ( getpagesize() & (PKT_TOT_SZ -1) ) { cantProceed("Internal error: unexpected page size %d - not a multiple of packet size %d\n", getpagesize(), PKT_TOT_SZ); } /* packets per page */ n = getpagesize() / PKT_TOT_SZ; if ( udpCommChnl >= MAX_DIGIS ) { fprintf(stderr,"Channel number too big\n"); return -1; } if ( sis8300Digis[udpCommChnl] ) { fprintf(stderr,"udpComm Channel %i already configured\n", udpCommChnl); return -1; } if ( ! (digi = calloc(1, sizeof(*digi))) ) { fprintf(stderr,"Out of memory\n"); return -1; } digi->fd = -1; digi->chnl = udpCommChnl; if ( (digi->fd = open(devnam, O_RDWR)) < 0 ) { fprintf(stderr,"Unable to open %s: %s\n", devnam, strerror(errno)); goto bail; } if ( sis8300DigiValidateSel( digi->fd, sel ) ) { goto bail; } digi->channelSelector = sel; if ( 0 == (fmax = sis8300DigiGetFclkMax( digi->fd )) ) { fprintf(stderr,"Unable to determine max. digitizer clock frequency!\n"); goto bail; } if ( fclk > fmax ) { fprintf(stderr,"Selected clock frequency too big - digitizer supports only %lu Hz\n", fmax); goto bail; } digi->devnam = strdup(devnam); digi->mtx = epicsMutexMustCreate(); digi->running = 0; digi->syncStart = epicsEventMustCreate( epicsEventEmpty ); digi->syncStop = 0; si5326.fin = 250000000UL; si5326.bw = 4000; if ( si5326.fin == fclk ) { si5326_p = 0; } else if ( si5326.fin/2 == fclk ) { si5326_p = 0; clkhl = 0; /* divide by two */ } else { switch ( sis8300ClkDetect( digi->fd ) ) { default: fprintf(stderr,"Unable to detect Si5326 clock synthesizer\n"); goto bail; case Si5326_WidebandMode: si5326.wb = 1; break; case Si5326_NarrowbandMode: si5326.wb = 0; break; } switch ( fclk ) { case 109000000UL: if ( si5326.wb ) { /* Use 109MHz clock */ si5326.n3 = 10; /* f3 = 25Mhz */ si5326.n2h = 1; si5326.n2l = 109*2; /* fo = 50*109 MHz */ si5326.n1h = 5; si5326.nc = 10; si5326.bwsel = 1; /* dspllsim gave us this; no other info available :-( */ clkhl = SIS8300_BYPASS_9510_DIVIDER; } else { /* Use 218MHz clock */ si5326.n3 = 125; /* f3 = 2Mhz */ si5326.n2h = 4; si5326.n2l = 654; /* fo = 2*109 MHz */ si5326.n1h = 6; si5326.nc = 4; si5326.bwsel = 5; /* dspllsim gave us this; no other info available :-( */ clkhl = 0; } break; default: if ( si53xx_calcParms( fclk, &si5326, 0 ) ) { fprintf(stderr,"Unable to find a PLL divider configuration for Fclk == %uHz\n", fclk); goto bail; } break; } } sis8300DigiSetup( digi->fd, si5326_p , clkhl, 1 ); /* try to arm for a calibration; if that fails then this RTM has no calibrator * and we do not run calibration. */ digi->kindMax = (0 == sis8300DigiArm( digi->fd, SIS8300_KIND_CGRN ) ? SIS8300_KIND_CGRN : SIS8300_KIND_BEAM); /* Disarm */ sis8300DigiArm( digi->fd, SIS8300_KIND_OFF ); digi->nbytes = 0; /* allocate packet buffers */ i=0; while ( i < nPkts ) { rbuf = mmap( 0, getpagesize(), PROT_READ | PROT_WRITE, MAP_SHARED, digi->fd, 0 ); if ( MAP_FAILED == rbuf ) { cantProceed("Unable to mmap kernel buffer #%i: %s\n", i, strerror(errno)); } for ( j=0; jdigiInfo, digi ); } i += n; } if ( afe_attach ) { digi->afe = afe_attach( udpCommChnl, sis8300DigiQspiWriteRead, (const void*)(intptr_t)digi->fd ); if ( ! digi->afe ) cantProceed("Unable to attach AFE\n"); } sprintf(buf,"sis8300-%d",udpCommChnl); digi->tid = epicsThreadMustCreate( buf, epicsThreadPriorityHigh, epicsThreadGetStackSize( epicsThreadStackMedium ), chnlThread, digi ); /* Success */ sis8300Digis[udpCommChnl] = digi; digi = 0; rval = 0; bail: freeDigi( digi ); return rval; } static int getfd(unsigned udpCommChnl, unsigned reg) { Sis8300Digi digi; if ( udpCommChnl >= MAX_DIGIS || ! (digi = sis8300Digis[udpCommChnl]) ) return -1; /* restrict to informational registers for now */ if ( reg < 0x4f8 || reg > 0x4ff ) return -1; return digi->fd; } int sis8300DigiCommWriteReg(unsigned udpCommChnl, unsigned reg, uint32_t val) { int fd = getfd(udpCommChnl, reg); return fd < 0 ? fd : sis8300DigiWriteReg(fd, reg, val); } int sis8300DigiCommReadReg(unsigned udpCommChnl, unsigned reg, uint32_t *val_p) { int fd = getfd(udpCommChnl, reg); return fd < 0 ? fd : sis8300DigiReadReg(fd, reg, val_p); } static UdpCommPkt allocPkt(Sis8300Digi digi) { Sis8300DigiPkt rval; epicsMutexLock( digi->mtx ); if ( (rval = digi->freeList) ) { digi->freeList = rval->digiInfo.next; assert( 0 == rval->digiInfo.refcnt ); rval->digiInfo.refcnt = 1; rval->digiInfo.next = 0; } epicsMutexUnlock( digi->mtx ); return (UdpCommPkt)rval; } static void nullhdl(int unused) { /* we just need a handler so that a signal may interrupt/wake a * chnlThread blocked in 'read'. * If there is no handler then the process would be aborted... */ } static int sis8300_setup(const char *arg, uint32_t *peer_ip_p, int *peer_port_p) { struct sigaction sa, oa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = nullhdl; sigemptyset( &sa.sa_mask ); sa.sa_flags = 0; if ( sigaction( SIGUSR1, &sa, &oa ) ) { fprintf(stderr,"sis8300_setup(): sigaction(SIGUSR1) failed: %s\n", strerror(errno)); return -1; } if ( SIG_DFL != oa.sa_handler ) { fprintf(stderr,"sis8300_setup(): SIGUSR1 seems to be already in use -- recompile with other signal\n"); sigaction( SIGUSR1, &oa, 0 ); } return 0; } static int given = 0; static int sis8300_open(int port) { switch ( port ) { case PADPROTO_STRM_PORT: if ( sckq ) break; sckq = qinit( QDEPTH, QDEPTH ); if ( 0 == sckq ) break; return 1; default: if ( given & 1 ) break; given |= 1; return 0; } return -1; } static int sis8300_close(int fd) { switch ( fd ) { case 0: if ( given & 1 ) { given &= ~1; return 0; } break; case 1: qfini( sckq ); sckq = 0; return 0; default: break; } return -1; } static int sis8300_connect(int fd, uint32_t peer_ip, int peer_port) { return 0; } static int sis8300_send(int fd, void *buf_p, int len) { PadReqU *r = buf_p; int i,sz,j; PadCommand cmd; if ( fd != 0 ) { fprintf(stderr,"sis8300_send(sis8300DigiComm) unsupported fd\n"); return -1; } if ( len < sizeof(r->req.hdr) ) { return -1; } if ( PADPROTO_VERSION4 != r->req.hdr.version ) { fprintf(stderr,"sis8300_send(sis8300DigiComm) unsupported PAD protocol version\n"); return -1; } sz = r->req.hdr.cmdSize; if ( r->req.hdr.nCmds < 0 ) { fprintf(stderr,"sis8300_send(sis8300DigiComm) command numbers < 0 not implemented\n"); return -1; } if ( MAX_DIGIS < r->req.hdr.nCmds ) { fprintf(stderr,"sis8300_send(sis8300DigiComm) max. command number mismatch\n"); return -1; } /* Ugly hack to pass this info :-( */ timestampInfo.timestampHi = r->req.hdr.timestampHi; timestampInfo.timestampLo = r->req.hdr.timestampLo; for ( i=0, j=0; ireq.hdr.nCmds; i++, j+=sz ) { cmd = (PadCommand)&r->req.hdr.data[j]; if ( sis8300_padIoReq( fd, i, cmd->type, r->req.hdr.xid, ntohl(timestampInfo.timestampHi), ntohl(timestampInfo.timestampLo), cmd, 0, -1) ) return -1; } return len; } static UdpCommPkt sis8300_recv(int fd, int timeout_ms) { UdpCommPkt rval = 0; if ( fd != 1 ) { fprintf(stderr,"sis8300_recv() bad socket fd\n"); return 0; } if ( ! sckq ) return 0; if ( timeout_ms < 0 ) { qrecv( sckq, &rval ); } else { cantProceed("sis8300_recv(): finite timeout not implemented\n"); } return rval; } static void * sis8300_bufptr(UdpCommPkt pkt) { return &((Sis8300DigiPkt)pkt)->pkt; } static UdpCommPkt sis8300_alloc(int fd) { /* cannot implement this since allocation is per digitizer; * it's not currently used by drvPadUdpComm anyways - maybe * we should remove it */ fprintf(stderr,"sis8300_alloc: UNIMPLEMENTED\n"); return 0; } int sisRef(Sis8300DigiPkt pkt) { return pkt->digiInfo.refcnt; } static void sis8300_creatref(UdpCommPkt raw_pkt) { Sis8300Digi digi; Sis8300DigiPkt pkt = raw_pkt; if ( !pkt ) cantProceed("NULL pointer passed to sis8300_creatref!\n"); digi = pkt->digiInfo.digi; epicsMutexLock( digi->mtx ); pkt->digiInfo.refcnt++; epicsMutexUnlock( digi->mtx ); } static void sis8300_free(UdpCommPkt raw_pkt) { Sis8300Digi digi; Sis8300DigiPkt pkt = raw_pkt; if ( pkt ) { digi = pkt->digiInfo.digi; epicsMutexLock( digi->mtx ); if ( --pkt->digiInfo.refcnt < 0 ) { cantProceed("Internal error - packet reference count < 0\n"); } if ( 0 == pkt->digiInfo.refcnt ) { pkt->digiInfo.next = digi->freeList; digi->freeList = pkt; } epicsMutexUnlock( digi->mtx ); } } static void chnlThread(void *arg) { Sis8300Digi digi = arg; UdpCommPkt p; PadReply rply; int kind,nextKind; ssize_t got; static PadDataKind kindMap[] = { [SIS8300_KIND_BEAM] PadDataBpm, [SIS8300_KIND_CRED] PadDataCalRed, [SIS8300_KIND_CGRN] PadDataCalGrn }; while ( digi->running >= 0 ) { epicsEventWait( digi->syncStart ); /* Could destroy 'syncStart' here -- but careful with chnlStop(digi, CHNL_KILL) */ kind = nextKind = 0; sis8300DigiArm(digi->fd, kind); while ( digi->running > 0 ) { if ( ! (p = allocPkt( digi )) ) { fprintf(stderr,"sis8300Digi: unable to allocate packet; I'll wait\n"); epicsThreadSleep( 5.0 ); continue; } rply = &((Sis8300DigiPkt)p)->pkt.padrply; got = pread( digi->fd, rply->data, digi->nbytes, 0 ); if ( SIS8300_KIND_BEAM == kind ) { DrvPadUdpCommHWTime now = drvPadUdpCommHWTime(); if ( now > digiMaxDiff ) digiMaxDiff = now; if ( now < digiMinDiff ) digiMinDiff = now; } if ( got != digi->nbytes ) { sis8300_free( p ); if ( got > 0 ) { fprintf(stderr,"sis8300Digi: incomplete packet read (%d of %d)\n", (int)got, (int)digi->nbytes); } continue; } rply->version = PADPROTO_VERSION4; rply->type = PADCMD_STRM; rply->chnl = digi->chnl; rply->nBytes = htons(digi->nbytes + sizeof(PadReplyRec)); rply->timestampHi = timestampInfo.timestampHi; rply->timestampLo = timestampInfo.timestampLo; rply->xid = timestampInfo.xid; rply->stat = 0; rply->strm_cmd_idx = 0; rply->strm_cmd_flags = PADCMD_STRM_FLAG_LE | PADRPLY_STRM_FLAG_TYPE_SET(kindMap[kind]); if ( SIS8300_KIND_BEAM == kind ? qsend_hp( sckq, &p ) : qsend( sckq, &p ) ) { sis8300_free( p ); } if ( digi->afe ) { switch ( digi->afe->calMode ) { case AFE_CALM_TOGGLE: nextKind = kind + 1; break; case AFE_CALM_RED: nextKind = SIS8300_KIND_BEAM == kind ? SIS8300_KIND_CRED : SIS8300_KIND_BEAM; break; case AFE_CALM_GRN: nextKind = SIS8300_KIND_BEAM == kind ? SIS8300_KIND_CGRN : SIS8300_KIND_BEAM; break; default: nextKind = SIS8300_KIND_BEAM; break; } if ( nextKind > digi->kindMax ) nextKind = 0; if ( nextKind != kind ) { sis8300DigiArm(digi->fd, nextKind); kind = nextKind; } } } /* Could re-create 'syncStart' here */ epicsEventSignal( digi->syncStop ); } } static void chnlStart(Sis8300Digi digi) { epicsMutexLock( digi->mtx ); if ( ! digi->running ) { digi->running = 1; epicsEventSignal( digi->syncStart ); } epicsMutexUnlock( digi->mtx ); } static void chnlStop(Sis8300Digi digi, int val) { epicsMutexLock( digi->mtx ); if ( val ) { /* make sure it is started */ epicsEventSignal( digi->syncStart ); } if ( digi->running ) { digi->syncStop = epicsEventMustCreate( epicsEventEmpty ); do { digi->running = val ? -1 : 0; /* could be that the target receives the signal after checking 'running' * but before really in the 'read' system call; signal is lost * in this case and the wait will time out; try again */ pthread_kill( epicsThreadGetPosixThreadId(digi->tid), SIGUSR1 ); } while ( epicsEventWaitWithTimeout( digi->syncStop, 1.0 ) ); epicsEventDestroy( digi->syncStop ); digi->syncStop = 0; } epicsMutexUnlock( digi->mtx ); } static int sis8300_padIoReq(int sd, int chnl, int type, uint32_t xid, uint32_t tsHi, uint32_t tsLo, void *cmdData, UdpCommPkt *wantReply, int timeout_ms) { int i,min,max; PadReply rply; Sis8300Digi digi; int st; if ( sd != 0 ) { fprintf(stderr,"sis8300_padIoReq() unsupported sd\n"); return -1; } if ( wantReply && PADCMD_SQRY != type ) { fprintf(stderr,"sis8300_padIoReq() does not implement replies other than queries\n"); return -1; } if ( chnl >= MAX_DIGIS ) { fprintf(stderr,"sis8300_padIoReq() channel # too big (%i)\n", chnl); return -1; } if ( chnl < 0 ) { min=0; max=MAX_DIGIS; } else { min=chnl; max=chnl+1; } timestampInfo.xid = xid; timestampInfo.timestampHi = htonl(tsHi); timestampInfo.timestampLo = htonl(tsLo); switch ( PADCMD_GET(type) ) { case PADCMD_STRM: { PadStrmCommandRec *scmd_p = cmdData; unsigned nsmpls = ntohl(scmd_p->nsamples); unsigned nbytes = nsmpls * PADRPLY_STRM_NCHANNELS * sizeof(int16_t); if ( (PADCMD_STRM_FLAG_32 | PADCMD_STRM_FLAG_C1) & scmd_p->flags ) { fprintf(stderr,"sis8300_padIoReq() does not implement 32-bit data nor single-channel mode\n"); return -1; } if ( ! (PADCMD_STRM_FLAG_LE & scmd_p->flags) ) { fprintf(stderr,"sis8300_padIoReq() does not implement big-endian mode\n"); return -1; } if ( (PADCMD_STRM_FLAG_CM & scmd_p->flags) ) { fprintf(stderr,"sis8300_padIoReq() does not implement col-major data\n"); return -1; } if ( (nsmpls & 0xf) ) { fprintf(stderr,"sis8300_padIoReq(STRM) - number of samples MUST be a multiple of 16\n"); return -1; } for ( i=min; inbytes != nbytes ) { if ( nbytes > sizeof( ((Sis8300DigiPkt)0)->pkt.raw ) - sizeof(PadReplyRec) ) { fprintf(stderr,"sis8300_padIoReq(START) - requested too many samples; won't fit\n"); return -1; } epicsMutexLock( digi->mtx ); /* SetCount is not thread-safe */ st = sis8300DigiSetCount(digi->fd, digi->channelSelector, nsmpls); epicsMutexUnlock( digi->mtx ); if ( st ) { fprintf(stderr,"sis8300_padIoReq(START) - setting sample count failed\n"); return -1; } digi->nbytes = nbytes; } /* check here (normal case; no need to enter chnlStart and take mutex */ if ( ! digi->running ) { chnlStart( digi ); } } } break; case PADCMD_SQRY: if ( (PADCMD_QUIET & type) ) { if ( wantReply ) *wantReply = 0; return 0; } if ( ! wantReply ) { fprintf(stderr,"sis8300_padIoReq() PADCMD_SQRY with NULL wantReply??\n"); return -1; } if ( !sis8300Digis[min] ) { fprintf(stderr,"sis8300_padIoReq() PADCMD_SQRY -- no digi connected @%i\n", min); return -1; } if ( ! (*wantReply = allocPkt( sis8300Digis[min] )) ) { /* no available packets */ return -1; } rply = &((Sis8300DigiPkt)*wantReply)->pkt.padrply; rply->version = PADPROTO_VERSION4; rply->type = PADCMD_SQRY | PADCMD_RPLY; rply->chnl = min; rply->stat = 0; rply->timestampHi = timestampInfo.timestampHi; rply->timestampLo = timestampInfo.timestampLo; rply->xid = xid; rply->nBytes = htons(sizeof(*rply)); /* we DO support row-major, little-endian, 16-bit, 4-channel mode ONLY */ rply->strm_sqry_sup_on = PADCMD_STRM_FLAG_LE; rply->strm_sqry_sup_off = PADCMD_STRM_FLAG_32 | PADCMD_STRM_FLAG_C1 | PADCMD_STRM_FLAG_CM; break; case PADCMD_STOP: for ( i=min; ifd, ntohl(scmd_p->a), ntohl(scmd_p->b), ntohl(scmd_p->c), ntohl(scmd_p->d), (scmd_p->flags & PADCMD_SIM_FLAG_NOSEND) ); } } break; case PADCMD_NOP: break; default: fprintf(stderr,"sis8300_padIoReq() does not implement cmd type %i\n",type); return -1; } return 0; } DrvPadUdpCommIORec io_ops = { /* int (*setup) (const char *arg, uint32_t *peer_ip_p, int *peer_port_p); */ setup: sis8300_setup, /*int (*open) (int port); */ open: sis8300_open, /*int (*close) (int fd); */ close: sis8300_close, /*int (*connect) (int fd, uint32_t peer_ip, int peer_port); */ connect: sis8300_connect, /*int (*send) (int fd, void *buf_p, int len); */ send: sis8300_send, /*UdpCommPkt (*recv) (int fd, int timeout_ms); */ recv: sis8300_recv, /*void * (*bufptr) (UdpCommPkt); */ bufptr: sis8300_bufptr, /*UdpCommPkt (*alloc) (int fd); */ alloc: sis8300_alloc, /*void (*creatref) (UdpCommPkt); */ creatref: sis8300_creatref, /* void (*free) (UdpCommPkt); */ free: sis8300_free, /* This last one is ugly but does different things * with the VME digitizer as opposed to the PAD. * Again: this is historic evolution not clean design from scratch... int (*padIoReq) (int fd, int chnl, int type, uint32_t xid, uint32_t tsHi, uint32_t tsLo, void *cmdData, UdpCommPkt *rply, int timeout_ms); */ padIoReq: sis8300_padIoReq, }; DrvPadUdpCommIO drvSis8300DigiCommIO = &io_ops; static const struct iocshArg args[] = { { "udpComm channel", iocshArgInt }, { "sis8300 device file", iocshArgString }, { "sis8300 digitizer channel selector", iocshArgInt }, { "digitizer clock frequency (in Hz) - currently only 125MHz or 109MHz supported", iocshArgInt }, { "number of packet buffers (per channel; optional)", iocshArgInt }, { "name of AFE attach function", iocshArgString } }; static const struct iocshArg *bloatp[sizeof(args)/sizeof(args[0])]; static const struct iocshFuncDef sis8300DigiCommConfigDesc = { "sis8300DigiCommConfig", sizeof(args)/sizeof(args[0]), bloatp }; static void sis8300DigiCommConfigFunc(const iocshArgBuf *args) { AfeAttachFunc f = 0; if ( !args[1].sval ) { epicsPrintf("sis8300DigiCommConfig -- need non-NULL device file name arg\n"); return; } if ( args[5].sval && args[5].sval[0] ) { if ( ! (f = afeAttachFind( args[5].sval )) ) { errlogPrintf("sis8300DigiCommConfig: AFE attach function '%s' not found!\n", args[5].sval); return; } } if ( sis8300DigiCommConfig(args[0].ival, args[1].sval, (unsigned)args[2].ival, (unsigned)args[3].ival, args[4].ival, f) ) { epicsPrintf("sis8300DigiCommConfig() FAILED for channel %i\n", args[0].ival); } } static void sis8300DigiCommRegistrar(void) { int i; for ( i=0; i