From 946c3c7886fa2e652e9105dc0fcd4dbe79b060db Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 23 Apr 1998 17:22:58 +0000 Subject: [PATCH] make it a little more robust against ca problems --- src/as/asCa.c | 67 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/src/as/asCa.c b/src/as/asCa.c index d30debe77..96bd961f3 100644 --- a/src/as/asCa.c +++ b/src/as/asCa.c @@ -72,13 +72,29 @@ LOCAL void connectCallback(struct connection_handler_args arg) LOCAL void eventCallback(struct event_handler_args arg) { - ASGINP *pasginp = (ASGINP *)arg.usr; - ASG *pasg = pasginp->pasg; - CAPVT *pcapvt = (CAPVT *)pasginp->capvt; - chid chid = pcapvt->chid; - int caStatus = arg.status; - READONLY struct dbr_sts_double *pdata = arg.dbr; + int caStatus = arg.status; + chid chid = arg.chid; + ASGINP *pasginp = (ASGINP *)arg.usr; + ASG *pasg; + CAPVT *pcapvt; + READONLY struct dbr_sts_double *pdata; + if(caStatus!=ECA_NORMAL) { + if(chid) { + epicsPrintf("asCa: eventCallback error %s channel %s\n", + ca_message(caStatus),ca_name(chid)); + } else { + epicsPrintf("asCa: eventCallback error %s chid is null\n", + ca_message(caStatus)); + } + return; + } + pasg = pasginp->pasg; + pcapvt = (CAPVT *)pasginp->capvt; + if(chid!=pcapvt->chid) { + epicsPrintf("asCa: eventCallback error pcapvt->chid != arg.chid\n"); + return; + } if(ca_state(chid)!=cs_conn || !ca_read_access(chid)) { if(!(pasg->inpBad & (1<inpIndex))) { /*was good so lets make it bad*/ @@ -86,31 +102,28 @@ LOCAL void eventCallback(struct event_handler_args arg) if(!caInitializing) asComputeAsg(pasg); if(asCaDebug) { printf("as eventCallback %s inpBad ca_state %d" - " ca_read_access %d\n", + " ca_read_access %d\n", ca_name(chid),ca_state(chid),ca_read_access(chid)); } } - } else { - if(caStatus!=ECA_NORMAL) { - epicsPrintf("asCa: eventCallback error %s\n",ca_message(caStatus)); - } else { - pcapvt->rtndata = *pdata; /*structure copy*/ - if(pdata->severity==INVALID_ALARM) { - pasg->inpBad |= (1<inpIndex); - if(asCaDebug) - printf("as eventCallback %s inpBad because INVALID_ALARM\n", - ca_name(chid)); - } else { - pasg->inpBad &= ~((1<inpIndex)); - pasg->pavalue[pasginp->inpIndex] = pdata->value; - if(asCaDebug) - printf("as eventCallback %s inpGood data %f\n", - ca_name(chid),pdata->value); - } - pasg->inpChanged |= (1<inpIndex); - if(!caInitializing) asComputeAsg(pasg); - } + return; } + pdata = arg.dbr; + pcapvt->rtndata = *pdata; /*structure copy*/ + if(pdata->severity==INVALID_ALARM) { + pasg->inpBad |= (1<inpIndex); + if(asCaDebug) + printf("as eventCallback %s inpBad because INVALID_ALARM\n", + ca_name(chid)); + } else { + pasg->inpBad &= ~((1<inpIndex)); + pasg->pavalue[pasginp->inpIndex] = pdata->value; + if(asCaDebug) + printf("as eventCallback %s inpGood data %f\n", + ca_name(chid),pdata->value); + } + pasg->inpChanged |= (1<inpIndex); + if(!caInitializing) asComputeAsg(pasg); } LOCAL void asCaTask(void)