Skip to content

Commit

Permalink
Fixed bug in conversion from binary to ascii gcode letting 'G29 G' li…
Browse files Browse the repository at this point in the history
…nes be translated to 'G29G', missing the space
  • Loading branch information
enricoturri1966 committed Jan 22, 2024
1 parent 7aaf717 commit 20b79e6
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 20b79e6

Please sign in to comment.