Skip to content

Commit c2363f2

Browse files
authored
Merge pull request #264 from arduino/remove_verbose_resolve
removed verbose options in commandline resolve, improved doc
2 parents eb07e84 + 2dd8b1c commit c2363f2

File tree

6 files changed

+42
-42
lines changed

6 files changed

+42
-42
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
12

23
arduino-create-agent
34
====================
@@ -242,7 +243,7 @@ You will receive an object of all the boards connected with USB or over the netw
242243
}
243244
```
244245

245-
## Open/Close ports
246+
### Open/Close ports
246247

247248
To read input from a board connected to USB you must first open the port with the command
248249

@@ -350,7 +351,7 @@ The payload is a json object that looks like this:
350351
{
351352
"board":"arduino:avr:leonardo",
352353
"port":"/dev/ttyACM1",
353-
"commandline":"\"{runtime.tools.avrdude.path}/bin/avrdude\" \"-C{runtime.tools.avrdude.path}/etc/avrdude.conf\" {upload.verbose} -patmega32u4 -cavr109 -P{serial.port} -b57600 -D \"-Uflash:w:{build.path}/{build.project_name}.hex:i\"",
354+
"commandline":"\"{runtime.tools.avrdude.path}/bin/avrdude\" \"-C{runtime.tools.avrdude.path}/etc/avrdude.conf\" -v -patmega32u4 -cavr109 -P{serial.port} -b57600 -D \"-Uflash:w:{build.path}/{build.project_name}.hex:i\"",
354355
"signature":"97db97ced2c",
355356
"hex":"OjEwMDAwMDAwMEM5NEU1MDAwQzk0MEQwMTBDOTQwRDAxMEM5NDBEMDE2MQ0KOjEwMDAxMDAwMEM5NDBEMDEwQzk0M",
356357
"filename":"Blink.ino.hex",
@@ -365,16 +366,13 @@ The payload is a json object that looks like this:
365366
"wait_for_upload_port":true,
366367
"use_1200bps_touch":true,
367368
"network":false,
368-
"params_verbose":"-v",
369-
"params_quiet":"-q -q",
370-
"verbose":true
371369
}
372370
}
373371
```
374372

375373
- commandline is the command to execute to perform the upload. This is, for example, avrdude on a Leonardo.
376374

377-
- hex contains the sketch hex encoded in base64
375+
- hex contains the sketch binary encoded in base64 (could decode in Intel hex or raw binary)
378376

379377
- signature is the signature of the commandline signed with the private key that matches the public key contained in the config.ini of the arduino-create-agent
380378

@@ -386,6 +384,10 @@ The results of the upload will be delivered via websocket with messages that loo
386384
{"Flash":"Ok","ProgrammerStatus":"Done"}
387385
```
388386

387+
### Javacript client library
388+
389+
You can install the [arduino-create-agent-js-client](https://github.com/arduino/arduino-create-agent-js-client) in your client application
390+
389391
---
390392

391393
## Development

conn.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type Upload struct {
7070
ExtraFiles []AdditionalFile `json:"extrafiles"`
7171
}
7272

73-
var uploadStatusStr string = "ProgrammerStatus"
73+
var uploadStatusStr = "ProgrammerStatus"
7474

7575
func uploadHandler(c *gin.Context) {
7676

@@ -156,7 +156,7 @@ func uploadHandler(c *gin.Context) {
156156
return
157157
}
158158

159-
l := PLogger{Verbose: data.Extra.Verbose}
159+
l := PLogger{Verbose: true}
160160

161161
// Upload
162162
if data.Extra.Network {
@@ -183,7 +183,7 @@ type PLogger struct {
183183
Verbose bool
184184
}
185185

186-
// Debug only sends messages if verbose is true
186+
// Debug only sends messages if verbose is true (always true for now)
187187
func (l PLogger) Debug(args ...interface{}) {
188188
if l.Verbose {
189189
l.Info(args...)

upload/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ type Extra struct {
113113
WaitForUploadPort bool `json:"wait_for_upload_port"`
114114
Network bool `json:"network"`
115115
Auth Auth `json:"auth"`
116-
Verbose bool `json:"verbose"`
117-
ParamsVerbose string `json:"params_verbose"`
118-
ParamsQuiet string `json:"params_quiet"`
119116
}
120117
```
121118
Extra contains some options used during the upload

upload/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// commandline = upload.Resolve("/dev/ttyACM0", "arduino:avr:leonardo", "./sketch.hex", commandline, upload.Extra{}, t)
3232
// ```
3333
//
34-
// t must implement the locater interface (the Tools package does!)
34+
// 't' must implement the locater interface (the Tools package does!)
3535
//
3636
// **Logging**
3737
// If you're interested in the output of the commands, you can implement the logger interface. Here's an example:

upload/upload.go

+5-14
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ type Auth struct {
3939

4040
// Extra contains some options used during the upload
4141
type Extra struct {
42-
Use1200bpsTouch bool `json:"use_1200bps_touch"`
43-
WaitForUploadPort bool `json:"wait_for_upload_port"`
44-
Network bool `json:"network"`
45-
Auth Auth `json:"auth"`
46-
Verbose bool `json:"verbose"`
47-
ParamsVerbose string `json:"params_verbose"`
48-
ParamsQuiet string `json:"params_quiet"`
49-
SSH bool `json:"ssh,omitempty"`
42+
Use1200bpsTouch bool `json:"use_1200bps_touch"`
43+
WaitForUploadPort bool `json:"wait_for_upload_port"`
44+
Network bool `json:"network"`
45+
Auth Auth `json:"auth"`
46+
SSH bool `json:"ssh,omitempty"`
5047
}
5148

5249
// PartiallyResolve replaces some symbols in the commandline with the appropriate values
@@ -57,12 +54,6 @@ func PartiallyResolve(board, file, platformPath, commandline string, extra Extra
5754
commandline = strings.Replace(commandline, "{network.password}", extra.Auth.Password, -1)
5855
commandline = strings.Replace(commandline, "{runtime.platform.path}", filepath.ToSlash(platformPath), -1)
5956

60-
if extra.Verbose == true {
61-
commandline = strings.Replace(commandline, "{upload.verbose}", extra.ParamsVerbose, -1)
62-
} else {
63-
commandline = strings.Replace(commandline, "{upload.verbose}", extra.ParamsQuiet, -1)
64-
}
65-
6657
// search for runtime variables and replace with values from Locater
6758
var runtimeRe = regexp.MustCompile("\\{(.*?)\\}")
6859
runtimeVars := runtimeRe.FindAllString(commandline, -1)

upload/upload_test.go

+25-15
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,23 @@ var TestNetworkData = []struct {
4545
Name string
4646
Port string
4747
Board string
48-
File string
48+
Files []string
4949
Commandline string
50-
Auth upload.Auth
50+
Extra upload.Extra
5151
}{
5252
{
53-
"yun", "", "", "",
54-
``, upload.Auth{}},
53+
"yun",
54+
"",
55+
"",
56+
[]string{"filename"},
57+
"",
58+
upload.Extra{
59+
Use1200bpsTouch: true,
60+
WaitForUploadPort: true,
61+
Network: true,
62+
Auth: upload.Auth{},
63+
},
64+
},
5565
}
5666

5767
func TestNetwork(t *testing.T) {
@@ -62,27 +72,27 @@ func TestNetwork(t *testing.T) {
6272

6373
for _, test := range TestNetworkData {
6474
commandline := strings.Replace(test.Commandline, "$HOME", home, -1)
65-
err := upload.Network(test.Port, test.Board, test.File, commandline, test.Auth, logger)
75+
err := upload.Network(test.Port, test.Board, test.Files, commandline, test.Extra.Auth, logger, test.Extra.SSH)
6676
log.Println(err)
6777
}
6878
}
6979

7080
var TestResolveData = []struct {
71-
Port string
72-
Board string
73-
File string
74-
Commandline string
75-
Extra upload.Extra
76-
Result string
81+
Board string
82+
File string
83+
PlatformPath string
84+
Commandline string
85+
Extra upload.Extra
86+
Result string
7787
}{
78-
{"/dev/ttyACM0", "arduino:avr:leonardo", "./upload_test.hex",
79-
`"{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" {upload.verbose} {upload.verify} -patmega32u4 -cavr109 -P{serial.port} -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`, upload.Extra{Use1200bpsTouch: true, WaitForUploadPort: true},
80-
`"$loc$loc{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" $loc{upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:./upload_test.hex:i"`},
88+
{"arduino:avr:leonardo", "./upload_test.hex", "",
89+
`"{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" -v {upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`, upload.Extra{Use1200bpsTouch: true, WaitForUploadPort: true},
90+
`"$loc$loc{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" -v $loc{upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:./upload_test.hex:i"`},
8191
}
8292

8393
func TestResolve(t *testing.T) {
8494
for _, test := range TestResolveData {
85-
result, _ := upload.Resolve(test.Port, test.Board, test.File, test.Commandline, test.Extra, mockTools{})
95+
result, _ := upload.PartiallyResolve(test.Board, test.File, test.PlatformPath, test.Commandline, test.Extra, mockTools{})
8696
if result != test.Result {
8797
t.Error("expected " + test.Result + ", got " + result)
8898
continue

0 commit comments

Comments
 (0)