Skip to content

add rts/cts flow-control support #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type Mode struct {
Parity Parity // Parity (see Parity type for more info)
StopBits StopBits // Stop bits (see StopBits type for more info)
InitialStatusBits *ModemOutputBits // Initial output modem bits status (if nil defaults to DTR=true and RTS=true)
RTSCTSFlowControl bool // Enable RTS/CTS hardware flow control
}

// Parity describes a serial port parity setting
Expand Down
4 changes: 2 additions & 2 deletions serial_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ func nativeOpen(portName string, mode *Mode) (*unixPort, error) {
// Set raw mode
setRawMode(settings)

// Explicitly disable RTS/CTS flow control
setTermSettingsCtsRts(false, settings)
// Explicitly enable/disable RTS/CTS flow control
setTermSettingsCtsRts(mode.RTSCTSFlowControl, settings)

if err = port.setTermSettings(settings); err != nil {
port.Close()
Expand Down
8 changes: 7 additions & 1 deletion serial_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,13 @@ func nativeOpen(portName string, mode *Mode) (*windowsPort, error) {
params.Flags |= windows.RTS_CONTROL_ENABLE
}
}
params.Flags &^= dcbOutXCTSFlow

if mode.RTSCTSFlowControl {
params.Flags |= dcbOutXCTSFlow
} else {
params.Flags &^= dcbOutXCTSFlow
}

params.Flags &^= dcbOutXDSRFlow
params.Flags &^= dcbDSRSensitivity
params.Flags |= dcbTXContinueOnXOFF
Expand Down