serialport/serialport-rs

Opening a COM port on Windows fails

miguelraz opened this issue · 5 comments

On Windows, with a nRF52840 USB Dongle, If I run

fn main() {
    let ports = serialport::available_ports().expect("No ports found!");
    for p in ports {
        println!("{}", p.port_name);
    }
    // COM8 was printed for me
    serialport::new("COM8", 9600).open().expect("we done goof'd");
}

I get

❯ cargo run
   Compiling serialbug v0.1.0 (C:\Users\mrg\work\serialbug)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.01s
     Running `target\debug\serialbug.exe`
COM8
thread 'main' panicked at src\main.rs:7:42:
we done goof'd: Error { kind: NoDevice, description: "The system cannot find the file specified." }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\serialbug.exe` (exit code: 101)

This shouldn't be required, but you could try the 'escaped' syntax: \\.\COM8

Other thoughts:

  • Does it work if you try from an admin command prompt?
  • I assume you can open the port in a program like PuTTy
  • Can you share how the device appears in device-manager?

Hey!

  • I tried using `r"\.\COM8" and it didn't work either.
  • Yes, running from an admin command prompt also fails.
  • I haven't tried PuTTy yet
  • yes, it shows up exactly like the screenshots here zephyrproject-rtos/zephyr#17266 and with the same error messages

Connecting via PuTTy also failed:
image

after
image

Hey!

  • I tried using `r"\.\COM8" and it didn't work either.
  • Yes, running from an admin command prompt also fails.
  • I haven't tried PuTTy yet
  • yes, it shows up exactly like the screenshots here zephyrproject-rtos/zephyr#17266 and with the same error messages

Unfortunately this is most likely an issue with your device drivers/USB descriptors, and isn't something that can be fixed by this library.

These issues can be tricky to debug, but I recommend taking a look at the device descriptor using USBTreeView as a place to start.

Thanks, will close this issue then.