From 0bd0848dd5fb10e32b0c2c7310fe4cbbe0012d70 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sat, 3 Jul 2010 02:03:51 +0200 Subject: [PATCH] Make resend requests RepRap host compatible, too. --- mendel/gcode.c | 21 +++++++++++++++++++-- mendel/gcode.h | 7 +++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mendel/gcode.c b/mendel/gcode.c index 5fbd4b9..7fcd493 100644 --- a/mendel/gcode.c +++ b/mendel/gcode.c @@ -329,15 +329,17 @@ void scan_char(uint8_t c) { next_target.N_expected = next_target.N + 1; } else { - serial_writestr_P(PSTR("RESEND: BAD CHECKSUM: EXPECTED ")); + serial_writestr_P(PSTR("Expected checksum ")); serwrite_uint8(next_target.checksum_calculated); serial_writestr_P(PSTR("\n")); + request_resend(); } } else { - serial_writestr_P(PSTR("RESEND: BAD LINE NUMBER: EXPECTED ")); + serial_writestr_P(PSTR("Expected line number ")); serwrite_uint32(next_target.N_expected); serial_writestr_P(PSTR("\n")); + request_resend(); } // reset variables @@ -722,3 +724,18 @@ void process_gcode_command(GCODE_COMMAND *gcmd) { } } } + +/**************************************************************************** +* * +* Request a resend of the current line - used from various places. * +* * +* Relies on the global variable next_target.N being valid. * +* * +****************************************************************************/ + +void request_resend() { + serial_writestr_P(PSTR("Resend:")); + serwrite_uint8(next_target.N); + serial_writestr_P(PSTR("\n")); +} + diff --git a/mendel/gcode.h b/mendel/gcode.h index c250a7b..461036a 100644 --- a/mendel/gcode.h +++ b/mendel/gcode.h @@ -7,10 +7,10 @@ // wether to insist on N line numbers // if not defined, N's are completely ignored -//#define REQUIRE_LINENUMBER +//#define REQUIRE_LINENUMBER // wether to insist on a checksum -//#define REQUIRE_CHECKSUM +//#define REQUIRE_CHECKSUM // this is a very crude decimal-based floating point structure. a real floating point would at least have signed exponent typedef struct { @@ -70,4 +70,7 @@ void scan_char(uint8_t c); // when we have a whole line, feed it to this void process_gcode_command(GCODE_COMMAND *gcmd); +// uses the global variable next_target.N +void request_resend(); + #endif /* _GCODE_H */