Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
url = https://bitbucket.org/codeimproved/qslog.git
[submodule "installer/nxt-tools"]
path = installer/nxt-tools
url = https://github.com/trikset/nxt-tools
url = https://github.com/trikset/nxt-tools.git
branch = main
[submodule "trik-checkapp"]
path = thirdparty/checkapp/checkapp
url = https://github.com/trikset/trik-checkapp
Expand Down
2 changes: 1 addition & 1 deletion installer/nxt-tools
Submodule nxt-tools updated 4377 files
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ cd "$(dirname "$0")"
source "$INSTALLER_ROOT"/utils/common_utils.sh
mkdir "$PWD"/../data/bin
cd "$PWD"/../data/bin
rsync -a "$INSTALLER_ROOT"/nxt-tools/linux/nxt-tools ./
rsync -a "$INSTALLER_ROOT"/nxt-tools ./
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ source "$INSTALLER_ROOT"/utils/common_utils.sh

cd "$PWD"/../data

rsync -aR "$INSTALLER_ROOT"/nxt-tools/win/./nxt-tools .
rsync -aR "$INSTALLER_ROOT"/./nxt-tools .
dos2unix nxt-tools/compile.sh
rm -rf bin
30 changes: 23 additions & 7 deletions plugins/robots/generators/nxt/nxtOsekCGenerator/nxtFlashTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <thirdparty/runExtensions.h>
#include <nxtKit/communication/nxtCommandConstants.h>
#include <nxtKit/communication/usbRobotCommunicationThread.h>
#include <QOperatingSystemVersion>

using namespace nxt;
using namespace qReal;
Expand Down Expand Up @@ -222,15 +223,26 @@ bool NxtFlashTool::uploadProgram(const QFileInfo &fileInfo)
mCompileState = idle;
mSource = fileInfo;

#ifdef Q_OS_WIN
mCompileProcess.setWorkingDirectory(path());
mCompileProcess.start("cmd", { "/c", path("compile.bat")
+ " " + fileInfo.completeBaseName()
+ " " + fileInfo.absolutePath() });
#else
mCompileProcess.start("sh", { path("compile.sh") , fileInfo.absolutePath()});
#endif

switch(QOperatingSystemVersion::currentType()) {
default:
break;
case QOperatingSystemVersion::OSType::Windows: {
auto pathToNxtTools = path().replace("\\", "/");
auto line = path("compile.bat")
+ " " + fileInfo.completeBaseName()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, file names with spaces are handled incorrectly here after the single line is combined.

+ " " + fileInfo.absolutePath() + " " + pathToNxtTools+"gnuarm";
mCompileProcess.start("cmd", { "/c", line});
}
break;
case QOperatingSystemVersion::OSType::Unknown: {
auto line = "./compile.sh . " + fileInfo.absolutePath() +
" GNUARM_ROOT="+SettingsManager::value("pathToArmNoneEabi").toString();
mCompileProcess.start("/bin/bash", {"-c", line});
}
break;
}
information(tr("Uploading program started. Please don't disconnect robot during the process"));
return true;
}
Expand Down Expand Up @@ -291,6 +303,10 @@ void NxtFlashTool::readNxtCompileData()
"If you sure in their validness contact developers"));
} else {
error(tr("Could not upload program. Make sure the robot is connected and ON"));
if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::OSType::Unknown) {
error(tr("If you are using GNU/Linux visit "
"https://help.trikset.com/nxt/run-upload-programs to get instructions"));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
* limitations under the License. */

#include "nxtOsekCGeneratorPlugin.h"

#include <QtCore/QDir>
#include <QtCore/QDateTime>
#include <QtWidgets/QApplication>

#include <qrkernel/settingsManager.h>
#include <qrkernel/platformInfo.h>
#include <qrutils/singleton.h>
#include <QOperatingSystemVersion>

#include "QsLog.h"
#include "nxtOsekCMasterGenerator.h"

using namespace nxt::osekC;
Expand All @@ -37,6 +38,12 @@ NxtOsekCGeneratorPlugin::NxtOsekCGeneratorPlugin()
, mMasterGenerator(nullptr)
, mCommunicator(utils::Singleton<communication::UsbRobotCommunicationThread>::instance())
{
const QString key = "pathToArmNoneEabi";
const QString defaultPath = QDir(PlatformInfo::invariantSettingsPath("pathToNxtTools")).absolutePath()
+"/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi";
if (qReal::SettingsManager::value(key).isNull()) {
qReal::SettingsManager::setValue(key, defaultPath);
}
initActions();
initHotKeyActions();
}
Expand Down Expand Up @@ -96,7 +103,6 @@ void NxtOsekCGeneratorPlugin::onCurrentDiagramChanged(const TabInfo &info)
void NxtOsekCGeneratorPlugin::init(const kitBase::KitPluginConfigurator &configurator)
{
RobotsGeneratorPluginBase::init(configurator);

mFlashTool.reset(new NxtFlashTool(*mMainWindowInterface->errorReporter(), *mCommunicator));
connect(&*mFlashTool, &NxtFlashTool::uploadingComplete, this, &NxtOsekCGeneratorPlugin::onUploadingComplete);
}
Expand Down Expand Up @@ -223,21 +229,31 @@ void NxtOsekCGeneratorPlugin::uploadProgram()
void NxtOsekCGeneratorPlugin::checkNxtTools()
{
const QDir dir(PlatformInfo::invariantSettingsPath("pathToNxtTools"));
if (!dir.exists()) {
const QDir gnuarm(dir.absolutePath() + "/gnuarm");
const QDir nexttool(dir.absolutePath() + "/nexttool");
const QDir nxtOSEK(dir.absolutePath() + "/nxtOSEK");

if (!dir.exists() || !gnuarm.exists() || !nexttool.exists() || !nxtOSEK.exists()) {
mNxtToolsPresent = false;
QLOG_ERROR() << "Missing" << dir.absolutePath() << "or mandatory subdirectory" <<
dir.entryList(QDir::Filter::NoFilter, QDir::SortFlag::DirsFirst | QDir::SortFlag::Name);
} else {
QDir gnuarm(dir.absolutePath() + "/gnuarm/bin");
QDir nexttool(dir.absolutePath() + "/nexttool");
QDir nxtOSEK(dir.absolutePath() + "/nxtOSEK");

#ifdef Q_OS_WIN
QFile compile1(dir.absolutePath() + "/compile.bat");
QFile compile2(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists()
&& compile1.exists() && compile2.exists();
#else
QFile compile(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists() && compile.exists();
#endif
switch(QOperatingSystemVersion::currentType()) {
default:
break;

case QOperatingSystemVersion::OSType::Windows: {
QFile compile1(dir.absolutePath() + "/compile.bat");
QFile compile2(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists()
&& compile1.exists() && compile2.exists();
}
break;
case QOperatingSystemVersion::OSType::Unknown: {
QFile compile(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = nexttool.exists() && nxtOSEK.exists() && compile.exists();
}
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

#include "nxtAdditionalPreferences.h"
#include "ui_nxtAdditionalPreferences.h"

#include <qrkernel/settingsManager.h>
#include <utils/widgets/comPortPicker.h>
#include "QsLog.h"
#include <QOperatingSystemVersion>


using namespace nxt;
using namespace qReal;
Expand All @@ -28,6 +30,8 @@ NxtAdditionalPreferences::NxtAdditionalPreferences(const QString &realRobotName,
{
mUi->setupUi(this);
mUi->robotImagePicker->configure("nxtRobot2DImage", tr("2D robot image:"));
mUi->compilerPicker->configure("pathToArmNoneEabi", tr("Path to arm-none-eabi:"));
setTextOnGeneratorLabel();
connect(mUi->manualComPortCheckbox, &QCheckBox::toggled
, this, &NxtAdditionalPreferences::manualComPortCheckboxChecked);
}
Expand All @@ -37,18 +41,44 @@ NxtAdditionalPreferences::~NxtAdditionalPreferences()
delete mUi;
}

void NxtAdditionalPreferences::setColorOnGeneratorLabel(QColor color){
QPalette palette = mUi->generatorLabel->palette();
palette.setColor(mUi->generatorLabel->foregroundRole(), color);
mUi->generatorLabel->setPalette(palette);
}

void NxtAdditionalPreferences::setTextOnGeneratorLabel(){
if (!mUi->compilerPicker->isSavedDirExist()){
mUi->generatorLabel->setText(tr("WARNING: Current directory doesn't exist. \nOpen "
"<a href=\"https://help.trikset.com/nxt/run-upload-programs\">link</a>"
" for instructions"));
mUi->generatorLabel->setTextFormat(Qt::RichText);
mUi->generatorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
mUi->generatorLabel->setOpenExternalLinks(true);
setColorOnGeneratorLabel(QColor("red"));
}
else {
mUi->generatorLabel->setText("Current directory exist.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the text is not intended to be shown to the user, please, state this clearly in the code. I recommend to use string literals like following

auto x = "*SOME TEMPORARY TEXT NOT FOR USER*"

setColorOnGeneratorLabel(QColor("black"));
}
}

void NxtAdditionalPreferences::save()
{
SettingsManager::setValue("NxtBluetoothPortName", selectedPortName());
SettingsManager::setValue("NxtManualComPortCheckboxChecked", mUi->manualComPortCheckbox->isChecked());
mUi->robotImagePicker->save();
mUi->compilerPicker->save();
setTextOnGeneratorLabel();
emit settingsChanged();
}

void NxtAdditionalPreferences::restoreSettings()
{
ui::ComPortPicker::populate(*mUi->comPortComboBox, "NxtBluetoothPortName");
mUi->robotImagePicker->restore();
mUi->compilerPicker->restore();
setTextOnGeneratorLabel();

if (mUi->comPortComboBox->count() == 0) {
mUi->comPortComboBox->hide();
Expand All @@ -72,7 +102,11 @@ void NxtAdditionalPreferences::restoreSettings()

void NxtAdditionalPreferences::onRobotModelChanged(kitBase::robotModel::RobotModelInterface * const robotModel)
{
QLOG_DEBUG() << robotModel->name();
mUi->bluetoothSettingsGroupBox->setVisible(robotModel->name() == mBluetoothRobotName);
if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::OSType::Unknown) {
mUi->generatorSettingsGroupBox->setVisible(robotModel->name() == "NxtOsekCGeneratorRobotModel");
}
}

void NxtAdditionalPreferences::manualComPortCheckboxChecked(bool state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ private slots:

private:
QString selectedPortName() const;

void setColorOnGeneratorLabel(QColor color);
void setTextOnGeneratorLabel();
Ui::NxtAdditionalPreferences *mUi;
const QString mBluetoothRobotName;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>414</width>
<height>164</height>
<width>401</width>
<height>284</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -27,22 +27,33 @@
<number>0</number>
</property>
<item>
<widget class="qReal::ui::ImagePicker" name="robotImagePicker">
</widget>
<widget class="qReal::ui::ImagePicker" name="robotImagePicker" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="bluetoothSettingsGroupBox">
<widget class="QGroupBox" name="generatorSettingsGroupBox">
<property name="title">
<string>Bluetooth Settings</string>
<string>nxtOSEK Generator Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="comPortLabel">
<widget class="QLabel" name="generatorLabel">
<property name="text">
<string>COM Port:</string>
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="qReal::ui::dirPicker" name="compilerPicker" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="bluetoothSettingsGroupBox">
<property name="title">
<string>Bluetooth Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="1">
<widget class="QComboBox" name="comPortComboBox">
<property name="sizePolicy">
Expand All @@ -53,16 +64,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="directInputComPortLabel">
<property name="text">
<string>COM Port:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="directInputComPortLineEdit"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="noComPortsFoundLabel">
<property name="text">
Expand All @@ -73,13 +74,30 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="directInputComPortLineEdit"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="manualComPortCheckbox">
<property name="text">
<string>Specify COM port manually</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="comPortLabel">
<property name="text">
<string>COM Port:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="directInputComPortLabel">
<property name="text">
<string>COM Port:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand All @@ -92,6 +110,12 @@
<header>qrutils/widgets/imagePicker.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>qReal::ui::dirPicker</class>
<extends>QWidget</extends>
<header>qrutils/widgets/dirPicker.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down
Loading