JS-wrapper over arduino-cli
npm install arduino-cliA javascript wrapper over the arduino-cli tool
Works on Arduino-cli 0.3.1-alpha.preview
1. Install it with npm install -S arduino-cli or yarn add arduino-cli;
2. Require in the code import arduinoCli from 'arduino-cli';
3. Create an instance and pass the path to the installed arduino-cli and config:
``js`
const cli = arduinoCli('/bin/arduino-cli', {
directories: {
user: '~/arduino-cli/sketches',
data: '~/arduino-cli/data',
},
});
arduino-cli
It will create a config file for the in your OS temp directory and pass it to any command you'll call later.`
4. Then you can run commands, like this:
js`
cli.version().then(console.log); // "0.2.1-alpha.preview"
All commands runs asynchronously, so methods return Promises.
Returns the version of arduino-cli. Wraps arduino-cli version.
* Returns Promise
Returns the current config of arduino-cli as a plain JS object. Wraps arduino-cli config dump.
* Returns Promise
Replaces old config with the new one.
Accepts:
* newConfig
* Returns
A wrapper with a custom extension over arduino-cli board list.
_Custom extension may be removed in the future. See issue #45_
Returns a plain JS object which describes boards connected through serial ports. Also, it extends boards' FQBN with cpu option from boards.txt if a board is identified (a package installed) and has some options. For example, Arduino Nano will be transformed into three items with a modified FQBN and name.
* Returns Promise
A wrapper with a custom extension over arduino-cli board listall.
_Custom extension may be removed in the future. See issue #45_
Returns a plain JS object with boards, whose packages are installed. Also, it extends boards' FQBN with cpu option from boards.txt if a board is identified (a package installed) and it has some options. For example, Arduino Nano will be transformed into three items with a modified FQBN and name.
* Returns Promise
Returns a list of all boards that found in all package_*_index.json files.
* Returns Promise
Sets a list of additional package index urls into the config file. Later you can download and install packages with arduino-cli (call core.updateIndex()).
Accepts:
urls — List of URLs of the third-party package_ files
* Returns Promise with just added URLs
Wraps arduino-cli core download packageName. Downloads core and tool archives for the specified package.
Accepts:
* progressCallback — A function that will be called on progress with one argument . See details below.packageName
* — A package and architecture to download. May contain a version. For example, arduino:avr or arduino:avr@1.6.9
* Returns Promise — log
Wraps arduino-cli core install packageName. Downloads and installs core and tool archives for the specified package.
Accepts:
* progressCallback — A function that will be called on progress with one argument . See details below.packageName
* — A package and architecture to install. May contain a version. For example, arduino:avr or arduino:avr@1.6.9
* Returns Promise — log
Wraps arduino-cli core list. Returns a list of installed packages.
* Returns Promise
Wraps arduino-cli core search query. Returns a list of packages found.
Accepts:
* query — A search query
* Returns Promise
Wraps arduino-cli core uninstall packageName. Uninstalls the core and tools for the specified package.
Accepts:
* packageName — A package identifier, like arduino:samd
* Returns Promise — a log
Wraps arduino-cli core update-index. Downloads the original package_index.json and additional package index files.
* Returns Promise — a log
Wraps arduino-cli sketch new sketchName. Creates an empty sketchName/sketchName.ino inside the sketchbook directory.
* Returns Promise — a full path to the created .ino file
Wraps arduino-cli compile. Compiles the sketch for the specified board.
Accepts:
* onProgress — A function that is called on new data in stdoutfqbn
* — A fully-qualified board name. Like arduino:avr:mega:cpu=atmega2560sketchName
* — A name of the sketch in the sketchbook directory. It can contain sketch name or full path to the sketch.verbose
* — Verbose output. By default is false
* Returns Promise with a log of the compilation process
Wraps arduino-cli upload. Uploads the compiled sketch onto the board.
Accepts:
* onProgress — A function that is called on new data in stdout with a single argumentport
* — A port name (e.g., COM3 or /dev/tty.usbmodem1411)fqbn
* — A fully-qualified board name. Like arduino:avr:mega:cpu=atmega2560sketchName
* — A name of the sketch in the sketchbook directory. It can contain sketch name or full path to the sketch.verbose
* — Verbose output. By default is false
* Returns Promise with a log of the upload process
Returns a list of running arduino-cli processes.
* Returns Array
Kills all running arduino-cli processes.
* Returns Boolean true
* name — A board name with an added cpu option, if it exists For example, "Arduino/Genuino Uno" or "Arduino/Genuino Mega2560 (ATmega2560 (Mega 2560))"fqbn
* — A fully-qualified board name For example, arduino:avr:uno or arduino:avr:mega2560:cpu=atmega2560port
* — A port name. Like /dev/tty.usbmodem1411usbID
* String — An ID of the board (VID, PID). For example, 2341:0042
* name — A board name E.G. "Arduino/Genuino Uno" or "Arduino/Genuino Mega2560"fqbn
* — A fully-qualified board name E.G. "arduino:avr:uno" or "arduino:avr:mega2560"options
* — a list of options for this board
Object, that represents one group of the board option. For example, CPU Frequency.
* optionName — A human-readable name of the option group ("CPU Frequency")optionId
* — An id of the option from boards.txt. E.G. CpuFrequencyvalues
* — a list of option values, that represented as objects with two fieldsname
* — A human-readable option name ("80 MHz")value
* — A value, that will be used by tools. ("80")
* name — A board name (e.g., "Arduino/Genuino Mega2560")package
* — A package and architecture, that could be used in the core.install command. For example, arduino:avrpackageName
* — A human-readable architecture name. Like "Arduino AVR Boards"version
* — A Semver of the latest architecture for this board (e.g., 1.6.21)
* message — A progress message from stdout of the arduino-cli. In case that there is a downloading process that shows progress bar, it will be null, because this type of progress should notify only about a percentage.percentage
* — A number in the range [0.00...100.00]estimated
* — An estimated time in the format 3m52s or unknown
* ID — A package identifier in format package:architecture (e.g., arduino:avr)Installed
* — A version of the installed packageLatest
* — A version of the latest packageName
* — A human-readable name of the architecture
* ID — A package identifier in format package:architecture (e.g., arduino:avr)Version
* — A version of the latest packageInstalled
* — Equals "Yes" if the package is installed, otherwise "No"Name
*