diff --git a/pty/src/serial.rs b/pty/src/serial.rs index a8e382b20..bd87c29c9 100644 --- a/pty/src/serial.rs +++ b/pty/src/serial.rs @@ -8,7 +8,9 @@ use crate::{Child, CommandBuilder, ExitStatus, MasterPty, PtyPair, PtySize, PtySystem, SlavePty}; use anyhow::{ensure, Context}; use filedescriptor::FileDescriptor; -use serial::{BaudRate, CharSize, FlowControl, Parity, SerialPort, StopBits, SystemPort}; +use serial::{ + BaudRate, CharSize, FlowControl, Parity, PortSettings, SerialPort, StopBits, SystemPort, +}; use std::ffi::{OsStr, OsString}; use std::io::Result as IoResult; use std::io::{Read, Write}; @@ -64,14 +66,16 @@ impl PtySystem for SerialTty { let mut port = serial::open(&self.port) .with_context(|| format!("openpty on serial port {:?}", self.port))?; - port.reconfigure(&|settings| { - settings.set_baud_rate(self.baud)?; - settings.set_char_size(self.char_size); - settings.set_parity(self.parity); - settings.set_stop_bits(self.stop_bits); - settings.set_flow_control(self.flow_control); - Ok(()) - })?; + let settings = PortSettings { + baud_rate: self.baud, + char_size: self.char_size, + parity: self.parity, + stop_bits: self.stop_bits, + flow_control: self.flow_control, + }; + log::debug!("serial settings: {:#?}", settings); + port.configure(&settings)?; + // The timeout needs to be rather short because, at least on Windows, // a read with a long timeout will block a concurrent write from // happening. In wezterm we tend to have a thread looping on read diff --git a/src/main.rs b/src/main.rs index d3e9a6cf3..54f1d8693 100644 --- a/src/main.rs +++ b/src/main.rs @@ -427,7 +427,7 @@ fn run_serial(config: config::ConfigHandle, opts: &SerialCommand) -> anyhow::Res serial.set_baud_rate(serial::BaudRate::from_speed(baud)); } - let pty_system = Box::new(portable_pty::serial::SerialTty::new(&opts.port)); + let pty_system = Box::new(serial); let domain: Arc = Arc::new(LocalDomain::with_pty_system("local", pty_system)); let mux = Rc::new(mux::Mux::new(Some(domain.clone()))); Mux::set_mux(&mux);