Skip to content
Merged
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
18 changes: 13 additions & 5 deletions serial_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,22 @@ func (port *windowsPort) SetRTS(rts bool) error {
}

func (port *windowsPort) GetModemStatusBits() (*ModemStatusBits, error) {
// GetCommModemStatus constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcommmodemstatus.
const (
MS_CTS_ON = 0x0010
MS_DSR_ON = 0x0020
MS_RING_ON = 0x0040
MS_RLSD_ON = 0x0080
)
var bits uint32
if err := windows.GetCommModemStatus(port.handle, &bits); err != nil {
return nil, &PortError{}
}
return &ModemStatusBits{
CTS: (bits & windows.EV_CTS) != 0,
DCD: (bits & windows.EV_RLSD) != 0,
DSR: (bits & windows.EV_DSR) != 0,
RI: (bits & windows.EV_RING) != 0,
CTS: (bits & MS_CTS_ON) != 0,
DCD: (bits & MS_RLSD_ON) != 0,
DSR: (bits & MS_DSR_ON) != 0,
RI: (bits & MS_RING_ON) != 0,
}, nil
}

Expand Down Expand Up @@ -366,7 +373,8 @@ func nativeOpen(portName string, mode *Mode) (*windowsPort, error) {
0, nil,
windows.OPEN_EXISTING,
windows.FILE_FLAG_OVERLAPPED,
0)
0,
)
if err != nil {
switch err {
case windows.ERROR_ACCESS_DENIED:
Expand Down