Skip to content

File syn_gcode.c

FileList > motor > syn_gcode.c

Go to the source code of this file

G-Code & NIST RS-274 Motion Interpreter and Controller Implementation.

  • #include "syn_gcode.h"
  • #include <ctype.h>
  • #include <math.h>
  • #include <string.h>

Public Functions

Type Name
SYN_Status syn_gcode_execute_block (SYN_GCode_Controller * ctrl, const SYN_GCode_Block * block)
Execute a parsed G-Code block on the controller.
SYN_Status syn_gcode_execute_line (SYN_GCode_Controller * ctrl, const char * line)
Parse and execute an ASCII G-Code line in one step.
SYN_Status syn_gcode_init (SYN_GCode_Controller * ctrl, const SYN_GCode_Config * cfg)
Initialize G-Code Controller.
SYN_Status syn_gcode_parse_line (const char * line, SYN_GCode_Block * block)
Parse a single ASCII G-Code line into a command block.
bool syn_gcode_step (SYN_GCode_Controller * ctrl, SYN_Vector3F * out_pos)
Step the active motion move generated by the G-code controller.
SYN_PT_Status syn_gcode_task_pt (SYN_PT * pt, SYN_Task * task)
Protothread continuation function for syn_sched .

Public Static Functions

Type Name
const char * parse_float_val (const char * p, float * out_val)
Parse floating point number from G-code word.
const char * parse_uint_val (const char * p, uint32_t * out_val)
Parse unsigned integer from G-code word.
const char * skip_whitespace (const char * p)
Skip whitespace characters in G-code string.

Macros

Type Name
define SYN_GCODE_DEFAULT_ACCEL 500.0f
Default acceleration in mm/s^2.
define SYN_GCODE_DEFAULT_FEEDRATE 100.0f
Default feedrate in mm/min.
define SYN_GCODE_DEFAULT_JERK 2000.0f
Default jerk in mm/s^3.
define SYN_GCODE_DEFAULT_STEP_RES 0.001f
Default step resolution in seconds.

Public Functions Documentation

function syn_gcode_execute_block

Execute a parsed G-Code block on the controller.

SYN_Status syn_gcode_execute_block (
    SYN_GCode_Controller * ctrl,
    const SYN_GCode_Block * block
) 

Parameters:

  • ctrl Controller instance.
  • block Parsed block to execute.

Returns:

SYN_OK on success.


function syn_gcode_execute_line

Parse and execute an ASCII G-Code line in one step.

SYN_Status syn_gcode_execute_line (
    SYN_GCode_Controller * ctrl,
    const char * line
) 

Parameters:

  • ctrl Controller instance.
  • line Null-terminated ASCII string line.

Returns:

SYN_OK on success.


function syn_gcode_init

Initialize G-Code Controller.

SYN_Status syn_gcode_init (
    SYN_GCode_Controller * ctrl,
    const SYN_GCode_Config * cfg
) 

Parameters:

  • ctrl Controller instance.
  • cfg Configuration parameters.

Returns:

SYN_OK on success, SYN_INVALID_PARAM on invalid argument.


function syn_gcode_parse_line

Parse a single ASCII G-Code line into a command block.

SYN_Status syn_gcode_parse_line (
    const char * line,
    SYN_GCode_Block * block
) 

Parameters:

  • line Null-terminated ASCII string line.
  • block Output parsed block structure.

Returns:

SYN_OK on success, SYN_INVALID_PARAM on malformed line.


function syn_gcode_step

Step the active motion move generated by the G-code controller.

bool syn_gcode_step (
    SYN_GCode_Controller * ctrl,
    SYN_Vector3F * out_pos
) 

Parameters:

  • ctrl Controller instance.
  • out_pos Output calculated position after step.

Returns:

true if move active and advanced, false if move complete / idle.


function syn_gcode_task_pt

Protothread continuation function for syn_sched .

SYN_PT_Status syn_gcode_task_pt (
    SYN_PT * pt,
    SYN_Task * task
) 

Parameters:

  • pt Protothread continuation structure.
  • task Task handle containing SYN_GCode_Controller in user_data.

Returns:

SYN_PT_Status continuation status.


Public Static Functions Documentation

function parse_float_val

Parse floating point number from G-code word.

static const char * parse_float_val (
    const char * p,
    float * out_val
) 

Parameters:

  • p Pointer to number start.
  • out_val Pointer to receive parsed float.

Returns:

Pointer after parsed number, or NULL on parse error.


function parse_uint_val

Parse unsigned integer from G-code word.

static const char * parse_uint_val (
    const char * p,
    uint32_t * out_val
) 

Parameters:

  • p Pointer to integer start.
  • out_val Pointer to receive parsed unsigned integer.

Returns:

Pointer after parsed integer, or NULL on parse error.


function skip_whitespace

Skip whitespace characters in G-code string.

static const char * skip_whitespace (
    const char * p
) 

Parameters:

  • p Pointer to input string.

Returns:

Pointer to next non-whitespace character.


Macro Definition Documentation

define SYN_GCODE_DEFAULT_ACCEL

Default acceleration in mm/s^2.

#define SYN_GCODE_DEFAULT_ACCEL `500.0f`


define SYN_GCODE_DEFAULT_FEEDRATE

Default feedrate in mm/min.

#define SYN_GCODE_DEFAULT_FEEDRATE `100.0f`


define SYN_GCODE_DEFAULT_JERK

Default jerk in mm/s^3.

#define SYN_GCODE_DEFAULT_JERK `2000.0f`


define SYN_GCODE_DEFAULT_STEP_RES

Default step resolution in seconds.

#define SYN_GCODE_DEFAULT_STEP_RES `0.001f`



The documentation for this class was generated from the following file src/syntropic/motor/syn_gcode.c