Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2016-03-13 20:27:02 +0300
committerAlessandro Ranellucci <aar@cpan.org>2016-03-13 20:27:02 +0300
commitd5ff69b1aadcefa7114cef8b9f95bfb9e2047b49 (patch)
tree6c2457d9e854ba03572a0a757488f74c2ce3fc0b /xs/src/libslic3r/GCodeSender.hpp
parentff0a9473643a9d0467e16343730115a1fe9d02de (diff)
Make GCodeSender more robust (keep more than one sent line) and fix a memory access problem in the asio write buffer
Diffstat (limited to 'xs/src/libslic3r/GCodeSender.hpp')
-rw-r--r--xs/src/libslic3r/GCodeSender.hpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/xs/src/libslic3r/GCodeSender.hpp b/xs/src/libslic3r/GCodeSender.hpp
index 384d417cc..cc0b29832 100644
--- a/xs/src/libslic3r/GCodeSender.hpp
+++ b/xs/src/libslic3r/GCodeSender.hpp
@@ -39,7 +39,7 @@ class GCodeSender : private boost::noncopyable {
asio::io_service io;
asio::serial_port serial;
boost::thread background_thread;
- boost::asio::streambuf read_buffer;
+ boost::asio::streambuf read_buffer, write_buffer;
bool open; // whether the serial socket is connected
bool connected; // whether the printer is online
bool error;
@@ -47,11 +47,12 @@ class GCodeSender : private boost::noncopyable {
// this mutex guards queue, priqueue, can_send, queue_paused, sent, last_sent
mutable boost::mutex queue_mutex;
- std::queue<std::string> queue, priqueue;
+ std::queue<std::string> queue;
+ std::list<std::string> priqueue;
bool can_send;
bool queue_paused;
size_t sent;
- std::string last_sent;
+ std::vector<std::string> last_sent;
// this mutex guards log, T, B
mutable boost::mutex log_mutex;
@@ -61,7 +62,7 @@ class GCodeSender : private boost::noncopyable {
void set_baud_rate(unsigned int baud_rate);
void set_error_status(bool e);
void do_send();
- void do_send(const std::string &line);
+ void on_write(const boost::system::error_code& error, size_t bytes_transferred);
void do_close();
void do_read();
void on_read(const boost::system::error_code& error, size_t bytes_transferred);