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.

54 lines
1.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
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. string m_rate;
  21. struct termios m_tty;
  22. public:
  23. Uart();
  24. ~Uart();
  25. /**
  26. * @brief
  27. *
  28. * @param path
  29. * @param rate
  30. * "0" "50" "75" "110"
  31. * "134" "150" "200" "300"
  32. * "600" "1200" "1800" "2400"
  33. * "4800" "9600" "19200" "38400"
  34. * "57600" "115200" "230400" "460800"
  35. * "500000" "576000" "921600" "1000000"
  36. * "1152000" "1500000" "2000000" "2500000"
  37. * "3000000" "3500000" "4000000"
  38. *
  39. * @return int
  40. */
  41. int open(string path, string ratestr);
  42. int send(char *data, int size);
  43. int receive(char *data, int size_max);
  44. int close();
  45. bool flush_rx();
  46. bool flush_tx();
  47. int get_m_fd(void) { return m_fd; };
  48. };
  49. } // namespace iflytop