mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Make GCodeSender more robust (keep more than one sent line) and fix a memory access problem in the asio write buffer
This commit is contained in:
parent
ff0a947364
commit
d5ff69b1aa
2 changed files with 66 additions and 30 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue