shell.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef __SHELL_H__
  2. #define __SHELL_H__
  3. #include <rtthread.h>
  4. #define FINSH_USING_HISTORY
  5. #ifndef FINSH_THREAD_PRIORITY
  6. #define FINSH_THREAD_PRIORITY 20
  7. #endif
  8. #ifndef FINSH_THREAD_STACK_SIZE
  9. #define FINSH_THREAD_STACK_SIZE 2048
  10. #endif
  11. #define FINSH_CMD_SIZE 80
  12. #define FINSH_OPTION_ECHO 0x01
  13. #if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
  14. #define FINSH_PROMPT finsh_get_prompt()
  15. #else
  16. #define FINSH_PROMPT "finsh>>"
  17. #endif
  18. #ifdef FINSH_USING_HISTORY
  19. enum input_stat
  20. {
  21. WAIT_NORMAL,
  22. WAIT_SPEC_KEY,
  23. WAIT_FUNC_KEY,
  24. };
  25. #ifndef FINSH_HISTORY_LINES
  26. #define FINSH_HISTORY_LINES 5
  27. #endif
  28. #endif
  29. struct finsh_shell
  30. {
  31. struct rt_semaphore rx_sem;
  32. enum input_stat stat;
  33. rt_uint8_t echo_mode:1;
  34. rt_uint8_t use_history:1;
  35. #ifdef FINSH_USING_HISTORY
  36. rt_uint8_t current_history;
  37. rt_uint16_t history_count;
  38. char cmd_history[FINSH_HISTORY_LINES][FINSH_CMD_SIZE];
  39. #endif
  40. struct finsh_parser parser;
  41. char line[FINSH_CMD_SIZE];
  42. rt_uint8_t line_position;
  43. rt_device_t device;
  44. };
  45. void finsh_set_echo(rt_uint32_t echo);
  46. rt_uint32_t finsh_get_echo(void);
  47. void finsh_set_device(const char* device_name);
  48. const char* finsh_get_device(void);
  49. #endif