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

Fixed bug in conversion from binary to ascii gcode letting 'G29 G' li… #45

Merged
merged 1 commit into from
Jan 22, 2024
Merged
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
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