>>> On 1/30/2002 at 19:54:19 EST, Adam Jon DeGrush wrote:
> I am trying to monitor the connection of channels using
> ca_change_connection_event from the client library and am having
> difficulty getting it to work. I would like to do a group poll
> (synchronous or asynchronously) of my channels at a certain frequency
> and would like make sure that my channels are connected before I do
> this.
First, are you "monitoring" your channels (using ca_add_event()) or are you
using ca_get() in your poll function ?
In any case, there is a field in the CHID that holds the status of the
connection, and a macro defined in cadef.h for accessing it (ca_state()).
The possible values are cs_never_conn, cs_prev_conn, cs_conn, cs_closed.
> I though I could just install a connection handler like in the
> example:
>
> for (pCurrent = pFirst; pCurrent != NULL; pCurrent = pCurrent->next){
> status=ca_change_connection_event(pCurrent->chan, myHandler);
> SEVCHK(status, "ca_change_connection_event:
> couldn't change handler");
> }
ca_change_connection_event() is normally used to replace an existing
connection handler, which would have been initially associated with the
channel by specifying it in the ca_search_and_connect() call used to open
the channel.
> and then have something like:
>
> while(1){
> ca_pend_event(POLL); //
> myGroupPoll();
> nanosleep(fiveseconds,NULL);
> }
>
> and then have my handler either block or remove from my list those
> channels that have been disconnected. Instead when I run it and
> disconnect a channel there is a pause of about 5 seconds and then a
> segmentation violation( although I think handler does get called).
(The "pause" is probably the time it takes for your system to write out a
"core" file.)
What do you mean by "disconnect a channel" ? Your connection handler has
been invoked *because* the channel has changed connection state. Either it
has re-connected, or it is already disconnected.
> The same thing happens if I remove myGroupPoll().
Which clearly implies that the action which causes the seg fault is in your
connection handler.
If all you are doing in the connection handler is flagging when a channel
is available or not, the CA library does that for you. You only really
need the connection handler if you need special handling (initialization,
message generation, cleanup, etc) when the connection changes state.
Otherwise, just test the state before you try to access the value.
----
Brian McAllister Controls Programmer/Beam Physicist
[email protected] MIT-Bates Linear Accelerator
(617) 253-9537 Middleton, MA
- Replies:
- Re: CA client library and Connection handler Adam Jon DeGrush
- References:
- CA client library and Connection handler Adam Jon DeGrush
- Navigate by Date:
- Prev:
Re: Epics 3.13.5 supporting Windows 2000 ? Geoff Savage
- Next:
et_wish, threadInit and osiThread.h Benjamin Sailer
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
<2002>
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
CA client library and Connection handler Adam Jon DeGrush
- Next:
Re: CA client library and Connection handler Adam Jon DeGrush
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
<2002>
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|