g+
g+ Communities
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  <20122013  2014  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
<== Date ==> <== Thread ==>

Subject: RE: epicsAtExit
From: "Szalata, Zenon M." <zms@slac.stanford.edu>
To: Mark Rivers <rivers@cars.uchicago.edu>, "Williams Jr., Ernest L." <ernesto@slac.stanford.edu>
Cc: "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Thu, 28 Jun 2012 11:33:56 -0700
Hi Mark,
I added epicsThreadSleep(0.5) after fflush().  Still see no printf message.  I also tried reboot command with the same result.  Yes, something is wrong, what could it be?  I'm almost sure that the C reboot routine is not called at reboot time.

I tried something different.  I have a second VME system in which I have a different ADC module.  I have written two versions of a device driver for this module, one is based on asynPortDriver, the other is non-asyn.  Presently I am using the non-asyn driver.  This IOC reboots successfully while it is handling interrupts at fairly high rate.  I concluded that the reboot callback routine was doing its job.  I put a print statement in this routine with flush and timeout and see nothing printed at reboot.  Then I commented out the interrupt turning off part in it and the IOC still reboots successfully.  Now, if I switch to the asynPortDriver driver, the IOC no longer succeeds rebooting if the interrupts are left enabled.
So, there are two pieces of a puzzle:
1. Why in my device drivers the epicsAtExit mechanism does not work.  That is, my callback routine never gets called.
2. Why the two flavors of the device driver have such different effects on rebooting?

Regarding the first piece of the puzzle.  Is it EPICS base or is it vxWorks?
Actually I think it is vxWorks.  The IOC prints the following while it is booting:

BSP routine sysAtReboot() not found, epicsExit() will not be
called by reboot.  For reduced functionality, call
    rebootHookAdd(epicsExitCallAtExits)
value = 22347616 = 0x154ff60 = '`' = epics_basebin + 0x620

I just a message from Andrew Johnson where he points out that this might be it.

Thanks,
Zen


> -----Original Message-----
> From: Mark Rivers [mailto:rivers@cars.uchicago.edu]
> Sent: Thursday, June 28, 2012 10:12 AM
> To: Szalata, Zenon M.; Williams Jr., Ernest L.
> Cc: tech-talk@aps.anl.gov
> Subject: RE: epicsAtExit
> 
> Hi Zen,
> 
> If you don't see the printf message in the console output then something is
> wrong.
> 
> My IpUnidig driver does exactly the same thing your driver does: register a C-
> linkage callback function with epicsAtExit, which in turn calls a C++ class
> member function.  I just added a printf to the C++ member function, and it
> does print the message when I type "reboot" at the vxWorks prompt.
> 
> void IpUnidig::rebootCallback()
> {
>   ipUnidigRegisters r = regs_;
> 
>   printf("IpUnidig::rebootCallback, disabling interrupts\n");
>   fflush(stdout);
>   epicsThreadSleep(0.5);
>   *r.intEnableRegisterLow = 0;
>   *r.intEnableRegisterHigh = 0;
>   rebooting_ = 1;
> }
> 
> ioc13lab> reboot
> IpUnidig::rebootCallback, disabling interrupts
> 
> Note that until I added the epicsThreadSleep(0.5) my printf message was
> truncated, and it is possible you would not see it at all in spite of the fflush().
> Try adding the epicsThreadSleep() to make sure the printf message is indeed
> not being printed.
> 
> Mark
> 
> 
> -----Original Message-----
> From: Szalata, Zenon M. [mailto:zms@slac.stanford.edu]
> Sent: Thursday, June 28, 2012 11:10 AM
> To: Mark Rivers; Williams Jr., Ernest L.
> Cc: tech-talk@aps.anl.gov
> Subject: RE: epicsAtExit
> 
> Hi Mark,
> I don't see the printf message in the console output.  I see no evidence that
> rebootCB() is called.
> This is how I have implemented the _wtReg function:
> 
> asynStatus drvV792::_wtReg( uint off,word v){
> //------------------------------------------------------------------------------
> // Reads a register at off offset wrt base and returns the read value in v.
> //------------------------------------------------------------------------------
>   volatile word* padr=(word*)(_pmem+off);
>   if(!_pmem) return(asynError);
>   *padr=v;
> //printf( "%s::_wtReg: off=0x%x, v=%d\n",dname,off,v);
>   return(asynSuccess);
> }
> 
> I will try the read after write in rebootCB().
> 
> Thank you Mark,
> Zen
> 
> > -----Original Message-----
> > From: Mark Rivers [mailto:rivers@cars.uchicago.edu]
> > Sent: Wednesday, June 27, 2012 9:01 PM
> > To: Szalata, Zenon M.; Williams Jr., Ernest L.
> > Cc: tech-talk@aps.anl.gov
> > Subject: RE: epicsAtExit
> >
> > Hi Zen,
> >
> > With the asyn driver do you see the printf message, i.e. is the
> > drvV792::rebootCb()  function being called?
> >
> > Perhaps the VME writes to disable interrupts are not actually being
> > done because they are cached, and the cache is never flushed before
> > the system shuts down.  Have you declared ILEV and EVTR  to be
> > volatile? What happens if you do a read from those registers after the
> > writes, which should flush the cache?
> >
> > Mark
> >
> > ________________________________
> > From: Szalata, Zenon M. [zms@slac.stanford.edu]
> > Sent: Wednesday, June 27, 2012 7:40 PM
> > To: Mark Rivers; Williams Jr., Ernest L.
> > Cc: tech-talk@aps.anl.gov
> > Subject: epicsAtExit
> >
> > Hi Mark,
> > I have a problem, which I have been ignoring for a while.
> > I have a device driver for a VME module based on asynPortDriver class.
> > It is used with asyn R4.18, EPICS R3.14.12.2, vxWorks 6.6.
> > I have coded a couple of routines to disable interrupts when the IOC
> > is shutdown (with CTRL-X), which does not work.  Restarting the IOC
> > which uses the asyn based driver with CTRL-X fails to come up.  The
> > IOC reaches some point in the booting sequence and then I suppose it
> > crashes because the boot starts all over.  I recover from that with a
> > VME reset.  Also, if I disable interrupts before rebooting all works fine.
> > I have created another device driver using the conventional approach,
> > which does not use asyn.  As far as I can tell most of the code if not
> > the same is equivalent.  With this device driver the interrupts get disabled on
> exit.
> > This is what I have in the asynPortDriver version of the device driver:
> >
> > In the constructor I have:
> >
> >   epicsAtExit( rebootCbC,this);
> >
> > then I have:
> >
> > extern "C"{
> > ...
> > static void rebootCbC( void* pvt){
> >   drvV792* pthis=(drvV792*)pvt;
> >   pthis->rebootCb();
> > }
> > }
> >
> > void drvV792::rebootCb(){
> > //------------------------------------------------------------------------------
> >   printf( "%s::rebootCb: Interrupts disabled and Soft reset\n",dname);
> >   fflush(stdout);
> >   epicsThreadSleep(1.0);
> >   _wtReg( ILEV,0);
> >   _wtReg( EVTR,0);
> > }
> >
> > Writing 0 to the EVTR disables interrupts.  Also writing 0 to the ILEV
> > register disables interrupts.
> > In fact, the same rebootCB code, seems to work fine in the non-asyn driver.
> > Is something subtle taking place because of vxWorks?
> > Can you offer suggestion on how to make it work?
> > Thanks in advance,
> > Zen



References:
epicsAtExit Szalata, Zenon M.
RE: epicsAtExit Mark Rivers
RE: epicsAtExit Szalata, Zenon M.
RE: epicsAtExit Mark Rivers

Navigate by Date:
Prev: Re: epicsAtExit Andrew Johnson
Next: RE: epicsAtExit Szalata, Zenon M.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
Navigate by Thread:
Prev: RE: epicsAtExit Mark Rivers
Next: Re: epicsAtExit Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·