Skip to content

Commit 77ccbf9

Browse files
committed
Log initial printer communication with marlin-like printers on info level. Implements #20.
1 parent 55e44f2 commit 77ccbf9

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/drivers/AbstractDriver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class AbstractDriver {
110110
Logger& log_;
111111
Server& server_;
112112

113-
virtual void sendCode(const std::string& code) = 0;
113+
virtual void sendCode(const std::string& code, bool logAsInfo = false) = 0;
114114
virtual void readResponseCode(std::string& code) = 0;
115115

116116
void printNextLine();

src/drivers/MakerbotDriver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ bool MakerbotDriver::resetPrint() {
218218
return true;
219219
}
220220

221-
void MakerbotDriver::sendCode(const std::string& code) {
222-
// LOG(Logger::VERBOSE, "sendCode(): %s",code.c_str());
221+
void MakerbotDriver::sendCode(const std::string& code, bool logAsInfo) {
222+
// LOG(logAsInfo ? Logger::INFO : Logger::BULK, "sendCode(): %s",code.c_str());
223223
// if (isConnected()) {
224224
// extractGCodeInfo(code);
225225
// serial_.send((code+"\n").c_str());

src/drivers/MakerbotDriver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class MakerbotDriver : public AbstractDriver {
4242
bool startPrint(STATE state = PRINTING);
4343
bool stopPrint();
4444
bool resetPrint();
45-
void sendCode(const std::string& code);
45+
void sendCode(const std::string& code, bool logAsInfo = false);
4646
void readResponseCode(std::string& code);
4747
void fullStop();
4848

src/drivers/MarlinDriver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ int MarlinDriver::update() {
3737
// during startup we use this to check for a valid connection, when it's established we stop checking
3838
if (checkConnection_) {
3939
if (checkTemperatureAttempt_ < maxCheckTemperatureAttempts_) {
40-
LOG(Logger::VERBOSE, "(checking connection) check temperature %i/%i", checkTemperatureAttempt_, maxCheckTemperatureAttempts_);
41-
checkTemperature();
40+
LOG(Logger::INFO, "(checking connection) check temperature %i/%i", checkTemperatureAttempt_, maxCheckTemperatureAttempts_);
41+
checkTemperature(true);
4242
checkTemperatureAttempt_++;
4343
} else {
4444
switchBaudrate();
@@ -86,7 +86,7 @@ void MarlinDriver::readResponseCode(string& code) {
8686
*/
8787
//filterText(code, "\x0D\x0E\x1B"); //not sure if replacing these is enough
8888

89-
LOG(Logger::BULK, "readResponseCode(): '%s'",code.c_str());
89+
LOG(checkConnection_ ? Logger::INFO : Logger::BULK, "readResponseCode(): '%s'",code.c_str());
9090

9191
bool tempMessage = (code.find("ok T:") == 0);
9292
bool heatingMessage = (code.find("T:") == 0);
@@ -165,12 +165,12 @@ void MarlinDriver::parseTemperatures(string& code) {
165165
}
166166
}
167167

168-
void MarlinDriver::checkTemperature() {
169-
sendCode("M105");
168+
void MarlinDriver::checkTemperature(bool logAsInfo) {
169+
sendCode("M105", logAsInfo);
170170
}
171171

172-
void MarlinDriver::sendCode(const string& code) {
173-
LOG(Logger::BULK, "sendCode(): %s", code.c_str());
172+
void MarlinDriver::sendCode(const string& code, bool logAsInfo) {
173+
LOG(logAsInfo ? Logger::INFO : Logger::BULK, "sendCode(): %s", code.c_str());
174174
if (isConnected()) {
175175
AbstractDriver::extractGCodeInfo(code);
176176
serial_.send((code + "\n").c_str());

src/drivers/MarlinDriver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class MarlinDriver : public AbstractDriver {
2828

2929
void readResponseCode(std::string& code);
3030
void parseTemperatures(std::string& code);
31-
void checkTemperature();
32-
void sendCode(const std::string& code);
31+
void checkTemperature(bool logAsInfo = false);
32+
void sendCode(const std::string& code, bool logAsInfo = false);
3333

3434
private:
3535
static const int UPDATE_INTERVAL;

0 commit comments

Comments
 (0)