SICS-593: Return 0 from the AsconReading state to ensure that SICS
progresses through tasks.
This commit is contained in:
@@ -41,6 +41,21 @@ int GalilReading(Ascon *a) {
|
|||||||
char chr, ch[2];
|
char chr, ch[2];
|
||||||
|
|
||||||
ret = AsconReadChar(a->fd, &chr);
|
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) {
|
switch (chr) {
|
||||||
case ' ':
|
case ' ':
|
||||||
return AsconStdHandler(a);
|
return AsconStdHandler(a);
|
||||||
@@ -52,12 +67,12 @@ int GalilReading(Ascon *a) {
|
|||||||
a->state = AsconWriteStart;
|
a->state = AsconWriteStart;
|
||||||
a->responseValid=0;
|
a->responseValid=0;
|
||||||
a->wrPos = 0;
|
a->wrPos = 0;
|
||||||
return 1;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
DynStringReplace(a->rdBuffer, "OK",0);
|
DynStringReplace(a->rdBuffer, "OK",0);
|
||||||
a->state = AsconReadDone;
|
a->state = AsconReadDone;
|
||||||
return 1;
|
return 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Check for first digit of errorcode followed by error message */
|
/* Check for first digit of errorcode followed by error message */
|
||||||
@@ -68,9 +83,10 @@ int GalilReading(Ascon *a) {
|
|||||||
DynStringInsert(a->rdBuffer, ch, 0);
|
DynStringInsert(a->rdBuffer, ch, 0);
|
||||||
a->state = AsconReadDone;
|
a->state = AsconReadDone;
|
||||||
AsconError(a, GetCharArray(a->rdBuffer), 0);
|
AsconError(a, GetCharArray(a->rdBuffer), 0);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Return 1 to read next char befor progressing to next task */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,10 +161,10 @@ int LFGenReading(Ascon *a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (a->timeout > 0) {
|
if (a->timeout > 0) {
|
||||||
if (DoubleTime() - a->start > 0.05) { //a->timeout) {
|
if (DoubleTime() - a->start > 0.05) {
|
||||||
AsconError(a, "read timeout", 0);
|
AsconError(a, "read timeout", 0);
|
||||||
a->state = AsconTimeout;
|
/* a->state = AsconTimeout; */
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = AsconReadChar(a->fd, &chr);
|
ret = AsconReadChar(a->fd, &chr);
|
||||||
@@ -210,7 +210,7 @@ int LFGenReading(Ascon *a)
|
|||||||
|
|
||||||
free(lfchar);
|
free(lfchar);
|
||||||
//DynStringConcatChar(a->rdBuffer, '\0');
|
//DynStringConcatChar(a->rdBuffer, '\0');
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LFGenProtHandler(Ascon *a)
|
int LFGenProtHandler(Ascon *a)
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ int ModbusReading(Ascon *a) {
|
|||||||
DynStringClear(a->rdBuffer);
|
DynStringClear(a->rdBuffer);
|
||||||
DynStringConcatBytes(a->rdBuffer, temp, rlen);
|
DynStringConcatBytes(a->rdBuffer, temp, rlen);
|
||||||
a->state = AsconReadDone;
|
a->state = AsconReadDone;
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = AsconReadChar(a->fd, &chr);
|
ret = AsconReadChar(a->fd, &chr);
|
||||||
@@ -249,7 +249,7 @@ int ModbusReading(Ascon *a) {
|
|||||||
if (a->timeout > 0) {
|
if (a->timeout > 0) {
|
||||||
if (DoubleTime() - a->start > a->timeout) {
|
if (DoubleTime() - a->start > a->timeout) {
|
||||||
AsconError(a, "read timeout", 0);
|
AsconError(a, "read timeout", 0);
|
||||||
a->state = AsconTimeout;
|
/* a->state = AsconTimeout; */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ int OrdHVPSReading(Ascon *a) {
|
|||||||
if (DynStringConcatChar(a->rdBuffer, chr) == 0) {
|
if (DynStringConcatChar(a->rdBuffer, chr) == 0) {
|
||||||
a->state = AsconReadDone;
|
a->state = AsconReadDone;
|
||||||
AsconError(a, "DynStringConcatChar failed:", ENOMEM);
|
AsconError(a, "DynStringConcatChar failed:", ENOMEM);
|
||||||
return 1;
|
return 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,20 +307,20 @@ int OrdHVPSReading(Ascon *a) {
|
|||||||
if (a->timeout > 0) {
|
if (a->timeout > 0) {
|
||||||
if (DoubleTime() - a->start > a->timeout) {
|
if (DoubleTime() - a->start > a->timeout) {
|
||||||
AsconError(a, "read timeout", 0);
|
AsconError(a, "read timeout", 0);
|
||||||
a->state = AsconTimeout;
|
/* a->state = AsconTimeout; */
|
||||||
return 1;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rsp_len = GetDynStringLength(a->rdBuffer);
|
rsp_len = GetDynStringLength(a->rdBuffer);
|
||||||
if (OrdFmtReply(GetCharArray(a->rdBuffer), rsp_len, response, errmsg) >= 0) {
|
if (OrdFmtReply(GetCharArray(a->rdBuffer), rsp_len, response, errmsg) >= 0) {
|
||||||
DynStringReplace(a->rdBuffer,response,0);
|
DynStringReplace(a->rdBuffer,response,0);
|
||||||
return 1;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
AsconError(a, errmsg, 0);
|
AsconError(a, errmsg, 0);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ int Protek608Reading(Ascon *a)
|
|||||||
snprintf(errMsg, ERRLEN, "PROTEK608: Unexpected value %X for last byte:", chr);
|
snprintf(errMsg, ERRLEN, "PROTEK608: Unexpected value %X for last byte:", chr);
|
||||||
AsconError(a, errMsg, 0);
|
AsconError(a, errMsg, 0);
|
||||||
}
|
}
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
transByteStatus = translateByte(a->private, chr, (a->readState)++, field);
|
transByteStatus = translateByte(a->private, chr, (a->readState)++, field);
|
||||||
if (transByteStatus == 1) {
|
if (transByteStatus == 1) {
|
||||||
@@ -392,22 +392,22 @@ int Protek608Reading(Ascon *a)
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
AsconError(a, "PROTEK608: AsconReadChar failed:", errno);
|
AsconError(a, "PROTEK608: AsconReadChar failed:", errno);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
if (DS_AllocFailed || transByteFailed) {
|
if (DS_AllocFailed || transByteFailed) {
|
||||||
a->state = AsconReadDone;
|
a->state = AsconReadDone;
|
||||||
a->readState = 0;
|
a->readState = 0;
|
||||||
data->first = 1;
|
data->first = 1;
|
||||||
AsconError(a, errMsg, errNum);
|
AsconError(a, errMsg, errNum);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
if (a->timeout > 0) {
|
if (a->timeout > 0) {
|
||||||
if (DoubleTime() - a->start > a->timeout) {
|
if (DoubleTime() - a->start > a->timeout) {
|
||||||
AsconError(a, "PROTEK608: read timeout", 0);
|
AsconError(a, "PROTEK608: read timeout", 0);
|
||||||
a->state = AsconTimeout;
|
/* a->state = AsconTimeout; */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ int RFAmpReading (Ascon *a)
|
|||||||
}
|
}
|
||||||
a->state = AsconReadDone;
|
a->state = AsconReadDone;
|
||||||
}
|
}
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
if (0 == DynStringConcatChar(a->rdBuffer, chr)) {
|
if (0 == DynStringConcatChar(a->rdBuffer, chr)) {
|
||||||
strcpy(errMsg, "ANSRFAMP: DynStringConcatChar failed:");
|
strcpy(errMsg, "ANSRFAMP: DynStringConcatChar failed:");
|
||||||
@@ -295,7 +295,7 @@ int RFAmpReading (Ascon *a)
|
|||||||
}
|
}
|
||||||
if (rdChRet < 0) {
|
if (rdChRet < 0) {
|
||||||
AsconError(a, "ANSRFAMP: AsconReadChar failed:", errno);
|
AsconError(a, "ANSRFAMP: AsconReadChar failed:", errno);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
if (GetReplyFailed) {
|
if (GetReplyFailed) {
|
||||||
a->state = AsconReadDone;
|
a->state = AsconReadDone;
|
||||||
@@ -303,15 +303,15 @@ int RFAmpReading (Ascon *a)
|
|||||||
a->readState = 0;
|
a->readState = 0;
|
||||||
data->transactInProg = txNormalRead;
|
data->transactInProg = txNormalRead;
|
||||||
AsconError(a, errMsg, errNum);
|
AsconError(a, errMsg, errNum);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
if (a->timeout > 0) {
|
if (a->timeout > 0) {
|
||||||
if (DoubleTime() - a->start > a->timeout) {
|
if (DoubleTime() - a->start > a->timeout) {
|
||||||
a->state = AsconTimeout;
|
/* a->state = AsconTimeout; */
|
||||||
AsconError(a, "ANSRFAMP: read timeout", 0);
|
AsconError(a, "ANSRFAMP: read timeout", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user