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.

39 lines
664 B

2 years ago
  1. #pragma once
  2. #include <termios.h>
  3. #include <unistd.h>
  4. #include <fstream>
  5. #include <functional>
  6. #include <iostream>
  7. #include <list>
  8. #include <map>
  9. #include <memory>
  10. #include <set>
  11. #include <sstream>
  12. #include <string>
  13. #include <vector>
  14. namespace iflytop {
  15. using namespace std;
  16. class Uart {
  17. private:
  18. int m_fd = 0;
  19. string m_name;
  20. int m_rate = B115200;
  21. struct termios m_tty;
  22. public:
  23. Uart();
  24. ~Uart();
  25. int open(string path);
  26. int send(char *data, int size);
  27. int receive(char *data, int size_max);
  28. int close();
  29. bool flush_rx();
  30. bool flush_tx();
  31. int get_m_fd(void) { return m_fd; };
  32. };
  33. } // namespace iflytop