Skip to content

Commit

Permalink
Updated Interface and response handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Schildkroet committed Sep 7, 2021
1 parent c053c2a commit 6355cab
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Linux: QT 5.12.2 with GCC
Downloads:
----------

* Windows: [Candle_2.2.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.2/Candle2.2.zip)
* Linux: [Candle_2.2_Linux.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.2/Candle2.2_Linux.zip)
* Windows: [Candle_2.3.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.3/Candle2.3.zip)
* Linux: [Candle_2.3_Linux.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.3/Candle2.3_Linux.zip)


Candle 2 GUI
Expand Down
2 changes: 1 addition & 1 deletion src/frmabout.ui
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<item>
<widget class="QLabel" name="lblAbout">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Candle 2&lt;br/&gt;Version: 2.2&lt;br/&gt;License: GNU GENERAL PUBLIC LICENSE&lt;a href=&quot;https://github.com/Schildkroet/Candle2/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;© 2015-2016 Hayrullin Denis Ravilevich&lt;br/&gt;© 2018-2021 Patrick F.&lt;/p&gt;&lt;p&gt;Visit: &lt;a href=&quot;https://github.com/Schildkroet/Candle2/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/Schildkroet/Candle2/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Candle 2&lt;br/&gt;Version: 2.3&lt;br/&gt;License: GNU GENERAL PUBLIC LICENSE&lt;a href=&quot;https://github.com/Schildkroet/Candle2/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;© 2015-2016 Hayrullin Denis Ravilevich&lt;br/&gt;© 2018-2021 Patrick F.&lt;/p&gt;&lt;p&gt;Visit: &lt;a href=&quot;https://github.com/Schildkroet/Candle2/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/Schildkroet/Candle2/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
Expand Down
5 changes: 3 additions & 2 deletions src/frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,9 @@ void frmMain::onProcessData()
on_cmdStop_clicked();
return;
}
sendCommand(msg);
sendCommand(msg, -1, false);
}
if(m_transferCompleted == false)
if(m_transferCompleted == false && m_serialHandWheel.isOpen())
{
// Drop all data received while sending file
m_serialHandWheel.clear();
Expand Down Expand Up @@ -792,6 +792,7 @@ void frmMain::onSendSerial()
Pdu_t p = {(uint8_t*)data.data(), (uint16_t)data.length()};
GrIP_Transmit(MSG_DATA_NO_RESPONSE, 0, &p);
}
//qDebug() << "Sent: " << command;

m_currentModel->setData(m_currentModel->index(q.tableIndex, 2), GCodeItem::Sent);
}
Expand Down
8 changes: 4 additions & 4 deletions src/frmmain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1646</width>
<height>887</height>
<height>932</height>
</rect>
</property>
<property name="acceptDrops">
Expand Down Expand Up @@ -352,7 +352,7 @@ QSlider::handle:horizontal:hover {
</font>
</property>
<property name="text">
<string>Handwheel</string>
<string>MPG</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -3054,8 +3054,8 @@ padding-right: 8;</string>
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>494</height>
<width>385</width>
<height>546</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down
47 changes: 28 additions & 19 deletions src/frmmain_processresponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,11 @@ void frmMain::ProcessGRBL1_1()
// Processed commands
//if(m_CommandAttributesList.length() > 0 && !DataIsFloating(data) && !(m_CommandAttributesList[0].command != "[CTRL+X]" && DataIsReset(data)))
auto &val = mCommandsSent.front();
//int i = mCommandsSent.size();
//QString tt = val.command;

if(mCommandsSent.size() > 0 && !DataIsFloating(data) && !(val.command != "[CTRL+X]" && DataIsReset(data)))
{
static QString response; // Full response string

//if((m_CommandAttributesList[0].command != "[CTRL+X]" && DataIsEnd(data)) || (m_CommandAttributesList[0].command == "[CTRL+X]" && DataIsReset(data)))
if((mCommandsSent.front().command != "[CTRL+X]" && DataIsEnd(data)) || (mCommandsSent.front().command == "[CTRL+X]" && DataIsReset(data)))
{
response.append(data);
Expand All @@ -437,21 +434,23 @@ void frmMain::ProcessGRBL1_1()

int ret = QMessageBox::information(this, qApp->applicationDisplayName(), tr("Confirm tool change"), QMessageBox::Ok | QMessageBox::Abort);

QString res = "$T\r";
const char res[4] = "$T\r";

if(ret == QMessageBox::Ok)
{
if(m_Protocol == PROT_GRBL1_1)
{
SerialIf_Write((const char*)res.constData(), res.size());
SerialIf_Write("\r", 1);
SerialIf_Write(res, strlen(res));
//SerialIf_Write("\r", 1);
}
else if(m_Protocol == PROT_GRIP)
{
//GrIP_Transmit(MSG_SYSTEM_CMD, 0, (const uint8_t*)res.constData(), res.size());
Pdu_t p = {(uint8_t*)res.data(), 1};
uint8_t ttt[3] = {'$', 'T', '\r'};
Pdu_t p = {ttt, 3};
GrIP_Transmit(MSG_REALTIME_CMD, 0, &p);
}
ca.command = "$T";
mCommandsSent.push_front(ca);
}

m_jogVector.setZ(0.0);
Expand Down Expand Up @@ -841,9 +840,10 @@ void frmMain::ProcessGRBL1_1()
ui->txtConsole->appendPlainText(data);
}
}
else
else if(data.size() > 2)
{
// Blank response
qDebug() << "Unknown: " << data;
}
}
}
Expand All @@ -855,7 +855,7 @@ void frmMain::ProcessGRBL_ETH(QString data)
{
data = data.trimmed();

qDebug() << "-- " << data << " --";
//qDebug() << "-- " << data << " --";

// Filter prereset responses
if(m_reseting)
Expand Down Expand Up @@ -1111,9 +1111,9 @@ void frmMain::ProcessGRBL_ETH(QString data)
}
else if(m_lastDrawnLineIndex < list.count())
{
qDebug() << "tool missed:" << list.at(m_lastDrawnLineIndex)->getLineNumber()
/* qDebug() << "tool missed:" << list.at(m_lastDrawnLineIndex)->getLineNumber()
<< m_currentModel->data(m_currentModel->index(m_fileProcessedCommandIndex, 4)).toInt()
<< m_fileProcessedCommandIndex;
<< m_fileProcessedCommandIndex;*/
}
}

Expand Down Expand Up @@ -1235,6 +1235,8 @@ void frmMain::ProcessGRBL_ETH(QString data)
if(mCommandsSent.size() > 0 && !DataIsFloating(data) && !(val.command != "[CTRL+X]" && DataIsReset(data)))
{
static QString response; // Full response string
//qDebug() << "CMD: " << mCommandsSent.front().command;
//qDebug() << "R: " << data;

if((mCommandsSent.front().command != "[CTRL+X]" && DataIsEnd(data)) || (mCommandsSent.front().command == "[CTRL+X]" && DataIsReset(data)))
{
Expand All @@ -1253,28 +1255,35 @@ void frmMain::ProcessGRBL_ETH(QString data)
int num = -1;
if(ca.command.toUpper().contains("T"))
{
sscanf(ca.command.toUpper().toStdString().c_str(), "T%d", &num);
sscanf(ca.command.toUpper().toStdString().c_str(), "%*s T%d", &num);
if(num == -1)
{
sscanf(ca.command.toUpper().toStdString().c_str(), "%*sT%d", &num);
}
}

QString msg = "Confirm tool change: T";
msg.append(QString::number(num));
int ret = QMessageBox::information(this, qApp->applicationDisplayName(), (msg), QMessageBox::Ok | QMessageBox::Abort);

QString res = "$T\r\n";
char res[4] = "$T\r";

if(ret == QMessageBox::Ok)
{
if(m_Protocol == PROT_GRBL1_1)
{
SerialIf_Write((const char*)res.constData(), res.size());
SerialIf_Write("\r", 1);
SerialIf_Write(res, strlen(res));
//SerialIf_Write("\r", 1);
}
else if(m_Protocol == PROT_GRIP)
{
Pdu_t p = {(uint8_t*)(res.data()), (uint16_t)res.size()};
GrIP_Transmit(MSG_REALTIME_CMD, 0, &p);
uint8_t ttt[3] = {'$', 'T', '\r'};
Pdu_t p = {ttt, 3};
GrIP_Transmit(MSG_SYSTEM_CMD, 0, &p);
QThread::msleep(10);
}
QThread::msleep(5);
ca.command = "$T";
mCommandsSent.push_front(ca);
}

m_jogVector.setZ(0.0);
Expand Down
2 changes: 1 addition & 1 deletion src/interface/SerialInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ qint64 SerialIf_Write(const QByteArray &data)
{
qDebug() << "Error: " << m_tcpSocket.errorString();
}
m_tcpSocket.waitForBytesWritten(6);
m_tcpSocket.waitForBytesWritten(4);

return bytes;
}
Expand Down

0 comments on commit 6355cab

Please sign in to comment.