diff --git a/serial_posix.go b/serial_posix.go index b8d58d3..df3dffa 100644 --- a/serial_posix.go +++ b/serial_posix.go @@ -14,7 +14,7 @@ type SError struct { msg string } -func (e SError) String() (string) { +func (e SError) String() string { return e.msg } @@ -23,7 +23,7 @@ func OpenPort(name string, baud int) (f *os.File, err os.Error) { if err != nil { return } - + fd := C.int(f.Fd()) var st C.struct_termios @@ -47,7 +47,7 @@ func OpenPort(name string, baud int) (f *os.File, err os.Error) { st.c_cflag |= (C.CLOCAL | C.CREAD) // Select raw mode - st.c_lflag &= ^C.tcflag_t(C.ICANON|C.ECHO|C.ECHOE|C.ISIG) + st.c_lflag &= ^C.tcflag_t(C.ICANON | C.ECHO | C.ECHOE | C.ISIG) st.c_oflag &= ^C.tcflag_t(C.OPOST) _, err = C.tcsetattr(fd, C.TCSANOW, &st) @@ -57,27 +57,27 @@ func OpenPort(name string, baud int) (f *os.File, err os.Error) { } fmt.Println("Tweaking", name) - r1, _, e := syscall.Syscall(syscall.SYS_FCNTL, - uintptr(f.Fd()), - uintptr(syscall.F_SETFL), - uintptr(0)) - if e != 0 || r1 != 0 { - s := fmt.Sprint("Clearing NONBLOCK syscall error:", e, r1) + r1, _, e := syscall.Syscall(syscall.SYS_FCNTL, + uintptr(f.Fd()), + uintptr(syscall.F_SETFL), + uintptr(0)) + if e != 0 || r1 != 0 { + s := fmt.Sprint("Clearing NONBLOCK syscall error:", e, r1) f.Close() return nil, SError{s} - } + } /* - r1, _, e = syscall.Syscall(syscall.SYS_IOCTL, - uintptr(f.Fd()), - uintptr(0x80045402), // IOSSIOSPEED - uintptr(unsafe.Pointer(&baud))); - if e != 0 || r1 != 0 { - s := fmt.Sprint("Baudrate syscall error:", e, r1) - f.Close() - return nil, SError{s} - } - */ - + r1, _, e = syscall.Syscall(syscall.SYS_IOCTL, + uintptr(f.Fd()), + uintptr(0x80045402), // IOSSIOSPEED + uintptr(unsafe.Pointer(&baud))); + if e != 0 || r1 != 0 { + s := fmt.Sprint("Baudrate syscall error:", e, r1) + f.Close() + return nil, SError{s} + } + */ + return -} \ No newline at end of file +}