From ed2a392dd713e63b961200e60466ce05ca5033e3 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Sat, 18 Oct 2025 20:28:02 +0200 Subject: [PATCH] Added _probe2_state system parameter, returns -1 if probe 2 is not available, 1 if triggered and 0 if not. Fix for hang when G65 sub call level is > 2. Fix for crash when selecting a tool (with the T command) outside the tool table range. --- README.md | 2 +- changelog.md | 22 +++++++++++++++++++++- driver_opts.h | 12 ------------ driver_opts2.h | 16 ++++++++++++++++ grbl.h | 2 +- ngc_params.c | 5 +++++ ngc_params.h | 1 + settings.c | 23 ++++++++++++----------- stream_file.c | 2 +- 9 files changed, 58 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index cd15e98..9ae393a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## grblHAL ## -Latest build date is 20251016, see the [changelog](changelog.md) for details. +Latest build date is 20251018, see the [changelog](changelog.md) for details. > [!NOTE] > A settings reset will be performed on an update of builds prior to 20241208. Backup and restore of settings is recommended. diff --git a/changelog.md b/changelog.md index ac0dfd7..3655604 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,25 @@ ## grblHAL changelog +Build 20251018 + +Core: + +* Fix for crash when selecting a tool \(with the `T` command\) outside the tool table range. + +* Fix for hang when `G65` sub call level is > 2. + +* Added `_probe2_state` system parameter, returns `-1` if probe 2 is not available, `1` if triggered and `0` if not. + +Drivers: + +* ESP32: Changed SPI and SD card pin symbols to "standard" naming convention. + +* RP2040: fix for analog out auxiliary I/O not working. Ref. issue [#154](https://github.com/grblHAL/RP2040/issues/154). + +* STM32F4xx: fix for board map typo \(Protoneer 3.x\). + +--- + Build 20251016 Core: @@ -15,7 +35,7 @@ Drivers: * All: updated for move of probe signal handling to the core. -* RP2040: fixed "leak" of stepper signals between axes when plasma plugin is enabled, affects the PicoCNC board. +* RP2040: fixed "leak" of stepper signals between axes when plasma plugin is enabled, affects the PicoCNC board. Ref issue [#152](https://github.com/grblHAL/RP2040/issues/152). * ESP32: fix for compilation failure for boards using the SDIO interface for SD card interface. diff --git a/driver_opts.h b/driver_opts.h index 9f49d26..260cc3f 100644 --- a/driver_opts.h +++ b/driver_opts.h @@ -726,16 +726,4 @@ #define FS_ENABLE 0 #endif -#ifndef SDCARD_SDIO -#define SDCARD_SDIO 0 -#endif - -#ifndef SPI_ENABLE -#if (SDCARD_ENABLE && !SDCARD_SDIO) || TRINAMIC_SPI_ENABLE -#define SPI_ENABLE 1 -#else -#define SPI_ENABLE 0 -#endif -#endif - /*EOF*/ diff --git a/driver_opts2.h b/driver_opts2.h index 2c22efc..620e2e7 100644 --- a/driver_opts2.h +++ b/driver_opts2.h @@ -67,6 +67,22 @@ #define FLASH_ENABLE 0 #endif +#ifndef SDCARD_SDIO +#define SDCARD_SDIO 0 +#endif + +#ifndef SPI_ENABLE +#if (SDCARD_ENABLE && !SDCARD_SDIO) || TRINAMIC_SPI_ENABLE +#define SPI_ENABLE 1 +#else +#define SPI_ENABLE 0 +#endif +#endif + +#if SDCARD_ENABLE && !SDCARD_SDIO && !defined(SD_CS_PIN) +#error SD card plugin not supported! +#endif + // Expand port shorthand names #ifdef ENABLE_PORT diff --git a/grbl.h b/grbl.h index ec5bb58..e562a85 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20251016 +#define GRBL_BUILD 20251018 #define GRBL_URL "https://github.com/grblHAL" diff --git a/ngc_params.c b/ngc_params.c index 36cb98d..ab3b363 100644 --- a/ngc_params.c +++ b/ngc_params.c @@ -400,6 +400,7 @@ PROGMEM static const ngc_named_ro_param_t ngc_named_ro_param[] = { { .name = "_selected_pocket", .id = NGCParam_selected_pocket }, { .name = "_call_level", .id = NGCParam_call_level }, { .name = "_probe_state", .id = NGCParam_probe_state }, + { .name = "_probe2_state", .id = NGCParam_probe2_state }, { .name = "_toolsetter_state", .id = NGCParam_toolsetter_state }, { .name = "_homed_state", .id = NGCParam_homed_state }, { .name = "_homed_axes", .id = NGCParam_homed_axes }, @@ -615,6 +616,10 @@ float ngc_named_param_get_by_id (ncg_name_param_id_t id) value = hal.driver_cap.probe && hal.probe.is_triggered ? (float)hal.probe.is_triggered(Probe_Default) : -1.0f; break; + case NGCParam_probe2_state: + value = hal.driver_cap.probe2 && hal.probe.is_triggered ? (float)hal.probe.is_triggered(Probe_2) : -1.0f; + break; + case NGCParam_toolsetter_state: value = hal.driver_cap.toolsetter && hal.probe.is_triggered ? (float)hal.probe.is_triggered(Probe_Toolsetter) : -1.0f; break; diff --git a/ngc_params.h b/ngc_params.h index b247377..3abbfdb 100644 --- a/ngc_params.h +++ b/ngc_params.h @@ -101,6 +101,7 @@ typedef enum { NGCParam_selected_pocket, NGCParam_call_level, NGCParam_probe_state, + NGCParam_probe2_state, NGCParam_toolsetter_state, NGCParam_homed_state, NGCParam_homed_axes, diff --git a/settings.c b/settings.c index 3525ffa..de3fc89 100644 --- a/settings.c +++ b/settings.c @@ -2505,28 +2505,29 @@ bool settings_read_coord_data (coord_system_id_t id, const float (*coord_data)[N static tool_data_t tool_data[N_TOOLS + 1]; // Write selected tool data to persistent storage. -static bool settings_set_tool_data (tool_data_t *tool_data) +static bool settings_set_tool_data (tool_data_t *tool) { - assert(tool_data->tool_id > 0 && tool_data->tool_id <= N_TOOLS); // NOTE: idx 0 is a non-persistent entry for tools not in tool table + bool ok = tool->tool_id <= N_TOOLS; - if(hal.nvs.type != NVS_None) - hal.nvs.memcpy_to_nvs(NVS_ADDR_TOOL_TABLE + (tool_data->tool_id - 1) * (sizeof(tool_data_t) + NVS_CRC_BYTES), (uint8_t *)tool_data, sizeof(tool_data_t), true); + if(ok && tool->tool_id && hal.nvs.type != NVS_None) + hal.nvs.memcpy_to_nvs(NVS_ADDR_TOOL_TABLE + (tool->tool_id - 1) * (sizeof(tool_data_t) + NVS_CRC_BYTES), (uint8_t *)tool, sizeof(tool_data_t), true); - return true; + return ok; } // Read selected tool data from persistent storage. static tool_data_t *settings_get_tool_data (tool_id_t tool_id) { - assert(tool_id <= N_TOOLS); // NOTE: idx 0 is a non-persistent entry for tools not in tool table + tool_data_t *tool = tool_id <= N_TOOLS ? &tool_data[tool_id] : NULL; - if(tool_id && !(hal.nvs.type != NVS_None && hal.nvs.memcpy_from_nvs((uint8_t *)&tool_data[tool_id], NVS_ADDR_TOOL_TABLE + (tool_id - 1) * (sizeof(tool_data_t) + NVS_CRC_BYTES), - sizeof(tool_data_t), true) == NVS_TransferResult_OK && tool_data[tool_id].tool_id == tool_id)) { - memset(&tool_data[tool_id], 0, sizeof(tool_data_t)); - tool_data[tool_id].tool_id = tool_id; + if(tool_id && tool && !(hal.nvs.type != NVS_None && + hal.nvs.memcpy_from_nvs((uint8_t *)tool, NVS_ADDR_TOOL_TABLE + (tool_id - 1) * (sizeof(tool_data_t) + NVS_CRC_BYTES), + sizeof(tool_data_t), true) == NVS_TransferResult_OK && tool->tool_id == tool_id)) { + memset(tool, 0, sizeof(tool_data_t)); + tool->tool_id = tool_id; } - return &tool_data[tool_id]; + return tool; } // Clear all tool data in persistent storage. diff --git a/stream_file.c b/stream_file.c index 5d0565b..65a0a1e 100644 --- a/stream_file.c +++ b/stream_file.c @@ -157,7 +157,7 @@ vfs_file_t *stream_redirect_read (char *filename, status_message_ptr status_hand streams->next = rd_stream; break; } - } while((streams == streams->next)); + } while((streams = streams->next)); } else { vfs_close(file); file = NULL;