Changes for APS release 3.1.0

This commit is contained in:
Marty Kraimer
1991-10-03 15:42:37 +00:00
parent 2678ca8318
commit d1d7e01085
7 changed files with 398 additions and 316 deletions

View File

@@ -1,6 +1,5 @@
/* dbAccess.c */
/* share/src/db $Id$ */
/*
* Original Author: Bob Dalesio
* Current Author: Marty Kraimer
@@ -30,7 +29,11 @@
* Modification Log:
* -----------------
* .01 07-26-91 mrk Allow choices to be retrieved as numeric
* .02 08-13-91 mrk Support db_field_log for dbGetField
* .03 09-30-91 mrk Support for TPRO and DISP
*/
/* This is a major revision of the original implementation of database access.*/
/* Global Database Access Routines
*
@@ -70,12 +73,13 @@
* caddr_t pbuffer; addr of input data
* long nRequest;
*
* dbGetField(paddr,dbrType,pbuffer,options,nRequest)
* dbGetField(paddr,dbrType,pbuffer,options,nRequest,pfl)
* struct dbAddr *paddr;
* short dbrType; DBR_xxx
* caddr_t pbuffer; addr of returned data
* long *options; addr of options
* long *nRequest; addr of number of elements
* struct db_field_log pfl; addr of field_log
*
* dbPutField(paddr,dbrType,pbuffer,nRequest)
* struct dbAddr *paddr;
@@ -107,6 +111,7 @@
#include <dbRecDes.h>
#include <dbRecType.h>
#include <dbRecords.h>
#include <db_field_log.h>
#include <errMdef.h>
#include <link.h>
#include <recSup.h>
@@ -202,28 +207,37 @@ long dbProcess(paddr)
{
struct rset *prset;
struct dbCommon *precord=(struct dbCommon *)(paddr->precord);
long status;
unsigned char tpro=precord->tpro;
short lset = precord->lset;
long status = 0;
static char trace=0;
static int trace_lset=0;
int set_trace=FALSE;
if (jba_debug)
printf ("-------------------------%s dbProcess entered -----------------\n",precord->name);
/* check for trace processing*/
if(tpro) {
if(vxTas(&trace)) {
trace = TRUE;
trace_lset = lset;
set_trace = TRUE;
}
}
/* If already active dont process */
if(precord->pact) {
struct rset *prset;
struct valueDes valueDes;
if (jba_debug)
printf ("-------------------------%s already active -----------------\n",precord->name);
if(trace && trace_lset==lset)
logMsg("active: %s\n",precord->name);
/* raise scan alarm after MAX_LOCK times */
if(precord->stat==SCAN_ALARM) return(0);
if(precord->lcnt++ !=MAX_LOCK) return(0);
if(precord->stat==SCAN_ALARM) goto all_done;
if(precord->lcnt++ !=MAX_LOCK) goto all_done;
precord->sevr = MAJOR_ALARM;
precord->stat = SCAN_ALARM;
precord->nsev = 0;
precord->nsta = 0;
/* anyone waiting for an event on this record?*/
if(precord->mlis.count==0) return(0);
if(precord->mlis.count==0) goto all_done;
db_post_events(precord,&precord->stat,DBE_VALUE);
db_post_events(precord,&precord->sevr,DBE_VALUE);
prset=GET_PRSET(paddr->record_type);
@@ -231,45 +245,45 @@ long dbProcess(paddr)
(*prset->get_value)(precord,&valueDes);
db_post_events(precord,valueDes.pvalue,DBE_VALUE|DBE_ALARM);
}
return(0);
goto all_done;
} else precord->lcnt=0;
/* get the scan disable link if defined*/
if(precord->sdis.type == DB_LINK) {
long options=0;
long nRequest=1;
(status = dbGetLink(&precord->sdis.value.db_link,precord,
DBR_SHORT,(caddr_t)(&(precord->disa)),&options,&nRequest));
if(!RTN_SUCCESS(status)) {
recGblDbaddrError(status,paddr,"dbProcess");
return(status);
}
status = dbGetLink(&precord->sdis.value.db_link,precord,
DBR_SHORT,(caddr_t)(&(precord->disa)),&options,&nRequest);
if(!RTN_SUCCESS(status)) recGblDbaddrError(status,paddr,"dbProcess");
}
/* if disabled just return success */
if(precord->disa == precord->disv) {
if (jba_debug)
printf ("-------------------------%s is disabled -----------------\n",precord->name);
return(0);
if(trace && trace_lset==lset)
logMsg("disabled: %s\n",precord->name);
goto all_done;
}
/* locate record processing routine */
if(!(prset=GET_PRSET(paddr->record_type)) || !(prset->process)) {
precord->pact=1;/*set pact TRUE so error is issued only once*/
recGblRecSupError(S_db_noRSET,paddr,"dbProcess","process");
return(S_db_noRSET);
status = S_db_noRSET;
if(trace && trace_lset==lset)
logMsg("failure: %s\n",precord->name);
goto all_done;
}
/* process record */
status = (*prset->process)(paddr);
if(trace && trace_lset==lset)
logMsg("processed: %s\n",precord->name);
if (jba_debug)
printf ("-------------------------%s processed ------------------------\n",precord->name);
all_done:
if(set_trace) {
trace_lset = 0;
trace = 0;
}
return(status);
}
@@ -376,7 +390,7 @@ long dbGetLink(pdblink,pdest,dbrType,pbuffer,options,nRequest)
}
}
status= dbGetField(paddr,dbrType,pbuffer,options,nRequest);
status= dbGetField(paddr,dbrType,pbuffer,options,nRequest,NULL);
if(status) recGblRecordError(status,pdest,"dbGetLink");
}
@@ -414,6 +428,12 @@ long dbPutField(paddr,dbrType,pbuffer,nRequest)
long status;
struct fldDes *pfldDes=(struct fldDes *)(paddr->pfldDes);
/*check for putField disabled*/
if(precord->disp) {
struct dbCommon *precord = (struct dbCommon *)(paddr->precord);
if((caddr_t)(&precord->disp) != paddr->pfield) return(0);
}
dbScanLock(paddr->precord);
status=dbPut(paddr,dbrType,pbuffer,nRequest);
if(status) recGblDbaddrError(status,paddr,"dbPutField");
@@ -2117,7 +2137,7 @@ long offset;
else
status=S_db_precision;
if(!RTN_SUCCESS(status)) {
recGblRecSupError(status,paddr,"db_get_field","get_precision");
recGblRecSupError(status,paddr,"dbGetField","get_precision");
return(status);
}
@@ -2357,7 +2377,7 @@ long offset;
else
status=S_db_precision;
if(!RTN_SUCCESS(status)) {
recGblRecSupError(status,paddr,"db_get_field","get_precision");
recGblRecSupError(status,paddr,"dbGetField","get_precision");
return(status);
}
@@ -2593,7 +2613,7 @@ long offset;
if((prset=GET_PRSET(record_type)) && (prset->get_enum_str))
return( (*prset->get_enum_str)(paddr,pbuffer) );
status=S_db_noRSET;
recGblRecSupError(status,paddr,"db_get_field","get_enum_str");
recGblRecSupError(status,paddr,"dbGetField","get_enum_str");
return(S_db_badDbrtype);
}
@@ -2957,12 +2977,13 @@ void get_graphics();
void get_control();
void get_alarm();
long dbGetField(paddr,dbrType,pbuffer,options,nRequest)
long dbGetField(paddr,dbrType,pbuffer,options,nRequest,pfl)
struct dbAddr *paddr;
short dbrType;
caddr_t pbuffer;
long *options;
long *nRequest;
db_field_log *pfl;
{
long no_elements=paddr->no_elements;
long offset;
@@ -2981,8 +3002,13 @@ long *nRequest;
/* Process options */
pcommon = (struct dbCommon *)(paddr->precord);
if( (*options) & DBR_STATUS ) {
*((unsigned short *)pbuffer)++ = pcommon->stat;
*((unsigned short *)pbuffer)++ = pcommon->sevr;
if(pfl!=NULL) {
*((unsigned short *)pbuffer)++ = pfl->stat;
*((unsigned short *)pbuffer)++ = pfl->sevr;
} else {
*((unsigned short *)pbuffer)++ = pcommon->stat;
*((unsigned short *)pbuffer)++ = pcommon->sevr;
}
perr_status=((long *)pbuffer)++;
*perr_status = 0;
}
@@ -3009,8 +3035,13 @@ long *nRequest;
pbuffer += dbr_precision_size;
}
if( (*options) & DBR_TIME ) {
*((unsigned long *)pbuffer)++ = pcommon->time.secPastEpoch;
*((unsigned long *)pbuffer)++ = pcommon->time.nsec;
if(pfl!=NULL) {
*((unsigned long *)pbuffer)++ = pfl->time.secPastEpoch;
*((unsigned long *)pbuffer)++ = pfl->time.nsec;
} else {
*((unsigned long *)pbuffer)++ = pcommon->time.secPastEpoch;
*((unsigned long *)pbuffer)++ = pcommon->time.nsec;
}
}
if( (*options) & DBR_ENUM_STRS ) get_enum_strs(paddr,&pbuffer,prset,options);
if( (*options) & (DBR_GR_LONG|DBR_GR_DOUBLE ))
@@ -3049,7 +3080,18 @@ GET_DATA:
return(S_db_badDbrtype);
}
/* convert database field to buffer type and place it in the buffer */
status=(*pconvert_routine)(paddr,pbuffer,*nRequest,no_elements,offset);
if(pfl!=NULL) {
struct dbAddr localAddr;
bcopy(paddr,&localAddr,sizeof(localAddr));
/*Use longest field size*/
localAddr.pfield = (char *)&pfl->field;
status=(*pconvert_routine)(&localAddr,pbuffer,*nRequest,
no_elements,offset);
} else {
status=(*pconvert_routine)(paddr,pbuffer,*nRequest,
no_elements,offset);
}
if(perr_status) *perr_status = status;
return(status);
}

View File

@@ -1,6 +1,5 @@
/* DB_EVENT.C */
/* share/src/db $Id$ */
/* routines for scheduling events to lower priority tasks via the RT kernel */
/*
* Author: Jeffrey O. Hill
@@ -28,10 +27,6 @@
* Argonne National Laboratory
*
* NOTES:
* 01 I have assumed that all C compilers align unions so that
* a pointer to a field in the union is also a pointer all
* of the other fields in the union. This has been verified
* on our current compiler and several other C compilers.
*
* Modification Log:
* -----------------
@@ -53,6 +48,9 @@
* joh 08 031590 improved flush wait in db_cancel_event()
* joh 09 112790 added time stamp, alarm, and status logging
* joh 10 112790 source cleanup
* ??? 11 ????91 anl turned off paddr sanity checking
* joh 12 082091 db_event_get_field() comented out
* joh 13 091191 updated for v5 vxWorks
*/
#include <vxWorks.h>
@@ -60,6 +58,7 @@
#include <wdLib.h>
#include <lstLib.h>
#include <semLib.h>
#include <tsDefs.h>
#include <dbDefs.h>
#include <db_access.h>
@@ -163,7 +162,7 @@ struct event_user{
int taskpri; /* event handler task pri */
char pendlck; /* Only one task can pend */
SEMAPHORE pendsem; /* Wait while empty */
SEM_ID ppendsem; /* Wait while empty */
unsigned char pendexit; /* exit pend task */
unsigned short queovr; /* event que overflow count */
@@ -270,6 +269,15 @@ struct event_user
evuser->firstque.evuser = evuser;
FASTLOCKINIT(&(evuser->firstque.writelock));
# ifdef V5_vxWorks
evuser->ppendsem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
# else
evuser->ppendsem = semCreate();
# endif
if(!evuser->ppendsem){
free(evuser);
return NULL;
}
return evuser;
}
@@ -277,7 +285,10 @@ struct event_user
/*
* DB_CLOSE_EVENTS()
*
*
* evuser block and additional event queues
* deallocated when the event thread terminates
* itself
*
*/
db_close_events(evuser)
@@ -295,7 +306,7 @@ register struct event_user *evuser;
evuser->pendexit = TRUE;
/* notify the waiting task */
semGive(&evuser->pendsem);
semGive(evuser->ppendsem);
return OK;
@@ -316,64 +327,6 @@ db_sizeof_event_block()
}
/*
* DB_EVENT_GET_FIELD()
*
*
*/
db_event_get_field(paddr, buffer_type, pbuffer, no_elements, pfl)
struct db_addr *paddr;
short buffer_type;
char *pbuffer;
unsigned short no_elements;
db_field_log *pfl;
{
int status;
char * pfield_save;
if(pfl==NULL) return(db_get_field(paddr,buffer_type,pbuffer,no_elements));
pfield_save = paddr->pfield;
if(buffer_type>=DBR_INT && buffer_type<=DBR_DOUBLE) {
if(pfl!=NULL)paddr->pfield = (char *)(&pfl->field);
status = db_get_field(paddr,buffer_type,pbuffer,no_elements);
paddr->pfield = pfield_save;
return(status);
}
if(buffer_type>=DBR_STS_INT && buffer_type<=DBR_STS_DOUBLE) {
struct dbr_sts_int *ps = (struct dbr_sts_int *)pbuffer;
short request_type = buffer_type - DBR_STS_STRING;
if(pfl!=NULL) {
ps->status = pfl->stat;
ps->severity = pfl->sevr;
paddr->pfield = (char *)(&pfl->field);
status=db_get_field(paddr,request_type,&ps->value,no_elements);
paddr->pfield = pfield_save;
return(status);
}
return(db_get_field(paddr,buffer_type,pbuffer,no_elements));
}
if(buffer_type>=DBR_TIME_INT && buffer_type<=DBR_TIME_DOUBLE) {
struct dbr_time_short *ps = (struct dbr_time_short *)pbuffer;
short request_type = buffer_type - DBR_TIME_STRING;
if(pfl!=NULL) {
ps->status = pfl->stat;
ps->severity = pfl->sevr;
ps->stamp = pfl->time;
paddr->pfield = (char *)(&pfl->field);
status=db_get_field(paddr,request_type,&ps->value,no_elements);
paddr->pfield = pfield_save;
return(status);
}
return(db_get_field(paddr,buffer_type,pbuffer,no_elements));
}
return(db_get_field(paddr,buffer_type,pbuffer,no_elements));
}
/*
* DB_ADD_EVENT()
@@ -415,12 +368,13 @@ register struct event_block *pevent; /* ptr to event blk (not required) */
if(!ev_que->nextque){
tmp_que = (struct event_que *)
calloc(1, sizeof(*tmp_que));
if(!tmp_que)
return ERROR;
tmp_que->evuser = evuser;
FASTLOCKINIT(&(tmp_que->writelock));
ev_que->nextque = tmp_que;
ev_que = tmp_que;
FASTLOCKINIT(&(ev_que->writelock));
break;
}
ev_que = ev_que->nextque;
@@ -449,7 +403,7 @@ register struct event_block *pevent; /* ptr to event blk (not required) */
if( paddr->no_elements == 1 &&
dbr_size[paddr->field_type] <= sizeof(union native_value))
pevent->valque = TRUE;
else
else
pevent->valque = FALSE;
LOCKREC(precord);
@@ -499,23 +453,32 @@ register struct event_block *pevent;
* flush without polling.
*/
if(pevent->npend){
struct event_block flush_event;
SEMAPHORE flush_sem;
void wake_cancel();
SEM_ID pflush_sem;
semInit(&flush_sem);
# ifdef V5_vxWorks
pflush_sem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
# else
pflush_sem = semCreate();
# endif
flush_event = *pevent;
flush_event.user_sub = wake_cancel;
flush_event.user_arg = &flush_sem;
flush_event.npend = 0;
if(pflush_sem){
struct event_block flush_event;
if(db_post_single_event(&flush_event)==OK)
semTake(&flush_sem);
flush_event = *pevent;
flush_event.user_sub = wake_cancel;
flush_event.user_arg = pflush_sem;
flush_event.npend = 0;
if(db_post_single_event(&flush_event)==OK){
semTake(pflush_sem, sysClkRateGet()*10);
}
semDelete(pflush_sem);
}
/* insurance- incase the event could not be queued */
while(pevent->npend)
taskDelay(10);
taskDelay(sysClkRateGet());
}
/*
@@ -533,10 +496,10 @@ register struct event_block *pevent;
* a very short routine to inform a db_clear thread that the deleted event
* has been flushed
*/
static void wake_cancel(sem)
SEMAPHORE *sem;
static void wake_cancel(psem)
SEM_ID psem;
{
semGive(sem);
semGive(psem);
}
@@ -602,7 +565,7 @@ register struct event_block *pevent;
}
/* notify the event handler */
semGive(&ev_que->evuser->pendsem);
semGive(ev_que->evuser->ppendsem);
ev_que->putix = RNGINC(putix);
success = TRUE;
}
@@ -680,7 +643,7 @@ register unsigned int select;
}
/* notify the event handler */
semGive(&ev_que->evuser->pendsem);
semGive(ev_que->evuser->ppendsem);
ev_que->putix = RNGINC(putix);
}
@@ -767,7 +730,11 @@ register int init_func_arg;
* routine at a time
*/
do{
semTake(&evuser->pendsem);
# ifdef V5_vxWorks
semTake(evuser->ppendsem, WAIT_FOREVER);
# else
semTake(evuser->ppendsem);
# endif
for( ev_que= &evuser->firstque;
ev_que;
@@ -794,19 +761,24 @@ register int init_func_arg;
evuser->pendlck = FALSE;
if(FASTLOCKFREE(&evuser->firstque.writelock)<0)
logMsg("evtsk: fast lock free fail 1\n");
/* joh- added this code to free additional event queues */
{
struct event_que *nextque;
for( ev_que = evuser->firstque.nextque;
ev_que;
ev_que = nextque){
ev_que = evuser->firstque.nextque;
while(ev_que){
nextque = ev_que->nextque;
if(FASTLOCKFREE(&ev_que->writelock)<0)
logMsg("evtsk: fast lock free fail 2\n");
if(free(ev_que))
logMsg("evtsk: sub queue free fail\n");
}
ev_que = nextque;
}
}
/* end added code */
if(free(evuser))
logMsg("evtsk: evuser free fail\n");

View File

@@ -1,6 +1,5 @@
/* dbScan.c */
/* share/src/db $Id$ */
/* tasks and subroutines to scan the database */
/*
* Author: Bob Dalesio
@@ -57,6 +56,7 @@
* intr_event_poster to io_scanner_wakeup
* .16 09-14-90 mrk changed for new record/device support
* .17 10-24-90 mrk replaced momentary task by general purpose callback task
* .18 09-30-91 mrk added intLock to callbackRequest
*/
/*
@@ -659,7 +659,15 @@ callbackTask(){
callbackRequest(pcallback)
struct callback *pcallback;
{
rngBufPut(callbackQ,&pcallback,sizeof(pcallback));
int priority = pcallback->priority;
int lockKey;
int nput;
/* multiple writers are possible so block interrupts*/
lockKey = intLock();
nput = rngBufPut(callbackQ,&pcallback,sizeof(pcallback));
intUnLock(lockKey);
if(nput!=sizeof(pcallback)) logMsg("callbackRequest ring buffer full");
semGive(&callbackSem);
}

View File

@@ -1,6 +1,5 @@
/* dbTest.c */
/* share/src/db $Id$ */
/* database access test subroutines */
/*
* Original Author: Bob Dalesio
@@ -30,7 +29,7 @@
*
* Modification Log:
* -----------------
* .01 mm-dd-yy iii Comment
* .01 08-13-91 mrk Added extra NULL arg to dbGetField calls
*/
/* Global Database Test Routines - All can be invoked via vxWorks shell
@@ -190,11 +189,11 @@ long dbgf(pname) /* get field value*/
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
if(addr.dbr_field_type==DBR_ENUM) {
status=dbGetField(&addr,DBR_STRING,pbuffer,&options,&no_elements);
status=dbGetField(&addr,DBR_STRING,pbuffer,&options,&no_elements,NULL);
printBuffer(status,DBR_STRING,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
else {
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,&options,&no_elements);
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
pmsg[0] = '\0';
@@ -336,49 +335,49 @@ long dbtgf(pname) /* test all options for dbGetField */
ret_options=req_options;
no_elements=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&ret_options,&no_elements);
&ret_options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer, req_options,ret_options,no_elements,pMsgBuff,tab_size);
/* Now try all request types */
ret_options=0;
dbr_type=DBR_STRING;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/MAX_STRING_SIZE));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_CHAR;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(char)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_UCHAR;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(unsigned char)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_SHORT;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(short)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_USHORT;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(unsigned short)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_LONG;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(long)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_ULONG;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(unsigned long)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_FLOAT;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(float)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_DOUBLE;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(double)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
dbr_type=DBR_ENUM;
no_elements=MIN(addr.no_elements,((sizeof(buffer))/sizeof(unsigned short)));
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements);
status=dbGetField(&addr,dbr_type,pbuffer,&ret_options,&no_elements,NULL);
printBuffer(status,dbr_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
pmsg[0] = '\0';
dbpr_msgOut(pMsgBuff, tab_size);
@@ -419,7 +418,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
/* DBR_CHAR */
@@ -432,7 +431,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_CHAR\n");
@@ -446,7 +445,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_UCHAR\n");
@@ -459,7 +458,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_SHORT\n");
@@ -472,7 +471,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_USHORT\n");
@@ -485,7 +484,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_LONG\n");
@@ -498,7 +497,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_ULONG\n");
@@ -511,7 +510,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_FLOAT\n");
@@ -524,7 +523,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_DOUBLE\n");
@@ -537,7 +536,7 @@ long dbtpf(pname,pvalue)/* test all options for dbPutField */
no_elements=MIN(addr.no_elements,((sizeof(buffer))/addr.field_size));
options=0;
status=dbGetField(&addr,addr.dbr_field_type,pbuffer,
&options,&no_elements);
&options,&no_elements,NULL);
printBuffer(status,addr.dbr_field_type,pbuffer,0L,0L,no_elements,pMsgBuff,tab_size);
}
} else printf("sscanf failed for DBR_SHORT\n");
@@ -1166,7 +1165,7 @@ static int dbpr_report(pname, paddr, interest_level, pMsgBuff, tab_size)
options = 0;
nRequest = MIN(pLaddr->no_elements,((sizeof(buffer))/pLaddr->field_size));
status = dbGetField(&Laddr, Laddr.dbr_field_type, pbuffer,
&options, &nRequest);
&options, &nRequest,NULL);
printBuffer(status, Laddr.dbr_field_type, pbuffer,
0L, 0L, nRequest, pMsgBuff, tab_size);
tab_size = sv_tab_size;

View File

@@ -1,6 +1,5 @@
/* db_access.c */
/* share/src/db $Id$ */
/* db_access.c - Interface between old database access and new */
/*
* Author: Bob Dalesio
@@ -31,6 +30,7 @@
* -----------------
* .01 06-25-91 joh inserted the RISC aligned db_access.h structures
* .02 08-06-91 mrk Make extra values 0
* .03 08-13-91 mrk Add pfl argument to dbGetField calls
*/
@@ -531,6 +531,7 @@ new_alarm(){
* see DBR_ defines in db_access.h
* pbuffer return buffer
* no_elements number of elements
* caddr_t pfl;
* returns
* 0 successful
* -1 failed
@@ -575,11 +576,12 @@ db_name_to_addr(pname,paddr)
typedef char DBSTRING[MAX_STRING_SIZE];
db_get_field(paddr,buffer_type,pbuffer,no_elements)
db_get_field(paddr,buffer_type,pbuffer,no_elements,pfl)
struct dbAddr *paddr;
short buffer_type;
char *pbuffer;
unsigned short no_elements;
caddr_t pfl;
{
long status;
long options;
@@ -596,7 +598,8 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_STRING,pbuffer,&options,&nRequest);
status = dbGetField(paddr,DBR_STRING,pbuffer,&options,&nRequest,
pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i][0] = 0;
}
break;
@@ -607,7 +610,8 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_SHORT,pbuffer,&options,&nRequest);
status = dbGetField(paddr,DBR_SHORT,pbuffer,&options,&nRequest,
pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -617,7 +621,8 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_FLOAT,pbuffer,&options,&nRequest);
status = dbGetField(paddr,DBR_FLOAT,pbuffer,&options,&nRequest,
pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -627,7 +632,8 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_ENUM,pbuffer,&options,&nRequest);
status = dbGetField(paddr,DBR_ENUM,pbuffer,&options,&nRequest,
pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -637,7 +643,8 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_CHAR,pbuffer,&options,&nRequest);
status = dbGetField(paddr,DBR_CHAR,pbuffer,&options,&nRequest,
pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -647,7 +654,8 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_LONG,pbuffer,&options,&nRequest);
status = dbGetField(paddr,DBR_LONG,pbuffer,&options,&nRequest,
pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -657,7 +665,8 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_DOUBLE,pbuffer,&options,&nRequest);
status = dbGetField(paddr,DBR_DOUBLE,pbuffer,&options,&nRequest,
pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -673,13 +682,14 @@ unsigned short no_elements;
options=DBR_STATUS;
nRequest=0;
status = dbGetField(paddr,DBR_STRING,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_STRING,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_STRING,&(pold->value[0]),
&options,&nRequest);
&options,&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i][0] = 0;
}
break;
@@ -694,13 +704,14 @@ unsigned short no_elements;
options=DBR_STATUS;
nRequest=0;
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_SHORT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -714,13 +725,14 @@ unsigned short no_elements;
options=DBR_STATUS;
nRequest=0;
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_FLOAT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -734,13 +746,14 @@ unsigned short no_elements;
options=DBR_STATUS;
nRequest=0;
status = dbGetField(paddr,DBR_ENUM,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_ENUM,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_ENUM,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -754,13 +767,14 @@ unsigned short no_elements;
options=DBR_STATUS;
nRequest=0;
status = dbGetField(paddr,DBR_UCHAR,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_UCHAR,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_UCHAR,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -774,13 +788,14 @@ unsigned short no_elements;
options=DBR_STATUS;
nRequest=0;
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_LONG,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -794,13 +809,14 @@ unsigned short no_elements;
options=DBR_STATUS;
nRequest=0;
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_DOUBLE,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -815,14 +831,15 @@ unsigned short no_elements;
options=DBR_STATUS | DBR_TIME;
nRequest=0;
status = dbGetField(paddr,DBR_STRING,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_STRING,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->stamp = new.time; /* structure copy */
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_STRING,pold->value,&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i][0] = 0;
}
break;
@@ -838,14 +855,15 @@ unsigned short no_elements;
options=DBR_STATUS | DBR_TIME;
nRequest=0;
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->stamp = new.time; /* structure copy */
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_SHORT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -860,14 +878,15 @@ unsigned short no_elements;
options=DBR_STATUS | DBR_TIME;
nRequest=0;
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->stamp = new.time; /* structure copy */
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_FLOAT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -882,14 +901,15 @@ unsigned short no_elements;
options=DBR_STATUS | DBR_TIME;
nRequest=0;
status = dbGetField(paddr,DBR_ENUM,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_ENUM,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->stamp = new.time; /* structure copy */
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_ENUM,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -904,14 +924,15 @@ unsigned short no_elements;
options=DBR_STATUS | DBR_TIME;
nRequest=0;
status = dbGetField(paddr,DBR_CHAR,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_CHAR,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->stamp = new.time; /* structure copy */
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_CHAR,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -926,14 +947,15 @@ unsigned short no_elements;
options=DBR_STATUS | DBR_TIME;
nRequest=0;
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->stamp = new.time; /* structure copy */
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_LONG,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -948,14 +970,15 @@ unsigned short no_elements;
options=DBR_STATUS | DBR_TIME;
nRequest=0;
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->stamp = new.time; /* structure copy */
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_DOUBLE,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -974,7 +997,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_GR_LONG|DBR_AL_LONG;
nRequest=0;
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
strncpy(pold->units,new.units,8);
@@ -987,7 +1011,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_SHORT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1006,7 +1030,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_PRECISION|DBR_GR_DOUBLE
|DBR_AL_DOUBLE;
nRequest=0;
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->precision = new.precision;
@@ -1020,7 +1045,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_FLOAT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1038,7 +1063,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_GR_LONG|DBR_AL_LONG;
nRequest=0;
status = dbGetField(paddr,DBR_UCHAR,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_UCHAR,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
strncpy(pold->units,new.units,8);
@@ -1051,7 +1077,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_UCHAR,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1068,7 +1094,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_GR_LONG|DBR_AL_LONG;
nRequest=0;
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
strncpy(pold->units,new.units,8);
@@ -1081,7 +1108,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_LONG,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1100,7 +1127,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_PRECISION|DBR_GR_DOUBLE
|DBR_AL_DOUBLE;
nRequest=0;
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->precision = new.precision;
@@ -1114,7 +1142,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_DOUBLE,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1134,7 +1162,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_GR_LONG|DBR_CTRL_LONG
|DBR_AL_LONG;
nRequest=0;
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_SHORT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
strncpy(pold->units,new.units,8);
@@ -1149,7 +1178,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_SHORT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1169,7 +1198,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_PRECISION|DBR_GR_DOUBLE
|DBR_CTRL_DOUBLE|DBR_AL_DOUBLE;
nRequest=0;
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_FLOAT,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->precision = new.precision;
@@ -1185,7 +1215,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_FLOAT,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1204,7 +1234,7 @@ unsigned short no_elements;
/* first get status and severity */
options=DBR_STATUS|DBR_ENUM_STRS;
nRequest=0;
status = dbGetField(paddr,DBR_ENUM,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_ENUM,&new,&options,&nRequest,pfl);
pold->status = new.status;
pold->severity = new.severity;
no_str = new.no_str;
@@ -1217,7 +1247,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_ENUM,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1236,7 +1266,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_GR_LONG|DBR_CTRL_LONG
|DBR_AL_LONG;
nRequest=0;
status = dbGetField(paddr,DBR_UCHAR,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_UCHAR,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
strncpy(pold->units,new.units,8);
@@ -1251,7 +1282,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_UCHAR,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1270,7 +1301,7 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_GR_LONG|DBR_CTRL_LONG
|DBR_AL_LONG;
nRequest=0;
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_LONG,&new,&options,&nRequest,pfl);
pold->status = new.status;
pold->severity = new.severity;
strncpy(pold->units,new.units,8);
@@ -1285,7 +1316,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_LONG,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;
@@ -1305,7 +1336,8 @@ unsigned short no_elements;
options=DBR_STATUS|DBR_UNITS|DBR_PRECISION|DBR_GR_DOUBLE
|DBR_CTRL_DOUBLE|DBR_AL_DOUBLE;
nRequest=0;
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest);
status = dbGetField(paddr,DBR_DOUBLE,&new,&options,&nRequest,
pfl);
pold->status = new.status;
pold->severity = new.severity;
pold->precision = new.precision;
@@ -1321,7 +1353,7 @@ unsigned short no_elements;
options=0;
nRequest=no_elements;
status = dbGetField(paddr,DBR_DOUBLE,&(pold->value),&options,
&nRequest);
&nRequest,pfl);
for(i=nRequest; i<no_elements; i++) pvalue[i] = 0;
}
break;

View File

@@ -1,5 +1,4 @@
/* share/src/db $Id$ */
/* database access subroutines */
/*
* Author: Bob Dalesio
@@ -30,8 +29,10 @@
* -----------------
* .01 07-26-91 mrk Major cleanup
* .02 08-06-91 mrk More cleanup
* .03 08-13-91 mrk Added extra null arg to db_get_field calls
*/
#include <vxWorks.h>
#include <types.h>
#include <db_access.h>
@@ -79,7 +80,7 @@ short index;
&& (i!=DBR_GR_STRING)
&& (i!=DBR_CTRL_STRING)) continue;
}
if(db_get_field(paddr,i,tgf_buffer,number_elements,0)<0)
if(db_get_field(paddr,i,tgf_buffer,number_elements,NULL)<0)
printf("\t%s Failed\n",dbr_text[i]);
else
print_returned(i,tgf_buffer,number_elements);
@@ -131,28 +132,28 @@ short index;
printf(" Field Size: %d\n",addr.field_size);
printf(" No Elements: %d\n",addr.no_elements);
if (db_put_field(paddr,DBR_STRING,pvalue,1) < 0) printf("\n\t failed ");
if (db_get_field(paddr,DBR_STRING,buffer,1) < 0) printf("\n\tfailed");
if (db_get_field(paddr,DBR_STRING,buffer,1,NULL) < 0) printf("\n\tfailed");
else print_returned(DBR_STRING,buffer,1);
if(addr.field_type<=DBF_STRING)
return(0);
if(sscanf(pvalue,"%hd",&shortvalue)==1) {
if (db_put_field(paddr,DBR_SHORT,&shortvalue,1) < 0)
printf("\n\t SHORT failed ");
if (db_get_field(paddr,DBR_SHORT,buffer,1) < 0)
if (db_get_field(paddr,DBR_SHORT,buffer,1,NULL) < 0)
printf("\n\t SHORT GET failed");
else print_returned(DBR_SHORT,buffer,1);
}
if(sscanf(pvalue,"%ld",&longvalue)==1) {
if (db_put_field(paddr,DBR_LONG,&longvalue,1) < 0)
printf("\n\t LONG failed ");
if (db_get_field(paddr,DBR_LONG,buffer,1) < 0)
if (db_get_field(paddr,DBR_LONG,buffer,1,NULL) < 0)
printf("\n\t LONG GET failed");
else print_returned(DBR_LONG,buffer,1);
}
if(sscanf(pvalue,"%f",&floatvalue)==1) {
if (db_put_field(paddr,DBR_FLOAT,&floatvalue,1) < 0)
printf("\n\t FLOAT failed ");
if (db_get_field(paddr,DBR_FLOAT,buffer,1) < 0)
if (db_get_field(paddr,DBR_FLOAT,buffer,1,NULL) < 0)
printf("\n\t FLOAT GET failed");
else print_returned(DBR_FLOAT,buffer,1);
}
@@ -160,7 +161,7 @@ short index;
doublevalue=floatvalue;
if (db_put_field(paddr,DBR_DOUBLE,&doublevalue,1) < 0)
printf("\n\t DOUBLE failed ");
if (db_get_field(paddr,DBR_DOUBLE,buffer,1) < 0)
if (db_get_field(paddr,DBR_DOUBLE,buffer,1,NULL) < 0)
printf("\n\t DOUBLE GET failed");
else print_returned(DBR_DOUBLE,buffer,1);
}
@@ -168,14 +169,14 @@ short index;
charvalue=(unsigned char)shortvalue;
if (db_put_field(paddr,DBR_CHAR,&charvalue,1) < 0)
printf("\n\t CHAR failed ");
if (db_get_field(paddr,DBR_CHAR,buffer,1) < 0)
if (db_get_field(paddr,DBR_CHAR,buffer,1,NULL) < 0)
printf("\n\t CHAR GET failed");
else print_returned(DBR_CHAR,buffer,1);
}
if(sscanf(pvalue,"%hu",&shortvalue)==1) {
if (db_put_field(paddr,DBR_ENUM,&shortvalue,1) < 0)
printf("\n\t ENUM failed ");
if (db_get_field(paddr,DBR_ENUM,buffer,1) < 0)
if (db_get_field(paddr,DBR_ENUM,buffer,1,NULL) < 0)
printf("\n\t ENUM GET failed");
else print_returned(DBR_ENUM,buffer,1);
}

View File

@@ -29,10 +29,14 @@
* -----------------
* .01 07-20-91 rac print release data; set env params
* .02 08-06-91 mrk parm string length test changed to warning
* with continue
* .03 08-30-91 mrk completed .02 fix
* .04 10-10-91 rcz changed getResources to accomodate EPICS_
* parameters in a structure (first try)
* .03 08-09-91 joh added ioc log client init
* .04 09-10-91 joh moved VME stuff from here to initVme()
* .05 09-10-91 joh printf() -> logMsg()
* .06 09-10-91 joh print message only on failure
* .07 08-30-91 rcz completed .02 fix
* .04 10-10-91 rcz changed getResources to accomodate EPICS_
* parameters in a structure (first try)
*
*/
#include <vxWorks.h>
@@ -65,14 +69,14 @@
static initialized=FALSE;
/* define forward references*/
extern long initBusController();
extern long sdrLoad();
extern long initDrvSup();
extern long initRecSup();
extern long initDevSup();
extern long initDatabase();
extern long addToSet();
extern long getResources();
long initDrvSup();
long initRecSup();
long initDevSup();
long initDatabase();
long addToSet();
long initialProcess();
long getResources();
iocInit(pfilename,pResourceFilename)
@@ -86,61 +90,51 @@ char * pResourceFilename;
UTINY type;
if(initialized) {
printf("iocInit can only be called once\n");
logMsg("iocInit can only be called once\n");
return(-1);
}
coreRelease();
epicsSetEnvParams();
if(status=initBusController()) {
printf("Xycom SRM010 Bus Controller Not Present\n");
status = iocLogInit();
if(status!=0){
logMsg("iocInit Failed to Initialize Ioc Log Client \n");
}
if(status=sdrLoad(pfilename)) {
printf("iocInit aborting because sdrLoad failed\n");
status=sdrLoad(pfilename);
if(status!=<0) {
logMsg("iocInit aborting because sdrLoad failed\n");
return(-1);
}
if(status=getResources(pResourceFilename)) {
printf("iocInit aborting because getResources failed\n");
status=getResources(pResourceFilename);
if(status!=<0) {
logMsg("iocInit aborting because getResources failed\n");
return(-1);
}
printf("getResources completed\n");
initialized = TRUE;
printf("sdrLoad completed\n");
/* enable interrupt level 5 and 6 */
sysIntEnable(5);
sysIntEnable(6);
if(initDrvSup()==0) printf("Drivers Initialized\n");
if(initRecSup()==0) printf("Record Support Initialized\n");
if(initDevSup()==0) printf("Device Support Initialized\n");
ts_init(); printf("Time Stamp Driver Initialized\n");
if(initDatabase()==0) printf("Database Initialized\n");
if(initDrvSup()!=<0) logMsg("iocInit: Drivers Failed to Initialized\n");
if(initRecSup()!=<0) logMsg("iocInit: Record Support Failed to Initialized\n");
if(initDevSup()!=<0) logMsg("iocInit: Device Support Failed to Initialized\n");
ts_init();
if(initDatabase()!=<0) logMsg("iocInit: Database Failed to Initialized\n");
/* if user exit exists call it */
strcpy(name,"_");
strcat(name,"dbUserExit");
rtnval = symFindByName(sysSymTbl,name,&pdbUserExit,&type);
if(rtnval==OK && (type&N_TEXT!=0)) {
(*pdbUserExit)();
printf("User Exit was called\n");
logMsg("User Exit was called\n");
}
scan_init(); printf("Scanners Initialized\n");
rsrv_init(); printf("Channel Access Servers Initialized\n");
printf("iocInit: All initialization complete\n");
if(initialProcess()!=0) logMsg("iocInit: initialProcess Failed\n");
scan_init();
rsrv_init();
logMsg("iocInit: All initialization complete\n");
return(0);
}
#include <module_types.h>
static long initBusController(){ /*static */
char ctemp;
/* initialize the Xycom SRM010 bus controller card */
ctemp = XY_LED;
if (vxMemProbe(SRM010_ADDR, WRITE,1,&ctemp) == -1) {
return(-1);
}
return(0);
}
static long initDrvSup() /* Locate all driver support entry tables */
{
char *pname;
@@ -312,6 +306,16 @@ static long initDatabase()
/* If NAME is null then skip this record*/
if(!(precord->name[0])) continue;
/*initialize fields rset and pdba*/
(struct rset *)(precord->rset) = prset;
strncpy(name,precord->name,PVNAME_SZ);
strcat(name,".VAL");
if(dbNameToAddr(name,&precord->pdba)) {
status = S_db_notFound;
errMessage(status,
"initDatbase logic error: dbNameToAddr failed");
}
/* initialize mlok and mlis*/
FASTLOCKINIT(&precord->mlok);
lstInit(&(precord->mlis));
@@ -479,6 +483,27 @@ static long addToSet(precord,record_type,lookAhead,i,j,lset)
return(0);
}
static long initialProcess()
{
short i,j;
struct recLoc *precLoc;
struct dbCommon *precord;
if(!dbRecords) return(0);
for(i=0; i< (dbRecords->number); i++) {
if(!(precLoc = dbRecords->papRecLoc[i]))continue;
for(j=0, ((char *)precord) = precLoc->pFirst;
j<precLoc->no_records;
j++, ((char *)precord) += precLoc->rec_size ) {
/* If NAME is null then skip this record*/
if(!(precord->name[0])) continue;
if(!precord->pini) continue;
(void)dbProcess(precord->pdba);
}
}
return(0);
}
#define MAX 128
#define SAME 0
static char *cvt_str[] = {
@@ -500,7 +525,7 @@ static long getResources(fname) /* Resource Definition File interpreter */
int i = 0;
int found = 0;
int cvType = 0;
int epicsFlag;
int epicsFlag;
char buff[MAX + 1];
char name[40];
char s1[MAX];
@@ -566,24 +591,24 @@ static long getResources(fname) /* Resource Definition File interpreter */
return (-1);
}
if ( (strncmp(s1,"EPICS_",6)) == SAME)
epicsFlag = 1;
else
epicsFlag = 0;
epicsFlag = 1;
else
epicsFlag = 0;
switch (cvType) {
case 0: /* DBF_STRING */
case 0: /* DBF_STRING */
len = strlen(s3);
len2 = 20;
if (len >= len2) {
sprintf(message,
"getResources: Warning, string might exceed previous reserved space - line=%d",
"getResources: Warning, string might exceed previous reserved space - line=%d",
lineNum);
errMessage(-1L, message);
}
if ( epicsFlag )
strncpy(pSymAddr+sizeof(caddr_t), s3, len + 1);
else
strncpy(pSymAddr, s3, len + 1);
if ( epicsFlag )
strncpy(pSymAddr+sizeof(caddr_t), s3, len + 1);
else
strncpy(pSymAddr, s3, len + 1);
break;
case 1: /* DBF_SHORT */
if ((sscanf(s3, "%hd", &n_short)) != 1) {
@@ -592,62 +617,65 @@ static long getResources(fname) /* Resource Definition File interpreter */
errMessage(0L, message);
return (-1);
}
if ( epicsFlag ) {
sprintf(message,
"getResources: EPICS_ type DBF_SHORT not supported - line=%d",
lineNum);
errMessage(-1L, message);
}
else
*(short *) pSymAddr = n_short;
if ( epicsFlag ) {
sprintf(message,
"getResources: EPICS_ type DBF_SHORT not supported - line =%d",
lineNum);
errMessage(-1L, message);
}
else
*(short *) pSymAddr = n_short;
break;
case 2: /* DBF_LONG */
case 2: /* DBF_LONG */
if ((sscanf(s3, "%ld", &n_long)) != 1) {
sprintf(message,
"getResources: conversion failed - line=%d", lineNum);
errMessage(0L, message);
return (-1);
}
if ( epicsFlag ) {
sprintf(message,
"getResources: EPICS_ type DBF_LONG not supported - line=%d",
lineNum);
errMessage(-1L, message);
}
else
*(long *) pSymAddr = n_long;
if ( epicsFlag ) {
sprintf(message,
"getResources: EPICS_ type DBF_LONG not supported - line= %d",
lineNum);
errMessage(-1L, message);
}
else
*(long *) pSymAddr = n_long;
break;
case 3: /* DBF_FLOAT */
case 3: /* DBF_FLOAT */
if ((sscanf(s3, "%e", &n_float)) != 1) {
sprintf(message,
"getResources: conversion failed - line=%d", lineNum);
errMessage(0L, message);
return (-1);
}
if ( epicsFlag ) {
sprintf(message,
"getResources: EPICS_ type DBF_FLOAT not supported - line=%d",
lineNum);
errMessage(-1L, message);
}
else
*(float *) pSymAddr = n_float;
if ( epicsFlag ) {
sprintf(message,
"getResources: EPICS_ type DBF_FLOAT not supported - line =%d",
lineNum);
errMessage(-1L, message);
}
else
*(float *) pSymAddr = n_float;
break;
case 4: /* DBF_DOUBLE */
case 4: /* DBF_DOUBLE */
if ((sscanf(s3, "%le", &n_double)) != 1) {
sprintf(message,
"getResources: conversion failed - line=%d", lineNum);
errMessage(0L, message);
return (-1);
}
if ( epicsFlag ) {
sprintf(message,
if ( epicsFlag ) {
sprintf(message,
"getResources: EPICS_ type DBF_DOUBLE not supported - line=%d",
lineNum);
errMessage(-1L, message);
}
else
*(double *) pSymAddr = n_double;
lineNum);
errMessage(-1L, message);
}
else
*(double *) pSymAddr = n_double;
break;
default:
sprintf(message,