Skip to content

Commit

Permalink
Allow baudrate retrieval from settings and test set/get.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbr committed Mar 5, 2017
1 parent d7f866f commit 42e2bcf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/posix/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ impl SerialPortSettings for TTYSettings {
B3500000 => Some(::BaudOther(3500000)),
#[cfg(target_os = "linux")]
B4000000 => Some(::BaudOther(4000000)),
#[cfg(target_os = "linux")]
BOTHER => {

if self.termios.c_ospeed != self.termios.c_ispeed {
return None;
}

Some(::BaudOther(self.termios.c_ospeed as usize))
}

_ => None
}
Expand Down Expand Up @@ -598,6 +607,14 @@ mod tests {
assert_eq!(settings.baud_rate(), Some(::Baud1200));
}

#[test]
fn tty_settings_sets_nonstandard_baud_rate() {
let mut settings = default_settings();

settings.set_baud_rate(::BaudOther(12345)).unwrap();
assert_eq!(settings.baud_rate(), Some(::BaudOther(12345)));
}

#[test]
fn tty_settings_sets_char_size() {
let mut settings = default_settings();
Expand Down

0 comments on commit 42e2bcf

Please sign in to comment.