Merge pull request #9326 from thinkyhead/bf1_fix_parser_M118
[1.1.x] Fix parser.has_value, M118 parameters
This commit is contained in:
commit
d60e5c89d8
@ -8590,8 +8590,8 @@ inline void gcode_M117() { lcd_setstatus(parser.string_arg); }
|
|||||||
* E1 Have the host 'echo:' the text
|
* E1 Have the host 'echo:' the text
|
||||||
*/
|
*/
|
||||||
inline void gcode_M118() {
|
inline void gcode_M118() {
|
||||||
if (parser.boolval('E')) SERIAL_ECHO_START();
|
if (parser.seenval('E') && parser.value_bool()) SERIAL_ECHO_START();
|
||||||
if (parser.boolval('A')) SERIAL_ECHOPGM("// ");
|
if (parser.seenval('A') && parser.value_bool()) SERIAL_ECHOPGM("// ");
|
||||||
SERIAL_ECHOLN(parser.string_arg);
|
SERIAL_ECHOLN(parser.string_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9165,7 +9165,7 @@ inline void gcode_M226() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
SERIAL_ERRORLN("Bad i2c request");
|
SERIAL_ERRORLNPGM("Bad i2c request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9296,7 +9296,7 @@ inline void gcode_M226() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
SERIAL_ERRORLN(MSG_INVALID_EXTRUDER);
|
SERIAL_ERRORLNPGM(MSG_INVALID_EXTRUDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10786,10 +10786,10 @@ inline void gcode_M355() {
|
|||||||
// always report case light status
|
// always report case light status
|
||||||
SERIAL_ECHO_START();
|
SERIAL_ECHO_START();
|
||||||
if (!case_light_on) {
|
if (!case_light_on) {
|
||||||
SERIAL_ECHOLN("Case light: off");
|
SERIAL_ECHOLNPGM("Case light: off");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) SERIAL_ECHOLN("Case light: on");
|
if (!USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) SERIAL_ECHOLNPGM("Case light: on");
|
||||||
else SERIAL_ECHOLNPAIR("Case light: ", (int)case_light_brightness);
|
else SERIAL_ECHOLNPAIR("Case light: ", (int)case_light_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10912,7 +10912,7 @@ inline void invalid_extruder_error(const uint8_t e) {
|
|||||||
SERIAL_CHAR('T');
|
SERIAL_CHAR('T');
|
||||||
SERIAL_ECHO_F(e, DEC);
|
SERIAL_ECHO_F(e, DEC);
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
|
SERIAL_ECHOLNPGM(MSG_INVALID_EXTRUDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(PARKING_EXTRUDER)
|
#if ENABLED(PARKING_EXTRUDER)
|
||||||
|
@ -335,7 +335,7 @@ void CardReader::openFile(char* name, const bool read, const bool subcall/*=fals
|
|||||||
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
|
SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
|
||||||
SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
|
SERIAL_ERRORLN((int)SD_PROCEDURE_DEPTH);
|
||||||
kill(PSTR(MSG_KILLED));
|
kill(PSTR(MSG_KILLED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#define _FASTIO_ARDUINO_H
|
#define _FASTIO_ARDUINO_H
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include "macros.h"
|
|
||||||
|
|
||||||
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
|
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
|
||||||
#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
|
#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
|
||||||
@ -56,9 +55,7 @@
|
|||||||
#error "Pins for this chip not defined in Arduino.h! If you have a working pins definition, please contribute!"
|
#error "Pins for this chip not defined in Arduino.h! If you have a working pins definition, please contribute!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _BV
|
#include "macros.h"
|
||||||
#define _BV(PIN) (1UL << PIN)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic I/O routines
|
* Magic I/O routines
|
||||||
|
@ -53,7 +53,7 @@ int GCodeParser::codenum;
|
|||||||
|
|
||||||
#if ENABLED(FASTER_GCODE_PARSER)
|
#if ENABLED(FASTER_GCODE_PARSER)
|
||||||
// Optimized Parameters
|
// Optimized Parameters
|
||||||
byte GCodeParser::codebits[4]; // found bits
|
uint32_t GCodeParser::codebits; // found bits
|
||||||
uint8_t GCodeParser::param[26]; // parameter offsets from command_ptr
|
uint8_t GCodeParser::param[26]; // parameter offsets from command_ptr
|
||||||
#else
|
#else
|
||||||
char *GCodeParser::command_args; // start of parameters
|
char *GCodeParser::command_args; // start of parameters
|
||||||
@ -76,7 +76,7 @@ void GCodeParser::reset() {
|
|||||||
subcode = 0; // No command sub-code
|
subcode = 0; // No command sub-code
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(FASTER_GCODE_PARSER)
|
#if ENABLED(FASTER_GCODE_PARSER)
|
||||||
ZERO(codebits); // No codes yet
|
codebits = 0; // No codes yet
|
||||||
//ZERO(param); // No parameters (should be safe to comment out this line)
|
//ZERO(param); // No parameters (should be safe to comment out this line)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -189,14 +189,7 @@ void GCodeParser::parse(char *p) {
|
|||||||
|
|
||||||
while (*p == ' ') p++; // Skip spaces between parameters & values
|
while (*p == ' ') p++; // Skip spaces between parameters & values
|
||||||
|
|
||||||
const bool has_num = NUMERIC(p[0]) // [0-9]
|
const bool has_num = valid_float(p);
|
||||||
|| (p[0] == '.' && NUMERIC(p[1])) // .[0-9]
|
|
||||||
|| (
|
|
||||||
(p[0] == '-' || p[0] == '+') && ( // [-+]
|
|
||||||
NUMERIC(p[1]) // [0-9]
|
|
||||||
|| (p[1] == '.' && NUMERIC(p[2])) // .[0-9]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
#if ENABLED(DEBUG_GCODE_PARSER)
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -218,13 +211,7 @@ void GCodeParser::parse(char *p) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(FASTER_GCODE_PARSER)
|
#if ENABLED(FASTER_GCODE_PARSER)
|
||||||
{
|
set(code, has_num ? p : NULL); // Set parameter exists and pointer (NULL for no number)
|
||||||
set(code, has_num ? p : NULL // Set parameter exists and pointer (NULL for no number)
|
|
||||||
#if ENABLED(DEBUG_GCODE_PARSER)
|
|
||||||
, debug
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (!string_arg) { // Not A-Z? First time, keep as the string_arg
|
else if (!string_arg) { // Not A-Z? First time, keep as the string_arg
|
||||||
@ -276,7 +263,7 @@ void GCodeParser::unknown_command_error() {
|
|||||||
SERIAL_ECHO(codenum);
|
SERIAL_ECHO(codenum);
|
||||||
SERIAL_ECHOLNPGM(")");
|
SERIAL_ECHOLNPGM(")");
|
||||||
#if ENABLED(FASTER_GCODE_PARSER)
|
#if ENABLED(FASTER_GCODE_PARSER)
|
||||||
SERIAL_ECHO(" args: \"");
|
SERIAL_ECHOPGM(" args: \"");
|
||||||
for (char c = 'A'; c <= 'Z'; ++c)
|
for (char c = 'A'; c <= 'Z'; ++c)
|
||||||
if (seen(c)) { SERIAL_CHAR(c); SERIAL_CHAR(' '); }
|
if (seen(c)) { SERIAL_CHAR(c); SERIAL_CHAR(' '); }
|
||||||
#else
|
#else
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
static char *value_ptr; // Set by seen, used to fetch the value
|
static char *value_ptr; // Set by seen, used to fetch the value
|
||||||
|
|
||||||
#if ENABLED(FASTER_GCODE_PARSER)
|
#if ENABLED(FASTER_GCODE_PARSER)
|
||||||
static byte codebits[4]; // Parameters pre-scanned
|
static uint32_t codebits; // Parameters pre-scanned
|
||||||
static uint8_t param[26]; // For A-Z, offsets into command args
|
static uint8_t param[26]; // For A-Z, offsets into command args
|
||||||
#else
|
#else
|
||||||
static char *command_args; // Args start here, for slow scan
|
static char *command_args; // Args start here, for slow scan
|
||||||
@ -99,30 +99,35 @@ public:
|
|||||||
// Reset is done before parsing
|
// Reset is done before parsing
|
||||||
static void reset();
|
static void reset();
|
||||||
|
|
||||||
// Index so that 'X' falls on index 24
|
#define LETTER_BIT(N) ((N) - 'A')
|
||||||
#define PARAM_IND(N) ((N) >> 3)
|
|
||||||
#define PARAM_BIT(N) ((N) & 0x7)
|
|
||||||
#define LETTER_OFF(N) ((N) - 'A')
|
|
||||||
#define LETTER_IND(N) PARAM_IND(LETTER_OFF(N))
|
|
||||||
#define LETTER_BIT(N) PARAM_BIT(LETTER_OFF(N))
|
|
||||||
|
|
||||||
#if ENABLED(FASTER_GCODE_PARSER)
|
#if ENABLED(FASTER_GCODE_PARSER)
|
||||||
|
|
||||||
|
FORCE_INLINE static bool valid_signless(const char * const p) {
|
||||||
|
return NUMERIC(p[0]) || (p[0] == '.' && NUMERIC(p[1])); // .?[0-9]
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE static bool valid_float(const char * const p) {
|
||||||
|
return valid_signless(p) || ((p[0] == '-' || p[0] == '+') && valid_signless(&p[1])); // [-+]?.?[0-9]
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE static bool valid_int(const char * const p) {
|
||||||
|
return NUMERIC(p[0]) || ((p[0] == '-' || p[0] == '+') && NUMERIC(p[1])); // [-+]?[0-9]
|
||||||
|
}
|
||||||
|
|
||||||
// Set the flag and pointer for a parameter
|
// Set the flag and pointer for a parameter
|
||||||
static void set(const char c, char * const ptr
|
static void set(const char c, char * const ptr) {
|
||||||
#if ENABLED(DEBUG_GCODE_PARSER)
|
const uint8_t ind = LETTER_BIT(c);
|
||||||
, const bool debug=false
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
const uint8_t ind = LETTER_OFF(c);
|
|
||||||
if (ind >= COUNT(param)) return; // Only A-Z
|
if (ind >= COUNT(param)) return; // Only A-Z
|
||||||
SBI(codebits[PARAM_IND(ind)], PARAM_BIT(ind)); // parameter exists
|
SBI(codebits, ind); // parameter exists
|
||||||
param[ind] = ptr ? ptr - command_ptr : 0; // parameter offset or 0
|
param[ind] = ptr ? ptr - command_ptr : 0; // parameter offset or 0
|
||||||
#if ENABLED(DEBUG_GCODE_PARSER)
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
||||||
if (debug) {
|
if (codenum == 800) {
|
||||||
SERIAL_ECHOPAIR("Set bit ", (int)PARAM_BIT(ind));
|
const uint16_t * const adr = (uint16_t*)&codebits;
|
||||||
SERIAL_ECHOPAIR(" of index ", (int)PARAM_IND(ind));
|
SERIAL_ECHOPAIR("Set bit ", (int)ind);
|
||||||
SERIAL_ECHOLNPAIR(" | param = ", (int)param[ind]);
|
SERIAL_ECHOPAIR(" of codebits (", hex_address((void*)adr[1]));
|
||||||
|
print_hex_word(adr[0]);
|
||||||
|
SERIAL_ECHOLNPAIR(") | param = ", (int)param[ind]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -130,16 +135,24 @@ public:
|
|||||||
// Code seen bit was set. If not found, value_ptr is unchanged.
|
// Code seen bit was set. If not found, value_ptr is unchanged.
|
||||||
// This allows "if (seen('A')||seen('B'))" to use the last-found value.
|
// This allows "if (seen('A')||seen('B'))" to use the last-found value.
|
||||||
static bool seen(const char c) {
|
static bool seen(const char c) {
|
||||||
const uint8_t ind = LETTER_OFF(c);
|
const uint8_t ind = LETTER_BIT(c);
|
||||||
if (ind >= COUNT(param)) return false; // Only A-Z
|
if (ind >= COUNT(param)) return false; // Only A-Z
|
||||||
const bool b = TEST(codebits[PARAM_IND(ind)], PARAM_BIT(ind));
|
const bool b = TEST(codebits, ind);
|
||||||
if (b) value_ptr = param[ind] ? command_ptr + param[ind] : (char*)NULL;
|
if (b) {
|
||||||
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
||||||
|
if (codenum == 800) {
|
||||||
|
SERIAL_CHAR('\''); SERIAL_CHAR(c); SERIAL_ECHOLNPGM("' is seen");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
char * const ptr = command_ptr + param[ind];
|
||||||
|
value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL;
|
||||||
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool seen_any() { return codebits[3] || codebits[2] || codebits[1] || codebits[0]; }
|
static bool seen_any() { return !!codebits; }
|
||||||
|
|
||||||
#define SEEN_TEST(L) TEST(codebits[LETTER_IND(L)], LETTER_BIT(L))
|
#define SEEN_TEST(L) TEST(codebits, LETTER_BIT(L))
|
||||||
|
|
||||||
#else // !FASTER_GCODE_PARSER
|
#else // !FASTER_GCODE_PARSER
|
||||||
|
|
||||||
@ -148,7 +161,7 @@ public:
|
|||||||
static bool seen(const char c) {
|
static bool seen(const char c) {
|
||||||
const char *p = strchr(command_args, c);
|
const char *p = strchr(command_args, c);
|
||||||
const bool b = !!p;
|
const bool b = !!p;
|
||||||
if (b) value_ptr = DECIMAL_SIGNED(p[1]) ? &p[1] : (char*)NULL;
|
if (b) value_ptr = valid_float(&p[1]) ? &p[1] : (char*)NULL;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +225,7 @@ public:
|
|||||||
inline static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
|
inline static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
|
||||||
|
|
||||||
// Bool is true with no value or non-zero
|
// Bool is true with no value or non-zero
|
||||||
inline static bool value_bool() { return !has_value() || value_byte(); }
|
inline static bool value_bool() { return !has_value() || !!value_byte(); }
|
||||||
|
|
||||||
// Units modes: Inches, Fahrenheit, Kelvin
|
// Units modes: Inches, Fahrenheit, Kelvin
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@
|
|||||||
#define STRINGIFY(M) STRINGIFY_(M)
|
#define STRINGIFY(M) STRINGIFY_(M)
|
||||||
|
|
||||||
// Macros for bit masks
|
// Macros for bit masks
|
||||||
|
#undef _BV // Marlin needs 32-bit unsigned!
|
||||||
|
#define _BV(b) (1UL << (b))
|
||||||
#define TEST(n,b) (((n)&_BV(b))!=0)
|
#define TEST(n,b) (((n)&_BV(b))!=0)
|
||||||
#define SBI(n,b) (n |= _BV(b))
|
#define SBI(n,b) (n |= _BV(b))
|
||||||
#define CBI(n,b) (n &= ~_BV(b))
|
#define CBI(n,b) (n &= ~_BV(b))
|
||||||
|
@ -114,7 +114,7 @@
|
|||||||
SERIAL_ECHOPAIR(" (", dac_amps(Z_AXIS));
|
SERIAL_ECHOPAIR(" (", dac_amps(Z_AXIS));
|
||||||
SERIAL_ECHOPAIR(") E:", dac_perc(E_AXIS));
|
SERIAL_ECHOPAIR(") E:", dac_perc(E_AXIS));
|
||||||
SERIAL_ECHOPAIR(" (", dac_amps(E_AXIS));
|
SERIAL_ECHOPAIR(" (", dac_amps(E_AXIS));
|
||||||
SERIAL_ECHOLN(")");
|
SERIAL_ECHOLNPGM(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
void dac_commit_eeprom() {
|
void dac_commit_eeprom() {
|
||||||
|
@ -264,11 +264,11 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!WITHIN(hotend, _BOT_HOTEND, _TOP_HOTEND)) {
|
if (!WITHIN(hotend, _BOT_HOTEND, _TOP_HOTEND)) {
|
||||||
SERIAL_ECHOLN(MSG_PID_BAD_EXTRUDER_NUM);
|
SERIAL_ECHOLNPGM(MSG_PID_BAD_EXTRUDER_NUM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SERIAL_ECHOLN(MSG_PID_AUTOTUNE_START);
|
SERIAL_ECHOLNPGM(MSG_PID_AUTOTUNE_START);
|
||||||
|
|
||||||
disable_all_heaters(); // switch off all heaters.
|
disable_all_heaters(); // switch off all heaters.
|
||||||
|
|
||||||
|
@ -1220,7 +1220,7 @@
|
|||||||
SERIAL_PROTOCOLLNPAIR("UBL object count: ", (int)ubl_cnt);
|
SERIAL_PROTOCOLLNPAIR("UBL object count: ", (int)ubl_cnt);
|
||||||
|
|
||||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||||
SERIAL_PROTOCOL("planner.z_fade_height : ");
|
SERIAL_PROTOCOLPGM("planner.z_fade_height : ");
|
||||||
SERIAL_PROTOCOL_F(planner.z_fade_height, 4);
|
SERIAL_PROTOCOL_F(planner.z_fade_height, 4);
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user