From a50d81827a1a4d7172e761dd64cecc5553f349d9 Mon Sep 17 00:00:00 2001 From: Wayne Date: Thu, 4 Feb 2021 22:53:58 +0800 Subject: [PATCH 1/2] Revert "fix the bug that rx_notice out of sync when data received after last rt_device_read() is zero" --- components/net/at/src/at_client.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index b9d0ee89cb..788549392d 100644 --- a/components/net/at/src/at_client.c +++ b/components/net/at/src/at_client.c @@ -434,20 +434,18 @@ static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeo { rt_err_t result = RT_EOK; -__retry: - result = rt_sem_take(client->rx_notice, rt_tick_from_millisecond(timeout)); - if (result != RT_EOK) + while (rt_device_read(client->device, 0, ch, 1) == 0) { - return result; - } - if(rt_device_read(client->device, 0, ch, 1) == 1) - { - return RT_EOK; - } - else - { - goto __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)); + if (result != RT_EOK) + { + return result; + } } + + return RT_EOK; } /** From eaacc0ae3e90eb381cad6e42183902f466eecdad Mon Sep 17 00:00:00 2001 From: Wayne Lin Date: Tue, 2 Mar 2021 10:42:40 +0800 Subject: [PATCH 2/2] Optimize getc flow. --- components/net/at/src/at_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index 788549392d..f46abd5cd4 100644 --- a/components/net/at/src/at_client.c +++ b/components/net/at/src/at_client.c @@ -436,13 +436,13 @@ static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeo while (rt_device_read(client->device, 0, ch, 1) == 0) { - 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; } + + rt_sem_control(client->rx_notice, RT_IPC_CMD_RESET, RT_NULL); } return RT_EOK;