diff --git a/frmmain.cpp b/frmmain.cpp index be580a1d..23dffd1a 100644 --- a/frmmain.cpp +++ b/frmmain.cpp @@ -611,6 +611,7 @@ void frmMain::grblReset() m_resetCompleted = false; m_updateSpindleSpeed = true; m_lastGrblStatus = -1; + m_statusReceived = true; // Drop all remaining commands in buffer m_commands.clear(); @@ -658,6 +659,8 @@ void frmMain::onSerialPortReadyRead() if (data[0] == '<') { int status = -1; + m_statusReceived = true; + // Update machine coordinates QRegExp mpx("MPos:([^,]*),([^,]*),([^,^>]*)"); if (mpx.indexIn(data) != -1) { @@ -743,7 +746,7 @@ void frmMain::onSerialPortReadyRead() if (m_aborting) { switch (status) { - case 0: // Idle + case IDLE: // Idle if (!m_processingFile && m_resetCompleted) { m_aborting = false; restoreOffsets(); @@ -751,7 +754,8 @@ void frmMain::onSerialPortReadyRead() return; } break; - case 4: // Hold + case HOLD: // Hold + case QUEUE: if (!m_reseting && compareCoordinates(x, y, z)) { x = sNan; y = sNan; @@ -1129,8 +1133,9 @@ void frmMain::onTimerConnection() void frmMain::onTimerStateQuery() { - if (m_serialPort.isOpen() && m_resetCompleted) { + if (m_serialPort.isOpen() && m_resetCompleted && m_statusReceived) { m_serialPort.write(QByteArray(1, '?')); + m_statusReceived = false; } ui->glwVisualizer->setBufferState(QString(tr("Buffer: %1 / %2")).arg(bufferLength()).arg(m_queue.length())); @@ -2270,7 +2275,8 @@ bool frmMain::dataIsFloating(QString data) { } bool frmMain::dataIsReset(QString data) { - return data.contains("'$' for help"); +// return data.contains("'$' for help"); + return data.toUpper().contains(QRegExp("^GRBL \\d\\.\\d.")); } QString frmMain::feedOverride(QString command) diff --git a/frmmain.h b/frmmain.h index 89d4eb18..4c0577c7 100644 --- a/frmmain.h +++ b/frmmain.h @@ -239,8 +239,9 @@ private slots: bool m_updateFeed = false; bool m_reseting = false; - bool m_resetCompleted = true; + bool m_resetCompleted = true; bool m_aborting = false; + bool m_statusReceived = false; bool m_processingFile = false; bool m_transferCompleted = false;