2011-06-02 12:40:52 +08:00
|
|
|
/*
|
|
|
|
* File : shell.h
|
|
|
|
* This file is part of RT-Thread RTOS
|
|
|
|
* COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
* found in the file LICENSE in this distribution or at
|
|
|
|
* http://www.rt-thread.org/license/LICENSE
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2011-06-02 Bernard Add finsh_get_prompt function declaration
|
|
|
|
*/
|
|
|
|
|
2010-05-26 07:54:45 +08:00
|
|
|
#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
|
2010-12-09 08:05:50 +08:00
|
|
|
#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
|
|
|
|
#define FINSH_PROMPT finsh_get_prompt()
|
2011-06-02 12:40:52 +08:00
|
|
|
const char* finsh_get_prompt(void);
|
2010-12-09 08:05:50 +08:00
|
|
|
#else
|
2010-05-26 07:54:45 +08:00
|
|
|
#define FINSH_PROMPT "finsh>>"
|
2010-12-09 08:05:50 +08:00
|
|
|
#endif
|
2010-05-26 07:54:45 +08:00
|
|
|
|
|
|
|
#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;
|
|
|
|
};
|
|
|
|
|
2010-11-29 08:04:55 +08:00
|
|
|
void finsh_set_echo(rt_uint32_t echo);
|
2010-05-26 07:54:45 +08:00
|
|
|
rt_uint32_t finsh_get_echo(void);
|
|
|
|
|
2012-04-15 21:03:00 +08:00
|
|
|
void finsh_system_init(void);
|
2010-05-26 07:54:45 +08:00
|
|
|
void finsh_set_device(const char* device_name);
|
2010-12-01 09:54:26 +08:00
|
|
|
const char* finsh_get_device(void);
|
2010-05-26 07:54:45 +08:00
|
|
|
|
|
|
|
#endif
|