Go to the source code of this file.
Data Structures | |
union | step_control_t |
union | control_signals_t |
union | spindle_stop_t |
union | report_tracking_flags_t |
struct | overrides_t |
union | system_override_delay_t |
union | system_flags_t |
struct | signal_event_t |
struct | work_envelope_t |
struct | system |
Global system variables struct. More... | |
union | sys_command_flags_t |
struct | sys_command_t |
struct | sys_commands_str |
Macros | |
#define | system_set_exec_state_flag(mask) hal.set_bits_atomic(&sys.rt_exec_state, (mask)) |
#define | system_clear_exec_state_flag(mask) hal.clear_bits_atomic(&sys.rt_exec_state, (mask)) |
#define | system_clear_exec_states() hal.set_value_atomic(&sys.rt_exec_state, 0) |
#define | system_set_exec_alarm(code) hal.set_value_atomic(&sys.rt_exec_alarm, (uint_fast16_t)(code)) |
#define | system_clear_exec_alarm() hal.set_value_atomic(&sys.rt_exec_alarm, 0) |
System executor bit map. | |
Used internally by realtime protocol as realtime command flags, which notifies the main program to execute the specified realtime command asynchronously. NOTE: The system executor uses an unsigned 16-bit volatile variable (16 flag limit.) The default flags are always false, so the realtime protocol only needs to check for a non-zero value to know when there is a realtime command to execute. | |
#define | EXEC_STATUS_REPORT bit(0) |
#define | EXEC_CYCLE_START bit(1) |
#define | EXEC_CYCLE_COMPLETE bit(2) |
#define | EXEC_FEED_HOLD bit(3) |
#define | EXEC_STOP bit(4) |
#define | EXEC_RESET bit(5) |
#define | EXEC_SAFETY_DOOR bit(6) |
#define | EXEC_MOTION_CANCEL bit(7) |
#define | EXEC_SLEEP bit(8) |
#define | EXEC_TOOL_CHANGE bit(9) |
#define | EXEC_PID_REPORT bit(10) |
#define | EXEC_GCODE_REPORT bit(11) |
#define | EXEC_TLO_REPORT bit(12) |
#define | EXEC_RT_COMMAND bit(13) |
#define | EXEC_DOOR_CLOSED bit(14) |
System state bit map. | |
The state variable (type sys_state_t) primarily tracks the individual states of grblHAL to manage each without overlapping. It is also used as a messaging flag for critical events. It is encapsulated by the main state machine in state_machine.c and can only be set via the state_set() or state_update() functions and read via the state_get() function. NOTE: flags are mutually exclusive, bit map allows testing for multiple states (except STATE_IDLE) in a single statement | |
#define | STATE_IDLE 0 |
Must be zero. No flags. More... | |
#define | STATE_ALARM bit(0) |
In alarm state. Locks out all g-code processes. Allows settings access. More... | |
#define | STATE_CHECK_MODE bit(1) |
G-code check mode. Locks out planner and motion only. More... | |
#define | STATE_HOMING bit(2) |
Performing homing cycle. More... | |
#define | STATE_CYCLE bit(3) |
Cycle is running or motions are being executed. More... | |
#define | STATE_HOLD bit(4) |
Active feed hold. More... | |
#define | STATE_JOG bit(5) |
Jogging mode. More... | |
#define | STATE_SAFETY_DOOR bit(6) |
Safety door is ajar. Feed holds and de-energizes system. More... | |
#define | STATE_SLEEP bit(7) |
Sleep state. More... | |
#define | STATE_ESTOP bit(8) |
EStop mode, reports and is mainly handled similar to alarm state. More... | |
#define | STATE_TOOL_CHANGE bit(9) |
Manual tool change, similar to STATE_HOLD - but stops spindle and allows jogging. More... | |
Typedefs | |
typedef uint_fast16_t | rt_exec_t |
See rt_exec. More... | |
typedef uint_fast16_t | sys_state_t |
See sys_state. More... | |
typedef struct system | system_t |
Global system variables struct. More... | |
typedef status_code_t(* | sys_command_ptr) (sys_state_t state, char *args) |
typedef const char *(* | sys_help_ptr) (const char *command) |
typedef struct sys_commands_str | sys_commands_t |
Enumerations | |
enum | machine_mode_t { Mode_Standard = 0 , Mode_Laser , Mode_Lathe } |
enum | parking_state_t { Parking_DoorClosed = 0 , Parking_DoorAjar , Parking_Retracting , Parking_Cancel , Parking_Resuming } |
enum | hold_state_t { Hold_NotHolding = 0 , Hold_Complete = 1 , Hold_Pending = 2 } |
enum | report_tracking_t { Report_ClearAll = 0 , Report_MPGMode = (1 << 0) , Report_Scaling = (1 << 1) , Report_Homed = (1 << 2) , Report_LatheXMode = (1 << 3) , Report_Spindle = (1 << 4) , Report_Coolant = (1 << 5) , Report_Overrides = (1 << 6) , Report_Tool = (1 << 7) , Report_WCO = (1 << 8) , Report_GWCO = (1 << 9) , Report_ToolOffset = (1 << 10) , Report_M66Result = (1 << 11) , Report_PWM = (1 << 12) , Report_Motor = (1 << 13) , Report_Encoder = (1 << 14) , Report_TLOReference = (1 << 15) , Report_Fan = (1 << 16) , Report_SpindleId = (1 << 17) , Report_ForceWCO = (1 << 29) , Report_CycleStart = (1 << 30) , Report_All = 0x8003FFFF } |
Functions | |
status_code_t | system_execute_line (char *line) |
Directs and executes one line of input from protocol_process. More... | |
void | system_execute_startup (void) |
Executes user startup scripts, if stored. More... | |
void | system_flag_wco_change (void) |
Called on a work coordinate (WCO) changes. More... | |
void | system_convert_array_steps_to_mpos (float *position, int32_t *steps) |
Sets machine position. Must be sent a 'step' array. More... | |
bool | system_xy_at_fixture (coord_system_id_t id, float tolerance) |
Checks if XY position is within coordinate system XY with given tolerance. More... | |
void | system_raise_alarm (alarm_code_t alarm) |
Raise and report a system alarm. More... | |
void | system_init_switches (void) |
void | system_command_help (void) |
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) |
Called on homing state changes. More... | |
void | system_add_rt_report (report_tracking_t report) |
Set(s) or clear all active realtime report addon flag(s) for the next report. More... | |
report_tracking_flags_t | system_get_rt_report_flags (void) |
Get the active realtime report addon flags for the next report. More... | |
void | control_interrupt_handler (control_signals_t signals) |
Pin change interrupt handler for pin-out commands, i.e. cycle start, feed hold, reset etc. Mainly sets the realtime command execute variable to have the main program execute these when its ready. This works exactly like the character-based realtime commands when picked off directly from the incoming data stream. More... | |
Variables | |
system_t | sys |
System global variable structure. More... | |
#define EXEC_CYCLE_COMPLETE bit(2) |
#define EXEC_CYCLE_START bit(1) |
#define EXEC_DOOR_CLOSED bit(14) |
#define EXEC_FEED_HOLD bit(3) |
#define EXEC_GCODE_REPORT bit(11) |
#define EXEC_MOTION_CANCEL bit(7) |
#define EXEC_PID_REPORT bit(10) |
#define EXEC_RESET bit(5) |
#define EXEC_RT_COMMAND bit(13) |
#define EXEC_SAFETY_DOOR bit(6) |
#define EXEC_SLEEP bit(8) |
#define EXEC_STATUS_REPORT bit(0) |
#define EXEC_STOP bit(4) |
#define EXEC_TLO_REPORT bit(12) |
#define EXEC_TOOL_CHANGE bit(9) |
#define STATE_ALARM bit(0) |
In alarm state. Locks out all g-code processes. Allows settings access.
#define STATE_CHECK_MODE bit(1) |
G-code check mode. Locks out planner and motion only.
#define STATE_CYCLE bit(3) |
Cycle is running or motions are being executed.
#define STATE_ESTOP bit(8) |
EStop mode, reports and is mainly handled similar to alarm state.
#define STATE_HOLD bit(4) |
Active feed hold.
#define STATE_HOMING bit(2) |
Performing homing cycle.
#define STATE_IDLE 0 |
Must be zero. No flags.
#define STATE_JOG bit(5) |
Jogging mode.
#define STATE_SAFETY_DOOR bit(6) |
Safety door is ajar. Feed holds and de-energizes system.
#define STATE_SLEEP bit(7) |
Sleep state.
#define STATE_TOOL_CHANGE bit(9) |
Manual tool change, similar to STATE_HOLD - but stops spindle and allows jogging.
#define system_clear_exec_alarm | ( | ) | hal.set_value_atomic(&sys.rt_exec_alarm, 0) |
#define system_clear_exec_state_flag | ( | mask | ) | hal.clear_bits_atomic(&sys.rt_exec_state, (mask)) |
#define system_clear_exec_states | ( | ) | hal.set_value_atomic(&sys.rt_exec_state, 0) |
#define system_set_exec_alarm | ( | code | ) | hal.set_value_atomic(&sys.rt_exec_alarm, (uint_fast16_t)(code)) |
#define system_set_exec_state_flag | ( | mask | ) | hal.set_bits_atomic(&sys.rt_exec_state, (mask)) |
typedef status_code_t(* sys_command_ptr) (sys_state_t state, char *args) |
typedef struct sys_commands_str sys_commands_t |
typedef const char*(* sys_help_ptr) (const char *command) |
typedef uint_fast16_t sys_state_t |
See sys_state.
enum hold_state_t |
enum machine_mode_t |
enum parking_state_t |
enum report_tracking_t |
void control_interrupt_handler | ( | control_signals_t | signals | ) |
Pin change interrupt handler for pin-out commands, i.e. cycle start, feed hold, reset etc. Mainly sets the realtime command execute variable to have the main program execute these when its ready. This works exactly like the character-based realtime commands when picked off directly from the incoming data stream.
signals | a control_signals_t union holding status of the signals. |
void system_add_rt_report | ( | report_tracking_t | report | ) |
Set(s) or clear all active realtime report addon flag(s) for the next report.
Fires the grbl.on_rt_reports_added event.
report | a report_tracking_t enum containing the flag(s) to set or clear. |
void system_clear_tlo_reference | ( | axes_signals_t | homing_cycle | ) |
Called on homing state changes.
Clears the tool length offset (TLO) when linear axis or X- or Z-axis is homed in lathe mode. Typically called on the grbl.on_homing complete event.
id | a axes_signals_t holding the axis flags that homed status was changed for. |
void system_command_help | ( | void | ) |
void system_convert_array_steps_to_mpos | ( | float * | position, |
int32_t * | steps | ||
) |
Sets machine position. Must be sent a 'step' array.
NOTE: If motor steps and machine position are not in the same coordinate frame, this function serves as a central place to compute the transformation.
position | pointer to the target float array for the machine position. |
steps | pointer to the source step count array to transform. |
status_code_t system_execute_line | ( | char * | line | ) |
Directs and executes one line of input from protocol_process.
While mostly incoming streaming g-code blocks, this also executes grblHAL internal commands, such as settings, initiating the homing cycle, and toggling switch states. This differs from the realtime command module by being susceptible to when grblHAL is ready to execute the next line during a cycle, so for switches like block delete, the switch only effects the lines that are processed afterward, not necessarily real-time during a cycle, since there are motions already stored in the buffer. However, this 'lag' should not be an issue, since these commands are not typically used during a cycle. If the command is not known to the core a grbl.on_unknown_sys_command event is raised so that plugin code can check if it is a command it supports.
NOTE: Code calling this function needs to provide the command in a writable buffer since the first part of the command (up to the first = character) is changed to uppercase and having spaces removed.
line | pointer to the command string. |
void system_execute_startup | ( | void | ) |
Executes user startup scripts, if stored.
void system_flag_wco_change | ( | void | ) |
Called on a work coordinate (WCO) changes.
If configured waits for the planner buffer to empty then fires the grbl.on_wco_changed event and sets the Report_WCO flag to add the WCO report element to the next status report.
report_tracking_flags_t system_get_rt_report_flags | ( | void | ) |
Get the active realtime report addon flags for the next report.
void system_init_switches | ( | void | ) |
void system_output_help | ( | const sys_command_t * | commands, |
uint32_t | num_commands | ||
) |
void system_raise_alarm | ( | alarm_code_t | alarm | ) |
Raise and report a system alarm.
a | alarm_code_t enum representing the alarm code. |
void system_register_commands | ( | sys_commands_t * | commands | ) |
bool system_xy_at_fixture | ( | coord_system_id_t | id, |
float | tolerance | ||
) |
Checks if XY position is within coordinate system XY with given tolerance.
id | a coord_system_id_t, typically CoordinateSystem_G59_3. |
tolerance | as the allowed radius the current position has to be within. |
|
extern |
System global variable structure.