aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authordeadprogram <[email protected]>2022-12-18 20:22:54 +0100
committerRon Evans <[email protected]>2022-12-19 08:44:39 +0100
commitc5c6464175652252ef73ea7878e1c9dbee8482d6 (patch)
treeb48ecd016414925d38ce465a99aec85eae9d1af0 /main.go
parentc90ff1e1cff3eff931728f750e09a11d4949139d (diff)
downloadtinygo-c5c6464175652252ef73ea7878e1c9dbee8482d6.tar.gz
tinygo-c5c6464175652252ef73ea7878e1c9dbee8482d6.zip
compileopts: replace 'retries' with more correct 'timeout' param
Signed-off-by: deadprogram <[email protected]>
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/main.go b/main.go
index 8f57b22ed..d820cb1ff 100644
--- a/main.go
+++ b/main.go
@@ -949,7 +949,7 @@ func flashUF2UsingMSD(volume, tmppath string, options *compileopts.Options) erro
infoPath = path + "/INFO_UF2.TXT"
}
- d, err := locateDevice(volume, infoPath, options.Retries)
+ d, err := locateDevice(volume, infoPath, options.Timeout)
if err != nil {
return err
}
@@ -978,7 +978,7 @@ func flashHexUsingMSD(volume, tmppath string, options *compileopts.Options) erro
destPath = path + "/"
}
- d, err := locateDevice(volume, destPath, options.Retries)
+ d, err := locateDevice(volume, destPath, options.Timeout)
if err != nil {
return err
}
@@ -986,10 +986,10 @@ func flashHexUsingMSD(volume, tmppath string, options *compileopts.Options) erro
return moveFile(tmppath, d+"/flash.hex")
}
-func locateDevice(volume, path string, maxRetries int) (string, error) {
+func locateDevice(volume, path string, timeout time.Duration) (string, error) {
var d []string
var err error
- for i := 0; i < maxRetries; i++ {
+ for start := time.Now(); time.Since(start) < timeout; {
d, err = filepath.Glob(path)
if err != nil {
return "", err
@@ -1396,7 +1396,7 @@ func main() {
ocdCommandsString := flag.String("ocd-commands", "", "OpenOCD commands, overriding target spec (can specify multiple separated by commas)")
ocdOutput := flag.Bool("ocd-output", false, "print OCD daemon output during debug")
port := flag.String("port", "", "flash port (can specify multiple candidates separated by commas)")
- maxRetries := flag.Int("retries", 10, "the maximum number of times to retry locating the MSD volume to be used for flashing")
+ timeout := flag.Duration("timeout", 20*time.Second, "the length of time to retry locating the MSD volume to be used for flashing")
programmer := flag.String("programmer", "", "which hardware programmer to use")
ldflags := flag.String("ldflags", "", "Go link tool compatible ldflags")
llvmFeatures := flag.String("llvm-features", "", "comma separated LLVM features to enable")
@@ -1493,7 +1493,7 @@ func main() {
PrintJSON: flagJSON,
Monitor: *monitor,
BaudRate: *baudrate,
- Retries: *maxRetries,
+ Timeout: *timeout,
}
if *printCommands {
options.PrintCommands = printCommand