Make N 0-based

This commit is contained in:
Alessandro Ranellucci 2017-03-26 04:18:06 +02:00
parent 2fc8152e24
commit 5f30ab2f0d

View File

@ -355,6 +355,7 @@ GCodeSender::on_read(const boost::system::error_code& error,
// extract the first number from line
boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
toresend++; // N is 0-based
if (toresend >= this->sent - this->last_sent.size()) {
{
boost::lock_guard<boost::mutex> l(this->queue_mutex);
@ -473,8 +474,8 @@ GCodeSender::do_send()
if (line.empty()) return;
// compute full line
this->sent++;
std::string full_line = "N" + boost::lexical_cast<std::string>(this->sent) + " " + line;
this->sent++;
// calculate checksum
int cs = 0;