From 32c4217a6e649dd56ea8e71a23edfde3b489de7c Mon Sep 17 00:00:00 2001 From: Andres Faina Date: Tue, 1 Oct 2024 14:13:36 +0200 Subject: [PATCH 1/2] allows using arduino cli and it still works with IDE 1.5 to 1.8 for existing users. Arduino IDE 2.x seems to not support comand line commands. Fixes #4010 --- src/program/platformarduino.cpp | 28 +++++++++++++++++++++++++--- src/program/platformarduino.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/program/platformarduino.cpp b/src/program/platformarduino.cpp index a6bfe0f64..323e1e382 100644 --- a/src/program/platformarduino.cpp +++ b/src/program/platformarduino.cpp @@ -70,9 +70,16 @@ void PlatformArduino::upload(QWidget *source, const QString &port, const QString } QStringList args; - // see https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc - //args.append(QString("--verbose")); - args.append(QString("--board")); + if (!usingArduinoCLI()) { + // see https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc + //args.append(QString("--verbose")); + args.append(QString("--board")); + }else { + // see https://github.com/arduino/arduino-cli + //args.append(QString("--verbose")); + args.append(QString("compile")); + args.append(QString("-b")); + } args.append(getBoards().value(board)); args.append(QString("--port")); args.append(port); @@ -83,4 +90,19 @@ void PlatformArduino::upload(QWidget *source, const QString &port, const QString if (tab != nullptr) tab->appendToConsole(tr("Running %1 %2").arg(getCommandLocation()).arg(args.join(" "))); process->start(getCommandLocation(), args); + +} + +bool PlatformArduino::usingArduinoCLI() { + //We make an error and analize if we are using the arduino-cli or not + auto * process = new QProcess(this); + QStringList args; + args.append(QString("--board")); + args.append(QString(" sssssss")); + + process->start(getCommandLocation(), args); + process->waitForFinished(500); + QString version = process->readAllStandardError(); + + return version.contains("arduino-cli"); } diff --git a/src/program/platformarduino.h b/src/program/platformarduino.h index 3ff27f765..ea77597bf 100644 --- a/src/program/platformarduino.h +++ b/src/program/platformarduino.h @@ -12,6 +12,7 @@ class PlatformArduino : public Platform PlatformArduino(); void upload(QWidget *source, const QString &port, const QString &board, const QString &fileLocation); + bool usingArduinoCLI(); }; #endif // PLATFORMARDUINO_H From 5614fa841ad0678c8050fb478ec7351beabe1b47 Mon Sep 17 00:00:00 2001 From: Andres Faina Date: Tue, 1 Oct 2024 14:36:21 +0200 Subject: [PATCH 2/2] Update the instructions to use the arduino command line interface (CLI) instead of the Arduino IDE (Arduino 1.x still works, but 2.x does not). So, let's push users to use the Arduino CLI. --- src/program/platformarduino.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/program/platformarduino.cpp b/src/program/platformarduino.cpp index 323e1e382..17ddc2fe4 100644 --- a/src/program/platformarduino.cpp +++ b/src/program/platformarduino.cpp @@ -8,9 +8,9 @@ PlatformArduino::PlatformArduino() : Platform(QString("Arduino")) { setReferenceUrl(QUrl(QString("http://arduino.cc/en/Reference/"))); - setIdeName("Arduino IDE"); - setDownloadUrl(QUrl("http://arduino.cc/en/Main/Software")); - setMinVersion("1.5.2"); + setIdeName("Arduino CLI"); + setDownloadUrl(QUrl("https://github.com/arduino/arduino-cli")); + setMinVersion("1.0.0"); setCanProgram(true); setExtensions(QStringList() << ".ino" << ".pde");