EPICS Home

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: Mark Rivers <[email protected]>
To: "J. Lewis Muir" <[email protected]>, "[email protected]" <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Sat, 2 Jun 2012 16:54:28 +0000
> 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


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

Navigate by Date:
Prev: RE: asynManager isConnected Mark Rivers
Next: Re: mbbi/mbbo Mask values Ralph Lange
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 matthew.pearson
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