grblHAL core  20241107
core_handlers.h File Reference

core function pointers and data structures definitions. More...

#include "system.h"
#include "stream.h"
#include "alarms.h"
#include "errors.h"
#include "settings.h"
#include "report.h"
#include "planner.h"
#include "machine_limits.h"
#include "vfs.h"

Go to the source code of this file.

Data Structures

struct  report_t
 
struct  tool_table_t
 
struct  user_mcode_ptrs_t
 Optional handlers for user defined M-codes. More...
 
struct  grbl_t
 

Typedefs

typedef void(* init_message_ptr) (void)
 
typedef void(* help_message_ptr) (void)
 
typedef status_code_t(* status_message_ptr) (status_code_t status_code)
 
typedef message_code_t(* feedback_message_ptr) (message_code_t message_code)
 
typedef alarm_code_t(* alarm_message_ptr) (alarm_code_t alarm_code)
 
typedef bool(* enqueue_gcode_ptr) (char *data)
 
typedef bool(* protocol_enqueue_realtime_command_ptr) (char c)
 
typedef bool(* travel_limits_ptr) (float *target, axes_signals_t axes, bool is_cartesian)
 
typedef bool(* arc_limits_ptr) (coord_data_t *target, coord_data_t *position, point_2d_t center, float radius, plane_t plane, int32_t turns)
 
typedef void(* jog_limits_ptr) (float *target, float *position)
 
typedef bool(* home_machine_ptr) (axes_signals_t cycle, axes_signals_t auto_square)
 
typedef void(* on_parser_init_ptr) (parser_state_t *gc_state)
 
typedef void(* on_state_change_ptr) (sys_state_t state)
 
typedef void(* on_override_changed_ptr) (override_changed_t override)
 
typedef void(* on_spindle_programmed_ptr) (spindle_ptrs_t *spindle, spindle_state_t state, float rpm, spindle_rpm_mode_t mode)
 
typedef void(* on_wco_changed_ptr) (void)
 
typedef void(* on_program_completed_ptr) (program_flow_t program_flow, bool check_mode)
 
typedef void(* on_execute_realtime_ptr) (sys_state_t state)
 
typedef void(* on_unknown_accessory_override_ptr) (uint8_t cmd)
 
typedef bool(* on_unknown_realtime_cmd_ptr) (char c)
 
typedef void(* on_report_handlers_init_ptr) (void)
 
typedef void(* on_report_options_ptr) (bool newopt)
 
typedef void(* on_report_ngc_parameters_ptr) (void)
 
typedef void(* on_report_command_help_ptr) (void)
 
typedef const char *(* on_setting_get_description_ptr) (setting_id_t id)
 
typedef void(* on_global_settings_restore_ptr) (void)
 
typedef void(* on_realtime_report_ptr) (stream_write_ptr stream_write, report_tracking_flags_t report)
 
typedef void(* on_unknown_feedback_message_ptr) (stream_write_ptr stream_write)
 
typedef void(* on_stream_changed_ptr) (stream_type_t type)
 
typedef bool(* on_laser_ppi_enable_ptr) (uint_fast16_t ppi, uint_fast16_t pulse_length)
 
typedef void(* on_homing_rate_set_ptr) (axes_signals_t axes, float rate, homing_mode_t mode)
 
typedef void(* on_homing_completed_ptr) (axes_signals_t cycle, bool success)
 
typedef bool(* on_probe_toolsetter_ptr) (tool_data_t *tool, coord_data_t *position, bool at_g59_3, bool on)
 
typedef bool(* on_probe_start_ptr) (axes_signals_t axes, float *target, plan_line_data_t *pl_data)
 
typedef void(* on_probe_completed_ptr) (void)
 
typedef void(* on_tool_selected_ptr) (tool_data_t *tool)
 
typedef void(* on_tool_changed_ptr) (tool_data_t *tool)
 
typedef void(* on_toolchange_ack_ptr) (void)
 
typedef void(* on_reset_ptr) (void)
 
typedef void(* on_jog_cancel_ptr) (sys_state_t state)
 
typedef bool(* on_spindle_select_ptr) (spindle_ptrs_t *spindle)
 
typedef void(* on_spindle_selected_ptr) (spindle_ptrs_t *spindle)
 
typedef status_code_t(* on_gcode_message_ptr) (char *msg)
 
typedef void(* on_rt_reports_added_ptr) (report_tracking_flags_t report)
 
typedef const char *(* on_set_axis_setting_unit_ptr) (setting_id_t setting_id, uint_fast8_t axis_idx)
 
typedef status_code_t(* on_file_open_ptr) (const char *fname, vfs_file_t *handle, bool stream)
 
typedef status_code_t(* on_file_end_ptr) (vfs_file_t *handle, status_code_t status)
 
typedef status_code_t(* on_unknown_sys_command_ptr) (sys_state_t state, char *line)
 
typedef status_code_t(* on_user_command_ptr) (char *line)
 
typedef sys_commands_t *(* on_get_commands_ptr) (void)
 
typedef status_code_t(* on_macro_execute_ptr) (macro_id_t macro)
 
typedef void(* on_macro_return_ptr) (void)
 
typedef bool(* write_tool_data_ptr) (tool_data_t *tool_data)
 
typedef bool(* read_tool_data_ptr) (tool_id_t tool_id, tool_data_t *tool_data)
 
typedef bool(* clear_tool_data_ptr) (void)
 
typedef user_mcode_type_t(* user_mcode_check_ptr) (user_mcode_t mcode)
 Pointer to function for checking if user defined M-code is supported. More...
 
typedef status_code_t(* user_mcode_validate_ptr) (parser_block_t *gc_block)
 Pointer to function for validating parameters for a user defined M-code. More...
 
typedef void(* user_mcode_execute_ptr) (sys_state_t state, parser_block_t *gc_block)
 Pointer to function for executing a user defined M-code. More...
 

Enumerations

enum  override_changed_t {
  OverrideChanged_FeedRate = 0 , OverrideChanged_RapidRate = 0 , OverrideChanged_SpindleRPM = 0 , OverrideChanged_SpindleState = 0 ,
  OverrideChanged_CoolantState = 0 , OverrideChanged_FanState = 0
}
 
enum  user_mcode_type_t { UserMCode_Unsupported = 0 , UserMCode_Normal , UserMCode_NoValueWords }
 

Variables

grbl_t grbl
 

Detailed Description

core function pointers and data structures definitions.

Typedef Documentation

◆ alarm_message_ptr

typedef alarm_code_t(* alarm_message_ptr) (alarm_code_t alarm_code)

◆ arc_limits_ptr

typedef bool(* arc_limits_ptr) (coord_data_t *target, coord_data_t *position, point_2d_t center, float radius, plane_t plane, int32_t turns)

◆ clear_tool_data_ptr

typedef bool(* clear_tool_data_ptr) (void)

◆ enqueue_gcode_ptr

typedef bool(* enqueue_gcode_ptr) (char *data)

◆ feedback_message_ptr

typedef message_code_t(* feedback_message_ptr) (message_code_t message_code)

◆ help_message_ptr

typedef void(* help_message_ptr) (void)

◆ home_machine_ptr

typedef bool(* home_machine_ptr) (axes_signals_t cycle, axes_signals_t auto_square)

◆ init_message_ptr

typedef void(* init_message_ptr) (void)

◆ jog_limits_ptr

typedef void(* jog_limits_ptr) (float *target, float *position)

◆ on_execute_realtime_ptr

typedef void(* on_execute_realtime_ptr) (sys_state_t state)

◆ on_file_end_ptr

typedef status_code_t(* on_file_end_ptr) (vfs_file_t *handle, status_code_t status)

◆ on_file_open_ptr

typedef status_code_t(* on_file_open_ptr) (const char *fname, vfs_file_t *handle, bool stream)

◆ on_gcode_message_ptr

typedef status_code_t(* on_gcode_message_ptr) (char *msg)

◆ on_get_commands_ptr

typedef sys_commands_t*(* on_get_commands_ptr) (void)

◆ on_global_settings_restore_ptr

typedef void(* on_global_settings_restore_ptr) (void)

◆ on_homing_completed_ptr

typedef void(* on_homing_completed_ptr) (axes_signals_t cycle, bool success)

◆ on_homing_rate_set_ptr

typedef void(* on_homing_rate_set_ptr) (axes_signals_t axes, float rate, homing_mode_t mode)

◆ on_jog_cancel_ptr

typedef void(* on_jog_cancel_ptr) (sys_state_t state)

◆ on_laser_ppi_enable_ptr

typedef bool(* on_laser_ppi_enable_ptr) (uint_fast16_t ppi, uint_fast16_t pulse_length)

◆ on_macro_execute_ptr

typedef status_code_t(* on_macro_execute_ptr) (macro_id_t macro)

◆ on_macro_return_ptr

typedef void(* on_macro_return_ptr) (void)

◆ on_override_changed_ptr

typedef void(* on_override_changed_ptr) (override_changed_t override)

◆ on_parser_init_ptr

typedef void(* on_parser_init_ptr) (parser_state_t *gc_state)

◆ on_probe_completed_ptr

typedef void(* on_probe_completed_ptr) (void)

◆ on_probe_start_ptr

typedef bool(* on_probe_start_ptr) (axes_signals_t axes, float *target, plan_line_data_t *pl_data)

◆ on_probe_toolsetter_ptr

typedef bool(* on_probe_toolsetter_ptr) (tool_data_t *tool, coord_data_t *position, bool at_g59_3, bool on)

◆ on_program_completed_ptr

typedef void(* on_program_completed_ptr) (program_flow_t program_flow, bool check_mode)

◆ on_realtime_report_ptr

typedef void(* on_realtime_report_ptr) (stream_write_ptr stream_write, report_tracking_flags_t report)

◆ on_report_command_help_ptr

typedef void(* on_report_command_help_ptr) (void)

◆ on_report_handlers_init_ptr

typedef void(* on_report_handlers_init_ptr) (void)

◆ on_report_ngc_parameters_ptr

typedef void(* on_report_ngc_parameters_ptr) (void)

◆ on_report_options_ptr

typedef void(* on_report_options_ptr) (bool newopt)

◆ on_reset_ptr

typedef void(* on_reset_ptr) (void)

◆ on_rt_reports_added_ptr

typedef void(* on_rt_reports_added_ptr) (report_tracking_flags_t report)

◆ on_set_axis_setting_unit_ptr

typedef const char*(* on_set_axis_setting_unit_ptr) (setting_id_t setting_id, uint_fast8_t axis_idx)

◆ on_setting_get_description_ptr

typedef const char*(* on_setting_get_description_ptr) (setting_id_t id)

◆ on_spindle_programmed_ptr

typedef void(* on_spindle_programmed_ptr) (spindle_ptrs_t *spindle, spindle_state_t state, float rpm, spindle_rpm_mode_t mode)

◆ on_spindle_select_ptr

typedef bool(* on_spindle_select_ptr) (spindle_ptrs_t *spindle)

◆ on_spindle_selected_ptr

typedef void(* on_spindle_selected_ptr) (spindle_ptrs_t *spindle)

◆ on_state_change_ptr

typedef void(* on_state_change_ptr) (sys_state_t state)

◆ on_stream_changed_ptr

typedef void(* on_stream_changed_ptr) (stream_type_t type)

◆ on_tool_changed_ptr

typedef void(* on_tool_changed_ptr) (tool_data_t *tool)

◆ on_tool_selected_ptr

typedef void(* on_tool_selected_ptr) (tool_data_t *tool)

◆ on_toolchange_ack_ptr

typedef void(* on_toolchange_ack_ptr) (void)

◆ on_unknown_accessory_override_ptr

typedef void(* on_unknown_accessory_override_ptr) (uint8_t cmd)

◆ on_unknown_feedback_message_ptr

typedef void(* on_unknown_feedback_message_ptr) (stream_write_ptr stream_write)

◆ on_unknown_realtime_cmd_ptr

typedef bool(* on_unknown_realtime_cmd_ptr) (char c)

◆ on_unknown_sys_command_ptr

typedef status_code_t(* on_unknown_sys_command_ptr) (sys_state_t state, char *line)

◆ on_user_command_ptr

typedef status_code_t(* on_user_command_ptr) (char *line)

◆ on_wco_changed_ptr

typedef void(* on_wco_changed_ptr) (void)

◆ protocol_enqueue_realtime_command_ptr

typedef bool(* protocol_enqueue_realtime_command_ptr) (char c)

◆ read_tool_data_ptr

typedef bool(* read_tool_data_ptr) (tool_id_t tool_id, tool_data_t *tool_data)

◆ status_message_ptr

typedef status_code_t(* status_message_ptr) (status_code_t status_code)

◆ travel_limits_ptr

typedef bool(* travel_limits_ptr) (float *target, axes_signals_t axes, bool is_cartesian)

◆ user_mcode_check_ptr

typedef user_mcode_type_t(* user_mcode_check_ptr) (user_mcode_t mcode)

Pointer to function for checking if user defined M-code is supported.

Parameters
mcodeas a user_mcode_t enum.
Returns
UserMCode_Normal or UserMCode_NoValueWords if M-code is handled, UserMCode_Unsupported if not.

◆ user_mcode_execute_ptr

typedef void(* user_mcode_execute_ptr) (sys_state_t state, parser_block_t *gc_block)

Pointer to function for executing a user defined M-code.

The M-code to execute is found in gc_block->user_mcode, parameter values in gc_block->values and claimed/validated parameter letters in the gc_block->words bitfield union.

Parameters
stateas a sys_state_t variable.
gc_blockpointer to a parser_block_t structure.
Returns
Status_OK enum value if validated ok, appropriate status_code_t enum value if not or Status_Unhandled if M-code is not recognized.

◆ user_mcode_validate_ptr

typedef status_code_t(* user_mcode_validate_ptr) (parser_block_t *gc_block)

Pointer to function for validating parameters for a user defined M-code.

The M-code to validate is found in gc_block->user_mcode, parameter values in gc_block->values and corresponding parameter letters in the gc_block->words bitfield union.

Parameter values claimed by the M-code must be flagged in the gc_block->words bitfield union by setting the respective parameter letters to false or the parser will raise the Status_GcodeUnusedWords error.

The validation function may set gc_block->user_mcode_sync to true if it is to be executed after all buffered motions are completed, otherwise it will be executed immediately.

NOTE: Valueless parameter letters are allowed for floats if the check function returns UserMCode_NoValueWords for the M-code. The corresponding values are set to NAN (not a number) if no value is given. The validation function should always test all parameter values by using the isnan() function in addition to any range checks when the check function returns UserMCode_NoValueWords for the M-code.

Parameters
gc_blockpointer to a parser_block_t structure.
Returns
Status_OK enum value if validated ok, appropriate status_code_t enum value if not or Status_Unhandled if the M-code is not recognized.

◆ write_tool_data_ptr

typedef bool(* write_tool_data_ptr) (tool_data_t *tool_data)

Enumeration Type Documentation

◆ override_changed_t

Enumerator
OverrideChanged_FeedRate 
OverrideChanged_RapidRate 
OverrideChanged_SpindleRPM 
OverrideChanged_SpindleState 
OverrideChanged_CoolantState 
OverrideChanged_FanState 

◆ user_mcode_type_t

Enumerator
UserMCode_Unsupported 

0 - M-code is not supported.

UserMCode_Normal 

1 - M-code is supported.

UserMCode_NoValueWords 

2 - M-code supports valueless parameter words.

Variable Documentation

◆ grbl

grbl_t grbl
extern