Skip to content

Commit 4a84564

Browse files
committed
discovery: Timeout is now configurable
1 parent e50f391 commit 4a84564

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arduino/discovery/discovery.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Discovery struct {
3737
out io.ReadCloser
3838
outJSON *json.Decoder
3939
cmd *exec.Cmd
40+
Timeout time.Duration
4041
}
4142

4243
// BoardPort is a generic port descriptor
@@ -60,7 +61,7 @@ func NewFromCommandLine(args ...string) (*Discovery, error) {
6061
if err != nil {
6162
return nil, fmt.Errorf("creating discovery process: %s", err)
6263
}
63-
disc := &Discovery{}
64+
disc := &Discovery{Timeout: time.Second}
6465
disc.cmd = cmd
6566
return disc, nil
6667
}
@@ -95,7 +96,7 @@ func (d *Discovery) List() ([]*BoardPort, error) {
9596
go func() {
9697
select {
9798
case <-done:
98-
case <-time.After(5 * time.Second):
99+
case <-time.After(d.Timeout):
99100
timeout = true
100101
d.Close()
101102
}

0 commit comments

Comments
 (0)