Skip to content

Commit

Permalink
Merge pull request #1335 from bdring/dymk/flow-control-repeat
Browse files Browse the repository at this point in the history
Fix repeat of 0, O commands with larger integer values
  • Loading branch information
dymk authored Sep 26, 2024
2 parents 83787c3 + 3f6f098 commit 561006c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion FluidNC/src/Flowcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Error flowcontrol(uint32_t o_label, char* line, size_t& pos, bool& skip) {
case Op_EndRepeat:
if (Job::active()) {
if (last_op == Op_Repeat) {
if (!skipping && o_label == context.top().o_label) {
if (o_label == context.top().o_label) {
if (context.top().repeats && --context.top().repeats) {
context.top().file->set_position(context.top().file_pos);
} else {
Expand Down
8 changes: 3 additions & 5 deletions FluidNC/src/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ Error gc_execute_line(char* line) {
size_t pos;
char letter;
float value;
uint8_t int_value = 0;
uint16_t mantissa = 0;
int32_t int_value = 0;
int32_t mantissa = 0;
pos = jogMotion ? 3 : 0; // Start parsing after `$J=` if jogging
while ((letter = line[pos]) != '\0') { // Loop until no more g-code words in line.
if (letter == '#') {
Expand Down Expand Up @@ -332,7 +332,7 @@ Error gc_execute_line(char* line) {
// a good enough compromise and catch most all non-integer errors. To make it compliant,
// we would simply need to change the mantissa to int16, but this add compiled flash space.
// Maybe update this later.
int_value = int8_t(truncf(value));
int_value = static_cast<int32_t>(truncf(value));
mantissa = lroundf(100 * (value - int_value)); // Compute mantissa for Gxx.x commands.
// NOTE: Rounding must be used to catch small floating point errors.
// Check if the g-code word is supported or errors due to modal group violations or has
Expand Down Expand Up @@ -766,7 +766,6 @@ Error gc_execute_line(char* line) {
case 'E':
axis_word_bit = GCodeWord::E;
gc_block.values.e = int_value;
//log_info("E " << gc_block.values.e);
break;
case 'F':
axis_word_bit = GCodeWord::F;
Expand Down Expand Up @@ -803,7 +802,6 @@ Error gc_execute_line(char* line) {
axis_word_bit = GCodeWord::O;
gc_block.values.o = int_value;
break;

case 'P':
axis_word_bit = GCodeWord::P;
gc_block.values.p = value;
Expand Down
7 changes: 7 additions & 0 deletions fixture_tests/fixtures/flow_control_large_values.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-> o1000 if [1]
-> (print, pass if)
-> o1000 else
-> (print, fail if)
-> o1000 endif
<- ok
<- [MSG:INFO: PRINT, pass if]

0 comments on commit 561006c

Please sign in to comment.