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  <20232024  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  <20232024 
<== Date ==> <== Thread ==>

Subject: A question on usage of the IP parameter in Asyn
From: =?gb18030?b?QW1iZXI=?= via Tech-talk <tech-talk at aps.anl.gov>
To: "=?gb18030?b?dGVjaC10YWxr?=" <tech-talk at aps.anl.gov>
Date: Thu, 17 Aug 2023 16:48:58 +0800
Hello everyone,
      I write an IOC with asyn based on the template in <epics>/Support/asyn/testConnect.
     When I connect the device with a function in libxxxcontrol.so, I do not know how to use Parameter
     1.  The st.cmd file is like this:
      
      #!../../bin/linux-x86_64/xxxDriver

       < envPaths
    
        cd "${TOP}"
    
        dbLoadDatabase("./dbd/Driver.dbd")
        xxxDriver_registerRecordDeviceDriver(pdbbase)

        # Turn on asynTraceFlow and asynTraceError for global trace, i.e. no connected asynUser.
        drvAsynIPPortConfigure("IPPort","192.168.1.7:18881",0,0,1)
        xxxDriverConfigure("Port1", "IPPort", NULL)

        dbLoadRecords("./db/xxxDriver.db","P=QS,R=6300:,PORT=Port1,ADDR=0,TIMEOUT=1")
        dbLoadRecords("./db/asynRecord.db","P=QS,R=6300:,PORT=Port1,ADDR=0,OMAX=80,IMAX=80")
        iocInit()


     2.  In the xxxDriver.cpp :
        xxxDriver::xxxDriver(const char *portName,const char *IPPortName, const char *outputString)
           : asynPortDriver(portName,
                            1, /* maxAddr */
                            asynInt32Mask | asynFloat64Mask | asynFloat64ArrayMask | asynEnumMask | asynDrvUserMask, /* Interface mask */
                            asynInt32Mask | asynFloat64Mask | asynFloat64ArrayMask | asynEnumMask,  /* Interrupt mask */
                            0, /* asynFlags.  This driver does not block and it is not multi-device, so flag is 0 */
                            1, /* Autoconnect */
                            0, /* Default priority */
                            0) /* Default stack size*/
        {
                    asynStatus status;
                    int channelnum;
                    double position0;
                    const char *functionName = "xxxDriver";

                    status=pasynOctetSyncIO->connect(IPPortName, 0, &pasynUserIPPort_, NULL);
                    if (status) {
                           printf("%s:%s:pasynOctetSyncIO->connect failure, status=%d\n",driverName, functionName, status);

                   return;
                   }
                   ... ...
        }

        ... ...

      int xxxDriverConfigure(const char *portName,const char *IPPortName, const char *outputString)
        {

                new xxxDriver(portName,IPPortName,outputString);
                handle=Init();
                int Deviceopen=OpenSession(handle,"192.168.1.7:18881");
                //int Deviceopen=OpenSession(handle,IPPortName); //portName? IPPortName?  Device connect failed
                ... ...
                if (Deviceopen==1) {
                        printf("Device is found.\r\n");
                        printf("Channels number is:%d\r\n", Num);
                        printf("pisition1 is %s\r\n", buffer);
                }
               return(asynSuccess);
        }

 3.  My Question is: 
     in the xxxDriverConfigure( )£¬the IP address "192.168.1.7:18881"  is used directly in this sentence:  int Deviceopen=OpenSession(handle,"192.168.1.7:18881");

     If  I change the "192.168.1.7:18881" to be "IPPortName" or "portName" :  
     int Deviceopen=OpenSession(handle, IPPortName),  or  int Deviceopen=OpenSession(handle, portName);
     the device can't be connected.  The IPPortName or portName can not be substituted by "192.168.1.7:18881", though we have these two sentences in the st.cmd file:

        drvAsynIPPortConfigure("IPPort","192.168.1.7:18881",0,0,1)
        xxxDriverConfigure("Port1", "IPPort", NULL)

    Then I put the  "int Deviceopen=OpenSession(handle, IPPortName/portName)"  in the  xxxDriver::xxxDriver( ) function,    
    with location behind  "status=pasynOctetSyncIO->connect(IPPortName, 0, &pasynUserIPPort_, NULL);", the connection failed again.

   How can I use a parameter defined in the st.cmd instead of a detailed IP like "xxx.xxx.xxx.xxx"?
   Why can't I use the IPPortName or portName directly in the .cpp file? What's the correct usage of the two parameters?

   That's all.  Thank you very much for any of your reply.
Best reguards,
Kevin


Replies:
RE: A question on usage of the IP parameter in Asyn Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: Re: Questions about ca_search and ca_create_channel 김대영 via Tech-talk
Next: Dante D Peter Siddons 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  <20232024 
Navigate by Thread:
Prev: Re: Re: Questions about ca_search and ca_create_channel 김대영 via Tech-talk
Next: RE: A question on usage of the IP parameter in 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  <20232024 
ANJ, 17 Aug 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·