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  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025  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  <20242025 
<== Date ==> <== Thread ==>

Subject: Managing connections with asyn
From: Marco Filho via Tech-talk <tech-talk at aps.anl.gov>
To: "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 14:54:42 +0000

Hi!

I have kind of a simple question that has persisted for a long time about managing connections with asyn. For several reasons, I want my module to manage the connection and disconnection to the device.

For a minimalistic example, I created a python socket server with code copied from the internet that I append at the end of this e-mail. With an st.cmd file that has:

drvAsynIPPortConfigure("LOCALHOST", "127.0.0.1:65432", 0, 0, 0)

My python server prints:
Connected by ('127.0.0.1', 39696)

And returns the terminal once the client disconnects.
I then tried starting my asyn port with no autoconnect option:

drvAsynIPPortConfigure("LOCALHOST", "127.0.0.1:65432", 0, 1, 0)

And the python server doesn't print anything. In my module code, I passed the port name as an argument to the ADDriver constructor and tried to connect with it trough the code:

    printf("###########");
    asynUser* pAsynUser_;
    pasynOctetSyncIO->connect(name, 0, &pAsynUser_, NULL);
    pasynManager->disconnect(pAsynUser_);
    printf("###########");

But when I execute the IOC i get nothing in my python port. My ioc terminal prints:
(...)
drvAsynIPPortConfigure("LOCALHOST", "127.0.0.1:65432", 0, 1, 0)
MyDriverConfig("MYPORT", "LOCALHOST", 1000, 1000, 1, 0, 0)
###########
###########
(...)

I am still struggling with this because I clearly don't fully understand the differences between asynManager, asynUser, SyncIO, etc...
I looked at the examples in the asyn module and in ADmythen module, but they all use asyn AutoConnect (or maybe I missed something). They are good for showing how to write and read trough the code, but I wasn't able to understand how to disconnect and conenct to the port's IP.

Can someone explain what am I doing wrong?

Thanks in advance :)

--------------------------------------

Python server:

# echo-server.py

import socket

HOST = "127.0.0.1"  # Standard loopback interface address (localhost)
PORT = 65432  # Port to listen on (non-privileged ports are > 1023)

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind((HOST, PORT))
    s.listen()
    conn, addr = s.accept()
    with conn:
        print(f"Connected by {addr}")
        while True:
            data = "">             if not data:
                break
            conn.sendall(data)


Replies:
RE: Managing connections with asyn Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: How to use CSS script? Yendell, Gary (DLSLtd, RAL, LSCI) via Tech-talk
Next: RE: Managing connections with asyn Mark Rivers via Tech-talk
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  <20242025 
Navigate by Thread:
Prev: RE: How to use CSS script? Zhang, Tong via Tech-talk
Next: RE: Managing connections with asyn Mark Rivers via Tech-talk
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  <20242025 
ANJ, 11 Sep 2024 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·