1.修复tty读取不完整的问题
This commit is contained in:
parent
409b49d5dd
commit
93990c03a1
|
@ -430,23 +430,25 @@ SINT32 sf_hal_ttyusb2_read_buf(SF_TTY_DATA_TYPE_S *recv)
|
||||||
TimeoutVal.tv_sec = 0;
|
TimeoutVal.tv_sec = 0;
|
||||||
TimeoutVal.tv_usec = (recv->waitMs)*1000;
|
TimeoutVal.tv_usec = (recv->waitMs)*1000;
|
||||||
|
|
||||||
while(waitTime--)
|
while(waitTime)
|
||||||
{
|
{
|
||||||
s32ret = select(TtyUSB2Fd + 1, &read_fds, NULL, NULL, &TimeoutVal);
|
s32ret = select(TtyUSB2Fd + 1, &read_fds, NULL, NULL, &TimeoutVal);
|
||||||
if (s32ret > 0) {
|
if (s32ret > 0) {
|
||||||
if (FD_ISSET(TtyUSB2Fd, &read_fds)) {
|
if (FD_ISSET(TtyUSB2Fd, &read_fds)) {
|
||||||
s32ret = read(TtyUSB2Fd, recv->data+dataL, recv->lenMax);
|
s32ret = read(TtyUSB2Fd, recv->data+dataL, recv->lenMax);
|
||||||
dataL += strlen(recv->data);
|
dataL += strlen(recv->data);
|
||||||
if ((((dataL) >= (recv->len)) && (strstr(recv->data, recv->cmp))) || (strstr(recv->data, recv->cmperr))) {
|
if (((dataL) >= (recv->len)) || (strstr(recv->data, recv->cmp)) || (strstr(recv->data, recv->cmperr))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (s32ret < 0) {
|
else if (s32ret < 0) {
|
||||||
|
waitTime--;
|
||||||
MLOGE(" select failed\n");
|
MLOGE(" select failed\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (0 == s32ret) {
|
else if (0 == s32ret) {
|
||||||
|
waitTime--;
|
||||||
MLOGW("FIFO select timeout [%d]\n",waitTime);
|
MLOGW("FIFO select timeout [%d]\n",waitTime);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user