1.tty usb打开关闭优化
This commit is contained in:
parent
34cd4c1cf5
commit
02884fd430
|
@ -97,9 +97,8 @@ SINT32 app_ttyusb_IsOpen(void) {
|
|||
int retryTime = 0;
|
||||
int retryFlag = 0;
|
||||
static SINT32 s32ret = SF_SUCCESS;
|
||||
static int flag = 0;
|
||||
|
||||
if((flag) && (sf_get_ttyusb_flag()))
|
||||
if(sf_get_ttyusb_flag() >= 0)
|
||||
{
|
||||
return s32ret;
|
||||
}
|
||||
|
@ -142,14 +141,25 @@ SINT32 app_ttyusb_IsOpen(void) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
flag = 1;
|
||||
|
||||
MLOGD("e\n");
|
||||
return s32ret;
|
||||
}
|
||||
|
||||
SINT32 sf_ttyusb_restart(void)
|
||||
{
|
||||
SINT32 ret = 0;
|
||||
SINT32 ret = -1;
|
||||
UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
|
||||
|
||||
if(strncmp(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q, 6) == 0)
|
||||
{
|
||||
//eg915q
|
||||
}
|
||||
else
|
||||
{
|
||||
system("killall quectel-CM-EG91");
|
||||
}
|
||||
|
||||
ret = sf_hal_ttyusb2_deinit();
|
||||
if (ret != 0)
|
||||
{
|
||||
|
|
|
@ -210,6 +210,12 @@ static SINT32 hal_ttyusb_write(SINT32 fd, SF_CHAR *sendBuf, SINT32 dataLen)
|
|||
{
|
||||
SINT32 len = 0;
|
||||
|
||||
if(fd < 0)
|
||||
{
|
||||
MLOGE(" fd write fail!\n");
|
||||
return SF_FAILURE;
|
||||
}
|
||||
|
||||
len = write(fd,sendBuf,dataLen);
|
||||
if (len == dataLen )
|
||||
{
|
||||
|
@ -252,6 +258,11 @@ static SINT32 hal_ttyusb_read(SINT32 fd, SF_CHAR *recvBuf, SINT32 waitTime)
|
|||
//if(waitTime > 0)
|
||||
// sf_sleep_ms(waitTime);
|
||||
|
||||
if(fd < 0)
|
||||
{
|
||||
MLOGE(" fd read fail!\n");
|
||||
return SF_FAILURE;
|
||||
}
|
||||
//while(waitTime--)
|
||||
{
|
||||
|
||||
|
@ -304,7 +315,7 @@ static SINT32 hal_ttyusb_create(SF_CHAR *ttyusbName,SF_SERIAL_DATA_FRAME_TYPE_S
|
|||
usleep(100000);//100ms
|
||||
}
|
||||
|
||||
if(*pttyfd <= 0)
|
||||
if(*pttyfd == -1)
|
||||
return SF_FAILURE;
|
||||
|
||||
ret = hal_ttyusb_config(*pttyfd,pSerialAttr);
|
||||
|
@ -318,7 +329,7 @@ static SINT32 hal_ttyusb_create(SF_CHAR *ttyusbName,SF_SERIAL_DATA_FRAME_TYPE_S
|
|||
}
|
||||
static SINT32 hal_ttyusb_destory(SINT32 fd)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret = -1;
|
||||
int count = 0;
|
||||
|
||||
while ((ret = close(fd)) < 0)
|
||||
|
@ -366,7 +377,7 @@ SINT32 sf_hal_ttyusb2_read(SF_CHAR *recvBuf, SINT32 waitMs)
|
|||
}
|
||||
SINT32 sf_hal_ttyusb2_deinit(void)
|
||||
{
|
||||
SINT32 ret = 0;
|
||||
SINT32 ret = -1;
|
||||
|
||||
if(TtyUSB2Fd < 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user