Skip to content

Commit

Permalink
Abort button fix. Status query fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denvi committed Dec 16, 2015
1 parent 241af18 commit 06c04c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -743,15 +746,16 @@ void frmMain::onSerialPortReadyRead()

if (m_aborting) {
switch (status) {
case 0: // Idle
case IDLE: // Idle
if (!m_processingFile && m_resetCompleted) {
m_aborting = false;
restoreOffsets();
restoreParserState();
return;
}
break;
case 4: // Hold
case HOLD: // Hold
case QUEUE:
if (!m_reseting && compareCoordinates(x, y, z)) {
x = sNan;
y = sNan;
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 06c04c0

Please # to comment.