diff --git a/site_ansto/hardsup/sct_rfamp.c b/site_ansto/hardsup/sct_rfamp.c index f97b4ba9..15cb62c1 100644 --- a/site_ansto/hardsup/sct_rfamp.c +++ b/site_ansto/hardsup/sct_rfamp.c @@ -44,6 +44,7 @@ struct RFAmpData { int targetCurrent; char rfCmd[16]; char statusCmd[5]; + int currTol; }; void RFAmpKill(void *private) @@ -206,7 +207,7 @@ int RFAmpReading (Ascon *a) if (data->transactInProg == txPreSet) { data->transactInProg = txPostSet; - if (abs(data->targetCurrent - atoi(curr)) <= 5) { + if (abs(data->targetCurrent - atoi(curr)) <= (5 + data->currTol)) { DynStringReplaceWithLen(a->wrBuffer, data->rfCmd,0, SCMDLEN); a->state = AsconWriting; a->noResponse = 0; @@ -225,9 +226,9 @@ int RFAmpReading (Ascon *a) strncpy(tmpFreq, &data->rfCmd[5], 3); tmpSwitchs = (unsigned char)data->rfCmd[8]; - if( (atoi(curr) != atoi(tmpCurr)) || + if( (abs(atoi(curr) - atoi(tmpCurr)) > data->currTol) || (atoi(freq) != atoi(tmpFreq)) || - ((switches & 0x7F) != (tmpSwitchs & 0x7F)) ) { + ((switches & 0x0F) != (tmpSwitchs & 0x0F)) ) { strcpy(errMsg, "ANSRFAMP: the (S)ET command failed"); GetReplyFailed = 1; break; @@ -316,6 +317,7 @@ int RFAmpInit(Ascon *a, SConnection *con, int argc, char *argv[]) data->targetCurrent = 0; data->rfCmd[0] = '\0'; data->statusCmd[0] = '\0'; + data->currTol = 1; /* TODO This should be a configuration parameter */ a->killPrivate = RFAmpKill; return AsconStdInit(a, con, argc, argv); }