diff --git a/serial_darwin.go b/serial_darwin.go new file mode 100644 index 0000000..249ce62 --- /dev/null +++ b/serial_darwin.go @@ -0,0 +1,54 @@ +// +// Copyright 2014 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 // import "go.bug.st/serial" + +import "syscall" + +const devFolder = "/dev" +const regexFilter = "tty.(serial|usbserial|usbmodem).*" + +// termios manipulation functions + +var baudrateMap = map[int]int{ + 0: syscall.B9600, // Default to 9600 + 50: syscall.B50, + 75: syscall.B75, + 110: syscall.B110, + 134: syscall.B134, + 150: syscall.B150, + 200: syscall.B200, + 300: syscall.B300, + 600: syscall.B600, + 1200: syscall.B1200, + 1800: syscall.B1800, + 2400: syscall.B2400, + 4800: syscall.B4800, + 9600: syscall.B9600, + 19200: syscall.B19200, + 38400: syscall.B38400, + 57600: syscall.B57600, + 115200: syscall.B115200, + 230400: syscall.B230400, +} + +var databitsMap = map[int]int{ + 0: syscall.CS8, // Default to 8 bits + 5: syscall.CS5, + 6: syscall.CS6, + 7: syscall.CS7, + 8: syscall.CS8, +} + +const tc_CMSPAR int = 0 // may be CMSPAR or PAREXT +const tc_IUCLC int = 0 + +// syscall wrappers + +//sys ioctl(fd int, req uint64, data uintptr) (err error) + +const ioctl_tcgetattr = syscall.TIOCGETA +const ioctl_tcsetattr = syscall.TIOCSETA diff --git a/serial_darwin_386.go b/serial_darwin_386.go new file mode 100644 index 0000000..8c0f714 --- /dev/null +++ b/serial_darwin_386.go @@ -0,0 +1,12 @@ +// +// Copyright 2014 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 // import "go.bug.st/serial" + +func termiosMask(data int) uint32 { + return uint32(data) +} + diff --git a/serial_darwin_amd64.go b/serial_darwin_amd64.go index 1001a6e..249086d 100644 --- a/serial_darwin_amd64.go +++ b/serial_darwin_amd64.go @@ -6,53 +6,9 @@ package serial // import "go.bug.st/serial" -import "syscall" - -const devFolder = "/dev" -const regexFilter = "tty.(serial|usbserial|usbmodem).*" - // termios manipulation functions -var baudrateMap = map[int]int{ - 0: syscall.B9600, // Default to 9600 - 50: syscall.B50, - 75: syscall.B75, - 110: syscall.B110, - 134: syscall.B134, - 150: syscall.B150, - 200: syscall.B200, - 300: syscall.B300, - 600: syscall.B600, - 1200: syscall.B1200, - 1800: syscall.B1800, - 2400: syscall.B2400, - 4800: syscall.B4800, - 9600: syscall.B9600, - 19200: syscall.B19200, - 38400: syscall.B38400, - 57600: syscall.B57600, - 115200: syscall.B115200, - 230400: syscall.B230400, -} - -var databitsMap = map[int]int{ - 0: syscall.CS8, // Default to 8 bits - 5: syscall.CS5, - 6: syscall.CS6, - 7: syscall.CS7, - 8: syscall.CS8, -} - -const tc_CMSPAR int = 0 // may be CMSPAR or PAREXT -const tc_IUCLC int = 0 - func termiosMask(data int) uint64 { return uint64(data) } -// syscall wrappers - -//sys ioctl(fd int, req uint64, data uintptr) (err error) - -const ioctl_tcgetattr = syscall.TIOCGETA -const ioctl_tcsetattr = syscall.TIOCSETA diff --git a/syscall_darwin_amd64.go b/syscall_darwin.go similarity index 83% rename from syscall_darwin_amd64.go rename to syscall_darwin.go index 721bc71..9ab2d96 100644 --- a/syscall_darwin_amd64.go +++ b/syscall_darwin.go @@ -5,15 +5,13 @@ // // This file is machine generated by the command: -// mksyscall.pl serial_darwin_amd64.go +// 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" import "syscall" -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - 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 {