fwt_software/include/fgc/SerialMotorController.h

32 lines
902 B
C++

#pragma once
#include "fgc/IMotorController.h"
#include <memory>
#include <string>
namespace fgc {
// Real motor controller over a serial port (Boost.Asio). Async-reads '$'-
// prefixed telemetry lines and parses them into MotorTelemetry; writes command
// strings. Wraps the logic of the old Serial.h SerialPort. Implementation
// detail (Boost.Asio) is hidden behind a pImpl.
class SerialMotorController : public IMotorController {
public:
SerialMotorController(std::string device, unsigned int baud);
~SerialMotorController() override;
void start() override;
void stop() override;
void sendCommand(const std::string& cmd) override;
MotorTelemetry telemetry() override;
std::string lastDump() override;
bool connected() const override;
private:
struct Impl;
std::unique_ptr<Impl> impl_;
};
} // namespace fgc