Fix for bug in NGC expressions return statement handling. Ref issue #485.

This commit is contained in:
Terje Io
2024-04-08 16:19:50 +02:00
parent ec209ecba7
commit 69f91b1952
4 changed files with 50 additions and 22 deletions

View File

@@ -1,5 +1,27 @@
## grblHAL changelog
<a name="20240408"/>Build 20240408
Core:
* Fix for bug in NGC expressions return statement handling. Ref issue [#485](https://github.com/grblHAL/core/issues/485).
Drivers:
* RP2040: fix for incorrect handling of safety door input inversion. Ref. issue [#85](https://github.com/grblHAL/RP2040/issues/85).
* STM32F7xx: removed stray project folder from Eclipse debug build configuration.
* All \(remaining\): now calls stepper enable via HAL.
Plugins:
* SD card: fix for potential expression stack issue when macro is terminated early with `M99`.
* Spindle: improved logic, switched polling to new task handling code. Ref. issue [#27](https://github.com/grblHAL/Plugins_spindle/issues/27).
---
<a name="20240404"/>Build 20240404
Core:

2
grbl.h
View File

@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20240404
#define GRBL_BUILD 20240408
#define GRBL_URL "https://github.com/grblHAL"

View File

@@ -5,20 +5,20 @@
Part of grblHAL
Copyright (c) 2023 Terje Io
Copyright (c) 2023-2024 Terje Io
Grbl is free software: you can redistribute it and/or modify
grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hal.h"
@@ -192,9 +192,14 @@ static bool stack_pull (void)
return ok;
}
// Public functions
void ngc_flowctrl_unwind_stack (vfs_file_t *file)
{
while(stack_idx >= 0 && stack[stack_idx].file == file)
stack_pull();
}
void ngc_flowctrl_init (void)
{
while(stack_idx >= 0)
@@ -417,16 +422,16 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
break;
case NGCFlowCtrl_Return:
if(!skipping && grbl.on_macro_return) {
vfs_file_t *file = stack[stack_idx].file;
while(stack_idx >= 0 && file == stack[stack_idx].file)
stack_pull();
if(ngc_eval_expression(line, pos, &value) == Status_OK) {
ngc_named_param_set("_value", value);
ngc_named_param_set("_value_returned", 1.0f);
} else
ngc_named_param_set("_value_returned", 0.0f);
grbl.on_macro_return();
if(hal.stream.file) {
if(!skipping && grbl.on_macro_return) {
ngc_flowctrl_unwind_stack(stack[stack_idx].file);
if(ngc_eval_expression(line, pos, &value) == Status_OK) {
ngc_named_param_set("_value", value);
ngc_named_param_set("_value_returned", 1.0f);
} else
ngc_named_param_set("_value_returned", 0.0f);
grbl.on_macro_return();
}
} else
status = Status_FlowControlNotExecutingMacro;
break;

View File

@@ -5,26 +5,27 @@
Part of grblHAL
Copyright (c) 2023 Terje Io
Copyright (c) 2023-2024 Terje Io
Grbl is free software: you can redistribute it and/or modify
grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NGC_FLOWCTRL_H_
#define _NGC_FLOWCTRL_H_
void ngc_flowctrl_init (void);
void ngc_flowctrl_unwind_stack (vfs_file_t *file);
status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, bool *skip);
#endif