RT-Thread / RT-Thread/rt-thread

at框架调用at_client_recv会引起串口接收数据冲突

Open
#6,814 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

at_client_para_init 初始化之后会创建client_parser线程,负责监听 rx 的数据 (at_client.c文件内)
client_parser
  -> at_recv_readline
   -> at_client_getchar(client, &ch, RT_WAITING_FOREVER);
    -> rt_device_read / rt_sem_take(client->rx_notice,..)

同时at组件对外开放以下接口(at.h文件内):

#define at_exec_cmd(resp, ...)                   at_obj_exec_cmd(at_client_get_first(), resp, __VA_ARGS__)
#define at_client_wait_connect(timeout)          at_client_obj_wait_connect(at_client_get_first(), timeout)
#define at_client_send(buf, size)                at_client_obj_send(at_client_get_first(), buf, size)
#define at_client_recv(buf, size, timeout)       at_client_obj_recv(at_client_get_first(), buf, size, timeout)
#define at_set_end_sign(ch)                      at_obj_set_end_sign(at_client_get_first(), ch)
#define at_set_urc_table(urc_table, table_sz)    at_obj_set_urc_table(at_client_get_first(), urc_table, table_sz)

如果调用 at_client_recv ,则也会在此函数内调用rt_sem_take(client->rx_notice,..)以及rt_device_read

此会导致两个线程争抢client->rx_notice信号量和对应串口 rx 的数据

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in at_client.c with the client_parser thread, at_recv_readline, and at_client_getchar, then compare that path with at_client_obj_recv exposed through the macros in at.h. Reproduce concurrent calls involving client->rx_notice and the serial device, and define done as preventing the two readers from competing for the same notification and received data.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.