EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: CA.pm
From: Andrew Johnson <[email protected]>
To: Pam Gurd <[email protected]>
Cc: [email protected]
Date: Wed, 27 May 2009 09:46:00 -0500
Hi Pam,

On Tuesday 26 May 2009 18:05:17 Pam Gurd wrote:
> (copy of a message sent to Andrew last week)

(sorry, I was on vacation; your message was next in my queue).

> I am testing an API which uses CA.pm for Perl procedures.  My
> specification says the procedure should abort when it loses
> any CA connections.  So I've started a soft IOC, started this test
> procedure, and then stop the soft IOC when it tells me to.  It sleeps
> for a minute to allow CA to really disconnect (and there is a message)
> but it never gets to the callback routine.  (Actually, it gets there
> once during channel creation - but not when the channel really
> connects.)  Am I doing something wrong here?

I have to admit that I've never tested the $SIG{__DIE__} hook with CA, but it 
does work once a few issues in your Perl code are sorted out.

> my $channel = CA->new("TEST:DEV1:CUR", &connectionCallback);

You need to pass either a reference to your connection handler routine or its 
name as a string, thus use \&connectionCallback or 'connectionCallback'.  As 
coded above, the routine is actually being called while evaluating the 
arguments for CA->new() and as a result it's not being attached to the 
channel at all.

> CA->pend_io(3);

If you're using a connection callback, you can't use CA->pend_io() to wait for 
your connection to be made (it returns immediately, just as ca_pend_io() does 
in the C API).  I replaced that line with CA->pend_event(3); but you could 
also restructure your code and put subsequent processing into the connection 
handler as long as you only do it once even if the channel later disconnects 
and reconnects.

> sleep 60;

I would discourage you from ever using sleep once CA is running; replace it 
with CA->pend_event() instead to allow CA activity to occur during the delay.

With the changes above, I get the following output, which I think shows that 
the callback is working:

testing connection for TEST:DEV1:CUR
TEST:DEV1:CUR is connected.
Stop the soft IOC and then press Enter
Wait 1 minute for EPICS disconnect
CA.Client.Exception...............................................
    Warning: "Virtual circuit disconnect"
    Context: "tux.aps.anl.gov:5064"
    Source File: ../cac.cpp line 1121
    Current Time: Wed May 27 2009 09:42:25.687166414
..................................................................
connection callback! undef status
 error: CA=SCALAR(0x9e6b50)->name!


HTH, I'd recommend that you study the various .pl programs in base/src/cap5 
for examples of how to use the Perl CA library.

- Andrew
-- 
The best FOSS code is written to be read by other humans -- Harold Welte

References:
CA.pm Pam Gurd

Navigate by Date:
Prev: Re: R3.14.9 access security and "no read access" w/caget John A. Priller
Next: Agilent E8257D Device Support? Gaul, Robert
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: CA.pm Pam Gurd
Next: Agilent E8257D Device Support? Gaul, Robert
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 31 Jan 2014 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·