From 3c76d41b70ef8645c818462e3767e95fdcbff1db Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Fri, 17 May 2002 15:43:37 +0000 Subject: [PATCH] support special_linconv for ai and ao --- src/dev/camacDev/devAiCamac.c | 41 ++++++++++++++++----------- src/dev/camacDev/devAoCamac.c | 38 ++++++++++++------------- src/dev/camacDev/devBiCamac.c | 2 +- src/dev/camacDev/devBoCamac.c | 2 +- src/dev/camacDev/devCamac.h | 5 ++-- src/dev/camacDev/devLiCamac.c | 2 +- src/dev/camacDev/devLoCamac.c | 2 +- src/dev/camacDev/devMbbiCamac.c | 2 +- src/dev/camacDev/devMbbiDirectCamac.c | 2 +- src/dev/camacDev/devMbboCamac.c | 2 +- src/dev/camacDev/devMbboDirectCamac.c | 2 +- 11 files changed, 53 insertions(+), 47 deletions(-) diff --git a/src/dev/camacDev/devAiCamac.c b/src/dev/camacDev/devAiCamac.c index 5d55cbb10..8103970e1 100644 --- a/src/dev/camacDev/devAiCamac.c +++ b/src/dev/camacDev/devAiCamac.c @@ -32,6 +32,7 @@ static long init(); static long init_record(); static long read_ai(); +static long special_linconv(); struct { long number; @@ -48,11 +49,10 @@ struct { init_record, NULL, read_ai, - NULL}; + special_linconv}; -static long init(after) -int after; +static long init( int after) { #ifdef DEBUG_ON @@ -61,12 +61,10 @@ int after; return(0); } -static long init_record(pai) -struct aiRecord *pai; +static long init_record(struct aiRecord *pai) { struct camacio *pcamacio; struct dinfo *pcio; -int fsd; #ifdef DEBUG_ON if ( CDEBUG)printf("devAiCamac (init_record) Called.\n"); #endif @@ -74,7 +72,7 @@ int fsd; /* ai.inp must be a CAMAC_IO */ switch (pai->inp.type) { case (CAMAC_IO) : - pcio = (struct dinfo *)malloc(sizeof(struct dinfo)); + pcio = (struct dinfo *)calloc(1,sizeof(struct dinfo)); if (pcio == NULL) { #ifdef DEBUG_ON if ( CDEBUG)printf("devAiCamac (init_record): malloc failed.\n"); @@ -97,13 +95,13 @@ int fsd; return(DO_NOT_CONVERT); /* cdreg failed if ext is zero */ } - sscanf((char *)pcamacio->parm, "%i",&fsd); - if (fsd > 0) { - if (!(fsd & (fsd+1))) fsd++; /* camac card count should be 2's power */ - pai->eslo = (pai->eguf - pai->egul)/fsd; + sscanf((char *)pcamacio->parm, "%i",&pcio->fsd); + if (pcio->fsd > 0) { + if (!(pcio->fsd & (pcio->fsd+1))) pcio->fsd++; /* camac card count should be 2's power */ + pai->eslo = (pai->eguf - pai->egul)/pcio->fsd; } - for (pcio->mask=1; pcio->mask < fsd; pcio->mask=pcio->mask<<1); + for (pcio->mask=1; pcio->mask < pcio->fsd; pcio->mask=pcio->mask<<1); pcio->mask--; pcio->f = pcamacio->f; @@ -119,24 +117,33 @@ int fsd; return(0); } -static long read_ai(pai) -struct aiRecord *pai; +static long read_ai(struct aiRecord *pai) { -register struct dinfo *pcio; +struct dinfo *pcio; int q; pcio = (struct dinfo *)pai->dpvt; if(!(pcio->ext)) return(DO_NOT_CONVERT); #ifdef DEBUG_ON - if ( CDEBUG) printf("devAiCamac (read_ai): f=%d ext=%ld mask=%ld\n", + if ( CDEBUG) printf("devAiCamac (read_ai): f=%d ext=%d mask=%d\n", pcio->f, pcio->ext, pcio->mask); #endif q=0; - cfsa(pcio->f, pcio->ext, &(pai->rval), &q); + cfsa(pcio->f, pcio->ext, (int *)&(pai->rval), &q); pai->rval &= pcio->mask; if(q) return(CONVERT); else return(DO_NOT_CONVERT); } + +static long special_linconv(struct aiRecord *pai,int after) +{ + struct dinfo *pcio = (struct dinfo *)pai->dpvt; + + if(!after) return(0); + /* set linear conversion slope*/ + if(pcio->fsd!=0) pai->eslo = (pai->eguf - pai->egul)/pcio->fsd; + return(0); +} diff --git a/src/dev/camacDev/devAoCamac.c b/src/dev/camacDev/devAoCamac.c index 1ee320a43..b73151657 100644 --- a/src/dev/camacDev/devAoCamac.c +++ b/src/dev/camacDev/devAoCamac.c @@ -56,8 +56,7 @@ struct { write_ao, special_linconv}; -static long init(after) -int after; +static long init(int after) { #ifdef DEBUG_ON if ( CDEBUG)printf("devAoCamac (init) called, pass=%d\n", after); @@ -65,12 +64,10 @@ int after; return(0); } -static long init_record(pao) -struct aoRecord *pao; +static long init_record(struct aoRecord *pao) { struct camacio *pcamacio; struct dinfo *pcio; -int fsd; #ifdef DEBUG_ON if ( CDEBUG)printf("devAoCamac (init_record) called.\n"); @@ -79,7 +76,7 @@ int fsd; /* ao.out must be a CAMAC_IO */ switch (pao->out.type) { case (CAMAC_IO) : - pcio = (struct dinfo *)malloc(sizeof(struct dinfo)); + pcio = (struct dinfo *)calloc(1,sizeof(struct dinfo)); if (pcio == NULL) { #ifdef DEBUG_ON if ( CDEBUG)printf("devAoCamac (init_record): malloc failed.\n"); @@ -95,15 +92,15 @@ int fsd; cdreg(&(pcio->ext), pcamacio->b, pcamacio->c, pcamacio->n, pcamacio->a); if(!(pcio->ext)) return(DO_NOT_CONVERT); - sscanf((char *)pcamacio->parm, "%i",&fsd); + sscanf((char *)pcamacio->parm, "%i",&pcio->fsd); - /* fsd = (int)atoi((char *)pcamacio->parm); */ - if (fsd > 0) { - if (!(fsd & (fsd+1))) fsd++; - pao->eslo=(pao->eguf - pao->egul)/fsd; + /* pcio->fsd = (int)atoi((char *)pcamacio->parm); */ + if (pcio->fsd > 0) { + if (!(pcio->fsd & (pcio->fsd+1))) pcio->fsd++; + pao->eslo=(pao->eguf - pao->egul)/pcio->fsd; } - for (pcio->mask=1; pcio->maskmask=pcio->mask<<1); + for (pcio->mask=1; pcio->maskfsd; pcio->mask=pcio->mask<<1); pcio->mask--; pcio->f = pcamacio->f; @@ -120,10 +117,9 @@ int fsd; return(0); } -static long write_ao(pao) -struct aoRecord *pao; +static long write_ao(struct aoRecord *pao) { -register struct dinfo *pcio; +struct dinfo *pcio; int q; pcio = (struct dinfo *)pao->dpvt; @@ -131,7 +127,7 @@ int q; pao->rval &= pcio->mask; q = 0; - cfsa(pcio->f, pcio->ext, &(pao->rval), &q); + cfsa(pcio->f, pcio->ext, (int *)&(pao->rval), &q); #ifdef DEBUG_ON if ( CDEBUG)printf("devAoCamac (write_ao): f=%d ext=%ld mask=%ld value=%d\n", pcio->f, pcio->ext, pcio->mask, pao->rval); @@ -140,10 +136,12 @@ int q; else return(DO_NOT_CONVERT); } -static long special_linconv(pao,after) -struct aoRecord *pao; -int after; +static long special_linconv(struct aoRecord *pao, int after) { - /* Stub routine, added for consistency. */ + struct dinfo *pcio = (struct dinfo *)pao->dpvt; + + if(!after) return(0); + /* set linear conversion slope*/ + if(pcio->fsd!=0) pao->eslo = (pao->eguf - pao->egul)/pcio->fsd; return(0); } diff --git a/src/dev/camacDev/devBiCamac.c b/src/dev/camacDev/devBiCamac.c index cf6916cdc..19d248a48 100644 --- a/src/dev/camacDev/devBiCamac.c +++ b/src/dev/camacDev/devBiCamac.c @@ -123,7 +123,7 @@ int q; pcio->f, pcio->ext, pbi->mask); #endif q=0; - cfsa(pcio->f, pcio->ext, &(pbi->rval), &q); + cfsa(pcio->f, pcio->ext, (int *)&(pbi->rval), &q); pbi->rval &= pbi->mask; if(q) return(CONVERT); diff --git a/src/dev/camacDev/devBoCamac.c b/src/dev/camacDev/devBoCamac.c index c2a010b7d..a4a1cc5da 100644 --- a/src/dev/camacDev/devBoCamac.c +++ b/src/dev/camacDev/devBoCamac.c @@ -124,7 +124,7 @@ int q; pbo->rval &= pbo->mask; q = 0; - cfsa(pcio->f, pcio->ext, &(pbo->rval), &q); + cfsa(pcio->f, pcio->ext, (int *)&(pbo->rval), &q); #ifdef DEBUG_ON if ( CDEBUG)printf("devBoCamac (write_bo): f=%d ext=%ld mask=%ld value=%d\n", pcio->f, pcio->ext, pbo->mask, pbo->rval); diff --git a/src/dev/camacDev/devCamac.h b/src/dev/camacDev/devCamac.h index 270df1609..a64f1e203 100644 --- a/src/dev/camacDev/devCamac.h +++ b/src/dev/camacDev/devCamac.h @@ -43,6 +43,7 @@ static int sizeofTypes[] = {0,1,1,2,2,4,4,4,8,2}; struct dinfo{ short f; - long ext; - long mask; + int ext; + int mask; + int fsd; /*full scale for ai and ao*/ }; diff --git a/src/dev/camacDev/devLiCamac.c b/src/dev/camacDev/devLiCamac.c index 677cbf42c..5f9083564 100644 --- a/src/dev/camacDev/devLiCamac.c +++ b/src/dev/camacDev/devLiCamac.c @@ -127,7 +127,7 @@ int q; pcio->f, pcio->ext, pcio->mask); #endif q=0; - cfsa(pcio->f, pcio->ext, &(plongin->val), &q); + cfsa(pcio->f, pcio->ext, (int *)&(plongin->val), &q); plongin->val &= pcio->mask; if(q) return(CONVERT); diff --git a/src/dev/camacDev/devLoCamac.c b/src/dev/camacDev/devLoCamac.c index d2511f1b4..97d1d39a2 100644 --- a/src/dev/camacDev/devLoCamac.c +++ b/src/dev/camacDev/devLoCamac.c @@ -127,7 +127,7 @@ int q; plongout->val &= pcio->mask; q = 0; - cfsa(pcio->f, pcio->ext, &(plongout->val), &q); + cfsa(pcio->f, pcio->ext, (int *)&(plongout->val), &q); #ifdef DEBUG_ON if ( CDEBUG)printf("devLoCamac (write_longout): f=%d ext=%ld mask=%ld value=%d\n", pcio->f, pcio->ext, pcio->mask, plongout->val); diff --git a/src/dev/camacDev/devMbbiCamac.c b/src/dev/camacDev/devMbbiCamac.c index 5c5389f70..da7eaea3f 100644 --- a/src/dev/camacDev/devMbbiCamac.c +++ b/src/dev/camacDev/devMbbiCamac.c @@ -124,7 +124,7 @@ unsigned long val; pcio->f, pcio->ext, pmbbi->mask); #endif q=0; - cfsa(pcio->f, pcio->ext, &val, &q); + cfsa(pcio->f, pcio->ext, (int *)&val, &q); if(q) { pmbbi->rval = val&pmbbi->mask; diff --git a/src/dev/camacDev/devMbbiDirectCamac.c b/src/dev/camacDev/devMbbiDirectCamac.c index 374ee26c4..82b5ce042 100644 --- a/src/dev/camacDev/devMbbiDirectCamac.c +++ b/src/dev/camacDev/devMbbiDirectCamac.c @@ -129,7 +129,7 @@ int q; pcio->f, pcio->ext, pcio->mask); #endif q=0; - cfsa(pcio->f, pcio->ext, &(pmbbidirect->rval), &q); + cfsa(pcio->f, pcio->ext, (int *)&(pmbbidirect->rval), &q); pmbbidirect->rval &= pcio->mask; if(q) return(CONVERT); diff --git a/src/dev/camacDev/devMbboCamac.c b/src/dev/camacDev/devMbboCamac.c index b3f0a6abe..96ed14434 100644 --- a/src/dev/camacDev/devMbboCamac.c +++ b/src/dev/camacDev/devMbboCamac.c @@ -124,7 +124,7 @@ int q; if(!(pcio->ext)) return(DO_NOT_CONVERT); q = 0; - cfsa(pcio->f, pcio->ext, &(pmbbo->rval), &q); + cfsa(pcio->f, pcio->ext, (int *)&(pmbbo->rval), &q); #ifdef DEBUG_ON if ( CDEBUG)printf("devMbboCamac (write_mbbo): f=%d ext=%ld mask=%ld value=%d\n", pcio->f, pcio->ext, pcio->mask, pmbbo->val); diff --git a/src/dev/camacDev/devMbboDirectCamac.c b/src/dev/camacDev/devMbboDirectCamac.c index 8853b7be0..474c84dcf 100644 --- a/src/dev/camacDev/devMbboDirectCamac.c +++ b/src/dev/camacDev/devMbboDirectCamac.c @@ -126,7 +126,7 @@ int q; if(!(pcio->ext)) return(DO_NOT_CONVERT); q = 0; - cfsa(pcio->f, pcio->ext, &(pmbbodirect->rval), &q); + cfsa(pcio->f, pcio->ext, (int *)&(pmbbodirect->rval), &q); #ifdef DEBUG_ON if(CDEBUG)printf("devMbboDirectCamac (write_mbbodirect): f=%d ext=%ld mask=%ld value=%d\n", pcio->f, pcio->ext, pcio->mask, pmbbodirect->rval);