Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019 
<== Date ==> <== Thread ==>

Subject: RE: how to know which PVs write to a PV
From: "Hu, Yong" <yhu@bnl.gov>
To: "Arnold, Ned D." <nda@aps.anl.gov>, LEI Ge <leige@ihep.ac.cn>, "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Tue, 27 May 2014 14:30:53 +0000
Hi Ned,

Yes, your approach is really a quicker way. How about the idea of integrating your code (or similar implementation) with the field TPRO in the dbProcess()? 

I did a quick test and put your code in base-3.14.12.2/src/db/dbAccess.c. With a few other changes on Makefile, I re-compiled my EPICS base and example ioc without problem. And the code below works: if recordName.TPRO is set to 1, this will show more information -- who is doing CA put from which machine, the message like this:

CAS-client: Process yhuHost:aiExample
CA put to yhuHost:aiExample by user yhu from host box32


/*trying to adapt Ned's code inside dbProcess()*/
long epicsShareAPI dbProcess(dbCommon *precord)
{
...

	if(*ptrace) printf("%s: Process %s\n",
			epicsThreadGetNameSelf(), precord->name);

	if(*ptrace){
	    tid = epicsThreadGetIdSelf();
	    LOCK_CLIENTQ;

            for(pclient=(struct client*)ellFirst(&clientQ);
                pclient && pclient->tid!=tid;
                pclient=(struct client*)ellNext(&pclient->node)
                );

            if(pclient)
              sprintf(result,"user %s from host %s",pclient->pUserName,pclient->pHostName);
            else
              sprintf(result,"Internal: TID = %p",tid);

            UNLOCK_CLIENTQ;

            printf("CA put to %s by %s\n",precord->name,result);
	}
	/* process record */
	status = (*prset->process)(precord);

...
}


Yong 

________________________________________
From: tech-talk-bounces@aps.anl.gov [tech-talk-bounces@aps.anl.gov] on behalf of Arnold, Ned D. [nda@aps.anl.gov]
Sent: Thursday, May 22, 2014 9:47 AM
To: LEI Ge; tech-talk@aps.anl.gov
Subject: RE: how to know which PVs write to a PV

Yet another <quicker> way to determine which host wrote to a PV:

1) Load a subroutine record into the IOC using the code below
2) Include this subroutine record in the record processing chain of the record you want to monitor. You can use a FLNK or SDIS for this (make sure that it is *not* a CA  or CP link).

When the record processes, you see something like this ...

ioclic1> caHostId: ioclic1:caHostId1: nda from chiron

We have a few of these subroutine records in all IOCs, so if we need to track down an errant "write" we can just change a few links ... without rebooting.

  Ned

RECORD
record(sub,"$(IOC):caHostId1") {
        field(INAM,"caHostIdI")
        field(SNAM,"caHostId")
}

SUBROUTINE
/* subroutine for determining host/uid of CA client
 *
 * DESC : String identifying Username & Host
 *
 */

#include        <stdio.h>
#include        <string.h>
#include        <dbEvent.h>
#include        <osiSock.h>
#include        <ellLib.h>
#include        <server.h>
#include <dbDefs.h>
#include <registryFunction.h>
#include <subRecord.h>
#include <epicsExport.h>

static long  caHostIdI(subRecord* pr)
{
    return(0);
}

static long  caHostId(subRecord* pr)
{
    char  result[100];
    epicsThreadId tid = epicsThreadGetIdSelf();
    struct client* pclient;

    LOCK_CLIENTQ;

    for(pclient=(struct client*)ellFirst(&clientQ);
        pclient && pclient->tid!=tid;
        pclient=(struct client*)ellNext(&pclient->node)
        );

    if(pclient)
      sprintf(result,"%s from %s",pclient->pUserName,pclient->pHostName);
    else
      sprintf(result,"Internal: TID = %p",tid);

    UNLOCK_CLIENTQ;

    strncpy(pr->desc, result, sizeof(pr->desc));
    pr->desc[sizeof(pr->desc)-1] = '\0';

    db_post_events(pr, pr->desc, 1);
    pr->val = pr->a;  /* set val to value of Input A */
    printf("caHostId: %s: %s\n",pr->name,result);

    return(0);

}

static registryFunctionRef caHostIdRef[] = {
    {"caHostIdI",(REGISTRYFUNCTION)caHostIdI},
    {"caHostId",(REGISTRYFUNCTION)caHostId}
};

static void caHostIdRegister(void)
{
    registryFunctionRefAdd(caHostIdRef,NELEMENTS(caHostIdRef));
}
epicsExportRegistrar(caHostIdRegister);

________________________________________
From: tech-talk-bounces@aps.anl.gov [tech-talk-bounces@aps.anl.gov] on behalf of LEI Ge [leige@ihep.ac.cn]
Sent: Wednesday, May 21, 2014 03:54 AM
To: tech-talk@aps.anl.gov
Subject: how to know which PVs write to a PV

Hi, all,

This week we met a problem, a PV's value should be 1 (to enable our e-gun trigger), but sometimes it becomes 0 unexpectedly. I checked the software logic I can remember to this pv, and have not found the reason. Maybe there is some logic I forget or I don't know, to write to this pv. So is there a way to check in our control system, which PVs write to this pv? Or, this PV is written from which IP?

Thanks a lot ,

Ge



Replies:
Re: how to know which PVs write to a PV Andrew Johnson
References:
how to know which PVs write to a PV LEI Ge
RE: how to know which PVs write to a PV Arnold, Ned D.

Navigate by Date:
Prev: how can I caget a PV's Value in the callback function of the caClient? ahwwq
Next: Job opportunities at ESS Timo Korhonen
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019 
Navigate by Thread:
Prev: RE: how to know which PVs write to a PV Arnold, Ned D.
Next: Re: how to know which PVs write to a PV Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·