mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
flash: retry 3 times when attempting to reset the serial port
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
@@ -473,16 +473,22 @@ func Run(pkgName string, options *compileopts.Options) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func touchSerialPortAt1200bps(port string) error {
|
func touchSerialPortAt1200bps(port string) (err error) {
|
||||||
// Open port
|
retryCount := 3
|
||||||
p, err := serial.Open(port, &serial.Mode{BaudRate: 1200})
|
for i := 0; i < retryCount; i++ {
|
||||||
if err != nil {
|
// Open port
|
||||||
return fmt.Errorf("opening port: %s", err)
|
p, e := serial.Open(port, &serial.Mode{BaudRate: 1200})
|
||||||
}
|
if e != nil {
|
||||||
defer p.Close()
|
time.Sleep(1 * time.Second)
|
||||||
|
err = e
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
defer p.Close()
|
||||||
|
|
||||||
p.SetDTR(false)
|
p.SetDTR(false)
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("opening port: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func flashUF2UsingMSD(volume, tmppath string) error {
|
func flashUF2UsingMSD(volume, tmppath string) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user