Skip to content

Commit

Permalink
Added input gcode text to data structure for logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
modmaker committed Jun 16, 2013
1 parent 4a2ded0 commit 0d69934
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gcode_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ static int32_t decfloat_to_int( decfloat *df, double multiplicand)
}


static char gcode_text[ 200];
static int gcode_text_index = 0;

/// Character Received - add it to our command
/// \param c the next character to process
void gcode_parse_char(uint8_t c) {
Expand All @@ -103,6 +106,14 @@ void gcode_parse_char(uint8_t c) {
/// for working out what to do with data just received
static uint8_t last_field = 0;

if (gcode_text_index < sizeof( gcode_text) - 1) {
if (c == '\t') {
gcode_text[ gcode_text_index++] = ' ';
} else if (c >= ' ') {
gcode_text[ gcode_text_index++] = c;
}
}

// uppercase
if (c >= 'a' && c <= 'z')
c &= ~32;
Expand Down Expand Up @@ -340,7 +351,10 @@ void gcode_parse_char(uint8_t c) {
) {
// process
serial_writestr_P( "ok ");
gcode_text[ gcode_text_index] = '\0';
next_target.command_text = gcode_text;
process_gcode_command( &next_target);
gcode_text_index = 0;
serial_writechar('\n');

// expect next line number
Expand Down
2 changes: 2 additions & 0 deletions gcode_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ typedef struct {

uint8_t checksum_read; ///< checksum in gcode command
uint8_t checksum_calculated; ///< checksum we calculated

char* command_text;
} GCODE_COMMAND;

/// accept the next character and process it
Expand Down

0 comments on commit 0d69934

Please sign in to comment.