Added support for sending breaks

This commit is contained in:
Jaime
2022-05-04 12:03:56 +02:00
committed by Cristian Maglie
parent f85edb454b
commit 75542ba31a
7 changed files with 30 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
// license that can be found in the LICENSE file.
//
//go:build linux || darwin || freebsd || openbsd
// +build linux darwin freebsd openbsd
package serial
@@ -117,6 +118,20 @@ func (port *unixPort) Write(p []byte) (n int, err error) {
return
}
func (port *unixPort) Break(t time.Duration) error {
if err := unix.IoctlSetInt(port.handle, ioctlTiocsbrk, 0); err != nil {
return err
}
time.Sleep(t)
if err := unix.IoctlSetInt(port.handle, ioctlTioccbrk, 0); err != nil {
return err
}
return nil
}
func (port *unixPort) SetMode(mode *Mode) error {
settings, err := port.getTermSettings()
if err != nil {