diff --git a/src/core/atcore.cpp b/src/core/atcore.cpp --- a/src/core/atcore.cpp +++ b/src/core/atcore.cpp @@ -376,8 +376,12 @@ void AtCore::pushCommand(const QString &comm) { - //Append command to the commandQueue - d->commandQueue.append(comm); +//M112 is Emergency stop be sure we perpend that if its sent + if (comm.contains(QStringLiteral("M112"))) { + d->commandQueue.prepend(comm); + } else { + d->commandQueue.append(comm); + } if (d->ready) { //The printer is ready for a command now so push one. processQueue(); @@ -461,8 +465,7 @@ setState(AtCore::STOP); } } - //push command through serial to bypass atcore's queue. - serial()->pushCommand(GCode::toCommand(GCode::M112).toLocal8Bit()); + pushCommand(GCode::toCommand(GCode::M112)); } void AtCore::stopSdPrint() @@ -478,8 +481,10 @@ void AtCore::requestFirmware() { if (serialInitialized()) { + //ensure M115 is sent on cold connect. + d->ready = true; qCDebug(ATCORE_CORE) << "Sending " << GCode::description(GCode::M115); - serial()->pushCommand(GCode::toCommand(GCode::M115).toLocal8Bit()); + pushCommand(GCode::toCommand(GCode::M115)); } else { qCDebug(ATCORE_CORE) << "There is no open device to send commands"; }