diff --git a/Makefile b/Makefile deleted file mode 100644 index 4c27616..0000000 --- a/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include $(GOROOT)/src/Make.inc - -TARG=github.com/tarm/goserial - -ifeq ($(GOOS),windows) -GOFILES=serial_$(GOOS).go -else -CGOFILES=serial_$(GOOS).go -endif -GOFILES+=serial.go - -include $(GOROOT)/src/Make.pkg diff --git a/basic_test.go b/basic_test.go index bb410fe..f6532ba 100644 --- a/basic_test.go +++ b/basic_test.go @@ -5,6 +5,9 @@ import ( ) func TestConnection(t *testing.T) { + if testing.Short() { + return + } c0 := &Config{Name: "COM5", Baud: 115200} /* diff --git a/serial_linux.go b/serial_linux.go deleted file mode 120000 index ec037dc..0000000 --- a/serial_linux.go +++ /dev/null @@ -1 +0,0 @@ -serial_darwin.go \ No newline at end of file diff --git a/serial_darwin.go b/serial_posix.go similarity index 94% rename from serial_darwin.go rename to serial_posix.go index 6aef9b9..198d6bc 100644 --- a/serial_darwin.go +++ b/serial_posix.go @@ -1,8 +1,11 @@ +// +build !windows + package serial // #include // #include import "C" + // TODO: Maybe change to using syscall package + ioctl instead of cgo import ( @@ -15,7 +18,7 @@ import ( ) func openPort(name string, baud int) (rwc io.ReadWriteCloser, err error) { - f, err := os.OpenFile(name, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK, 0666) + f, err := os.OpenFile(name, syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_NONBLOCK, 0666) if err != nil { return } diff --git a/serial_windows.go b/serial_windows.go index efe4a3b..76e0a30 100644 --- a/serial_windows.go +++ b/serial_windows.go @@ -1,3 +1,5 @@ +// +build windows + package serial import ( @@ -50,7 +52,7 @@ func openPort(name string, baud int) (rwc io.ReadWriteCloser, err error) { if err != nil { return nil, err } - f := os.NewFile(h, name) + f := os.NewFile(uintptr(h), name) defer func() { if err != nil { f.Close()