grblHAL core  20241107
protocol.h
Go to the documentation of this file.
1 /*
2  protocol.h - controls Grbl execution protocol and procedures
3 
4  Part of grblHAL
5 
6  Copyright (c) 2016-2024 Terje Io
7  Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
8  Copyright (c) 2009-2011 Simen Svale Skogsrud
9 
10  grblHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  grblHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef _PROTOCOL_H_
25 #define _PROTOCOL_H_
26 
27 #include "task.h"
28 
29 // Line buffer size from the input stream to be executed.
30 // NOTE: Not a problem except for extreme cases, but the line buffer size can be too small
31 // and g-code blocks can get truncated. Officially, the g-code standards support up to 256
32 // characters. In future versions, this will be increased, when we know how much extra
33 // memory space we can invest into here or we re-write the g-code parser not to have this
34 // buffer.
35 #ifndef LINE_BUFFER_SIZE
36  #define LINE_BUFFER_SIZE 257 // 256 characters plus terminator
37 #endif
38 
39 typedef union {
42 } fg_task_ptr __attribute__ ((__transparent_union__));
43 
44 // Starts grblHAL main loop. It handles all incoming characters from the input stream and executes
45 // them as they complete. It is also responsible for finishing the initialization procedures.
46 bool protocol_main_loop (void);
47 
48 // Checks and executes a realtime command at various stop points in main program
49 bool protocol_execute_realtime (void);
50 bool protocol_exec_rt_system (void);
51 void protocol_execute_noop (uint_fast16_t state);
53 bool protocol_enqueue_foreground_task (fg_task_ptr fn, void *data);
54 
55 // Executes the auto cycle feature, if enabled.
56 void protocol_auto_cycle_start (void);
57 
58 // Block until all buffered steps are executed
59 bool protocol_buffer_synchronize (void);
60 
62 bool protocol_enqueue_gcode (char *data);
63 void protocol_message (char *message);
64 
65 #endif
void(* on_execute_realtime_ptr)(sys_state_t state)
Definition: core_handlers.h:93
__attribute__
Definition: errors.h:30
void protocol_message(char *message)
bool protocol_main_loop(void)
Definition: protocol.c:143
bool protocol_execute_realtime(void)
Definition: protocol.c:419
bool protocol_enqueue_realtime_command(char c)
Definition: protocol.c:829
void protocol_auto_cycle_start(void)
Definition: protocol.c:400
bool protocol_enqueue_rt_command(on_execute_realtime_ptr fn)
Enqueue a function to be called once by the foreground process.
Definition: protocol.c:1065
bool protocol_enqueue_foreground_task(fg_task_ptr fn, void *data)
Enqueue a function to be called once by the foreground process.
Definition: protocol.c:1045
bool protocol_buffer_synchronize(void)
Definition: protocol.c:379
void protocol_execute_noop(uint_fast16_t state)
Definition: protocol.c:1093
bool protocol_enqueue_gcode(char *data)
Definition: protocol.c:74
bool protocol_exec_rt_system(void)
Definition: protocol.c:462
void(* foreground_task_ptr)(void *data)
Definition: task.h:25
Definition: protocol.h:39
foreground_task_ptr fn
Definition: protocol.h:40
on_execute_realtime_ptr fn_deprecated
Definition: protocol.h:41