Skip to content

SerialPortBuilder.timeout(Duration::MAX) gives "Invalid argument" #207

@wxifze

Description

@wxifze

When serial port is created through SerialPortBuilder and .timeout() is called with the argument set to Duration::MAX, any attempt to read from the port returns an error Custom { kind: Other, error: "Invalid argument" }.
Apparently there is no other way to set blocking read without a timeout.

Code to reproduce:

use std::{time::Duration, error::Error};

fn main() -> Result<(), Box<dyn Error>> {
    let mut serial = serialport::new("/dev/ttyUSB0", 9600)
        .timeout(Duration::MAX)
        .open()?;
    let mut tmp = vec![0];
    serial.read(&mut tmp)?;
    dbg!(tmp);
    Ok(())
}

Environment:

  • Fedora 40
  • 6.9.11-200.fc40.x86_64
  • rustc 1.79.0 (129f3b996 2024-06-10)
  • serialport = "4.4.0"
  • /dev/ttyUSB0: ID 1a86:7523 QinHeng Electronics CH340 serial converter
  • also reproducible with /dev/tty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions