@@ -14,7 +14,6 @@ import (
14
14
"strings"
15
15
"sync"
16
16
"sync/atomic"
17
- "unsafe"
18
17
19
18
"go.bug.st/serial/unixutils"
20
19
"golang.org/x/sys/unix"
@@ -94,11 +93,11 @@ func (port *unixPort) Write(p []byte) (n int, err error) {
94
93
}
95
94
96
95
func (port * unixPort ) ResetInputBuffer () error {
97
- return ioctl (port .handle , ioctlTcflsh , unix .TCIFLUSH )
96
+ return unix . IoctlSetInt (port .handle , ioctlTcflsh , unix .TCIFLUSH )
98
97
}
99
98
100
99
func (port * unixPort ) ResetOutputBuffer () error {
101
- return ioctl (port .handle , ioctlTcflsh , unix .TCOFLUSH )
100
+ return unix . IoctlSetInt (port .handle , ioctlTcflsh , unix .TCOFLUSH )
102
101
}
103
102
104
103
func (port * unixPort ) SetMode (mode * Mode ) error {
@@ -390,29 +389,25 @@ func setRawMode(settings *unix.Termios) {
390
389
// native syscall wrapper functions
391
390
392
391
func (port * unixPort ) getTermSettings () (* unix.Termios , error ) {
393
- settings := & unix.Termios {}
394
- err := ioctl (port .handle , ioctlTcgetattr , uintptr (unsafe .Pointer (settings )))
395
- return settings , err
392
+ return unix .IoctlGetTermios (port .handle , ioctlTcgetattr )
396
393
}
397
394
398
395
func (port * unixPort ) setTermSettings (settings * unix.Termios ) error {
399
- return ioctl (port .handle , ioctlTcsetattr , uintptr ( unsafe . Pointer ( settings )) )
396
+ return unix . IoctlSetTermios (port .handle , ioctlTcsetattr , settings )
400
397
}
401
398
402
399
func (port * unixPort ) getModemBitsStatus () (int , error ) {
403
- var status int
404
- err := ioctl (port .handle , unix .TIOCMGET , uintptr (unsafe .Pointer (& status )))
405
- return status , err
400
+ return unix .IoctlGetInt (port .handle , unix .TIOCMGET )
406
401
}
407
402
408
403
func (port * unixPort ) setModemBitsStatus (status int ) error {
409
- return ioctl (port .handle , unix .TIOCMSET , uintptr ( unsafe . Pointer ( & status )) )
404
+ return unix . IoctlSetPointerInt (port .handle , unix .TIOCMSET , status )
410
405
}
411
406
412
407
func (port * unixPort ) acquireExclusiveAccess () error {
413
- return ioctl (port .handle , unix .TIOCEXCL , 0 )
408
+ return unix . IoctlSetInt (port .handle , unix .TIOCEXCL , 0 )
414
409
}
415
410
416
411
func (port * unixPort ) releaseExclusiveAccess () error {
417
- return ioctl (port .handle , unix .TIOCNXCL , 0 )
412
+ return unix . IoctlSetInt (port .handle , unix .TIOCNXCL , 0 )
418
413
}
0 commit comments