Skip to content
Snippets Groups Projects
Commit db4452e9 authored by Nagy Tibor's avatar Nagy Tibor
Browse files

Add termios baud rate functions

parent b22d3861
No related branches found
No related tags found
1 merge request!165Add termios baud rate functions
//! termios implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html
use header::errno;
use platform;
use platform::types::*;
use platform::{Pal, Sys};
......@@ -31,6 +33,44 @@ pub extern "C" fn tcsetattr(fd: c_int, act: c_int, value: *mut termios) -> c_int
Sys::tcsetattr(fd, act, value)
}
#[no_mangle]
pub extern "C" fn cfgetispeed(termios_p: *const termios) -> speed_t {
unsafe { (*termios_p).__c_ispeed }
}
#[no_mangle]
pub extern "C" fn cfgetospeed(termios_p: *const termios) -> speed_t {
unsafe { (*termios_p).__c_ospeed }
}
#[no_mangle]
pub extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> c_int {
match speed as usize {
B0..=B38400 | B57600..=B4000000 => {
unsafe { (*termios_p).__c_ispeed = speed };
0
}
_ => {
unsafe { platform::errno = errno::EINVAL };
-1
}
}
}
#[no_mangle]
pub extern "C" fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> c_int {
match speed as usize {
B0..=B38400 | B57600..=B4000000 => {
unsafe { (*termios_p).__c_ospeed = speed };
0
}
_ => {
unsafe { platform::errno = errno::EINVAL };
-1
}
}
}
pub const VINTR: usize = 0;
pub const VQUIT: usize = 1;
pub const VERASE: usize = 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment