From 931d81af58599ed9eeb053b61b0b43420b16b094 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Thu, 16 Aug 2012 23:32:29 +0200 Subject: [PATCH] gcode_parse.c: checksum the characters actually received. Wow! It took something like two years to expose (and get developer attention of) such a bug: the checksum was calculated based on the uppercased characters parsed, not the ones actually received over the line. --- gcode_parse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcode_parse.c b/gcode_parse.c index c2e0446..5d559ea 100644 --- a/gcode_parse.c +++ b/gcode_parse.c @@ -97,6 +97,8 @@ void gcode_init(void) { /// Character Received - add it to our command /// \param c the next character to process void gcode_parse_char(uint8_t c) { + uint8_t checksum_char = c; + // uppercase if (c >= 'a' && c <= 'z') c &= ~32; @@ -309,7 +311,8 @@ void gcode_parse_char(uint8_t c) { next_target.seen_parens_comment = 0; // recognize stuff after a (comment) if (next_target.seen_checksum == 0) - next_target.checksum_calculated = crc(next_target.checksum_calculated, c); + next_target.checksum_calculated = + crc(next_target.checksum_calculated, checksum_char); // end of line if ((c == 10) || (c == 13)) {