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> 2025 | 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> 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | RE: Managing connections with asyn |
From: | Mark Rivers via Tech-talk <tech-talk at aps.anl.gov> |
To: | Marco Filho <marco.filho at ess.eu>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Cc: | George Kontogiorgos <george.kontogiorgos at ess.eu> |
Date: | Thu, 8 Aug 2024 20:36:17 +0000 |
Hi Marco, My previous message had some typing errors. It should read: To connect to the device, i.e. open the socket, you need to call asynCommonSyncIO->connectDevice(), which calls asynCommon->connect(). I realize this
is quite confusing, but it is explained in the documentation for asynCommonSyncIO which says: Mark From: Tech-talk <tech-talk-bounces at aps.anl.gov>
On Behalf Of Mark Rivers via Tech-talk Hi Marco, The documentation is here:
https://epics-modules.github.io/asyn/asynDriver.html asynManager is the low-level C code for asyn. It is used to register asyn port drivers, connect asyn clients to the ports, and provide standard interfaces for asyn clients to communicate
with asyn port drivers. asynUser is a C structure that is passed to asyn methods. It is associated with a particular asyn port driver and address. pasynManager->connectDevice(). This is the documentation for that function:
So this method just associates the asynUser structure with a particular asyn port and address. pasynCommon->connect() Connect to the hardware device or communication path. The queueRequest must specify priority asynQueuePriorityConnect. This is a function that is implemented by the port driver. When it is called it attempts to connect to the underlying device. For an IP port it tries to open the socket. If it succeeds
it calls pasynManager->exceptionConnect() to signal to asynManager that the port is connected and ready to accept queueRequests. You called
pasynOctetSyncIO->connect(). That function results in a call to pasynManager->connectDevice(), NOT a call to pasynCommon->connect(). So it just disconnects the pasynUser from the asyn port driver, it does not close the socket. To disconnect from the device, i.e. close the socket, you need to call asynCommonSyncIO->connectDevice(), which calls asynCommon->connect(). I realize this is quite confusing,
but it is explained in the documentation for asynCommonSyncIO which says: asynCommonSyncIO provides a convenient interface for software that needs to perform “synchronous” operations to an asyn device, i.e. that blocks while
waiting for the port to be available and for the operation to complete. The code does not need to handle callbacks or understand the details of the asynManager and asynCommon interfaces. Note that there is a potential for confusion in the connect* and disconnect* function names of this interface. For consistency with the other SyncIO
interfaces, connect calls pasynManager->connectDevice, disconnect calls pasynManager->disconnect, connectDevice calls asynCommon->connect, and disconnectDevice calls asynCommon->disconnect. I think your code should be changed to this: asynUser* pAsynUserOctet_, pasynUserCommon_; pasynCommonSyncIO->connectDevice(pasynUserCommon_); // This opens the socket pasynCommonSyncIO->disconnect(name, 0, &pAsynUserOctet_, NULL); // This disconnects the asynUser from the port, not strictly necessary Mark From: Tech-talk <tech-talk-bounces at aps.anl.gov>
On Behalf Of Marco Filho via Tech-talk Hi! printf("###########");
drvAsynIPPortConfigure("LOCALHOST", "127.0.0.1:65432", 0, 1, 0) (...) # echo-server.py |