Skip to content
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

Add NXT support for GNU/Linux #1696

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add NXT support for GNU/Linux #1696

wants to merge 3 commits into from

Conversation

zhitm
Copy link

@zhitm zhitm commented Dec 10, 2023

What?

I've added NXT support for GNU/Linux so this PR allows to compile and load programs via USB connection on Lego NXT.

Why?

Where's no NXT support for GNU/Linux, but it exist for Windows.

How?

I've changed structure of nxt-tools. There is no more division into win and linux directories. I use gcc-arm-none-eabi to compile C code on Linux same as on Windows. In order not to increase the volume of the installer, the user is given the opportunity to run the download-arm-none-eabi.sh script.
There are some changes in compile.sh and compile.bat to pass sysroot as argument and use sysroot as compile option. There are also added more setting to choose cross compiler path as shown on image below. I've added widget dirPicker to choose path.

Screenshots

image_2023-12-21_16-21-47
image_2023-12-21_16-22-17

Other info

The imagePicker widget exist, but it only allows you to select image path. To reduce code repetitions it would be a good idea to unify that widget and dirPicker.

Linked pull requests

PR to nxt-tools
PR to trik-help

@zhitm zhitm force-pushed the master branch 4 times, most recently from c4b5f98 to f828e2b Compare December 21, 2023 11:02
@zhitm zhitm changed the title Added NXT support for GNU/Linux Add NXT support for GNU/Linux Dec 21, 2023
Copy link
Member

@iakov iakov left a comment

Choose a reason for hiding this comment

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

Very impressive! But small polishing is required.

.gitmodules Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

?

trikV62QtsGenerator \
trikPythonGeneratorLibrary \
trikV62PythonGenerator \
trikGeneratorBase \
Copy link
Member

Choose a reason for hiding this comment

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

?

case QOperatingSystemVersion::OSType::Windows: {
QFile compile1(dir.absolutePath() + "/compile.bat");
QFile compile2(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists()
Copy link
Member

Choose a reason for hiding this comment

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

The preferable way to check for existence of the FS object is QFileInfo::exists(path). Also, in case you need a readable regular file, the exists is not enough, because it returns true for directories too.

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*"

mUi->bluetoothSettingsGroupBox->setVisible(robotModel->name() == mBluetoothRobotName);
if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::OSType::Unknown) {
Copy link
Member

Choose a reason for hiding this comment

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

Unknown means that QOperatingSystemVersion does not have a special literal name for a variant. I suggest using PlatformInfo::osType here

QFile compile(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists() && compile.exists();
#endif
switch(QOperatingSystemVersion::currentType()) {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using PlatformInfo::osType or introducing a companion function to that one to return some useful enumerable type.

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

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

Unknown is not intended to check for Linux. See comments below


switch(QOperatingSystemVersion::currentType()) {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like QOperatingSystemVersion was not designed for this use-case, please, find additional info in my other comments.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants