grbl-LPC-CoreXY/protocol.h
2014-05-18 10:01:05 -06:00

61 lines
2.3 KiB
C

/*
protocol.h - the serial protocol master control unit
Part of Grbl
The MIT License (MIT)
GRBL(tm) - Embedded CNC g-code interpreter and motion-controller
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011-2012 Sungeun K. Jeon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef protocol_h
#define protocol_h
#include <avr/sleep.h>
// Line buffer size from the serial input stream to be executed.
// NOTE: Not a problem except for extreme cases, but the line buffer size can be too small
// and g-code blocks can get truncated. Officially, the g-code standards support up to 256
// characters. In future versions, this will be increased, when we know how much extra
// memory space we can invest into here or we re-write the g-code parser not to have his
// buffer.
#ifndef LINE_BUFFER_SIZE
#define LINE_BUFFER_SIZE 70
#endif
// Initialize the serial protocol
void protocol_init();
// Read command lines from the serial port and execute them as they
// come in. Blocks until the serial buffer is emptied.
void protocol_process();
// Executes one line of input according to protocol
uint8_t protocol_execute_line(char *line);
// Checks and executes a runtime command at various stop points in main program
void protocol_execute_runtime();
// Execute the startup script lines stored in EEPROM upon initialization
void protocol_execute_startup();
#endif