SICS-593: Return 0 from the AsconReading state to ensure that SICS

progresses through tasks.
This commit is contained in:
Ferdi Franceschini
2013-05-13 08:40:30 +10:00
parent 0ab6b5f67f
commit 0f2df4a8fe
6 changed files with 41 additions and 25 deletions

View File

@@ -41,6 +41,21 @@ int GalilReading(Ascon *a) {
char chr, ch[2];
ret = AsconReadChar(a->fd, &chr);
if (ret > 0) {
a->start = DoubleTime();
} else if (ret < 0) {
AsconError(a, "ASC5", errno)
return 0;
} else if (ret == 0) {
if (a->timeout > 0) {
if (DoubleTime() - a->start > a->timeout) {
AsconError(a, "read timeout", 0);
/* a->state = AsconTimeout; */
}
}
return 0;
}
switch (chr) {
case ' ':
return AsconStdHandler(a);
@@ -52,12 +67,12 @@ int GalilReading(Ascon *a) {
a->state = AsconWriteStart;
a->responseValid=0;
a->wrPos = 0;
return 1;
return 0;
break;
case ':':
DynStringReplace(a->rdBuffer, "OK",0);
a->state = AsconReadDone;
return 1;
return 0;
break;
default:
/* Check for first digit of errorcode followed by error message */
@@ -68,9 +83,10 @@ int GalilReading(Ascon *a) {
DynStringInsert(a->rdBuffer, ch, 0);
a->state = AsconReadDone;
AsconError(a, GetCharArray(a->rdBuffer), 0);
return 1;
return 0;
}
}
/* Return 1 to read next char befor progressing to next task */
return 1;
}