Added option flag to $22 (Homing cycle) to run startup scripts only on homing completed.

Added API call modbus_isbusy() for checking if Modbus transaction is ongoing.
This commit is contained in:
Terje Io
2025-06-25 08:52:15 +02:00
parent e03e594ca5
commit 081f24f663
10 changed files with 84 additions and 20 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
## grblHAL ##
Latest build date is 20250618, see the [changelog](changelog.md) for details.
Latest build date is 20250625, 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.
@@ -89,4 +89,4 @@ G/M-codes not supported by [legacy Grbl](https://github.com/gnea/grbl/wiki) are
Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes.
---
20250521
20250525
+14
View File
@@ -1,5 +1,19 @@
## grblHAL changelog
<a name="20250625">Build 20250625
Core:
* Added option flag to $22 \(Homing cycle\) to run startup scripts only on homing completed.
* Added API call `modbus_isbusy()` for checking if Modbus transaction is ongoing.
Drivers:
* STM32F4xx: now skips RGB LED output via plain GPIO if there is an ongoing Modbus transaction. Allow setting RGB strip lengths to 0.
---
<a name="20250621">20250621
* Fix for typecast issue causing compile failure with some compilers. Ref issue [#761](https://github.com/grblHAL/core/issues/761).
+13 -3
View File
@@ -1482,7 +1482,7 @@ homing cycle while on the limit switch and not have to move the machine off of i
\brief
If enabled this allows using the homing $-commands to set the home position to the
current axis position.
\internal Bit 4 in settings.homing.flags.
\internal Bit 5 in settings.homing.flags.
*/
#if !defined DEFAULT_HOMING_ALLOW_MANUAL || defined __DOXYGEN__
#define DEFAULT_HOMING_ALLOW_MANUAL Off // Default disabled. Set to \ref On or 1 to enable.
@@ -1492,7 +1492,7 @@ current axis position.
\brief
If homing init lock is enabled this sets grblHAL into an alarm state upon power up or a soft reset.
To allow a soft reset to override the lock uncomment the line below.
\internal Bit 5 in settings.homing.flags.
\internal Bit 6 in settings.homing.flags.
*/
#if !defined DEFAULT_HOMING_OVERRIDE_LOCKS || defined __DOXYGEN__
#define DEFAULT_HOMING_OVERRIDE_LOCKS Off // Default disabled. Set to \ref On or 1 to enable.
@@ -1501,13 +1501,23 @@ To allow a soft reset to override the lock uncomment the line below.
/*! /def DEFAULT_HOMING_USE_LIMIT_SWITCHES
\brief
Enable this setting to force using limit switches for homing.
\internal Bit 7 in settings.homing.flags.
\internal Bit 8 in settings.homing.flags.
*/
#if !defined DEFAULT_HOMING_USE_LIMIT_SWITCHES || defined __DOXYGEN__
#define DEFAULT_HOMING_USE_LIMIT_SWITCHES Off // Default disabled. Set to \ref On or 1 to enable.
#endif
///@}
/*! /def DEFAULT_RUN_STARTUP_SCRIPTS_ONLY_ON_HOMED
\brief
Enable this setting to to only run startup scripts ($N0 and $N1) on homing completed.
\internal Bit 10 in settings.homing.flags.
*/
#if !defined DEFAULT_RUN_STARTUP_SCRIPTS_ONLY_ON_HOMED || defined __DOXYGEN__
#define DEFAULT_RUN_STARTUP_SCRIPTS_ONLY_ON_HOMED Off // Default disabled. Set to \ref On or 1 to enable.
#endif
///@}
/*! @name $23 - Setting_HomingDirMask
\ref axismask controlling the direction of movement during homing.
Unset bits in the mask results in movement in positive direction.
+1 -1
View File
@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20250618
#define GRBL_BUILD 20250625
#define GRBL_URL "https://github.com/grblHAL"
+27
View File
@@ -58,6 +58,33 @@ modbus_cap_t modbus_isup (void)
return cap;
}
bool modbus_isbusy (void)
{
bool busy = false;
uint_fast16_t idx = n_api;
if(idx) do {
idx--;
if(modbus[idx].is_busy) switch(modbus[idx].interface) {
case Modbus_InterfaceRTU:
busy = modbus[idx].is_busy();
break;
case Modbus_InterfaceASCII:
busy = modbus[idx].is_busy();
break;
case Modbus_InterfaceTCP:
busy = modbus[idx].is_busy();
break;
}
} while(idx && !busy);
return busy;
}
bool modbus_enabled (void)
{
return n_api > 0;
+3
View File
@@ -97,6 +97,7 @@ typedef bool (*modbus_is_up_ptr)(void);
typedef void (*modbus_flush_queue_ptr)(void);
typedef void (*modbus_set_silence_ptr)(const modbus_silence_timeout_t *timeout);
typedef bool (*modbus_send_ptr)(modbus_message_t *msg, const modbus_callbacks_t *callbacks, bool block);
typedef bool (*modbus_is_busy_ptr)(void);
typedef struct {
modbus_if_t interface;
@@ -104,9 +105,11 @@ typedef struct {
modbus_flush_queue_ptr flush_queue;
modbus_set_silence_ptr set_silence;
modbus_send_ptr send;
modbus_is_busy_ptr is_busy;
} modbus_api_t;
modbus_cap_t modbus_isup (void);
bool modbus_isbusy (void);
bool modbus_enabled (void);
void modbus_flush_queue (void);
void modbus_set_silence (const modbus_silence_timeout_t *timeout);
+7 -1
View File
@@ -453,6 +453,11 @@ static bool modbus_rtu_isup (void)
return is_up;
}
static bool modbus_is_busy (void)
{
return state != STATE_IDLE;
}
static void modbus_rtu_flush_queue (void)
{
while(spin_lock);
@@ -540,7 +545,8 @@ void modbus_rtu_init (int8_t stream, int8_t dir_aux)
.is_up = modbus_rtu_isup,
.flush_queue = modbus_rtu_flush_queue,
.set_silence = modbus_rtu_set_silence,
.send = modbus_send_rtu
.send = modbus_send_rtu,
.is_busy = modbus_is_busy
};
static setting_details_t setting_details = {
+2 -1
View File
@@ -174,7 +174,8 @@ bool protocol_main_loop (void)
}
#endif
// All systems go!
task_add_immediate(system_execute_startup, NULL); // Schedule startup script for execution.
if(!settings.homing.flags.nx_scrips_on_homed_only)
task_add_immediate(system_execute_startup, NULL); // Schedule startup script for execution.
}
// Ensure spindle and coolant is switched off on a cold start
+3 -1
View File
@@ -132,6 +132,7 @@ PROGMEM const settings_t defaults = {
.homing.flags.override_locks = DEFAULT_HOMING_OVERRIDE_LOCKS,
.homing.flags.keep_on_reset = DEFAULT_HOMING_KEEP_STATUS_ON_RESET,
.homing.flags.use_limit_switches = DEFAULT_HOMING_USE_LIMIT_SWITCHES,
.homing.flags.nx_scrips_on_homed_only = DEFAULT_RUN_STARTUP_SCRIPTS_ONLY_ON_HOMED,
#else
.homing.flags.value = 0,
#endif
@@ -414,7 +415,7 @@ PROGMEM static const setting_group_detail_t setting_group_detail [] = {
static bool machine_mode_changed = false;
#if COMPATIBILITY_LEVEL <= 1
static char probe_signals[] = "Probe,Toolsetter,Probe 2";
static char homing_options[] = "Enable,Enable single axis commands,Homing on startup required,Set machine origin to 0,Two switches shares one input,Allow manual,Override locks,N/A,Use limit switches,Per axis feedrates";
static char homing_options[] = "Enable,Enable single axis commands,Homing on startup required,Set machine origin to 0,Two switches shares one input,Allow manual,Override locks,N/A,Use limit switches,Per axis feedrates,Run startup scripts only on homing completed";
#else
static char probe_signals[] = "Probe";
#endif
@@ -998,6 +999,7 @@ static status_code_t set_homing_enable (setting_id_t id, uint_fast16_t int_value
settings.homing.flags.override_locks = DEFAULT_HOMING_OVERRIDE_LOCKS;
settings.homing.flags.keep_on_reset = DEFAULT_HOMING_KEEP_STATUS_ON_RESET;
settings.homing.flags.use_limit_switches = DEFAULT_HOMING_USE_LIMIT_SWITCHES;
settings.homing.flags.nx_scrips_on_homed_only = DEFAULT_RUN_STARTUP_SCRIPTS_ONLY_ON_HOMED;
settings.limits.flags.two_switches = DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES;
#else
settings.limits.flags.two_switches = settings.homing.flags.two_switches;
+12 -11
View File
@@ -682,17 +682,18 @@ typedef struct {
typedef union {
uint16_t value;
struct {
uint16_t enabled :1,
single_axis_commands :1,
init_lock :1,
force_set_origin :1,
two_switches :1, // -> limits.flags.two_switches, never set
manual :1,
override_locks :1,
keep_on_reset :1,
use_limit_switches :1,
per_axis_feedrates :1,
unused :6;
uint16_t enabled :1,
single_axis_commands :1,
init_lock :1,
force_set_origin :1,
two_switches :1, // -> limits.flags.two_switches, never set
manual :1,
override_locks :1,
keep_on_reset :1,
use_limit_switches :1,
per_axis_feedrates :1,
nx_scrips_on_homed_only :1,
unused :5;
};
} homing_settings_flags_t;