- A couple of small fixes for memory and initialization problems.
This is to make valgrind happy
This commit is contained in:
@ -59,7 +59,7 @@
|
|||||||
if(pVar)
|
if(pVar)
|
||||||
{
|
{
|
||||||
fVal = pVar->pInter->GetValue(pVar->pObject,self->pCon);
|
fVal = pVar->pInter->GetValue(pVar->pObject,self->pCon);
|
||||||
pVar->fData[iP] = fVal;
|
AppendScanVar(pVar,fVal);
|
||||||
sprintf(pItem,"%-10.10s",pVar->Name);
|
sprintf(pItem,"%-10.10s",pVar->Name);
|
||||||
strcat(pHead,pItem);
|
strcat(pHead,pItem);
|
||||||
sprintf(pItem,"%-10.3f",fVal);
|
sprintf(pItem,"%-10.3f",fVal);
|
||||||
|
74
el734hp.c
74
el734hp.c
@ -57,6 +57,7 @@
|
|||||||
int oredMsr;
|
int oredMsr;
|
||||||
int posCount;
|
int posCount;
|
||||||
int runCount;
|
int runCount;
|
||||||
|
char errorReply[80];
|
||||||
} EL734Driv, *pEL734Driv;
|
} EL734Driv, *pEL734Driv;
|
||||||
/*------------------- error codes ----------------------------------*/
|
/*------------------- error codes ----------------------------------*/
|
||||||
#define BADADR -1
|
#define BADADR -1
|
||||||
@ -97,7 +98,10 @@ static int checkResponse(pEL734Driv self, char *pReply){
|
|||||||
self->errorCode = BADRNG;
|
self->errorCode = BADRNG;
|
||||||
}else if(strstr(pReply,"*es") != NULL){
|
}else if(strstr(pReply,"*es") != NULL){
|
||||||
self->errorCode = BADEMERG;
|
self->errorCode = BADEMERG;
|
||||||
|
}else if(strstr(pReply,"*ms") != NULL){
|
||||||
|
self->errorCode = BADSTP;
|
||||||
} else {
|
} else {
|
||||||
|
strncpy(self->errorReply,pReply,79);
|
||||||
self->errorCode = BADUNKNOWN;
|
self->errorCode = BADUNKNOWN;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -295,10 +299,11 @@ static void EL734Error(void *pData, int *iCode, char *error, int errLen){
|
|||||||
strncpy(error,"Bad range",errLen);
|
strncpy(error,"Bad range",errLen);
|
||||||
break;
|
break;
|
||||||
case BADUNKNOWN:
|
case BADUNKNOWN:
|
||||||
strncpy(error,"Unknown error condition",errLen);
|
snprintf(pBueffel,131,"Unknown response: %s",self->errorReply);
|
||||||
|
strncpy(error,pBueffel,errLen);
|
||||||
break;
|
break;
|
||||||
case BADSTP:
|
case BADSTP:
|
||||||
strncpy(error,"Motor is switeched off at motor controller",errLen);
|
strncpy(error,"Motor is switched off at motor controller",errLen);
|
||||||
break;
|
break;
|
||||||
case BADEMERG:
|
case BADEMERG:
|
||||||
strncpy(error,"Emergency stop is engaged, please release",errLen);
|
strncpy(error,"Emergency stop is engaged, please release",errLen);
|
||||||
@ -383,17 +388,62 @@ static int EL734Halt(void *pData){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static int EL734GetPar(void *self, char *name,
|
static int EL734GetPar(void *pData, char *name,
|
||||||
float *fValue){
|
float *fValue){
|
||||||
|
pEL734Driv self = NULL;
|
||||||
|
int status;
|
||||||
|
char pCommand[50],pReply[80];
|
||||||
|
|
||||||
|
self = (pEL734Driv)pData;
|
||||||
|
assert(self);
|
||||||
|
if(strcmp(name,"speed") == 0){
|
||||||
|
snprintf(pCommand,79,"J %d\r",self->iMotor);
|
||||||
|
status = transactRS232(self->controller,pCommand,strlen(pCommand),
|
||||||
|
pReply,79);
|
||||||
|
if(status != 1){
|
||||||
|
self->errorCode = status;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(!checkResponse(self,pReply)){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
sscanf(pReply,"%f",fValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static int EL734SetPar(void *self, SConnection *pCon,
|
static int EL734SetPar(void *pData, SConnection *pCon,
|
||||||
char *name, float newValue){
|
char *name, float newValue){
|
||||||
|
pEL734Driv self = NULL;
|
||||||
|
int status;
|
||||||
|
char pCommand[50],pReply[80];
|
||||||
|
|
||||||
|
self = (pEL734Driv)pData;
|
||||||
|
assert(self);
|
||||||
|
if(strcmp(name,"speed") == 0){
|
||||||
|
snprintf(pCommand,79,"J %d %d\r",self->iMotor,(int)newValue);
|
||||||
|
status = transactRS232(self->controller,pCommand,strlen(pCommand),
|
||||||
|
pReply,79);
|
||||||
|
if(status != 1){
|
||||||
|
self->errorCode = status;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(!checkResponse(self,pReply)){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static void EL734List(void *self, char *name, SConnection *pCon){
|
static void EL734List(void *self, char *name, SConnection *pCon){
|
||||||
|
float value;
|
||||||
|
char pBueffel[256];
|
||||||
|
|
||||||
|
EL734GetPar(self,"speed",&value);
|
||||||
|
snprintf(pBueffel,255,"%s speed = %f",name,value);
|
||||||
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
@ -409,7 +459,7 @@ MotorDriver *CreateEL734HP(SConnection *pCon, int argc, char *argv[]){
|
|||||||
pEL734Driv pNew = NULL;
|
pEL734Driv pNew = NULL;
|
||||||
int motor, status;
|
int motor, status;
|
||||||
prs232 controller = NULL;
|
prs232 controller = NULL;
|
||||||
char pCommand[50],pReply[80];
|
char pCommand[50],pReply[80], pError[255];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
check arguments
|
check arguments
|
||||||
@ -461,13 +511,21 @@ MotorDriver *CreateEL734HP(SConnection *pCon, int argc, char *argv[]){
|
|||||||
snprintf(pCommand,49,"h %d\r",pNew->iMotor);
|
snprintf(pCommand,49,"h %d\r",pNew->iMotor);
|
||||||
status = transactRS232(pNew->controller, pCommand,strlen(pCommand),
|
status = transactRS232(pNew->controller, pCommand,strlen(pCommand),
|
||||||
pReply,79);
|
pReply,79);
|
||||||
if(!status){
|
if(status != 1){
|
||||||
SCWrite(pCon,"ERROR: failed to read HW limits, defaulting..",eError);
|
SCWrite(pCon,"ERROR: failed to read HW limits, defaulting..",eError);
|
||||||
|
getRS232Error(status,pReply,79);
|
||||||
|
snprintf(pError,255,"ERROR: %s",pReply);
|
||||||
|
SCWrite(pCon,pError,eError);
|
||||||
pNew->fLower = -180.;
|
pNew->fLower = -180.;
|
||||||
pNew->fUpper = 180.;
|
pNew->fUpper = 180.;
|
||||||
} else {
|
} else {
|
||||||
if(checkResponse(pNew,pReply)){
|
if(checkResponse(pNew,pReply)){
|
||||||
sscanf(pReply,"%f %f",&pNew->fLower,&pNew->fUpper);
|
if(sscanf(pReply,"%f %f",&pNew->fLower,&pNew->fUpper)!= 2){
|
||||||
|
snprintf(pError,255,
|
||||||
|
"ERROR: received shitty HW limit response from SICS: %s",
|
||||||
|
pReply);
|
||||||
|
SCWrite(pCon,pError,eError);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SCWrite(pCon,
|
SCWrite(pCon,
|
||||||
"ERROR: invalid response when reading HW limits, defaulting..",
|
"ERROR: invalid response when reading HW limits, defaulting..",
|
||||||
@ -476,6 +534,8 @@ MotorDriver *CreateEL734HP(SConnection *pCon, int argc, char *argv[]){
|
|||||||
pNew->fUpper = 180.;
|
pNew->fUpper = 180.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
snprintf(pError,255,"EL734 returned HW-limits of: %s", pReply);
|
||||||
|
SCWrite(pCon,pError,eError);
|
||||||
return (MotorDriver *)pNew;
|
return (MotorDriver *)pNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
psi.c
2
psi.c
@ -443,7 +443,7 @@ static pEVControl InstallPsiEnvironmentController(SicsInterp *pSics,
|
|||||||
pDriv = CreateEL755Driv(argc-4,&argv[4]);
|
pDriv = CreateEL755Driv(argc-4,&argv[4]);
|
||||||
if(pDriv != NULL){
|
if(pDriv != NULL){
|
||||||
pNew = CreateEVController(pDriv,argv[2],&status);
|
pNew = CreateEVController(pDriv,argv[2],&status);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprintf(pBueffel,"ERROR: %s not recognized as a valid driver type", argv[3]);
|
sprintf(pBueffel,"ERROR: %s not recognized as a valid driver type", argv[3]);
|
||||||
SCWrite(pCon,pBueffel,eError);
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
18
tasscan.c
18
tasscan.c
@ -30,6 +30,7 @@
|
|||||||
#include <scan.i>
|
#include <scan.i>
|
||||||
#include "tas.h"
|
#include "tas.h"
|
||||||
#include "tasu.h"
|
#include "tasu.h"
|
||||||
|
#include "../scanvar.h"
|
||||||
#include <evcontroller.h>
|
#include <evcontroller.h>
|
||||||
#include <splitter.h>
|
#include <splitter.h>
|
||||||
#include <status.h>
|
#include <status.h>
|
||||||
@ -233,9 +234,9 @@ static int TASHeader(pScanData self)
|
|||||||
pVar = (pVarEntry)pPtr;
|
pVar = (pVarEntry)pPtr;
|
||||||
if(pVar)
|
if(pVar)
|
||||||
{
|
{
|
||||||
strncpy(pWork2,pVar->Name,59);
|
strncpy(pWork2,ScanVarName(pVar),59);
|
||||||
strtoupper(pWork2);
|
strtoupper(pWork2);
|
||||||
sprintf(pWork,"D%s=%8.4f, ",pWork2,pVar->fStep);
|
sprintf(pWork,"D%s=%8.4f, ",pWork2,ScanVarStep(pVar));
|
||||||
strcat(pBueffel,pWork);
|
strcat(pBueffel,pWork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -514,9 +515,9 @@ static int TASScanPoint(pScanData self, int iPoint)
|
|||||||
pVar = (pVarEntry)pPtr;
|
pVar = (pVarEntry)pPtr;
|
||||||
if(pVar)
|
if(pVar)
|
||||||
{
|
{
|
||||||
if(isTASMotor(pVar->Name) >= 0)
|
if(isTASMotor(ScanVarName(pVar)) >= 0)
|
||||||
{
|
{
|
||||||
pMot = FindMotor(self->pSics,pVar->Name);
|
pMot = FindMotor(self->pSics,ScanVarName(pVar));
|
||||||
if(pMot)
|
if(pMot)
|
||||||
{
|
{
|
||||||
status = MotorGetSoftPosition(pMot,self->pCon,&fVal);
|
status = MotorGetSoftPosition(pMot,self->pCon,&fVal);
|
||||||
@ -648,13 +649,13 @@ static int TASScanDrive(pScanData self, int iPoint)
|
|||||||
if(pVar)
|
if(pVar)
|
||||||
{
|
{
|
||||||
/* set variable if QE-variable */
|
/* set variable if QE-variable */
|
||||||
if((iPtr = isTASEnergy(pVar->Name)) >= 0)
|
if((iPtr = isTASEnergy(ScanVarName(pVar))) >= 0)
|
||||||
{
|
{
|
||||||
iTAS = 1;
|
iTAS = 1;
|
||||||
pTAS->tasPar[EI+iPtr]->fVal =
|
pTAS->tasPar[EI+iPtr]->fVal =
|
||||||
pVar->fStart + iPoint * pVar->fStep;
|
ScanVarStart(pVar) + iPoint * ScanVarStep(pVar);
|
||||||
pTAS->tasPar[ETARGET+iPtr]->fVal =
|
pTAS->tasPar[ETARGET+iPtr]->fVal =
|
||||||
pVar->fStart + iPoint * pVar->fStep;
|
ScanVarStart(pVar) + iPoint * ScanVarStep(pVar);
|
||||||
tasMask[iPtr] = 1;
|
tasMask[iPtr] = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -836,7 +837,7 @@ static int TASScanCount(pScanData self, int iPoint)
|
|||||||
MotorGetSoftPosition(pMot,self->pCon,&fVal);
|
MotorGetSoftPosition(pMot,self->pCon,&fVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pVar->fData[iPoint] = fVal;
|
AppendScanVar(pVar,fVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,7 +930,6 @@ static int AddTASScanVar(pScanData self, SicsInterp *pSics, SConnection *pCon,
|
|||||||
pVar.pObject = pData;
|
pVar.pObject = pData;
|
||||||
pVar.fStart = fStart;
|
pVar.fStart = fStart;
|
||||||
pVar.fStep = fStep;
|
pVar.fStep = fStep;
|
||||||
pVar.fData = NULL;
|
|
||||||
|
|
||||||
/* put it away */
|
/* put it away */
|
||||||
DynarPutCopy(self->pScanVar,self->iScanVar,&pVar,sizeof(VarEntry));
|
DynarPutCopy(self->pScanVar,self->iScanVar,&pVar,sizeof(VarEntry));
|
||||||
|
Reference in New Issue
Block a user