From abc0edc6356e266e7aff0e5ea1d09c5b0f72aef7 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sat, 3 Jul 2010 02:24:13 +0200 Subject: [PATCH] Add the option to not include the asterisk in checksum calculation. RepRap host software does it this way. --- mendel/gcode.c | 11 +++++++++-- mendel/gcode.h | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mendel/gcode.c b/mendel/gcode.c index 645f21c..23faa5c 100644 --- a/mendel/gcode.c +++ b/mendel/gcode.c @@ -17,6 +17,8 @@ uint8_t last_field = 0; const char alphabet[] = "GMXYZEFSPN*"; +#define crc(a, b) (a ^ b) + decfloat read_digit __attribute__ ((__section__ (".bss"))); GCODE_COMMAND next_target __attribute__ ((__section__ (".bss"))); @@ -103,10 +105,10 @@ void SpecialMoveE(int32_t e, uint32_t f) { ****************************************************************************/ void scan_char(uint8_t c) { - // move this below switch(c) if the asterisk isn't included in the checksum - #define crc(a, b) (a ^ b) + #ifdef ASTERISK_IN_CHECKSUM_INCLUDED if (next_target.seen_checksum == 0) next_target.checksum_calculated = crc(next_target.checksum_calculated, c); + #endif // uppercase if (c >= 'a' && c <= 'z') @@ -290,6 +292,11 @@ void scan_char(uint8_t c) { } } + #ifndef ASTERISK_IN_CHECKSUM_INCLUDED + if (next_target.seen_checksum == 0) + next_target.checksum_calculated = crc(next_target.checksum_calculated, c); + #endif + // end of line if ((c == 10) || (c == 13)) { if (debug_flags & DEBUG_ECHO) diff --git a/mendel/gcode.h b/mendel/gcode.h index 461036a..075099d 100644 --- a/mendel/gcode.h +++ b/mendel/gcode.h @@ -5,6 +5,10 @@ #include "dda.h" +// wether the asterisk (checksum-command) is included for checksum calculation +// undefined for RepRap host software +//#define ASTERISK_IN_CHECKSUM_INCLUDED + // wether to insist on N line numbers // if not defined, N's are completely ignored //#define REQUIRE_LINENUMBER