Skip to content

Commit e354653

Browse files
author
Stefania
committed
removed verbose options in commandline resolve, improved doc
Signed-off-by: Stefania <[email protected]>
1 parent 549558c commit e354653

File tree

6 files changed

+41
-42
lines changed

6 files changed

+41
-42
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ You will receive an object of all the boards connected with USB or over the netw
232232
}
233233
```
234234

235-
## Open/Close ports
235+
### Open/Close ports
236236

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

@@ -340,7 +340,7 @@ The payload is a json object that looks like this:
340340
{
341341
"board":"arduino:avr:leonardo",
342342
"port":"/dev/ttyACM1",
343-
"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\"",
343+
"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\"",
344344
"signature":"97db97ced2c",
345345
"hex":"OjEwMDAwMDAwMEM5NEU1MDAwQzk0MEQwMTBDOTQwRDAxMEM5NDBEMDE2MQ0KOjEwMDAxMDAwMEM5NDBEMDEwQzk0M",
346346
"filename":"Blink.ino.hex",
@@ -355,16 +355,13 @@ The payload is a json object that looks like this:
355355
"wait_for_upload_port":true,
356356
"use_1200bps_touch":true,
357357
"network":false,
358-
"params_verbose":"-v",
359-
"params_quiet":"-q -q",
360-
"verbose":true
361358
}
362359
}
363360
```
364361

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

367-
- hex contains the sketch hex encoded in base64
364+
- hex contains the sketch binary encoded in base64 (could decode in Intel hex or raw binary)
368365

369366
- 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
370367

@@ -376,6 +373,10 @@ The results of the upload will be delivered via websocket with messages that loo
376373
{"Flash":"Ok","ProgrammerStatus":"Done"}
377374
```
378375

376+
### Javacript client library
377+
378+
You can install the [arduino-create-agent-js-client](https://github.com/arduino/arduino-create-agent-js-client) in your client application
379+
379380
---
380381

381382
## 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)