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: RE: A question on usage of the IP parameter in Asyn
From: Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
To: Amber <279762081 at qq.com>, tech-talk <tech-talk at aps.anl.gov>
Date: Thu, 17 Aug 2023 15:53:38 +0000

Hi Kevin,

 

        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.

 

The string “IPPort” which is passed to your driver as IPPortName is not the string 192.168.1.7:18881.  It is the string “IPPort”, and is the name of a new asynIPPort driver you created with the first line above.  In your case you are actually not using that asynIPPort driver at all.  You can simply your startup script and driver like this:

 

< envPaths

cd "${TOP}"

dbLoadDatabase("./dbd/Driver.dbd")

xxxDriver_registerRecordDeviceDriver(pdbbase)

epicsEnvSet("IPPort","192.168.1.7:18881")

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

 

Remove these lines from your driver, you don’t need them:

 

                    status=pasynOctetSyncIO->connect(IPPortName, 0, &pasynUserIPPort_, NULL);

                    if (status) {

                           printf("%s:%s:pasynOctetSyncIO->connect failure, status=%d\n",driverName, functionName, status);

 

                   return;

 

In the Configure function you can now use this line:

               int Deviceopen=OpenSession(handle,IPPortName);

 

Mark

 

 

From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Amber via Tech-talk
Sent: Thursday, August 17, 2023 3:49 AM
To: tech-talk <tech-talk at aps.anl.gov>
Subject: A question on usage of the IP parameter in Asyn

 

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

 


References:
A question on usage of the IP parameter in Asyn =?gb18030?b?QW1iZXI=?= via Tech-talk

Navigate by Date:
Prev: Re: Dante Mark Rivers via Tech-talk
Next: Re: Dante Siddons, David 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: A question on usage of the IP parameter in Asyn =?gb18030?b?QW1iZXI=?= 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 
ANJ, 18 Aug 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·