Repetier-Firmware  0.80
Repetier/gcode.h File Reference
#include <avr/pgmspace.h>

Go to the source code of this file.

Data Structures

struct  GCode
struct  ring_buffer
class  RFHardwareSerial
class  SerialOutput

Defines

#define SERIAL_BUFFER_SIZE   128
#define SERIAL_BUFFER_MASK   127
#define RFSERIAL   RFSerial
#define WAIT_OUT_EMPTY   while(tx_buffer.head != tx_buffer.tail) {}
#define OUT_P_I(p, i)   out.print_int_P(PSTR(p),(int)(i))
#define OUT_P_I_LN(p, i)   out.println_int_P(PSTR(p),(int)(i))
#define OUT_P_L(p, i)   out.print_long_P(PSTR(p),(long)(i))
#define OUT_P_L_LN(p, i)   out.println_long_P(PSTR(p),(long)(i))
#define OUT_P_F(p, i)   out.print_float_P(PSTR(p),(float)(i))
#define OUT_P_F_LN(p, i)   out.println_float_P(PSTR(p),(float)(i))
#define OUT_P_FX(p, i, x)   out.print_float_P(PSTR(p),(float)(i),x)
#define OUT_P_FX_LN(p, i, x)   out.println_float_P(PSTR(p),(float)(i),x)
#define OUT_P(p)   out.print_P(PSTR(p))
#define OUT_P_LN(p)   out.println_P(PSTR(p))
#define OUT_ERROR_P(p)   out.print_error_P(PSTR(p),false)
#define OUT_ERROR_P_LN(p)   out.print_error_P(PSTR(p),true)
#define OUT(v)   out.print(v)
#define OUT_LN   out.println()
#define GCODE_HAS_N(a)   ((a->params & 1)!=0)
#define GCODE_HAS_M(a)   ((a->params & 2)!=0)
#define GCODE_HAS_G(a)   ((a->params & 4)!=0)
#define GCODE_HAS_X(a)   ((a->params & 8)!=0)
#define GCODE_HAS_Y(a)   ((a->params & 16)!=0)
#define GCODE_HAS_Z(a)   ((a->params & 32)!=0)
#define GCODE_HAS_NO_XYZ(a)   ((a->params & 56)==0)
#define GCODE_HAS_E(a)   ((a->params & 64)!=0)
#define GCODE_HAS_F(a)   ((a->params & 256)!=0)
#define GCODE_HAS_T(a)   ((a->params & 512)!=0)
#define GCODE_HAS_S(a)   ((a->params & 1024)!=0)
#define GCODE_HAS_P(a)   ((a->params & 2048)!=0)
#define GCODE_IS_V2(a)   ((a->params & 4096)!=0)
#define GCODE_HAS_STRING(a)   ((a->params & 32768)!=0)
#define GCODE_HAS_I(a)   ((a->params2 & 1)!=0)
#define GCODE_HAS_J(a)   ((a->params2 & 2)!=0)
#define GCODE_HAS_R(a)   ((a->params2 & 4)!=0)
#define DEBUG_ECHO   ((debug_level & 1)!=0)
#define DEBUG_INFO   ((debug_level & 2)!=0)
#define DEBUG_ERRORS   ((debug_level & 4)!=0)
#define DEBUG_DRYRUN   ((debug_level & 8)!=0)
#define DEBUG_COMMUNICATION   ((debug_level & 16)!=0)
#define DEBUG_NO_MOVES   ((debug_level & 32)!=0)

Functions

GCodegcode_next_command ()
void gcode_command_finished (GCode *code)
 Removes the last returned command from cache.
void gcode_read_serial ()
 Read from serial console or sdcard.
void gcode_execute_PString (PGM_P cmd)
 Execute commands in progmem stored string. Multiple commands are seperated by
.
void gcode_print_command (GCode *code)
 Print command on serial console.
byte gcode_comp_binary_size (char *ptr)
 Computes size of binary data from bitfield.
bool gcode_parse_binary (GCode *code, byte *buffer)
bool gcode_parse_ascii (GCode *code, char *line)
void emergencyStop ()

Variables

RFHardwareSerial RFSerial
ring_buffer tx_buffer
SerialOutput out
 Instance used for serail write operations.
byte debug_level
 Bitfield defining debug output. 1 = echo, 2 = info, 4 = error, 8 = dry run., 16 = Only communication, 32 = No moves.

Define Documentation

#define DEBUG_COMMUNICATION   ((debug_level & 16)!=0)
#define DEBUG_DRYRUN   ((debug_level & 8)!=0)
#define DEBUG_ECHO   ((debug_level & 1)!=0)
#define DEBUG_ERRORS   ((debug_level & 4)!=0)
#define DEBUG_INFO   ((debug_level & 2)!=0)
#define DEBUG_NO_MOVES   ((debug_level & 32)!=0)
#define GCODE_HAS_E (   a)    ((a->params & 64)!=0)
#define GCODE_HAS_F (   a)    ((a->params & 256)!=0)
#define GCODE_HAS_G (   a)    ((a->params & 4)!=0)
#define GCODE_HAS_I (   a)    ((a->params2 & 1)!=0)
#define GCODE_HAS_J (   a)    ((a->params2 & 2)!=0)
#define GCODE_HAS_M (   a)    ((a->params & 2)!=0)
#define GCODE_HAS_N (   a)    ((a->params & 1)!=0)
#define GCODE_HAS_NO_XYZ (   a)    ((a->params & 56)==0)
#define GCODE_HAS_P (   a)    ((a->params & 2048)!=0)
#define GCODE_HAS_R (   a)    ((a->params2 & 4)!=0)
#define GCODE_HAS_S (   a)    ((a->params & 1024)!=0)
#define GCODE_HAS_STRING (   a)    ((a->params & 32768)!=0)
#define GCODE_HAS_T (   a)    ((a->params & 512)!=0)
#define GCODE_HAS_X (   a)    ((a->params & 8)!=0)
#define GCODE_HAS_Y (   a)    ((a->params & 16)!=0)
#define GCODE_HAS_Z (   a)    ((a->params & 32)!=0)
#define GCODE_IS_V2 (   a)    ((a->params & 4096)!=0)
#define OUT (   v)    out.print(v)
#define OUT_ERROR_P (   p)    out.print_error_P(PSTR(p),false)
#define OUT_ERROR_P_LN (   p)    out.print_error_P(PSTR(p),true)
#define OUT_LN   out.println()
#define OUT_P (   p)    out.print_P(PSTR(p))
#define OUT_P_F (   p,
 
)    out.print_float_P(PSTR(p),(float)(i))
#define OUT_P_F_LN (   p,
 
)    out.println_float_P(PSTR(p),(float)(i))
#define OUT_P_FX (   p,
  i,
 
)    out.print_float_P(PSTR(p),(float)(i),x)
#define OUT_P_FX_LN (   p,
  i,
 
)    out.println_float_P(PSTR(p),(float)(i),x)
#define OUT_P_I (   p,
 
)    out.print_int_P(PSTR(p),(int)(i))
#define OUT_P_I_LN (   p,
 
)    out.println_int_P(PSTR(p),(int)(i))
#define OUT_P_L (   p,
 
)    out.print_long_P(PSTR(p),(long)(i))
#define OUT_P_L_LN (   p,
 
)    out.println_long_P(PSTR(p),(long)(i))
#define OUT_P_LN (   p)    out.println_P(PSTR(p))
#define RFSERIAL   RFSerial
#define SERIAL_BUFFER_MASK   127
#define SERIAL_BUFFER_SIZE   128
#define WAIT_OUT_EMPTY   while(tx_buffer.head != tx_buffer.tail) {}

Function Documentation

void emergencyStop ( )
void gcode_command_finished ( GCode code)

Removes the last returned command from cache.

Frees the cache used by the last command fetched.

byte gcode_comp_binary_size ( char *  ptr)

Computes size of binary data from bitfield.

In the repetier-protocol in binary mode, the first 2 bytes define the data. From this bitfield, this function computes the size of the command including the 2 bytes of the bitfield and the 2 bytes for the checksum.

Gcode Letter to Bit and Datatype:

  • N : Bit 0 : 16-Bit Integer
  • M : Bit 1 : 8-Bit unsigned byte
  • G : Bit 2 : 8-Bit unsigned byte
  • X : Bit 3 : 32-Bit Float
  • Y : Bit 4 : 32-Bit Float
  • Z : Bit 5 : 32-Bit Float
  • E : Bit 6 : 32-Bit Float
  • : Bit 7 : always set to distinguish binary from ASCII line.
  • F : Bit 8 : 32-Bit Float
  • T : Bit 9 : 8 Bit Integer
  • S : Bit 10 : 32 Bit Value
  • P : Bit 11 : 32 Bit Integer
  • V2 : Bit 12 : Version 2 command for additional commands/sizes
  • Ext : Bit 13 : There are 2 more bytes following with Bits, only for future versions
  • Int :Bit 14 : Marks it as internal command,
  • Text : Bit 15 : 16 Byte ASCII String terminated with 0 Second word if V2:
  • I : Bit 0 : 32-Bit float
  • J : Bit 1 : 32-Bit float
  • R : Bit 2 : 32-Bit float
void gcode_execute_PString ( PGM_P  cmd)

Execute commands in progmem stored string. Multiple commands are seperated by
.

Get next command in command buffer. After the command is processed, call gcode_command_finished()

Get the next buffered command. Returns 0 if no more commands are buffered. For each returned command, the gcode_command_finished() function must be called.

bool gcode_parse_ascii ( GCode code,
char *  line 
)

Converts a ascii GCode line into a GCode structure.

bool gcode_parse_binary ( GCode code,
byte *  buffer 
)

Converts a binary bytefield containing one GCode line into a GCode structure. Returns true if checksum was correct.

void gcode_print_command ( GCode code)

Print command on serial console.

Read from serial console or sdcard.

This function is the main function to read the commands from serial console or from sdcard. It must be called frequently to empty the incoming buffer.


Variable Documentation

Bitfield defining debug output. 1 = echo, 2 = info, 4 = error, 8 = dry run., 16 = Only communication, 32 = No moves.

Instance used for serail write operations.

 All Data Structures Namespaces Files Functions Variables Typedefs Friends Defines