- fixed an issue when trying to drive a device not yet started up
This commit is contained in:
36
ease.c
36
ease.c
@ -150,12 +150,19 @@ void EaseSavePars(void) {
|
|||||||
}
|
}
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
int EaseHandler(EaseBase *eab) {
|
int EaseHandler(EaseBase *eab) {
|
||||||
EaseDriv *ead;
|
EaseDriv *ead = EaseDrivCast(eab);;
|
||||||
int iret;
|
int iret;
|
||||||
|
|
||||||
ead = EaseDrivCast(eab);
|
|
||||||
|
|
||||||
EaseSavePars();
|
EaseSavePars();
|
||||||
|
if (ead && ead->stopped && ead->hwstate == HWBusy) {
|
||||||
|
ead->stopped = 0;
|
||||||
|
ead->hwstate = HWIdle;
|
||||||
|
if (FsmStop(eab->task, eab->doit)) {
|
||||||
|
ParPrintf(eab, -1, "%s stopped", eab->p.name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (eab->state == EASE_expect) {
|
if (eab->state == EASE_expect) {
|
||||||
if (eab->cmdtime !=0 && time(NULL) > eab->cmdtime + eab->p.period*2) {
|
if (eab->cmdtime !=0 && time(NULL) > eab->cmdtime + eab->p.period*2) {
|
||||||
snprintf(eab->msg, sizeof eab->msg, "no response since %d sec",
|
snprintf(eab->msg, sizeof eab->msg, "no response since %d sec",
|
||||||
@ -200,14 +207,6 @@ int EaseHandler(EaseBase *eab) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (ead->stopped && ead->hwstate == HWBusy) {
|
|
||||||
ead->stopped = 0;
|
|
||||||
ead->hwstate = HWIdle;
|
|
||||||
if (FsmStop(eab->task, eab->doit)) {
|
|
||||||
ParPrintf(eab, -1, "%s stopped", eab->p.name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (eab->state == EASE_lost) {
|
if (eab->state == EASE_lost) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -258,6 +257,7 @@ static long EaseIdle(long pc, void *object) {
|
|||||||
FsmCall(todo);
|
FsmCall(todo);
|
||||||
return __LINE__; case __LINE__: /**********************************/
|
return __LINE__; case __LINE__: /**********************************/
|
||||||
|
|
||||||
|
eab->startOk = 1;
|
||||||
rd:
|
rd:
|
||||||
/*
|
/*
|
||||||
if (eab->state == EASE_lost) {
|
if (eab->state == EASE_lost) {
|
||||||
@ -365,15 +365,20 @@ static long EaseRun(void *obj, SConnection *pCon, float fVal) {
|
|||||||
|
|
||||||
assert(ead );
|
assert(ead );
|
||||||
|
|
||||||
|
SCSave(&eab->p.conn, pCon);
|
||||||
if (! eab->doit) {
|
if (! eab->doit) {
|
||||||
ParPrintf(ead, -1, "missing run function %s", eab->p.name);
|
ParPrintf(ead, -1, "ERROR: missing run function %s", eab->p.name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!eab->startOk) {
|
||||||
|
ParPrintf(ead, -1, "ERROR: %s is not ready to run", eab->p.name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (FsmStop(eab->task, eab->doit)) {
|
if (FsmStop(eab->task, eab->doit)) {
|
||||||
ParPrintf(ead, -1, "running %s cancelled", eab->p.name);
|
ParPrintf(ead, -1, "running %s cancelled", eab->p.name);
|
||||||
}
|
}
|
||||||
if (eab->todo) {
|
if (eab->todo) {
|
||||||
ParPrintf(ead, -1, "%s busy", eab->p.name);
|
ParPrintf(ead, -1, "ERROR: %s busy", eab->p.name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ead->targetValue = fVal;
|
ead->targetValue = fVal;
|
||||||
@ -438,6 +443,9 @@ static int EaseCheckStatus(void *obj, SConnection *pCon) {
|
|||||||
|
|
||||||
assert(ead);
|
assert(ead);
|
||||||
SCSave(&ead->b.p.conn, pCon);
|
SCSave(&ead->b.p.conn, pCon);
|
||||||
|
if (ead->stopped) {
|
||||||
|
return HWIdle;
|
||||||
|
}
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
if (now > ead->timeout) {
|
if (now > ead->timeout) {
|
||||||
ParPrintf(obj, eWarning, "maxwait expired when driving %s", ead->b.p.name);
|
ParPrintf(obj, eWarning, "maxwait expired when driving %s", ead->b.p.name);
|
||||||
@ -500,6 +508,7 @@ static int EaseRestart(EaseBase *eab) {
|
|||||||
FsmStop(eab->task, eab->idle);
|
FsmStop(eab->task, eab->idle);
|
||||||
FsmRestartTask(eab->task, eab->idle);
|
FsmRestartTask(eab->task, eab->idle);
|
||||||
}
|
}
|
||||||
|
eab->startOk = 0;
|
||||||
eab->todo = eab->start;
|
eab->todo = eab->start;
|
||||||
eab->state = EASE_connecting;
|
eab->state = EASE_connecting;
|
||||||
iRet = initRS232WithFlags(eab->ser, 3);
|
iRet = initRS232WithFlags(eab->ser, 3);
|
||||||
@ -579,6 +588,7 @@ static int EaseInit(SConnection *pCon, EaseBase *eab, int argc, char *argv[],
|
|||||||
}
|
}
|
||||||
eab->ser = ser;
|
eab->ser = ser;
|
||||||
|
|
||||||
|
eab->startOk = 0;
|
||||||
eab->errCode = 0;
|
eab->errCode = 0;
|
||||||
eab->cmdtime = 0;
|
eab->cmdtime = 0;
|
||||||
eab->version[0] = '\0';
|
eab->version[0] = '\0';
|
||||||
|
3
ease.h
3
ease.h
@ -39,7 +39,7 @@ typedef struct {
|
|||||||
int errCode; /* error code of last operation. not changed on success */
|
int errCode; /* error code of last operation. not changed on success */
|
||||||
EaseState state;
|
EaseState state;
|
||||||
time_t cmdtime;
|
time_t cmdtime;
|
||||||
int syntax; /* not used in ease, may be used by the driver. used by oicom */
|
int syntax; /* not used in ease, may be used by the driver. used by oxinst.c */
|
||||||
char cmd[32];
|
char cmd[32];
|
||||||
char ans[64];
|
char ans[64];
|
||||||
char version[64];
|
char version[64];
|
||||||
@ -47,6 +47,7 @@ typedef struct {
|
|||||||
int maxflag;
|
int maxflag;
|
||||||
time_t readPeriod;
|
time_t readPeriod;
|
||||||
unsigned long *updateFlags;
|
unsigned long *updateFlags;
|
||||||
|
int startOk;
|
||||||
} EaseBase;
|
} EaseBase;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Reference in New Issue
Block a user