FirmwareDialog: UI improvements, bugfixes

This commit is contained in:
Vojtech Kral 2018-07-27 11:55:11 +02:00 committed by bubnikv
parent 14c9ff174d
commit b6d70f5fe8
7 changed files with 385 additions and 174 deletions

View file

@ -46,8 +46,7 @@ static size_t hex_num_sections(fs::ifstream &file)
}
HexFile::HexFile(fs::path path) :
path(std::move(path)),
device(DEV_GENERIC)
path(std::move(path))
{
fs::ifstream file(this->path);
if (! file.good()) {

View file

@ -19,9 +19,10 @@ struct HexFile
};
boost::filesystem::path path;
DeviceKind device;
DeviceKind device = DEV_GENERIC;
std::string model_id;
HexFile() {}
HexFile(boost::filesystem::path path);
};

View file

@ -373,7 +373,7 @@ void Serial::set_DTR(bool on)
void Serial::reset_line_num()
{
// See https://github.com/MarlinFirmware/Marlin/wiki/M110
printer_write_line("M110 N0", 0);
write_string("M110 N0\n");
m_line_num = 0;
}
@ -390,9 +390,9 @@ bool Serial::read_line(unsigned timeout, std::string &line, error_code &ec)
asio::async_read(*this, boost::asio::buffer(&c, 1), [&](const error_code &read_ec, size_t size) {
if (ec || size == 0) {
fail = true;
ec = read_ec;
ec = read_ec; // FIXME: only if operation not aborted
}
timer.cancel();
timer.cancel(); // FIXME: ditto
});
if (timeout > 0) {
@ -444,6 +444,7 @@ bool Serial::printer_ready_wait(unsigned retries, unsigned timeout)
}
line.clear();
}
line.clear();
}
@ -469,7 +470,7 @@ void Serial::printer_reset()
this->set_DTR(true);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
this->set_DTR(false);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
std::string Serial::printer_format_line(const std::string &line, unsigned line_num)

View file

@ -51,12 +51,13 @@ public:
// Reads a line or times out, the timeout is in milliseconds
bool read_line(unsigned timeout, std::string &line, boost::system::error_code &ec);
// Perform setup for communicating with a printer
// Perform an initial setup for communicating with a printer
void printer_setup();
// Write data from a string
size_t write_string(const std::string &str);
// Attempts to reset the line numer and waits until the printer says "ok"
bool printer_ready_wait(unsigned retries, unsigned timeout);
// Write Marlin-formatted line, with a line number and a checksum