lua2rtt.h 1.4 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 <rtthread.h>
  15. #include "luaconf.h"
  16. #define LUA2RTT_USING_DEBUG
  17. #ifndef LUA2RTT_USING_DEBUG
  18. #define LUA2RTT_DBG(fmt, ...)
  19. #else
  20. #define LUA2RTT_DBG(fmt, ...) \
  21. do{ \
  22. rt_kprintf("[\033[32mLua2RTT\033[0m] "); \
  23. rt_kprintf(fmt, ##__VA_ARGS__); \
  24. }while(0)
  25. #endif
  26. #ifndef LUA2RTT_THREAD_STACK_SIZE
  27. #define LUA2RTT_THREAD_STACK_SIZE 10240
  28. #endif
  29. #ifndef LUA2RTT_CMD_SIZE
  30. #define LUA2RTT_CMD_SIZE 512
  31. #endif
  32. #ifndef LUA2RTT_HISTORY_LINES
  33. #define LUA2RTT_HISTORY_LINES 5
  34. #endif
  35. enum lua2rtt_input_stat
  36. {
  37. LUA2RTT_WAIT_NORMAL,
  38. LUA2RTT_WAIT_SPEC_KEY,
  39. LUA2RTT_WAIT_FUNC_KEY,
  40. };
  41. struct lua2rtt
  42. {
  43. rt_thread_t thread;
  44. struct rt_semaphore rx_sem;
  45. enum lua2rtt_input_stat stat;
  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_uint16_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