We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I use serialport::available_ports() to get information about the current ports. I have the next code:
serialport::available_ports()
let ports = serialport::available_ports().unwrap(); debug!("{ports:?}");
Which outputs the following to the command line:
18:56:39 [windows] 2025-03-26T13:56:39.768815Z DEBUG ThreadId(12) tmcs_client::flash::resolver::usb_resolver: [ 18:56:39 [windows] SerialPortInfo { 18:56:39 [windows] port_name: "COM1", 18:56:39 [windows] port_type: Unknown, 18:56:39 [windows] }, 18:56:39 [windows] SerialPortInfo { 18:56:39 [windows] port_name: "", // ATTENTION HERE 18:56:39 [windows] port_type: UsbPort( 18:56:39 [windows] UsbPortInfo { 18:56:39 [windows] vid: 1155, 18:56:39 [windows] pid: 22336, 18:56:39 [windows] serial_number: Some( 18:56:39 [windows] "TMCS_B000000000", 18:56:39 [windows] ), 18:56:39 [windows] manufacturer: Some( 18:56:39 [windows] "STMicroelectronics.", 18:56:39 [windows] ), 18:56:39 [windows] product: Some( 18:56:39 [windows] "TMCarSolutions: Common Bootloader (COM 10)", 18:56:39 [windows] ), 18:56:39 [windows] }, 18:56:39 [windows] ), 18:56:39 [windows] }, 18:56:39 [windows] ]
As you and I can see, there is no port name for the second device.
I don't know what the problem is, and I don't know how to reproduce this on another computer.
Other programs easily recognize the COM port name of this device.
Serial Debug Assistant
Windows registry
This may be because I changed the FriendlyName of the device in the Windows registry. I also tried changing COM 10 to COM10, but that did not work.
COM 10
COM10
The text was updated successfully, but these errors were encountered:
So far, I've done a workaround using the following function to which I give a string with the FriendlyName of the device.
fn guess_com_port_from_str<S>(str: S) -> Option<String> where S: AsRef<str> { static RGX: LazyLock<Regex> = LazyLock::new(|| { Regex::new(r#"\(COM\s*(?<num>\d+)\s*\)"#).unwrap() }); if let Some(caps) = RGX.captures(str.as_ref()) { let port_num = caps.name("num").unwrap().as_str(); return Some(format!("COM{port_num}")) } None }
list.insert(unique_device_sequence, UsbDevice { sw_name: info.product_string().map(|v| v.to_owned()), serial_number: sn.to_owned(), com_port: if device.port_name.len() > 0 { device.port_name } else { let com_port = usb_port.product .as_ref() .and_then(|product| Self::guess_com_port_from_str(product)); if let Some(port) = com_port { port } else { continue; } }, });
Sorry, something went wrong.
No branches or pull requests
Problem Description
I use
serialport::available_ports()
to get information about the current ports.I have the next code:
Which outputs the following to the command line:
As you and I can see, there is no port name for the second device.
I don't know what the problem is, and I don't know how to reproduce this on another computer.
Other programs easily recognize the COM port name of this device.
Serial Debug Assistant

Windows registry

This may be because I changed the FriendlyName of the device in the Windows registry.
I also tried changing
COM 10
toCOM10
, but that did not work.My environment
The text was updated successfully, but these errors were encountered: