Added interface methods for RS232 signals

This commit is contained in:
Cristian Maglie
2016-10-29 22:18:24 +02:00
parent f56a50621e
commit 5be0087bd5
4 changed files with 110 additions and 0 deletions

View File

@@ -22,10 +22,29 @@ type Port interface {
// Returns the number of bytes written.
Write(p []byte) (n int, err error)
// SetDTR sets the modem status bit DataTerminalReady
SetDTR(dtr bool) error
// SetRTS sets the modem status bit RequestToSend
SetRTS(rts bool) error
// GetModemStatusBits returns a ModemStatusBits structure containing the
// modem status bits for the serial port (CTS, DSR, etc...)
GetModemStatusBits() (*ModemStatusBits, error)
// Close the serial port
Close() error
}
// ModemStatusBits contains all the modem status bits for a serial port (CTS, DSR, etc...).
// It can be retrieved with the Port.GetModemStatusBits() method.
type ModemStatusBits struct {
CTS bool // ClearToSend status
DSR bool // DataSetReady status
RI bool // RingIndicator status
DCD bool // DataCarrierDetect status
}
// Open opens the serial port using the specified modes
func Open(portName string, mode *Mode) (Port, error) {
return nativeOpen(portName, mode)