add timeout parameter in protocol
r3694 | jgn | 2012-08-07 12:03:23 +1000 (Tue, 07 Aug 2012) | 1 line
This commit is contained in:
committed by
Douglas Clowes
parent
1993aa2c11
commit
15fdda1deb
@@ -143,22 +143,32 @@ int LFGenReading(Ascon *a)
|
||||
//BYTE HEAD, LEN, CTRL, CRC=0, *Data=NULL;
|
||||
|
||||
// Read HEAD info
|
||||
usleep(1000*50);
|
||||
ret = AsconReadChar(a->fd, &chr);
|
||||
while (ret>0) {
|
||||
HEAD = (BYTE)chr;
|
||||
if (HEAD!=0x96) {
|
||||
a->start = DoubleTime();
|
||||
if(ret<0) {
|
||||
AsconError(a, "AsconReadChar failed in Head Info reading in LFGenReading:", 0);
|
||||
//a->state = AsconReadDone;
|
||||
return 0;
|
||||
} else {
|
||||
while (ret>=0) {
|
||||
if(ret>0) {
|
||||
HEAD = (BYTE)chr;
|
||||
if (HEAD==0x96) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (a->timeout > 0) {
|
||||
if (DoubleTime() - a->start > 0.05) { //a->timeout) {
|
||||
AsconError(a, "read timeout", 0);
|
||||
a->state = AsconTimeout;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
ret = AsconReadChar(a->fd, &chr);
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if(ret<0) {
|
||||
AsconError(a, "AsconReadChar failed in Head Info reading in LFGenReading:", 0);
|
||||
//a->state = AsconReadDone;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read LEN info
|
||||
ret = AsconReadChar(a->fd, &chr);
|
||||
|
||||
Reference in New Issue
Block a user