Skip to content

Commit a280fb8

Browse files
authored
Merge pull request #4964 from mysterywolf/finshgetchar
[finsh] 将finsh_getchar函数暴露出来
2 parents af52c57 + 60aaa9f commit a280fb8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

components/finsh/shell.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode)
164164
shell->prompt_mode = prompt_mode;
165165
}
166166

167-
static int finsh_getchar(void)
167+
char finsh_getchar(void)
168168
{
169169
#ifdef RT_USING_DEVICE
170170
#ifdef RT_USING_POSIX
@@ -176,7 +176,7 @@ static int finsh_getchar(void)
176176
while (rt_device_read(shell->device, -1, &ch, 1) != 1)
177177
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
178178

179-
return (int)ch;
179+
return ch;
180180
#endif
181181
#else
182182
extern char rt_hw_console_getchar(void);
@@ -329,7 +329,7 @@ static void finsh_wait_auth(void)
329329
while (1)
330330
{
331331
/* read one character from device */
332-
ch = finsh_getchar();
332+
ch = (int)finsh_getchar();
333333
if (ch < 0)
334334
{
335335
continue;
@@ -541,7 +541,7 @@ void finsh_thread_entry(void *parameter)
541541

542542
while (1)
543543
{
544-
ch = finsh_getchar();
544+
ch = (int)finsh_getchar();
545545
if (ch < 0)
546546
{
547547
continue;

components/finsh/shell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ rt_uint32_t finsh_get_echo(void);
9797
int finsh_system_init(void);
9898
void finsh_set_device(const char* device_name);
9999
const char* finsh_get_device(void);
100+
char finsh_getchar(void);
100101

101102
rt_uint32_t finsh_get_prompt_mode(void);
102103
void finsh_set_prompt_mode(rt_uint32_t prompt_mode);

0 commit comments

Comments
 (0)