-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[component][net][at] at_client增加deInit接口 #10598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
📌 Code Review Assignment🏷️ Tag: componentsReviewers: Maihuanyi Changed Files (Click to expand)
🏷️ Tag: components_net_atReviewers: Ryan-CW-Code lizhen9880 Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-08-18 22:58 CST)
📝 Review Instructions
|
上面实现中,at_client_rx_ind使用了 更新: 已修改为轮询方式 |
CI错误都是at_device软件包的报错,合并此PR后会对at_device提PR |
@Rbb666 |
我研究下 |
@@ -41,7 +47,7 @@ extern rt_size_t at_vprintfln(rt_device_t device, char *send_buf, rt_size_t buf_ | |||
extern rt_size_t at_vprintf(rt_device_t device, char *send_buf, rt_size_t buf_size, const char *format, va_list args); | |||
extern rt_size_t at_vprintfcr(rt_device_t device, char *send_buf, rt_size_t buf_size, const char *format, va_list args); | |||
extern rt_size_t at_vprintflf(rt_device_t device, char *send_buf, rt_size_t buf_size, const char *format, va_list args); | |||
extern void at_print_raw_cmd(const char *type, const char *cmd, rt_size_t size); | |||
extern void at_print_raw_cmd(const char *type, const char *cmd, rt_size_t size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码需要用工具格式化下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码需要用工具格式化下
用clang-format格式化的,使用的 https://github.com/RT-Thread/rt-thread/blob/master/.clang-format 配置文件
components/net/at/src/at_client.c
Outdated
return -RT_EFULL; | ||
} | ||
|
||
// Since the buffer state is uncertain, we proactively clear it; the overhead is negligible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释风格请统一使用 /**/
components/net/at/src/at_client.c
Outdated
} | ||
else | ||
{ | ||
/* log_d("unrecognized line: %.*s", client->recv_line_len, client->recv_line_buf);*/ | ||
// rt_kprintf("unrecognized line: %.*s", client->recv_line_len, client->recv_line_buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无关的代码请删除
7ca2c6b
to
dce06ba
Compare
@Rbb666 @lizhen9880 @Maihuanyi 麻烦再审查一遍吧 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a deInit interface to the AT client component for proper cleanup and resource management. The implementation replaces the static client table with a dynamic linked list and switches from semaphores to events for better synchronization control.
Key changes:
- Added
at_client_deInit()
function for graceful client cleanup - Replaced static client array with dynamic linked list for better memory management
- Switched from semaphores to RT-Thread events for synchronization
- Changed mutex/semaphore pointers to embedded objects in client struct
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
components/net/at/src/at_client.c | Core implementation of deInit functionality, client management refactoring, and synchronization mechanism changes |
components/net/at/include/at.h | Header updates for new deInit function declaration and client struct modifications |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
resp->line_counts = 0; | ||
} | ||
|
||
client->resp = resp; | ||
rt_sem_control(client->resp_notice, RT_IPC_CMD_RESET, RT_NULL); | ||
rt_event_recv(&client->event, at_client_resp_notice_event, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rt_event_recv
call with timeout 0 appears to be used for clearing events, but the return value is not checked. This should likely use rt_event_control
with RT_IPC_CMD_RESET
for clearing events, or the return value should be handled.
rt_event_recv(&client->event, at_client_resp_notice_event, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, NULL); | |
if (rt_event_control(&client->event, RT_IPC_CMD_RESET, RT_NULL) != RT_EOK) | |
{ | |
LOG_E("Failed to clear client event before sending command!"); | |
rt_mutex_release(&client->lock); | |
return -RT_ERROR; | |
} |
Copilot uses AI. Check for mistakes.
resp->line_counts = 0; | ||
} | ||
|
||
client->resp = resp; | ||
rt_sem_control(client->resp_notice, RT_IPC_CMD_RESET, RT_NULL); | ||
rt_event_recv(&client->event, at_client_resp_notice_event, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rt_event_recv
call with timeout 0 appears to be used for clearing events, but the return value is not checked. This should likely use rt_event_control
with RT_IPC_CMD_RESET
for clearing events, or the return value should be handled.
rt_event_recv(&client->event, at_client_resp_notice_event, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, NULL); | |
rt_event_control(&client->event, RT_IPC_CMD_RESET, RT_NULL); |
Copilot uses AI. Check for mistakes.
while (size) | ||
{ | ||
rt_size_t read_len; | ||
|
||
rt_sem_control(client->rx_notice, RT_IPC_CMD_RESET, RT_NULL); | ||
rt_event_recv(&client->event, at_client_rx_notice_event, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rt_event_recv
call with timeout 0 appears to be used for clearing events, but the return value is not checked. This should likely use rt_event_control
with RT_IPC_CMD_RESET
for clearing events, or the return value should be handled.
rt_event_recv(&client->event, at_client_rx_notice_event, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, NULL); | |
rt_event_control(&client->event, RT_IPC_CMD_RESET, RT_NULL); |
Copilot uses AI. Check for mistakes.
{ | ||
is_full = RT_TRUE; | ||
rt_event_send(&client->event, at_client_deInit_over_event); | ||
rt_thread_delete(rt_thread_self()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling rt_thread_delete(rt_thread_self())
is dangerous and can lead to undefined behavior. The thread should exit gracefully by returning from the thread function instead of deleting itself.
rt_thread_delete(rt_thread_self()); | |
return -RT_ERROR; /* Exit the thread gracefully */ |
Copilot uses AI. Check for mistakes.
麻烦先提个 pr 吧,然后引用下 |
已提交,有改动的地方是 互斥锁 不再使用 |
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
V2版本的串口,已在at_socket没有使用deinit测试3天,ppp拨号中每隔3分钟deinit一次测试4天。
V1版本的串口,在at_socket测试一个小时。
已知待解决:at_device软件包中直接访问at_client的lock变量需要修改一下,合并后就准备给at_device提PR
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up