Skip to content

Commit d70590f

Browse files
authored
Merge pull request #32 from arduino/cleanup_buffers
Cleanup IO buffers after opening the serial port
2 parents 2639c59 + c28e1a0 commit d70590f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

main.go

+5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ func (d *SerialMonitor) Open(boardPort string) (io.ReadWriter, error) {
156156
if err != nil {
157157
return nil, err
158158
}
159+
160+
// Clean up residual data in IO buffers
161+
_ = serialPort.ResetInputBuffer() // do not error if resetting buffers fails
162+
_ = serialPort.ResetOutputBuffer()
163+
159164
d.openedPort = true
160165
d.serialPort = serialPort
161166
return d.serialPort, nil

0 commit comments

Comments
 (0)