diff --git a/motor.c b/motor.c index 78eae618..c136d758 100644 --- a/motor.c +++ b/motor.c @@ -1180,6 +1180,16 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray); iRet = Tcl_Eval(pServ->pSics->pTcl,pCommand); return iRet; } + +static int CheckMotiMatch(const void* context, const void* pUserData) +{ + pMotInfo pMoti = (pMotInfo) pUserData; + SConnection *pCon = (SConnection*) context; + if (pMoti->pCon == pCon) + return 0; + return 1; +} + /*---------------------------------------------------------------------------- The wrapper function for a motor. Commands currently supported are: @@ -1280,6 +1290,7 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray); } pMoti->lastValue = fValue; + RemoveCallback3(self->pCall, InterestCallback, CheckMotiMatch, pCon); /* only this one */ lID = RegisterCallback(self->pCall, SCGetContext(pCon),MOTDRIVE, InterestCallback, pMoti, KillInfo); SCRegister(pCon,pSics, self->pCall,lID); @@ -1289,7 +1300,7 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray); } else if(strcmp(pCurrent->text,"uninterest") == 0) { - RemoveCallback2(self->pCall,pCon); + RemoveCallback3(self->pCall, InterestCallback, CheckMotiMatch, pCon); SCSendOK(pCon); DeleteTokenList(pList); return 1;