All //sys instructions moved to separate syscall_* files
Generated `syscall_*` files ranamed to `zsyscall_*` ones like it done in `golang.org/x/sys` package.
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
package serial // import "go.bug.st/serial.v1"
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
//go:generate go run extras/mksyscall_windows.go -output syscall_windows.go serial_windows.go
|
//go:generate go run extras/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go
|
||||||
|
|
||||||
// Port is the interface for a serial Port
|
// Port is the interface for a serial Port
|
||||||
type Port interface {
|
type Port interface {
|
||||||
|
|||||||
@@ -11,7 +11,5 @@ import "syscall"
|
|||||||
const devFolder = "/dev"
|
const devFolder = "/dev"
|
||||||
const regexFilter = "^(cu|tty)\\..*"
|
const regexFilter = "^(cu|tty)\\..*"
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint64, data uintptr) (err error)
|
|
||||||
|
|
||||||
const ioctlTcgetattr = syscall.TIOCGETA
|
const ioctlTcgetattr = syscall.TIOCGETA
|
||||||
const ioctlTcsetattr = syscall.TIOCSETA
|
const ioctlTcsetattr = syscall.TIOCSETA
|
||||||
|
|||||||
@@ -53,7 +53,5 @@ const tcCRTS_IFLOW uint32 = 0x00020000
|
|||||||
|
|
||||||
const tcCRTSCTS uint32 = tcCCTS_OFLOW
|
const tcCRTSCTS uint32 = tcCCTS_OFLOW
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint64, data uintptr) (err error)
|
|
||||||
|
|
||||||
const ioctlTcgetattr = syscall.TIOCGETA
|
const ioctlTcgetattr = syscall.TIOCGETA
|
||||||
const ioctlTcsetattr = syscall.TIOCSETA
|
const ioctlTcsetattr = syscall.TIOCSETA
|
||||||
|
|||||||
@@ -60,7 +60,5 @@ const tcIUCLC = syscall.IUCLC
|
|||||||
|
|
||||||
const tcCRTSCTS uint32 = 0x80000000
|
const tcCRTSCTS uint32 = 0x80000000
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint64, data uintptr) (err error)
|
|
||||||
|
|
||||||
const ioctlTcgetattr = syscall.TCGETS
|
const ioctlTcgetattr = syscall.TCGETS
|
||||||
const ioctlTcsetattr = syscall.TCSETS
|
const ioctlTcsetattr = syscall.TCSETS
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ type windowsPort struct {
|
|||||||
handle syscall.Handle
|
handle syscall.Handle
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, value *uint16, valueLen *uint32) (regerrno error) = advapi32.RegEnumValueW
|
|
||||||
|
|
||||||
func nativeGetPortsList() ([]string, error) {
|
func nativeGetPortsList() ([]string, error) {
|
||||||
subKey, err := syscall.UTF16PtrFromString("HARDWARE\\DEVICEMAP\\SERIALCOMM\\")
|
subKey, err := syscall.UTF16PtrFromString("HARDWARE\\DEVICEMAP\\SERIALCOMM\\")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -181,10 +179,6 @@ type commTimeouts struct {
|
|||||||
WriteTotalTimeoutConstant uint32
|
WriteTotalTimeoutConstant uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys getCommState(handle syscall.Handle, dcb *dcb) (err error) = GetCommState
|
|
||||||
//sys setCommState(handle syscall.Handle, dcb *dcb) (err error) = SetCommState
|
|
||||||
//sys setCommTimeouts(handle syscall.Handle, timeouts *commTimeouts) (err error) = SetCommTimeouts
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
noParity = 0
|
noParity = 0
|
||||||
oddParity = 1
|
oddParity = 1
|
||||||
@@ -213,8 +207,6 @@ var stopBitsMap = map[StopBits]byte{
|
|||||||
TwoStopBits: twoStopBits,
|
TwoStopBits: twoStopBits,
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys escapeCommFunction(handle syscall.Handle, function uint32) (res bool) = EscapeCommFunction
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
commFunctionSetXOFF = 1
|
commFunctionSetXOFF = 1
|
||||||
commFunctionSetXON = 2
|
commFunctionSetXON = 2
|
||||||
@@ -226,8 +218,6 @@ const (
|
|||||||
commFunctionClrBreak = 9
|
commFunctionClrBreak = 9
|
||||||
)
|
)
|
||||||
|
|
||||||
//sys getCommModemStatus(handle syscall.Handle, bits *uint32) (res bool) = GetCommModemStatus
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
msCTSOn = 0x0010
|
msCTSOn = 0x0010
|
||||||
msDSROn = 0x0020
|
msDSROn = 0x0020
|
||||||
@@ -321,10 +311,6 @@ func (port *windowsPort) GetModemStatusBits() (*ModemStatusBits, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys createEvent(eventAttributes *uint32, manualReset bool, initialState bool, name *uint16) (handle syscall.Handle, err error) = CreateEventW
|
|
||||||
//sys resetEvent(handle syscall.Handle) (err error) = ResetEvent
|
|
||||||
//sys getOverlappedResult(handle syscall.Handle, overlapEvent *syscall.Overlapped, n *uint32, wait bool) (err error) = GetOverlappedResult
|
|
||||||
|
|
||||||
func createOverlappedEvent() (*syscall.Overlapped, error) {
|
func createOverlappedEvent() (*syscall.Overlapped, error) {
|
||||||
h, err := createEvent(nil, true, false, nil)
|
h, err := createEvent(nil, true, false, nil)
|
||||||
return &syscall.Overlapped{HEvent: h}, err
|
return &syscall.Overlapped{HEvent: h}, err
|
||||||
|
|||||||
@@ -4,18 +4,6 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
|
|
||||||
// This file is machine generated by the command:
|
|
||||||
// mksyscall.pl serial_darwin.go
|
|
||||||
// The generated stub is modified to make it compile under the "serial" package
|
|
||||||
|
|
||||||
package serial // import "go.bug.st/serial.v1"
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
import "syscall"
|
//sys ioctl(fd int, req uint64, data uintptr) (err error)
|
||||||
|
|
||||||
func ioctl(fd int, req uint64, data uintptr) (err error) {
|
|
||||||
_, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(data))
|
|
||||||
if e1 != 0 {
|
|
||||||
err = e1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,18 +4,6 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
|
|
||||||
// This file is machine generated by the command:
|
|
||||||
// mksyscall.pl serial_darwin.go
|
|
||||||
// The generated stub is modified to make it compile under the "serial" package
|
|
||||||
|
|
||||||
package serial // import "go.bug.st/serial.v1"
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
import "syscall"
|
//sys ioctl(fd int, req uint64, data uintptr) (err error)
|
||||||
|
|
||||||
func ioctl(fd int, req uint64, data uintptr) (err error) {
|
|
||||||
_, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(data))
|
|
||||||
if e1 != 0 {
|
|
||||||
err = e1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,18 +4,6 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
|
|
||||||
// This file is machine generated by the command:
|
|
||||||
// mksyscall.pl serial_linux.go
|
|
||||||
// The generated stub is modified to make it compile under the "serial" package
|
|
||||||
|
|
||||||
package serial // import "go.bug.st/serial.v1"
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
import "syscall"
|
//sys ioctl(fd int, req uint64, data uintptr) (err error)
|
||||||
|
|
||||||
func ioctl(fd int, req uint64, data uintptr) (err error) {
|
|
||||||
_, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(data))
|
|
||||||
if e1 != 0 {
|
|
||||||
err = e1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,138 +1,25 @@
|
|||||||
// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
|
//
|
||||||
|
// Copyright 2014-2016 Cristian Maglie. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
|
||||||
package serial
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
import (
|
//sys regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, value *uint16, valueLen *uint32) (regerrno error) = advapi32.RegEnumValueW
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
//sys getCommState(handle syscall.Handle, dcb *dcb) (err error) = GetCommState
|
||||||
)
|
|
||||||
|
|
||||||
var _ unsafe.Pointer
|
//sys setCommState(handle syscall.Handle, dcb *dcb) (err error) = SetCommState
|
||||||
|
|
||||||
var (
|
//sys setCommTimeouts(handle syscall.Handle, timeouts *commTimeouts) (err error) = SetCommTimeouts
|
||||||
modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
|
|
||||||
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
|
||||||
|
|
||||||
procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW")
|
//sys escapeCommFunction(handle syscall.Handle, function uint32) (res bool) = EscapeCommFunction
|
||||||
procGetCommState = modkernel32.NewProc("GetCommState")
|
|
||||||
procSetCommState = modkernel32.NewProc("SetCommState")
|
|
||||||
procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts")
|
|
||||||
procEscapeCommFunction = modkernel32.NewProc("EscapeCommFunction")
|
|
||||||
procGetCommModemStatus = modkernel32.NewProc("GetCommModemStatus")
|
|
||||||
procCreateEventW = modkernel32.NewProc("CreateEventW")
|
|
||||||
procResetEvent = modkernel32.NewProc("ResetEvent")
|
|
||||||
procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
|
|
||||||
)
|
|
||||||
|
|
||||||
func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, value *uint16, valueLen *uint32) (regerrno error) {
|
//sys getCommModemStatus(handle syscall.Handle, bits *uint32) (res bool) = GetCommModemStatus
|
||||||
r0, _, _ := syscall.Syscall9(procRegEnumValueW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(value)), uintptr(unsafe.Pointer(valueLen)), 0)
|
|
||||||
if r0 != 0 {
|
|
||||||
regerrno = syscall.Errno(r0)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCommState(handle syscall.Handle, dcb *dcb) (err error) {
|
//sys createEvent(eventAttributes *uint32, manualReset bool, initialState bool, name *uint16) (handle syscall.Handle, err error) = CreateEventW
|
||||||
r1, _, e1 := syscall.Syscall(procGetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(dcb)), 0)
|
|
||||||
if r1 == 0 {
|
|
||||||
if e1 != 0 {
|
|
||||||
err = error(e1)
|
|
||||||
} else {
|
|
||||||
err = syscall.EINVAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func setCommState(handle syscall.Handle, dcb *dcb) (err error) {
|
//sys resetEvent(handle syscall.Handle) (err error) = ResetEvent
|
||||||
r1, _, e1 := syscall.Syscall(procSetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(dcb)), 0)
|
|
||||||
if r1 == 0 {
|
|
||||||
if e1 != 0 {
|
|
||||||
err = error(e1)
|
|
||||||
} else {
|
|
||||||
err = syscall.EINVAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func setCommTimeouts(handle syscall.Handle, timeouts *commTimeouts) (err error) {
|
//sys getOverlappedResult(handle syscall.Handle, overlapEvent *syscall.Overlapped, n *uint32, wait bool) (err error) = GetOverlappedResult
|
||||||
r1, _, e1 := syscall.Syscall(procSetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
|
|
||||||
if r1 == 0 {
|
|
||||||
if e1 != 0 {
|
|
||||||
err = error(e1)
|
|
||||||
} else {
|
|
||||||
err = syscall.EINVAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func escapeCommFunction(handle syscall.Handle, function uint32) (res bool) {
|
|
||||||
r0, _, _ := syscall.Syscall(procEscapeCommFunction.Addr(), 2, uintptr(handle), uintptr(function), 0)
|
|
||||||
res = r0 != 0
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCommModemStatus(handle syscall.Handle, bits *uint32) (res bool) {
|
|
||||||
r0, _, _ := syscall.Syscall(procGetCommModemStatus.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(bits)), 0)
|
|
||||||
res = r0 != 0
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func createEvent(eventAttributes *uint32, manualReset bool, initialState bool, name *uint16) (handle syscall.Handle, err error) {
|
|
||||||
var _p0 uint32
|
|
||||||
if manualReset {
|
|
||||||
_p0 = 1
|
|
||||||
} else {
|
|
||||||
_p0 = 0
|
|
||||||
}
|
|
||||||
var _p1 uint32
|
|
||||||
if initialState {
|
|
||||||
_p1 = 1
|
|
||||||
} else {
|
|
||||||
_p1 = 0
|
|
||||||
}
|
|
||||||
r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttributes)), uintptr(_p0), uintptr(_p1), uintptr(unsafe.Pointer(name)), 0, 0)
|
|
||||||
handle = syscall.Handle(r0)
|
|
||||||
if handle == 0 {
|
|
||||||
if e1 != 0 {
|
|
||||||
err = error(e1)
|
|
||||||
} else {
|
|
||||||
err = syscall.EINVAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func resetEvent(handle syscall.Handle) (err error) {
|
|
||||||
r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(handle), 0, 0)
|
|
||||||
if r1 == 0 {
|
|
||||||
if e1 != 0 {
|
|
||||||
err = error(e1)
|
|
||||||
} else {
|
|
||||||
err = syscall.EINVAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func getOverlappedResult(handle syscall.Handle, overlapEvent *syscall.Overlapped, n *uint32, wait bool) (err error) {
|
|
||||||
var _p0 uint32
|
|
||||||
if wait {
|
|
||||||
_p0 = 1
|
|
||||||
} else {
|
|
||||||
_p0 = 0
|
|
||||||
}
|
|
||||||
r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapEvent)), uintptr(unsafe.Pointer(n)), uintptr(_p0), 0, 0)
|
|
||||||
if r1 == 0 {
|
|
||||||
if e1 != 0 {
|
|
||||||
err = error(e1)
|
|
||||||
} else {
|
|
||||||
err = syscall.EINVAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
21
zsyscall_darwin.go
Normal file
21
zsyscall_darwin.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2014-2016 Cristian Maglie. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
|
||||||
|
// This file is machine generated by the command:
|
||||||
|
// mksyscall.pl serial_darwin.go
|
||||||
|
// The generated stub is modified to make it compile under the "serial" package
|
||||||
|
|
||||||
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func ioctl(fd int, req uint64, data uintptr) (err error) {
|
||||||
|
_, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(data))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
21
zsyscall_freebsd.go
Normal file
21
zsyscall_freebsd.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2014-2016 Cristian Maglie. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
|
||||||
|
// This file is machine generated by the command:
|
||||||
|
// mksyscall.pl serial_darwin.go
|
||||||
|
// The generated stub is modified to make it compile under the "serial" package
|
||||||
|
|
||||||
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func ioctl(fd int, req uint64, data uintptr) (err error) {
|
||||||
|
_, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(data))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
21
zsyscall_linux.go
Normal file
21
zsyscall_linux.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2014-2016 Cristian Maglie. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
|
||||||
|
// This file is machine generated by the command:
|
||||||
|
// mksyscall.pl serial_linux.go
|
||||||
|
// The generated stub is modified to make it compile under the "serial" package
|
||||||
|
|
||||||
|
package serial // import "go.bug.st/serial.v1"
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func ioctl(fd int, req uint64, data uintptr) (err error) {
|
||||||
|
_, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(data))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
138
zsyscall_windows.go
Normal file
138
zsyscall_windows.go
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
package serial
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ unsafe.Pointer
|
||||||
|
|
||||||
|
var (
|
||||||
|
modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
|
||||||
|
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||||
|
|
||||||
|
procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW")
|
||||||
|
procGetCommState = modkernel32.NewProc("GetCommState")
|
||||||
|
procSetCommState = modkernel32.NewProc("SetCommState")
|
||||||
|
procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts")
|
||||||
|
procEscapeCommFunction = modkernel32.NewProc("EscapeCommFunction")
|
||||||
|
procGetCommModemStatus = modkernel32.NewProc("GetCommModemStatus")
|
||||||
|
procCreateEventW = modkernel32.NewProc("CreateEventW")
|
||||||
|
procResetEvent = modkernel32.NewProc("ResetEvent")
|
||||||
|
procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
|
||||||
|
)
|
||||||
|
|
||||||
|
func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, value *uint16, valueLen *uint32) (regerrno error) {
|
||||||
|
r0, _, _ := syscall.Syscall9(procRegEnumValueW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(value)), uintptr(unsafe.Pointer(valueLen)), 0)
|
||||||
|
if r0 != 0 {
|
||||||
|
regerrno = syscall.Errno(r0)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCommState(handle syscall.Handle, dcb *dcb) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procGetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(dcb)), 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = error(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func setCommState(handle syscall.Handle, dcb *dcb) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procSetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(dcb)), 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = error(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func setCommTimeouts(handle syscall.Handle, timeouts *commTimeouts) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procSetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = error(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func escapeCommFunction(handle syscall.Handle, function uint32) (res bool) {
|
||||||
|
r0, _, _ := syscall.Syscall(procEscapeCommFunction.Addr(), 2, uintptr(handle), uintptr(function), 0)
|
||||||
|
res = r0 != 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCommModemStatus(handle syscall.Handle, bits *uint32) (res bool) {
|
||||||
|
r0, _, _ := syscall.Syscall(procGetCommModemStatus.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(bits)), 0)
|
||||||
|
res = r0 != 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func createEvent(eventAttributes *uint32, manualReset bool, initialState bool, name *uint16) (handle syscall.Handle, err error) {
|
||||||
|
var _p0 uint32
|
||||||
|
if manualReset {
|
||||||
|
_p0 = 1
|
||||||
|
} else {
|
||||||
|
_p0 = 0
|
||||||
|
}
|
||||||
|
var _p1 uint32
|
||||||
|
if initialState {
|
||||||
|
_p1 = 1
|
||||||
|
} else {
|
||||||
|
_p1 = 0
|
||||||
|
}
|
||||||
|
r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttributes)), uintptr(_p0), uintptr(_p1), uintptr(unsafe.Pointer(name)), 0, 0)
|
||||||
|
handle = syscall.Handle(r0)
|
||||||
|
if handle == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = error(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func resetEvent(handle syscall.Handle) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(handle), 0, 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = error(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getOverlappedResult(handle syscall.Handle, overlapEvent *syscall.Overlapped, n *uint32, wait bool) (err error) {
|
||||||
|
var _p0 uint32
|
||||||
|
if wait {
|
||||||
|
_p0 = 1
|
||||||
|
} else {
|
||||||
|
_p0 = 0
|
||||||
|
}
|
||||||
|
r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapEvent)), uintptr(unsafe.Pointer(n)), uintptr(_p0), 0, 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = error(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user