- changed OxiGet
- various bug fixes and improvements
This commit is contained in:
37
ease.c
37
ease.c
@ -158,7 +158,7 @@ int EaseHandler(EaseBase *eab) {
|
||||
ead->stopped = 0;
|
||||
ead->hwstate = HWIdle;
|
||||
if (FsmStop(eab->task, eab->doit)) {
|
||||
ParPrintf(eab, -1, "%s stopped", eab->p.name);
|
||||
ParPrintf(eab, eWarning, "%s stopped", eab->p.name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -203,7 +203,7 @@ int EaseHandler(EaseBase *eab) {
|
||||
if (ead) {
|
||||
if (eab->state == EASE_lost) {
|
||||
if (FsmStop(eab->task, eab->doit)) {
|
||||
ParPrintf(eab, -1, "stop %s caused by timeout", eab->p.name);
|
||||
ParPrintf(eab, eWarning, "stop %s caused by timeout", eab->p.name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -226,10 +226,26 @@ int EaseNextFullRead(EaseBase *eab) {
|
||||
return 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static long EaseSendIt(long pc, void *object) {
|
||||
EaseBase *eab = EaseBaseCast(object);
|
||||
|
||||
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||
EaseWrite(eab, eab->sendCmd);
|
||||
ParPrintf(eab, eWarning, "send cmd> %s", eab->sendCmd);
|
||||
eab->sendCmd = NULL;
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
ParPrintf(eab, eWarning, "response> %s", eab->ans);
|
||||
return 0; } /* FSM END ********************************************/
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int EaseCheckDoit(EaseBase *eab) {
|
||||
int i, n;
|
||||
|
||||
if (eab->todo == NULL) {
|
||||
if (eab->sendCmd != NULL) {
|
||||
eab->todo = EaseSendIt;
|
||||
return 1;
|
||||
}
|
||||
n = eab->maxflag / EASE_FLAGBITS;
|
||||
for (i=0; i<=n; i++) {
|
||||
if (eab->updateFlags[i]) {
|
||||
@ -367,18 +383,18 @@ static long EaseRun(void *obj, SConnection *pCon, float fVal) {
|
||||
|
||||
SCSave(&eab->p.conn, pCon);
|
||||
if (! eab->doit) {
|
||||
ParPrintf(ead, -1, "ERROR: missing run function %s", eab->p.name);
|
||||
ParPrintf(ead, eError, "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);
|
||||
ParPrintf(ead, eError, "ERROR: %s is not ready to run", eab->p.name);
|
||||
return 0;
|
||||
}
|
||||
if (FsmStop(eab->task, eab->doit)) {
|
||||
ParPrintf(ead, -1, "running %s cancelled", eab->p.name);
|
||||
ParPrintf(ead, eWarning, "running %s cancelled", eab->p.name);
|
||||
}
|
||||
if (eab->todo) {
|
||||
ParPrintf(ead, -1, "ERROR: %s busy", eab->p.name);
|
||||
ParPrintf(ead, eError, "ERROR: %s busy", eab->p.name);
|
||||
return 0;
|
||||
}
|
||||
ead->targetValue = fVal;
|
||||
@ -593,6 +609,7 @@ static int EaseInit(SConnection *pCon, EaseBase *eab, int argc, char *argv[],
|
||||
eab->cmdtime = 0;
|
||||
eab->version[0] = '\0';
|
||||
eab->maxflag = maxflag;
|
||||
eab->sendCmd = NULL;
|
||||
eab->updateFlags = calloc(maxflag / EASE_FLAGBITS + 1, sizeof (*eab->updateFlags));
|
||||
if (eab->updateFlags == NULL) {
|
||||
SCWrite(pCon, "out of memory", eError);
|
||||
@ -764,12 +781,8 @@ int EaseSend(void *object, void *userarg, int argc, char *argv[]) {
|
||||
|
||||
iret = EaseWaitRead(eab);
|
||||
if (iret >= 0) {
|
||||
term = eab->ser->sendTerminator;
|
||||
ParArg2Text(argc, argv, cmd, sizeof(cmd) - strlen(term));
|
||||
ParPrintf(eab, -2, "cmd: %s", cmd);
|
||||
strcat(cmd, term);
|
||||
iret = transactRS232(eab->ser, cmd, strlen(cmd),
|
||||
ans, sizeof ans);
|
||||
eab->sendCmd = ParArg2Text(argc, argv, NULL, 0);
|
||||
|
||||
ParPrintf(eab, -2, "ans: %s", ans);
|
||||
ParPrintf(eab, eValue, "%s", ans);
|
||||
}
|
||||
|
Reference in New Issue
Block a user