mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 17:21:11 -06:00
Firmware updater: Add support for l10n firmware images
This commit is contained in:
parent
15f943938b
commit
635bb1e484
4 changed files with 156 additions and 78 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "avrdude-slic3r.hpp"
|
||||
|
||||
#include <deque>
|
||||
#include <thread>
|
||||
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +34,8 @@ static void avrdude_progress_handler_closure(const char *task, unsigned progress
|
|||
struct AvrDude::priv
|
||||
{
|
||||
std::string sys_config;
|
||||
std::vector<std::string> args;
|
||||
std::deque<std::vector<std::string>> args;
|
||||
size_t current_args_set = 0;
|
||||
RunFn run_fn;
|
||||
MessageFn message_fn;
|
||||
ProgressFn progress_fn;
|
||||
|
|
@ -41,10 +43,13 @@ struct AvrDude::priv
|
|||
|
||||
std::thread avrdude_thread;
|
||||
|
||||
priv(std::string &&sys_config) : sys_config(sys_config) {}
|
||||
|
||||
int run_one(const std::vector<std::string> &args);
|
||||
int run();
|
||||
};
|
||||
|
||||
int AvrDude::priv::run() {
|
||||
int AvrDude::priv::run_one(const std::vector<std::string> &args) {
|
||||
std::vector<char*> c_args {{ const_cast<char*>(PACKAGE_NAME) }};
|
||||
for (const auto &arg : args) {
|
||||
c_args.push_back(const_cast<char*>(arg.data()));
|
||||
|
|
@ -69,10 +74,22 @@ int AvrDude::priv::run() {
|
|||
return res;
|
||||
}
|
||||
|
||||
int AvrDude::priv::run() {
|
||||
for (; args.size() > 0; current_args_set++) {
|
||||
int res = run_one(args.front());
|
||||
args.pop_front();
|
||||
if (res != 0) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Public
|
||||
|
||||
AvrDude::AvrDude() : p(new priv()) {}
|
||||
AvrDude::AvrDude(std::string sys_config) : p(new priv(std::move(sys_config))) {}
|
||||
|
||||
AvrDude::AvrDude(AvrDude &&other) : p(std::move(other.p)) {}
|
||||
|
||||
|
|
@ -83,15 +100,9 @@ AvrDude::~AvrDude()
|
|||
}
|
||||
}
|
||||
|
||||
AvrDude& AvrDude::sys_config(std::string sys_config)
|
||||
AvrDude& AvrDude::push_args(std::vector<std::string> args)
|
||||
{
|
||||
if (p) { p->sys_config = std::move(sys_config); }
|
||||
return *this;
|
||||
}
|
||||
|
||||
AvrDude& AvrDude::args(std::vector<std::string> args)
|
||||
{
|
||||
if (p) { p->args = std::move(args); }
|
||||
if (p) { p->args.push_back(std::move(args)); }
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +148,7 @@ AvrDude::Ptr AvrDude::run()
|
|||
auto res = self->p->run();
|
||||
|
||||
if (self->p->complete_fn) {
|
||||
self->p->complete_fn(res);
|
||||
self->p->complete_fn(res, self->p->current_args_set);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue