diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index 7227a1c2..f618839b 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -38,7 +38,9 @@ int readRS232(prs232 self, /*@out@*/void *data, /*@out@*/int *dataLen); int readRS232TillTerm(prs232 self, /*@out@*/void *data, int *datalen); void KillRS232(/*@only@*/ void *pData); -/*@observer@*/ char *Tcl_GetVar2(Tcl_Interp *interp, char *name1, char *name2, int flags); +/* Storage returned by Tcl_GetVar2 is owned by the Tcl interpreter and should not be modified */ +/*@observer@*//*@dependent@*/ char *Tcl_GetVar2(Tcl_Interp *interp, char *name1, char *name2, int flags); +/* The pointer to the Tcl interpreter is owned by SICS and should not be modified */ /*@observer@*//*@dependent@*/ Tcl_Interp *InterpGetTcl(SicsInterp *pSics); /*@+incondefs@*/ /*----------------------------------------------------------------------- @@ -49,24 +51,22 @@ typedef struct __MoDriv { /* general motor driver interface fields. _REQUIRED! */ - /*@-incondefs@*/ float fUpper; /* upper limit */ float fLower; /* lower limit */ - /*@owned@*/char *name; - int (*GetPosition)(/*@dependent@*/void *self, float *fPos); - int (*RunTo)(/*@dependent@*/void *self, float fNewVal); - int (*GetStatus)(/*@dependent@*/void *self); - void (*GetError)(/*@dependent@*/void *self, int *iCode, char *buffer, int iBufLen); - int (*TryAndFixIt)(/*@dependent@*/void *self,int iError, float fNew); - int (*Halt)(/*@dependent@*/void *self); - int (*GetDriverPar)(/*@dependent@*/void *self, char *name, + char *name; + int (*GetPosition)(void *self, float *fPos); + int (*RunTo)(void *self, float fNewVal); + int (*GetStatus)(void *self); + void (*GetError)(void *self, int *iCode, char *buffer, int iBufLen); + int (*TryAndFixIt)(void *self,int iError, float fNew); + int (*Halt)(void *self); + int (*GetDriverPar)(void *self, char *name, float *value); - int (*SetDriverPar)(/*@dependent@*/void *self,SConnection *pCon, + int (*SetDriverPar)(void *self,SConnection *pCon, char *name, float newValue); - void (*ListDriverPar)(/*@dependent@*/void *self, char *motorName, + void (*ListDriverPar)(void *self, char *motorName, SConnection *pCon); - void (*KillPrivate)(/*@dependent@*/void *self); - /*@+incondefs@*/ + void (*KillPrivate)(/*@only@*/void *self); /* DMC-2280 specific fields */ @@ -133,14 +133,14 @@ typedef struct __MoDriv { #define DECEL "decel" #define MAXDECEL "maxDecel" -static int DMC2280Receive(/*@dependent@*/pDMC2280Driv self, /*@out@*/ char *reply); +static int DMC2280Receive(pDMC2280Driv self, /*@out@*/ char *reply); /** \brief Convert motor speed from physical units to steps/sec * \param self (r) provides access to the motor's data structure * \param speed in physical units, eg mm/sec degrees/sec * \return the speed in motor steps/sec */ -static int motSpeed(/*@dependent@*/pDMC2280Driv self, float speed) { +static int motSpeed(pDMC2280Driv self, float speed) { int motSpeed; motSpeed = abs((int)(speed * self->stepsPerX + 0.5)); return motSpeed; @@ -151,7 +151,7 @@ static int motSpeed(/*@dependent@*/pDMC2280Driv self, float speed) { * \param acceleration in physical units, eg mm/sec^2 degrees/sec^2 * \return the acceleration in motor steps/sec^2 */ -static int motAccel(/*@dependent@*/pDMC2280Driv self, float accel) { +static int motAccel(pDMC2280Driv self, float accel) { int motAccel; motAccel = abs((int)(accel * self->stepsPerX + 0.5)); return motAccel; @@ -162,7 +162,7 @@ static int motAccel(/*@dependent@*/pDMC2280Driv self, float accel) { * \param deceleration in physical units, eg mm/sec^2 degrees/sec^2 * \return the deceleration in motor steps/sec^2 */ -static int motDecel(/*@dependent@*/pDMC2280Driv self, float decel) { +static int motDecel(pDMC2280Driv self, float decel) { int motDecel; motDecel = abs((int)(decel * self->stepsPerX + 0.5)); return motDecel; @@ -178,7 +178,7 @@ static int motDecel(/*@dependent@*/pDMC2280Driv self, float decel) { * - FAILURE * \see SUCCESS FAILURE */ -static int DMC2280ReadChar(/*@dependent@*/pDMC2280Driv self, /*@out@*/char *reply) { +static int DMC2280ReadChar(pDMC2280Driv self, /*@out@*/char *reply) { int i, status, retries=20, dataLen=1; reply[0] = '\0'; for (i=0; ilastCmd, command, CMDLEN); + if ((self->lastCmd) != command) { + /*@-mayaliasunique@ this won't happen unless they overlap */ + strncpy(self->lastCmd, command, CMDLEN); + /*@+mayaliasunique@*/ + } + /*@+matchanyintegral@ let size_t from strlen match int */ status = writeRS232(self->controller, command, strlen(command)); /*@-matchanyintegral@*/ @@ -268,7 +273,7 @@ static int DMC2280Send(/*@dependent@*/pDMC2280Driv self, /*@observer@*//*@depend * - FAILURE * \see SUCCESS FAILURE */ -static int DMC2280Receive(/*@dependent@*/pDMC2280Driv self, /*@out@*/char *reply) { +static int DMC2280Receive(pDMC2280Driv self, /*@out@*/char *reply) { int i, status, retries=20, dataLen=255; reply[0] = '\0'; for (i=0; iaxisLabel); @@ -785,7 +790,7 @@ static void KillDMC2280(/*@only@*/void *pData){ self = (pDMC2280Driv)pData; assert(self != NULL); free(self->name); - /*@-temptrans@*/ free(self); /*@+temptrans@*/ + free(self); return; } /*@only@*/ prs232 createRS232(char *host, int iPort); @@ -831,9 +836,9 @@ static void KillDMC2280(/*@only@*/void *pData){ * possible values * - _REQUIRED * - _OPTIONAL - * \return a string with the parameter value + * \return (r) a reference to a string representation of the parameter value */ -/*@observer@*/static char *getParam(/*@dependent@*/SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave ) { +/*@observer@*/ static char *getParam(/*@dependent@*/SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave ) { char *pPtr=NULL; char pError[ERRLEN]; pPtr = Tcl_GetVar2(pTcl,params,parName,TCL_GLOBAL_ONLY); @@ -885,7 +890,7 @@ static void KillDMC2280(/*@only@*/void *pData){ pNew->controller = NULL; pNew->name = NULL; pNew->errorCode = 0; - pNew->lastCmd = NULL; + pNew->lastCmd[0] = '\0'; pNew->absEncHome = 0; pNew->cntsPerX = 0; /* Get hostname and port from the list of named parameters */