You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
305 B
18 lines
305 B
|
2 months ago
|
//go:build linux
|
||
|
|
|
||
|
|
package serial
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
|
||
|
|
"golang.org/x/sys/unix"
|
||
|
|
)
|
||
|
|
|
||
|
|
func openSerialDevice(path string) (*os.File, error) {
|
||
|
|
fd, err := unix.Open(path, unix.O_RDWR|unix.O_NOCTTY|unix.O_NONBLOCK|unix.O_CLOEXEC, 0)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return os.NewFile(uintptr(fd), path), nil
|
||
|
|
}
|