Skip to content
Snippets Groups Projects
Commit aec6a48c authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'termios-baudrate' into 'master'

Add termios baud rate functions

See merge request !165
parents b22d3861 db4452e9
No related branches found
No related tags found
1 merge request!165Add termios baud rate functions
Pipeline #1391 failed
//! 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