Skip to content

Add cfmakeraw and cfsetspeed #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,10 @@ extern {
pub fn tcdrain(fd: ::c_int) -> ::c_int;
pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
pub fn cfmakeraw(termios: *mut ::termios);
pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
pub fn tcsetattr(fd: ::c_int,
optional_actions: ::c_int,
Expand Down
15 changes: 15 additions & 0 deletions src/unix/notbsd/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,16 @@ f! {
pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t {
(*termios).c_cflag & ::CBAUD
}
pub fn cfmakeraw(termios: *mut ::termios) -> () {
(*termios).c_iflag &= !(::IGNBRK | ::BRKINT | ::PARMRK | ::ISTRIP |
::INLCR | ::IGNCR | ::ICRNL | ::IXON);
(*termios).c_oflag &= !::OPOST;
(*termios).c_lflag &= !(::ECHO | ::ECHONL | ::ICANON | ::ISIG |
::IEXTEN);
(*termios).c_cflag &= !(::CSIZE | ::PARENB);
(*termios).c_cflag |= ::CS8;
()
}
pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int {
let cbaud = ::CBAUD;
(*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud);
Expand All @@ -762,6 +772,11 @@ f! {
(*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud);
return 0
}
pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int {
let cbaud = ::CBAUD;
(*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud);
return 0
}
pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int {
ioctl(fd, ::TCGETS, termios)
}
Expand Down