Repetier-Firmware  0.80
Repetier/gcode.cpp File Reference
#include "Reptier.h"

Defines

#define bit_clear(x, y)   x&= ~(1<<y)
#define bit_set(x, y)   x|= (1<<y)
#define MAX_CMD_SIZE   96

Functions

void rf_store_char (unsigned char c, ring_buffer *buffer)
byte gcode_comp_binary_size (char *ptr)
 Computes size of binary data from bitfield.
void __cxa_pure_virtual ()
void gcode_resend ()
 request resend of the expected line.
void emergencyStop ()
void gcode_checkinsert (GCode *act)
void gcode_silent_insert ()
GCodegcode_next_command ()
void gcode_command_finished (GCode *code)
 Removes the last returned command from cache.
void gcode_execute_PString (PGM_P cmd)
 Execute commands in progmem stored string. Multiple commands are seperated by
.
void gcode_read_serial ()
 Read from serial console or sdcard.
bool gcode_parse_binary (GCode *code, byte *buffer)
float gcode_value (char *s)
long gcode_value_long (char *s)
bool gcode_parse_ascii (GCode *code, char *line)
void gcode_print_command (GCode *code)
 Print command on serial console.

Variables

GCode gcode_buffer [GCODE_BUFFER_SIZE]
 Buffer for received commands.
byte gcode_rindex = 0
 Read position in gcode_buffer.
byte gcode_windex = 0
 Write position in gcode_buffer.
byte gcode_transbuffer [MAX_CMD_SIZE]
 Current received command.
byte gcode_wpos = 0
 Writing position in gcode_transbuffer.
byte gcode_binary
 Flags the command as binary input.
byte gcode_last_binary = 0
 Was the last successful command in binary mode?
byte gcode_comment = false
 Flags true if we are reading the comment part of a command.
byte gcode_binary_size
 Expected size of the incoming binary command.
bool gcode_wait_all_parsed = false
 Don't read until all commands are parsed. Needed if gcode_buffer is misused as storage for strings.
long gcode_lastN = 0
 Last line number received.
long gcode_actN
 Line number of current command.
char gcode_wait_resend = -1
 Waiting for line to be resend. -1 = no wait.
volatile byte gcode_buflen = 0
 Number of commands stored in gcode_buffer.
unsigned long gcode_lastdata = 0
 Time, when we got the last data packet. Used to detect missing bytes.
SerialOutput out
 Instance used for serail write operations.
ring_buffer rx_buffer = { { 0 }, 0, 0}
ring_buffer tx_buffer = { { 0 }, 0, 0}

Define Documentation

#define bit_clear (   x,
 
)    x&= ~(1<<y)
#define bit_set (   x,
 
)    x|= (1<<y)
#define MAX_CMD_SIZE   96

Function Documentation

void emergencyStop ( )
void gcode_checkinsert ( GCode act)

Check if result is plausible. If it is, an ok is send and the command is stored in queue. If not, a resend and ok is send.

void gcode_command_finished ( GCode code)

Removes the last returned command from cache.

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 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.

void gcode_resend ( )

request resend of the expected line.

float gcode_value ( char *  s) [inline]
long gcode_value_long ( char *  s) [inline]
void rf_store_char ( unsigned char  c,
ring_buffer buffer 
) [inline]

Variable Documentation

long gcode_actN

Line number of current command.

Flags the command as binary input.

Expected size of the incoming binary command.

Buffer for received commands.

volatile byte gcode_buflen = 0

Number of commands stored in gcode_buffer.

byte gcode_comment = false

Flags true if we are reading the comment part of a command.

Was the last successful command in binary mode?

unsigned long gcode_lastdata = 0

Time, when we got the last data packet. Used to detect missing bytes.

long gcode_lastN = 0

Last line number received.

byte gcode_rindex = 0

Read position in gcode_buffer.

Current received command.

bool gcode_wait_all_parsed = false

Don't read until all commands are parsed. Needed if gcode_buffer is misused as storage for strings.

char gcode_wait_resend = -1

Waiting for line to be resend. -1 = no wait.

byte gcode_windex = 0

Write position in gcode_buffer.

byte gcode_wpos = 0

Writing position in gcode_transbuffer.

Instance used for serail write operations.

ring_buffer rx_buffer = { { 0 }, 0, 0}
ring_buffer tx_buffer = { { 0 }, 0, 0}
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Defines