-
Notifications
You must be signed in to change notification settings - Fork 26
Add NXT support for GNU/Linux #1696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
|
|
@@ -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) { | ||
MinyazevR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| error(tr("If you are using GNU/Linux visit " | ||
| "https://help.trikset.com/nxt/run-upload-programs to get instructions")); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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); | ||
| } | ||
|
|
@@ -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."); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
|
@@ -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) { | ||
MinyazevR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mUi->generatorSettingsGroupBox->setVisible(robotModel->name() == "NxtOsekCGeneratorRobotModel"); | ||
MinyazevR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| void NxtAdditionalPreferences::manualComPortCheckboxChecked(bool state) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.