Allow to set initial RTS and DTR state after connect
This commit is contained in:
committed by
Cristian Maglie
parent
7ca3f7d1cd
commit
980038c3ea
@@ -78,6 +78,8 @@ type Mode struct {
|
|||||||
DataBits int // Size of the character (must be 5, 6, 7 or 8)
|
DataBits int // Size of the character (must be 5, 6, 7 or 8)
|
||||||
Parity Parity // Parity (see Parity type for more info)
|
Parity Parity // Parity (see Parity type for more info)
|
||||||
StopBits StopBits // Stop bits (see StopBits type for more info)
|
StopBits StopBits // Stop bits (see StopBits type for more info)
|
||||||
|
InitialRTS bool // Initial state for RTS
|
||||||
|
InitialDTR bool // Initial state for DTR
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parity describes a serial port parity setting
|
// Parity describes a serial port parity setting
|
||||||
|
|||||||
@@ -235,6 +235,9 @@ func nativeOpen(portName string, mode *Mode) (*unixPort, error) {
|
|||||||
// Explicitly disable RTS/CTS flow control
|
// Explicitly disable RTS/CTS flow control
|
||||||
setTermSettingsCtsRts(false, settings)
|
setTermSettingsCtsRts(false, settings)
|
||||||
|
|
||||||
|
port.SetDTR(mode.InitialDTR)
|
||||||
|
port.SetRTS(mode.InitialRTS)
|
||||||
|
|
||||||
if port.setTermSettings(settings) != nil {
|
if port.setTermSettings(settings) != nil {
|
||||||
port.Close()
|
port.Close()
|
||||||
return nil, &PortError{code: InvalidSerialPort}
|
return nil, &PortError{code: InvalidSerialPort}
|
||||||
|
|||||||
@@ -451,9 +451,13 @@ func nativeOpen(portName string, mode *Mode) (*windowsPort, error) {
|
|||||||
return nil, &PortError{code: InvalidSerialPort}
|
return nil, &PortError{code: InvalidSerialPort}
|
||||||
}
|
}
|
||||||
params.Flags &= dcbRTSControlDisbaleMask
|
params.Flags &= dcbRTSControlDisbaleMask
|
||||||
|
if mode.InitialRTS {
|
||||||
params.Flags |= dcbRTSControlEnable
|
params.Flags |= dcbRTSControlEnable
|
||||||
|
}
|
||||||
params.Flags &= dcbDTRControlDisableMask
|
params.Flags &= dcbDTRControlDisableMask
|
||||||
|
if mode.InitialDTR {
|
||||||
params.Flags |= dcbDTRControlEnable
|
params.Flags |= dcbDTRControlEnable
|
||||||
|
}
|
||||||
params.Flags &^= dcbOutXCTSFlow
|
params.Flags &^= dcbOutXCTSFlow
|
||||||
params.Flags &^= dcbOutXDSRFlow
|
params.Flags &^= dcbOutXDSRFlow
|
||||||
params.Flags &^= dcbDSRSensitivity
|
params.Flags &^= dcbDSRSensitivity
|
||||||
|
|||||||
Reference in New Issue
Block a user