diff --git a/src/slic3r/Utils/MKS.cpp b/src/slic3r/Utils/MKS.cpp index 1a60c5a3e..97cdbfffa 100644 --- a/src/slic3r/Utils/MKS.cpp +++ b/src/slic3r/Utils/MKS.cpp @@ -32,13 +32,15 @@ namespace pt = boost::property_tree; namespace Slic3r { MKS::MKS(DynamicPrintConfig* config) : - host(config->opt_string("print_host")), console(config->opt_string("print_host"), "8080") + host(config->opt_string("print_host")), console_port("8080") {} const char* MKS::get_name() const { return "MKS"; } bool MKS::test(wxString& msg) const { + Utils::TCPConsole console(host, console_port); + console.enqueue_cmd("M105"); bool ret = console.run_queue(); @@ -131,6 +133,8 @@ namespace Slic3r { // TODO: Inspect reasons std::this_thread::sleep_for(std::chrono::milliseconds(1500)); + Utils::TCPConsole console(host, console_port); + console.enqueue_cmd(std::string("M23 ") + filename); console.enqueue_cmd("M24"); diff --git a/src/slic3r/Utils/MKS.hpp b/src/slic3r/Utils/MKS.hpp index 67c655293..6e0aad58b 100644 --- a/src/slic3r/Utils/MKS.hpp +++ b/src/slic3r/Utils/MKS.hpp @@ -8,7 +8,6 @@ #include "TCPConsole.hpp" namespace Slic3r { - class DynamicPrintConfig; class Http; @@ -31,7 +30,7 @@ namespace Slic3r { private: std::string host; - Utils::TCPConsole console; + std::string console_port; std::string get_upload_url(const std::string& filename) const; std::string timestamp_str() const; diff --git a/src/slic3r/Utils/TCPConsole.cpp b/src/slic3r/Utils/TCPConsole.cpp index bea991945..17a37ef7c 100644 --- a/src/slic3r/Utils/TCPConsole.cpp +++ b/src/slic3r/Utils/TCPConsole.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include "TCPConsole.hpp" using boost::asio::steady_timer; using boost::asio::ip::tcp; @@ -20,6 +20,18 @@ using boost::asio::ip::tcp; namespace Slic3r { namespace Utils { + const char* default_newline = "\n"; + const char* default_done_string = "ok"; + + TCPConsole::TCPConsole() : resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string) {} + + TCPConsole::TCPConsole(const std::string& host_name, const std::string& port_name) : + resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string) + { + set_remote(host_name, port_name); + } + + void TCPConsole::transmit_next_command() { if (cmd_queue_.empty()) { diff --git a/src/slic3r/Utils/TCPConsole.hpp b/src/slic3r/Utils/TCPConsole.hpp index aa3b7da6f..82d850299 100644 --- a/src/slic3r/Utils/TCPConsole.hpp +++ b/src/slic3r/Utils/TCPConsole.hpp @@ -10,21 +10,13 @@ namespace Slic3r { namespace Utils { - const char* default_newline = "\n"; - const char* default_done_string = "ok"; - using boost::asio::ip::tcp; class TCPConsole { public: - TCPConsole() : resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string) {} - - TCPConsole(const std::string& host_name, const std::string& port_name) : - resolver_(io_context_), socket_(io_context_), newline_(default_newline), done_string_(default_done_string) - { - set_remote(host_name, port_name); - } + TCPConsole(); + TCPConsole(const std::string& host_name, const std::string& port_name); ~TCPConsole() {} void set_line_delimiter(const std::string& newline) {