Skip to content

Commit

Permalink
Add fix for UltiGcode comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
FormerLurker committed Feb 6, 2021
1 parent fc7b9f2 commit 41e7170
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions octoprint_arc_welder/data/lib/c/arc_welder/arc_welder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,31 @@ arc_welder_results results;
p_logger_->log(logger_type_, DEBUG, "Target file opened successfully.");
std::string line;
int lines_with_no_commands = 0;
//gcodeFile.sync_with_stdio(false);
//output_file_.sync_with_stdio(false);

add_arcwelder_comment_to_target();

parsed_command cmd;
// Communicate every second
p_logger_->log(logger_type_, DEBUG, "Sending initial progress update.");
continue_processing = on_progress_(get_progress_(static_cast<long>(gcodeFile.tellg()), static_cast<double>(start_clock)));
p_logger_->log(logger_type_, DEBUG, "Processing source file.");

while (std::getline(gcodeFile, line) && continue_processing)
{
lines_processed_++;

// Check the first line of gcode and see if it = ;FLAVOR:UltiGCode
// This comment MUST be preserved as the first line for ultimakers, else things won't work
if (lines_processed_ == 1)
{
bool isUltiGCode = line == ";FLAVOR:UltiGCode";
if (isUltiGCode)
{
write_gcode_to_file(line);
}
add_arcwelder_comment_to_target();
if (isUltiGCode)
{
lines_with_no_commands++;
continue;
}
}
cmd.clear();
if (verbose_logging_enabled_)
{
Expand Down Expand Up @@ -306,7 +317,7 @@ arc_welder_results results;

if (current_arc_.is_shape() && waiting_for_arc_)
{
p_logger_->log(logger_type_, DEBUG, "The target file opened successfully.");
p_logger_->log(logger_type_, DEBUG, "Processing the final line.");
process_gcode(cmd, true, false);
}
p_logger_->log(logger_type_, DEBUG, "Writing all unwritten gcodes to the target file.");
Expand Down

0 comments on commit 41e7170

Please sign in to comment.