-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[utest][driver][serial_v2] 优化flush判断逻辑 #10841
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,8 @@ static rt_err_t test_item(rt_uint8_t *uart_write_buffer, rt_uint32_t send_size) | |
| rt_device_control(&serial->parent, RT_SERIAL_CTRL_TX_FLUSH, RT_NULL); | ||
| tick_diff = rt_tick_get() - old_tick; | ||
|
|
||
| if (tick_diff < expect_time || tick_diff > (expect_time + 10)) | ||
| rt_uint32_t lower_bound = (expect_time > 2) ? (expect_time - 2) : 0; | ||
| if (tick_diff < lower_bound || tick_diff > (expect_time + 10)) | ||
|
||
| { | ||
| LOG_E("send_size [%4d], time required for TXB mode transmission to complete [%3d], expect_time [%3d]", send_size, tick_diff, expect_time); | ||
| return -RT_ERROR; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,8 @@ static rt_err_t test_item(rt_uint8_t *uart_write_buffer, rt_uint32_t send_size) | |
| rt_device_control(&serial->parent, RT_SERIAL_CTRL_TX_FLUSH, RT_NULL); | ||
| tick_diff = rt_tick_get() - old_tick; | ||
|
|
||
| if (tick_diff < expect_time || tick_diff > (expect_time + 10)) | ||
| rt_uint32_t lower_bound = (expect_time > 2) ? (expect_time - 2) : 0; | ||
|
||
| if (tick_diff < lower_bound || tick_diff > (expect_time + 10)) | ||
|
||
| { | ||
| LOG_E("send_size [%4d], time required for TXNB mode transmission to complete [%3d], expect_time [%3d]", send_size, tick_diff, expect_time); | ||
| return -RT_ERROR; | ||
|
|
||
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.
Magic number alert / 魔术数字警告: The constant value
2used in the lower bound calculation is a magic number that lacks explanation. Consider defining it as a named constant (e.g.,TIMING_TOLERANCE_MARGIN) to improve code readability and maintainability.English: The hardcoded value
2should be extracted to a constant with a meaningful name explaining why this specific tolerance is needed for the lower bound calculation.中文: 硬编码的值
2应该提取为一个有意义名称的常量,解释为什么下限计算需要这个特定的容差值。Example/示例: