From eff4939bf54d11eac7a01dd3aca605f9c0a02c2f Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Mon, 6 Feb 2017 15:20:20 -0600 Subject: [PATCH 1/6] Improve handling of too-long lines, and up minimum buffers to 512bytes. Fixes #206 --- g2core/config.cpp | 3 +- g2core/config.h | 2 +- g2core/controller.h | 5 +- g2core/error.h | 3 - g2core/gcode_parser.cpp | 38 ++++++------- g2core/main.cpp | 1 - g2core/planner.cpp | 2 +- g2core/report.cpp | 5 +- g2core/xio.cpp | 122 ++++++++++++++++++++-------------------- g2core/xio.h | 4 +- 10 files changed, 89 insertions(+), 96 deletions(-) diff --git a/g2core/config.cpp b/g2core/config.cpp index 9548d65e..3018968d 100644 --- a/g2core/config.cpp +++ b/g2core/config.cpp @@ -178,8 +178,7 @@ stat_t config_test_assertions() (BAD_MAGIC(nvl.magic_start)) || (BAD_MAGIC(nvl.magic_end)) || (BAD_MAGIC(nvStr.magic_start)) || - (BAD_MAGIC(nvStr.magic_end)) || - (global_string_buf[GLOBAL_STRING_LEN-1] != NUL)) { + (BAD_MAGIC(nvStr.magic_end))) { return(cm_panic(STAT_CONFIG_ASSERTION_FAILURE, "config_test_assertions()")); } return (STAT_OK); diff --git a/g2core/config.h b/g2core/config.h index 7f65852a..3100d707 100644 --- a/g2core/config.h +++ b/g2core/config.h @@ -177,7 +177,7 @@ typedef uint16_t index_t; // use this if there are > 255 indexed o #define NV_MESSAGE_LEN 128 // sufficient space to contain end-user messages // pre-allocated defines (take RAM permanently) -#define NV_SHARED_STRING_LEN 512 // shared string for string values +#define NV_SHARED_STRING_LEN 1024 // shared string for string values #define NV_BODY_LEN 40 // body elements - allow for 1 parent + N children #define NV_EXEC_LEN 10 // elements reserved for exec, which won't directly respond // (each body element takes about 30 bytes of RAM) diff --git a/g2core/controller.h b/g2core/controller.h index ad307f88..910e7822 100755 --- a/g2core/controller.h +++ b/g2core/controller.h @@ -28,9 +28,10 @@ #ifndef CONTROLLER_H_ONCE #define CONTROLLER_H_ONCE +#include "xio.h" + // see also: g2core.h MESSAGE_LEN and config.h NV_ lengths -#define SAVED_BUFFER_LEN 80 // saved buffer size (for reporting only) -#define MAXED_BUFFER_LEN 255 // same as streaming RX buffer size as a worst case +#define SAVED_BUFFER_LEN RX_BUFFER_SIZE // saved buffer size (for reporting only) #define OUTPUT_BUFFER_LEN 512 // text buffer size #define LED_NORMAL_BLINK_RATE 3000 // blink rate for normal operation (in ms) diff --git a/g2core/error.h b/g2core/error.h index 609c65ee..5ecf2cf4 100644 --- a/g2core/error.h +++ b/g2core/error.h @@ -53,9 +53,6 @@ typedef uint8_t stat_t; extern stat_t status_code; -#define GLOBAL_STRING_LEN 256 // allow sufficient space for JSON responses and message strings -extern char global_string_buf[]; - char *get_status_message(stat_t status); // ritorno is a handy way to provide exception returns diff --git a/g2core/gcode_parser.cpp b/g2core/gcode_parser.cpp index 674a7028..db1c3e32 100644 --- a/g2core/gcode_parser.cpp +++ b/g2core/gcode_parser.cpp @@ -2,8 +2,8 @@ * gcode_parser.cpp - rs274/ngc Gcode parser * This file is part of the g2core project * - * Copyright (c) 2010 - 2016 Alden S. Hart, Jr. - * Copyright (c) 2016 Rob Giseburt + * Copyright (c) 2010 - 2017 Alden S. Hart, Jr. + * Copyright (c) 2016 - 2017 Rob Giseburt * * This file ("the software") is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 as published by the @@ -107,7 +107,7 @@ stat_t gcode_parser(char *block) * - block_delete_flag is set true if block delete encountered, false otherwise */ -static char _normalize_scratch[RX_BUFFER_MIN_SIZE]; +char _normalize_scratch[RX_BUFFER_SIZE]; static void _normalize_gcode_block(char *str, char **active_comment, uint8_t *block_delete_flag) { @@ -359,7 +359,7 @@ static stat_t _get_next_gcode_word(char **pstr, char *letter, float *value) char *end; *value = strtof(*pstr, &end); if(end == *pstr) { - return(STAT_BAD_NUMBER_FORMAT); + return(STAT_BAD_NUMBER_FORMAT); } // more robust test then checking for value=0; *pstr = end; return (STAT_OK); // pointer points to next character after the word @@ -409,9 +409,9 @@ static stat_t _validate_gcode_block(char *active_comment) static stat_t _parse_gcode_block(char *buf, char *active_comment) { - char *pstr = (char *)buf; // persistent pointer into gcode block for parsing words - char letter; // parsed letter, eg.g. G or X or Y - float value = 0; // value parsed from letter (e.g. 2 for G2) + char *pstr = (char *)buf; // persistent pointer into gcode block for parsing words + char letter; // parsed letter, eg.g. G or X or Y + float value = 0; // value parsed from letter (e.g. 2 for G2) stat_t status = STAT_OK; // set initial state for new move @@ -574,7 +574,7 @@ static stat_t _parse_gcode_block(char *buf, char *active_comment) case 'K': SET_NON_MODAL (arc_offset[2], value); case 'L': SET_NON_MODAL (L_word, value); case 'R': SET_NON_MODAL (arc_radius, value); - case 'N': SET_NON_MODAL (linenum,(uint32_t)value); // line number + case 'N': SET_NON_MODAL (linenum,(uint32_t)value); // line number default: status = STAT_GCODE_COMMAND_UNSUPPORTED; } if(status != STAT_OK) break; @@ -660,15 +660,15 @@ static stat_t _execute_gcode_block(char *active_comment) switch (cm.gn.next_action) { // Tool length offsets case NEXT_ACTION_SET_TL_OFFSET: { // G43 ritorno(cm_set_tl_offset(cm.gn.H_word, false)); - break; + break; } case NEXT_ACTION_SET_ADDITIONAL_TL_OFFSET: { // G43.2 ritorno(cm_set_tl_offset(cm.gn.H_word, true)); - break; + break; } case NEXT_ACTION_CANCEL_TL_OFFSET: { // G49 - ritorno(cm_cancel_tl_offset()); - break; + ritorno(cm_cancel_tl_offset()); + break; } } @@ -681,9 +681,9 @@ static stat_t _execute_gcode_block(char *active_comment) //--> set retract mode goes here switch (cm.gn.next_action) { - case NEXT_ACTION_SET_G28_POSITION: { status = cm_set_g28_position(); break;} // G28.1 + case NEXT_ACTION_SET_G28_POSITION: { status = cm_set_g28_position(); break;} // G28.1 case NEXT_ACTION_GOTO_G28_POSITION: { status = cm_goto_g28_position(cm.gn.target, cm.gf.target); break;} // G28 - case NEXT_ACTION_SET_G30_POSITION: { status = cm_set_g30_position(); break;} // G30.1 + case NEXT_ACTION_SET_G30_POSITION: { status = cm_set_g30_position(); break;} // G30.1 case NEXT_ACTION_GOTO_G30_POSITION: { status = cm_goto_g30_position(cm.gn.target, cm.gf.target); break;} // G30 case NEXT_ACTION_SEARCH_HOME: { status = cm_homing_cycle_start(); break;} // G28.2 @@ -697,12 +697,12 @@ static stat_t _execute_gcode_block(char *active_comment) case NEXT_ACTION_SET_G10_DATA: { status = cm_set_g10_data(cm.gn.parameter, cm.gn.L_word, cm.gn.target, cm.gf.target); break;} case NEXT_ACTION_SET_ORIGIN_OFFSETS: { status = cm_set_origin_offsets(cm.gn.target, cm.gf.target); break;}// G92 - case NEXT_ACTION_RESET_ORIGIN_OFFSETS: { status = cm_reset_origin_offsets(); break;} // G92.1 - case NEXT_ACTION_SUSPEND_ORIGIN_OFFSETS: { status = cm_suspend_origin_offsets(); break;} // G92.2 - case NEXT_ACTION_RESUME_ORIGIN_OFFSETS: { status = cm_resume_origin_offsets(); break;} // G92.3 + case NEXT_ACTION_RESET_ORIGIN_OFFSETS: { status = cm_reset_origin_offsets(); break;} // G92.1 + case NEXT_ACTION_SUSPEND_ORIGIN_OFFSETS: { status = cm_suspend_origin_offsets(); break;} // G92.2 + case NEXT_ACTION_RESUME_ORIGIN_OFFSETS: { status = cm_resume_origin_offsets(); break;} // G92.3 case NEXT_ACTION_JSON_COMMAND_SYNC: { status = cm_json_command(active_comment); break;} // M100 - case NEXT_ACTION_JSON_WAIT: { status = cm_json_wait(active_comment); break;} // M101 + case NEXT_ACTION_JSON_WAIT: { status = cm_json_wait(active_comment); break;} // M101 // case NEXT_ACTION_JSON_COMMAND_IMMEDIATE: { status = mp_json_command_immediate(active_comment); break;} // M102 case NEXT_ACTION_DEFAULT: { @@ -711,7 +711,7 @@ static stat_t _execute_gcode_block(char *active_comment) case MOTION_MODE_CANCEL_MOTION_MODE: { cm.gm.motion_mode = cm.gn.motion_mode; break;} // G80 case MOTION_MODE_STRAIGHT_TRAVERSE: { status = cm_straight_traverse(cm.gn.target, cm.gf.target); break;} // G0 case MOTION_MODE_STRAIGHT_FEED: { status = cm_straight_feed(cm.gn.target, cm.gf.target); break;} // G1 - case MOTION_MODE_CW_ARC: // G2 + case MOTION_MODE_CW_ARC: // G2 case MOTION_MODE_CCW_ARC: { status = cm_arc_feed(cm.gn.target, cm.gf.target, // G3 cm.gn.arc_offset, cm.gf.arc_offset, cm.gn.arc_radius, cm.gf.arc_radius, diff --git a/g2core/main.cpp b/g2core/main.cpp index 625d38e5..7667e6a4 100644 --- a/g2core/main.cpp +++ b/g2core/main.cpp @@ -49,7 +49,6 @@ /******************** System Globals *************************/ stat_t status_code; // allocate a variable for the ritorno macro -char global_string_buf[GLOBAL_STRING_LEN]; // allocate a string for global message use /************* System Globals For Diagnostics ****************/ diff --git a/g2core/planner.cpp b/g2core/planner.cpp index 205ed8c0..f8dcd146 100644 --- a/g2core/planner.cpp +++ b/g2core/planner.cpp @@ -72,7 +72,7 @@ mpMotionRuntimeSingleton_t mr; // context for block runtime #define JSON_COMMAND_BUFFER_SIZE 3 struct json_command_buffer_t { - char buf[RX_BUFFER_MIN_SIZE]; + char buf[RX_BUFFER_SIZE]; json_command_buffer_t *pv; json_command_buffer_t *nx; }; diff --git a/g2core/report.cpp b/g2core/report.cpp index 829545e6..e31bbb86 100644 --- a/g2core/report.cpp +++ b/g2core/report.cpp @@ -59,9 +59,10 @@ stat_t rpt_exception(stat_t status, const char *msg) // you cannot send an exception report if the USB has not been set up. Causes a processor exception. if (cs.controller_state >= CONTROLLER_READY) { - sprintf(global_string_buf, "{\"er\":{\"fb\":%0.2f,\"st\":%d,\"msg\":\"%s - %s\"}}\n", + char buffer[128]; + sprintf(buffer, "{\"er\":{\"fb\":%0.2f,\"st\":%d,\"msg\":\"%s - %s\"}}\n", G2CORE_FIRMWARE_BUILD, status, get_status_message(status), msg); - xio_writeline(global_string_buf); + xio_writeline(buffer); } } return (status); // makes it possible to inline, e.g: return(rpt_exception(status)); diff --git a/g2core/xio.cpp b/g2core/xio.cpp index 57d94e9f..8068a421 100755 --- a/g2core/xio.cpp +++ b/g2core/xio.cpp @@ -50,6 +50,8 @@ using Motate::TXBuffer; #include "text_parser.h" #endif +// defines for assertions + /**** HIGH LEVEL EXPLANATION OF XIO **** * * The XIO subsystem serves three purposes: @@ -103,14 +105,6 @@ struct xioDeviceWrapperBase { // C++ base class for device primit devflags_t flags; // bitfield for device state flags (these are not) devflags_t next_flags; // bitfield for next-state transitions - // line reader functions -// uint16_t read_index; // index into line being read -// const uint16_t read_buf_size; // static variable set at init time -// char read_buf[USB_LINE_BUFFER_SIZE]; // buffer for reading lines - - // Internal use only: -// bool _ready_to_send; - // Checks against class flags variable: // bool canRead() { return caps & DEV_CAN_READ; } // bool canWrite() { return caps & DEV_CAN_WRITE; } @@ -411,7 +405,7 @@ extern xio_t xio; // LineRXBuffer takes the Motate RXBuffer (which handles "transfers", usually DMA), and adds G2 line-reading // semantics to it. -template +template struct LineRXBuffer : RXBuffer<_size, owner_type, char> { typedef RXBuffer<_size, owner_type, char> parent_type; @@ -429,7 +423,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { // START OF LineRXBuffer PROPER static_assert(((_header_count-1)&_header_count)==0, "_header_count must be 2^N"); - char _line_buffer[_line_buffer_size]; // hold exactly one line to return + char _line_buffer[_line_buffer_size+1]; // hold exactly one line to return uint32_t _line_end_guard = 0xBEEF; // General term usage: @@ -437,7 +431,9 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { // * "offset" means it's a character in the _data array uint16_t _scan_offset; // offset into data of the last character scanned - uint16_t _line_start_offset; // offset into first character of the line + uint16_t _line_start_offset; // offset into first character of the line, or the first char to ignore (too-long lines) + uint16_t _last_line_length; // used for ensuring lines aren't too long + bool _ignore_until_next_line; // if we get a too-long-line, we ignore the rest by setting this flag bool _at_start_of_line; // true if the last character scanned was the end of a line uint16_t _lines_found; // count of complete non-control lines that were found during scanning. @@ -611,13 +607,30 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { // Look for line endings if (c == '\r' || c == '\n') { - if (!_at_start_of_line) { // We only mark ends_line for the first end-line char, and if + if (_ignore_until_next_line) { + // we finally ended the line we were ignoring + // add a skip section to jump over the overage + _skip_sections.addSkip(_line_start_offset, _scan_offset); + // move the start of the next skip section to after this skip + _line_start_offset = _scan_offset; + + // we DON'T want to end it normally (by counting a line) + _at_start_of_line = true; + _ignore_until_next_line = false; + + _last_line_length = 0; + } + else if (!_at_start_of_line) { // We only mark ends_line for the first end-line char, and if ends_line = true; // _at_start_of_line is already true, this is not the first. } } + // prevent going furnther if we are ignoring + else if (_ignore_until_next_line) + { + // don't do anything + } // Classify the line if it's a single character - else - if (_at_start_of_line && + else if (_at_start_of_line && ((c == '!') || (c == '~') || (c == ENQ) || // request ENQ/ack @@ -637,12 +650,14 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { if (_at_start_of_line) { // This is the first character at the beginning of the line. _line_start_offset = _scan_offset; + _last_line_length = 0; } _at_start_of_line = false; } // bump the _scan_offset _scan_offset = _getNextScanOffset(); + _last_line_length++; if (ends_line) { // _scan_offset is now one past the end of the line, @@ -650,7 +665,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { _at_start_of_line = true; // Here we classify the line. - // If we are is_control is already true, it's an already classified + // If is_control is already true, it's an already classified // single-character command. if (!is_control) { // TODO --- Call a function to do this @@ -676,7 +691,25 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { _lines_found++; } } // if ends_line + else if (_last_line_length == (_line_buffer_size - 1)) { + // force an end-of-line, splitting this line into two lines + _ignore_until_next_line = true; + _line_start_offset = _scan_offset; + _lines_found++; + } } //while (_isMoreToScan()) + + // special edge case: we ran out of items to scan (buffer full?), but we're ignoring because a line was too long + // example: we get a line that it multiple-times the length of the buffer + // so we'll dump skip sections to the readline will move the read pointer forward + if (_ignore_until_next_line && (_line_start_offset != _scan_offset)) { + // add a skip section to jump over the overage + _skip_sections.addSkip(_line_start_offset, _scan_offset); + // move the start of the next skip section to after this skip + _line_start_offset = _scan_offset; + } + + return false; // no control was found }; @@ -725,11 +758,8 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { } } - while ((_scan_offset != _line_start_offset) && - (line_size < (_line_buffer_size - 2))) { -// if (!_canBeRead(read_offset)) { // This test should NEVER fail. -// _debug_trap("readline hit unreadable and shouldn't have!"); -// } + // note that if it's marked as a control, it's guaranteed to fit in the line buffer + while (_scan_offset != _line_start_offset) { // copy the charater to _line_buffer char c = _data[_line_start_offset]; @@ -749,38 +779,6 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { if (ctrl_is_at_beginning_of_data) { _read_offset = _scan_offset; } -// else { -// // special case: if the return value is '%' -// // then we actually consider everything before it to be read -// -// if ('%' == _line_buffer[0]) { -// // Things that must be managed here: -// // * _read_offset -- we're skipping data -// // * _lines_found -- we shouldn't have any lines "left" -// // * _skip_sections -- there's nothing to skip, we just did -// -// // Things that won't be changed (further): -// // * _scan_offset -- we're not changing past where it's scanned -// // * _line_start_offset -- we've already adjusted it -// // * _at_start_of_line -- should always be true when we're here -// -// // move the read buffer up to where we're scanning -// _read_offset = _scan_offset; -// -// // record that we have 0 lines (of data) in the buffer -// _lines_found = 0; -// -// // and clear out any skip sections we have -// while (!_skip_sections.isEmpty()) { -// _skip_sections.popSkip(); -// } -// } -// } - -// if (ctrl_is_at_beginning_of_data) { -// // attempt to request more data -// _restartTransfer(); -// } return _line_buffer; } // end if (found_control) @@ -790,13 +788,16 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { return nullptr; } + // skip sections will always start at the beginning of a line + // handle this, even with no line, in case we're ignoring a huge too-long line + _skip_sections.skip(_read_offset); + if (_lines_found == 0) { // nothing to return line_size = 0; return nullptr; } - // By the time we get here, we know we have at least one line in _data. @@ -804,9 +805,6 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { _debug_trap("read ran into NULL"); } - // skip sections will always start at the beginning of a line - _skip_sections.skip(_read_offset); - // scan past any leftover CR or LF from the previous line char c = _data[_read_offset]; while ((c == '\n') || (c == '\r')) { @@ -819,11 +817,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { c = _data[_read_offset]; } - while (line_size < (_line_buffer_size - 2)) { -// if (!_canBeRead(read_offset)) { // This test should NEVER fail. -// _debug_trap("readline hit unreadable and shouldn't have!"); -// } - + while (line_size < (_line_buffer_size - 1)) { _read_offset = (_read_offset+1)&(_size-1); if ( c == '\r' || @@ -841,6 +835,10 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { c = _data[_read_offset]; } + if (line_size == (_line_buffer_size - 1)) { + // add a line-ending + *dst_ptr++ = '\n'; + } --_lines_found; @@ -1091,7 +1089,7 @@ struct xioDeviceWrapper : xioDeviceWrapperBase { // describes a device for re // Specialization for xio_flash_file -- we don't need most of the structure around a Device for xio_flash_file -template +template struct xioFlashFileDeviceWrapper : xioDeviceWrapperBase { // describes a device for reading and writing xio_flash_file *_current_file = nullptr; diff --git a/g2core/xio.h b/g2core/xio.h index c6c5c265..ec04b668 100755 --- a/g2core/xio.h +++ b/g2core/xio.h @@ -60,8 +60,6 @@ #undef _FDEV_EOF #define _FDEV_EOF -2 -#define USB_LINE_BUFFER_SIZE 255 // text buffer size - //*** Device flags *** typedef uint16_t devflags_t; // might need to bump to 32 be 16 or 32 @@ -110,7 +108,7 @@ enum xioSPIMode { /**** readline stuff *****/ -#define RX_BUFFER_MIN_SIZE 256 // minimum requested buffer size (they are usually larger) +#define RX_BUFFER_SIZE 512 // maximum length of recieved lines from xio_readline /**** function prototypes ****/ From d63c93c75885b22ce7c485649a22beb74b9ef03a Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Tue, 14 Feb 2017 10:33:51 -0600 Subject: [PATCH 2/6] Update Motate for new DEBUG switches --- Motate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Motate b/Motate index ba0db89b..beeece64 160000 --- a/Motate +++ b/Motate @@ -1 +1 @@ -Subproject commit ba0db89b35fd7ffbc7acd2c6ad1c7861e6fcb481 +Subproject commit beeece645780cd660462827142a32816e9d70583 From e65ef956e45bf0859fa706013b97a1751dc35d7b Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Tue, 14 Feb 2017 10:34:08 -0600 Subject: [PATCH 3/6] Added DEBUG=3 to enable Semihosting, while DEBUG=2 does not --- g2core/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/g2core/Makefile b/g2core/Makefile index fa453acb..e4928c15 100755 --- a/g2core/Makefile +++ b/g2core/Makefile @@ -58,5 +58,8 @@ endif ifeq ($(DEBUG),2) DEVICE_DEFINES += DEBUG=1 IN_DEBUGGER=1 endif +ifeq ($(DEBUG),3) + DEVICE_DEFINES += DEBUG=1 IN_DEBUGGER=1 DEBUG_SEMIHOSTING=1 +endif # *** EOF *** From 47495ffdbabfd2919ab650096491deae4c95d889 Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Tue, 14 Feb 2017 15:03:07 -0600 Subject: [PATCH 4/6] New Motate reference for Sam3x USB changes --- Motate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Motate b/Motate index beeece64..3f3be794 160000 --- a/Motate +++ b/Motate @@ -1 +1 @@ -Subproject commit beeece645780cd660462827142a32816e9d70583 +Subproject commit 3f3be7947d889bc4432b775c985cb3b4cd82ed50 From 838166d1e9785494ff7f75bb57a619679e1ad9b9 Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Tue, 14 Feb 2017 15:04:45 -0600 Subject: [PATCH 5/6] Minor adjustments to exec and stepper to handle a rare stall condition. --- g2core/plan_exec.cpp | 2 +- g2core/stepper.cpp | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/g2core/plan_exec.cpp b/g2core/plan_exec.cpp index 3aab7b92..719308b5 100644 --- a/g2core/plan_exec.cpp +++ b/g2core/plan_exec.cpp @@ -274,7 +274,7 @@ stat_t mp_exec_move() if (bf->buffer_state == MP_BUFFER_PREPPED) { if (cm.motion_state == MOTION_RUN) { #if IN_DEBUGGER == 1 - __asm__("BKPT"); // we are running but don't have a block planned +// __asm__("BKPT"); // we are running but don't have a block planned #endif } // We need to have it planned. We don't want to do this here, as it diff --git a/g2core/stepper.cpp b/g2core/stepper.cpp index 05969b50..40b40557 100644 --- a/g2core/stepper.cpp +++ b/g2core/stepper.cpp @@ -349,10 +349,7 @@ void dda_timer_type::interrupt() void st_request_exec_move() { stepper_debug("e"); - if (st_pre.buffer_state == PREP_BUFFER_OWNED_BY_EXEC) { // bother interrupting - exec_timer.setInterruptPending(); - return; - } + exec_timer.setInterruptPending(); stepper_debug("!\n"); } @@ -438,7 +435,16 @@ static void _load_move() return; // exit if the runtime is busy } if (st_pre.buffer_state != PREP_BUFFER_OWNED_BY_LOADER) { // if there are no moves to load... - + + if (cm.motion_state == MOTION_RUN) { +#if IN_DEBUGGER == 1 +//#warning debbugger REQUIRED for running this firmware! +// __asm__("BKPT"); // attempted to _load_move with PREP_BUFFER_OWNED_BY_EXEC and cm.motion_state == MOTION_RUN +#endif + st_request_exec_move(); + return; + } + // ...start motor power timeouts // for (uint8_t motor = MOTOR_1; motor < MOTORS; motor++) { // Motors[motor]->motionStopped(); @@ -659,8 +665,8 @@ stat_t st_prep_line(float travel_steps[], float following_error[], float segment return (cm_panic(STAT_PREP_LINE_MOVE_TIME_IS_INFINITE, "st_prep_line()")); } else if (isnan(segment_time)) { // never supposed to happen return (cm_panic(STAT_PREP_LINE_MOVE_TIME_IS_NAN, "st_prep_line()")); - } else if (segment_time < EPSILON) { - return (STAT_MINIMUM_TIME_MOVE); +// } else if (segment_time < EPSILON) { +// return (STAT_MINIMUM_TIME_MOVE); } // setup segment parameters // - dda_ticks is the integer number of DDA clock ticks needed to play out the segment From 660eedafa3cded7bfd866c9cfb75e844e4658981 Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Thu, 16 Feb 2017 12:05:26 -0600 Subject: [PATCH 6/6] New Motate reference to fix warnings about missing IN_DEBUGGER --- Motate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Motate b/Motate index 3f3be794..c1ffc728 160000 --- a/Motate +++ b/Motate @@ -1 +1 @@ -Subproject commit 3f3be7947d889bc4432b775c985cb3b4cd82ed50 +Subproject commit c1ffc728bd23bc224e371af22c3aa7dad10fec94