From 27b7e0d929642b883c1ed7884162f822f359c9e9 Mon Sep 17 00:00:00 2001 From: 任光伟 Date: Thu, 26 Dec 2019 00:46:38 +0800 Subject: 解决在判断接收字节为0与RESET信号量之间接收到数据时,导致此次数据无法被处理的bug。 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RGW --- components/net/at/src/at_client.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'components') diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index ba4009738d..9dd731535a 100644 --- a/components/net/at/src/at_client.c +++ b/components/net/at/src/at_client.c @@ -434,18 +434,20 @@ static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeo { rt_err_t result = RT_EOK; - while (rt_device_read(client->device, 0, ch, 1) == 0) +__retry: + result = rt_sem_take(client->rx_notice, rt_tick_from_millisecond(timeout)); + if (result != RT_EOK) { - rt_sem_control(client->rx_notice, RT_IPC_CMD_RESET, RT_NULL); - - result = rt_sem_take(client->rx_notice, rt_tick_from_millisecond(timeout)); - if (result != RT_EOK) - { - return result; - } + return result; + } + if(rt_device_read(client->device, 0, ch, 1) == 1) + { + return RT_EOK; + } + else + { + goto __retry; } - - return RT_EOK; } /** -- cgit v1.3.1