Skip to content

Commit 15bf593

Browse files
authored
Merge pull request #217 from cmaglie/daemon
Daemon mode (GRPC) + pluggable discovery
2 parents 5358b8e + 59a4830 commit 15bf593

File tree

356 files changed

+175206
-2134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+175206
-2134
lines changed

Diff for: Gopkg.lock

+84-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Gopkg.toml

-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
branch = "master"
5252
name = "github.com/bgentry/go-netrc"
5353

54-
[[constraint]]
55-
name = "github.com/codeclysm/cc"
56-
version = "1.2.1"
57-
5854
[[constraint]]
5955
branch = "master"
6056
name = "github.com/mitchellh/go-homedir"

Diff for: README.md

+19-12
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Once downloaded, place the executable into a directory which is in your `PATH` e
3030

3131
### Build the latest "bleeding-edge" from source
3232

33-
* You should have a recent Go compiler installed.
34-
* Run `go get -u github.com/arduino/arduino-cli`
35-
* The `arduino-cli` executable will be produced in `$GOPATH/bin/arduino-cli`
33+
- You should have a recent Go compiler installed.
34+
- Run `go get -u github.com/arduino/arduino-cli`
35+
- The `arduino-cli` executable will be produced in `$GOPATH/bin/arduino-cli`
3636

3737
You may want to copy the executable into a directory which is in your `PATH` environment variable
3838
(such as `/usr/local/bin/`).
@@ -45,7 +45,8 @@ The Arduino CLI aims to replace the majority of features the Arduino IDE has wit
4545
## Getting Started
4646

4747
### Step 1. Create a new sketch
48-
The command will create a new empty sketch named MyFirstSketch in the default directory under $HOME/Arduino/
48+
49+
The command will create a new empty sketch named MyFirstSketch in the default directory under \$HOME/Arduino/
4950

5051
$ arduino-cli sketch new MyFirstSketch
5152
Sketch created in: /home/luca/Arduino/MyFirstSketch
@@ -58,6 +59,7 @@ The command will create a new empty sketch named MyFirstSketch in the default di
5859
}
5960

6061
### Step 2. Modify your sketch
62+
6163
Use your favourite file editor or IDE to modify the .ino file under: `$HOME/Arduino/MyFirstSketch/MyFirstSketch.ino`
6264
and change the file to look like this one:
6365

@@ -73,6 +75,7 @@ and change the file to look like this one:
7375
}
7476

7577
### Step 3. Connect the board to your PC
78+
7679
If you are running a fresh install of the arduino-cli you probably need to update the platform indexes by running:
7780

7881
$ arduino-cli core update-index
@@ -139,7 +142,6 @@ Now verify we have installed the core properly by running
139142
ID Installed Latest Name
140143
arduino:samd 1.6.19 1.6.19 Arduino SAMD Boards (32-bits ARM Cortex-M0+)
141144

142-
143145
We can finally check if the board is now recognized as a MKR1000
144146

145147
$ arduino-cli board list
@@ -162,25 +164,29 @@ Great! Now we have the Board FQBN (Fully Qualified Board Name) `arduino:samd:mkr
162164
and the Board Name look good, we are ready to compile and upload the sketch
163165

164166
#### Adding 3rd party cores
165-
To add 3rd party core packages add a link of the additional package to the file `arduino-cli.yaml`
167+
168+
To add 3rd party core packages add a link of the additional package to the file `arduino-cli.yaml`
166169

167170
If you want to add the ESP8266 core, for example:
168171

169172
board_manager:
170173
additional_urls:
171174
- http://arduino.esp8266.com/stable/package_esp8266com_index.json
175+
172176
And then run:
173-
177+
174178
arduino-cli core update-index
175179
arduino-cli core install esp8266:esp8266
176180

177181
### Step 5. Compile the sketch
182+
178183
To compile the sketch we have to run the `compile` command with the proper FQBN we just got in the previous command.
179184

180185
$ arduino-cli compile --fqbn arduino:samd:mkr1000 Arduino/MyFirstSketch
181186
Sketch uses 9600 bytes (3%) of program storage space. Maximum is 262144 bytes.
182187

183188
### Step 6. Upload your sketch
189+
184190
We can finally upload the sketch and see our board blinking, we now have to specify the serial port used by our board other than the FQBN:
185191

186192
$ arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:samd:mkr1000 Arduino/MyFirstSketch
@@ -216,6 +222,7 @@ We can finally upload the sketch and see our board blinking, we now have to spec
216222
CPU reset.
217223

218224
### Step 7. Add libraries
225+
219226
Now we can try to add a useful library to our sketch. We can at first look at the name of a library, our favourite one is the wifi101, here the command to get more info
220227

221228
$ arduino-cli lib search wifi101
@@ -250,6 +257,7 @@ We are now ready to install it! Please be sure to use the full name of the lib a
250257
## Inline Help
251258

252259
`arduino-cli` is a container of commands, to see the full list just run:
260+
253261
```bash
254262
$ arduino-cli
255263
Arduino Command Line Interface (arduino-cli).
@@ -295,7 +303,7 @@ Flags:
295303
-h, --help help for core
296304

297305
Global Flags:
298-
--config-file string The custom config file (if not specified the default one will be used). (example "/home/user/.config/arduino/arduino-cli/arduino-cli.yaml")
306+
--config-file string The custom config file (if not specified the default one will be used).
299307
--debug Enables debug output (super verbose, used to debug the CLI).
300308
--format string The output format, can be [text|json]. (default "text")
301309

@@ -318,11 +326,10 @@ Because:
318326

319327
#### What is the FQBN for ...?
320328

321-
* Arduino UNO: `arduino:avr:uno`
322-
* Arduino Mega: `arduino:avr:mega`
323-
* Arduino Nano: `arduino:avr:nano` or `arduino:avr:nano:cpu=atmega328old` if you have the old bootloader
329+
- Arduino UNO: `arduino:avr:uno`
330+
- Arduino Mega: `arduino:avr:mega`
331+
- Arduino Nano: `arduino:avr:nano` or `arduino:avr:nano:cpu=atmega328old` if you have the old bootloader
324332

325333
#### How can I find the core/FQBN for a board?
326334

327335
See: https://github.com/arduino/arduino-cli#step-4-find-and-install-the-right-core
328-

Diff for: arduino/cores/cores.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ package cores
2020
import (
2121
"strings"
2222

23-
"github.com/arduino/go-paths-helper"
23+
paths "github.com/arduino/go-paths-helper"
2424

2525
"github.com/arduino/arduino-cli/arduino/resources"
26-
"github.com/arduino/go-properties-orderedmap"
27-
"go.bug.st/relaxed-semver"
26+
properties "github.com/arduino/go-properties-orderedmap"
27+
semver "go.bug.st/relaxed-semver"
2828
)
2929

3030
// Platform represents a platform package.
@@ -158,7 +158,7 @@ func (platform *Platform) latestReleaseVersion() *semver.Version {
158158
func (platform *Platform) GetAllInstalled() []*PlatformRelease {
159159
res := []*PlatformRelease{}
160160
for _, release := range platform.Releases {
161-
if release.InstallDir != nil {
161+
if release.IsInstalled() {
162162
res = append(res, release)
163163
}
164164
}

Diff for: arduino/cores/packagemanager/identify.go

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* This file is part of arduino-cli.
3+
*
4+
* Copyright 2018 ARDUINO SA (http://www.arduino.cc/)
5+
*
6+
* This software is released under the GNU General Public License version 3,
7+
* which covers the main part of arduino-cli.
8+
* The terms of this license can be found at:
9+
* https://www.gnu.org/licenses/gpl-3.0.en.html
10+
*
11+
* You can be released from the requirements of the above licenses by purchasing
12+
* a commercial license. Buying such a license is mandatory if you want to modify or
13+
* otherwise use the software for commercial activities involving the Arduino
14+
* software without disclosing the source code of your own applications. To purchase
15+
* a commercial license, send an email to [email protected].
16+
*/
17+
18+
package packagemanager
19+
20+
import (
21+
"fmt"
22+
23+
"github.com/arduino/arduino-cli/arduino/cores"
24+
properties "github.com/arduino/go-properties-orderedmap"
25+
)
26+
27+
// IdentifyBoard returns a list of baords matching the provided identification properties.
28+
func (pm *PackageManager) IdentifyBoard(idProps *properties.Map) []*cores.Board {
29+
if idProps.Size() == 0 {
30+
return []*cores.Board{}
31+
}
32+
33+
checkSuffix := func(props *properties.Map, s string) (checked bool, found bool) {
34+
for k, v1 := range idProps.AsMap() {
35+
v2, ok := props.GetOk(k + s)
36+
if !ok {
37+
return false, false
38+
}
39+
if v1 != v2 {
40+
return true, false
41+
}
42+
}
43+
return false, true
44+
}
45+
46+
foundBoards := []*cores.Board{}
47+
for _, board := range pm.InstalledBoards() {
48+
if _, found := checkSuffix(board.Properties, ""); found {
49+
foundBoards = append(foundBoards, board)
50+
continue
51+
}
52+
id := 0
53+
for {
54+
again, found := checkSuffix(board.Properties, fmt.Sprintf(".%d", id))
55+
if found {
56+
foundBoards = append(foundBoards, board)
57+
}
58+
if !again {
59+
break
60+
}
61+
id++
62+
}
63+
}
64+
return foundBoards
65+
}

0 commit comments

Comments
 (0)