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  2014  2015  2016  2017  <20182019  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  <20182019 
<== Date ==> <== Thread ==>

Subject: Re: {ASYN} How to detect autoconnect or disconnect
From: Mark Rivers <rivers@cars.uchicago.edu>
To: "matic.pogacnik@diamond.ac.uk" <matic.pogacnik@diamond.ac.uk>, "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Fri, 5 Oct 2018 12:02:51 +0000
Hi Matic,


>  Is there a way to specify a callback which gets called when reconnect is successful?


Yes, look at the definition of asynManager here:

https://epics.anl.gov/modules/soft/asyn/R4-34/asynDriver.html

It defines:
      typedef void (*exceptionCallback)(asynUser *pasynUser,asynException exception);
and
      pasynManager->exceptionCallbackAdd().

You will get a callback whenever an exception occurs.  Your callback needs to test what type of exception it is.  You are interested in asynExceptionConnect, and you need to call pasynManager->isConnected() to determine if it is a connect or disconnect callback.

You can look at asyn/asynRecord/asynRecord.c to see an example of using pasynManager->exceptionCallbackAdd().

>  pasynManager->isConnected() seems to be always 1 for me, even after few minutes when the device is off.

That is a function of the underlying OS.  For drvAsynIPPort isConnected()=No means that the OS has closed the socket.  On Linux this can take quite a long time.  On Windows it is faster.  I assume one can change these settings by I have not tried to do that.

You should consider using the asynSetOption(port, 0, "disconnectOnReadTimeout", "Y")

This will cause the port to disconnect when there is a read timeout.  If you use exceptionCallbackAdd() then you will get a callback each time a read operation to the device times out.  Your callback can then try to reconnect, and if successful send the initialization string.

Mark


________________________________
From: tech-talk-bounces@aps.anl.gov <tech-talk-bounces@aps.anl.gov> on behalf of matic.pogacnik@diamond.ac.uk <matic.pogacnik@diamond.ac.uk>
Sent: Friday, October 5, 2018 3:53 AM
To: tech-talk@aps.anl.gov
Subject: {ASYN} How to detect autoconnect or disconnect

Hi,

I have a device to which I must send the configuration of the data format in which I want the data to be sent to me when the connection is established otherwise all commands are ignored. Which represents a problem when a device is power-cycled and IOC keep running.

Basically, I'm between two options but none of them work for me somehow:

Autoconnect is ON: I'm not getting any data from the device as configuration was not send when reconnect happened. Is there a way to specify a callback which gets called when reconnect is successful?

Autoconnect is OFF: How to detect that device was lost to call connect() function again (and send configuration)? pasynManager->isConnected() seems to be always 1 for me, even after few minutes when the device is off.

I'm using asyn version 4-31.

Thank you,
Matic


--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom


References:
{ASYN} How to detect autoconnect or disconnect matic.pogacnik@diamond.ac.uk

Navigate by Date:
Prev: Re: Building epics base for a different location Jeong Han Lee
Next: Re: Linux network tuning Fors, Thomas L.
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  <20182019 
Navigate by Thread:
Prev: {ASYN} How to detect autoconnect or disconnect matic.pogacnik@diamond.ac.uk
Next: PV alias with logical names Bo Jakobsen
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  <20182019 
ANJ, 05 Oct 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·