解决在判断接收字节为0与RESET信号量之间接收到数据时,导致此次数据无法被处理的bug。

Signed-off-by: RGW <rgw5267@gmail.com>
This commit is contained in:
任光伟 2019-12-26 00:46:38 +08:00 committed by RGW
parent dd23a36713
commit 27b7e0d929
1 changed files with 12 additions and 10 deletions

View File

@ -434,19 +434,21 @@ static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeo
{ {
rt_err_t result = RT_EOK; rt_err_t result = RT_EOK;
while (rt_device_read(client->device, 0, ch, 1) == 0) __retry:
{
rt_sem_control(client->rx_notice, RT_IPC_CMD_RESET, RT_NULL);
result = rt_sem_take(client->rx_notice, rt_tick_from_millisecond(timeout)); result = rt_sem_take(client->rx_notice, rt_tick_from_millisecond(timeout));
if (result != RT_EOK) if (result != RT_EOK)
{ {
return result; return result;
} }
} if(rt_device_read(client->device, 0, ch, 1) == 1)
{
return RT_EOK; return RT_EOK;
} }
else
{
goto __retry;
}
}
/** /**
* AT client receive fixed-length data. * AT client receive fixed-length data.