diff options
| author | Bernard Xiong <[email protected]> | 2020-12-31 08:34:57 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-31 08:34:57 +0800 |
| commit | 72bc0d8fadc95eb9f006baf41244f4952ed6a3dd (patch) | |
| tree | c200e254c26e00f962f15de88f7a4d2c8facee03 /components/net/at/src | |
| parent | 5fd6aec3d16105b30d331f7f519e7c305eab0967 (diff) | |
| parent | 27b7e0d929642b883c1ed7884162f822f359c9e9 (diff) | |
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
Diffstat (limited to 'components/net/at/src')
| -rw-r--r-- | components/net/at/src/at_client.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index 788549392d..b9d0ee89cb 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; } /** |
