From 0a86e57ddc622c758a2c490f4100af948beebee2 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Tue, 4 Jun 2024 12:57:17 +0700 Subject: [PATCH] Fixed incorrect implementation of EXISTS function. Ref. issue #527. Added missing clear of parser tool change state when cycle start signal is asserted. Affects tool change mode 'Normal' ($341=0). --- README.md | 2 +- changelog.md | 10 ++++++++++ grbl.h | 2 +- ngc_expr.c | 25 ++++++++++++++----------- settings.h | 11 +++++++++++ system.c | 14 +++++++------- 6 files changed, 44 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d647a90..74914e1 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ It has been written to complement grblHAL and has features such as proper keyboa --- -Latest build date is 20240602, see the [changelog](changelog.md) for details. +Latest build date is 20240604, see the [changelog](changelog.md) for details. __NOTE:__ Build 20240222 has moved the probe input to the ioPorts pool of inputs and will be allocated from it when configured. The change is major and _potentially dangerous_, it may damage your probe, so please _verify correct operation_ after installing this, or later, builds. diff --git a/changelog.md b/changelog.md index 9d68bae..bd725e8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,15 @@ ## grblHAL changelog +Build 20240604 + +Core: + +* Fixed incorrect implementation of `EXISTS` function. Ref. [issue #527](https://github.com/grblHAL/core/issues/527). + +* Added missing clear of parser tool change state when cycle start signal is asserted. Affects tool change mode 'Normal' ($341=0). + +--- + Build 20240602 Core: diff --git a/grbl.h b/grbl.h index d448461..bebbc06 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20240602 +#define GRBL_BUILD 20240604 #define GRBL_URL "https://github.com/grblHAL" diff --git a/ngc_expr.c b/ngc_expr.c index 3f0a991..91f336d 100644 --- a/ngc_expr.c +++ b/ngc_expr.c @@ -53,7 +53,7 @@ typedef enum { NGCBinaryOp_LE, NGCBinaryOp_GE, NGCBinaryOp_GT, - NGCBinaryOp_RelationalLast = NGCBinaryOp_GT, + NGCBinaryOp_RelationalLast = NGCBinaryOp_GT } ngc_binary_op_t; typedef enum { @@ -70,7 +70,7 @@ typedef enum { NGCUnaryOp_SIN, NGCUnaryOp_SQRT, NGCUnaryOp_TAN, - NGCUnaryOp_Exists, // Not implemented + NGCUnaryOp_Exists } ngc_unary_op_t; /*! \brief Executes the operations: /, MOD, ** (POW), *. @@ -675,19 +675,22 @@ static status_code_t read_unary (char *line, uint_fast8_t *pos, float *value) else { - if (operation == NGCUnaryOp_Exists) { + if(operation == NGCUnaryOp_Exists) { - char *arg = &line[++(*pos)], *s; + char *arg = &line[++(*pos)], *s = NULL; - s = arg; - while(*s && *s != ']') - s++; + if(*arg == '#' && *(arg + 1) == '<') { + arg += 2; + s = arg; + while(*s && *s != ']') + s++; + } - if(*s == ']') { - *s = '\0'; + if(s && *s == ']' && *(s - 1) == '>') { + *(s - 1) = '\0'; *value = ngc_named_param_exists(arg) ? 1.0f : 0.0f; - *s = ']'; - *pos = *pos + s - arg + 1; + *(s - 1) = '>'; + *pos = *pos + s - arg + 3; } else status = Status_ExpressionSyntaxError; diff --git a/settings.h b/settings.h index 4094371..bb1277b 100644 --- a/settings.h +++ b/settings.h @@ -391,6 +391,17 @@ typedef enum { Setting_Panel_Encoder3_Cpd = 559, Setting_Panel_SettingsMax = 579, + Setting_ButtonAction0 = 590, + Setting_ButtonAction1 = 591, + Setting_ButtonAction2 = 592, + Setting_ButtonAction3 = 593, + Setting_ButtonAction4 = 594, + Setting_ButtonAction5 = 595, + Setting_ButtonAction6 = 596, + Setting_ButtonAction7 = 597, + Setting_ButtonAction8 = 598, + Setting_ButtonAction9 = 599, + Setting_ModbusTCPBase = 600, // Reserving settings values 600 to 639 for ModBus TCP (8 sets) Setting_ModbusIpAddressBase = Setting_ModbusTCPBase + Setting_ModbusIpAddress, Setting_ModbusPortBase = Setting_ModbusTCPBase + Setting_ModbusPort, diff --git a/system.c b/system.c index b45234e..06a8ea7 100644 --- a/system.c +++ b/system.c @@ -74,11 +74,11 @@ ISR_CODE void ISR_FUNC(control_interrupt_handler)(control_signals_t signals) sys.last_event.control.value = signals.value; - if ((signals.reset || signals.e_stop || signals.motor_fault) && state_get() != STATE_ESTOP) + if((signals.reset || signals.e_stop || signals.motor_fault) && state_get() != STATE_ESTOP) mc_reset(); else { #ifndef NO_SAFETY_DOOR_SUPPORT - if (signals.safety_door_ajar && hal.signals_cap.safety_door_ajar) { + if(signals.safety_door_ajar && hal.signals_cap.safety_door_ajar) { if(settings.safety_door.flags.ignore_when_idle) { // Only stop the spindle (laser off) when idle or jogging, // this to allow positioning the controlled point (spindle) when door is open. @@ -91,27 +91,27 @@ ISR_CODE void ISR_FUNC(control_interrupt_handler)(control_signals_t signals) system_set_exec_state_flag(EXEC_SAFETY_DOOR); } #endif - if(signals.probe_overtravel) { limit_signals_t overtravel = { .min.z = On}; hal.limits.interrupt_callback(overtravel); // TODO: add message? - } else if (signals.probe_triggered) { + } else if(signals.probe_triggered) { if(sys.probing_state == Probing_Off && (state_get() & (STATE_CYCLE|STATE_JOG))) { system_set_exec_state_flag(EXEC_STOP); sys.alarm_pending = Alarm_ProbeProtect; } else hal.probe.configure(false, false); - } else if (signals.probe_disconnected) { + } else if(signals.probe_disconnected) { if(sys.probing_state == Probing_Active && state_get() == STATE_CYCLE) { system_set_exec_state_flag(EXEC_FEED_HOLD); sys.alarm_pending = Alarm_ProbeProtect; } - } else if (signals.feed_hold) + } else if(signals.feed_hold) system_set_exec_state_flag(EXEC_FEED_HOLD); - else if (signals.cycle_start) { + else if(signals.cycle_start) { system_set_exec_state_flag(EXEC_CYCLE_START); sys.report.cycle_start = settings.status_report.pin_state; + gc_state.tool_change = false; } if(signals.block_delete)