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