[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [atcore] src: Report no serial when detecting fw and nothing connected. initSerial now returns true
From: Chris Rizzitello <null () kde ! org>
Date: 2017-07-31 23:16:36
Message-ID: E1dcJvQ-0001Bh-Iv () code ! kde ! org
[Download RAW message or body]
Git commit 03257a185bd6cb6fa2fe125e4e02959e0c5d4b31 by Chris Rizzitello.
Committed on 31/07/2017 at 20:13.
Pushed by rizzitello into branch 'master'.
Report no serial when detecting fw and nothing connected. initSerial now returns true if
connection attempt successful
Signed-off-by: Chris Rizzitello <rizzitello@kde.org>
M +9 -3 src/atcore.cpp
M +2 -1 src/atcore.h
https://commits.kde.org/atcore/03257a185bd6cb6fa2fe125e4e02959e0c5d4b31
diff --git a/src/atcore.cpp b/src/atcore.cpp
index ac38974..9cc6916 100644
--- a/src/atcore.cpp
+++ b/src/atcore.cpp
@@ -197,13 +197,17 @@ void AtCore::loadFirmwarePlugin(const QString &fwName)
}
}
-void AtCore::initSerial(const QString &port, int baud)
+bool AtCore::initSerial(const QString &port, int baud)
{
d->serial = new SerialLayer(port, baud);
if (serialInitialized()) {
setState(AtCore::CONNECTING);
+ connect(serial(), &SerialLayer::receivedCommand, this, &AtCore::findFirmware);
+ return true;
+ } else {
+ qCDebug(ATCORE_CORE) << "Failed to open device.";
+ return false;
}
- connect(serial(), &SerialLayer::receivedCommand, this, &AtCore::findFirmware);
}
bool AtCore::serialInitialized() const
@@ -329,9 +333,11 @@ void AtCore::emergencyStop()
void AtCore::requestFirmware()
{
- qCDebug(ATCORE_CORE) << "Sending " << GCode::toString(GCode::M115);
if (serialInitialized()) {
+ qCDebug(ATCORE_CORE) << "Sending " << GCode::toString(GCode::M115);
serial()->pushCommand(GCode::toCommand(GCode::M115).toLocal8Bit());
+ } else {
+ qCDebug(ATCORE_CORE) << "There is no open device to send commands";
}
}
diff --git a/src/atcore.h b/src/atcore.h
index a4dbded..77457b2 100644
--- a/src/atcore.h
+++ b/src/atcore.h
@@ -102,9 +102,10 @@ public:
* @brief Initialize a connection to \p port at a speed of \p baud <br />
* @param port: the port to initialize
* @param baud: the baud of the port
+ * @return True is connection was successful
* @sa serialPorts(),serial(),closeConnection()
*/
- void initSerial(const QString &port, int baud);
+ bool initSerial(const QString &port, int baud);
/**
* @brief Main access ot the serialLayer
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic