Browse Source

Merge pull request #4305 from OpenNuvoton/revert-3293-fix_at

Revert "fix the bug that rx_notice out of sync when data received aft…
Bernard Xiong 4 years ago
parent
commit
fac97f1716
1 changed files with 10 additions and 12 deletions
  1. 10 12
      components/net/at/src/at_client.c

+ 10 - 12
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)
-    {
-        return result;
-    }
-    if(rt_device_read(client->device, 0, ch, 1) == 1)
-    {
-        return RT_EOK;
-    }
-    else
+    while (rt_device_read(client->device, 0, ch, 1) == 0)
     {
-        goto __retry;
+        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;
 }
 
 /**