Skip to content

Commit

Permalink
Fixed cross compilation on MIPS architecture (#10)
Browse files Browse the repository at this point in the history
* Fixed termios portability issue.

* Cleaned up for cross compilation.
  • Loading branch information
Ethan Kan authored and nqv committed Oct 3, 2017
1 parent d490ecc commit 5efbe92
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
4 changes: 2 additions & 2 deletions serial_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ func newTermios(c *Config) (termios *syscall.Termios, err error) {
}
termios.Cflag |= flag
// Input baud.
termios.Ispeed = flag
cfSetIspeed(termios, flag)
// Output baud.
termios.Ospeed = flag
cfSetOspeed(termios, flag)
// Character size.
if c.DataBits == 0 {
flag = syscall.CS8
Expand Down
15 changes: 15 additions & 0 deletions termios_bsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// +build freebsd openbsd netbsd

package serial

import (
"syscall"
)

func cfSetIspeed(termios *syscall.Termios, speed uint32) {
termios.Ispeed = speed
}

func cfSetOspeed(termios *syscall.Termios, speed uint32) {
termios.Ospeed = speed
}
13 changes: 13 additions & 0 deletions termios_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package serial

import (
"syscall"
)

func cfSetIspeed(termios *syscall.Termios, speed uint64) {
termios.Ispeed = speed
}

func cfSetOspeed(termios *syscall.Termios, speed uint64) {
termios.Ospeed = speed
}
15 changes: 15 additions & 0 deletions termios_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// +build !mips,!mipsle,!mips64,!mips64le

package serial

import (
"syscall"
)

func cfSetIspeed(termios *syscall.Termios, speed uint32) {
termios.Ispeed = speed
}

func cfSetOspeed(termios *syscall.Termios, speed uint32) {
termios.Ospeed = speed
}
16 changes: 16 additions & 0 deletions termios_mipsx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// +build linux
// +build mips mipsle mips64 mips64le

package serial

import (
"syscall"
)

func cfSetIspeed(termios *syscall.Termios, speed uint32) {
// MIPS has no Ispeed field in termios.
}

func cfSetOspeed(termios *syscall.Termios, speed uint32) {
// MIPS has no Ospeed field in termios.
}

0 comments on commit 5efbe92

Please sign in to comment.