File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package serial
19
19
20
20
import (
21
21
"errors"
22
+ "strings"
22
23
"sync"
23
24
"syscall"
24
25
"time"
@@ -45,12 +46,22 @@ func nativeGetPortsList() ([]string, error) {
45
46
}
46
47
defer key .Close ()
47
48
48
- list , err := key .ReadValueNames (0 )
49
+ names , err := key .ReadValueNames (0 )
49
50
if err != nil {
50
51
return nil , & PortError {code : ErrorEnumeratingPorts , causedBy : err }
51
52
}
52
53
53
- return list , nil
54
+ var values []string
55
+ for _ , n := range names {
56
+ v , _ , err := key .GetStringValue (n )
57
+ if err != nil || v == "" {
58
+ continue
59
+ }
60
+
61
+ values = append (values , v )
62
+ }
63
+
64
+ return values , nil
54
65
}
55
66
56
67
func (port * windowsPort ) Close () error {
@@ -342,7 +353,9 @@ func createOverlappedEvent() (*windows.Overlapped, error) {
342
353
}
343
354
344
355
func nativeOpen (portName string , mode * Mode ) (* windowsPort , error ) {
345
- portName = "\\ \\ .\\ " + portName
356
+ if ! strings .HasPrefix (portName , `\\.\` ) {
357
+ portName = `\\.\` + portName
358
+ }
346
359
path , err := windows .UTF16PtrFromString (portName )
347
360
if err != nil {
348
361
return nil , err
You can’t perform that action at this time.
0 commit comments