24 #include "GrblGpio.hpp"
26 #include <ccut/async.hpp>
28 #include "GrblPlatform.hpp"
29 #include "util/grbl/GrblDeviceBase.hpp"
30 #include "util/grbl/GrblGenerator.hpp"
32 using namespace logger;
34 using namespace smc::internal;
35 using namespace smc::units;
39 GrblGpio::GrblGpio(
const std::string &uid,
40 const std::shared_ptr<GrblPlatform> &grbl) :
47 std::shared_ptr<GrblPlatform> grbl(m_grbl.lock());
49 return ccut::make_future_error(
50 Exception(ErrorCode::Canceled,
"platform stopped (deleted)"));
54 uint8_t gpioPin = grbl->getGpio(
uid());
55 return grbl->run<
void>(
59 rc = ctx.device->send(
60 grbl::gen::DigitalOut::off(gpioPin,
true).value);
62 rc = ctx.device->send(
63 grbl::gen::DigitalOut::on(gpioPin,
true).value);
65 cmd.prom->get<
void>().set_value();
68 catch (
const std::exception &e)
70 return ccut::make_future_error(e);
76 return ccut::make_future_error<io_port_t>(
78 std::string(
"getIoState not supported on: ") +
uid()});
DeviceId uid() const
Get the address of device.
Exception thrown by MotionController in case of issues with command.
virtual std::future< units::io_port_t > getIoState() const override
Get current state of this GPIO.
main motion-lib namespace