summaryrefslogtreecommitdiff
path: root/src/sys/termios.rs
diff options
context:
space:
mode:
authorBryant Mairs <bryant@mai.rs>2017-02-27 13:21:22 -0800
committerBryant Mairs <bryant@mai.rs>2017-07-10 20:49:42 -0700
commit3b66681f5330b091f260899f358a5cd1973d22bf (patch)
treebd529bd9431c276ccb02c0488af9041c44399d2b /src/sys/termios.rs
parente3529352e9bfb337c8ccdbfbfa660d23df247cf9 (diff)
downloadnix-3b66681f5330b091f260899f358a5cd1973d22bf.zip
Add cfmakeraw and cfsetspeed
Diffstat (limited to 'src/sys/termios.rs')
-rw-r--r--src/sys/termios.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 10adf089..2a815158 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -776,6 +776,20 @@ pub fn cfgetospeed(termios: &Termios) -> BaudRate {
unsafe { libc::cfgetospeed(&*inner_termios) }.into()
}
+/// Configures the port to something like the "raw" mode of the old Version 7 terminal driver (see
+/// [termios(3)](http://man7.org/linux/man-pages/man3/termios.3.html)).
+///
+/// `cfmakeraw()` configures the termios structure such that input is available character-by-
+/// character, echoing is disabled, and all special input and output processing is disabled. Note
+/// that this is a non-standard function, but is available on Linux and BSDs.
+pub fn cfmakeraw(termios: &mut Termios) {
+ let inner_termios = unsafe { termios.get_libc_termios_mut() };
+ unsafe {
+ libc::cfmakeraw(inner_termios);
+ }
+ termios.update_wrapper();
+}
+
/// Set input baud rate (see
/// [cfsetispeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetispeed.html)).
///
@@ -798,6 +812,18 @@ pub fn cfsetospeed(termios: &mut Termios, baud: BaudRate) -> Result<()> {
Errno::result(res).map(drop)
}
+/// Set both the input and output baud rates (see
+/// [termios(3)](http://man7.org/linux/man-pages/man3/termios.3.html)).
+///
+/// `cfsetspeed()` sets the input and output baud rate in the given termios structure. Note that
+/// this is part of the 4.4BSD standard and not part of POSIX.
+pub fn cfsetspeed(termios: &mut Termios, baud: BaudRate) -> Result<()> {
+ let inner_termios = unsafe { termios.get_libc_termios_mut() };
+ let res = unsafe { libc::cfsetspeed(inner_termios, baud as libc::speed_t) };
+ termios.update_wrapper();
+ Errno::result(res).map(drop)
+}
+
/// Return the configuration of a port
/// [tcgetattr(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetattr.html)).
///