Skip to content

Commit

Permalink
Toggle off the CMSPAR flag when switching to other parity modes
Browse files Browse the repository at this point in the history
  • Loading branch information
YgorSouza committed May 17, 2024
1 parent 7419d10 commit 0937208
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/posix/termios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,29 @@ pub(crate) fn set_parity(termios: &mut Termios, parity: Parity) -> Result<()> {
termios.c_cflag &= !(libc::PARENB | libc::PARODD);
termios.c_iflag &= !libc::INPCK;
termios.c_iflag |= libc::IGNPAR;
#[cfg(any(target_os = "linux", target_os = "android"))]
{
termios.c_iflag &= !libc::CMSPAR;
}
}
Parity::Odd => {
termios.c_cflag |= libc::PARENB | libc::PARODD;
termios.c_iflag |= libc::INPCK;
termios.c_iflag &= !libc::IGNPAR;
#[cfg(any(target_os = "linux", target_os = "android"))]
{
termios.c_iflag &= !libc::CMSPAR;
}
}
Parity::Even => {
termios.c_cflag &= !libc::PARODD;
termios.c_cflag |= libc::PARENB;
termios.c_iflag |= libc::INPCK;
termios.c_iflag &= !libc::IGNPAR;
#[cfg(any(target_os = "linux", target_os = "android"))]
{
termios.c_iflag &= !libc::CMSPAR;
}
}
#[cfg(any(target_os = "linux", target_os = "android"))]
Parity::Mark => {
Expand Down

0 comments on commit 0937208

Please sign in to comment.