Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
27a91066
Unverified
Commit
27a91066
authored
Mar 06, 2020
by
Giampaolo Mancini
Committed by
GitHub
Mar 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read upload port from sketch.json (#454)
* Read upload port from sketch.json * Fix 'attach' help message
parent
d80f1199
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
3 deletions
+15
-3
arduino/sketches/sketches.go
arduino/sketches/sketches.go
+1
-0
cli/board/attach.go
cli/board/attach.go
+3
-3
commands/board/attach.go
commands/board/attach.go
+1
-0
commands/upload/upload.go
commands/upload/upload.go
+10
-0
No files found.
arduino/sketches/sketches.go
View file @
27a91066
...
...
@@ -38,6 +38,7 @@ type Metadata struct {
type
BoardMetadata
struct
{
Fqbn
string
`json:"fqbn,required"`
Name
string
`json:"name,omitempty"`
Port
string
`json:"port,omitepty"`
}
// NewSketchFromPath loads a sketch from the specified path
...
...
cli/board/attach.go
View file @
27a91066
...
...
@@ -35,14 +35,14 @@ func initAttachCommand() *cobra.Command {
Use
:
"attach <port>|<FQBN> [sketchPath]"
,
Short
:
"Attaches a sketch to a board."
,
Long
:
"Attaches a sketch to a board."
,
Example
:
" "
+
os
.
Args
[
0
]
+
" board attach serial:///dev/tty
/
ACM0
\n
"
+
" "
+
os
.
Args
[
0
]
+
" board attach serial:///dev/tty
/
ACM0 HelloWorld
\n
"
+
Example
:
" "
+
os
.
Args
[
0
]
+
" board attach serial:///dev/ttyACM0
\n
"
+
" "
+
os
.
Args
[
0
]
+
" board attach serial:///dev/ttyACM0 HelloWorld
\n
"
+
" "
+
os
.
Args
[
0
]
+
" board attach arduino:samd:mkr1000"
,
Args
:
cobra
.
RangeArgs
(
1
,
2
),
Run
:
runAttachCommand
,
}
attachCommand
.
Flags
()
.
StringVar
(
&
attachFlags
.
searchTimeout
,
"timeout"
,
"5s"
,
"The
timeout of the search of connected devices, try to high it if your board is not found
(e.g. to 10s)."
)
"The
connected devices search timeout, raise it if your board doesn't show up
(e.g. to 10s)."
)
return
attachCommand
}
...
...
commands/board/attach.go
View file @
27a91066
...
...
@@ -96,6 +96,7 @@ func Attach(ctx context.Context, req *rpc.BoardAttachReq, taskCB commands.TaskPr
sketch
.
Metadata
.
CPU
=
sketches
.
BoardMetadata
{
Fqbn
:
board
.
FQBN
(),
Name
:
board
.
Name
(),
Port
:
deviceURI
.
String
(),
}
}
...
...
commands/upload/upload.go
View file @
27a91066
...
...
@@ -19,6 +19,7 @@ import (
"context"
"fmt"
"io"
"net/url"
"os"
"path/filepath"
"strings"
...
...
@@ -53,6 +54,15 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
// FIXME: make a specification on how a port is specified via command line
port
:=
req
.
GetPort
()
if
port
==
""
&&
sketch
!=
nil
&&
sketch
.
Metadata
!=
nil
{
deviceURI
,
err
:=
url
.
Parse
(
sketch
.
Metadata
.
CPU
.
Port
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid Device URL format: %s"
,
err
)
}
if
deviceURI
.
Scheme
==
"serial"
{
port
=
deviceURI
.
Host
+
deviceURI
.
Path
}
}
if
port
==
""
{
return
nil
,
fmt
.
Errorf
(
"no upload port provided"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment