Repetier-Firmware  0.91
GCode Class Reference

#include <gcode.h>

Public Member Functions

bool hasM ()
bool hasN ()
bool hasG ()
bool hasX ()
bool hasY ()
bool hasZ ()
bool hasNoXYZ ()
bool hasE ()
bool hasF ()
bool hasT ()
bool hasS ()
bool hasP ()
bool isV2 ()
bool hasString ()
bool hasI ()
bool hasJ ()
bool hasR ()
long getS (long def)
long getP (long def)
void setFormatError ()
bool hasFormatError ()
void printCommand ()
 Print command on serial console.
bool parseBinary (uint8_t *buffer, bool fromSerial)
bool parseAscii (char *line, bool fromSerial)
void popCurrentCommand ()
 Removes the last returned command from cache.
void echoCommand ()

Static Public Member Functions

static GCodepeekCurrentCommand ()
static void readFromSerial ()
 Read from serial console or sdcard.
static void pushCommand ()
static void executeFString (FSTRINGPARAM(cmd))
 Execute commands in progmem stored string. Multiple commands are seperated by
.
static uint8_t computeBinarySize (char *ptr)
 Computes size of binary data from bitfield.

Data Fields

unsigned int N
unsigned int M
unsigned int G
float X
float Y
float Z
float E
float F
uint8_t T
long S
long P
float I
float J
float R
char * text

Private Member Functions

void debugCommandBuffer ()
void checkAndPushCommand ()
float parseFloatValue (char *s)
long parseLongValue (char *s)

Static Private Member Functions

static void requestResend ()

Private Attributes

unsigned int params
unsigned int params2

Static Private Attributes

static GCode commandsBuffered [GCODE_BUFFER_SIZE]
 Buffer for received commands.
static uint8_t bufferReadIndex = 0
 Read position in gcode_buffer.
static uint8_t bufferWriteIndex = 0
 Write position in gcode_buffer.
static uint8_t commandReceiving [MAX_CMD_SIZE]
 Current received command.
static uint8_t commandsReceivingWritePosition = 0
 Writing position in gcode_transbuffer.
static uint8_t sendAsBinary
 Flags the command as binary input.
static uint8_t wasLastCommandReceivedAsBinary = 0
 Was the last successful command in binary mode?
static uint8_t commentDetected = false
 Flags true if we are reading the comment part of a command.
static uint8_t binaryCommandSize
 Expected size of the incoming binary command.
static bool waitUntilAllCommandsAreParsed = false
 Don't read until all commands are parsed. Needed if gcode_buffer is misused as storage for strings.
static uint32_t lastLineNumber = 0
 Last line number received.
static uint32_t actLineNumber
 Line number of current command.
static int8_t waitingForResend = -1
 Waiting for line to be resend. -1 = no wait.
static volatile uint8_t bufferLength = 0
 Number of commands stored in gcode_buffer.
static millis_t timeOfLastDataPacket = 0
 Time, when we got the last data packet. Used to detect missing uint8_ts.
static uint8_t formatErrors = 0
 Number of sequential format errors.

Friends

class SDCard
class UIDisplay

Member Function Documentation

void checkAndPushCommand ( ) [private]

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.

uint8_t computeBinarySize ( char *  ptr) [static]

Computes size of binary data from bitfield.

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

Gcode Letter to Bit and Datatype:

  • N : Bit 0 : 16-Bit Integer
  • M : Bit 1 : 8-Bit unsigned uint8_t
  • G : Bit 2 : 8-Bit unsigned uint8_t
  • 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 uint8_ts 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 debugCommandBuffer ( ) [private]
void echoCommand ( )
void executeFString ( FSTRINGPARAM(cmd)  ) [static]

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

long getP ( long  def) [inline]
long getS ( long  def) [inline]
bool hasE ( ) [inline]
bool hasF ( ) [inline]
bool hasFormatError ( ) [inline]
bool hasG ( ) [inline]
bool hasI ( ) [inline]
bool hasJ ( ) [inline]
bool hasM ( ) [inline]
bool hasN ( ) [inline]
bool hasNoXYZ ( ) [inline]
bool hasP ( ) [inline]
bool hasR ( ) [inline]
bool hasS ( ) [inline]
bool hasString ( ) [inline]
bool hasT ( ) [inline]
bool hasX ( ) [inline]
bool hasY ( ) [inline]
bool hasZ ( ) [inline]
bool isV2 ( ) [inline]
bool parseAscii ( char *  line,
bool  fromSerial 
)

Converts a ascii GCode line into a GCode structure.

bool parseBinary ( uint8_t *  buffer,
bool  fromSerial 
)

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

float parseFloatValue ( char *  s) [inline, private]
long parseLongValue ( char *  s) [inline, private]
GCode * peekCurrentCommand ( ) [static]

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.

Removes the last returned command from cache.

void printCommand ( )

Print command on serial console.

void pushCommand ( ) [static]
void readFromSerial ( ) [static]

Read from serial console or sdcard.

Frees the cache used by the last command fetched.

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 requestResend ( ) [static, private]
void setFormatError ( ) [inline]

Friends And Related Function Documentation

friend class SDCard [friend]
friend class UIDisplay [friend]

Field Documentation

uint32_t actLineNumber [static, private]

Line number of current command.

uint8_t binaryCommandSize [static, private]

Expected size of the incoming binary command.

volatile uint8_t bufferLength = 0 [static, private]

Number of commands stored in gcode_buffer.

uint8_t bufferReadIndex = 0 [static, private]

Read position in gcode_buffer.

uint8_t bufferWriteIndex = 0 [static, private]

Write position in gcode_buffer.

uint8_t commandReceiving [static, private]

Current received command.

GCode commandsBuffered [static, private]

Buffer for received commands.

uint8_t commandsReceivingWritePosition = 0 [static, private]

Writing position in gcode_transbuffer.

uint8_t commentDetected = false [static, private]

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

float E
float F
uint8_t formatErrors = 0 [static, private]

Number of sequential format errors.

unsigned int G
float I
float J
uint32_t lastLineNumber = 0 [static, private]

Last line number received.

unsigned int M
unsigned int N
long P
unsigned int params [private]
unsigned int params2 [private]
float R
long S
uint8_t sendAsBinary [static, private]

Flags the command as binary input.

uint8_t T
char* text
millis_t timeOfLastDataPacket = 0 [static, private]

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

int8_t waitingForResend = -1 [static, private]

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

bool waitUntilAllCommandsAreParsed = false [static, private]

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

uint8_t wasLastCommandReceivedAsBinary = 0 [static, private]

Was the last successful command in binary mode?

float X
float Y
float Z

The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Defines