Skip to content

Commit

Permalink
Merge pull request #45 from prusa3d/et_fixes
Browse files Browse the repository at this point in the history
Fixed bug in conversion from binary to ascii gcode letting 'G29 G' li…
  • Loading branch information
enricoturri1966 authored Jan 22, 2024
2 parents 7aaf717 + 20b79e6 commit 6f43cb0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/LibBGCode/binarize/meatpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void unbinarize(const std::vector<uint8_t>& src, std::string& dst)
// G2, G3
'I', 'J', 'R',
// G29
'P', 'W', 'H', 'C', 'A'
'G', 'P', 'W', 'H', 'C', 'A'
};
return std::find(parameters.begin(), parameters.end(), c) != parameters.end();
};
Expand All @@ -395,12 +395,15 @@ void unbinarize(const std::vector<uint8_t>& src, std::string& dst)
// GCodeReader::parse_line_internal() is unable to parse a G line where the data are not separated by spaces
// so we add them where needed
const size_t curr_unbin_buffer_length = std::distance(unbin_buffer.begin(), it_unbin_end);
if (c_unbin[i] == 'G' && (curr_unbin_buffer_length == 0 || *std::prev(it_unbin_end, 1) == '\n'))
bool new_line = false;
if (c_unbin[i] == 'G' && (curr_unbin_buffer_length == 0 || *std::prev(it_unbin_end, 1) == '\n')) {
add_space = true;
new_line = true;
}
else if (c_unbin[i] == '\n')
add_space = false;

if (add_space && (curr_unbin_buffer_length == 0 || *std::prev(it_unbin_end, 1) != ' ') &&
if (!new_line && add_space && (curr_unbin_buffer_length == 0 || *std::prev(it_unbin_end, 1) != ' ') &&
is_gline_parameter(c_unbin[i])) {
*it_unbin_end = ' ';
++it_unbin_end;
Expand Down

0 comments on commit 6f43cb0

Please sign in to comment.