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
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
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")
2. In the xxxDriver.cpp :
xxxDriver::xxxDriver(const char *portName,const char *IPPortName, const char *outputString)
: asynPortDriver(portName,
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 */
0, /* Default priority */
0) /* Default stack size*/
const char *functionName = "xxxDriver";
status=pasynOctetSyncIO->connect(IPPortName, 0, &pasynUserIPPort_, NULL);
printf("%s:%s:pasynOctetSyncIO->connect failure, status=%d\n",driverName, functionName, status);
int xxxDriverConfigure(const char *portName,const char *IPPortName, const char *outputString)
new xxxDriver(portName,IPPortName,outputString);
int Deviceopen=OpenSession(handle,"192.168.1.7:18881");
//int Deviceopen=OpenSession(handle,IPPortName); //portName? IPPortName? Device connect failed
printf("Device is found.\r\n");
printf("Channels number is:%d\r\n", Num);
printf("pisition1 is %s\r\n", buffer);
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.
|