diff --git a/changelog.md b/changelog.md index 9fd8d53..cae8d7c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,20 @@ ## grblHAL changelog +Build 20240801 + +Core: + +* Added option bit for enabling realtime reporting while homing to `$10`, _Status report options_. Ref. [issue #551](https://github.com/grblHAL/core/issues/551). +__NOTE:__ Enabling this may affect some senders. + +Drivers: + +* iMXRT1062, LPC176x, SAM3X8E and STM32F1xx: moved board maps/board specific code to new _boards_ directory. + +* STM32F4xx: fixed regression in SD card code affecting boards using SDIO interface. + +--- + Build 20240719 Core: diff --git a/config.h b/config.h index 4f269ce..dc53aa7 100644 --- a/config.h +++ b/config.h @@ -696,6 +696,16 @@ The following codes are defined: #define DEFAULT_REPORT_RUN_SUBSTATE Off // Default off. Set to \ref On or 1 to enable. #endif +/*! \def DEFAULT_REPORT_WHEN_HOMING +\brief +Enabling this setting enables status reporting while homing. +
__NOTE:__ Enabling this option may break senders. +\internal Bit 12 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_WHEN_HOMING || defined __DOXYGEN__ +#define DEFAULT_REPORT_WHEN_HOMING Off // Default off. Set to \ref On or 1 to enable. +#endif + ///@} /*! @name $11 - Setting_JunctionDeviation diff --git a/grbl.h b/grbl.h index cfe386f..862dbb0 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20240719 +#define GRBL_BUILD 20240801 #define GRBL_URL "https://github.com/grblHAL" diff --git a/machine_limits.c b/machine_limits.c index 659c004..4231d59 100644 --- a/machine_limits.c +++ b/machine_limits.c @@ -273,6 +273,7 @@ static bool homing_cycle (axes_signals_t cycle, axes_signals_t auto_square) squaring_mode_t squaring_mode = SquaringMode_Both; coord_data_t target; plan_line_data_t plan_data; + rt_exec_t rt_exec, rt_exec_states = EXEC_SAFETY_DOOR|EXEC_RESET|EXEC_CYCLE_COMPLETE; plan_data_init(&plan_data); plan_data.condition.system_motion = On; @@ -320,6 +321,9 @@ static bool homing_cycle (axes_signals_t cycle, axes_signals_t auto_square) autosquare_fail_distance = truncf(fail_distance * settings.axis[dual_motor_axis].steps_per_mm); } + if(settings.status_report.when_homing) + rt_exec_states |= EXEC_STATUS_REPORT; + // Set search mode with approach at seek rate to quickly engage the specified cycle.mask limit switches. do { @@ -420,36 +424,40 @@ static bool homing_cycle (axes_signals_t cycle, axes_signals_t auto_square) st_prep_buffer(); // Check and prep segment buffer. // Exit routines: No time to run protocol_execute_realtime() in this loop. - if (sys.rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET | EXEC_CYCLE_COMPLETE)) { + if((rt_exec = (sys.rt_exec_state & rt_exec_states))) { - uint_fast16_t rt_exec = sys.rt_exec_state; - - // Homing failure condition: Reset issued during cycle. - if (rt_exec & EXEC_RESET) - system_set_exec_alarm(Alarm_HomingFailReset); - - // Homing failure condition: Safety door was opened. - if (rt_exec & EXEC_SAFETY_DOOR) - system_set_exec_alarm(Alarm_HomingFailDoor); - - hal.delay_ms(2, NULL); - - // Homing failure condition: Homing switch(es) still engaged after pull-off motion - if (mode == HomingMode_Pulloff && (homing_signals_select(hal.homing.get_state(), (axes_signals_t){0}, SquaringMode_Both).mask & cycle.mask)) - system_set_exec_alarm(Alarm_FailPulloff); - - // Homing failure condition: Limit switch not found during approach. - if (mode != HomingMode_Pulloff && (rt_exec & EXEC_CYCLE_COMPLETE)) - system_set_exec_alarm(Alarm_HomingFailApproach); - - if (sys.rt_exec_alarm) { - mc_reset(); // Stop motors, if they are running. - protocol_execute_realtime(); - return false; + if(rt_exec == EXEC_STATUS_REPORT) { + system_clear_exec_state_flag(EXEC_STATUS_REPORT); + report_realtime_status(); } else { - // Pull-off motion complete. Disable CYCLE_STOP from executing. - system_clear_exec_state_flag(EXEC_CYCLE_COMPLETE); - break; + + // Homing failure condition: Reset issued during cycle. + if (rt_exec & EXEC_RESET) + system_set_exec_alarm(Alarm_HomingFailReset); + + // Homing failure condition: Safety door was opened. + if (rt_exec & EXEC_SAFETY_DOOR) + system_set_exec_alarm(Alarm_HomingFailDoor); + + hal.delay_ms(2, NULL); + + // Homing failure condition: Homing switch(es) still engaged after pull-off motion + if (mode == HomingMode_Pulloff && (homing_signals_select(hal.homing.get_state(), (axes_signals_t){0}, SquaringMode_Both).mask & cycle.mask)) + system_set_exec_alarm(Alarm_FailPulloff); + + // Homing failure condition: Limit switch not found during approach. + if (mode != HomingMode_Pulloff && (rt_exec & EXEC_CYCLE_COMPLETE)) + system_set_exec_alarm(Alarm_HomingFailApproach); + + if (sys.rt_exec_alarm) { + mc_reset(); // Stop motors, if they are running. + protocol_execute_realtime(); + return false; + } else { + // Pull-off motion complete. Disable CYCLE_STOP from executing. + system_clear_exec_state_flag(EXEC_CYCLE_COMPLETE); + break; + } } } diff --git a/motion_control.c b/motion_control.c index fdd4e0d..0d7c6be 100644 --- a/motion_control.c +++ b/motion_control.c @@ -874,8 +874,10 @@ status_code_t mc_homing_cycle (axes_signals_t cycle) state_set(STATE_HOMING); // Set homing system state. #if COMPATIBILITY_LEVEL == 0 - system_set_exec_state_flag(EXEC_STATUS_REPORT); // Force a status report and - delay_sec(0.1f, DelayMode_Dwell); // delay a bit to get it sent (or perhaps wait a bit for a request?) + if(!settings.status_report.when_homing) { + system_set_exec_state_flag(EXEC_STATUS_REPORT); // Force a status report and + delay_sec(0.1f, DelayMode_Dwell); // delay a bit to get it sent (or perhaps wait a bit for a request?) + } #endif // Turn off spindle and coolant (and update parser state) if(spindle_is_on()) diff --git a/settings.c b/settings.c index c536406..4bcae74 100644 --- a/settings.c +++ b/settings.c @@ -144,6 +144,7 @@ PROGMEM const settings_t defaults = { .status_report.parser_state = DEFAULT_REPORT_PARSER_STATE, .status_report.alarm_substate = DEFAULT_REPORT_ALARM_SUBSTATE, .status_report.run_substate = DEFAULT_REPORT_RUN_SUBSTATE, + .status_report.when_homing = DEFAULT_REPORT_WHEN_HOMING, .limits.flags.hard_enabled = DEFAULT_HARD_LIMIT_ENABLE, .limits.flags.soft_enabled = DEFAULT_SOFT_LIMIT_ENABLE, .limits.flags.jog_soft_limited = DEFAULT_JOG_LIMIT_ENABLE, @@ -490,7 +491,7 @@ PROGMEM static const setting_detail_t setting_detail[] = { { Setting_GangedDirInvertMask, Group_Stepper, "Ganged axes direction invert", NULL, Format_Bitfield, ganged_axes, NULL, NULL, Setting_IsExtendedFn, set_ganged_dir_invert, get_int, is_setting_available }, { Setting_SpindlePWMOptions, Group_Spindle, "PWM Spindle", NULL, Format_XBitfield, "Enable,RPM controls spindle enable signal,Disable laser mode capability", NULL, NULL, Setting_IsExtendedFn, set_pwm_options, get_int, is_setting_available }, #if COMPATIBILITY_LEVEL <= 1 - { Setting_StatusReportMask, Group_General, "Status report options", NULL, Format_Bitfield, "Position in machine coordinate,Buffer state,Line numbers,Feed & speed,Pin state,Work coordinate offset,Overrides,Probe coordinates,Buffer sync on WCO change,Parser state,Alarm substatus,Run substatus", NULL, NULL, Setting_IsExtendedFn, set_report_mask, get_int, NULL }, + { Setting_StatusReportMask, Group_General, "Status report options", NULL, Format_Bitfield, "Position in machine coordinate,Buffer state,Line numbers,Feed & speed,Pin state,Work coordinate offset,Overrides,Probe coordinates,Buffer sync on WCO change,Parser state,Alarm substatus,Run substatus,Enable when homing", NULL, NULL, Setting_IsExtendedFn, set_report_mask, get_int, NULL }, #else { Setting_StatusReportMask, Group_General, "Status report options", NULL, Format_Bitfield, "Position in machine coordinate,Buffer state", NULL, NULL, Setting_IsLegacyFn, set_report_mask, get_int, NULL }, #endif @@ -661,7 +662,7 @@ PROGMEM static const setting_descr_t setting_descr[] = { { Setting_GangedDirInvertMask, "Inverts the direction signals for the second motor used for ganged axes.\\n\\n" "NOTE: This inversion will be applied in addition to the inversion from setting $3." }, - { Setting_StatusReportMask, "Specifies optional data included in status reports.\\n" + { Setting_StatusReportMask, "Specifies optional data included in status reports and if report is sent when homing.\\n" "If Run substatus is enabled it may be used for simple probe protection.\\n\\n" "NOTE: Parser state will be sent separately after the status report and only on changes." }, diff --git a/settings.h b/settings.h index 4192492..8f67ad6 100644 --- a/settings.h +++ b/settings.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2023 Terje Io + Copyright (c) 2017-2024 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -565,7 +565,8 @@ typedef union { parser_state :1, alarm_substate :1, run_substate :1, - unassigned :4; + when_homing :1, + unassigned :3; }; } reportmask_t; diff --git a/stream.c b/stream.c index ad2d921..96faf70 100644 --- a/stream.c +++ b/stream.c @@ -761,8 +761,10 @@ void debug_printf (const char *fmt, ...) if(hal.stream.write) { report_message(debug_out, Message_Debug); - while(hal.stream.get_tx_buffer_count()) // Wait until message is delivered - grbl.on_execute_realtime(state_get()); + if(hal.stream.get_tx_buffer_count) { + while(hal.stream.get_tx_buffer_count()) // Wait until message is delivered + grbl.on_execute_realtime(state_get()); + } } }