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.
This commit is contained in:
Terje Io
2025-10-18 20:28:02 +02:00
parent 106f5fd573
commit ed2a392dd7
9 changed files with 58 additions and 27 deletions

View File

@@ -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.

View File

@@ -1,5 +1,25 @@
## grblHAL changelog
<a name="20251018">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\).
---
<a name="20251016">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.

View File

@@ -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*/

View File

@@ -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

2
grbl.h
View File

@@ -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"

View File

@@ -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;

View File

@@ -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,

View File

@@ -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.

View File

@@ -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;