UARTDevice.h 964 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. #include "SerialDevice.h"
  3. #include <AP_HAL/utility/Socket.h>
  4. class UARTDevice: public SerialDevice {
  5. public:
  6. UARTDevice(const char *device_path);
  7. virtual ~UARTDevice();
  8. virtual bool open() override;
  9. virtual bool close() override;
  10. virtual ssize_t write(const uint8_t *buf, uint16_t n) override;
  11. virtual ssize_t read(uint8_t *buf, uint16_t n) override;
  12. virtual void set_blocking(bool blocking) override;
  13. virtual void set_speed(uint32_t speed) override;
  14. virtual void set_flow_control(enum AP_HAL::UARTDriver::flow_control flow_control_setting) override;
  15. virtual AP_HAL::UARTDriver::flow_control get_flow_control(void) override
  16. {
  17. return _flow_control;
  18. }
  19. virtual void set_parity(int v) override;
  20. private:
  21. void _disable_crlf();
  22. AP_HAL::UARTDriver::flow_control _flow_control = AP_HAL::UARTDriver::flow_control::FLOW_CONTROL_DISABLE;
  23. int _fd = -1;
  24. const char *_device_path;
  25. };