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.
This commit is contained in:
Markus Hitter 2012-08-16 23:32:29 +02:00
parent 25aaafeff2
commit 931d81af58
1 changed files with 4 additions and 1 deletions

View File

@ -97,6 +97,8 @@ void gcode_init(void) {
/// Character Received - add it to our command /// Character Received - add it to our command
/// \param c the next character to process /// \param c the next character to process
void gcode_parse_char(uint8_t c) { void gcode_parse_char(uint8_t c) {
uint8_t checksum_char = c;
// uppercase // uppercase
if (c >= 'a' && c <= 'z') if (c >= 'a' && c <= 'z')
c &= ~32; c &= ~32;
@ -309,7 +311,8 @@ void gcode_parse_char(uint8_t c) {
next_target.seen_parens_comment = 0; // recognize stuff after a (comment) next_target.seen_parens_comment = 0; // recognize stuff after a (comment)
if (next_target.seen_checksum == 0) 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 // end of line
if ((c == 10) || (c == 13)) { if ((c == 10) || (c == 13)) {