Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repeat of 0, O commands with larger integer values #1335

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -288,8 +288,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 @@ -327,7 +327,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 @@ -757,7 +757,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 @@ -794,7 +793,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]
Loading