diff --git a/code/application/source/sf_app/code/source/ttyusb/sf_hal_ttyusb.c b/code/application/source/sf_app/code/source/ttyusb/sf_hal_ttyusb.c index 44714cea7..0f41aeb39 100755 --- a/code/application/source/sf_app/code/source/ttyusb/sf_hal_ttyusb.c +++ b/code/application/source/sf_app/code/source/ttyusb/sf_hal_ttyusb.c @@ -252,26 +252,37 @@ static SINT32 hal_ttyusb_read(SINT32 fd, SF_CHAR *recvBuf, SINT32 waitTime) static SINT32 hal_ttyusb_read(SINT32 fd, SF_CHAR *recvBuf, SINT32 waitTime) { //SF_PDT_PARAM_CFG_S *sfParam = sf_customer_param_get(); - SINT32 s32ret = 0; + SF_TTY_DATA_TYPE_S ttyData = { .waitMs = 1000, .len = 255/*Must wait for OK or error.*/, .lenMax = (GPRS_INFO_LINE_MAX-1), .cmp = "OK", .cmperr = "ERROR", .data = recvBuf}; + if(fd < 0) + { + MLOGE(" fd read fail!\n"); + return SF_FAILURE; + } + sf_hal_ttyusb2_read_buf(&ttyData); + return SF_SUCCESS; + #if 0 + SINT32 s32ret = 0; fd_set read_fds; struct timeval TimeoutVal; - //if(waitTime > 0) - // sf_sleep_ms(waitTime); + if(waitTime > 0) + { + sf_sleep_ms(waitTime); + // waitTime = 10;//200ms*10=2s + } if(fd < 0) { MLOGE(" fd read fail!\n"); return SF_FAILURE; } - //while(waitTime--) + // while(waitTime--) { - FD_ZERO(&read_fds); FD_SET(fd, &read_fds); TimeoutVal.tv_sec = 0; - TimeoutVal.tv_usec = 200000; + TimeoutVal.tv_usec = 10000; s32ret = select(fd + 1, &read_fds, NULL, NULL, &TimeoutVal); if (s32ret > 0) { @@ -287,17 +298,18 @@ static SINT32 hal_ttyusb_read(SINT32 fd, SF_CHAR *recvBuf, SINT32 waitTime) else if (s32ret < 0) { //MLOGE(" select failed\n"); return SF_FAILURE; - //continue; + // continue; } else if (0 == s32ret) { //MLOGW("FIFO select timeout [%d]\n",waitTime); return SF_FAILURE; - //continue; + // continue; } } return SF_SUCCESS; + #endif } #endif