Skip to content

Commit 347bfeb

Browse files
committed
Disable DTR clearing on 1200-bps touch (only on Windows) (#2234)
The reason why it was originally introduced: arduino/Arduino@a6909bd Why we are removing it now? * Windows does preserve the state of the RTS/DTR bits on successive opening of the serial port. * The serial library used in the Arduino IDE 1.8.x has a bug when trying to set DTR=false, on successive opening of the port the DTR line is set back high by the USB serial driver. This works differently from the serial library we use in the Arduino CLI, that sets DTR=false for good and this change is preserved on the successive opening of the port. * Having the serial port left in a state with DTR=false may cause problems to tools uploading later. It may probably completely removed, but for now, to reduce the testing surface, it will be disabled only for Windows.
1 parent ca60d4b commit 347bfeb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: arduino/serialutils/serialutils.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package serialutils
1717

1818
import (
1919
"fmt"
20+
"runtime"
2021
"strings"
2122
"time"
2223

@@ -37,10 +38,15 @@ func TouchSerialPortAt1200bps(port string) error {
3738
return errors.WithMessage(err, tr("opening port at 1200bps"))
3839
}
3940

40-
// Set DTR to false
41-
if err = p.SetDTR(false); err != nil {
42-
p.Close()
43-
return errors.WithMessage(err, tr("setting DTR to OFF"))
41+
if runtime.GOOS != "windows" {
42+
// This is not required on Windows
43+
// TODO: Investigate if it can be removed for other OS too
44+
45+
// Set DTR to false
46+
if err = p.SetDTR(false); err != nil {
47+
p.Close()
48+
return errors.WithMessage(err, tr("setting DTR to OFF"))
49+
}
4450
}
4551

4652
// Close serial port

0 commit comments

Comments
 (0)