Skip to content

Commit 3f46213

Browse files
authored
Merge branch 'trikset:master' into me/fix_memleak
2 parents 2d9d095 + eeafe92 commit 3f46213

File tree

16 files changed

+236
-93
lines changed

16 files changed

+236
-93
lines changed

.gitmodules

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
url = https://bitbucket.org/codeimproved/qslog.git
2626
[submodule "installer/nxt-tools"]
2727
path = installer/nxt-tools
28-
url = https://github.com/trikset/nxt-tools
28+
url = https://github.com/trikset/nxt-tools.git
29+
branch = main
2930
[submodule "trik-checkapp"]
3031
path = thirdparty/checkapp/checkapp
3132
url = https://github.com/trikset/trik-checkapp

installer/nxt-tools

Submodule nxt-tools updated 4377 files

installer/packages/trik-studio/ru.qreal.root.nxt.tools/meta/prebuild-linux-gnu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ cd "$(dirname "$0")"
66
source "$INSTALLER_ROOT"/utils/common_utils.sh
77
mkdir "$PWD"/../data/bin
88
cd "$PWD"/../data/bin
9-
rsync -a "$INSTALLER_ROOT"/nxt-tools/linux/nxt-tools ./
9+
rsync -a "$INSTALLER_ROOT"/nxt-tools ./

installer/packages/trik-studio/ru.qreal.root.nxt.tools/meta/prebuild-win32.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ source "$INSTALLER_ROOT"/utils/common_utils.sh
77

88
cd "$PWD"/../data
99

10-
rsync -aR "$INSTALLER_ROOT"/nxt-tools/win/./nxt-tools .
10+
rsync -aR "$INSTALLER_ROOT"/./nxt-tools .
1111
dos2unix nxt-tools/compile.sh
1212
rm -rf bin

installer/packages/trik-studio/ru.qreal.root.trik.core/meta/prebuild-win32.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ rsync -a "$BIN_DIR"/vcruntime*.dll
1717
rsync -a "$BIN_DIR"/{system.js,TRIK.py,2D-model.exe,checkapp.exe} "$PWD/../data/"
1818
rsync -a "$QT_LIB"/Qt5SerialPort.dll "$PWD"/../data
1919

20-
winscp_ver=5.17.10
21-
putty_ver=0.75
20+
winscp_ver=6.3.6
21+
putty_ver=0.82
22+
2223
cache_dir="$(cygpath "$APPDATA")"/"$PRODUCT"/installer_cache
2324
mkdir -p "$cache_dir"
2425
cd "$cache_dir"

plugins/robots/generators/nxt/nxtOsekCGenerator/nxtFlashTool.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,25 @@ bool NxtFlashTool::uploadProgram(const QFileInfo &fileInfo)
222222
mCompileState = idle;
223223
mSource = fileInfo;
224224

225-
#ifdef Q_OS_WIN
226225
mCompileProcess.setWorkingDirectory(path());
227-
mCompileProcess.start("cmd", { "/c", path("compile.bat")
228-
+ " " + fileInfo.completeBaseName()
229-
+ " " + fileInfo.absolutePath() });
230-
#else
231-
mCompileProcess.start("sh", { path("compile.sh") , fileInfo.absolutePath()});
232-
#endif
233226

227+
auto osType = PlatformInfo::osType();
228+
if (osType == "windows") {
229+
auto line = path("compile.bat")
230+
+ " " + fileInfo.completeBaseName()
231+
+ " " + fileInfo.absolutePath()
232+
+ " " + path("gnuarm");
233+
mCompileProcess.start("cmd", { "/c", line});
234+
}
235+
else if (osType == "linux") {
236+
auto line = "./compile.sh . " + fileInfo.absolutePath() +
237+
" GNUARM_ROOT="+SettingsManager::value("pathToArmNoneEabi").toString();
238+
mCompileProcess.start("/bin/bash", {"-c", line});
239+
}
240+
else {
241+
QLOG_INFO() << "Platform: " << osType << "not supported for upload program";
242+
return false;
243+
}
234244
information(tr("Uploading program started. Please don't disconnect robot during the process"));
235245
return true;
236246
}
@@ -291,6 +301,10 @@ void NxtFlashTool::readNxtCompileData()
291301
"If you sure in their validness contact developers"));
292302
} else {
293303
error(tr("Could not upload program. Make sure the robot is connected and ON"));
304+
if (PlatformInfo::osType() == "linux") {
305+
error(tr("If you are using GNU/Linux visit "
306+
"https://help.trikset.com/nxt/run-upload-programs to get instructions"));
307+
}
294308
}
295309
}
296310

plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.cpp

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* limitations under the License. */
1414

1515
#include "nxtOsekCGeneratorPlugin.h"
16-
1716
#include <QtCore/QDir>
1817
#include <QtCore/QDateTime>
1918
#include <QtWidgets/QApplication>
@@ -22,6 +21,7 @@
2221
#include <qrkernel/platformInfo.h>
2322
#include <qrutils/singleton.h>
2423

24+
#include "QsLog.h"
2525
#include "nxtOsekCMasterGenerator.h"
2626

2727
using namespace nxt::osekC;
@@ -34,9 +34,14 @@ NxtOsekCGeneratorPlugin::NxtOsekCGeneratorPlugin()
3434
, mFlashRobotAction(new QAction(this))
3535
, mUploadProgramAction(new QAction(this))
3636
, mNxtToolsPresent(false)
37-
, mMasterGenerator(nullptr)
3837
, mCommunicator(utils::Singleton<communication::UsbRobotCommunicationThread>::instance())
3938
{
39+
const QString key = "pathToArmNoneEabi";
40+
const QString defaultPath = QDir(PlatformInfo::invariantSettingsPath("pathToNxtTools")).absolutePath()
41+
+"/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi";
42+
if (qReal::SettingsManager::value(key).isNull()) {
43+
qReal::SettingsManager::setValue(key, defaultPath);
44+
}
4045
initActions();
4146
initHotKeyActions();
4247
}
@@ -96,7 +101,6 @@ void NxtOsekCGeneratorPlugin::onCurrentDiagramChanged(const TabInfo &info)
96101
void NxtOsekCGeneratorPlugin::init(const kitBase::KitPluginConfigurator &configurator)
97102
{
98103
RobotsGeneratorPluginBase::init(configurator);
99-
100104
mFlashTool.reset(new NxtFlashTool(*mMainWindowInterface->errorReporter(), *mCommunicator));
101105
connect(&*mFlashTool, &NxtFlashTool::uploadingComplete, this, &NxtOsekCGeneratorPlugin::onUploadingComplete);
102106
}
@@ -179,21 +183,24 @@ void NxtOsekCGeneratorPlugin::onUploadingComplete(bool success)
179183

180184
generatorBase::MasterGeneratorBase *NxtOsekCGeneratorPlugin::masterGenerator()
181185
{
182-
mMasterGenerator = new NxtOsekCMasterGenerator(*mRepo
186+
return new NxtOsekCMasterGenerator(*mRepo
183187
, *mMainWindowInterface->errorReporter()
184188
, *mParserErrorReporter
185189
, *mRobotModelManager
186190
, *mTextLanguage
187191
, mMainWindowInterface->activeDiagram()
188192
, generatorName());
189-
return mMasterGenerator;
190193
}
191194

192195
void NxtOsekCGeneratorPlugin::regenerateExtraFiles(const QFileInfo &newFileInfo)
193196
{
194-
mMasterGenerator->initialize();
195-
mMasterGenerator->setProjectDir(newFileInfo);
196-
mMasterGenerator->generateOilAndMakeFiles();
197+
// Static cast is possible and correct, but dynamic will be more flexible.
198+
if (auto nxtGenerator = qobject_cast<NxtOsekCMasterGenerator*>(masterGenerator())) {
199+
QScopedPointer<NxtOsekCMasterGenerator> generator(nxtGenerator);
200+
generator->initialize();
201+
generator->setProjectDir(newFileInfo);
202+
generator->generateOilAndMakeFiles();
203+
}
197204
}
198205

199206
void NxtOsekCGeneratorPlugin::flashRobot()
@@ -223,21 +230,27 @@ void NxtOsekCGeneratorPlugin::uploadProgram()
223230
void NxtOsekCGeneratorPlugin::checkNxtTools()
224231
{
225232
const QDir dir(PlatformInfo::invariantSettingsPath("pathToNxtTools"));
226-
if (!dir.exists()) {
227-
mNxtToolsPresent = false;
228-
} else {
229-
QDir gnuarm(dir.absolutePath() + "/gnuarm/bin");
230-
QDir nexttool(dir.absolutePath() + "/nexttool");
231-
QDir nxtOSEK(dir.absolutePath() + "/nxtOSEK");
232-
233-
#ifdef Q_OS_WIN
234-
QFile compile1(dir.absolutePath() + "/compile.bat");
235-
QFile compile2(dir.absolutePath() + "/compile.sh");
236-
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists()
237-
&& compile1.exists() && compile2.exists();
238-
#else
239-
QFile compile(dir.absolutePath() + "/compile.sh");
240-
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists() && compile.exists();
241-
#endif
233+
auto compilePath = dir.absolutePath() + "/compile.sh";
234+
235+
auto nxtToolsPresent = dir.exists()
236+
&& QFileInfo::exists(dir.absolutePath() + "/gnuarm")
237+
&& QFileInfo::exists(dir.absolutePath() + "/nexttool")
238+
&& QFileInfo::exists(dir.absolutePath() + "/nxtOSEK")
239+
&& QFileInfo::exists(compilePath) && QFileInfo(compilePath).isFile();
240+
241+
if (!nxtToolsPresent) {
242+
mNxtToolsPresent = false;
243+
QLOG_ERROR() << "Missing" << dir.absolutePath() << "or mandatory subdirectory" <<
244+
dir.entryList(QDir::Filter::NoFilter, QDir::SortFlag::DirsFirst | QDir::SortFlag::Name);
245+
return;
246+
}
247+
248+
auto osType = PlatformInfo::osType();
249+
if (osType == "linux") {
250+
mNxtToolsPresent = true;
251+
}
252+
else if (osType == "windows") {
253+
auto compileBatPath = dir.absolutePath() + "/compile.bat";
254+
mNxtToolsPresent = QFileInfo::exists(compileBatPath) && QFileInfo(compileBatPath).isFile();
242255
}
243256
}

plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ private slots:
8989
bool mNxtToolsPresent { false };
9090
/// Flasher object
9191
QScopedPointer<NxtFlashTool> mFlashTool;
92-
93-
NxtOsekCMasterGenerator *mMasterGenerator;
9492
const QSharedPointer<communication::UsbRobotCommunicationThread> mCommunicator;
9593
};
9694

plugins/robots/interpreters/nxtKitInterpreter/src/nxtAdditionalPreferences.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414

1515
#include "nxtAdditionalPreferences.h"
1616
#include "ui_nxtAdditionalPreferences.h"
17-
1817
#include <qrkernel/settingsManager.h>
1918
#include <utils/widgets/comPortPicker.h>
19+
#include "QsLog.h"
20+
#include <QOperatingSystemVersion>
21+
#include <qrkernel/platformInfo.h>
2022

2123
using namespace nxt;
2224
using namespace qReal;
@@ -28,6 +30,13 @@ NxtAdditionalPreferences::NxtAdditionalPreferences(const QString &realRobotName,
2830
{
2931
mUi->setupUi(this);
3032
mUi->robotImagePicker->configure("nxtRobot2DImage", tr("2D robot image:"));
33+
if (PlatformInfo::osType() == "linux") {
34+
mUi->compilerPicker->configure("pathToArmNoneEabi", tr("Path to arm-none-eabi:"));
35+
setTextOnGeneratorLabel();
36+
}
37+
else {
38+
mUi->generatorSettingsGroupBox->setVisible(false);
39+
}
3140
connect(mUi->manualComPortCheckbox, &QCheckBox::toggled
3241
, this, &NxtAdditionalPreferences::manualComPortCheckboxChecked);
3342
}
@@ -37,18 +46,44 @@ NxtAdditionalPreferences::~NxtAdditionalPreferences()
3746
delete mUi;
3847
}
3948

49+
void NxtAdditionalPreferences::setColorOnGeneratorLabel(QColor color){
50+
QPalette palette = mUi->generatorLabel->palette();
51+
palette.setColor(mUi->generatorLabel->foregroundRole(), color);
52+
mUi->generatorLabel->setPalette(palette);
53+
}
54+
55+
void NxtAdditionalPreferences::setTextOnGeneratorLabel(){
56+
if (!mUi->compilerPicker->isSavedDirExist()){
57+
mUi->generatorLabel->setText(tr("WARNING: Current directory doesn't exist. \nOpen "
58+
"<a href=\"https://help.trikset.com/nxt/run-upload-programs\">link</a>"
59+
" for instructions"));
60+
mUi->generatorLabel->setTextFormat(Qt::RichText);
61+
mUi->generatorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
62+
mUi->generatorLabel->setOpenExternalLinks(true);
63+
setColorOnGeneratorLabel(QColor("red"));
64+
}
65+
else {
66+
mUi->generatorLabel->setText("Current directory exist.");
67+
setColorOnGeneratorLabel(QColor("black"));
68+
}
69+
}
70+
4071
void NxtAdditionalPreferences::save()
4172
{
4273
SettingsManager::setValue("NxtBluetoothPortName", selectedPortName());
4374
SettingsManager::setValue("NxtManualComPortCheckboxChecked", mUi->manualComPortCheckbox->isChecked());
4475
mUi->robotImagePicker->save();
76+
mUi->compilerPicker->save();
77+
setTextOnGeneratorLabel();
4578
emit settingsChanged();
4679
}
4780

4881
void NxtAdditionalPreferences::restoreSettings()
4982
{
5083
ui::ComPortPicker::populate(*mUi->comPortComboBox, "NxtBluetoothPortName");
5184
mUi->robotImagePicker->restore();
85+
mUi->compilerPicker->restore();
86+
setTextOnGeneratorLabel();
5287

5388
if (mUi->comPortComboBox->count() == 0) {
5489
mUi->comPortComboBox->hide();
@@ -72,7 +107,11 @@ void NxtAdditionalPreferences::restoreSettings()
72107

73108
void NxtAdditionalPreferences::onRobotModelChanged(kitBase::robotModel::RobotModelInterface * const robotModel)
74109
{
110+
QLOG_DEBUG() << robotModel->name();
75111
mUi->bluetoothSettingsGroupBox->setVisible(robotModel->name() == mBluetoothRobotName);
112+
if (PlatformInfo::osType() == "linux") {
113+
mUi->generatorSettingsGroupBox->setVisible(robotModel->name() == "NxtOsekCGeneratorRobotModel");
114+
}
76115
}
77116

78117
void NxtAdditionalPreferences::manualComPortCheckboxChecked(bool state)

plugins/robots/interpreters/nxtKitInterpreter/src/nxtAdditionalPreferences.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ private slots:
4242

4343
private:
4444
QString selectedPortName() const;
45-
45+
void setColorOnGeneratorLabel(QColor color);
46+
void setTextOnGeneratorLabel();
4647
Ui::NxtAdditionalPreferences *mUi;
4748
const QString mBluetoothRobotName;
4849
};

0 commit comments

Comments
 (0)