From 78ce86ed362883a03ef0b3133d9d255b06fd0c84 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Sat, 25 Feb 2017 11:59:23 -0800 Subject: [PATCH] Add cfmakeraw/cfsetspeed --- src/sys/termios.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sys/termios.rs b/src/sys/termios.rs index e8df1ed95b..2f56c98690 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -22,6 +22,8 @@ mod ffi { extern { pub fn cfgetispeed(termios: *const Termios) -> speed_t; pub fn cfgetospeed(termios: *const Termios) -> speed_t; + pub fn cfmakeraw(termios: *mut Termios); + pub fn cfsetspeed(termios: *mut Termios, speed: speed_t) -> c_int; pub fn cfsetispeed(termios: *mut Termios, speed: speed_t) -> c_int; pub fn cfsetospeed(termios: *mut Termios, speed: speed_t) -> c_int; pub fn tcgetattr(fd: c_int, termios: *mut Termios) -> c_int; @@ -599,6 +601,18 @@ pub fn cfgetospeed(termios: &Termios) -> BaudRate { } } +pub fn cfmakeraw(termios: &mut Termios) { + unsafe { + ffi::cfmakeraw(termios); + } +} + +pub fn cfsetspeed(termios: &mut Termios, baud: BaudRate) -> Result<()> { + Errno::result(unsafe { + ffi::cfsetspeed(termios, baud as speed_t) + }).map(drop) +} + pub fn cfsetispeed(termios: &mut Termios, baud: BaudRate) -> Result<()> { Errno::result(unsafe { ffi::cfsetispeed(termios, baud as speed_t)