You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
797 B

2 years ago
  1. #pragma once
  2. #include <map>
  3. #include <string>
  4. #include "sdk/os/zos.hpp"
  5. namespace iflytop {
  6. using namespace std;
  7. class CmdScheduler {
  8. public:
  9. class CmdProcessContext {
  10. public:
  11. bool breakflag = false;
  12. };
  13. typedef function<void(int, char**, CmdProcessContext*)> call_cmd_t;
  14. private:
  15. map<string, call_cmd_t> m_cmdMap;
  16. ZUART* m_uart;
  17. char* rxbuf;
  18. int32_t m_rxsize = 0;
  19. uint32_t m_rxbufsize;
  20. bool m_dataisready = false;
  21. char cmdcache[100];
  22. public:
  23. void initialize(UART_HandleTypeDef* huart, uint32_t rxbufsize);
  24. void registerCmd(std::string cmd, call_cmd_t call_cmd);
  25. void schedule();
  26. private:
  27. void callcmd(const char* cmd, CmdProcessContext& context);
  28. void prase_cmd(char* input, int inputlen, int& argc, char* argv[]);
  29. };
  30. } // namespace iflytop