Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoconnect with ASYN_MULTIDEVICE #186

Open
xiaoqiangwang opened this issue Jun 15, 2023 · 1 comment
Open

autoconnect with ASYN_MULTIDEVICE #186

xiaoqiangwang opened this issue Jun 15, 2023 · 1 comment

Comments

@xiaoqiangwang
Copy link
Contributor

When I test a model-3 asynMotor driver, I notice the asynMotorController::connect method was not invoked by reconnect timer.

Use the testAsynPortDriver driver with the following changes, the problem can be reproduced, i.e. no periodic printout of "connect" message. Without ASYN_MULTIDEVICE flag, the reconnection timer works.

diff --git a/testAsynPortDriverApp/src/testAsynPortDriver.cpp b/testAsynPortDriverApp/src/testAsynPortDriver.cpp
index 359c89a8..22a91f90 100644
--- a/testAsynPortDriverApp/src/testAsynPortDriver.cpp
+++ b/testAsynPortDriverApp/src/testAsynPortDriver.cpp
@@ -51,7 +51,7 @@ testAsynPortDriver::testAsynPortDriver(const char *portName, int maxPoints)
                     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 */
+                    ASYN_CANBLOCK|ASYN_MULTIDEVICE, /* 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*/
@@ -123,9 +123,15 @@ testAsynPortDriver::testAsynPortDriver(const char *portName, int maxPoints)
         printf("%s:%s: epicsThreadCreate failure\n", driverName, functionName);
         return;
     }
-}
 
+    this->disconnect(pasynUserSelf);
+}
 
+asynStatus testAsynPortDriver::connect(asynUser *pasynUser)
+{
+    printf("connect\n");
+    return asynDisconnected;
+}
 
 void simTask(void *drvPvt)
 {
diff --git a/testAsynPortDriverApp/src/testAsynPortDriver.h b/testAsynPortDriverApp/src/testAsynPortDriver.h
index c9deb4a3..959b376f 100644
--- a/testAsynPortDriverApp/src/testAsynPortDriver.h
+++ b/testAsynPortDriverApp/src/testAsynPortDriver.h
@@ -54,6 +54,7 @@ public:
                                         size_t nElements, size_t *nIn);
     virtual asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[],
                                 size_t nElements, size_t *nIn);
+    virtual asynStatus connect(asynUser *pasynUser);
 
     /* These are the methods that are new to this class */
     void simTask(void);
@xiaoqiangwang
Copy link
Contributor Author

The reconnection timer is only initiated by asynManager->exceptionDisconnect. If the port was never connected, it will reach an early return and the timer would not start.

if(!pdpCommon->connected) {
epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
"%s addr %d asynManager:exceptionDisconnect but not connected",
pport->portName, (puserPvt->pdevice ? puserPvt->pdevice->addr : -1));
return asynError;
}

It is somewhat related to #147.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant