24 #include "MEdgeGrblDevice.hpp"
29 #include <ccut/Regex.hpp>
30 #include <ccut/utils.hpp>
31 #include <logger/Logger.hpp>
33 #include "Exception.hpp"
34 #include "util/grbl/MGrblParser.hpp"
36 using namespace logger;
37 using namespace std::chrono;
39 static const ccut::Regex s_grblInit(
"^CMGrbl.*$");
43 MEdgeGrblDevice::MEdgeGrblDevice(
int lun,
const std::string &driverPath)
45 setenv(
"GRBL_SIM_INSTANCES",
"8", 1);
46 init(lun, driverPath);
47 const std::string cmd = mgrbl::ControlSymbol +
48 mgrbl::gen::Control::GrblCount;
51 [&cmd](
const std::string &msg) {
52 notice(loggerCat) <<
"<--(init) " << msg;
53 if (s_grblInit.search(msg))
54 throw grbl::ErrorCode{0};
55 else if (ccut::startsWith(msg, cmd))
59 milliseconds{5000}) != grbl::ErrorCode{0})
61 error(loggerCat) <<
"MGrbl initialization failed";
63 std::string{
"Failed to get Grbl banner"}};
Exception thrown by MotionController in case of issues with command.