Posts | Comments

Planet Arduino

Archive for the ‘Arduino Command Line Interface’ Category

There’s a truckload of news from the Arduino Tooling Team today: Arduino CLI 0.19.0 is now available! This release has tons of great enhancements, exciting new features and heaps of bug fixes. Some things required quite a bit of breaking changes but they’re worth the hassle.

The highlights of this release are certainly the addition of pluggable discovery and the internal restructuring of the startup steps of the Arduino CLI. These affected the JSON output of some commands and the gRPC interface functions, which is documented in the upgrading guide.

We’re really excited about the release of the pluggable discovery. This new feature will give platform developers the possibility to support more and more boards (such as the Teensy), and also new ways of uploading to boards, like via WiFi, Bluetooth, SSH, CAN bus and anything that comes to mind! If you’re a platform developer and want to know how to start supporting pluggable discovery take a look at the updated platform specification documentation.

The internal restructuring is also no small thing, it makes the Arduino CLI much more resilient to errors. For example, if the user added an invalid or unreachable package index URL, Arduino CLI would previously be completely unusable. After this change, a warning is shown to notify the user of that failure and other functionality of Arduino CLI is unaffected. And last but not least this change greatly improves other tools as well, in some tests we managed to slice in half the startup time of the Arduino IDE 2.0!

There are some breaking changes that only affect those that use the Arduino CLI code as a Go library. These were the result of improvements to the internal structures that store information about Sketches, and to the support for different languages. 

As always, all breaking changes are documented in the upgrading guide. You will find the complete changelog here!

The post The new Arduino CLI 0.19.0 is out and better than ever! appeared first on Arduino Blog.

The Arduino CLI is an open source command line application written in Golang that can be used from a terminal to compile, verify and upload sketches to Arduino boards, and that’s capable of managing all the software and tools needed in the process. But don’t get fooled by its name: the Arduino CLI can do much more than the average console application, as shown by the Pro IDE and Arduino Create, which rely on it for similar purposes but each one in a completely different way from the other.

In this article, we introduce the three pillars of the Arduino CLI, explaining how we designed the software so that it can be effectively leveraged under different scenarios.

The first pillar: command line interface

Console applications for humans

As you might expect, the first way to use the Arduino CLI is from a terminal and by a human, and user experience plays a key role here. The UX is under a continuous improvement process as we want the tool to be powerful without being too complicated. We heavily rely on sub-commands to provide a rich set of different operations logically grouped together, so that users can easily explore the interface while getting very specific contextual help.

Console applications for robots

Humans are not the only type of customers we want to support and the Arduino CLI was also designed to be used programmatically — think about automation pipelines or a CI/CD system. 

There are some niceties to observe when you write software that’s supposed to be easy to run when unattended and one in particular is the ability to run without a configuration file. This is possible because every configuration option you find in the arduino-cli.yaml configuration file can be provided either through a command line flag or by setting an environment variable. To give an example, the following commands are all equivalent and will proceed fetching the unstable package index that can be used to work with experimental versions of cores: 

See the documentation for details about Arduino CLI’s configuration system.

Consistent with the previous paragraph, when it comes to providing output the Arduino CLI aims to be user friendly but also slightly verbose, something that doesn’t play well with robots. This is why we added an option to provide output that’s easy to parse. For example, the following figure shows what getting the software version in JSON format looks like.

Even if not related to software design, one last feature that’s worth mentioning is the availability of a one-line installation script that can be used to make the latest version of the Arduino CLI available on most systems with an HTTP client like curl or wget and a shell like bash.

The second pillar: gRPC interface

gRPC is a high-performance RPC framework that can efficiently connect client and server applications. The Arduino CLI can act as a gRPC server (we call it daemon mode), exposing a set of procedures that implement the very same set of features of the command line interface and waiting for clients to connect and use them. To give an idea, the following is some Golang code capable of retrieving the version number of a remote running Arduino CLI server instance:

gRPC is language-agnostic: even if the example is written in Golang, the programming language used for the client can be Python, JavaScript or any of the many supported ones, leading to a variety of possible scenarios. The new Arduino Pro IDE is a good example of how to leverage the daemon mode of the Arduino CLI with a clean separation of concerns: the Pro IDE knows nothing about how to download a core, compile a sketch or talk to an Arduino board and it demands all these features of an Arduino CLI instance. Conversely, the Arduino CLI doesn’t even know that the client that’s connected is the Pro IDE, and neither does it care.

The third pillar: embedding

The Arduino CLI is written in Golang and the code is organized in a way that makes it easy to use it as a library by including the modules you need in another Golang application at compile time. Both the first and second pillars rely on a common Golang API, a set of functions that abstract all the functionalities offered by the Arduino CLI, so that when we provide a fix or a new feature, they are automatically available to both the command line and gRPC interfaces. 

The source modules implementing this API can be imported in other Golang programs to embed a full-fledged Arduino CLI. For example, this is how some backend services powering Arduino Create can compile sketches and manage libraries. Just to give you a taste of what it means to embed the Arduino CLI, here is how to search for a core using the API:

Embedding the Arduino CLI is limited to Golang applications and requires a deep knowledge of its internals. For the average use case, the gRPC interface might be a better alternative; nevertheless this remains a valid option that we use and provide support for.

Conclusion

You can start playing with the Arduino CLI right away. The code is open source and we provide extensive documentation. The repo contains example code showing how to implement a gRPC client, and if you’re curious about how we designed the low-level API, have a look at the commands package and don’t hesitate to leave feedback on the issue tracker if you’ve got a use case that doesn’t fit one of the three pillars.

The arduino-cli tool just got some new exciting features with the release of 0.11.0:

  • Command-line completion
  • External programmer support
  • Internationalization and localization support (i18n)

Command-line completion

Finally, the autocompletion feature has landed!

With this functionality, the program automatically fills in partially typed commands by pressing the tab key. For example, with this update, you can type “arduino-cli bo”:

And, after pressing the <TAB> key, the command will auto-magically become: 

There are a few steps to follow in order to make it work seamlessly. We have to generate the required file — to do so, we have added a new command named “completion”. 

To generate the completion file, you can use:

By default, this command will print on the standard output (the shell window) the content of the completion file. To save to an actual file, use the “>” redirect symbol. Now you can move it to the required location (it depends on the shell you are using). Remember to open a new shell! Finally, you can press <TAB><TAB> to get the suggested command and flags.

In a future release, we will also be adding the completion for cores names, libraries, and boards.

Example with Bash (from the documentation)

To generate the completion file, use:

At this point, you can move that file in “/etc/bash_completion.d/” (root access is required) with:

A not recommended alternative is to source the completion file in `.bashrc`.

Remember to open a new shell to test the functionality.

External programmer

Another brand new feature is support for external programmers!

Now you can specify the external programmer to use when uploading code to a board. For example, you can use `arduino-cli upload …. –programmer programmer-id` for that. You can list the supported programmers with `arduino-cli upload –fqbn arduino:avr:uno –programmer list`.

And if you’re using the external programmer to burn a bootloader, you can do that from arduino-cli as well: `arduino-cli burn-bootloader –fqbn …`

Internationalization and localization support

Now the Arduino CLI messages can be translated to your native language thanks to i18n support! We are currently setting up the infrastructure; however, if you would like to help us with the translation, we will provide you more details in another blog post soon!

That’s all folks!

That’s it, we’ve worked hard to add these new features. Check them out by downloading 0.11.0 here. Do you like them? What are your thoughts on the arduino-cli? Are you using it for your projects? Let us know in the comments!

In our last post, we told you that the Arduino CLI’s primary goal is to provide a flexible yet simple command line tool with all the features and ease of use that made Arduino a successful platform, and enable users to find new ways of improving their workflows. 

The Arduino CLI is not just a command line tool, but contains all you need to build applications around the Arduino ecosystem.

For example, you can:

  • Parse the JSON output of the CLI and easily integrate it into your custom application.
  • Run the CLI as an always-on service that accepts commands via a gRPC interface using your language of choice.
  • Use the CLI in your Go application as a library.

In the video below, we’ll focus on how to start using the Arduino CLI in a terminal session. The tutorial will walk you through setting up all the required tools on your machine to the fastest way to compile and upload a sketch on your target board to allow quick iterations in developing your project with Arduinos.

The Arduino team has been working hard to support the needs of our professional developer community. Many of you requested a way to use our tools in Makefiles, and wanted Arduino IDE features available via a fast, clean command line interface.  How cool would it be to install project dependencies with:

arduino-cli lib install “WiFi101” “WiFi101OTA”

So that’s what we’ve done! To make it even cooler, most Arduino CLI commands have the option to output JSON for easy parsing by other programs:

arduino-cli –format json lib search wifinina

{“libraries”:[{“Name”:”WiFiNINA”,”Releases”:{“1.0.0”:{“Author”:”Arduino”,”Version”:”1.0.0″,”Maintainer”:”Arduino \u003cinfo@arduino.cc\u003e”,”Sentence”:”Enables network connection (local and Internet) with the Arduino MKR WiFi 1010, Arduino MKR VIDOR 4000 and Arduino UNO WiFi Rev.2.”,”Paragraph”:”With this library you can instantiate Servers, Clients and send/receive UDP packets through WiFi. The board can connect either to open or encrypted networks (WEP, WPA). The IP address can be assigned statically or through a DHCP. The library can also manage DNS.”,”Website”:”http://www.arduino.cc/en/Reference/WiFiNINA”,”Category”:”Communication”,”Architectures”:[“*”],”Types”:[“Arduino”],”Resource”:{“URL”:”http://downloads.arduino.cc/libraries/github.com/arduino-libraries/WiFiNINA-1.0.0.zip”,”ArchiveFileName”:”WiFiNINA-1.0.0.zip”,”Checksum”:”SHA-256:79f133fedf86411ca7add773a4293137dec057a3b8f1a7904db2d444ed8f4246″,”Size”:65651,”CachePath”:”libraries”}}}}]}

The other big news is you can run Arduino CLI on both ARM and Intel (x86, x86_64) architectures. This means you can install Arduino CLI on a Raspberry Pi or on your servers, and use it to compile Sketches targeting the board of your choice (Don’t forget you can also remotely manage your Linux device with Arduino Create Device Manager!)

Getting Started

This first release is an alpha, and we would like your feedback to help us improve it. You can download the Arduino CLI alpha preview binaries from:

Linux (64-bit): https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-linux64.tar.bz2

Linux (32-bit): https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-linux32.tar.bz2

Linux (ARM): https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-linuxarm.tar.bz2

OSX: https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-osx.zip

Windows: https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-windows.zip

Once you’ve installed Arduino CLI, you can try it out using our getting started guide: https://github.com/arduino/arduino-cli#getting-started

The Arduino CLI code repository is also available at: https://github.com/arduino/arduino-cli. As usual, it’s open source – but if you’re a company who wants to use it to create a customized tool, you can also contact us for a commercial license.

Integrate Arduino Support Into Your Preferred Platform

After we used Arduino CLI for awhile, we decided to make it the standard way our software communicates. Imagine having the Arduino IDE or Arduino Create Editor speaking directly to Arduino CLI – and you having full control of it. You will be able to compile on your machine or on our online servers, detect your board or create your own IDE on top of it!

We want you to be able to add Arduino support to whatever development flow you prefer. Whether you use Atom, Eclipse, Emacs, Vim, VSCode, or are even building your own tools, Arduino CLI makes this possible. Let us know what you think!

The Arduino team has been working hard to support the needs of our professional developer community. Many of you requested a way to use our tools in Makefiles, and wanted Arduino IDE features available via a fast, clean command line interface.  How cool would it be to install project dependencies with:

arduino-cli lib install “WiFi101” “WiFi101OTA”

So that’s what we’ve done! To make it even cooler, most Arduino CLI commands have the option to output JSON for easy parsing by other programs:

arduino-cli –format json lib search wifinina

{“libraries”:[{“Name”:”WiFiNINA”,”Releases”:{“1.0.0”:{“Author”:”Arduino”,”Version”:”1.0.0″,”Maintainer”:”Arduino \u003cinfo@arduino.cc\u003e”,”Sentence”:”Enables network connection (local and Internet) with the Arduino MKR WiFi 1010, Arduino MKR VIDOR 4000 and Arduino UNO WiFi Rev.2.”,”Paragraph”:”With this library you can instantiate Servers, Clients and send/receive UDP packets through WiFi. The board can connect either to open or encrypted networks (WEP, WPA). The IP address can be assigned statically or through a DHCP. The library can also manage DNS.”,”Website”:”http://www.arduino.cc/en/Reference/WiFiNINA”,”Category”:”Communication”,”Architectures”:[“*”],”Types”:[“Arduino”],”Resource”:{“URL”:”http://downloads.arduino.cc/libraries/github.com/arduino-libraries/WiFiNINA-1.0.0.zip”,”ArchiveFileName”:”WiFiNINA-1.0.0.zip”,”Checksum”:”SHA-256:79f133fedf86411ca7add773a4293137dec057a3b8f1a7904db2d444ed8f4246″,”Size”:65651,”CachePath”:”libraries”}}}}]}

The other big news is you can run Arduino CLI on both ARM and Intel (x86, x86_64) architectures. This means you can install Arduino CLI on a Raspberry Pi or on your servers, and use it to compile Sketches targeting the board of your choice (Don’t forget you can also remotely manage your Linux device with Arduino Create Device Manager!)

Getting Started

This first release is an alpha, and we would like your feedback to help us improve it. You can download the Arduino CLI alpha preview binaries from:

Linux (64-bit): https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-linux64.tar.bz2

Linux (32-bit): https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-linux32.tar.bz2

Linux (ARM): https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-linuxarm.tar.bz2

OSX: https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-osx.zip

Windows: https://downloads.arduino.cc/arduino-cli/0.1.0-alpha.preview/arduino-cli-0.1.0-alpha.preview-windows.zip

Once you’ve installed Arduino CLI, you can try it out using our getting started guide: https://github.com/arduino/arduino-cli#getting-started

The Arduino CLI code repository is also available at: https://github.com/arduino/arduino-cli. As usual, it’s open source – but if you’re a company who wants to use it to create a customized tool, you can also contact us for a commercial license.

Integrate Arduino Support Into Your Preferred Platform

After we used Arduino CLI for awhile, we decided to make it the standard way our software communicates. Imagine having the Arduino IDE or Arduino Create Editor speaking directly to Arduino CLI – and you having full control of it. You will be able to compile on your machine or on our online servers, detect your board or create your own IDE on top of it!

We want you to be able to add Arduino support to whatever development flow you prefer. Whether you use Atom, Eclipse, Emacs, Vim, VSCode, or are even building your own tools, Arduino CLI makes this possible. Let us know what you think!



  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook