diff --git a/serial_posix.go b/serial_posix.go index 311e7f6..6d25b2d 100644 --- a/serial_posix.go +++ b/serial_posix.go @@ -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 diff --git a/termios_bsd.go b/termios_bsd.go new file mode 100644 index 0000000..17016a7 --- /dev/null +++ b/termios_bsd.go @@ -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 +} diff --git a/termios_darwin.go b/termios_darwin.go new file mode 100644 index 0000000..209872e --- /dev/null +++ b/termios_darwin.go @@ -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 +} diff --git a/termios_linux.go b/termios_linux.go new file mode 100644 index 0000000..4e091ea --- /dev/null +++ b/termios_linux.go @@ -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 +} diff --git a/termios_mipsx.go b/termios_mipsx.go new file mode 100644 index 0000000..88c0b32 --- /dev/null +++ b/termios_mipsx.go @@ -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. +}