shell.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * File : shell.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-06-02 Bernard Add finsh_get_prompt function declaration
  13. */
  14. #ifndef __SHELL_H__
  15. #define __SHELL_H__
  16. #include <rtthread.h>
  17. #include "finsh.h"
  18. #define FINSH_USING_HISTORY
  19. #ifndef FINSH_THREAD_PRIORITY
  20. #define FINSH_THREAD_PRIORITY 20
  21. #endif
  22. #ifndef FINSH_THREAD_STACK_SIZE
  23. #define FINSH_THREAD_STACK_SIZE 2048
  24. #endif
  25. #define FINSH_CMD_SIZE 80
  26. #define FINSH_OPTION_ECHO 0x01
  27. #if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
  28. #define FINSH_PROMPT finsh_get_prompt()
  29. const char* finsh_get_prompt(void);
  30. #else
  31. #define FINSH_PROMPT "finsh>>"
  32. #endif
  33. #ifdef FINSH_USING_HISTORY
  34. enum input_stat
  35. {
  36. WAIT_NORMAL,
  37. WAIT_SPEC_KEY,
  38. WAIT_FUNC_KEY,
  39. };
  40. #ifndef FINSH_HISTORY_LINES
  41. #define FINSH_HISTORY_LINES 5
  42. #endif
  43. #endif
  44. struct finsh_shell
  45. {
  46. struct rt_semaphore rx_sem;
  47. enum input_stat stat;
  48. rt_uint8_t echo_mode:1;
  49. rt_uint8_t use_history:1;
  50. #ifdef FINSH_USING_HISTORY
  51. rt_uint8_t current_history;
  52. rt_uint16_t history_count;
  53. char cmd_history[FINSH_HISTORY_LINES][FINSH_CMD_SIZE];
  54. #endif
  55. struct finsh_parser parser;
  56. char line[FINSH_CMD_SIZE];
  57. rt_uint8_t line_position;
  58. rt_device_t device;
  59. };
  60. void finsh_set_echo(rt_uint32_t echo);
  61. rt_uint32_t finsh_get_echo(void);
  62. void finsh_system_init(void);
  63. void finsh_set_device(const char* device_name);
  64. const char* finsh_get_device(void);
  65. #endif