Skip to content

Commit 0d1bbac

Browse files
committed
if 1200bps touch is ineffective, use the original port to upload
1 parent cf0e029 commit 0d1bbac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

upload/upload.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func reset(port string, wait bool, l Logger) (string, error) {
160160

161161
// Wait for port to disappear and reappear
162162
if wait {
163-
port = waitReset(ports, l)
163+
port = waitReset(ports, l, port)
164164
}
165165

166166
return port, nil
@@ -192,7 +192,7 @@ func touchSerialPortAt1200bps(port string, l Logger) error {
192192
// waitReset is meant to be called just after a reset. It watches the ports connected
193193
// to the machine until a port disappears and reappears. The port name could be different
194194
// so it returns the name of the new port.
195-
func waitReset(beforeReset []string, l Logger) string {
195+
func waitReset(beforeReset []string, l Logger, originalPort string) string {
196196
var port string
197197
timeout := false
198198

@@ -237,6 +237,11 @@ func waitReset(beforeReset []string, l Logger) string {
237237
time.Sleep(time.Millisecond * 100)
238238
}
239239

240+
// try to upload on the existing port if the touch was ineffective
241+
if port == "" {
242+
port = originalPort
243+
}
244+
240245
return port
241246
}
242247

0 commit comments

Comments
 (0)