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

Support for Arduino CLI #1532

Merged
merged 47 commits into from
Jan 28, 2023
Merged

Support for Arduino CLI #1532

merged 47 commits into from
Jan 28, 2023

Conversation

arengarajan99
Copy link
Contributor

@arengarajan99 arengarajan99 commented Jan 9, 2023

With the new Arduino 2.0 IDE release, the functionality that allowed us to use CMake (the avr compiler) has been abstracted away, prompting us to move to Arduino-CLI, the backbone of the Arduino build system. Arduino-CLI has limitation with regards to how to compile multilayered projects, but allows for lazy compilation in a specified src folder.

This PR uses Arduino specifications in the following workflow: LFC generated code is treated like an Arduino Sketch and the corresponding reactor-c files are placed in a src folder to be lazy compiled. To do this, I removed files that aren't used by Arduino that when compiled will cause redefinition errors and changed all includes using Regex to be relative links inside the src folder since Arduino doesn't support adding additional include paths.

To try this:

  • Install Arduino CLI
  • Plug in your Arduino board
  • Run arduino-cli board list and record the Fully Qualified Board Name (FQBN) and port
  • Compile your Lingua Franca program with the platform: {name: arduino, board: <FQBN>} target property
  • Change directory to the generated sources, and run arduino-cli upload -b <FQBN> -p <port>

Features implemented:

  • LF programs that specify arduino as the platform without specifying a board or port will only generate C code (as it works now), but print a message instructing the user how to obtain the information and provide it to LF
  • For LF programs that do specify a board and port, arduino-cli is invoked automatically (unless the no-compile flag is used)
  • As of yet, Arduino boards that run an MBED RTOS cannot handle physical actions. The compiler needs to reject programs with physical actions that target such boards.

Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

Great work, @arengarajan99! I've left some minor comments.

.github/workflows/c-tests.yml Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/util/FileUtil.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/util/FileUtil.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/util/FileUtil.java Show resolved Hide resolved
org.lflang/src/org/lflang/util/FileUtil.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/c/CGenerator.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/c/CGenerator.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/c/CGenerator.java Outdated Show resolved Hide resolved
Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

Looks ready to me, modulo the remaining util.c issue. Will approve and merge once fixed.

@lhstrh
Copy link
Member

lhstrh commented Jan 23, 2023

Oh, there are also a bunch of conflicts with master that are probably a result of the work done in fed-gen. Can you handle these, or should I take a look, @arengarajan99?

@lhstrh lhstrh added the feature New feature label Jan 25, 2023
Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

Getting close! Minor changes requested.

org.lflang.tests/src/org/lflang/tests/TestBase.java Outdated Show resolved Hide resolved
@@ -47,11 +48,14 @@
import org.lflang.generator.LFGeneratorContext;
import org.lflang.generator.LFGeneratorContext.BuildParm;
import org.lflang.generator.MainContext;
import org.lflang.generator.GeneratorCommandFactory;
Copy link
Member

Choose a reason for hiding this comment

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

Unused import?

import org.lflang.tests.Configurators.Configurator;
import org.lflang.tests.LFTest.Result;
import org.lflang.tests.TestRegistry.TestCategory;
import org.lflang.util.FileUtil;
import org.lflang.util.LFCommand;
import org.lflang.util.ArduinoUtil;
Copy link
Member

Choose a reason for hiding this comment

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

Unused import?

@lhstrh lhstrh merged commit ef70a95 into master Jan 28, 2023
@arengarajan99 arengarajan99 deleted the arduino-cli-support branch February 25, 2023 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants