瀏覽代碼

Merge pull request #3293 from rgw5267/fix_at

fix the bug that rx_notice out of sync when data received after last rt_device_read() is zero
Bernard Xiong 4 年之前
父節點
當前提交
72bc0d8fad
共有 1 個文件被更改,包括 12 次插入10 次删除
  1. 12 10
      components/net/at/src/at_client.c

+ 12 - 10
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;
 }
 
 /**