EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: dbhcr
From: "Johnson, Andrew N. via Core-talk" <[email protected]>
To: Ralph Lange <[email protected]>
Cc: EPICS core-talk <[email protected]>
Date: Tue, 15 Jan 2019 21:18:55 +0000
Hi Ralph,

You must be running dbhcr before iocInit, which outputs nothing for me
either (whereas it works fine after iocInit). This happens because the
new link parser doesn't set plink->type until iocInit, and the code in
dbReportDeviceConfig() [which dbhcr() calls] was expecting it to be set
already.

We can check whether plink->text is set to detect this condition, but we
can't immediately use the contents as the field value because that would
show PV links and constant values as well, which dbhcr is supposed to
ignore. However we can call dbParseLink() to get the link type, and then
for the types it's supposed to display just use the raw plink->text as
the string value.

The result won't be quite as fast since it's now reparsing every link
field before displaying a subset of their values, and the output may be
slightly different since it's now showing the raw text from the .db file
instead of converting the structure fields back to text, but I think it
should be close enough.

See patch (includes formatting changes too, sorry!).

- Andrew

-- 
Arguing for surveillance because you have nothing to hide is no
different than making the claim, "I don't care about freedom of
speech because I have nothing to say." -- Edward Snowdon

diff --git a/modules/database/src/ioc/dbStatic/dbStaticLib.c b/modules/database/src/ioc/dbStatic/dbStaticLib.c
index 7cc2645..1484e4b 100644
--- a/modules/database/src/ioc/dbStatic/dbStaticLib.c
+++ b/modules/database/src/ioc/dbStatic/dbStaticLib.c
@@ -3556,68 +3556,110 @@ void  dbDumpBreaktable(DBBASE *pdbbase,const char *name)
     return;
 }
 
-static char *bus[VXI_IO+1] = {"","","VME","CAMAC","AB",
-	"GPIB","BITBUS","","","","","","INST","BBGPIB","VXI"};
-void  dbReportDeviceConfig(dbBase *pdbbase,FILE *report)
+static char *bus[LINK_NTYPES] = {
+    "",     /* CONSTANT */
+    NULL,   /* PV_LINK */
+    "VME",
+    "CAMAC",
+    "AB",
+    "GPIB",
+    "BITBUS",
+    NULL,   /* MACRO_LINK */
+    NULL,   /* JSON_LINK */
+    NULL,   /* PN_LINK */
+    NULL,   /* DB_LINK */
+    NULL,   /* CA_LINK */
+    "INST",
+    "BBGPIB",
+    "VXI"
+};
+void  dbReportDeviceConfig(dbBase *pdbbase, FILE *report)
 {
-    DBENTRY	dbentry;
-    DBENTRY	*pdbentry=&dbentry;
-    long	status;
-    char	linkValue[messagesize];
-    char	dtypValue[50];
-    char	cvtValue[40];
-    int		ilink,nlinks;
-    struct link	*plink;
-    int         linkType;
-    FILE        *stream = (report==0) ? stdout : report;
+    DBENTRY dbentry, *pdbentry = &dbentry;
+    long status;
+    FILE *stream = report ? report : stdout;
 
-    if(!pdbbase) {
-	fprintf(stderr,"pdbbase not specified\n");
-	return;
+    if (!pdbbase) {
+        fprintf(stderr, "dbReportDeviceConfig: pdbbase not specified\n");
+        return;
     }
+
     dbInitEntry(pdbbase,pdbentry);
     status = dbFirstRecordType(pdbentry);
-    while(!status) {
-	status = dbFirstRecord(pdbentry);
-	while(!status) {
-	    nlinks = dbGetNLinks(pdbentry);
-	    for(ilink=0; ilink<nlinks; ilink++) {
-		status = dbGetLinkField(pdbentry,ilink);
-		if(status || dbGetLinkType(pdbentry)!=DCT_LINK_FORM) continue;
-		plink = pdbentry->pfield;
-		linkType = plink->type;
-		if(bus[linkType][0]==0) continue;
-		strncpy(linkValue, dbGetString(pdbentry), NELEMENTS(linkValue)-1);
-		linkValue[NELEMENTS(linkValue)-1] = '\0';
-		status = dbFindField(pdbentry,"DTYP");
-		if(status) break;
-		strcpy(dtypValue,dbGetString(pdbentry));
-		status = dbFindField(pdbentry,"LINR");
-		if(status) {
-		    cvtValue[0] = 0;
-		} else {
-		    if(strcmp(dbGetString(pdbentry),"LINEAR")!=0) {
-			cvtValue[0] = 0;
-		    } else {
-			strcpy(cvtValue,"cvt(");
-			status = dbFindField(pdbentry,"EGUL");
-			if(!status) strcat(cvtValue,dbGetString(pdbentry));
-			status = dbFindField(pdbentry,"EGUF");
-			if(!status) {
-			    strcat(cvtValue,",");
-			    strcat(cvtValue,dbGetString(pdbentry));
-			}
-			strcat(cvtValue,")");
-		    }
-		}
-		fprintf(stream,"%-8s %-20s %-20s %-20s %-s\n",
-			bus[linkType],linkValue,dtypValue,
-			dbGetRecordName(pdbentry),cvtValue);
-		break;
-	    }
-	    status = dbNextRecord(pdbentry);
-	}
-	status = dbNextRecordType(pdbentry);
+    while (!status) {
+        const int nlinks = dbGetNLinks(pdbentry);
+
+        status = dbFirstRecord(pdbentry);
+        while (!status) {
+            int ilink;
+
+            for (ilink=0; ilink<nlinks; ilink++) {
+                char linkValue[messagesize];
+                char dtypValue[50];
+                char cvtValue[40];
+                struct link *plink;
+                int linkType;
+
+                status = dbGetLinkField(pdbentry, ilink);
+                if (status)
+                    continue;
+
+                plink = pdbentry->pfield;
+                linkType = plink->type;
+                if (plink->text) {  /* Not yet parsed */
+                    dbLinkInfo linfo;
+
+                    if (dbParseLink(plink->text, pdbentry->pflddes->field_type, &linfo))
+                        continue;
+
+                    linkType = linfo.ltype;
+                    if (linkType && bus[linkType])
+                        strncpy(linkValue, plink->text, messagesize-1);
+
+                    dbFreeLinkInfo(&linfo);
+                }
+                else {
+                    strncpy(linkValue, dbGetString(pdbentry), messagesize-1);
+                }
+
+                if (!linkType || !bus[linkType])
+                    continue;
+                linkValue[messagesize-1] = '\0';
+
+                status = dbFindField(pdbentry, "DTYP");
+                if (status)
+                    break;  /* Next record type */
+
+                strcpy(dtypValue, dbGetString(pdbentry));
+                status = dbFindField(pdbentry, "LINR");
+                if (status) {
+                    cvtValue[0] = 0;
+                }
+                else {
+                    if (strcmp(dbGetString(pdbentry), "LINEAR") != 0) {
+                        cvtValue[0] = 0;
+                    }
+                    else {
+                        strcpy(cvtValue,"cvt(");
+                        status = dbFindField(pdbentry, "EGUL");
+                        if (!status)
+                            strcat(cvtValue, dbGetString(pdbentry));
+                        status = dbFindField(pdbentry, "EGUF");
+                        if (!status) {
+                            strcat(cvtValue, ",");
+                            strcat(cvtValue, dbGetString(pdbentry));
+                        }
+                        strcat(cvtValue, ")");
+                    }
+                }
+                fprintf(stream,"%-8s %-20s %-20s %-20s %-s\n",
+                        bus[linkType], linkValue, dtypValue,
+                        dbGetRecordName(pdbentry), cvtValue);
+                break;
+            }
+            status = dbNextRecord(pdbentry);
+        }
+        status = dbNextRecordType(pdbentry);
     }
     dbFinishEntry(pdbentry);
     finishOutstream(stream);

Navigate by Date:
Prev: Re: 'Request' support in qsrv Timo Korhonen via Core-talk
Next: pvAccess monitor & changing request type in same channel Pearson, Matthew R. via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Int64 PV and caget Williams Jr., Ernest L. via Core-talk
Next: pvAccess monitor & changing request type in same channel Pearson, Matthew R. via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 16 Jan 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·