mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-26 06:43:58 +08:00
clean up finsh shell code.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@734 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -107,6 +107,61 @@ long list_thread(void)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(list_thread, list thread);
|
||||
|
||||
#if 0
|
||||
long dump_thread(rt_thread_t tid)
|
||||
{
|
||||
rt_uint8_t *ptr;
|
||||
rt_uint32_t sp;
|
||||
rt_thread_t thread;
|
||||
|
||||
rt_kprintf(" thread pri status sp stack size max used left tick error\n");
|
||||
rt_kprintf("-------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
|
||||
|
||||
thread = rt_thread_self();
|
||||
if ((thread == tid) || (tid == RT_NULL)) /* it's current thread */
|
||||
{
|
||||
ptr = (rt_uint8_t*)thread->stack_addr;
|
||||
while (*ptr == '#')ptr ++;
|
||||
sp = (rt_uint32_t)__current_sp();
|
||||
rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority);
|
||||
|
||||
if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready ");
|
||||
else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
|
||||
else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
|
||||
|
||||
rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
|
||||
thread->stack_size + ((rt_uint32_t)thread->stack_addr - sp),
|
||||
thread->stack_size,
|
||||
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
|
||||
thread->remaining_tick,
|
||||
thread->error);
|
||||
}
|
||||
else
|
||||
{
|
||||
thread = tid;
|
||||
sp = (rt_uint32_t)thread->sp;
|
||||
|
||||
ptr = (rt_uint8_t*)thread->stack_addr;
|
||||
while (*ptr == '#')ptr ++;
|
||||
|
||||
rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority);
|
||||
|
||||
if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready ");
|
||||
else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
|
||||
else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
|
||||
|
||||
rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
|
||||
thread->stack_size + ((rt_uint32_t)thread->stack_addr - sp),
|
||||
thread->stack_size,
|
||||
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
|
||||
thread->remaining_tick,
|
||||
thread->error);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void show_wait_queue(struct rt_list_node* list)
|
||||
{
|
||||
struct rt_thread *thread;
|
||||
|
||||
+207
-211
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
#ifndef __SHELL_H__
|
||||
#define __SHELL_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#define FINSH_USING_HISTORY
|
||||
#ifndef FINSH_THREAD_PRIORITY
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#endif
|
||||
#ifndef FINSH_THREAD_STACK_SIZE
|
||||
#define FINSH_THREAD_STACK_SIZE 2048
|
||||
#endif
|
||||
#define FINSH_CMD_SIZE 80
|
||||
|
||||
#define FINSH_OPTION_ECHO 0x01
|
||||
#define FINSH_PROMPT "finsh>>"
|
||||
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
enum input_stat
|
||||
{
|
||||
WAIT_NORMAL,
|
||||
WAIT_SPEC_KEY,
|
||||
WAIT_FUNC_KEY,
|
||||
};
|
||||
#ifndef FINSH_HISTORY_LINES
|
||||
#define FINSH_HISTORY_LINES 5
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct finsh_shell
|
||||
{
|
||||
struct rt_semaphore rx_sem;
|
||||
|
||||
enum input_stat stat;
|
||||
|
||||
rt_uint8_t echo_mode:1;
|
||||
rt_uint8_t use_history:1;
|
||||
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
rt_uint8_t current_history;
|
||||
rt_uint16_t history_count;
|
||||
|
||||
char cmd_history[FINSH_HISTORY_LINES][FINSH_CMD_SIZE];
|
||||
#endif
|
||||
|
||||
struct finsh_parser parser;
|
||||
|
||||
char line[FINSH_CMD_SIZE];
|
||||
rt_uint8_t line_position;
|
||||
|
||||
rt_device_t device;
|
||||
};
|
||||
|
||||
void finsh_set_echo(rt_uint32_t enable);
|
||||
rt_uint32_t finsh_get_echo(void);
|
||||
|
||||
void finsh_set_device(const char* device_name);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user