shell.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #define FINSH_USING_HISTORY
  18. #ifndef FINSH_THREAD_PRIORITY
  19. #define FINSH_THREAD_PRIORITY 20
  20. #endif
  21. #ifndef FINSH_THREAD_STACK_SIZE
  22. #define FINSH_THREAD_STACK_SIZE 2048
  23. #endif
  24. #define FINSH_CMD_SIZE 80
  25. #define FINSH_OPTION_ECHO 0x01
  26. #if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
  27. #define FINSH_PROMPT finsh_get_prompt()
  28. const char* finsh_get_prompt(void);
  29. #else
  30. #define FINSH_PROMPT "finsh>>"
  31. #endif
  32. #ifdef FINSH_USING_HISTORY
  33. enum input_stat
  34. {
  35. WAIT_NORMAL,
  36. WAIT_SPEC_KEY,
  37. WAIT_FUNC_KEY,
  38. };
  39. #ifndef FINSH_HISTORY_LINES
  40. #define FINSH_HISTORY_LINES 5
  41. #endif
  42. #endif
  43. struct finsh_shell
  44. {
  45. struct rt_semaphore rx_sem;
  46. enum input_stat stat;
  47. rt_uint8_t echo_mode:1;
  48. rt_uint8_t use_history:1;
  49. #ifdef FINSH_USING_HISTORY
  50. rt_uint8_t current_history;
  51. rt_uint16_t history_count;
  52. char cmd_history[FINSH_HISTORY_LINES][FINSH_CMD_SIZE];
  53. #endif
  54. struct finsh_parser parser;
  55. char line[FINSH_CMD_SIZE];
  56. rt_uint8_t line_position;
  57. rt_device_t device;
  58. };
  59. void finsh_set_echo(rt_uint32_t echo);
  60. rt_uint32_t finsh_get_echo(void);
  61. void finsh_system_init(void);
  62. void finsh_set_device(const char* device_name);
  63. const char* finsh_get_device(void);
  64. #endif