Skip to content

Commit 2911ed6

Browse files
committed
[closes #18] prepends Win32 device namespace to port names
1 parent 5ca6756 commit 2911ed6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/windows/com.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ impl COMPort {
4040
/// * `InvalidInput` if `port` is not a valid device name.
4141
/// * `Io` for any other I/O error while opening or initializing the device.
4242
pub fn open<T: AsRef<OsStr> + ?Sized>(port: &T) -> ::Result<Self> {
43-
let mut name: Vec<u16> = port.as_ref().encode_wide().collect();
43+
let mut name = Vec::<u16>::new();
44+
45+
name.extend(OsStr::new("\\\\.\\").encode_wide());
46+
name.extend(port.as_ref().encode_wide());
4447
name.push(0);
4548

4649
let handle = unsafe {

0 commit comments

Comments
 (0)