- improvements in protocols and drivers

This commit is contained in:
zolliker
2012-06-19 07:19:03 +00:00
parent 6c69b59fce
commit 86d225a714
13 changed files with 243 additions and 95 deletions

View File

@ -68,7 +68,9 @@ int OxiHandler(void *object)
if (eab->state < EASE_idle)
goto quit;
if (availableNetRS232(eab->ser) || availableRS232(eab->ser)) {
eab->msg[0] = '\0';
if (strncmp(eab->msg, "ERROR:", 6) != 0) {
eab->msg[0] = '\0';
}
l = sizeof(eab->ans);
iret = readRS232TillTerm(eab->ser, eab->ans, &l);
if (eab->state != EASE_expect && eab->state != EASE_lost) {
@ -82,8 +84,8 @@ int OxiHandler(void *object)
if (strcmp(eab->ans, "??ck") == 0) {
if (eab->state == EASE_lost) {
EaseWrite(eab, "V");
goto quit;
}
goto quit;
} else if (eab->state == EASE_lost) {
goto quit;
} else if (eab->cmd[0] == 'V') {
@ -100,14 +102,14 @@ int OxiHandler(void *object)
goto quit;
} else if (eab->cmd[2] == 'k') { /* ?ck */
} else {
eab->tmo = 120; /* long timeout: the user may block the response with the adjust keys */
if (eab->syntax <= -8) {
eab->tmo = 20; /* long timeout: the user may block the response with the adjust keys */
if (eab->syntax <= -8) { /* OLDIGH */
corr = OxiCorrect(eab->ans);
if (corr) {
// ParPrintf(eab, eWarning, "corrected bad response from IGH: %s", corr);
/* ParPrintf(eab, eWarning, "corrected bad response from IGH: %s", corr); */
}
}
if (eab->cmd[0] != eab->ans[0]) {
if (eab->cmd[0] != eab->ans[0] && eab->cmd[0] != '{') {
iret = EASE_ILL_ANS;
}
}
@ -119,6 +121,11 @@ int OxiHandler(void *object)
}
eab->state = EASE_read;
} else if (eab->state == EASE_expect) {
if (time(NULL) > eab->chktime) {
writeRS232(eab->ser, "?ck", 3);
ParPrintf(eab, -2, "cmd: ?ck");
eab->chktime = time(NULL);
}
if (time(NULL) > eab->cmdtime + eab->tmo) {
eab->state = EASE_lost;
}
@ -177,7 +184,7 @@ void OxiSet(EaseBase * eab, char *cmd, double val, int dig)
f = fabs(val);
if (f < 1.0)
f = 1.0;
dig = 5 - log10(f);
dig = 7 - log10(f);
if (dig < 0)
dig = 0;
}