25 #include "MGrblParser.hpp"
27 #include <ccut/utils.hpp>
28 #include <logger/Logger.hpp>
30 #include "Exception.hpp"
33 using namespace logger;
38 const std::string Control::Layout =
"$layout";
39 const std::string Control::GrblCount =
"$grblCount";
40 const std::string Control::TrigArm =
"$trigArm";
41 const std::string Control::TrigSoft =
"$trigSoft";
42 const std::string Control::BuildInfo =
"$I";
45 static const std::string s_loggerCat{
"mgrbl:parser"};
47 bool MGrblParser::parseLayout(
const std::string &line, Layout &layout)
49 if (!ccut::startsWith(line, gen::Control::Layout) ||
50 line[gen::Control::Layout.size()] !=
'=')
52 error(s_loggerCat) <<
"invalid layout";
56 std::size_t end(line.find_first_of(
"\r\n", 8));
57 const std::string value(
58 line.substr(8, (end == std::string::npos) ? end : (end - 8)));
59 layout.reserve(value.size());
60 for (
const char c : value)
61 layout.emplace_back(c -
'0');
65 bool MGrblParser::parseIsArmed(
const std::string &line,
bool &isArmed)
67 if (!ccut::startsWith(line, gen::Control::TrigArm) ||
68 line[gen::Control::TrigArm.size()] !=
'=')
73 const std::string value(line.substr(9, 1));
76 else if (value ==
"0")
79 throw Exception(smc::ErrorCode::InvalidArguments,
80 "invalid isArmed response value");
Exception thrown by MotionController in case of issues with command.
main motion-lib namespace