diff --git a/src/candle.vcxproj b/src/candle.vcxproj
index 4c5061150..00967bec5 100644
--- a/src/candle.vcxproj
+++ b/src/candle.vcxproj
@@ -13,13 +13,15 @@
{225C620D-C774-30C0-A16D-B392DA51D110}
Candle
- Qt4VSv1.0
- 10.0.17763.0
+ QtVS_v303
+ 10.0
10.0.17763.0
+ C:\Qt\5.12.10\msvc2017
+ $(MSBuildProjectDirectory)\QtMsBuild
- v141
+ v142
release\
false
NotSet
@@ -28,7 +30,7 @@
Candle
- v141
+ v142
debug\
false
NotSet
@@ -37,15 +39,9 @@
Candle
-
- $(MSBuildProjectDirectory)\QtMsBuild
-
-
-
-
@@ -54,20 +50,36 @@
-
- .\build-$(Platform)\$(Configuration)\Bin
- .\build-$(Platform)\$(Configuration)\
- Candle
- true
- false
- .\build-$(Platform)\$(Configuration)\Bin
- .\build-$(Platform)\$(Configuration)\
- Candle
- true
+
+
+
+
+ .\build-$(Platform)\$(Configuration)\Bin\
+ .\build-$(Platform)\$(Configuration)\
+ Candle
+ true
+
+
+ .\build-$(Platform)\$(Configuration)\Bin\
+ .\build-$(Platform)\$(Configuration)\
+ Candle
+ true
+ false
+
+
+ msvc2017
+ core;gui;network;opengl;serialport;widgets;winextras
+
+
+ msvc2017
+ core;gui;network;opengl;serialport;widgets;winextras
+
+
+
- .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtOpenGL;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtWidgets;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtWinExtras;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtGui;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtANGLE;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtSerialPort;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtCore;release;\include;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\mkspecs\win32-msvc;%(AdditionalIncludeDirectories)
+ GeneratedFiles\$(ConfigurationName);GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;release;\include;%(AdditionalIncludeDirectories)
-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions)
release\
false
@@ -76,7 +88,7 @@
Sync
$(IntDir)
MaxSpeed
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;APP_VERSION="1.1.8";_USE_MATH_DEFINES;QT_NO_DEBUG;QT_OPENGL_LIB;QT_WIDGETS_LIB;QT_WINEXTRAS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_CORE_LIB;NDEBUG;%(PreprocessorDefinitions)
+ _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;APP_VERSION="1.1.8";_USE_MATH_DEFINES;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)
false
$(IntDir)vc$(PlatformToolsetVersion).pdb
MultiThreadedDLL
@@ -84,10 +96,11 @@
true
Level3
true
+ true
- $(QTDIR)\lib\Qt5OpenGL.lib;$(QTDIR)\lib\Qt5Widgets.lib;$(QTDIR)\lib\Qt5WinExtras.lib;$(QTDIR)\lib\Qt5Gui.lib;$(QTDIR)\lib\Qt5SerialPort.lib;$(QTDIR)\lib\Qt5Core.lib;$(QTDIR)\lib\qtmain.lib;%(AdditionalDependencies)
- $(QTDIR)\lib;E:\QT\QT5.12.0\5.12.0\MSVC2017\lib;%(AdditionalLibraryDirectories)
+ %(AdditionalDependencies)
+ %(AdditionalLibraryDirectories)
"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)
true
false
@@ -108,33 +121,28 @@
_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;sNan="65536";APP_VERSION=\"1.1.8\";_USE_MATH_DEFINES;QT_NO_DEBUG;QT_OPENGL_LIB;QT_WIDGETS_LIB;QT_WINEXTRAS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_CORE_LIB;%(PreprocessorDefinitions)
- E:\QT\QT5.12.0\5.12.0\MSVC2017
- .\build-$(Platform)\$(Configuration)\moc_%(Filename).cpp
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;APP_VERSION="1.1.8";_USE_MATH_DEFINES;QT_NO_DEBUG;QT_OPENGL_LIB;QT_WIDGETS_LIB;QT_WINEXTRAS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_CORE_LIB;NDEBUG;%(PreprocessorDefinitions)
msvc
./$(Configuration)/moc_predefs.h
Moc'ing %(Identity)...
- %(FullPath)
output
- .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;E:/QT/QT5.12.0/5.12.0/MSVC2017/mkspecs/$(Platform)-msvc;.;E:/QT/QT5.12.0/5.12.0/MSVC2017/include;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtOpenGL;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtWidgets;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtWinExtras;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtGui;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtANGLE;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtSerialPort;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtCore;C:\Program Files (x86)\Microsoft Visual Studio\VC98\atl\include;C:\Program Files (x86)\Microsoft Visual Studio\VC98\mfc\include;C:\Program Files (x86)\Microsoft Visual Studio\VC98\include;E:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include;E:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt
+ .\build-$(Platform)\$(Configuration)
+ moc_%(Filename).cpp
- .\build-$(Platform)\$(Configuration)\qrc_%(Filename).cpp
- E:\QT\QT5.12.0\5.12.0\MSVC2017
default
Rcc'ing %(Identity)...
- %(FullPath)
+ .\build-$(Platform)\$(Configuration)
+ qrc_%(Filename).cpp
- E:\QT\QT5.12.0\5.12.0\MSVC2017
Uic'ing %(Identity)...
- %(FullPath)
- .\build-$(Platform)\$(Configuration)\ui_%(Filename).h
+ .\build-$(Platform)\$(Configuration)
+ ui_%(Filename).h
- .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtOpenGL;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtWidgets;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtWinExtras;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtGui;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtANGLE;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtSerialPort;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\include\QtCore;debug;\include;..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\mkspecs\win32-msvc;%(AdditionalIncludeDirectories)
+ GeneratedFiles\$(ConfigurationName);GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;debug;\include;%(AdditionalIncludeDirectories)
-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions)
debug\
false
@@ -143,7 +151,7 @@
Sync
$(IntDir)
Disabled
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;APP_VERSION="1.1.8";_USE_MATH_DEFINES;QT_OPENGL_LIB;QT_WIDGETS_LIB;QT_WINEXTRAS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_CORE_LIB;%(PreprocessorDefinitions)
+ _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;APP_VERSION="1.1.8";_USE_MATH_DEFINES;%(PreprocessorDefinitions)
false
MultiThreadedDebugDLL
true
@@ -151,10 +159,11 @@
Level3
true
$(IntDir)vc$(PlatformToolsetVersion).pdb
+ true
- $(QTDIR)\lib\Qt5OpenGLd.lib;$(QTDIR)\lib\Qt5Widgetsd.lib;$(QTDIR)\lib\Qt5WinExtrasd.lib;$(QTDIR)\lib\Qt5Guid.lib;$(QTDIR)\lib\Qt5SerialPortd.lib;$(QTDIR)\lib\Qt5Cored.lib;$(QTDIR)\lib\qtmaind.lib;%(AdditionalDependencies)
- $(QTDIR)\lib;E:\QT\QT5.12.0\5.12.0\MSVC2017\lib;%(AdditionalLibraryDirectories)
+ %(AdditionalDependencies)
+ %(AdditionalLibraryDirectories)
"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)
true
true
@@ -174,28 +183,23 @@
_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;APP_VERSION=\"1.1.8\";_USE_MATH_DEFINES;QT_OPENGL_LIB;QT_WIDGETS_LIB;QT_WINEXTRAS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions)
- E:\QT\QT5.12.0\5.12.0\MSVC2017
- .\build-$(Platform)\$(Configuration)\moc_%(Filename).cpp
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WINDOWS;APP_VERSION="1.1.8";_USE_MATH_DEFINES;QT_OPENGL_LIB;QT_WIDGETS_LIB;QT_WINEXTRAS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_CORE_LIB;%(PreprocessorDefinitions)
msvc
./$(Configuration)/moc_predefs.h
Moc'ing %(Identity)...
- %(FullPath)
output
- .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;E:/QT/QT5.12.0/5.12.0/MSVC2017/mkspecs/$(Platform)-msvc;.;E:/QT/QT5.12.0/5.12.0/MSVC2017/include;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtOpenGL;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtWidgets;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtWinExtras;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtGui;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtANGLE;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtSerialPort;E:/QT/QT5.12.0/5.12.0/MSVC2017/include/QtCore;C:\Program Files (x86)\Microsoft Visual Studio\VC98\atl\include;C:\Program Files (x86)\Microsoft Visual Studio\VC98\mfc\include;C:\Program Files (x86)\Microsoft Visual Studio\VC98\include;E:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include;E:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt
+ .\build-$(Platform)\$(Configuration)
+ moc_%(Filename).cpp
default
- .\build-$(Platform)\$(Configuration)\qrc_%(Filename).cpp
- E:\QT\QT5.12.0\5.12.0\MSVC2017
Rcc'ing %(Identity)...
- %(FullPath)
+ .\build-$(Platform)\$(Configuration)
+ qrc_%(Filename).cpp
- E:\QT\QT5.12.0\5.12.0\MSVC2017
Uic'ing %(Identity)...
- %(FullPath)
- .\build-$(Platform)\$(Configuration)\ui_%(Filename).h
+ .\build-$(Platform)\$(Configuration)
+ ui_%(Filename).h
@@ -232,67 +236,50 @@
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
+
-
-
-
-
+
+
-
-
+
Document
true
- ..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\mkspecs\features\data\dummy.cpp;%(AdditionalInputs)
- cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -g3 -pg -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E ..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h
+ $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs)
+ cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -g3 -pg -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h
Generate moc_predefs.h
debug\moc_predefs.h;%(Outputs)
Document
- ..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\mkspecs\features\data\dummy.cpp;%(AdditionalInputs)
- cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E ..\..\..\QT\QT5.12.0\5.12.0\MSVC2017\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h
+ $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs)
+ cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h
Generate moc_predefs.h
release\moc_predefs.h;%(Outputs)
true
@@ -310,20 +297,20 @@
- ui_frmabout.h
- ui_frmabout.h
+ $(ProjectDir)
+ ui_frmabout.h
- ui_frmmain.h
- ui_frmmain.h
+ $(ProjectDir)
+ ui_frmmain.h
- ui_frmsettings.h
- ui_frmsettings.h
+ $(ProjectDir)
+ ui_frmsettings.h
- ui_sliderbox.h
- ui_sliderbox.h
+ $(ProjectDir)
+ ui_sliderbox.h
@@ -382,9 +369,11 @@
+
@@ -392,7 +381,7 @@
-
+
\ No newline at end of file
diff --git a/src/frmmain.cpp b/src/frmmain.cpp
index cab86028e..8e6f794da 100644
--- a/src/frmmain.cpp
+++ b/src/frmmain.cpp
@@ -264,9 +264,16 @@ frmMain::frmMain(QWidget *parent) :
m_serialPort.setPortName(m_settings->port());
m_serialPort.setBaudRate(m_settings->baud());
}
+ // Setup TCP socket
+ // set the socket to low delay to avoid too much buffering
+ // since it's expected the connection to be on a local network where congestion is not an issue
+ m_serialSocket.setSocketOption(QAbstractSocket::SocketOption::LowDelayOption, 1);
connect(&m_serialPort, SIGNAL(readyRead()), this, SLOT(onSerialPortReadyRead()), Qt::QueuedConnection);
connect(&m_serialPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(onSerialPortError(QSerialPort::SerialPortError)));
+ connect(&m_serialSocket, SIGNAL(readyRead()), this, SLOT(onSerialPortReadyRead()), Qt::QueuedConnection);
+ connect(&m_serialSocket, SIGNAL(connected()), this, SLOT(onSerialSocketConnected()), Qt::QueuedConnection);
+ connect(&m_serialSocket, SIGNAL(errorOccured(QAbstractSocket::SocketError)), this, SLOT(onSerialSocketError(QAbstractSocket::SocketError)));
this->installEventFilter(this);
ui->tblProgram->installEventFilter(this);
@@ -336,6 +343,7 @@ void frmMain::loadSettings()
m_settings->setFontSize(set.value("fontSize", 8).toInt());
m_settings->setPort(set.value("port").toString());
m_settings->setBaud(set.value("baud").toInt());
+ m_settings->setSerialHostname(set.value("serialHostname").toString());
m_settings->setIgnoreErrors(set.value("ignoreErrors", false).toBool());
m_settings->setAutoLine(set.value("autoLine", true).toBool());
m_settings->setToolDiameter(set.value("toolDiameter", 3).toDouble());
@@ -487,6 +495,7 @@ void frmMain::saveSettings()
set.setValue("port", m_settings->port());
set.setValue("baud", m_settings->baud());
+ set.setValue("serialHostname", m_settings->serialHostname());
set.setValue("ignoreErrors", m_settings->ignoreErrors());
set.setValue("autoLine", m_settings->autoLine());
set.setValue("toolDiameter", m_settings->toolDiameter());
@@ -622,7 +631,7 @@ bool frmMain::saveChanges(bool heightMapMode)
}
void frmMain::updateControlsState() {
- bool portOpened = m_serialPort.isOpen();
+ bool portOpened = getIODevice().isOpen();
ui->grpState->setEnabled(portOpened);
ui->grpControl->setEnabled(portOpened);
@@ -728,6 +737,10 @@ void frmMain::updateControlsState() {
void frmMain::openPort()
{
+ // Don't open serial port if already connected/connecting via TCP
+ if (m_serialSocket.state() != QAbstractSocket::SocketState::UnconnectedState
+ && m_serialSocket.state() != QAbstractSocket::SocketState::ClosingState)
+ return;
if (m_serialPort.open(QIODevice::ReadWrite)) {
ui->txtStatus->setText(tr("Port opened"));
ui->txtStatus->setStyleSheet(QString("background-color: palette(button); color: palette(text);"));
@@ -738,7 +751,7 @@ void frmMain::openPort()
void frmMain::sendCommand(QString command, int tableIndex, bool showInConsole)
{
- if (!m_serialPort.isOpen() || !m_resetCompleted) return;
+ if (!getIODevice().isOpen() || !m_resetCompleted) return;
command = command.toUpper();
@@ -787,14 +800,14 @@ void frmMain::sendCommand(QString command, int tableIndex, bool showInConsole)
m_fileEndSent = true;
}
- m_serialPort.write((command + "\r").toLatin1());
+ getIODevice().write((command + "\r").toLatin1());
}
void frmMain::grblReset()
{
qDebug() << "grbl reset";
- m_serialPort.write(QByteArray(1, (char)24));
+ getIODevice().write(QByteArray(1, (char)24));
// m_serialPort.flush();
m_processingFile = false;
@@ -837,8 +850,9 @@ int frmMain::bufferLength()
void frmMain::onSerialPortReadyRead()
{
- while (m_serialPort.canReadLine()) {
- QString data = m_serialPort.readLine().trimmed();
+ auto& ioDevice = getIODevice();
+ while (ioDevice.canReadLine()) {
+ QString data = ioDevice.readLine().trimmed();
// Filter prereset responses
if (m_reseting) {
@@ -1042,13 +1056,13 @@ void frmMain::onSerialPortReadyRead()
if (rapid != target) switch (target) {
case 25:
- m_serialPort.write(QByteArray(1, char(0x97)));
+ getIODevice().write(QByteArray(1, char(0x97)));
break;
case 50:
- m_serialPort.write(QByteArray(1, char(0x96)));
+ getIODevice().write(QByteArray(1, char(0x96)));
break;
case 100:
- m_serialPort.write(QByteArray(1, char(0x95)));
+ getIODevice().write(QByteArray(1, char(0x95)));
break;
}
@@ -1271,7 +1285,7 @@ void frmMain::onSerialPortReadyRead()
holding = true; // Hold transmit while messagebox is visible
response.clear();
- m_serialPort.write("!");
+ getIODevice().write("!");
m_senderErrorBox->checkBox()->setChecked(false);
qApp->beep();
int result = m_senderErrorBox->exec();
@@ -1279,7 +1293,7 @@ void frmMain::onSerialPortReadyRead()
holding = false;
errors.clear();
if (m_senderErrorBox->checkBox()->isChecked()) m_settings->setIgnoreErrors(true);
- if (result == QMessageBox::Ignore) m_serialPort.write("~"); else on_cmdFileAbort_clicked();
+ if (result == QMessageBox::Ignore) getIODevice().write("~"); else on_cmdFileAbort_clicked();
}
}
@@ -1380,10 +1394,37 @@ void frmMain::onSerialPortError(QSerialPort::SerialPortError error)
}
}
+void frmMain::onSerialSocketConnected()
+{
+ ui->txtStatus->setText(tr("TCP serial opened"));
+ ui->txtStatus->setStyleSheet(QString("background-color: palette(button); color: palette(text);"));
+ // updateControlsState();
+ grblReset();
+}
+
+void frmMain::onSerialSocketError(QAbstractSocket::SocketError socketError)
+{
+ static QAbstractSocket::SocketError previousSocketError;
+
+ if (socketError != previousSocketError) {
+ previousSocketError = socketError;
+ ui->txtConsole->appendPlainText(tr("TCP Socket error ") + QString::number(socketError) + ": " + m_serialSocket.errorString());
+ if (m_serialSocket.isOpen()) {
+ m_serialSocket.close();
+ updateControlsState();
+ }
+ }
+}
+
void frmMain::onTimerConnection()
{
- if (!m_serialPort.isOpen()) {
- openPort();
+ if (m_serialSocket.state() == QAbstractSocket::SocketState::UnconnectedState && !m_serialPort.isOpen()) {
+ if (m_serialSocket.state() == QAbstractSocket::SocketState::UnconnectedState && m_settings->serialHostname() != "") {
+ m_serialSocket.connectToHost(m_settings->serialHostname(), m_settings->serialTcpPort());
+ }
+ else {
+ openPort();
+ }
} else if (!m_homing/* && !m_reseting*/ && !ui->cmdFilePause->isChecked() && m_queue.length() == 0) {
if (m_updateSpindleSpeed) {
m_updateSpindleSpeed = false;
@@ -1398,8 +1439,9 @@ void frmMain::onTimerConnection()
void frmMain::onTimerStateQuery()
{
- if (m_serialPort.isOpen() && m_resetCompleted && m_statusReceived) {
- m_serialPort.write(QByteArray(1, '?'));
+ auto& ioDevice = getIODevice();
+ if (ioDevice.isOpen() && m_resetCompleted && m_statusReceived) {
+ ioDevice.write(QByteArray(1, '?'));
m_statusReceived = false;
}
@@ -1549,7 +1591,8 @@ void frmMain::closeEvent(QCloseEvent *ce)
return;
}
- if (m_serialPort.isOpen()) m_serialPort.close();
+ auto& ioDevice = getIODevice();
+ if (ioDevice.isOpen()) ioDevice.close();
if (m_queue.length() > 0) {
m_commands.clear();
m_queue.clear();
@@ -1983,7 +2026,7 @@ void frmMain::on_cmdFileAbort_clicked()
{
m_aborting = true;
if (!ui->chkTestMode->isChecked()) {
- m_serialPort.write("!");
+ getIODevice().write("!");
} else {
grblReset();
}
@@ -2160,9 +2203,15 @@ void frmMain::on_actServiceSettings_triggered()
if (m_settings->exec()) {
qDebug() << "Applying settings";
qDebug() << "Port:" << m_settings->port() << "Baud:" << m_settings->baud();
-
- if (m_settings->port() != "" && (m_settings->port() != m_serialPort.portName() ||
- m_settings->baud() != m_serialPort.baudRate())) {
+ qDebug() << "Hostname:" << m_settings->serialHostname() << ":" << m_settings->serialTcpPort();
+
+ if (!m_settings->serialHostname().isEmpty() && (m_settings->serialHostname() != m_serialSocket.peerName() ||
+ m_settings->serialTcpPort() != m_serialSocket.peerPort())) {
+ if (m_serialSocket.isOpen())
+ m_serialSocket.close();
+ // The socket will be reconnected in the timer event handler
+ } else if (!m_settings->port().isEmpty() && (m_settings->port() != m_serialPort.portName() ||
+ m_settings->baud() != m_serialPort.baudRate())) {
if (m_serialPort.isOpen()) m_serialPort.close();
m_serialPort.setPortName(m_settings->port());
m_serialPort.setBaudRate(m_settings->baud());
@@ -2452,7 +2501,7 @@ void frmMain::on_cmdSpindle_toggled(bool checked)
void frmMain::on_cmdSpindle_clicked(bool checked)
{
if (ui->cmdFilePause->isChecked()) {
- m_serialPort.write(QByteArray(1, char(0x9e)));
+ getIODevice().write(QByteArray(1, char(0x9e)));
} else {
sendCommand(checked ? QString("M3 S%1").arg(ui->slbSpindle->value()) : "M5", -1, m_settings->showUICommands());
}
@@ -2472,7 +2521,7 @@ void frmMain::on_chkTestMode_clicked(bool checked)
void frmMain::on_cmdFilePause_clicked(bool checked)
{
- m_serialPort.write(checked ? "!" : "~");
+ getIODevice().write(checked ? "!" : "~");
}
void frmMain::on_cmdFileReset_clicked()
@@ -3861,9 +3910,9 @@ void frmMain::updateOverride(SliderBox *slider, int value, char command)
bool smallStep = abs(target - slider->currentValue()) < 10 || m_settings->queryStateTime() < 100;
if (slider->currentValue() < target) {
- m_serialPort.write(QByteArray(1, char(smallStep ? command + 2 : command)));
+ getIODevice().write(QByteArray(1, char(smallStep ? command + 2 : command)));
} else if (slider->currentValue() > target) {
- m_serialPort.write(QByteArray(1, char(smallStep ? command + 3 : command + 1)));
+ getIODevice().write(QByteArray(1, char(smallStep ? command + 3 : command + 1)));
}
}
@@ -3900,6 +3949,13 @@ void frmMain::jogStep()
}
}
+QIODevice& frmMain::getIODevice()
+{
+ if (m_serialSocket.isOpen())
+ return m_serialSocket;
+ return m_serialPort;
+}
+
void frmMain::on_cmdYPlus_pressed()
{
m_jogVector += QVector3D(0, 1, 0);
@@ -3975,5 +4031,5 @@ void frmMain::on_cmdZMinus_released()
void frmMain::on_cmdStop_clicked()
{
m_queue.clear();
- m_serialPort.write(QByteArray(1, char(0x85)));
+ getIODevice().write(QByteArray(1, char(0x85)));
}
diff --git a/src/frmmain.h b/src/frmmain.h
index c1f0ef94e..034e8bb0f 100644
--- a/src/frmmain.h
+++ b/src/frmmain.h
@@ -6,6 +6,7 @@
#include
#include
+#include
#include
#include
#include
@@ -91,6 +92,8 @@ private slots:
void onSerialPortReadyRead();
void onSerialPortError(QSerialPort::SerialPortError);
+ void onSerialSocketConnected();
+ void onSerialSocketError(QAbstractSocket::SocketError socketError);
void onTimerConnection();
void onTimerStateQuery();
void onVisualizatorRotationChanged();
@@ -232,6 +235,8 @@ private slots:
bool m_settingsLoading;
QSerialPort m_serialPort;
+ QTcpSocket m_serialSocket;
+ QIODevice& getIODevice();
frmSettings *m_settings;
frmAbout m_frmAbout;
diff --git a/src/frmsettings.cpp b/src/frmsettings.cpp
index cdc873715..a7c56d58b 100644
--- a/src/frmsettings.cpp
+++ b/src/frmsettings.cpp
@@ -28,6 +28,7 @@ frmSettings::frmSettings(QWidget *parent) :
ui->listCategories->item(0)->setSelected(true);
connect(ui->scrollSettings->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onScrollBarValueChanged(int)));
+ connect(ui->hostEdit, SIGNAL(textChanged(QString)), this, SLOT(onHostnameEdited(QString)));
searchPorts();
}
@@ -583,6 +584,37 @@ void frmSettings::setAutoLine(bool value)
ui->chkAutoLine->setChecked(value);
}
+QString frmSettings::serialHostname()
+{
+ auto hostname = ui->hostEdit->text();
+ auto parts = hostname.splitRef(':');
+ if (parts.length() == 2) {
+ return parts[0].toString();
+ }
+ return hostname;
+}
+
+void frmSettings::setSerialHostname(QString hostName)
+{
+ ui->hostEdit->setText(hostName);
+}
+
+int frmSettings::serialTcpPort()
+{
+ auto hostname = this->serialHostname();
+ if (hostname.isEmpty())
+ return -1;
+ auto parts = hostname.splitRef(':');
+ if (parts.length() == 2) {
+ auto portRef = parts[1];
+ bool ok;
+ auto port = portRef.toInt(&ok);
+ if (ok)
+ return port;
+ }
+ return 6778;
+}
+
void frmSettings::showEvent(QShowEvent *se)
{
Q_UNUSED(se)
@@ -716,3 +748,14 @@ void frmSettings::on_radGrayscaleZ_toggled(bool checked)
{
ui->radGrayscaleS->setChecked(!checked);
}
+
+void frmSettings::onHostnameEdited(const QString& newValue)
+{
+ if (newValue.isEmpty()) {
+ ui->cboPort->setEnabled(true);
+ ui->cboBaud->setEnabled(true);
+ } else {
+ ui->cboPort->setEnabled(false);
+ ui->cboBaud->setEnabled(false);
+ }
+}
diff --git a/src/frmsettings.h b/src/frmsettings.h
index fc44eb819..b9d9a8eab 100644
--- a/src/frmsettings.h
+++ b/src/frmsettings.h
@@ -117,12 +117,16 @@ class frmSettings : public QDialog
void setIgnoreErrors(bool value);
bool autoLine();
void setAutoLine(bool value);
+ QString serialHostname();
+ void setSerialHostname(QString hostName);
+ int serialTcpPort();
protected:
void showEvent(QShowEvent *se);
private slots:
void onScrollBarValueChanged(int value);
+ void onHostnameEdited(const QString& newValue);
void on_cmdRefresh_clicked();
void on_cmdOK_clicked();
diff --git a/src/frmsettings.ui b/src/frmsettings.ui
index d7b6d39dc..56385a9c3 100644
--- a/src/frmsettings.ui
+++ b/src/frmsettings.ui
@@ -72,8 +72,8 @@ QGroupBox {
0
0
- 436
- 1749
+ 368
+ 1571
@@ -84,12 +84,15 @@ QGroupBox {
-
-
+
-
Port:
+
+ cboPort
+
-
@@ -124,6 +127,9 @@ QGroupBox {
Baud:
+
+ cboBaud
+
-
@@ -168,6 +174,27 @@ QGroupBox {
+ -
+
+
-
+
+
+ Hostname:
+
+
+ hostEdit
+
+
+
+ -
+
+
+ Connect to a remote server (HOST:PORT syntax)
+
+
+
+
+
@@ -225,6 +252,9 @@ QGroupBox {
Status query period:
+
+ txtQueryStateTime
+
-
@@ -286,6 +316,9 @@ QGroupBox {
Units:
+
+ cboUnits
+
-
@@ -293,6 +326,9 @@ QGroupBox {
Rapid speed:
+
+ txtRapidSpeed
+
-
@@ -318,6 +354,9 @@ QGroupBox {
Acceleration:
+
+ txtAcceleration
+
-
@@ -343,6 +382,9 @@ QGroupBox {
max.:
+
+ txtSpindleSpeedMax
+
-
@@ -350,6 +392,9 @@ QGroupBox {
Spindle speed min.:
+
+ txtSpindleSpeedMin
+
-
@@ -375,6 +420,9 @@ QGroupBox {
Laser power min.:
+
+ txtLaserPowerMin
+
-
@@ -400,6 +448,9 @@ QGroupBox {
max.:
+
+ txtLaserPowerMax
+
-
@@ -442,6 +493,9 @@ QGroupBox {
0
+
+ txtTouchCommand
+
-
@@ -465,6 +519,9 @@ QGroupBox {
0
+
+ txtSafeCommand
+
-
@@ -551,6 +608,9 @@ QGroupBox {
0
+
+ txtUserCommand0
+
-
@@ -574,6 +634,9 @@ QGroupBox {
0
+
+ txtUserCommand1
+
-
@@ -597,6 +660,9 @@ QGroupBox {
0
+
+ txtUserCommand2
+
-
@@ -620,6 +686,9 @@ QGroupBox {
0
+
+ txtUserCommand3
+
-
@@ -648,6 +717,9 @@ QGroupBox {
Heightmap probing feed:
+
+ txtHeightMapProbingFeed
+
-
@@ -826,6 +898,9 @@ QGroupBox {
Line width:
+
+ txtLineWidth
+
-
@@ -853,6 +928,9 @@ QGroupBox {
FPS lock:
+
+ cboFps
+
-
@@ -1027,6 +1105,9 @@ QGroupBox {
Type:
+
+ cboToolType
+
-
@@ -1034,6 +1115,9 @@ QGroupBox {
Diameter:
+
+ txtToolDiameter
+
-
@@ -1064,6 +1148,9 @@ QGroupBox {
Angle:
+
+ txtToolAngle
+
-
@@ -1071,6 +1158,9 @@ QGroupBox {
Length:
+
+ txtToolLength
+
-
@@ -1379,6 +1469,9 @@ QGroupBox {
Size:
+
+ cboFontSize
+
-