Skip to content

Commit

Permalink
M2 and M30 return from macros
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchBradley committed Jan 9, 2025
1 parent c8324a7 commit 043fb29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions FluidNC/src/Machine/Macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ void MacroChannel::ack(Error status) {

MacroChannel::MacroChannel(Macro* macro) : Channel(macro->name(), false), _macro(macro) {}

void MacroChannel::end_message() {
_progress += name();
_progress += ": Sent";
}

Error MacroChannel::pollLine(char* line) {
// Macros only execute as proper jobs so we should not be polling one with a null line
if (!line) {
Expand All @@ -125,6 +130,10 @@ Error MacroChannel::pollLine(char* line) {
if (_pending_error != Error::Ok) {
return _pending_error;
}
if (_ended) {
end_message();
return Error::Eof;
}
switch (auto err = readLine(line, Channel::maxLine)) {
case Error::Ok: {
log_debug("Macro line: " << line);
Expand All @@ -136,8 +145,7 @@ Error MacroChannel::pollLine(char* line) {
}
return Error::Ok;
case Error::Eof:
_progress = name();
_progress += ": Sent";
end_message();
return Error::Eof;
default:
log_error("Macro readLine failed");
Expand Down
1 change: 1 addition & 0 deletions FluidNC/src/Machine/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace Machine {
Macro* _macro;

Error readLine(char* line, int maxlen);
void end_message();

public:
Error pollLine(char* line) override;
Expand Down

0 comments on commit 043fb29

Please sign in to comment.