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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2015-12-26 13:49:19 +0300
committerAlessandro Ranellucci <aar@cpan.org>2015-12-26 13:50:20 +0300
commit83c91a3538661af2447eb0e90489ec55c4a4d52e (patch)
tree2354337351db27aad60c80cca8b3ef2a95a77b39 /xs/src/libslic3r/GCodeSender.cpp
parentf5326c393a588f122accc6b17bd587d330564b3a (diff)
Dump serial messages to file in order to debug communication issues
Diffstat (limited to 'xs/src/libslic3r/GCodeSender.cpp')
-rw-r--r--xs/src/libslic3r/GCodeSender.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/xs/src/libslic3r/GCodeSender.cpp b/xs/src/libslic3r/GCodeSender.cpp
index e284ef701..c9c3cf22d 100644
--- a/xs/src/libslic3r/GCodeSender.cpp
+++ b/xs/src/libslic3r/GCodeSender.cpp
@@ -19,6 +19,12 @@
#include <linux/serial.h>
#endif
+//#define DEBUG_SERIAL
+#ifdef DEBUG_SERIAL
+#include <fstream>
+std::fstream fs;
+#endif
+
namespace Slic3r {
namespace asio = boost::asio;
@@ -61,6 +67,11 @@ GCodeSender::connect(std::string devname, unsigned int baud_rate)
this->open = true;
this->reset();
+ /* Initialize debugger */
+#ifdef DEBUG_SERIAL
+ fs.open("serial.txt", std::fstream::out | std::fstream::trunc);
+#endif
+
// this gives some work to the io_service before it is started
// (post() runs the supplied function in its thread)
this->io.post(boost::bind(&GCodeSender::do_read, this));
@@ -131,6 +142,10 @@ GCodeSender::disconnect()
"Error while closing the device"));
}
*/
+
+#ifdef DEBUG_SERIAL
+ fs.close();
+#endif
}
bool
@@ -285,6 +300,10 @@ GCodeSender::on_read(const boost::system::error_code& error,
std::string line;
std::getline(is, line);
if (!line.empty()) {
+#ifdef DEBUG_SERIAL
+ fs << "<< " << line;
+#endif
+
// note that line might contain \r at its end
// parse incoming line
if (!this->connected
@@ -440,6 +459,10 @@ GCodeSender::do_send(const std::string &line)
this->last_sent = line;
this->can_send = false;
+
+#ifdef DEBUG_SERIAL
+ fs << ">> " << full_line;
+#endif
}
void