mirror of
https://github.com/grblHAL/core.git
synced 2026-08-17 08:31:43 +08:00
Changed real time reporting to allow per connection status for which report elements to output.
Added pragmas to shut up warning from the ESP32 compiler.
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
## grblHAL changelog
|
||||
|
||||
<a name="20260203">20260203
|
||||
|
||||
Core:
|
||||
|
||||
* Changed real time reporting to allow per connection flags for which report elements to output.
|
||||
|
||||
* Added pragmas to shut up warnings from the ESP32 compiler.
|
||||
|
||||
Plugins:
|
||||
|
||||
* Keypad, I2C display interface: Updated to v2. The first byte in the message has been changed to hold the version number, this has been changed from 1 to 2.
|
||||
The main other changes are the machine state code is now according to the [official version](https://github.com/grblHAL/core/blob/08c778530ca5b476d22b73244366e32db7993302/system.h#L88-L110) and
|
||||
position etc. is converted to imperial when $13=1. Ref. PR [#20](https://github.com/grblHAL/Plugin_keypad/pull/20).
|
||||
|
||||
* Fans, Laser, Spindle, Encoder: updated for core change.
|
||||
|
||||
---
|
||||
|
||||
<a name="20260202">20260202
|
||||
|
||||
Core:
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2016-2025 Terje Io
|
||||
Copyright (c) 2016-2026 Terje Io
|
||||
Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
|
||||
grblHAL is free software: you can redistribute it and/or modify
|
||||
@@ -34,7 +34,7 @@ void coolant_restore (coolant_state_t mode, uint16_t on_delay_ms)
|
||||
hal.coolant.set_state(mode);
|
||||
if(mode.value && on_delay_ms)
|
||||
delay_sec((float)on_delay_ms / 1000.0f, sys.suspend ? DelayMode_SysSuspend : DelayMode_Dwell);
|
||||
system_add_rt_report(Report_Coolant);
|
||||
report_add_realtime(Report_Coolant);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void coolant_set_state (coolant_state_t mode)
|
||||
hal.coolant.set_state(mode);
|
||||
if(mode.value && settings.coolant.on_delay)
|
||||
delay_sec((float)settings.coolant.on_delay / 1000.0f, DelayMode_Dwell);
|
||||
system_add_rt_report(Report_Coolant);
|
||||
report_add_realtime(Report_Coolant);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ typedef union {
|
||||
G4 :1, //!< [G91.1] Arc IJK distance mode
|
||||
G5 :1, //!< [G93,G94,G95] Feed rate mode
|
||||
G6 :1, //!< [G20,G21] Units
|
||||
G7 :1, //!< [G40] Cutter radius compensation mode. G41/42 NOT SUPPORTED.
|
||||
G7 :1, //!< [G40,G41,G41.1,G42,G42.1] Cutter radius compensation mode. ONLY G40 SUPPORTED.
|
||||
G8 :1, //!< [G43,G43.1,G49] Tool length offset
|
||||
G10 :1, //!< [G98,G99] Return mode in canned cycles
|
||||
G11 :1, //!< [G50,G51] Scaling
|
||||
@@ -80,7 +80,7 @@ typedef union {
|
||||
G15 :1, //!< [G7,G8] Lathe Diameter Mode
|
||||
// G16 :1, //!< [G66,G67] Modal macro call (12)
|
||||
|
||||
M4 :1, //!< [M0,M1,M2,M30] Stopping
|
||||
M4 :1, //!< [M0,M1,M2,M30,M99] Stopping
|
||||
M5 :1, //!< [M62,M63,M64,M65,M66,M67,M68] Aux I/O
|
||||
M6 :1, //!< [M6] Tool change
|
||||
M7 :1, //!< [M3,M4,M5] Spindle turning
|
||||
@@ -250,7 +250,7 @@ static void set_scaling (float factor)
|
||||
gc_state.modal.scaling_active = factor != 1.0f;
|
||||
|
||||
if(state.value != gc_get_g51_state().value)
|
||||
system_add_rt_report(Report_Scaling);
|
||||
report_add_realtime(Report_Scaling);
|
||||
}
|
||||
|
||||
float *gc_get_scaling (void)
|
||||
@@ -324,7 +324,7 @@ void gc_set_tool_offset (tool_offset_mode_t mode, uint_fast8_t idx, int32_t offs
|
||||
gc_state.modal.tool_offset_mode = mode;
|
||||
|
||||
if(tlo_changed) {
|
||||
system_add_rt_report(Report_ToolOffset);
|
||||
report_add_realtime(Report_ToolOffset);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
}
|
||||
@@ -592,12 +592,12 @@ bool gc_modal_state_restore (gc_modal_snapshot_t *snapshot)
|
||||
coolant_restore(gc_state.modal.coolant, settings.coolant.on_delay);
|
||||
|
||||
if(actions->command.G12) {
|
||||
system_add_rt_report(Report_GWCO);
|
||||
report_add_realtime(Report_GWCO);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
|
||||
if(actions->command.G15)
|
||||
system_add_rt_report(Report_LatheXMode);
|
||||
report_add_realtime(Report_LatheXMode);
|
||||
|
||||
for(idx = 0; idx < N_SYS_SPINDLE; idx++) {
|
||||
if(actions->update_spindle[idx]) {
|
||||
@@ -837,14 +837,14 @@ void gc_spindle_off (void)
|
||||
}
|
||||
|
||||
spindle_all_off();
|
||||
system_add_rt_report(Report_Spindle);
|
||||
report_add_realtime(Report_Spindle);
|
||||
}
|
||||
|
||||
void gc_coolant (coolant_state_t state)
|
||||
{
|
||||
gc_state.modal.coolant = state;
|
||||
hal.coolant.set_state(gc_state.modal.coolant);
|
||||
system_add_rt_report(Report_Coolant);
|
||||
report_add_realtime(Report_Coolant);
|
||||
}
|
||||
|
||||
static void add_offset (const coord_data_t *offset)
|
||||
@@ -2540,7 +2540,7 @@ status_code_t gc_execute_block (char *block)
|
||||
report_scaling |= scale_factor.ijk[idx] != gc_block.values.xyz[idx];
|
||||
scale_factor.ijk[idx] = gc_block.values.xyz[idx];
|
||||
bit_false(axis_words.mask, bit(idx));
|
||||
system_add_rt_report(Report_Scaling);
|
||||
report_add_realtime(Report_Scaling);
|
||||
}
|
||||
gc_block.modal.scaling_active = gc_block.modal.scaling_active || (scale_factor.xyz[idx] != 1.0f);
|
||||
} while(idx);
|
||||
@@ -2582,7 +2582,7 @@ status_code_t gc_execute_block (char *block)
|
||||
gc_state.modal.scaling_active = gc_block.modal.scaling_active;
|
||||
|
||||
if(report_scaling)
|
||||
system_add_rt_report(Report_Scaling);
|
||||
report_add_realtime(Report_Scaling);
|
||||
|
||||
} else
|
||||
set_scaling(1.0f);
|
||||
@@ -2722,7 +2722,10 @@ status_code_t gc_execute_block (char *block)
|
||||
p_value = (uint8_t)truncf(gc_block.values.p); // Convert p value to int.
|
||||
|
||||
switch(gc_block.values.l) {
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
||||
#endif
|
||||
case 2:
|
||||
#ifndef ROTATION_ENABLE
|
||||
if(gc_block.words.r)
|
||||
@@ -2767,7 +2770,9 @@ status_code_t gc_execute_block (char *block)
|
||||
} // else, keep current stored value.
|
||||
} while(idx);
|
||||
break;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
case 1: case 10:
|
||||
#if COMPATIBILITY_LEVEL <= 1
|
||||
case 11:
|
||||
@@ -3679,14 +3684,14 @@ status_code_t gc_execute_block (char *block)
|
||||
if(grbl.on_tool_changed)
|
||||
grbl.on_tool_changed(gc_state.tool);
|
||||
|
||||
system_add_rt_report(Report_Tool);
|
||||
report_add_realtime(Report_Tool);
|
||||
}
|
||||
|
||||
// Prepare tool carousel when available
|
||||
if(hal.tool.select)
|
||||
hal.tool.select(pending_tool, !set_tool);
|
||||
else
|
||||
system_add_rt_report(Report_Tool);
|
||||
report_add_realtime(Report_Tool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3708,7 +3713,7 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
case IoMCode_WaitOnInput:
|
||||
sys.var5399 = ioport_wait_on_input((io_port_type_t)gc_block.output_command.is_digital, gc_block.output_command.port, (wait_mode_t)gc_block.values.l, gc_block.values.q);
|
||||
system_add_rt_report(Report_M66Result);
|
||||
report_add_realtime(Report_M66Result);
|
||||
break;
|
||||
|
||||
case IoMCode_AnalogOutSynced:
|
||||
@@ -3756,7 +3761,7 @@ status_code_t gc_execute_block (char *block)
|
||||
#endif
|
||||
RETURN((status_code_t)int_value);
|
||||
}
|
||||
system_add_rt_report(Report_Tool);
|
||||
report_add_realtime(Report_Tool);
|
||||
} else { // Manual
|
||||
int_value = (uint_fast16_t)Status_OK;
|
||||
gc_state.tool_change = true;
|
||||
@@ -3873,7 +3878,7 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
actions->command.G8 = Off;
|
||||
system_flag_wco_change();
|
||||
system_add_rt_report(Report_ToolOffset);
|
||||
report_add_realtime(Report_ToolOffset);
|
||||
|
||||
gc_state.modal.tool_offset_mode = gc_block.modal.tool_offset_mode;
|
||||
memcpy(&gc_state.modal.tool_length_offset, &snapshot->modal.tool_length_offset, sizeof(gc_state.modal.tool_length_offset));
|
||||
@@ -4028,7 +4033,7 @@ status_code_t gc_execute_block (char *block)
|
||||
} while(idx);
|
||||
|
||||
if(tlo_changed) {
|
||||
system_add_rt_report(Report_ToolOffset);
|
||||
report_add_realtime(Report_ToolOffset);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
}
|
||||
@@ -4036,7 +4041,7 @@ status_code_t gc_execute_block (char *block)
|
||||
// [15. Coordinate system selection ]:
|
||||
if(command_words.G12) {
|
||||
memcpy(&gc_state.modal.g5x_offset, &gc_block.modal.g5x_offset, sizeof(coord_system_t));
|
||||
system_add_rt_report(Report_GWCO);
|
||||
report_add_realtime(Report_GWCO);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
|
||||
@@ -4053,7 +4058,7 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
if(command_words.G15) {
|
||||
gc_state.modal.diameter_mode = gc_block.modal.diameter_mode;
|
||||
system_add_rt_report(Report_LatheXMode);
|
||||
report_add_realtime(Report_LatheXMode);
|
||||
}
|
||||
|
||||
// [18. Set retract mode ]:
|
||||
@@ -4451,7 +4456,7 @@ status_code_t gc_execute_block (char *block)
|
||||
// gc_state.modal.cutter_comp = CUTTER_COMP_DISABLE; // Not supported.
|
||||
if(gc_state.modal.g5x_offset.id != CoordinateSystem_G54) {
|
||||
gc_state.modal.g5x_offset.id = CoordinateSystem_G54;
|
||||
system_add_rt_report(Report_GWCO);
|
||||
report_add_realtime(Report_GWCO);
|
||||
}
|
||||
gc_state.modal.coolant = (coolant_state_t){0};
|
||||
gc_state.modal.override_ctrl.feed_rates_disable = Off;
|
||||
@@ -4503,8 +4508,8 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
spindle_all_off();
|
||||
hal.coolant.set_state(gc_state.modal.coolant);
|
||||
system_add_rt_report(Report_Spindle); // Set to report change
|
||||
system_add_rt_report(Report_Coolant); // immediately.
|
||||
report_add_realtime(Report_Spindle); // Set to report change
|
||||
report_add_realtime(Report_Coolant); // immediately.
|
||||
}
|
||||
|
||||
if(grbl.on_program_completed)
|
||||
|
||||
@@ -135,7 +135,11 @@ typedef enum {
|
||||
} feed_mode_t;
|
||||
|
||||
// Modal Group G7: Cutter radius compensation mode
|
||||
//#define CUTTER_COMP_DISABLE 0 // G40 - Default, must be zero
|
||||
typedef enum {
|
||||
CComp_Off = 0, //!< 0 - G40 - Default, must be zero
|
||||
CComp_Left, //!< 1 - G41, G41.1
|
||||
CComp_Right //!< 2 - G42, G42.1
|
||||
} ccomp_mode_t;
|
||||
|
||||
/*! Modal Group G8: Tool length offset
|
||||
|
||||
@@ -326,6 +330,12 @@ typedef enum {
|
||||
#endif
|
||||
} gc_probe_t;
|
||||
|
||||
typedef struct {
|
||||
ccomp_mode_t side;
|
||||
bool first_move;
|
||||
float radius;
|
||||
} gc_ccomp_t;
|
||||
|
||||
//! Parser flags for special cases.
|
||||
typedef union {
|
||||
uint16_t value;
|
||||
@@ -489,7 +499,7 @@ typedef struct {
|
||||
bool diameter_mode; //!< {G7,G8} Lathe diameter mode.
|
||||
//< uint8_t distance_arc; //!< {G91.1} NOTE: Don't track. Only default supported.
|
||||
plane_select_t plane_select; //!< {G17,G18,G19}
|
||||
//< uint8_t cutter_comp; //!< {G40} NOTE: Don't track. Only default supported.
|
||||
//< gc_ccomp_t cutter_comp; //!< {G40,G41,G41.1,G42,G42.1} NOTE: Don't track. Only default (G40) supported.
|
||||
tool_offset_mode_t tool_offset_mode; //!< {G43,G43.1,G49}
|
||||
coord_system_t g5x_offset; //!< {G54,G55,G56,G57,G58,G59,G59.1,G59.2,G59.3}
|
||||
#if ENABLE_PATH_BLENDING
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#else
|
||||
#define GRBL_VERSION "1.1f"
|
||||
#endif
|
||||
#define GRBL_BUILD 20260202
|
||||
#define GRBL_BUILD 20260203
|
||||
|
||||
#define GRBL_URL "https://github.com/grblHAL"
|
||||
|
||||
@@ -109,10 +109,9 @@
|
||||
#define CMD_FEED_HOLD_LEGACY '!'
|
||||
#define CMD_PROGRAM_DEMARCATION '%'
|
||||
|
||||
// NOTE: All override realtime commands must be in the extended ASCII character set, starting
|
||||
// at character value 128 (0x80) and up to 255 (0xFF). If the normal set of realtime commands,
|
||||
// such as status reports, feed hold, reset, and cycle start, are moved to the extended set
|
||||
// space, protocol.c's protocol_process_realtime() will need to be modified to accommodate the change.
|
||||
// NOTE: All realtime commands must be in the extended ASCII character set, starting
|
||||
// at character value 128 (0x80) and up to 191 (0xBF). Do not assign values > 191 since those
|
||||
// are for the first character in UTF-8 code points.
|
||||
#define CMD_STATUS_REPORT 0x80 // (128) TODO: use 0x05 ctrl-E ENQ instead?
|
||||
#define CMD_CYCLE_START 0x81 // (129) TODO: use 0x06 ctrl-F ACK instead? or SYN/DC2/DC3?
|
||||
#define CMD_FEED_HOLD 0x82 // (130) TODO: use 0x15 ctrl-U NAK instead?
|
||||
|
||||
+1
-1
@@ -438,7 +438,7 @@ static bool homing_cycle (axes_signals_t cycle, axes_signals_t auto_square)
|
||||
|
||||
if(rt_exec == EXEC_STATUS_REPORT) {
|
||||
system_clear_exec_state_flag(EXEC_STATUS_REPORT);
|
||||
report_realtime_status(hal.stream.write_all, system_get_rt_report_flags());
|
||||
report_realtime_status(hal.stream.write_all, &hal.stream.report);
|
||||
} else {
|
||||
|
||||
// Homing failure condition: Reset issued during cycle.
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2017-2025 Terje Io
|
||||
Copyright (c) 2017-2026 Terje Io
|
||||
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
@@ -971,7 +971,7 @@ status_code_t mc_homing_cycle (axes_signals_t cycle)
|
||||
sync_position();
|
||||
}
|
||||
|
||||
system_add_rt_report(Report_Homed);
|
||||
report_add_realtime(Report_Homed);
|
||||
|
||||
homed_status = settings.limits.flags.hard_enabled &&
|
||||
settings.limits.flags.check_at_init &&
|
||||
|
||||
+10
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2021-2025 Terje Io
|
||||
Copyright (c) 2021-2026 Terje Io
|
||||
|
||||
grblHAL is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -23,6 +23,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wexpansion-to-defined"
|
||||
#endif
|
||||
|
||||
#define CAT(a, b) CAT_(a, b)
|
||||
#define CAT_(a, b) a##b
|
||||
|
||||
@@ -1419,4 +1424,8 @@ static inline home_signals_t get_motor_fault_cap (void)
|
||||
return motor_fault;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/*EOF*/
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2021-2025 Terje Io
|
||||
Copyright (c) 2021-2026 Terje Io
|
||||
|
||||
grblHAL is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -1129,7 +1129,7 @@ static status_code_t macro_select_probe (parameter_words_t args)
|
||||
if(!args.q)
|
||||
status = Status_GcodeValueWordMissing;
|
||||
else if(ngc_param_get(17 /* Q word */, &probe_id) && (hal.probe.select ? hal.probe.select((probe_id_t)probe_id) : probe_id == 0.0f))
|
||||
system_add_rt_report(Report_ProbeId);
|
||||
report_add_realtime(Report_ProbeId);
|
||||
else
|
||||
status = Status_GcodeValueOutOfRange;
|
||||
|
||||
|
||||
+2
-2
@@ -321,7 +321,7 @@ static inline void aux_ctrl_claim_ports (aux_claim_explicit_ptr aux_claim_explic
|
||||
if(aux_claim == NULL)
|
||||
aux_claim = __claim_in_port;
|
||||
|
||||
for(idx = 0; idx < sizeof(aux_ctrl) / sizeof(aux_ctrl_t); idx++) {
|
||||
if(sizeof(aux_ctrl)) for(idx = 0; idx < sizeof(aux_ctrl) / sizeof(aux_ctrl_t); idx++) {
|
||||
|
||||
if(aux_ctrl[idx].port != IOPORT_UNASSIGNED)
|
||||
aux_claim_explicit(&aux_ctrl[idx]);
|
||||
@@ -511,7 +511,7 @@ static inline void aux_ctrl_claim_out_ports (aux_claim_explicit_out_ptr aux_clai
|
||||
if(aux_claim_explicit == NULL)
|
||||
aux_claim_explicit = ___claim_out_port_explicit;
|
||||
|
||||
for(idx = 0; idx < sizeof(aux_ctrl_out) / sizeof(aux_ctrl_out_t); idx++) {
|
||||
if(sizeof(aux_ctrl_out)) for(idx = 0; idx < sizeof(aux_ctrl_out) / sizeof(aux_ctrl_out_t); idx++) {
|
||||
if(aux_ctrl_out[idx].gpio.port == (void *)EXPANDER_PORT) {
|
||||
if(ioports_enumerate(Port_Digital, Port_Output, (pin_cap_t){ .external = On, .claimable = On }, aux_claim, &aux_ctrl_out[idx])) {
|
||||
if((aux_ctrl_out[idx].output = ioport_claim(Port_Digital, Port_Output, &aux_ctrl_out[idx].port, NULL /*xbar_fn_to_pinname(aux_ctrl_out[idx].function)*/))) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2017-2025 Terje Io
|
||||
Copyright (c) 2017-2026 Terje Io
|
||||
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
Copyright (c) 2011 Jens Geisler
|
||||
@@ -767,7 +767,7 @@ void plan_feed_override (override_t feed_override, override_t rapid_override)
|
||||
(rapidrate_changed = rapid_override != sys.override.rapid_rate)) {
|
||||
sys.override.feed_rate = feed_override;
|
||||
sys.override.rapid_rate = rapid_override;
|
||||
system_add_rt_report(Report_Overrides); // Set to report change immediately
|
||||
report_add_realtime(Report_Overrides); // Set to report change immediately
|
||||
if(plan_update_velocity_profile_parameters())
|
||||
plan_cycle_reinitialize();
|
||||
if(grbl.on_override_changed) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2025 Terje Io
|
||||
Copyright (c) 2025-2026 Terje Io
|
||||
|
||||
grblHAL is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -58,7 +58,7 @@ static void probe_connected_toggle (void)
|
||||
probe->flags.guarded = probe_state.irq_enabled = Off;
|
||||
|
||||
if(settings.probe.enable_protection)
|
||||
system_add_rt_report(Report_ProbeProtect);
|
||||
report_add_realtime(Report_ProbeProtect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ static void probe_configure (bool is_probe_away, bool probing)
|
||||
}
|
||||
|
||||
if(settings.probe.enable_protection)
|
||||
system_add_rt_report(Report_ProbeProtect);
|
||||
report_add_realtime(Report_ProbeProtect);
|
||||
|
||||
if(!probe_state.irq_enabled)
|
||||
probe_state.triggered = Off;
|
||||
|
||||
+3
-3
@@ -499,7 +499,7 @@ bool protocol_exec_rt_system (void)
|
||||
|
||||
if(bit_istrue(sys.rt_exec_state, EXEC_STATUS_REPORT)) {
|
||||
system_clear_exec_state_flag(EXEC_STATUS_REPORT);
|
||||
report_realtime_status(hal.stream.write_all, system_get_rt_report_flags());
|
||||
report_realtime_status(hal.stream.write_all, &hal.stream.report);
|
||||
}
|
||||
|
||||
protocol_poll_cmd();
|
||||
@@ -599,7 +599,7 @@ bool protocol_exec_rt_system (void)
|
||||
|
||||
// Execute and print status to output stream
|
||||
if (rt_exec & EXEC_STATUS_REPORT)
|
||||
report_realtime_status(hal.stream.write_all, system_get_rt_report_flags());
|
||||
report_realtime_status(hal.stream.write_all, &hal.stream.report);
|
||||
|
||||
if(rt_exec & EXEC_GCODE_REPORT)
|
||||
report_gcode_modes(hal.stream.write);
|
||||
@@ -860,7 +860,7 @@ ISR_CODE bool ISR_FUNC(protocol_enqueue_realtime_command)(uint8_t c)
|
||||
#endif
|
||||
|
||||
case CMD_STATUS_REPORT_ALL: // Add all statuses to report
|
||||
system_add_rt_report(report_get_rt_flags_all().value);
|
||||
hal.stream.report.flags.value = report_get_rt_flags_all().value;
|
||||
system_set_exec_state_flag(EXEC_STATUS_REPORT);
|
||||
drop = true;
|
||||
break;
|
||||
|
||||
@@ -49,8 +49,6 @@ static char buf[(STRLEN_COORDVALUE + 1) * N_AXIS];
|
||||
static char *(*get_axis_values)(float *axis_values);
|
||||
static char *(*get_axis_value)(float value);
|
||||
static char *(*get_rate_value)(float value);
|
||||
static uint8_t override_counter = 0; // Tracks when to add override data to status reports.
|
||||
static uint8_t wco_counter = 0; // Tracks when to add work coordinate offset data to status reports.
|
||||
static const char vbar[2] = { '|', '\0' };
|
||||
|
||||
// Append a number of strings to the static buffer
|
||||
@@ -312,7 +310,7 @@ static message_code_t report_feedback_message (message_code_t id)
|
||||
// Welcome message
|
||||
static void report_init_message (stream_write_ptr write)
|
||||
{
|
||||
override_counter = wco_counter = 0;
|
||||
hal.stream.report.override_counter = hal.stream.report.wco_counter = 0;
|
||||
|
||||
#if COMPATIBILITY_LEVEL == 0
|
||||
write(ASCII_EOL "GrblHAL " GRBL_VERSION " ['$' or '$HELP' for help]" ASCII_EOL);
|
||||
@@ -1184,7 +1182,7 @@ static bool report_spindle_num (spindle_info_t *spindle, void *data)
|
||||
// specific needs, but the desired real-time data report must be as short as possible. This is
|
||||
// requires as it minimizes the computational overhead and allows grblHAL to keep running smoothly,
|
||||
// especially during g-code programs with fast, short line segments and high frequency reports (5-20Hz).
|
||||
void report_realtime_status (stream_write_ptr stream_write, report_tracking_flags_t report)
|
||||
void report_realtime_status (stream_write_ptr stream_write, status_report_tracking_t *report)
|
||||
{
|
||||
static bool probing = false;
|
||||
|
||||
@@ -1236,7 +1234,7 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
|
||||
case STATE_ESTOP:
|
||||
case STATE_ALARM:
|
||||
if((report.all || settings.status_report.alarm_substate) && sys.alarm)
|
||||
if((report->flags.all || settings.status_report.alarm_substate) && sys.alarm)
|
||||
stream_write(appendbuf(2, "Alarm:", uitoa((uint32_t)sys.alarm)));
|
||||
else
|
||||
stream_write("Alarm");
|
||||
@@ -1261,10 +1259,10 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
|
||||
system_convert_array_steps_to_mpos(print_position, sys.position);
|
||||
|
||||
if((report.distance_to_go = settings.status_report.distance_to_go)) {
|
||||
if((report->flags.distance_to_go = settings.status_report.distance_to_go)) {
|
||||
// Calculate distance-to-go in current block (i.e., difference between target / end-of-block) and current position)
|
||||
plan_block_t *cur_block = plan_get_current_block();
|
||||
if((report.distance_to_go = !!cur_block)) {
|
||||
if((report->flags.distance_to_go = !!cur_block)) {
|
||||
for(idx = 0; idx < N_AXIS; idx++) {
|
||||
dist_remaining[idx] = cur_block->target_mm[idx] - print_position[idx];
|
||||
}
|
||||
@@ -1300,7 +1298,7 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
stream_write(appendbuf(2, "|Ln:", uitoa(line_number)));
|
||||
}
|
||||
|
||||
if(report.distance_to_go) {
|
||||
if(report->flags.distance_to_go) {
|
||||
// Report distance-to-go.
|
||||
stream_write("|DTG:");
|
||||
stream_write(get_axis_values(dist_remaining));
|
||||
@@ -1362,7 +1360,7 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
|
||||
ctrl_pin_state.probe_triggered = probe_state.triggered;
|
||||
ctrl_pin_state.probe_disconnected = !probe_state.connected;
|
||||
ctrl_pin_state.cycle_start |= report.cycle_start;
|
||||
ctrl_pin_state.cycle_start |= report->flags.cycle_start;
|
||||
if(sys.flags.value & sys_switches.value) {
|
||||
if(!hal.signals_cap.stop_disable)
|
||||
ctrl_pin_state.stop_disable = sys.flags.optional_stop_disable;
|
||||
@@ -1391,45 +1389,45 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
|
||||
if(settings.status_report.overrides) {
|
||||
|
||||
if((report.overrides = override_counter == 0 || report.overrides)) {
|
||||
if((report->flags.overrides = report->override_counter == 0 || report->flags.overrides)) {
|
||||
|
||||
override_counter = state & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR)
|
||||
? (REPORT_OVERRIDE_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh
|
||||
: (REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1);
|
||||
report->override_counter = state & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR)
|
||||
? (REPORT_OVERRIDE_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh
|
||||
: (REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1);
|
||||
|
||||
if(!report.all) {
|
||||
report.spindle = report.spindle || spindle_0_state.on;
|
||||
report.coolant = report.coolant || hal.coolant.get_state().value != 0;
|
||||
if(!report->flags.all) {
|
||||
report->flags.spindle = report->flags.spindle || spindle_0_state.on;
|
||||
report->flags.coolant = report->flags.coolant || hal.coolant.get_state().value != 0;
|
||||
}
|
||||
} else
|
||||
override_counter--;
|
||||
report->override_counter--;
|
||||
|
||||
if(override_counter > (REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1) && state == STATE_IDLE)
|
||||
override_counter = REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1;
|
||||
if(report->override_counter > (REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1) && state == STATE_IDLE)
|
||||
report->override_counter = REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1;
|
||||
} else
|
||||
report.overrides = Off;
|
||||
report->flags.overrides = Off;
|
||||
|
||||
if(settings.status_report.work_coord_offset) {
|
||||
|
||||
if(wco_counter == 0 || report.wco || report.force_wco || report.gwco || report.all) {
|
||||
if(report->wco_counter == 0 || report->flags.wco || report->flags.force_wco || report->flags.gwco || report->flags.all) {
|
||||
|
||||
wco_counter = state & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR)
|
||||
? (REPORT_WCO_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh
|
||||
: (REPORT_WCO_REFRESH_IDLE_COUNT - 1);
|
||||
report->wco_counter = state & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR)
|
||||
? (REPORT_WCO_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh
|
||||
: (REPORT_WCO_REFRESH_IDLE_COUNT - 1);
|
||||
|
||||
if(!(report.wco = !report.overrides || report.all || report.force_wco || report.gwco))
|
||||
if(!(report->flags.wco = !report->flags.overrides || report->flags.all || report->flags.force_wco || report->flags.gwco))
|
||||
delayed_report.wco = On;
|
||||
} else
|
||||
wco_counter--;
|
||||
report->wco_counter--;
|
||||
|
||||
if(wco_counter > (REPORT_WCO_REFRESH_IDLE_COUNT - 1) && state == STATE_IDLE)
|
||||
wco_counter = REPORT_WCO_REFRESH_IDLE_COUNT - 1;
|
||||
if(report->wco_counter > (REPORT_WCO_REFRESH_IDLE_COUNT - 1) && state == STATE_IDLE)
|
||||
report->wco_counter = REPORT_WCO_REFRESH_IDLE_COUNT - 1;
|
||||
} else
|
||||
report.wco = Off;
|
||||
report->flags.wco = Off;
|
||||
|
||||
if(report.value || gc_state.tool_change) {
|
||||
if(report->flags.value || gc_state.tool_change) {
|
||||
|
||||
if(report.wco) {
|
||||
if(report->flags.wco) {
|
||||
if(settings.status_report.machine_position) {
|
||||
for(idx = 0; idx < N_AXIS; idx++)
|
||||
wco[idx] = gc_get_offset(idx, true);
|
||||
@@ -1442,18 +1440,18 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
#endif
|
||||
}
|
||||
|
||||
if(report.gwco) {
|
||||
if(report->flags.gwco) {
|
||||
stream_write("|WCS:");
|
||||
stream_write(gc_coord_system_to_str(gc_state.modal.g5x_offset.id));
|
||||
}
|
||||
|
||||
if(report.overrides) {
|
||||
if(report->flags.overrides) {
|
||||
stream_write(appendbuf(2, "|Ov:", uitoa((uint32_t)sys.override.feed_rate)));
|
||||
stream_write(appendbuf(2, ",", uitoa((uint32_t)sys.override.rapid_rate)));
|
||||
stream_write(appendbuf(2, ",", uitoa((uint32_t)spindle_0->param->override_pct)));
|
||||
}
|
||||
|
||||
if(report.spindle || report.coolant || report.tool || gc_state.tool_change) {
|
||||
if(report->flags.spindle || report->flags.coolant || report->flags.tool || gc_state.tool_change) {
|
||||
|
||||
coolant_state_t cl_state = hal.coolant.get_state();
|
||||
|
||||
@@ -1476,53 +1474,53 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
if (cl_state.mist)
|
||||
*append++ = 'M';
|
||||
|
||||
if(gc_state.tool_change && !report.tool)
|
||||
if(gc_state.tool_change && !report->flags.tool)
|
||||
*append++ = 'T';
|
||||
|
||||
*append = '\0';
|
||||
stream_write(buf);
|
||||
}
|
||||
|
||||
if(report.scaling) {
|
||||
if(report->flags.scaling) {
|
||||
axis_signals_tostring(buf, gc_get_g51_state());
|
||||
stream_write("|Sc:");
|
||||
stream_write(buf);
|
||||
}
|
||||
|
||||
#if COMPATIBILITY_LEVEL <= 1
|
||||
if((report.all || report.mpg_mode) && settings.report_interval) {
|
||||
if((report->flags.all || report->flags.mpg_mode) && settings.report_interval) {
|
||||
stream_write(sys.flags.auto_reporting ? "|AR:" : "|AR");
|
||||
if(sys.flags.auto_reporting)
|
||||
stream_write(uitoa(settings.report_interval));
|
||||
}
|
||||
#endif
|
||||
|
||||
if(report.mpg_mode)
|
||||
if(report->flags.mpg_mode)
|
||||
stream_write(sys.mpg_mode ? "|MPG:1" : "|MPG:0");
|
||||
|
||||
if(report.homed && (sys.homing.mask || settings.homing.flags.single_axis_commands || settings.homing.flags.manual)) {
|
||||
if(report->flags.homed && (sys.homing.mask || settings.homing.flags.single_axis_commands || settings.homing.flags.manual)) {
|
||||
axes_signals_t homing = {sys.homing.mask ? sys.homing.mask : AXES_BITMASK};
|
||||
stream_write(appendbuf(2, "|H:", (homing.mask & sys.homed.mask) == homing.mask ? "1" : "0"));
|
||||
if(settings.homing.flags.single_axis_commands)
|
||||
stream_write(appendbuf(2, ",", uitoa(sys.homed.mask)));
|
||||
}
|
||||
|
||||
if(report.xmode && settings.mode == Mode_Lathe)
|
||||
if(report->flags.xmode && settings.mode == Mode_Lathe)
|
||||
stream_write(gc_state.modal.diameter_mode ? "|D:1" : "|D:0");
|
||||
|
||||
if(report.tool)
|
||||
if(report->flags.tool)
|
||||
stream_write(appendbuf(2, "|T:", uitoa((uint32_t)gc_state.tool->tool_id)));
|
||||
|
||||
if(report.probe_id || report.probe_protect) {
|
||||
if(report->flags.probe_id || report->flags.probe_protect) {
|
||||
stream_write(appendbuf(2, "|P:", uitoa((uint32_t)probe_state.probe_id)));
|
||||
if(report.probe_protect && !probe_state.is_probing && probe_state.irq_enabled)
|
||||
if(report->flags.probe_protect && !probe_state.is_probing && probe_state.irq_enabled)
|
||||
stream_write(",P");
|
||||
}
|
||||
|
||||
if(report.tlo_reference)
|
||||
if(report->flags.tlo_reference)
|
||||
stream_write(appendbuf(2, "|TLR:", uitoa(sys.tlo_reference_set.mask != 0)));
|
||||
|
||||
if(report.m66result && sys.var5399 > -2) { // M66 result
|
||||
if(report->flags.m66result && sys.var5399 > -2) { // M66 result
|
||||
if(sys.var5399 >= 0)
|
||||
stream_write(appendbuf(2, "|In:", uitoa(sys.var5399)));
|
||||
else
|
||||
@@ -1531,10 +1529,10 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
}
|
||||
|
||||
if(grbl.on_realtime_report)
|
||||
grbl.on_realtime_report(stream_write, report);
|
||||
grbl.on_realtime_report(stream_write, report->flags);
|
||||
|
||||
#if COMPATIBILITY_LEVEL <= 1
|
||||
if(report.all) {
|
||||
if(report->flags.all) {
|
||||
stream_write("|FW:grblHAL");
|
||||
if(sys.blocking_event)
|
||||
stream_write("|$C:1");
|
||||
@@ -1578,18 +1576,18 @@ void report_realtime_status (stream_write_ptr stream_write, report_tracking_flag
|
||||
if (is_changed)
|
||||
system_set_exec_state_flag(EXEC_GCODE_REPORT);
|
||||
|
||||
if(report.tool_offset)
|
||||
if(report->flags.tool_offset)
|
||||
system_set_exec_state_flag(EXEC_TLO_REPORT);
|
||||
}
|
||||
|
||||
stream_write(">" ASCII_EOL);
|
||||
|
||||
if(stream_write == hal.stream.write_all) {
|
||||
system_add_rt_report(Report_ClearAll);
|
||||
|
||||
report_add_realtime(Report_ClearAll);
|
||||
if(delayed_report.wco)
|
||||
system_add_rt_report(Report_WCO); // Set to report on next request
|
||||
}
|
||||
report_add_realtime(Report_WCO); // Set to report on next request
|
||||
} else
|
||||
report->flags.value = delayed_report.value;
|
||||
}
|
||||
|
||||
static void report_bitfield (const char *format, bool bitmap)
|
||||
@@ -2904,9 +2902,48 @@ report_tracking_flags_t report_get_rt_flags_all (void)
|
||||
report_tracking_flags_t report;
|
||||
|
||||
report.value = (uint32_t)Report_All;
|
||||
report.tool_offset = sys.report.tool_offset;
|
||||
report.tool_offset = hal.stream.report.flags.tool_offset;
|
||||
report.m66result = sys.var5399 > -2;
|
||||
report.probe_id = !!hal.probe.select;
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
/*! \brief Set(s) or clear all active realtime report addon flag(s) for the next report.
|
||||
|
||||
Fires the \ref grbl.on_rt_reports_added event.
|
||||
\param report a #report_tracking_t enum containing the flag(s) to set or clear.
|
||||
*/
|
||||
ISR_CODE void report_add_realtime (report_tracking_t report)
|
||||
{
|
||||
report_tracking_flags_t flags = { .value = (uint32_t)report };
|
||||
|
||||
switch(report) {
|
||||
|
||||
case Report_ClearAll:
|
||||
hal.stream.report.flags.value = 0;
|
||||
return;
|
||||
|
||||
case Report_MPGMode:
|
||||
if(!hal.driver_cap.mpg_mode)
|
||||
return;
|
||||
break;
|
||||
|
||||
case Report_LatheXMode:
|
||||
flags.wco = settings.status_report.work_coord_offset;
|
||||
break;
|
||||
|
||||
case Report_ProbeId:
|
||||
if(hal.probe.select == NULL)
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
hal.stream.report.flags.value |= flags.value;
|
||||
|
||||
if(grbl.on_rt_reports_added && (flags.value || report == Report_ClearAll))
|
||||
grbl.on_rt_reports_added(flags);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ status_code_t report_grbl_setting (setting_id_t id, void *data);
|
||||
void report_echo_line_received (char *line);
|
||||
|
||||
// Prints realtime status report.
|
||||
void report_realtime_status (stream_write_ptr stream_write, report_tracking_flags_t report);
|
||||
void report_realtime_status (stream_write_ptr stream_write, status_report_tracking_t *report);
|
||||
|
||||
// Prints recorded probe position.
|
||||
void report_probe_parameters (void);
|
||||
@@ -128,5 +128,6 @@ status_code_t report_time (void);
|
||||
void report_pid_log (void);
|
||||
|
||||
report_tracking_flags_t report_get_rt_flags_all (void);
|
||||
void report_add_realtime (report_tracking_t report);
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -1348,7 +1348,7 @@ FLASHMEM static status_code_t set_axis_setting (setting_id_t setting, float valu
|
||||
if(settings.axis[idx].max_travel != -value) {
|
||||
sys.flags.travel_changed = On;
|
||||
bit_false(sys.homed.mask, bit(idx));
|
||||
system_add_rt_report(Report_Homed);
|
||||
report_add_realtime(Report_Homed);
|
||||
}
|
||||
settings.axis[idx].max_travel = -value; // Store as negative for internal use.
|
||||
tmp_set_soft_limits();
|
||||
|
||||
+4
-4
@@ -122,7 +122,7 @@ static bool spindle_activate (spindle_id_t spindle_id, spindle_num_t spindle_num
|
||||
if(grbl.on_spindle_selected)
|
||||
grbl.on_spindle_selected(&sys_spindle[spindle_num].hal);
|
||||
#if N_SPINDLE > 1
|
||||
system_add_rt_report(Report_SpindleId);
|
||||
report_add_realtime(Report_SpindleId);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -552,7 +552,7 @@ float spindle_set_override (spindle_ptrs_t *spindle, override_t speed_override)
|
||||
} else
|
||||
sys.step_control.update_spindle_rpm = On;
|
||||
|
||||
system_add_rt_report(Report_Overrides); // Set to report change immediately
|
||||
report_add_realtime(Report_Overrides); // Set to report change immediately
|
||||
|
||||
// if(grbl.on_spindle_programmed)
|
||||
// grbl.on_spindle_programmed(spindle, spindle->param->state, spindle->param->rpm, spindle->param->rpm_mode);
|
||||
@@ -618,7 +618,7 @@ bool spindle_set_state (spindle_ptrs_t *spindle, spindle_state_t state, float rp
|
||||
spindle->param->state.on = state.on;
|
||||
spindle->param->state.ccw = state.ccw;
|
||||
|
||||
system_add_rt_report(Report_Spindle); // Set to report change immediately
|
||||
report_add_realtime(Report_Spindle); // Set to report change immediately
|
||||
|
||||
st_rpm_changed(rpm);
|
||||
}
|
||||
@@ -754,7 +754,7 @@ void spindle_all_off (void)
|
||||
}
|
||||
} while(spindle_num);
|
||||
|
||||
system_add_rt_report(Report_Spindle);
|
||||
report_add_realtime(Report_Spindle);
|
||||
}
|
||||
|
||||
/*! \brief Check if any of the enabled spindles is running.
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2018-2025 Terje Io
|
||||
Copyright (c) 2018-2026 Terje Io
|
||||
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
@@ -461,7 +461,7 @@ static void state_await_toolchanged (uint_fast16_t rt_exec)
|
||||
if(grbl.on_tool_changed)
|
||||
grbl.on_tool_changed(gc_state.tool);
|
||||
|
||||
system_add_rt_report(Report_Tool);
|
||||
report_add_realtime(Report_Tool);
|
||||
}
|
||||
pending_state = gc_state.tool_change ? STATE_TOOL_CHANGE : STATE_IDLE;
|
||||
state_set(STATE_IDLE);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2016-2025 Terje Io
|
||||
Copyright (c) 2016-2026 Terje Io
|
||||
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
@@ -495,7 +495,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void)
|
||||
st.dir_out = st.exec_segment->exec_block->direction;
|
||||
|
||||
if(st.exec_block != NULL && st.exec_block->offset_id != st.exec_segment->exec_block->offset_id)
|
||||
sys.report.wco = sys.report.force_wco = On; // Do not generate grbl.on_rt_reports_added event!
|
||||
report_add_realtime(Report_WCO|Report_ForceWCO);
|
||||
|
||||
st.exec_block = st.exec_segment->exec_block;
|
||||
st.step_event_count = st.exec_block->step_event_count;
|
||||
|
||||
@@ -79,6 +79,7 @@ static struct {
|
||||
io_stream_t stream;
|
||||
stream_write_char_ptr write_char;
|
||||
stream_connection_flags_t flags;
|
||||
on_rt_reports_added_ptr on_rt_reports_added;
|
||||
} mpg;
|
||||
|
||||
void stream_register_streams (io_stream_details_t *details)
|
||||
@@ -201,8 +202,8 @@ ISR_CODE bool ISR_FUNC(stream_enqueue_realtime_command)(uint8_t c)
|
||||
{
|
||||
bool drop = hal.stream.enqueue_rt_command ? hal.stream.enqueue_rt_command(c) : protocol_enqueue_realtime_command(c);
|
||||
|
||||
if(drop && (c == CMD_CYCLE_START || c == CMD_CYCLE_START_LEGACY))
|
||||
sys.report.cycle_start = settings.status_report.pin_state;
|
||||
if(drop && (c == CMD_CYCLE_START || c == CMD_CYCLE_START_LEGACY) && settings.status_report.pin_state)
|
||||
report_add_realtime(Report_CycleStart);
|
||||
|
||||
return drop;
|
||||
}
|
||||
@@ -541,6 +542,17 @@ void stream_set_defaults (const io_stream_t *stream, uint32_t baud_rate)
|
||||
|
||||
// MPG stream
|
||||
|
||||
ISR_CODE static void mpg_rt_report_add (report_tracking_flags_t report)
|
||||
{
|
||||
if(mpg.on_rt_reports_added)
|
||||
mpg.on_rt_reports_added(report);
|
||||
|
||||
if(report.value == 0)
|
||||
mpg.stream.report.flags.value = 0;
|
||||
else
|
||||
mpg.stream.report.flags.value |= report.value;
|
||||
}
|
||||
|
||||
void stream_mpg_set_mode (void *data)
|
||||
{
|
||||
stream_mpg_enable(data != NULL);
|
||||
@@ -551,7 +563,11 @@ static void stream_mpg_write (void *cmd)
|
||||
switch((uint32_t)cmd) {
|
||||
|
||||
case CMD_STATUS_REPORT_ALL:
|
||||
report_realtime_status(mpg.stream.write, report_get_rt_flags_all());
|
||||
mpg.stream.report.flags.value = report_get_rt_flags_all().value;
|
||||
// no break
|
||||
case CMD_STATUS_REPORT:
|
||||
case CMD_STATUS_REPORT_LEGACY:
|
||||
report_realtime_status(mpg.stream.write, &mpg.stream.report);
|
||||
break;
|
||||
|
||||
case CMD_GCODE_REPORT:
|
||||
@@ -569,6 +585,8 @@ ISR_CODE bool ISR_FUNC(stream_mpg_check_enable)(uint8_t c)
|
||||
break;
|
||||
|
||||
case CMD_GCODE_REPORT:
|
||||
case CMD_STATUS_REPORT:
|
||||
case CMD_STATUS_REPORT_LEGACY:
|
||||
case CMD_STATUS_REPORT_ALL:
|
||||
if(mpg.flags.is_mpg_tx)
|
||||
task_add_immediate(stream_mpg_write, (void *)((uint32_t)c));
|
||||
@@ -576,8 +594,8 @@ ISR_CODE bool ISR_FUNC(stream_mpg_check_enable)(uint8_t c)
|
||||
|
||||
default:
|
||||
protocol_enqueue_realtime_command(c);
|
||||
if((c == CMD_CYCLE_START || c == CMD_CYCLE_START_LEGACY) && settings.status_report.pin_state)
|
||||
sys.report.cycle_start |= state_get() == STATE_IDLE;
|
||||
if((c == CMD_CYCLE_START || c == CMD_CYCLE_START_LEGACY) && settings.status_report.pin_state && state_get() == STATE_IDLE)
|
||||
report_add_realtime(Report_CycleStart);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -624,6 +642,9 @@ bool stream_mpg_register (const io_stream_t *stream, bool rx_only, stream_write_
|
||||
|
||||
stream_set_description(stream, "MPG");
|
||||
|
||||
mpg.on_rt_reports_added = grbl.on_rt_reports_added;
|
||||
grbl.on_rt_reports_added = mpg_rt_report_add;
|
||||
|
||||
if(grbl.on_mpg_registered)
|
||||
grbl.on_mpg_registered(&mpg.stream, true);
|
||||
}
|
||||
@@ -674,6 +695,7 @@ bool stream_mpg_enable (bool on)
|
||||
} else if(org_stream.type != StreamType_Redirected) {
|
||||
memcpy(&hal.stream, &org_stream, sizeof(io_stream_t));
|
||||
org_stream.type = StreamType_Redirected;
|
||||
mpg.stream.report.override_counter = mpg.stream.report.wco_counter = 0;
|
||||
if(hal.stream.disable_rx)
|
||||
hal.stream.disable_rx(false);
|
||||
if(mpg.write_char)
|
||||
@@ -686,7 +708,7 @@ bool stream_mpg_enable (bool on)
|
||||
|
||||
sys.mpg_mode = on;
|
||||
mpg.flags.mpg_control = Off;
|
||||
system_add_rt_report(Report_MPGMode);
|
||||
report_add_realtime(Report_MPGMode);
|
||||
|
||||
// Force a realtime status report, all reports when MPG mode active
|
||||
task_add_delayed(report_mpg_mode, (void *)((uintptr_t)(on ? CMD_STATUS_REPORT_ALL : CMD_STATUS_REPORT)), 5);
|
||||
|
||||
@@ -78,6 +78,7 @@ Helper functions for saving away and restoring a stream input buffer. _Not refer
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "vfs.h"
|
||||
#include "system.h"
|
||||
|
||||
typedef enum {
|
||||
StreamType_Serial = 0,
|
||||
@@ -316,6 +317,7 @@ typedef struct {
|
||||
set_format_ptr set_format; //!< Optional handler for setting the stream format.
|
||||
stream_set_direction_ptr set_direction; //!< Optional handler for setting the transfer direction for half-duplex communication.
|
||||
on_linestate_changed_ptr on_linestate_changed; //!< Optional handler to be called when line state changes. Set by client.
|
||||
status_report_tracking_t report; //!< Tracks when to add data to status reports.
|
||||
vfs_file_t *file; //!< File handle, non-null if streaming from a file.
|
||||
} io_stream_t;
|
||||
|
||||
|
||||
@@ -147,7 +147,8 @@ ISR_CODE void ISR_FUNC(control_interrupt_handler)(control_signals_t signals)
|
||||
|
||||
if(event_signals.cycle_start) {
|
||||
system_set_exec_state_flag(EXEC_CYCLE_START);
|
||||
sys.report.cycle_start = settings.status_report.pin_state;
|
||||
if(settings.status_report.pin_state)
|
||||
report_add_realtime(Report_CycleStart);
|
||||
gc_state.tool_change = false;
|
||||
if(grbl.on_cycle_start)
|
||||
grbl.on_cycle_start();
|
||||
@@ -325,7 +326,7 @@ static status_code_t output_all_settings (sys_state_t state, char *args)
|
||||
static status_code_t output_parser_state (sys_state_t state, char *args)
|
||||
{
|
||||
report_gcode_modes(hal.stream.write);
|
||||
system_add_rt_report(Report_Homed); // Report homed state on next realtime report
|
||||
report_add_realtime(Report_Homed); // Report homed state on next realtime report
|
||||
|
||||
return Status_OK;
|
||||
}
|
||||
@@ -572,7 +573,7 @@ static status_code_t set_tool_reference (sys_state_t state, char *args)
|
||||
} else
|
||||
sys.tlo_reference_set.mask = 0;
|
||||
#endif
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
report_add_realtime(Report_TLOReference);
|
||||
|
||||
return Status_OK;
|
||||
}
|
||||
@@ -1179,7 +1180,7 @@ void system_clear_tlo_reference (axes_signals_t homing_cycle)
|
||||
if(homing_cycle.mask & (settings.mode == Mode_Lathe ? (X_AXIS_BIT|Z_AXIS_BIT) : bit(plane.axis_linear))) {
|
||||
if(sys.tlo_reference_set.mask != 0) {
|
||||
sys.tlo_reference_set.mask = 0; // Invalidate tool length offset reference
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
report_add_realtime(Report_TLOReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1198,7 +1199,7 @@ void system_flag_wco_change (void)
|
||||
if(grbl.on_wco_changed)
|
||||
grbl.on_wco_changed();
|
||||
|
||||
system_add_rt_report(Report_WCO);
|
||||
report_add_realtime(Report_WCO);
|
||||
}
|
||||
|
||||
/*! \brief Sets machine position. Must be sent a 'step' array.
|
||||
@@ -1256,50 +1257,3 @@ void system_raise_alarm (alarm_code_t alarm)
|
||||
grbl.report.alarm_message(alarm);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: encapsulate sys.report
|
||||
|
||||
/*! \brief Get the active realtime report addon flags for the next report.
|
||||
\return a #report_tracking_flags_t union containing the flags.
|
||||
*/
|
||||
report_tracking_flags_t system_get_rt_report_flags (void)
|
||||
{
|
||||
return sys.report;
|
||||
}
|
||||
|
||||
/*! \brief Set(s) or clear all active realtime report addon flag(s) for the next report.
|
||||
|
||||
Fires the \ref grbl.on_rt_reports_added event.
|
||||
\param report a #report_tracking_t enum containing the flag(s) to set or clear.
|
||||
*/
|
||||
ISR_CODE void system_add_rt_report (report_tracking_t report)
|
||||
{
|
||||
switch(report) {
|
||||
|
||||
case Report_ClearAll:
|
||||
sys.report.value = 0;
|
||||
return;
|
||||
|
||||
case Report_MPGMode:
|
||||
if(!hal.driver_cap.mpg_mode)
|
||||
return;
|
||||
break;
|
||||
|
||||
case Report_LatheXMode:
|
||||
sys.report.wco = settings.status_report.work_coord_offset;
|
||||
break;
|
||||
|
||||
case Report_ProbeId:
|
||||
if(hal.probe.select == NULL)
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sys.report.value |= (uint32_t)report;
|
||||
|
||||
if(sys.report.value && grbl.on_rt_reports_added)
|
||||
grbl.on_rt_reports_added((report_tracking_flags_t)((uint32_t)report));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2017-2025 Terje Io
|
||||
Copyright (c) 2017-2026 Terje Io
|
||||
Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
|
||||
grblHAL is free software: you can redistribute it and/or modify
|
||||
@@ -241,6 +241,12 @@ typedef union {
|
||||
};
|
||||
} report_tracking_flags_t;
|
||||
|
||||
typedef struct {
|
||||
report_tracking_flags_t flags;
|
||||
uint8_t override_counter; //!< Tracks when to add override data to status reports.
|
||||
uint8_t wco_counter; //!< Tracks when to add work coordinate offset data to status reports.
|
||||
} status_report_tracking_t;
|
||||
|
||||
typedef struct {
|
||||
override_t feed_rate; //!< Feed rate override value in percent
|
||||
override_t rapid_rate; //!< Rapids override value in percent
|
||||
@@ -306,7 +312,6 @@ typedef struct system {
|
||||
axes_signals_t homing; //!< Axes with homing enabled.
|
||||
overrides_t override; //!< Override values & states
|
||||
system_override_delay_t override_delay; //!< Flags for delayed overrides.
|
||||
report_tracking_flags_t report; //!< Tracks when to add data to status reports.
|
||||
parking_state_t parking_state; //!< Tracks parking state
|
||||
hold_state_t holding_state; //!< Tracks holding state
|
||||
coord_system_id_t probe_coordsys_id; //!< Coordinate system in which last probe took place.
|
||||
@@ -386,8 +391,6 @@ void system_output_help (const sys_command_t *commands, uint32_t num_commands);
|
||||
void system_register_commands (sys_commands_t *commands);
|
||||
|
||||
void system_clear_tlo_reference (axes_signals_t homing_cycle);
|
||||
void system_add_rt_report (report_tracking_t report);
|
||||
report_tracking_flags_t system_get_rt_report_flags (void);
|
||||
|
||||
// Special handlers for setting and clearing grblHAL's real-time execution flags.
|
||||
#define system_set_exec_state_flag(mask) hal.set_bits_atomic(&sys.rt_exec_state, (mask))
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2020-2025 Terje Io
|
||||
Copyright (c) 2020-2026 Terje Io
|
||||
|
||||
grblHAL is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -126,7 +126,7 @@ static void reset (void)
|
||||
memcpy(gc_state.tool, ¤t_tool, sizeof(tool_data_t));
|
||||
else
|
||||
memcpy(next_tool, ¤t_tool, sizeof(tool_data_t));
|
||||
system_add_rt_report(Report_Tool);
|
||||
report_add_realtime(Report_Tool);
|
||||
}
|
||||
gc_state.tool_pending = gc_state.tool->tool_id;
|
||||
next_tool = NULL;
|
||||
@@ -352,7 +352,7 @@ static void execute_probe (void *data)
|
||||
if(!(sys.tlo_reference_set.mask & bit(plane.axis_linear))) {
|
||||
sys.tlo_reference[plane.axis_linear] = sys.probe_position[plane.axis_linear];
|
||||
sys.tlo_reference_set.mask |= bit(plane.axis_linear);
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
report_add_realtime(Report_TLOReference);
|
||||
grbl.report.feedback_message(Message_ReferenceTLOEstablished);
|
||||
} else
|
||||
gc_set_tool_offset(ToolLengthOffset_EnableDynamic, plane.axis_linear,
|
||||
@@ -572,7 +572,7 @@ void tc_init (void)
|
||||
if(!hal.stream.suspend_read) // Tool change requires support for suspending input stream.
|
||||
return;
|
||||
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
report_add_realtime(Report_TLOReference);
|
||||
|
||||
if(settings.tool_change.mode == ToolChange_Disabled || settings.tool_change.mode == ToolChange_Ignore) {
|
||||
hal.tool.change = NULL;
|
||||
|
||||
Reference in New Issue
Block a user