Changed _vminor named parameter to contain build date in YYMMDD format, previously value was 0.

Added support for LinuxCNC style (ABORT,<msg>) comment, requires expressions enabled. Terminates gcode program, outputs message and returns error 253.
Added PRM[<setting>] and PRM[<setting>,<bit>] functions to expressions, returns $-setting value or value of bit in integer type setting.
"hardened" flow control code, fixed bug in repeat...continue handling.
Changed signature of grbl.on_gcode_comment event, now returns status code.
This commit is contained in:
Terje Io
2024-10-27 07:27:25 +07:00
parent 99681254f1
commit 9a98243fd3
15 changed files with 171 additions and 50 deletions
+30 -3
View File
@@ -84,6 +84,7 @@ static volatile int_fast8_t stack_idx = -1;
static bool skip_sub = false;
static ngc_sub_t *subs = NULL, *exec_sub = NULL;
static ngc_stack_entry_t stack[NGC_STACK_DEPTH] = {0};
static on_gcode_message_ptr on_gcode_comment;
static status_code_t read_command (char *line, uint_fast8_t *pos, ngc_cmd_t *operation)
{
@@ -294,8 +295,34 @@ void ngc_flowctrl_unwind_stack (vfs_file_t *file)
stack_pull();
}
static status_code_t onGcodeComment (char *comment)
{
uint_fast8_t pos = 6;
status_code_t status = Status_OK;
if(!strncasecmp(comment, "ABORT,", 6)) {
char *buf = NULL;
if(ngc_substitute_parameters(comment + pos, &buf)) {
report_message(buf, Message_Error);
free(buf);
}
status = Status_UserException;
} else if(on_gcode_comment)
status = on_gcode_comment(comment);
return status;
}
void ngc_flowctrl_init (void)
{
static bool init_ok = false;
if(!init_ok) {
init_ok = true;
on_gcode_comment = grbl.on_gcode_comment;
grbl.on_gcode_comment = onGcodeComment;
}
clear_subs(NULL);
while(stack_idx >= 0)
stack_pull();
@@ -523,7 +550,7 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
if(stack[stack_idx].repeats && --stack[stack_idx].repeats)
vfs_seek(stack[stack_idx].file, stack[stack_idx].file_pos);
else
stack_pull();
stack[stack_idx].skip = true;
break;
case NGCFlowCtrl_Do:
@@ -606,7 +633,7 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
if(!skipping) {
ngc_sub_t *sub = subs;
ngc_sub_t *sub;
if(o_label > NGC_MAX_PARAM_ID) {
#if 0
@@ -631,7 +658,7 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
status = Status_FlowControlOutOfMemory; // file not found...
}
#endif
} else do {
} else if((sub = subs)) do {
if(sub->o_label == o_label && sub->file == hal.stream.file)
break;
} while((sub = sub->next));