- New batch file management module
- New oscillator module - Bug fixes
This commit is contained in:
@@ -36,6 +36,7 @@ typedef struct {
|
||||
int lastStatus; /* need to remember last status, otherwise I get oscillating
|
||||
NoBeam and Counting status if the beam goes off
|
||||
*/
|
||||
char *badReply;
|
||||
} EL737hp, *pEL737hp;
|
||||
/*--------------------- ERROR CODES -------------------------------------*/
|
||||
#define OFFLINE -1
|
||||
@@ -48,6 +49,13 @@ typedef struct {
|
||||
#define BADREPLY -10
|
||||
#define SELECTFAIL -11
|
||||
#define TIMEOUT737 -12
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void setBadReply(pEL737hp self, char *reply){
|
||||
if(self->badReply != NULL){
|
||||
free(self->badReply);
|
||||
}
|
||||
self->badReply = strdup(reply);
|
||||
}
|
||||
/*-----------------------------------------------------------------------
|
||||
search errors in a reply from the EL737. Returns 1 on success or a
|
||||
negative error code in case of trouble.
|
||||
@@ -136,6 +144,7 @@ static int readRS(pEL737hp pPriv, int *RS){
|
||||
status = sscanf(reply,"%d",RS);
|
||||
if(status < 1){
|
||||
pPriv->errorCode = BADREPLY;
|
||||
setBadReply(pPriv,reply);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -196,6 +205,7 @@ static int updateMonitors(struct __COUNTER *self){
|
||||
status = sscanf(reply,"%d %d %d %d %f",&m1,&m2,&m3,&m4,&fTime);
|
||||
if(status != 5){
|
||||
pPriv->errorCode = BADREPLY;
|
||||
setBadReply(pPriv,reply);
|
||||
printf("Bad reply to EL737 RA command: %s\n", reply);
|
||||
return 0;
|
||||
}
|
||||
@@ -399,7 +409,8 @@ static int EL737GetError(struct __COUNTER *self, int *iCode,
|
||||
strncpy(pError,"EL737 has an internal system error",errLen);
|
||||
break;
|
||||
case BADREPLY:
|
||||
strncpy(pError,"EL737 sent an unexpected reply",errLen);
|
||||
snprintf(pError,errLen,"EL737 sent an unexpected reply: %s",
|
||||
pPriv->badReply);
|
||||
break;
|
||||
case SELECTFAIL:
|
||||
strncpy(pError,"select system call failed, network trouble",errLen);
|
||||
@@ -415,13 +426,14 @@ static int EL737FixIt(struct __COUNTER *self, int iCode){
|
||||
pEL737hp pPriv = NULL;
|
||||
int status;
|
||||
char pReply[50];
|
||||
char buffer[256];
|
||||
int dataLen = 255;
|
||||
|
||||
assert(self);
|
||||
pPriv = (pEL737hp)self->pData;
|
||||
|
||||
switch(iCode){
|
||||
case TIMEOUT:
|
||||
case BADREPLY:
|
||||
case BADPARAM:
|
||||
case NOPARAM:
|
||||
case BADRANGE:
|
||||
@@ -429,6 +441,17 @@ static int EL737FixIt(struct __COUNTER *self, int iCode){
|
||||
case TIMEOUT737:
|
||||
return COREDO;
|
||||
break;
|
||||
case BADREPLY:
|
||||
/*
|
||||
try to read away all the garbage which may still be in the line
|
||||
*/
|
||||
if(availableRS232(pPriv->controller) > 0){
|
||||
memset(buffer,0,256);
|
||||
readRS232(pPriv->controller,buffer,&dataLen);
|
||||
printf("EL737hpdriv dumped %s after bad reply\n", buffer);
|
||||
}
|
||||
return COREDO;
|
||||
break;
|
||||
case OFFLINE:
|
||||
EL737Command(pPriv,"RMT 1\r",pReply,49);
|
||||
EL737Command(pPriv,"echo 2\r",pReply,49);
|
||||
@@ -527,6 +550,9 @@ static void KillHP(pCounterDriver self){
|
||||
if(pPriv->controller != NULL){
|
||||
KillRS232(pPriv->controller);
|
||||
}
|
||||
if(pPriv->badReply != NULL){
|
||||
free(pPriv->badReply);
|
||||
}
|
||||
free(pPriv);
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user