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  2009  2010  2011  <20122013  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  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: asynManager isConnected
From: <[email protected]>
To: <[email protected]>
Date: Tue, 17 Jul 2012 11:39:10 +0000
Hi,

Just posting a follow up to this problem. Mark suggested some additional tests I could do to diagnose it.

The original problem was that the pasynManager->isConnected() function was saying the IP port was connected even though I initialized it with a non-valid IP address.

What was happening was that I issued a asynOctetSyncIO->connect() call on the IP port, and then attempted to set the EOS parameters, which failed because the port wasn't connected. And then I disconnected the port, like this:

status = pasynOctetSyncIO->setInputEos(*ppasynUser, inputEos, strlen(inputEos) );
if (status) {
  asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
	      "drvPmacCreate: unable to set input EOS on %s: %s\n", 
	      port, (*ppasynUser)->errorMessage);
  pasynOctetSyncIO->disconnect(*ppasynUser);
  return status;
}

So, the asynUser structure was freed by asynManager. However, my pointer to it was still valid. So when another port was set up by asynPortDriver, and a new asynUser structure created, my pointer was pointing to this new structure. And since this new structure was connected ok, asynManager->isConnected() returned true.

Cheers,
Matt


> -----Original Message-----
> From: Mark Rivers [mailto:[email protected]]
> Sent: 02 June 2012 17:54
> To: J. Lewis Muir; Pearson, Matthew (DLSLtd,RAL,DIA)
> Cc: [email protected]
> Subject: RE: asynManager isConnected
> 
> > I don't know of a function in Asyn that allows one to determine
> > whether the IP socket is connected.  I always just determine
> > this based on the asynStatus returned from a read or write.  But
> > maybe there's a way that I don't know about?
> 
> pasynManager->isConnected() will tell you this.
> 
> It will return 1 when the underlying driver has most recently called
> pasynManager->exceptionConnect().  It will return 0 when the underlying
> driver has most recently called pasynManager->exceptionDisconnect().
> Note that it can take some time after an IP device is disconnected
> (network cable unplugged etc.) before the drvAsynIPPortDriver can
> determine that the device is disconnected and calls pasynManager-
> >exceptionDisconnect().  During this time the client will receive
> timeout messages, rather than disconnected messages.
> 
> To illustrate this, I have run the test program I posted in my last
> message with a 4'th case: the IP device is initially available, and
> then reboots, and becomes available again:
> 
> 2012/06/02 11:47:40.425 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:47:41.426 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:41.426 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:47:42.426 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:42.427 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:47:43.427 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:43.427 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:47:44.427 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:44.428 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:47:45.428 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:46.429 testConnect:pollerTask: error calling
> pasynOctetSyncIO->writeRead, status=1, error=newport-xps5:5001 timeout:
> Resource temporarily unavailable
> 2012/06/02 11:47:47.429 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:48.430 testConnect:pollerTask: error calling
> pasynOctetSyncIO->writeRead, status=1, error=newport-xps5:5001 timeout:
> Resource temporarily unavailable
> 2012/06/02 11:47:49.430 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:50.431 testConnect:pollerTask: error calling
> pasynOctetSyncIO->writeRead, status=1, error=newport-xps5:5001 timeout:
> Resource temporarily unavailable
> 2012/06/02 11:47:51.431 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:52.432 testConnect:pollerTask: error calling
> pasynOctetSyncIO->writeRead, status=1, error=newport-xps5:5001 timeout:
> Resource temporarily unavailable
> 2012/06/02 11:47:53.432 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:54.433 testConnect:pollerTask: error calling
> pasynOctetSyncIO->writeRead, status=1, error=newport-xps5:5001 timeout:
> Resource temporarily unavailable
> 2012/06/02 11:47:55.433 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:56.434 testConnect:pollerTask: error calling
> pasynOctetSyncIO->writeRead, status=1, error=newport-xps5:5001 timeout:
> Resource temporarily unavailable
> 2012/06/02 11:47:57.434 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:58.177 testConnect:pollerTask: error calling
> pasynOctetSyncIO->writeRead, status=3, error=newport-xps5:5001 read
> error: Connection reset by peer
> 2012/06/02 11:47:59.177 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:47:59.178 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:48:00.178 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:48:00.179 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:48:01.179 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:48:01.179 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 2012/06/02 11:48:02.179 testConnect:pollerTask: isConnected = 1
> 2012/06/02 11:48:02.180 testConnect:pollerTask: numWrite=26, wrote:
> FirmwareVersionGet(char *), numRead=60, response=0,XPS-Q8 Firmware
> Precision Platform V1.0.0 Beta 27,EndOfAPI
> 
> 
> Note that initially the device is connected, isConnected=1 and the I/O
> succeeds.  Then the device is rebooted.  For the next 10 seconds or so
> isConnected is still 1, but the I/O returns a timeout error and the
> error "Resource temporarily unavailable".  Then the device reconnects
> and things proceed normally.  If the device had remained off-line for
> longer eventually the IP driver would have detected that the device was
> not available and called pasynManager->exceptionDisconnect().  At that
> time isConnected would have been 0.
> 
> Mark
> 
> 
> 
> Mark
> ________________________________________
> From: [email protected] [[email protected]] on
> behalf of J. Lewis Muir [[email protected]]
> Sent: Friday, June 01, 2012 10:18 AM
> To: [email protected]
> Cc: [email protected]
> Subject: Re: asynManager isConnected
> 
> On 6/1/12 6:17 AM, [email protected] wrote:
> > Hi,
> >
> > I'm trying to use asynManager isConnected() to test whether or not an
> IP port is connected to a device. But I'm finding that isConnected()
> only seems to report the connected status of the asynUser structure to
> the underlying device.
> >
> > If I attempt to call drvAsynIPPort on an IP address that has nothing
> connected to it, the connection fails. Then I attempt to connect an
> asynUser to this port using asynOctetSyncIO connect(), which also
> fails. Then I call asynManager isConnected a few times, and I find that
> the first few calls return false, and then after iocInit it returns
> true. But still, in the background, asynManager is attempting to
> connect to the IP port via the autoConnect feature.
> >
> > Is this behaviour correct?
> >
> > I can get around it by maintaining connected status myself. But the
> documentation seems to indicate that isConnected() shouldn't return
> true if the IP port is not connected.
> 
> Hi, Matt.
> 
> I'm sure Mark Rivers or someone else will give a more helpful
> response, but I'll just share what I usually do.
> 
> If I want to write an IP client that handles connecting and
> disconnecting of an IP socket, I do the following:
> 
> 1. Ensure that auto-connect is disabled for the ASYN IP port
> 
> 2. Create and attach an asynUser to the ASYN port using
>    pasynOctetSyncIO->connect
> 
> 3. Create and attach an asynUser for the pasynCommonSyncIO
>    interface using pasynCommonSyncIO->connect
> 
> 4. Establish the IP socket connection (using the
>    pasynCommonSyncIO asynUser) using
>    pasynCommonSyncIO->connectDevice
> 
> 5. I can now use the pasynOctetSyncIO asynUser for reading and
>    writing on the IP socket.
> 
> If I don't want to handle connecting and disconnecting of an IP
> socket myself, I enable auto-connect for the ASYN port and don't
> make any attempt at connecting or disconnecting the IP socket
> since that would interfere with the auto-connect functionality.
> 
> I don't know of a function in Asyn that allows one to determine
> whether the IP socket is connected.  I always just determine
> this based on the asynStatus returned from a read or write.  But
> maybe there's a way that I don't know about?
> 
> Lewis

-- 
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
 





Replies:
RE: asynManager isConnected Mark Rivers
References:
asynManager isConnected matthew.pearson
Re: asynManager isConnected J. Lewis Muir
RE: asynManager isConnected Mark Rivers

Navigate by Date:
Prev: Fwd: RE: MAXvConfig() error in st.cmd Ron Sluiter
Next: RE: asynManager isConnected Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: asynManager isConnected Mark Rivers
Next: RE: asynManager isConnected Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·