lua2rtt.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * @File: lua2rtt.c
  3. * @Author: liu2guang
  4. * @Date: 2018-05-06 09:16:56
  5. *
  6. * @LICENSE: https://github.com/liu2guang/lua2rtt/blob/master/LICENSE.
  7. *
  8. * Change Logs:
  9. * Date Author Notes
  10. * 2018-05-06 liu2guang The first version.
  11. */
  12. #ifndef __LUA2RTT_H_
  13. #define __LUA2RTT_H_
  14. #include "luaconf.h"
  15. #define LUA2RTT_USING_DEBUG
  16. #ifndef LUA2RTT_USING_DEBUG
  17. #define LUA2RTT_DBG(fmt, ...)
  18. #else
  19. #define LUA2RTT_DBG(fmt, ...) \
  20. do{ \
  21. rt_kprintf("[\033[32mLua2RTT\033[0m] "); \
  22. rt_kprintf(fmt, ##__VA_ARGS__); \
  23. }while(0)
  24. #endif
  25. #ifndef LUA2RTT_THREAD_STACK_SIZE
  26. #define LUA2RTT_THREAD_STACK_SIZE 10240
  27. #endif
  28. #ifndef LUA2RTT_CMD_SIZE
  29. #define LUA2RTT_CMD_SIZE LUA_MAXINPUT
  30. #endif
  31. #ifndef LUA2RTT_HISTORY_LINES
  32. #define LUA2RTT_HISTORY_LINES 5
  33. #endif
  34. enum lua2rtt_input_stat
  35. {
  36. LUA2RTT_WAIT_NORMAL,
  37. LUA2RTT_WAIT_SPEC_KEY,
  38. LUA2RTT_WAIT_FUNC_KEY,
  39. };
  40. struct lua2rtt
  41. {
  42. rt_thread_t thread;
  43. struct rt_semaphore rx_sem;
  44. enum lua2rtt_input_stat stat;
  45. /* ÊäÈë²ÎÊý */
  46. int argc;
  47. char *argv[3];
  48. char lua_history[LUA2RTT_HISTORY_LINES][LUA2RTT_CMD_SIZE];
  49. rt_uint16_t history_count;
  50. rt_uint16_t history_current;
  51. char line[LUA2RTT_CMD_SIZE];
  52. rt_uint8_t line_position;
  53. rt_uint8_t line_curpos;
  54. rt_device_t device;
  55. rt_err_t (*rx_indicate)(rt_device_t dev, rt_size_t size); /* msh»Øµ÷º¯Êý */
  56. };
  57. typedef struct lua2rtt *lua2rtt_t;
  58. #endif