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

Defines

#define MAX_CMD_SIZE   96

Functions

byte gcode_comp_binary_size (unsigned int bitfield)
 Computes size of binary data from bitfield.
void __cxa_pure_virtual ()
void osFifoInit (uint8 *buffer, uint8 bufferSize)
uint8 osFifoPutByte (uint8 *buffer, uint8 value)
 put byte in fofo buffer.
int osFifoGetByte (uint8 *buffer)
uint8 osFifoGetWaitByte (uint8 *buffer)
uint8 osFifoEmpty (uint8 *buffer)
uint8 osFifoFull (uint8 *buffer)
 ISR (USART0_UDRE_vect)
void gcode_resend ()
 request resend of the expected line.
void gcode_checkinsert (GCode *act)
void gcode_silent_insert ()
GCodegcode_next_command ()
void gcode_command_finished ()
 Removes the last returned command from cache.
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_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.
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.
byte out_buffer [OUTPUT_BUFFER_SIZE+4]
 Buffer for serial write operations.
SerialOutput out
 Instance used for serail write operations.

Define Documentation

#define MAX_CMD_SIZE   96

Function Documentation

void __cxa_pure_virtual ( )
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 ( )

Removes the last returned command from cache.

byte gcode_comp_binary_size ( unsigned int  bitfield)

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
GCode* gcode_next_command ( )

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.

void gcode_read_serial ( )

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.

void gcode_silent_insert ( )
float gcode_value ( char *  s) [inline]
long gcode_value_long ( char *  s) [inline]
ISR ( USART0_UDRE_vect  )

Write next byte in ouput buffer or disable output interrupt.

uint8 osFifoEmpty ( uint8 *  buffer)
uint8 osFifoFull ( uint8 *  buffer)
int osFifoGetByte ( uint8 *  buffer)
uint8 osFifoGetWaitByte ( uint8 *  buffer)
void osFifoInit ( uint8 *  buffer,
uint8  bufferSize 
)
uint8 osFifoPutByte ( uint8 *  buffer,
uint8  value 
)

put byte in fofo buffer.

The function returns 0 if it was not successfull, because the buffer was full.


Variable Documentation

long gcode_actN

Line number of current command.

Flags the command as binary input.

Expected size of the incoming binary command.

GCode gcode_buffer[GCODE_BUFFER_SIZE]

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.

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.

byte gcode_transbuffer[MAX_CMD_SIZE]

Current received command.

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.

byte out_buffer[OUTPUT_BUFFER_SIZE+4]

Buffer for serial write operations.

 All Data Structures Files Functions Variables Typedefs Friends Defines