diff --git a/src/devOpt/devXxBugRac.c b/src/devOpt/devXxBugRac.c deleted file mode 100644 index 48f3bc1a1..000000000 --- a/src/devOpt/devXxBugRac.c +++ /dev/null @@ -1,517 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* devXxBugRac.c */ - -/* Device Support Routines for BUF RAC commands */ -/* - * Original Author: Ned Arnold (based on work by Jim Kowalkowski) - * Date: 02/01/93 - */ - - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* types */ -#define AI 0x01 -#define AO 0x02 -#define BI 0x03 -#define BO 0x04 -#define LI 0x05 -#define LO 0x06 -#define MBBI 0x07 -#define MBBO 0x08 - - -/* Define forward references */ -long report(); -long init(); -static long init_ai(); -static long init_ao(); -static long init_bo(); -static long init_bi(); -static long init_li(); -long init_lo(); -static long init_mbbi(); -static long init_mbbo(); -long get_ioint_info(); -static long bug_rac(); - -/* Create the dsets for devXxBugRac */ -typedef struct { - long number; - DEVSUPFUN report; - DEVSUPFUN init; - DEVSUPFUN init_record; - DEVSUPFUN get_ioint_info; - DEVSUPFUN read_write; - DEVSUPFUN special_linconv; -} IODSET; - -/* DEFINE SUPPORTED RAC COMMANDS -#define RESET_STATION 0x00 /* BO record */ -#define GET_FUNCTION_ID 0x03 /* LI record */ - -/* xxDSET devXxxx={ 5,report,init,init_rec,get_ioint_info,bug_rac}; */ - -IODSET devBoBugRac = { 5, NULL, NULL, init_bo, NULL, bug_rac }; -IODSET devLiBugRac = { 5, NULL, NULL, init_li, NULL, bug_rac }; - -/* forward references */ - -static void get_data(); -static void send_cntl_trans(); -extern struct drvBitBusEt drvBitBus; - -volatile int bugRacDebug=0; - -#define OFF 0 -#define ON 1 - -#ifdef NODEBUG -#define Debug(FMT,V) ; -#else -#define Debug(FMT,V) { if(bugRacDebug) \ - {\ - printf("%s(%d):",__FILE__,__LINE__); \ - printf(FMT,V); \ - } \ - } -#endif - - - -struct dprivate { - struct dpvtBitBusHead bitbus; - char type; - unsigned char cmd; - struct dbCommon *precord; /* at end for callback to get it */ -}; - -static int io_callback(struct dprivate *pcallback) -{ - struct dbCommon *precord; - struct rset *prset; - - precord=pcallback->precord; - prset=(struct rset *)(precord->rset); - - dbScanLock(precord); - (*prset->process)(precord); - dbScanUnlock(precord); -} - -static struct dprivate * set_bitbus(int prio,unsigned char cmd,struct bitbusio *pbitbusio) -{ - struct dprivate *my_dpvt; - - my_dpvt=(struct dprivate *)(malloc(sizeof(struct dprivate))); - - my_dpvt->bitbus.finishProc=io_callback; - my_dpvt->bitbus.psyncSem=(SEM_ID *)NULL; - my_dpvt->bitbus.priority=prio; - my_dpvt->bitbus.link=pbitbusio->link; - my_dpvt->bitbus.rxMaxLen=9; - my_dpvt->bitbus.ageLimit=240; - - my_dpvt->bitbus.txMsg.length=9; - my_dpvt->bitbus.txMsg.route=0x40; - my_dpvt->bitbus.txMsg.node=pbitbusio->node; - my_dpvt->bitbus.txMsg.tasks=0; - my_dpvt->bitbus.txMsg.cmd=cmd; - my_dpvt->bitbus.txMsg.data=(unsigned char *)malloc(2); - my_dpvt->bitbus.rxMsg.data=(unsigned char *)malloc(BB_MAX_DAT_LEN); - - my_dpvt->bitbus.txMsg.data[0]='\0'; - my_dpvt->bitbus.txMsg.data[1]='\0'; - - Debug("command sent:(%02.2x)\n", my_dpvt->bitbus.txMsg.cmd); - - return(my_dpvt); -} - - -static long init_ai(struct aiRecord *ai) -{ - struct bitbusio *pbitbusio = (struct bitbusio *)(&ai->inp.value); - struct dprivate *my_dpvt; - int ret; - - Debug("init ai invoked\n",0); - - /* type must be an BITBUS_IO */ - if(ai->inp.type!=BITBUS_IO) - { - recGblRecordError(S_dev_badBus,(void *)ai, - "devXxBugRac (init_record) Illegal IN Bus Type"); - return(S_dev_badBus); - } - - - my_dpvt=set_bitbus(ai->prio,pbitbusio->signal,pbitbusio); - my_dpvt->precord = (struct dbCommon *)ai; - my_dpvt->type = AI; - - ai->dpvt=(void *)my_dpvt; - return(0); -} - - -static long init_ao(struct aoRecord *ao) -{ - struct bitbusio *pbitbusio = (struct bitbusio *)(&ao->out.value); - struct dprivate *my_dpvt; - - Debug("init ao invoked\n",0); - - /* out must be an BITBUS_IO */ - if(ao->out.type!=BITBUS_IO) - { - recGblRecordError(S_dev_badBus,(void *)ao, - "devXxBugRac (init_record) Illegal OUT Bus Type"); - return(S_dev_badBus); - } - - my_dpvt=set_bitbus(ao->prio,pbitbusio->signal,pbitbusio); - my_dpvt->precord = (struct dbCommon *)ao; - my_dpvt->type = AO; - - ao->dpvt=(void *)my_dpvt; - - return(0); -} - - -static long init_bi(struct biRecord *bi) -{ - struct bitbusio *pbitbusio = (struct bitbusio *)(&bi->inp.value); - struct dprivate *my_dpvt; - unsigned char cmd = 0; - - Debug("init bi invoked\n",0); - - /* out must be an BITBUS_IO */ - if(bi->inp.type!=BITBUS_IO) - { - recGblRecordError(S_dev_badBus,(void *)bi, - "devXxBugRac (init_record) Illegal IN Bus Type"); - return(S_dev_badBus); - } - - - my_dpvt=set_bitbus(bi->prio,pbitbusio->signal,pbitbusio); - my_dpvt->precord = (struct dbCommon *)bi; - my_dpvt->type = BI; - my_dpvt->cmd = cmd; - bi->dpvt=(void *)my_dpvt; - - return(0); -} - - -static long init_bo(struct boRecord *bo) -{ - struct bitbusio *pbitbusio = (struct bitbusio *)(&bo->out.value); - struct dprivate *my_dpvt; - - Debug("init bo invoked\n",0); - - /* out must be an BITBUS_IO */ - if(bo->out.type!=BITBUS_IO) - { - recGblRecordError(S_dev_badBus,(void *)bo, - "devXxBugRac (init_record) Illegal IN Bus Type"); - return(S_dev_badBus); - } - - switch(pbitbusio->signal) - { - default: - recGblRecordError(S_dev_badBus,(void *)bo, - "devXxBugRac (init_record) Illegal IN signal number"); - return(S_dev_badBus); - case 0: /* signal 0 is a bo record */ - break; - } - - my_dpvt=set_bitbus(bo->prio,pbitbusio->signal,pbitbusio); - my_dpvt->precord = (struct dbCommon *)bo; - my_dpvt->type = BO; - my_dpvt->cmd = pbitbusio->signal; - - bo->dpvt=(void *)my_dpvt; - - return(0); -} - - -static long init_li(struct longinRecord *li) -{ - struct bitbusio *pbitbusio = (struct bitbusio *)(&li->inp.value); - struct dprivate *my_dpvt; - unsigned char cmd = 0; - - Debug("init li invoked\n",0); - - /* out must be an BITBUS_IO */ - if(li->inp.type!=BITBUS_IO) - { - recGblRecordError(S_dev_badBus,(void *)li, - "devXxBugRac (init_record) Illegal IN Bus Type"); - return(S_dev_badBus); - } - - switch(pbitbusio->signal) - { - default: - recGblRecordError(S_dev_badBus,(void *)li, - "devXxBugRac (init_record) Illegal IN signal number"); - return(S_dev_badBus); - case 3: /* signal 3 is a li record */ - break; - } - - my_dpvt=set_bitbus(li->prio,pbitbusio->signal,pbitbusio); - my_dpvt->precord = (struct dbCommon *)li; - my_dpvt->type = LI; - my_dpvt->cmd = pbitbusio->signal; - li->dpvt=(void *)my_dpvt; - - return(0); -} - - -static long init_mbbi(struct mbbiRecord *mbbi) -{ - struct bitbusio *pbitbusio = (struct bitbusio *)(&mbbi->inp.value); - struct dprivate *my_dpvt; - unsigned char cmd = 0; - - Debug("init mbbi invoked\n",0); - - /* out must be an BITBUS_IO */ - if(mbbi->inp.type!=BITBUS_IO) - { - recGblRecordError(S_dev_badBus,(void *)mbbi, - "devXxBugRac (init_record) Illegal IN Bus Type"); - return(S_dev_badBus); - } - - my_dpvt=set_bitbus(mbbi->prio,pbitbusio->signal,pbitbusio); - my_dpvt->precord = (struct dbCommon *)mbbi; - my_dpvt->type = MBBI; - my_dpvt->cmd = cmd; - mbbi->dpvt=(void *)my_dpvt; - - return(0); -} - - -static long init_mbbo(struct mbboRecord *mbbo) -{ - struct bitbusio *pbitbusio = (struct bitbusio *)(&mbbo->out.value); - struct dprivate *my_dpvt; - unsigned char cmd = 0; - - Debug("init mbbo invoked\n",0); - - /* out must be an BITBUS_IO */ - if(mbbo->out.type!=BITBUS_IO) - { - recGblRecordError(S_dev_badBus,(void *)mbbo, - "devXxBugRac (init_record) Illegal OUT Bus Type"); - return(S_dev_badBus); - } - - if(pbitbusio->signal >= 8 ) - { - recGblRecordError(S_dev_badBus,(void *)mbbo, - "devXxBugRac (init_record) Illegal OUT signal number"); - return(S_dev_badBus); - } - - my_dpvt=set_bitbus(mbbo->prio,pbitbusio->signal,pbitbusio); - my_dpvt->precord = (struct dbCommon *)mbbo; - my_dpvt->type = MBBO; - my_dpvt->cmd = cmd; - - mbbo->dpvt=(void *)my_dpvt; - - return(0); -} - - -static long bug_rac(struct dbCommon *io) -{ - struct dprivate *my_dpvt=(struct dprivate *)io->dpvt; - struct dpvtBitBusHead *pbitbus; - - if(!io->dpvt) return(S_dev_NoInit); - - pbitbus=&(my_dpvt->bitbus); - - if(io->pact==TRUE) - { - Debug("Bitbus message completed \n",0); - - /* a transaction to bitbus has completed */ - switch(pbitbus->status) - { - case BB_OK: - Debug("Getting data \n",0); - get_data(io); - return(0); - default: - recGblSetSevr(io,WRITE_ALARM,MAJOR_ALARM); - recGblRecordError(S_dev_badBus,(void *)io, - "devXxBugRac (iobug_rdwr) BitBus Error!"); - return(S_dev_badBus); - } - } - else - { - /* data needs to be sent to bitbus */ - Debug("Sending transaction \n",0); - send_cntl_trans(io); - } - - io->pact=TRUE; - - /* queue the command */ - if((*drvBitBus.qReq)(pbitbus,BB_Q_LOW)<0) - { - recGblSetSevr(io,WRITE_ALARM,MAJOR_ALARM); - recGblRecordError(S_dev_badBus,(void *)io, - "devXxBugRac (init_record) Initial BitBus message failed"); - return(S_dev_badBus); - } - Debug("Queued transaction \n",0); - - return(0); -} - -static void get_data(struct dbCommon *io) -{ - struct dprivate *my_dpvt=(struct dprivate *)io->dpvt; - struct dpvtBitBusHead *pbitbus; - struct boRecord *bo; - struct biRecord *bi; - struct aoRecord *ao; - struct aiRecord *ai; - struct longoutRecord *lo; - struct longinRecord *li; - struct mbboRecord *mbbo; - struct mbbiRecord *mbbi; - long value; - unsigned long uvalue; - - pbitbus=&(my_dpvt->bitbus); - - Debug("Command return: 0x%04.4X\n",pbitbus->rxMsg.cmd); - Debug("byte 1 of return: 0x%04.4X\n",pbitbus->rxMsg.data[0]); - Debug("byte 2 of return: 0x%04.4X\n",pbitbus->rxMsg.data[1]); - - switch(my_dpvt->type) - { - case LI: - li=(struct longinRecord *)io; - switch(my_dpvt->bitbus.txMsg.cmd) - { - case GET_FUNCTION_ID: - /* extract the second ID code (task 1) */ - li->val = pbitbus->rxMsg.data[1]; - li->udf = 0; - if ((pbitbus->rxMsg.cmd) != 0) - { - recGblSetSevr(li, READ_ALARM, INVALID_ALARM); - } - break; - default: - break; - } - default: - break; - } - - return; -} - -static void send_cntl_trans(struct dbCommon *io) -{ - struct dprivate *my_dpvt=(struct dprivate *)io->dpvt; - struct dpvtBitBusHead *pbitbus; - struct boRecord *bo; - struct aoRecord *ao; - struct mbboRecord *mbbo; - short lsb,msb; - - pbitbus=&(my_dpvt->bitbus); - - pbitbus->finishProc=io_callback; - pbitbus->psyncSem=(SEM_ID *)NULL; - pbitbus->priority=io->prio; - pbitbus->txMsg.cmd=my_dpvt->cmd; - - switch(my_dpvt->type) - { - case BO: - bo=(struct boRecord *)io; - break; - case MBBO: - mbbo=(struct mbboRecord *)io; - break; - case AO: - ao=(struct aoRecord *)io; - pbitbus->txMsg.data[0]=0; - pbitbus->txMsg.data[1]=0; - break; - default: - break; - } - - my_dpvt->precord=(struct dbCommon *)io; - - Debug("Command send: 0x%02.2X\n",pbitbus->txMsg.cmd); - Debug("byte 1 sent: 0x%02.2X\n",(unsigned char)pbitbus->txMsg.data[0]); - Debug("byte 2 sent: 0x%02.2X\n",(unsigned char)pbitbus->txMsg.data[1]); - - return; -} diff --git a/src/devOpt/devXxDig500Msg232.c b/src/devOpt/devXxDig500Msg232.c deleted file mode 100644 index 620be614c..000000000 --- a/src/devOpt/devXxDig500Msg232.c +++ /dev/null @@ -1,677 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* share/src/devOpt $Id$ */ -/* - * Author: John Winans - * Date: 04-13-92 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "/home/phebos/WINANS/appl/record-3.5/bprecH/rec/brownpileRecord.h" - -#include -#include -#include - -#define DSET_AI devAidig500Msg232 -#define DSET_AO devAodig500Msg232 -#define DSET_BI devBidig500Msg232 -#define DSET_BO devBodig500Msg232 -#define DSET_MI devMidig500Msg232 -#define DSET_MO devModig500Msg232 -#define DSET_LI devLidig500Msg232 -#define DSET_LO devLodig500Msg232 -#define DSET_SI devSidig500Msg232 -#define DSET_SO devSodig500Msg232 -#define DSET_WF devWfdig500Msg232 - -#define DSET_BP devBpdig500Msg232 - -#define STATIC static - -int dig500MsgDebug = 0; - -STATIC long init(), report(); -STATIC msgParmBlock parmBlock; - -/***************************************************************************** - * - * custom support routines that are not provided by the generic message driver - * - ******************************************************************************/ -static msgRecEnum local_bp = { "PE dig500" }; - -STATIC long -local_initBp(struct brownpileRecord *pbp) -{ - char message[100]; - long status; - - if (dig500MsgDebug) - printf("local_initBp entered\n"); - - pbp->dpvt = drvMsg_genXact(((struct msgDset *)(pbp->dset))->pparmBlock, &(pbp->inp), pbp); - - if (pbp->dpvt != NULL) - { - status = drvMsg_checkParm(pbp, "Perkin Elmer"); - if (status == 0) - drvMsg_initCallback(pbp); - else - pbp->pact = 1; - return(status); - } - pbp->pact = 1; - return(S_db_badField); -} - -/*****************************************************************************/ -STATIC long -local_procBp(struct brownpileRecord *pbp) -{ - if (dig500MsgDebug > 10) - printf("local_procBp entered\n"); - - return(drvMsg_proc(pbp, 0)); -} - -msgDset DSET_AI = { 6, { report, init, drvMsg_initAi, NULL, - drvMsg_procAi, NULL}, &parmBlock, &drvMsgAi}; -msgDset DSET_AO = { 6, { NULL, NULL, drvMsg_initAo, NULL, - drvMsg_procAo, NULL}, &parmBlock, &drvMsgAo}; - -msgDset DSET_BI = { 6, { NULL, NULL, drvMsg_initBi, NULL, - drvMsg_procBi, NULL}, &parmBlock, &drvMsgBi}; -msgDset DSET_BO = { 6, { NULL, NULL, drvMsg_initBo, NULL, - drvMsg_procBo, NULL}, &parmBlock, &drvMsgBo}; - -msgDset DSET_MI = { 6, { NULL, NULL, drvMsg_initMi, NULL, - drvMsg_procMi, NULL}, &parmBlock, &drvMsgMi}; -msgDset DSET_MO = { 6, { NULL, NULL, drvMsg_initMo, NULL, - drvMsg_procMo, NULL}, &parmBlock, &drvMsgMo}; - -msgDset DSET_LI = { 6, { NULL, NULL, drvMsg_initLi, NULL, - drvMsg_procLi, NULL}, &parmBlock, &drvMsgLi}; -msgDset DSET_LO = { 6, { NULL, NULL, drvMsg_initLo, NULL, - drvMsg_procLo, NULL}, &parmBlock, &drvMsgLo}; - -msgDset DSET_SI = { 6, { NULL, NULL, drvMsg_initSi, NULL, - drvMsg_procSi, NULL}, &parmBlock, &drvMsgSi}; -msgDset DSET_SO = { 6, { NULL, NULL, drvMsg_initSo, NULL, - drvMsg_procSo, NULL}, &parmBlock, &drvMsgSo}; - -msgDset DSET_WF = { 6, { NULL, NULL, drvMsg_initWf, NULL, - drvMsg_procWf, NULL}, &parmBlock, &drvMsgWf}; - -msgDset DSET_BP = { 6, { NULL, NULL, local_initBp, NULL, - local_procBp, NULL}, &parmBlock, &local_bp}; - -/****************************************************************************** - * - * Custom I/O operations not supported by the drvMsg module required by the - * dig500 record. - * - ******************************************************************************/ -#define LOCAL_OP_PROC MSG_OP_USER+0 - -static msgCmd cmds[] = { - { &local_bp, READ_NDLY, {LOCAL_OP_PROC, NULL}, {MSG_OP_NOP, NULL}, NULL, -1 }, -}; - -/****************************************************************************** - * - * This function is used to intercept the read-portion of custom opertaion codes - * that are specific to the digitel 500. - * - ******************************************************************************/ - -/* Flag bits set to indicate fields that have been altered. */ -#define MOD_DSPL 0x0001 -#define MOD_KLCK 0x0002 -#define MOD_MODS 0x0004 -#define MOD_SP1S 0x0008 -#define MOD_S1HS 0x0010 -#define MOD_S1MS 0x0020 -#define MOD_S1VS 0x0040 -#define MOD_SP2S 0x0080 -#define MOD_S2HS 0x0100 -#define MOD_S2MS 0x0200 -#define MOD_S2VS 0x0400 - -/* Values for enumerated fields. */ -#define REC_BP_CHOICE_DSPL_VOLT 0 -#define REC_BP_CHOICE_DSPL_CURR 1 -#define REC_BP_CHOICE_DSPL_PRES 2 - -#define REC_BP_CHOICE_KLCK_UNLK 0 -#define REC_BP_CHOICE_KLCK_LOCK 1 - -#define REC_BP_CHOICE_OPER_SBY 0 -#define REC_BP_CHOICE_OPER_BUSY 1 - -#define REC_BP_CHOICE_SP_OFF 0 -#define REC_BP_CHOICE_SP_ON 1 - -#define REC_BP_CHOICE_SPMODE_PRES 0 -#define REC_BP_CHOICE_SPMODE_CURR 1 - -#define REC_BP_CHOICE_HVI_OFF 0 -#define REC_BP_CHOICE_HVI_ON 1 - -#define REC_BP_CHOICE_PUMP_30 0 /* 30 Liter/sec */ -#define REC_BP_CHOICE_PUMP_60 1 /* 60 Liter/sec */ -#define REC_BP_CHOICE_PUMP_120 2 /* 120 Liter/sec */ -#define REC_BP_CHOICE_PUMP_220 3 /* 220 Liter/sec */ - - -STATIC long -local_xactWork(msgXact *pxact, msgCmdOp *pop) -{ - char msg[100]; /* A place to format error messages */ - char buf[100]; /* A place to build & parse strings */ - msgStrParm strParm; /* Room to put the driver's parms */ - struct brownpileRecord *pbp = (struct brownpileRecord *)(pxact->prec); - int dd, hh, mm; - int t1, t2, t3, t4; - - if (pop->op != LOCAL_OP_PROC) - /* Transaction is not a local-custom operation, let drvMsg deal with it. */ - return(drvMsg_xactWork(pxact, pop)); - - strParm.buf = buf; - - /* We have to check to see if any record fields changed and send them out */ - if (pbp->flgs) - { - buf[0] = 'M'; - buf[2] = '\r'; - strParm.len = 3; - - if (pbp->flgs & MOD_DSPL) - { - buf[1] = '3'+pbp->dspl; - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - if (pbp->flgs & MOD_KLCK) - { - buf[1] = '8'+pbp->klck; - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - if (pbp->flgs & MOD_MODS) - { - buf[1] = '1'+pbp->mods; - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - - if (pbp->flgs & MOD_SP1S) - { - sprintf(buf, "S11%.0le", pbp->sp1s); - if (buf[5] == '0') - buf[4] = '0'; - else - buf[4] = buf[6]; - buf[5] = '\r'; - strParm.len = 6; - - if (dig500MsgDebug > 9) - { - buf[6] = '\0'; - printf(">%s< setpoint1 parm = >%s<\n", pbp->name, buf); - } - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - if (pbp->flgs & MOD_S1HS) - { - sprintf(buf, "S12%.0le\r", pbp->s1hs); - if (buf[5] == '0') - buf[4] = '0'; - else - buf[4] = buf[6]; - buf[5] = '\r'; - strParm.len = 6; - - if (dig500MsgDebug > 9) - { - buf[6] = '\0'; - printf(">%s< setpoint1 hysteresis = >%s<\n", pbp->name, buf); - } - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - if (pbp->flgs & (MOD_S1MS|MOD_S1VS)) - { - buf[0] = 'S'; - buf[1] = '1'; - buf[2] = '3'; - if(pbp->s1ms == REC_BP_CHOICE_SPMODE_PRES) - buf[3] = '0'; - else - buf[3] = '1'; - buf[4] = '0'; - if (pbp->s1vs == REC_BP_CHOICE_HVI_OFF) - buf[5] = '1'; - else - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '\r'; - - strParm.len = 8; - - if (dig500MsgDebug > 9) - { - buf[8] = '\0'; - printf(">%s< sp1 options parm = >%s<\n", pbp->name, buf); - } - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - - if (pbp->flgs & MOD_SP2S) - { - sprintf(buf, "S21%.0le\r", pbp->sp2s); - if (buf[5] == '0') - buf[4] = '0'; - else - buf[4] = buf[6]; - buf[5] = '\r'; - strParm.len = 6; - - if (dig500MsgDebug > 9) - { - buf[6] = '\0'; - printf(">%s< setpoint2 parm = >%s<\n", pbp->name, buf); - } - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - if (pbp->flgs & MOD_S2HS) - { - sprintf(buf, "S22%.0le\r", pbp->s2hs); - if (buf[5] == '0') - buf[4] = '0'; - else - buf[4] = buf[6]; - buf[5] = '\r'; - strParm.len = 6; - - if (dig500MsgDebug > 9) - { - buf[6] = '\0'; - printf(">%s< setpoint2 hysteresis = >%s<\n", pbp->name, buf); - } - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - if (pbp->flgs & (MOD_S2MS|MOD_S2VS)) - { - buf[0] = 'S'; - buf[1] = '2'; - buf[2] = '3'; - if(pbp->s2ms == REC_BP_CHOICE_SPMODE_PRES) - buf[3] = '0'; - else - buf[3] = '1'; - buf[4] = '0'; - if (pbp->s2vs == REC_BP_CHOICE_HVI_OFF) - buf[5] = '1'; - else - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '\r'; - - strParm.len = 8; - - if (dig500MsgDebug > 9) - { - buf[8] = '\0'; - printf(">%s< sp2 options parm = >%s<\n", pbp->name, buf); - } - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - } - pbp->flgs = 0; - } - - /************************************************************************ - * - * Then we have to read all the running parameters back from the dig500 - * - ************************************************************************/ - - buf[0] = 'R'; - buf[1] = 'D'; - buf[2] = '\r'; - strParm.len = 3; - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - - strParm.len = sizeof(buf); - drvMsg_drvRead(pxact, &strParm); - - if (dig500MsgDebug > 10) - printf(">%s< RD ->%s< pxact->status %d\n", pbp->name, buf, pxact->status); - - if (pxact->status != XACT_OK) - return(pxact->status); - - if (sscanf(buf, "%d %d:%d %ldV%lf", &dd, &hh, &mm, &(pbp->volt), &(pbp->crnt)) != 5) - { - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RD response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - if (dig500MsgDebug > 10) - printf("dd %d, hh %d, mm %d, volts %ld, current %lf\n", dd, hh, mm, pbp->volt, pbp->crnt); - pbp->tonl = dd*1440 + hh*60 + mm; - - if(buf[23] == 'H') /* High voltage is on */ - pbp->modr = REC_BP_CHOICE_OPER_BUSY; - else if (buf[23] == '-') - pbp->modr = REC_BP_CHOICE_OPER_SBY; - else - { /* invalid character in response string... go to valid alarm. */ - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RD response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - -#if 0 - if(buf[24] == 'C') /* Cooldown mode is active */ - { - } -#endif - - if(buf[26] == '1') /* Setpoint 1 is energized */ - pbp->set1 = REC_BP_CHOICE_SP_ON; - else if (buf[26] == '-') - pbp->set1 = REC_BP_CHOICE_SP_OFF; - else - { /* invalid character in response string... go to valid alarm. */ - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RD response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - if(buf[27] == '2') /* Setpoint 2 is energized */ - pbp->set2 = REC_BP_CHOICE_SP_ON; - else if (buf[27] == '-') - pbp->set2 = REC_BP_CHOICE_SP_OFF; - else - { /* invalid character in response string... go to valid alarm. */ - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RD response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - buf[0] = 'R'; - buf[1] = 'C'; - buf[2] = '\r'; - strParm.len = 3; - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - - strParm.len = sizeof(buf); - drvMsg_drvRead(pxact, &strParm); - - if (dig500MsgDebug > 10) - printf(">%s< RC ->%s< pxact->status %d\n", pbp->name, buf, pxact->status); - - if (pxact->status != XACT_OK) - return(pxact->status); - - if (sscanf(buf, "%dP %dI %dC %d", &t1, &t2, &t3, &t4) != 4) - { - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RC response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - - pbp->accw = t1 * .444; /* Calculate the accumulated power */ - pbp->acci = t2 * 1.11; /* Calculate the accumulated current */ - pbp->cool = t3; /* Cool period */ - - switch (t4) { - case 1: - pbp->ptyp = REC_BP_CHOICE_PUMP_30; - break; - case 2: - pbp->ptyp = REC_BP_CHOICE_PUMP_60; - break; - case 4: - pbp->ptyp = REC_BP_CHOICE_PUMP_120; - break; - case 8: - pbp->ptyp = REC_BP_CHOICE_PUMP_220; - break; - default: - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RC response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - /* - * Check out the setpoint 1 situation - */ - buf[0] = 'R'; - buf[1] = 'S'; - buf[2] = '1'; - buf[3] = '\r'; - strParm.len = 4; - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - - strParm.len = sizeof(buf); - drvMsg_drvRead(pxact, &strParm); - - if (dig500MsgDebug > 10) - printf(">%s< RS1 ->%s< pxact->status %d\n", pbp->name, buf, pxact->status); - - if (pxact->status != XACT_OK) - return(pxact->status); - - if (sscanf(buf, "%lf %lf", &(pbp->sp1r), &(pbp->s1hr)) != 2) - { - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RS1 response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - if (buf[14] == '0') - pbp->s1mr = REC_BP_CHOICE_SPMODE_PRES; - else if (buf[14] == '1') - pbp->s1mr = REC_BP_CHOICE_SPMODE_CURR; - else - { - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RS1 response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - if (buf[16] == '0') - pbp->s1vr = REC_BP_CHOICE_HVI_OFF; - else if (buf[16] == '1') - pbp->s1vr = REC_BP_CHOICE_HVI_ON; - else - { - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RS1 response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - /* - * Check out the setpoint 2 situation - */ - buf[0] = 'R'; - buf[1] = 'S'; - buf[2] = '2'; - buf[3] = '\r'; - strParm.len = 4; - - drvMsg_drvWrite(pxact, &strParm); - if (pxact->status != XACT_OK) - return(pxact->status); - - strParm.len = sizeof(buf); - drvMsg_drvRead(pxact, &strParm); - - if (dig500MsgDebug > 10) - printf(">%s< RS2 ->%s< pxact->status %d\n", pbp->name, buf, pxact->status); - - if (pxact->status != XACT_OK) - return(pxact->status); - - sscanf(buf, "%lf %lf", &(pbp->sp2r), &(pbp->s2hr)); - - if (buf[14] == '0') - pbp->s2mr = REC_BP_CHOICE_SPMODE_PRES; - else if (buf[14] == '1') - pbp->s2mr = REC_BP_CHOICE_SPMODE_CURR; - else - { - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RS2 response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - if (buf[16] == '0') - pbp->s2vr = REC_BP_CHOICE_HVI_OFF; - else if (buf[16] == '1') - pbp->s2vr = REC_BP_CHOICE_HVI_ON; - else - { - if (dig500MsgDebug) - printf("Dig500: >%s< invalid RS2 response string >%s<\n", pbp->name, buf); - - pxact->status = XACT_IOERR; - return(pxact->status); - } - - pbp->udf = FALSE; - return(XACT_OK); -} - -/****************************************************************************** - * - * The dev232ParmBlock contains driver specific extensions to the msgParmBlock - * structure. - * - ******************************************************************************/ -static dev232ParmBlock parm232extension = { - 0, /* Time window */ - 60, /* DMA time limit */ - ECHO|CRLF|KILL_CRLF, /* Device echos & does CR -> CR LF, loose the CRs and LFs */ - 0x0d, /* EOI character, always stop reading when I hit it */ - 2400, /* Baud rate to the machine at */ - OPT_7_BIT /* Use 7-bit protocol */ -}; - -/****************************************************************************** - * - * Parm block extensions for the bitbus interface. - * - ******************************************************************************/ -static drvBB232ParmBlock parmBB232extension = { - 60, - 9600, -}; -/****************************************************************************** - * - * The parmBlock is used to define the relationship b/w the command table and - * the driverBlock. - * - ******************************************************************************/ -static msgParmBlock parmBlock = { - &dig500MsgDebug, - NULL, - cmds, - sizeof(cmds) / sizeof(msgCmd), - "Dig500MsgBB232", - &drvBB232Block, - local_xactWork, - &parmBB232extension -}; -STATIC long -init(int parm) -{ - return(drvMsg_initMsg(parm, &devAidig500Msg232)); -} -STATIC long -report(void) -{ - return(drvMsg_reportMsg(&devAidig500Msg232)); -} diff --git a/src/devOpt/devXxHvpsGpib.c b/src/devOpt/devXxHvpsGpib.c deleted file mode 100644 index 607a1e841..000000000 --- a/src/devOpt/devXxHvpsGpib.c +++ /dev/null @@ -1,1589 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* devXxHvpsGpib.c */ -/* share/src/devOpt $Id$ */ -/* - * Author: Bob Daly - * Date: 10-21-91 - * - * BUGS: - * GPIBSOFT type commands should NOT be processed by the link task. They - * should be handled by a callback task! - */ - -/* Includes support for the following device types : - * "devAiHvpsGpib" - * "devAoHvpsGpib" - * "devBiHvpsGpib" - * "devBoHvpsGpib" - * "devMbbiHvpsGpib" - * "devMbbiHvpsGpib" - * "devStrinHvpsGpib" - * "devStroutHvpsGpib" - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifndef INVALID_ALARM -#define INVALID_ALARM VALID_ALARM -#endif - -extern struct drvGpibSet drvGpib; /* entry points to driver functions */ - -long init_dev_sup(); -long init_rec_ai(); -long read_ai(); -long init_rec_ao(); -long write_ao(); -long init_rec_bi(); -long read_bi(); -long init_rec_bo(); -long write_bo(); -long init_rec_xx(); -long init_rec_stringin(); -long read_stringin(); -long init_rec_stringout(); -long write_stringout(); - -void aiGpibWork(); -void aoGpibWork(); -void biGpibWork(); -void boGpibWork(); -void soGpibWork(); -void siGpibWork(); -void processCallback(); - -int xxGpibWork(); - -/****************************************************************************** - * - * Define all the dset's. - * - ******************************************************************************/ -/* Generic dset structure */ -typedef struct { - long number; - DEVSUPFUN f1; - DEVSUPFUN f2; - DEVSUPFUN f3; - DEVSUPFUN f4; - DEVSUPFUN f5; - DEVSUPFUN f6; -} gDset; - -gDset devAiHvps = {6, NULL, init_dev_sup, init_rec_ai, NULL, read_ai, NULL}; -gDset devSiHvps = {5, NULL, NULL, init_rec_stringin, NULL, read_stringin}; -gDset devAoHvps = {6, NULL, NULL, init_rec_ao, NULL, write_ao, NULL }; -gDset devSoHvps = {5, NULL, NULL, init_rec_stringout, NULL, write_stringout}; -gDset devBiHvps = {5, NULL, NULL, init_rec_bi, NULL, read_bi}; -gDset devBoHvps = {5, NULL, NULL, init_rec_bo, NULL, write_bo}; - -/*#define _SRQSUPPORT_ */ /*NO SRQ SUPPORT*/ -#define RESPONDS_2_WRITES - -#define GPIBREAD 1 -#define GPIBWRITE 2 -#define GPIBCMD 3 -#define GPIBCNTL 4 -#define GPIBSOFT 5 -#define GPIBINIT 6 - -/* BUG - dynamically allocate the hvpsTmoTable, don't hard-code this! */ -/* BUG - this is really based on the number of power supplies, not the links */ -#define MAXGPIBLINKS 2 -/* array for determining elapsed timesince last node timeout */ -static unsigned long hvpsTmoTable[MAXGPIBLINKS][2]; - -/*********************************************************** -* -* device common stuff -* -************************************************************/ -int HvpsDebug = 0; -#define UNDEFINED 1e-37 -static char UDF[10] = "Undefined"; -static char pOK[3] = "OK"; - -/********************************************************** -* -* Hvps specific stuff -* -***********************************************************/ -/* initialization and secondary commands*/ - -/* The operating mode of the HVPS*/ -#define MANUAL 0 -#define REMOTE 1 - -/* Response char in all returned messages from hvps */ - -#define NAK 0x15 -#define ACK 0x6 - -/* Local data settable from the shell */ -int hvpsGpibDelay = 0; - -struct msgMetered { - char acknak; - float data[20]; -}meteredData,lastData,onTimerData,countsData; - -struct msgChar { - char acknak; - char data[80]; -}statusData,htrTimerdata,htrStatusData; - -/* binary in strings */ - -char *modeStrs[] = {"Local", "Remote", NULL}; - -/* binary out strings */ - -char *resetStrs[] = {NULL, "RESET\r"}; -char *onStrs[] = {NULL, "HV_ON\r"}; -char *offStrs[] = {NULL, "HV_OFF\r"}; - -/* device initialization string sent one time during iocInit */ -static char *pDevInit = NULL; - -/* forward declarations of some custom convert routines */ -int inMode(); -int inData(); -int getInData(); -int inOnTimers(); -int getInTimers(); -int inCounts(); -int getInCounts(); -int inStatus(); -int getInStatus(); -int getRespStr(); -int inSetpt(); -int setPvSevr(); - - - -/**************** Hvps Declarations *****************/ - -/****************************************************************************** - * - * This structure will be attached to each pv (via psub->dpvt) to store the - * appropriate gpibWork pointer, callback address to record support, - * gpib link #, listen address, talk address and command information. - * - ******************************************************************************/ - -struct hvpsDpvt { - struct dpvtGpibHead head; - - short parm; /* parameter index into gpib commands */ - char *rsp; /* for read/write message error Responses*/ - char *msg; /* for read/write messages */ - struct dbCommon *precord; /* record this dpvt is part of */ - void (*process)(); /* callback to perform forward db processing */ - int processPri; /* process callback's priority */ - long linkType; /* GPIB_IO, BBGPIB_IO... */ -}; - -/****************************************************************************** - * - * Record type enumerations used by init routines for cross-checking - * - ******************************************************************************/ -#define GPIB_AO 0 -#define GPIB_AI 1 -#define GPIB_BO 2 -#define GPIB_BI 3 -#define GPIB_MBBO 4 -#define GPIB_MBBI 5 -#define GPIB_SO 6 -#define GPIB_SI 7 - -/****************************************************************************** - * - * GPIB work routines associated with record types - * - ******************************************************************************/ -#define mbboGpibWork NULL -#define mbbiGpibWork NULL -typedef void (*GPIBSUPFUN)(); /* pointer to gpib support functions*/ -static GPIBSUPFUN pgpibWork[] = { - aoGpibWork, - aiGpibWork, - boGpibWork, - biGpibWork, - mbboGpibWork, - mbbiGpibWork, - soGpibWork, - siGpibWork -}; - -/****************************************************************************** - * - * The next structure defines the GPIB command and format statements to - * extract or send data to a GPIB Instrument. Each transaction type is - * described below : - * - * GPIBREAD : (1) The cmd string is sent to the instrument - * (2) Data is read from the inst into a buffer (hvpsDpvt.msg) - * (3) The important data is extracted from the buffer using the - * format string. - * - * GPIBREADW : (1) The cmd string is sent to the instrument - * (2) Wait for SRQ - * (3) Data is read from the inst into a buffer (hvpsDpvt.msg) - * (4) The important data is extracted from the buffer using the - * format string. - * - * GPIBWRITE: (1) An ascii string is generated using the format string and - * contents of the hvpsDpvt->precord->val - * (2) The ascii string is sent to the instrument - * - * GPIBCMND : (1) The cmd string is sent to the instrument - * - * GPIBCNTL : (1) The control string is sent to the instrument (ATN active) - * - * GPIBSOFT : (1) No GPIB activity involved - normally retrieves internal data - * - * GPIBINIT : (1) The instrument is send SDC with command string - * - * If a particular GPIB message does not fit one of these formats, a custom - * routine may be provided. Store a pointer to this routine in the .convert - * field to use it rather than the above approaches. - * - ******************************************************************************/ -struct hvpsGpibCmd { - int recType ; /* enum - GPIB_AI, GPIB_AO ... */ - int type; /* enum - GPIBREAD, GPIBWRITE, GPIBCMND */ - short pri; /* priority of gpib request--IB_Q_HIGH or IB_Q_LOW*/ - char *sta; /* status string */ - char *cmd; /* CONSTANT STRING to send to instrument */ - char *format; /* string used to generate or interpret msg*/ - short rspLen; /* room for response error message*/ - short msgLen; /* room for return data message length*/ - int (*convert)(); /* custom routine for wierd conversions */ - int P1; /* parameter used in convert*/ - int P2; /* parameter user in convert*/ - char **P3; /* pointer to array containing pointers to strings */ - struct names *namelist; /* for bx and mbbx record's name fields */ -}; - -# define FILL {10,0,IB_Q_LOW,UDF,NULL,NULL,0,0,NULL,0,0,NULL,NULL } -# define FILL10 FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL - -static struct hvpsGpibCmd hvpsGpibCmds[] = -{ - -/* ai records */ -/* 0 ->59 */ -{GPIB_AI, GPIBREAD, IB_Q_LOW, UDF, "RD_DATA\r", NULL, 80, 80, inData, 0 ,0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 0, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 1, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 2, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 3, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 4, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 5, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 6, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 7, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 8, 0, NULL, NULL}, -/*10*/ -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 9, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 10, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 11, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 12, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInData, 13, 0, NULL, NULL}, -{GPIB_AI, GPIBREAD, IB_Q_LOW, UDF, "RD_TMRS\r", "%f%f", 80, 80, inOnTimers, 0 ,0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInTimers, 0, 0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInTimers, 1, 0, NULL, NULL}, -{GPIB_AI, GPIBREAD, IB_Q_LOW, UDF, "RD_CNTS\r", "%f%f", 80, 80, inCounts, 0 ,0, NULL, NULL}, -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInCounts, 0, 0, NULL, NULL}, -/*10*/ -{GPIB_AI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInCounts, 1, 0, NULL, NULL}, -{GPIB_AI, GPIBREAD, IB_Q_LOW, UDF, "RD_SETPT HV_VOLTS\r", "%lf", 80, 80, inSetpt, 0 ,0, NULL, NULL}, -{GPIB_AI, GPIBREAD, IB_Q_LOW, UDF, "RD_SETPT MA_VOLTS\r","%lf", 80, 80, inSetpt, 0 ,0, NULL, NULL}, -{GPIB_AI, GPIBREAD, IB_Q_LOW, UDF, "RD_SETPT KLHTR_VOLTS\r", "%lf", 80, 80, inSetpt, 0 ,0, NULL, NULL}, -{GPIB_AI, GPIBREAD, IB_Q_LOW, UDF, "RD_SETPT KLMAG_AMPS\r", "%lf", 80, 80, inSetpt, 0 ,0, NULL, NULL}, -FILL,FILL,FILL,FILL,FILL, -/*10*/ -FILL10, -/*10*/ -FILL10, -/*10*/ -FILL10, - - -/* bi records */ -/*start 60 ->119*/ -{GPIB_BI, GPIBREAD, IB_Q_LOW, UDF, "RD_STATUS\r", NULL, 80, 80, inStatus, 0, 0, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x1, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x2, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x4, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x8, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x10, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x20, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x40, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 0, 0x80, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x1, NULL, NULL}, -/*10*/ -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x2, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x4, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x8, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x10, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x20, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x40, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 1, 0x80, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x1, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x2, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x4, NULL, NULL}, -/*10*/ -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x8, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x10, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x20, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x40, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 2, 0x80, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x1, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x2, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x4, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x8, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x10, NULL, NULL}, -/*10*/ -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x20, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x40, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 3, 0x80, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x1, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x2, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x4, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x8, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x10, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x20, NULL, NULL}, -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x40, NULL, NULL}, -/*10*/ -{GPIB_BI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 0, 0, getInStatus, 4, 0x80, NULL, NULL}, -{GPIB_BI, GPIBREAD, IB_Q_LOW, UDF, "RD_MODE\r", NULL, 40,40, NULL, 0 ,0, modeStrs, NULL}, -FILL,FILL,FILL, -FILL,FILL,FILL,FILL,FILL, -/*10*/ -FILL10, - - -/* ao records */ -/* start 120->159*/ -{GPIB_AO, GPIBWRITE, IB_Q_LOW, UDF, NULL, "LD_SETPT HV_VOLTS %10.3E\r", 40, 40, NULL, 0, 0, NULL, NULL}, -{GPIB_AO, GPIBWRITE, IB_Q_LOW, UDF, NULL, "LD_SETPT MA_VOLTS %10.3E\r", 40, 40, NULL, 0, 0, NULL, NULL}, -{GPIB_AO, GPIBWRITE, IB_Q_LOW, UDF, NULL, "LD_SETPT KLHTR_VOLTS %10.3E\r", 40, 40, NULL, 0, 0, NULL, NULL}, -{GPIB_AO, GPIBWRITE, IB_Q_LOW, UDF, NULL, "LD_SETPT KLMAG_AMPS %10.3E\r", 40, 40, NULL, 0, 0, NULL, NULL}, -FILL, -FILL,FILL,FILL,FILL,FILL, -/*10*/ -FILL10, -/*10*/ -FILL10, -/*10*/ -FILL10, - - -/* bo records */ -/*start 160->179*/ -{GPIB_BO, GPIBWRITE, IB_Q_LOW, UDF, NULL, NULL, 80, 80, NULL, 0, 0, resetStrs, NULL}, -{GPIB_BO, GPIBWRITE, IB_Q_LOW, UDF, NULL, NULL, 80, 80, NULL, 0, 0, onStrs, NULL}, -{GPIB_BO, GPIBWRITE, IB_Q_LOW, UDF, NULL, NULL, 80, 80, NULL, 0, 0, offStrs, NULL}, -FILL,FILL, -FILL,FILL,FILL,FILL,FILL, -/*10*/ -FILL10, - - -/* stringin records */ -/*start 180->199*/ -{GPIB_SI, GPIBREAD, IB_Q_LOW, UDF, "RD_HTR_STATUS\r", NULL, 40,40, NULL, 0 ,0, NULL, NULL}, -{GPIB_SI, GPIBREAD, IB_Q_LOW, UDF, "RD_WARMUP\r", NULL, 40,40, NULL, 0 ,0, NULL, NULL}, -{GPIB_SI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 40,40, getRespStr, 101 ,0, NULL, NULL}, -{GPIB_SI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 40,40, getRespStr, 102 ,0, NULL, NULL}, -{GPIB_SI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 40,40, getRespStr, 103 ,0, NULL, NULL}, -{GPIB_SI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 40,40, getRespStr, 160 ,0, NULL, NULL}, -{GPIB_SI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 40,40, getRespStr, 161 ,0, NULL, NULL}, -{GPIB_SI, GPIBSOFT, IB_Q_LOW, UDF, NULL, NULL, 40,40, getRespStr, 162 ,0, NULL, NULL}, -FILL, FILL, -/*10*/ -FILL10, - - -/* stringout records */ -/*start 200->209*/ -{GPIB_SO, GPIBWRITE, IB_Q_LOW, UDF, NULL, NULL, 40,40, NULL, 0 ,0, NULL, NULL} -}; - -#define NUMHVPSPARAMS sizeof(hvpsGpibCmds)/sizeof(struct hvpsGpibCmd) - -/****************************************************************************** - * - * Initialization for Hvps device support - * - ******************************************************************************/ - -static long init_dev_sup() -{ - static char firstInitCall = 0; - - /* check to see if we have been here before */ - if (firstInitCall) - { - return(OK); /* if already initialized, return */ - } - firstInitCall = 1; - - /* continue initalizations */ - logMsg("Hvps Device Support Initializing ...\n"); - - return(OK); -} - -/****************************************************************************** - * - * Initialization routines for each record specifying a Hvps Device Type - * - ******************************************************************************/ - -/****************************************************************************** - * - * ai record init - * - ******************************************************************************/ -static long -init_rec_ai(pai, process) -struct aiRecord *pai; -void (*process)(); -{ - /* do common initialization */ - return(init_rec_xx((caddr_t) pai, &pai->inp, GPIB_AI)); -} - -/****************************************************************************** - * - * ao record init - * - ******************************************************************************/ -static long -init_rec_ao(pao, process) -struct aoRecord *pao; -void (*process)(); -{ - /* do common initialization */ - return(init_rec_xx((caddr_t) pao, &pao->out, GPIB_AO)); -} - -/****************************************************************************** - * - * stringin record init - * - ******************************************************************************/ -static long -init_rec_stringin(pstringin, process) -struct stringinRecord *pstringin; -void (*process)(); -{ - /* do common initialization */ - return( init_rec_xx((caddr_t) pstringin, &pstringin->inp, GPIB_SI)); -} - -/****************************************************************************** - * - * stringout record init - * - ******************************************************************************/ -static long -init_rec_stringout(pstringout, process) -struct stringoutRecord *pstringout; -void (*process)(); -{ - /* do common initialization */ - return(init_rec_xx((caddr_t) pstringout, &pstringout->out, GPIB_SO)); -} - -/****************************************************************************** - * - * bi record init - * - ******************************************************************************/ -static long -init_rec_bi(pbi, process) -struct biRecord *pbi; -void (*process)(); -{ - /* do common initialization */ - return(init_rec_xx((caddr_t) pbi, &pbi->inp, GPIB_BI)); - -/* BUG - what about the button labels?? */ -} - -/* bo record init */ -static long init_rec_bo(pbo, process) -struct boRecord *pbo; -void (*process)(); -{ - /* do common initialization */ - return(init_rec_xx((caddr_t) pbo, &pbo->out, GPIB_BO)); - -/* BUG - what about the button labels?? */ -} - -/****************************************************************************** - * - * This init routine is common to all record types - * - ******************************************************************************/ - -static long -init_rec_xx(prec, plink, recType) -struct dbCommon *prec; -struct link *plink; -int recType; -{ - static short firstTime = TRUE; - - struct hvpsDpvt *pdpvt; - struct dbCommon *pdbCommon = (struct dbCommon *)prec; - char message[100]; - struct hvpsGpibCmd *pCmd; - char subType; - - - if (HvpsDebug) - logMsg("hvps init_rec_xx(): entered\n"); - - /* allocate space for the private structure */ - pdpvt = (struct hvpsDpvt *) malloc(sizeof(struct hvpsDpvt)); - prec->dpvt = (void *) pdpvt; - - pdpvt->precord = prec; - pdpvt->head.workStart = pgpibWork[recType]; - pdpvt->parm = -1; /* In case the sscanf fails */ - pdpvt->linkType = plink->type; - - switch (plink->type) { - case GPIB_IO: /* Is a straight Network Instruments link */ - -/* BUG - this should be a driver supplied function to fill in the header */ - - pdpvt->head.link = plink->value.gpibio.link; /* NI link number */ - pdpvt->head.device = plink->value.gpibio.addr; /* gpib dev address */ - sscanf(plink->value.gpibio.parm, "%hd", &(pdpvt->parm)); - pdpvt->head.bitBusDpvt = NULL; /* no bitbus data needed */ - break; - case BBGPIB_IO: /* Is a bitbus -> gpib link */ - -/* BUG - this should be a driver supplied function to fill in the header */ - - pdpvt->head.device = plink->value.bbgpibio.gpibaddr; /* gpib dev address */ - sscanf(plink->value.bbgpibio.parm, "%hd", &(pdpvt->parm)); - - pdpvt->head.bitBusDpvt = (struct dpvtBitBusHead *) malloc(sizeof(struct dpvtBitBusHead)); - pdpvt->head.bitBusDpvt->txMsg = (struct bitBusMsg *) malloc(sizeof(struct bitBusMsg)); - pdpvt->head.bitBusDpvt->rxMsg = (struct bitBusMsg *) malloc(sizeof(struct bitBusMsg)); - pdpvt->head.bitBusDpvt->txMsg->node = plink->value.bbgpibio.bbaddr; /* bug node address */ - pdpvt->head.bitBusDpvt->link = plink->value.bbgpibio.link; /* bug link number */ - pdpvt->head.link = plink->value.bbgpibio.link; - pdpvt->head.bitBusDpvt->rxMaxLen = sizeof(struct bitBusMsg); - break; - default: - strcpy(message, pdbCommon->name); - strcat(message,": init_record : GPIB link type is invalid"); - errMessage(S_db_badField, message); - return(S_db_badField); - break; - } - - /* check for valid GPIB addr */ - if ((pdpvt->head.device < 0) || (pdpvt->head.device >= IBAPERLINK)) - { - strcpy(message, pdbCommon->name); - strcat(message,": init_record : GPIB address out of range"); - errMessage(S_db_badField,message); - return(S_db_badField); - } - /* check for valid param entry */ - if ((pdpvt->parm < 0) || (pdpvt->parm > NUMHVPSPARAMS)) - { - strcpy(message, pdbCommon->name); - strcat(message,": init_record : Parameter # out of range"); - errMessage(S_db_badField,message); - return(S_db_badField); - } - - /* check record type*/ - if(hvpsGpibCmds[pdpvt->parm].recType != recType ) - { - strcpy(message, pdbCommon->name); - strcat(message,": init_record : record type invalid for parameter"); - errMessage(S_db_badField,message); - return(S_db_badField); - } - - pCmd = &hvpsGpibCmds[pdpvt->parm]; - if(pCmd->msgLen > 0) - pdpvt->msg = (char *)(calloc(pCmd->msgLen,1)); - if(pCmd->rspLen > 0) - pdpvt->rsp = (char *)(calloc(pCmd->rspLen,1)); - -/* BUG this init logic is wrong for multi-devices... */ -/* BUG - it should be on a per-device address basis */ -/* - fix it when dynamically allocating the per-device structures. */ - -/* BUG!!! this HAS to be done via qGpibReq!!!! */ - if( firstTime && pDevInit != NULL ) - { - if( (*(drvGpib.writeIb))(pdpvt->head.link, pdpvt->head.device, pDevInit, strlen(pDevInit)) == ERROR) - { - logMsg("Hvps device initialization-GPIB setup error\n"); - return(ERROR); - } - } - - /* fill in the required stuff for the callback task */ - pdpvt->process = processCallback; - pdpvt->processPri = priorityLow; - - return(0); -} - -/****************************************************************************** - * - * These are the device support routne entry points called by record support. - * - ******************************************************************************/ -static long -read_ai(pai) -struct aiRecord *pai; -{ - struct hvpsDpvt *pdpvt = (struct hvpsDpvt *)(pai->dpvt); - struct hvpsGpibCmd *pCmd; - - pCmd = &hvpsGpibCmds[pdpvt->parm]; - if (pai->pact) - { - if(HvpsDebug) - logMsg("read_ai with PACT = 1\n"); - return(2); /* work is all done, return '2' to indicate val */ - } - else if (pCmd->type == GPIBSOFT) - { - (*pCmd->convert)(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - return(2); - } - else - { /* put pointer to dvpt field on ring buffer */ - if(HvpsDebug) - logMsg("read_ai with PACT = 0\n"); - if((*(drvGpib.qGpibReq))(pdpvt->linkType, pdpvt->head.link, pdpvt, pCmd->pri) == ERROR) - { - setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); - return(0); - } - return(1); - } -} - - -static long write_ao(pao) -struct aoRecord *pao; -{ - struct hvpsDpvt *pdpvt = (struct hvpsDpvt *)(pao->dpvt); - struct hvpsGpibCmd *pCmd; - - pCmd = &hvpsGpibCmds[pdpvt->parm]; - - if(HvpsDebug) - logMsg("Hvps-write_ao entered type: %d format %s\n",pCmd->type,pCmd->format); - - if (pao->pact) - return(2); /* work is all done, finish processing */ - else if (pCmd->type == GPIBSOFT) - { - (*pCmd->convert)(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - return(0); - } - else - { /* put pointer to dvpt field on ring buffer */ - if((*(drvGpib.qGpibReq))(pdpvt->linkType, pdpvt->head.link, pdpvt, pCmd->pri) == ERROR) - { - setPvSevr(pao,WRITE_ALARM,INVALID_ALARM); - return(0); - } - return(1); - } -} - -static long read_stringin(pstringin) -struct stringinRecord *pstringin; -{ - struct hvpsDpvt *pdpvt = (struct hvpsDpvt *)(pstringin->dpvt); - struct hvpsGpibCmd *pCmd; - - pCmd = &hvpsGpibCmds[pdpvt->parm]; - if (pstringin->pact) - { - if(HvpsDebug) - logMsg("read_stringin with PACT = 1\n"); - return(2); /* work is all done, return '2' to indicate val */ - } - else if (pCmd->type == GPIBSOFT) - { - (*pCmd->convert)(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - return(0); - } - else - { /* put pointer to dvpt field on ring buffer */ - if(HvpsDebug) - logMsg("read_stringin with PACT = 0\n"); - if((*(drvGpib.qGpibReq))(pdpvt->linkType, pdpvt->head.link, pdpvt, pCmd->pri) == ERROR) - { - setPvSevr(pstringin,MAJOR_ALARM,INVALID_ALARM); - return(0); - } - return(1); - } -} - - -static long write_stringout(pstringout) -struct stringoutRecord *pstringout; -{ - struct hvpsDpvt *pdpvt = (struct hvpsDpvt *)(pstringout->dpvt); - struct hvpsGpibCmd *pCmd; - - pCmd = &hvpsGpibCmds[pdpvt->parm]; - if(HvpsDebug) - logMsg("stringout entered string %s\n",pstringout->val); - - if (pstringout->pact) - { - return(0); /* work is all done, finish processing */ - } - else if (pCmd->type == GPIBSOFT) - { - (*pCmd->convert)(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - return(0); - } - else - { /* put pointer to dvpt field on ring buffer */ - if((*(drvGpib.qGpibReq))(pdpvt->linkType, pdpvt->head.link, pdpvt, pCmd->pri) == ERROR) - { - setPvSevr(pstringout,WRITE_ALARM,INVALID_ALARM); - return(0); - } - return(1); - } -} - -static long read_bi(pbi) -struct biRecord *pbi; -{ - struct hvpsDpvt *pdpvt = (struct hvpsDpvt *)(pbi->dpvt); - struct hvpsGpibCmd *pCmd; - - pCmd = &hvpsGpibCmds[pdpvt->parm]; - - if (pbi->pact) - return(2); /* work is all done, finish processing */ - else if (pCmd->type == GPIBSOFT) - { - (*pCmd->convert)(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - return(2); - } - else - { /* put pointer to dvpt field on ring buffer */ - if((*(drvGpib.qGpibReq))(pdpvt->linkType, pdpvt->head.link, pdpvt, pCmd->pri) == ERROR) - { - setPvSevr(pbi,READ_ALARM,INVALID_ALARM); - return(0); - } - return(1); - } -} - - -static long write_bo(pbo) -struct boRecord *pbo; -{ - struct hvpsDpvt *pdpvt = (struct hvpsDpvt *)(pbo->dpvt); - struct hvpsGpibCmd *pCmd; - - pCmd = &hvpsGpibCmds[pdpvt->parm]; - - if (pbo->pact) - return(2); /* work is all done, finish processing */ - else if (pCmd->type == GPIBSOFT) - { - (*pCmd->convert)(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - return(0); - } - else - { /* put pointer to dvpt field on ring buffer */ - if((*(drvGpib.qGpibReq))(pdpvt->linkType, pdpvt->head.link, pdpvt, pCmd->pri) == ERROR) - { - setPvSevr(pbo,WRITE_ALARM,INVALID_ALARM); - return(0); - } - return(1); - } -} - -/****************************************************************************** - * - * Routines to do the real GPIB work. - * - * These functions are invoked by the GPIB link task. As such, they should not - * do any expensive operations within the context of that task. If expensive - * non-I/O related things are to be done, they should be done by scheduling a - * callbackRequest for an other function to handle it. - * - ******************************************************************************/ - -static void -aiGpibWork(pdpvt) -struct hvpsDpvt *pdpvt; -{ - double value; - struct aiRecord *pai= ((struct aiRecord *)(pdpvt->precord)); - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - /* go send predefined cmd msg and read response into msg[] */ - - if(HvpsDebug) - logMsg("aiGpibWork: starting ...\n"); - - if (xxGpibWork(pdpvt) == ERROR) - { - if(HvpsDebug) - logMsg("aiGpibWork: error in xxGpibWork ...\n"); - setPvSevr(pai,READ_ALARM,INVALID_ALARM); - } - else /* interpret response that came back */ - { /* call convert routine, if defined */ - if (pCmd->convert != NULL) - { - if(HvpsDebug) - logMsg("aiGpibWork: calling convert ...\n"); - (*(pCmd->convert))(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - if(HvpsDebug) - logMsg("aiGpibWork: returned from convert ...\n"); - } - else /* interpret msg with predefined format and write into .val */ - { - /* scan response string, return value will be 1 if successful */ - if(sscanf(pdpvt->msg,pCmd->format,&value)) - { - pai->val = value; - } - else /* sscanf did not find or assign the parameter */ - { - setPvSevr(pai,READ_ALARM,INVALID_ALARM); - } - } - } - if(HvpsDebug) - logMsg("aiGpibWork: calling process ...\n"); - - pdpvt->head.header.callback.finishProc = pdpvt->process; - pdpvt->head.header.callback.priority = pdpvt->processPri; - callbackRequest(pdpvt); /* jrw */ -} - -static void siGpibWork(pdpvt) -struct hvpsDpvt *pdpvt; -{ - struct stringinRecord *pstringin= ((struct stringinRecord *)(pdpvt->precord)); - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - /* go send predefined cmd msg and read response into msg[] */ - - if(HvpsDebug) - logMsg("stringinGpibWork: starting ...\n"); - - if (xxGpibWork(pdpvt) == ERROR) - { - if(HvpsDebug) - logMsg("stringinGpibWork: error in xxGpibWork ...\n"); - setPvSevr(pstringin,READ_ALARM,INVALID_ALARM); - } - else /* interpret response that came back */ - { /* call convert routine, if defined */ - if (pCmd->convert != NULL) - { - if(HvpsDebug) - logMsg("stringinGpibWork: calling convert ...\n"); - (*(pCmd->convert))(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - if(HvpsDebug) - logMsg("stringinGpibWork: returned from convert ...\n"); - } - else /* copy up to 39 characters into .val + null terminator */ - { - strncpy(pstringin->val,pdpvt->msg,39); - pstringin->val[40] = '\0'; - pstringin->udf = FALSE; - } - } - if(HvpsDebug) - logMsg("siGpibWork: calling process ...\n"); - - pdpvt->head.header.callback.finishProc = pdpvt->process; - pdpvt->head.header.callback.priority = pdpvt->processPri; - callbackRequest(pdpvt); /* jrw */ -} - - - -static void aoGpibWork(pdpvt) -struct hvpsDpvt *pdpvt; -{ - int cnvrtStat = OK; - struct aoRecord *pao= ((struct aoRecord *)(pdpvt->precord)); - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - /* generate command string to be sent */ - - /* call convert routine, if defined */ - if (pCmd->convert != NULL) - { - cnvrtStat = (*(pCmd->convert))(pdpvt, pCmd->P1,pCmd->P2, pCmd->P3); - } - else /* generate msg using predefined format and current val */ - { - sprintf(pdpvt->msg, pCmd->format, pao->val); - } - /* go access board with this message, unless convert was unsuccessful */ - if ((cnvrtStat == ERROR) || (xxGpibWork(pdpvt) == ERROR)) - { - setPvSevr(pao,WRITE_ALARM,INVALID_ALARM); - } - else if(pdpvt->rsp[0] == NAK) - { - pCmd->sta = &pdpvt->rsp[1]; - setPvSevr(pao,WRITE_ALARM,INVALID_ALARM); - } - else - { - pCmd->sta = pOK; - } - if(HvpsDebug) - logMsg("aoGpibWork: calling process ...\n"); - - pdpvt->head.header.callback.finishProc = pdpvt->process; - pdpvt->head.header.callback.priority = pdpvt->processPri; - callbackRequest(pdpvt); /* jrw */ -} - - static void soGpibWork(pdpvt) -struct hvpsDpvt *pdpvt; -{ - int cnvrtStat = OK; - struct stringoutRecord *pstringout= ((struct stringoutRecord *)(pdpvt->precord)); - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - /* generate command string to be sent */ - - /* call convert routine, if defined */ - if (pCmd->convert != NULL) - { - cnvrtStat = (*(pCmd->convert))(pdpvt, pCmd->P1,pCmd->P2, pCmd->P3); - } - else /* generate msg using predefined format and current val */ - { - pstringout->udf = FALSE; - strncpy(pdpvt->msg,pstringout->val,40 ); - logMsg("parameter %d message %s type %d \n",pdpvt->parm,pdpvt->msg,pCmd->type); - } - - /* go access board with this message, unless convert was unsuccessful */ - if ((cnvrtStat == ERROR) || (xxGpibWork(pdpvt) == ERROR)) - { - setPvSevr(pstringout,WRITE_ALARM,INVALID_ALARM); - } - if(HvpsDebug) - logMsg("aiGpibWork: calling process ...\n"); - - pdpvt->head.header.callback.finishProc = pdpvt->process; - pdpvt->head.header.callback.priority = pdpvt->processPri; - callbackRequest(pdpvt); /* jrw */ -} - -/* BUG -- use the convertion routine for the mode string stuff */ -static void biGpibWork(pdpvt) -struct hvpsDpvt *pdpvt; -{ - unsigned long value; - struct biRecord *pbi= ((struct biRecord *)(pdpvt->precord)); - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - short strIndex; - struct msgChar *pMsg = ( struct msgChar *)pdpvt->msg; - - /* go send predefined cmd msg and read response into msg[] */ - - if (xxGpibWork(pdpvt) == ERROR) - { - setPvSevr(pbi,READ_ALARM,INVALID_ALARM); - } - else /* interpret response that came back */ - { /* call convert routine, if defined */ - if (pCmd->convert != NULL) - { - if(HvpsDebug) - logMsg("biGpibWork calling convert routine\n"); - - (*(pCmd->convert))(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - - if(HvpsDebug) - logMsg("biGpibWork return from convert routine\n"); - } - else - if (pCmd->P3 != NULL) /* compare with expected strings */ - { - strIndex = 0; - while(pCmd->P3[strIndex] != NULL) - { - if( strncmp(pCmd->P3[strIndex],pMsg->data,strlen(pCmd->P3[strIndex])) == 0 ) break ; - strIndex++; - if(HvpsDebug) - logMsg("biGpibWork:string index:%d\n",strIndex); - } - if(pCmd->P3[strIndex] != NULL & strIndex < 2) - { - pbi->udf = FALSE; - pbi->val = strIndex; - if(HvpsDebug) - logMsg("biGpibWork: matched string index:%d\n",strIndex); - } - else - { - pbi->udf = TRUE; - setPvSevr(pbi,READ_ALARM,INVALID_ALARM); - } - } - else /* interpret msg with predefined format and write into .rval */ - { - /* scan response string, return value will be 1 if successful */ - if(sscanf(pdpvt->msg,pCmd->format, &value)) - { - pbi->rval = value; - } - else /* sscanf did not find or assign the parameter */ - { - setPvSevr(pbi,READ_ALARM,INVALID_ALARM); - } - }/*else*/ - }/*else*/ - if(HvpsDebug) - logMsg("biGpibWork calling final callback routine\n"); - - pdpvt->head.header.callback.finishProc = pdpvt->process; - pdpvt->head.header.callback.priority = pdpvt->processPri; - callbackRequest(pdpvt); /* jrw */ -} - -static void boGpibWork(pdpvt) -struct hvpsDpvt *pdpvt; -{ - int cnvrtStat = OK; - int strStat = OK; - struct boRecord *pbo= ((struct boRecord *)(pdpvt->precord)); - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - /* generate command string to be sent */ - - /* call convert routine, if defined */ - if (pCmd->convert != NULL) - { - cnvrtStat = (*(pCmd->convert))(pdpvt,pCmd->P1,pCmd->P2, pCmd->P3); - } - else - if(pbo->val == 0 || pbo->val == 1) - { /* generate msg using predefined format and current val */ - pbo->udf = FALSE; - if(pCmd->P3[pbo->val] != NULL) - { - strncpy(pdpvt->msg, pCmd->P3[pbo->val],(pCmd->msgLen)-1); - pdpvt->msg[pCmd->msgLen] = NULL; - } - else - strStat = ERROR; - } - else - cnvrtStat = ERROR; - - if(strStat == OK) - { /* go access board with this message, unless convert was unsuccessful */ - if ((cnvrtStat == ERROR) || (xxGpibWork(pdpvt) == ERROR)) - { - setPvSevr(pbo,WRITE_ALARM,MAJOR_ALARM); - } - else if(pdpvt->rsp[0] == NAK) - { - pCmd->sta = &pdpvt->rsp[1]; - setPvSevr(pbo,WRITE_ALARM,MAJOR_ALARM); - } - else - { - pCmd->sta = pOK; - } - }/*strStat*/ - if(HvpsDebug) - logMsg("boGpibWork: calling process ...\n"); - - pdpvt->head.header.callback.finishProc = pdpvt->process; - pdpvt->head.header.callback.priority = pdpvt->processPri; - callbackRequest(pdpvt); /* jrw */ -} - -/****************************************************************************** - * - * General GPIB work function. - * This is the only place (after initialization) that any GPIB message commands - * are issued. - * - ******************************************************************************/ -static int xxGpibWork(pdpvt) -struct hvpsDpvt *pdpvt; -{ - int status; /* for GPIBREAD, contains ERROR or # of bytes read */ - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - short ibnode = pdpvt->head.device; - short bbnode; - - /* If is a BBGPIB_IO link, the bug address is needed */ - if (pdpvt->linkType == BBGPIB_IO) - bbnode = pdpvt->head.bitBusDpvt->txMsg->node; - - if (HvpsDebug) - logMsg("Hvps - xxGpibWork(%08.8X): device = %d, link = %d\n", pdpvt, pdpvt->head.device, pdpvt->head.link); - -/* - * check to see if this node has timed out within last 10 sec - */ - -/* BUG -- loose the hard-coded ticks and fix refs to the tmoTable */ - if(hvpsTmoTable[pdpvt->head.link][1] != 0) - { - if(tickGet() < (hvpsTmoTable[pdpvt->head.link][0] +600) ) - { - if (HvpsDebug) - logMsg("Hvps-xxGpibWork(): timeout flush\n"); - return(ERROR); - } - } - - switch (pCmd->type) { - case GPIBWRITE: /* write the message to the GPIB listen adrs */ - if(HvpsDebug) - logMsg("xxGpibWork : processing GPIBWRITE\n"); - status = (*(drvGpib.writeIb))(pdpvt->linkType, pdpvt->head.link, bbnode, ibnode, pdpvt->msg, strlen(pdpvt->msg)); - -/* - * use for devices which respond to write commands - */ -#ifdef RESPONDS_2_WRITES - if (status == ERROR) - { - break; - } - if(hvpsGpibDelay) - taskDelay(hvpsGpibDelay); - status = (*(drvGpib.readIb))(pdpvt->linkType, pdpvt->head.link, bbnode, ibnode, pdpvt->rsp, pCmd->rspLen); -#endif - break; - - case GPIBREAD: /* write the command string */ - if(HvpsDebug) - logMsg("xxGpibWork : processing GPIBREAD\n"); - status = (*(drvGpib.writeIb))(pdpvt->linkType, pdpvt->head.link, bbnode, ibnode, pCmd->cmd, strlen(pCmd->cmd)); - if (status == ERROR) - break; - /* read the instrument */ - if(hvpsGpibDelay) - taskDelay(hvpsGpibDelay); - status = (*(drvGpib.readIb))(pdpvt->linkType, pdpvt->head.link, bbnode, ibnode, pdpvt->msg, pCmd->msgLen); - - if (status == ERROR) - break; - else - if (status >( (pCmd->msgLen) - 1) ) /* check length of resp */ - { - logMsg("GPIB Response length equaled allocated space !!!\n"); - pdpvt->msg[(pCmd->msgLen)-1] = '\0'; /* place \0 at end */ - } - else - { - pdpvt->msg[status] = '\0'; /* terminate response with \0 */ - } - break; - -/* BUG - this srq stuff is not right at all */ -#ifdef _SRQSUPPORT_ - case GPIBREADW: /* write the command string */ - if(HvpsDebug) - logMsg("xxGpibWork : processing GPIBREADW\n"); - - /*enable SRQ to set semaphore*/ - srqTable.active = TRUE; - srqTable.status = 0; - - status = (*(drvGpib.writeIb))( pdpvt->link,pdpvt->lad, pCmd->cmd, strlen(pCmd->cmd)); - if (status == ERROR) - break; - - /*wait for SRQ on measurement completion*/ -/* BUG -this should be via callbackRequest span */ - semTake(HvpsSrqSEM); - logMsg("srq startus %x\n",srqTable.status); - - /* read the instrument */ - status = (*(drvGpib.readIb))(pdpvt->link,pdpvt->tad, pdpvt->msg, pCmd->msgLen); - if (status == ERROR) - break; - else - if (status >( (pCmd->msgLen) - 1) ) /* check length of resp */ - { - logMsg("GPIB Response length equaled allocated space !!!\n"); - pdpvt->msg[(pCmd->msgLen)-1] = '\0'; /* place \0 at end */ - } - else - { - pdpvt->msg[status] = '\0'; /* terminate response with \0 */ - } - break; -#endif /* _SRQSUPPORT_ */ - - case GPIBCMD: /* write the cmd to the GPIB listen adrs */ - status = (*(drvGpib.writeIb))(pdpvt->linkType, pdpvt->head.link, bbnode, ibnode, pCmd->cmd, strlen(pCmd->cmd)); - break; - -/* BUG - this is not supported... yet */ -#ifdef I_CANT_DO_THIS - case GPIBINIT: /* write the cmd & SDC to GPIB listen adrs */ - status = initib(pdpvt->head.device, pCmd->cmd, strlen(pCmd->cmd)); - break; -#endif - - } - if(HvpsDebug) - logMsg("xxGpibWork : done, status = %d\n",status); - /* if error occurrs then mark it with time */ - if(status == ERROR) - { - hvpsTmoTable[pdpvt->head.link][0] = tickGet(); - hvpsTmoTable[pdpvt->head.link][1]++; - } - return(status); -} - -/****************************************************************************** - * - * This function is called by the callback task. The callback task - * calls it after being given the 'go ahead' by callbackRequest() - * function calls made in the xxxWork routines defined above. - * - * The reason it is done this way is because the process() call may - * recursively call itself when records are chained and the callback - * task's stack is larger... just for this purpose. (jrw) - * - ******************************************************************************/ -void processCallback(pDpvt) -struct hvpsDpvt *pDpvt; -{ - if(HvpsDebug) - logMsg("processCallback: locking %08.8X\n", pDpvt->precord); - - dbScanLock(pDpvt->precord); - - if(HvpsDebug) - logMsg("processCallback: calling process\n"); - - (*(struct rset *)(pDpvt->precord->rset)).process(pDpvt->precord); - - if(HvpsDebug) - logMsg("processCallback: unlocking %08.8X\n", pDpvt->precord); - - dbScanUnlock(pDpvt->precord); -} - -/****************************************************************************** - * - * Convert routines for the Hvps - * - ******************************************************************************/ - -/* BUG - deal with hard-coded lengths, they are bad as well as wrong */ -static int inMode(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - strncpy(((struct stringinRecord *)(pdpvt->precord))->val, pdpvt->msg,39); - ((struct stringinRecord *)(pdpvt->precord))->val[39] = '\0'; -} - - -static int getRespStr(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - - struct stringinRecord *pstringin= (struct stringinRecord *)(pdpvt->precord); - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[P1]; - - pstringin->udf = FALSE; - strncpy(pstringin->val,pCmd->sta,39); - pstringin->val[40] = '\0'; -} - - -static int inData(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - short i; - char *pFirstDataByte; - - struct aiRecord *pai= (struct aiRecord *)(pdpvt->precord); - struct msgMetered *pMsg = ( struct msgMetered *)pdpvt->msg; - pai->udf = FALSE; - - if(pMsg->acknak == ACK) - { - pFirstDataByte = (pdpvt->msg)+1; - memcpy(meteredData.data,pFirstDataByte,56); -/* for(i=0;i<=13;i++) meteredData.data[i] = pMsg->data[i];*/ - meteredData.acknak = ACK; - } - else if(pMsg->acknak == NAK) - { - for(i=0;i<=13;i++) meteredData.data[i] = UNDEFINED; - meteredData.acknak = NAK; - setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); - } -} - - -static int getInData(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - struct aiRecord *pai= (struct aiRecord *)(pdpvt->precord); - struct msgMetered *pMsg = &meteredData; - - pai->udf = FALSE; - pai->val = pMsg->data[P1]; - if(pMsg->acknak == NAK) setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); -} - -static int inStatus(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - short i; - - struct biRecord *pbi= (struct biRecord *)(pdpvt->precord); - struct msgChar *pMsg = (struct msgChar *)pdpvt->msg; - - pbi->udf = FALSE; - if(pMsg->acknak == ACK) - { - if(HvpsDebug) logMsg("inStatus entered with ACK\n"); - for(i=0;i<=4;i++) statusData.data[i] = pMsg->data[i]; - statusData.acknak = ACK; - } - else if(pMsg->acknak == NAK) - { - if(HvpsDebug) logMsg("inStatus entered with NAK\n"); - statusData.acknak = NAK; - setPvSevr(pbi,MAJOR_ALARM,INVALID_ALARM); - } -} - -static int getInStatus(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - struct biRecord *pbi= (struct biRecord *)(pdpvt->precord); - struct msgChar *pMsg = &statusData; - - pbi->udf = FALSE; - pbi->val = ( (pMsg->data[P1]) & P2 ) ? 1:0; - if(pMsg->acknak == NAK) setPvSevr(pbi,MAJOR_ALARM,INVALID_ALARM); -} - -static int inOnTimers(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - short i; - struct aiRecord *pai= (struct aiRecord *)(pdpvt->precord); - struct msgChar *pMsg = (struct msgChar *)pdpvt->msg; - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - - pai->udf = FALSE; - if(pMsg->acknak == ACK) - { - sscanf(pMsg->data,pCmd->format,&onTimerData.data[0], - &onTimerData.data[1] ); - onTimerData.acknak = ACK; - } - else if(pMsg->acknak == NAK) - { - for(i=0;i<=1;i++) onTimerData.data[i] = UNDEFINED; - - strncpy(pdpvt->rsp, pdpvt->msg,(pCmd->rspLen)-1); - pdpvt->rsp[pCmd->rspLen] = '\0'; - - onTimerData.acknak = NAK; - setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); - } -} - -static int getInTimers(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - struct aiRecord *pai= (struct aiRecord *)(pdpvt->precord); - struct msgMetered *pMsg = &onTimerData; - - pai->udf = FALSE; - pai->val = pMsg->data[P1]; - if(pMsg->acknak == NAK) setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); -} - - -static int inCounts(pdpvt,P1,P2,P3) -struct hvpsDpvt *pdpvt; -int P1; -int P2; -char **P3; -{ - short i; - struct aiRecord *pai= (struct aiRecord *)(pdpvt->precord); - struct msgChar *pMsg = (struct msgChar *)pdpvt->msg; - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - - pai->udf = FALSE; - if(pMsg->acknak == ACK) - { - sscanf(pMsg->data,pCmd->format,&countsData.data[0], - &countsData.data[1] ); - countsData.acknak = ACK; - } - else if(pMsg->acknak == NAK) - { - for(i=0;i<=1;i++) countsData.data[i] = UNDEFINED; - - strncpy(pdpvt->rsp, pdpvt->msg,(pCmd->rspLen)-1); - pdpvt->rsp[pCmd->rspLen] = '\0'; - - countsData.acknak = NAK; - setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); - } -} - -static int getInCounts(pdpvt,P1,P2,P3) - struct hvpsDpvt *pdpvt; - int P1; - int P2; - char **P3; -{ - struct aiRecord *pai= (struct aiRecord *)(pdpvt->precord); - struct msgMetered *pMsg = &countsData; - - pai->udf = FALSE; - pai->val = pMsg->data[P1]; - if(pMsg->acknak == NAK) setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); -} - -static int inSetpt(pdpvt,P1,P2,P3) - struct hvpsDpvt *pdpvt; - int P1; - int P2; - char **P3; -{ - short i; - float temp; - struct aiRecord *pai= (struct aiRecord *)(pdpvt->precord); - struct msgChar *pMsg = (struct msgChar *)pdpvt->msg; - struct hvpsGpibCmd *pCmd = &hvpsGpibCmds[pdpvt->parm]; - - - pai->udf = FALSE; - if(pMsg->acknak == ACK) - { - sscanf(pMsg->data,pCmd->format,&(pai->val)); - pCmd->sta = pOK; - } - else if(pMsg->acknak == NAK) - { - - strncpy(pdpvt->rsp, pdpvt->msg,(pCmd->rspLen)-1); - pdpvt->rsp[pCmd->rspLen] = '\0'; - - pCmd->sta = pdpvt->rsp; - setPvSevr(pai,MAJOR_ALARM,INVALID_ALARM); - } -} - - -static int setPvSevr(pPv, status,severity) -struct dbCommon *pPv; -short severity; -short status; -{ - if (severity > pPv->nsev) - { - pPv->nsta = status; - pPv->nsev = severity; - } -} diff --git a/src/devOpt/devXxSoftMsg.c b/src/devOpt/devXxSoftMsg.c deleted file mode 100644 index 16d1c9835..000000000 --- a/src/devOpt/devXxSoftMsg.c +++ /dev/null @@ -1,237 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* share/src/devOpt $Id$ */ -/* - * Author: John Winans - * Date: 04-13-92 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -static long BBinit(), BBreport(), VXinit(), VXreport(); -static msgParmBlock BBParmBlock, VXParmBlock; - -/****************************************************************************** - * - * DSET tables used for BITBUS -> RS-232 ports. - * - ******************************************************************************/ -msgDset devBBAiSoftMsg = { 6, { BBreport, BBinit, drvMsg_initAi, NULL, - drvMsg_procAi, NULL}, &BBParmBlock, &drvMsgAi}; -msgDset devBBAoSoftMsg = { 6, { NULL, NULL, drvMsg_initAo, NULL, - drvMsg_procAo, NULL}, &BBParmBlock, &drvMsgAo}; - -msgDset devBBBiSoftMsg = { 6, { NULL, NULL, drvMsg_initBi, NULL, - drvMsg_procBi, NULL}, &BBParmBlock, &drvMsgBi}; -msgDset devBBBoSoftMsg = { 6, { NULL, NULL, drvMsg_initBo, NULL, - drvMsg_procBo, NULL}, &BBParmBlock, &drvMsgBo}; - -msgDset devBBMiSoftMsg = { 6, { NULL, NULL, drvMsg_initMi, NULL, - drvMsg_procMi, NULL}, &BBParmBlock, &drvMsgMi}; -msgDset devBBMoSoftMsg = { 6, { NULL, NULL, drvMsg_initMo, NULL, - drvMsg_procMo, NULL}, &BBParmBlock, &drvMsgMo}; - -msgDset devBBLiSoftMsg = { 6, { NULL, NULL, drvMsg_initLi, NULL, - drvMsg_procLi, NULL}, &BBParmBlock, &drvMsgLi}; -msgDset devBBLoSoftMsg = { 6, { NULL, NULL, drvMsg_initLo, NULL, - drvMsg_procLo, NULL}, &BBParmBlock, &drvMsgLo}; - -msgDset devBBSiSoftMsg = { 6, { NULL, NULL, drvMsg_initSi, NULL, - drvMsg_procSi, NULL}, &BBParmBlock, &drvMsgSi}; -msgDset devBBSoSoftMsg = { 6, { NULL, NULL, drvMsg_initSo, NULL, - drvMsg_procSo, NULL}, &BBParmBlock, &drvMsgSo}; - -msgDset devBBWfSoftMsg = { 6, { NULL, NULL, drvMsg_initWf, NULL, - drvMsg_procWf, NULL}, &BBParmBlock, &drvMsgWf}; - -/****************************************************************************** - * - * DSET tables used for vxWorks tty ports. - * - ******************************************************************************/ -msgDset devVXAiSoftMsg = { 6, { VXreport, VXinit, drvMsg_initAi, NULL, - drvMsg_procAi, NULL}, &VXParmBlock, &drvMsgAi}; -msgDset devVXAoSoftMsg = { 6, { NULL, NULL, drvMsg_initAo, NULL, - drvMsg_procAo, NULL}, &VXParmBlock, &drvMsgAo}; - -msgDset devVXBiSoftMsg = { 6, { NULL, NULL, drvMsg_initBi, NULL, - drvMsg_procBi, NULL}, &VXParmBlock, &drvMsgBi}; -msgDset devVXBoSoftMsg = { 6, { NULL, NULL, drvMsg_initBo, NULL, - drvMsg_procBo, NULL}, &VXParmBlock, &drvMsgBo}; - -msgDset devVXMiSoftMsg = { 6, { NULL, NULL, drvMsg_initMi, NULL, - drvMsg_procMi, NULL}, &VXParmBlock, &drvMsgMi}; -msgDset devVXMoSoftMsg = { 6, { NULL, NULL, drvMsg_initMo, NULL, - drvMsg_procMo, NULL}, &VXParmBlock, &drvMsgMo}; - -msgDset devVXLiSoftMsg = { 6, { NULL, NULL, drvMsg_initLi, NULL, - drvMsg_procLi, NULL}, &VXParmBlock, &drvMsgLi}; -msgDset devVXLoSoftMsg = { 6, { NULL, NULL, drvMsg_initLo, NULL, - drvMsg_procLo, NULL}, &VXParmBlock, &drvMsgLo}; - -msgDset devVXSiSoftMsg = { 6, { NULL, NULL, drvMsg_initSi, NULL, - drvMsg_procSi, NULL}, &VXParmBlock, &drvMsgSi}; -msgDset devVXSoSoftMsg = { 6, { NULL, NULL, drvMsg_initSo, NULL, - drvMsg_procSo, NULL}, &VXParmBlock, &drvMsgSo}; - -msgDset devVXWfSoftMsg = { 6, { NULL, NULL, drvMsg_initWf, NULL, - drvMsg_procWf, NULL}, &VXParmBlock, &drvMsgWf}; - -int softMsgDebug = 0; - -static msgStrParm wrParms[] = { - { "Parm 0 write string!\n\r", -1}, - { "wrParm-1 raw write string\n\r", -1 }, - { "123456789012", -1 }, - { "1234567890123", -1 }, - { "12345678901234", -1}, -}; - -static msgFoParm foParms[] = { - { "Parm 1 Value is: %lf\n\r" }, - { "pArM 2 VaLuE iS: %lf\n\r" }, - { "longout value is %ld\n\r" } -}; - -static msgFiParm fiParms[] = { - { "%s %lf", 0, 50 }, - { "%lf", 0, 50 }, - { "%ld", 0, 50 }, -}; - -static msgCmd cmds[] = { -{&drvMsgAi, READ_NDLY, {MSG_OP_WRITE, &wrParms[0]}, {MSG_OP_FAI, &fiParms[0]}, NULL, -1}, -{&drvMsgAo, READ_NDLY, {MSG_OP_FAO, &foParms[0]}, {MSG_OP_NOP, NULL}, NULL, -1}, -{&drvMsgAi, READ_NDLY, {MSG_OP_WRITE, &wrParms[1]}, {MSG_OP_FAI, &fiParms[1]}, NULL, -1}, -{&drvMsgAo, READ_NDLY, {MSG_OP_FAO, &foParms[1]}, {MSG_OP_NOP, NULL}, NULL, -1}, -{&drvMsgLi, READ_NDLY, {MSG_OP_WRITE, &wrParms[1]}, {MSG_OP_FLI, &fiParms[2]}, NULL, -1}, -{&drvMsgLo, READ_NDLY, {MSG_OP_FLO, &foParms[2]}, {MSG_OP_NOP, NULL}, NULL, -1}, -{&drvMsgBo, READ_NDLY, {MSG_OP_WRITE, &wrParms[2]}, {MSG_OP_NOP, NULL}, NULL, -1}, -{&drvMsgBo, READ_NDLY, {MSG_OP_WRITE, &wrParms[3]}, {MSG_OP_NOP, NULL}, NULL, -1}, -{&drvMsgBo, READ_NDLY, {MSG_OP_WRITE, &wrParms[4]}, {MSG_OP_NOP, NULL}, NULL, -1}, -}; - -/****************************************************************************** - * - * The devTy232ParmBlock contains vxWorks tty-driver specific extensions to - * the msgParmBlock structure. - * - ******************************************************************************/ -/* For vxWorks tty ports */ -static devTy232ParmBlock parm232extension = { - 0, /* Time window */ - 60, /* DMA time limit */ - KILL_CRLF, /* loose the CRs and LFs */ - 0x0d, /* EOI character, always stop reading when I hit it */ - 9600, /* Baud rate to the machine at */ - OPT_7_BIT /* 7-bit transfers */ -}; - -/****************************************************************************** - * - * The drvBB232ParmBlock contains the bitbus->RS232 specific extensions to the - * msgParmBlock structure. - * - ******************************************************************************/ -static drvBB232ParmBlock parmBB232extension = { - 0, - 9600 -}; -/****************************************************************************** - * - * The parmBlock is used to define the relationship b/w the command table and - * the driverBlock. - * - ******************************************************************************/ - -/* For records requesting Bitbus->232 */ - -static msgParmBlock BBParmBlock = { - &softMsgDebug, - NULL, - cmds, - sizeof(cmds) / sizeof(msgCmd), - "softMsg", - &drvBB232Block, - drvMsg_xactWork, - &parmBB232extension -}; - -/* For records requesting vxWorks tty */ - -static msgParmBlock VXParmBlock = { - &softMsgDebug, - NULL, - cmds, - sizeof(cmds) / sizeof(msgCmd), - "softMsg", - &drv232Block, - drvMsg_xactWork, - &parm232extension -}; - -/****************************************************************************** - * - * These are used to add parameters to calls made to the init routines. - * - ******************************************************************************/ - -/* For records requesting Bitbus->232 */ - -static long -BBinit(parm) -int parm; -{ - return(drvMsg_initMsg(parm, &devBBAiSoftMsg)); -} -static long -BBreport() -{ - return(drvMsg_reportMsg(&devBBAiSoftMsg)); -} - -/* For records requesting vxWorks tty */ - -static long -VXinit(parm) -int parm; -{ - return(drvMsg_initMsg(parm, &devVXAiSoftMsg)); -} -static long -VXreport() -{ - return(drvMsg_reportMsg(&devVXAiSoftMsg)); -}