-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[componnents][finsh] 适配serial_v2提高效率,减少内存占用 #10607
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,8 @@ | |||||
|
|
||||||
| #ifdef RT_USING_FINSH | ||||||
|
|
||||||
| #include <rtdef.h> | ||||||
| #include <rtdevice.h> | ||||||
| #include "shell.h" | ||||||
| #include "msh.h" | ||||||
|
|
||||||
|
|
@@ -177,7 +179,8 @@ int finsh_getchar(void) | |||||
| { | ||||||
| return -1; /* EOF */ | ||||||
| } | ||||||
|
|
||||||
| /* Temporarily retain the distinction */ | ||||||
| #ifndef RT_USING_SERIAL_V2 | ||||||
| while (rt_device_read(device, -1, &ch, 1) != 1) | ||||||
| { | ||||||
| rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER); | ||||||
|
|
@@ -190,6 +193,19 @@ int finsh_getchar(void) | |||||
| } | ||||||
| } | ||||||
| } | ||||||
| #else | ||||||
| while (rt_device_read(device, -1, &ch, 1) != 1) | ||||||
|
||||||
| { | ||||||
| if (shell->device != device) | ||||||
| { | ||||||
| device = shell->device; | ||||||
| if (device == RT_NULL) | ||||||
| { | ||||||
| return -1; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| #endif | ||||||
| return ch; | ||||||
| #endif /* RT_USING_POSIX_STDIO */ | ||||||
| #else | ||||||
|
|
@@ -199,6 +215,7 @@ int finsh_getchar(void) | |||||
| } | ||||||
|
|
||||||
| #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) | ||||||
| #ifndef RT_USING_SERIAL_V2 | ||||||
| static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size) | ||||||
| { | ||||||
| RT_ASSERT(shell != RT_NULL); | ||||||
|
|
@@ -208,6 +225,7 @@ static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size) | |||||
|
|
||||||
| return RT_EOK; | ||||||
| } | ||||||
| #endif | ||||||
|
|
||||||
| /** | ||||||
| * @ingroup group_finsh | ||||||
|
|
@@ -231,8 +249,13 @@ void finsh_set_device(const char *device_name) | |||||
| /* check whether it's a same device */ | ||||||
| if (dev == shell->device) return; | ||||||
| /* open this device and set the new device in finsh shell */ | ||||||
| #ifndef RT_USING_SERIAL_V2 | ||||||
| if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX | \ | ||||||
| RT_DEVICE_FLAG_STREAM) == RT_EOK) | ||||||
| #else | ||||||
| if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_RX_BLOCKING | \ | ||||||
| RT_DEVICE_FLAG_TX_BLOCKING | RT_DEVICE_FLAG_STREAM) == RT_EOK) | ||||||
| #endif | ||||||
| { | ||||||
| if (shell->device != RT_NULL) | ||||||
| { | ||||||
|
|
@@ -246,7 +269,12 @@ void finsh_set_device(const char *device_name) | |||||
| shell->line_curpos = shell->line_position = 0; | ||||||
|
|
||||||
| shell->device = dev; | ||||||
| #ifndef RT_USING_SERIAL_V2 | ||||||
| rt_device_set_rx_indicate(dev, finsh_rx_ind); | ||||||
| #else | ||||||
| rt_int32_t rx_timeout = RT_WAITING_FOREVER; | ||||||
| rt_device_control(dev, RT_SERIAL_CTRL_SET_RX_TIMEOUT, (void *)&rx_timeout); | ||||||
|
||||||
| rt_device_control(dev, RT_SERIAL_CTRL_SET_RX_TIMEOUT, (void *)&rx_timeout); | |
| rt_device_control(dev, RT_SERIAL_CTRL_SET_RX_TIMEOUT, (void *)&serial_rx_timeout); |
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.
The comment should be in English for consistency with the codebase. Consider changing to 'Temporarily retain the distinction' or a more descriptive comment explaining why this distinction exists.